1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : BasicGUI_MarkerDlg.cxx
25 // Author : Sergey LITONIN
29 #include "BasicGUI_MarkerDlg.h"
30 #include "DlgRef_SpinBox.h"
32 #include "SUIT_Desktop.h"
33 #include "SUIT_Session.h"
34 #include "SalomeApp_Application.h"
35 #include "LightApp_SelectionMgr.h"
39 #include "GEOMImpl_Types.hxx"
40 #include "utilities.h"
45 #include <TopoDS_Vertex.hxx>
46 #include <TopoDS_Face.hxx>
47 #include <TColStd_IndexedMapOfInteger.hxx>
48 #include <TopTools_IndexedMapOfShape.hxx>
49 #include <BRep_Tool.hxx>
52 #include <Geom_Plane.hxx>
53 #include <GProp_GProps.hxx>
54 #include <BRepGProp.hxx>
56 //=================================================================================
57 // class : BasicGUI_MarkerDlg()
58 // purpose : Constructor
59 //=================================================================================
60 BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* theParent )
61 : GEOMBase_Skeleton(theGeometryGUI, theParent, "BasicGUI_MarkerDlg", false,
62 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
64 QPixmap iconCS1 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER" ) ) );
65 QPixmap iconCS2 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER2" ) ) );
66 QPixmap iconCS3 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER3" ) ) );
67 QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
69 setCaption( tr( "CAPTION" ) );
71 GroupConstructors->setTitle( tr( "LOCALCS" ) );
72 RadioButton1->setPixmap( iconCS1 );
73 RadioButton2->setPixmap( iconCS2 );
74 RadioButton3->setPixmap( iconCS3 );
76 Group1 = new DlgRef_1Sel_QTD(this, "Group1");
77 Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
78 Group1->TextLabel1->setText(tr("GEOM_OBJECT"));
79 Group1->PushButton1->setPixmap(iconSelect);
81 Group2 = new DlgRef_3Sel_QTD(this, "Group2");
82 Group2->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
83 Group2->TextLabel1->setText(tr("GEOM_POINT"));
84 Group2->TextLabel2->setText(tr("XDIR"));
85 Group2->TextLabel3->setText(tr("YDIR"));
86 Group2->PushButton1->setPixmap(iconSelect);
87 Group2->PushButton2->setPixmap(iconSelect);
88 Group2->PushButton3->setPixmap(iconSelect);
90 aMainGrp = new QGroupBox( 1, Qt::Horizontal, this );
91 aMainGrp->setFrameStyle( QFrame::NoFrame );
92 aMainGrp->setInsideMargin( 0 );
94 QGroupBox* anOriGrp = new QGroupBox( 1, Qt::Vertical, tr( "ORIGIN" ), aMainGrp );
95 new QLabel( tr( "GEOM_X" ), anOriGrp );
96 myData[ X ] = new DlgRef_SpinBox( anOriGrp );
97 new QLabel( tr( "GEOM_Y" ), anOriGrp );
98 myData[ Y ] = new DlgRef_SpinBox( anOriGrp );
99 new QLabel( tr( "GEOM_Z" ), anOriGrp );
100 myData[ Z ] = new DlgRef_SpinBox( anOriGrp );
102 QGroupBox* aXAxisGrp = new QGroupBox( 1, Qt::Vertical, tr( "XDIR" ), aMainGrp );
103 new QLabel( tr( "DX" ), aXAxisGrp );
104 myData[ DX1 ] = new DlgRef_SpinBox( aXAxisGrp );
105 new QLabel( tr( "DY" ), aXAxisGrp );
106 myData[ DY1 ] = new DlgRef_SpinBox( aXAxisGrp );
107 new QLabel( tr( "DZ" ), aXAxisGrp );
108 myData[ DZ1 ] = new DlgRef_SpinBox( aXAxisGrp );
110 QGroupBox* anYAxisGrp = new QGroupBox( 1, Qt::Vertical, tr( "YDIR" ), aMainGrp );
111 new QLabel( tr( "DX" ), anYAxisGrp );
112 myData[ DX2 ] = new DlgRef_SpinBox( anYAxisGrp );
113 new QLabel( tr( "DY" ), anYAxisGrp );
114 myData[ DY2 ] = new DlgRef_SpinBox( anYAxisGrp );
115 new QLabel( tr( "DZ" ), anYAxisGrp );
116 myData[ DZ2 ] = new DlgRef_SpinBox( anYAxisGrp );
118 Layout1->addWidget( aMainGrp, 2, 0 );
119 Layout1->addWidget( Group1, 2, 0 );
120 Layout1->addWidget( Group2, 2, 0 );
122 setHelpFileName("local_coordinate_system.htm");
128 //=================================================================================
129 // function : ~BasicGUI_MarkerDlg()
130 // purpose : Destroys the object and frees any allocated resources
131 //=================================================================================
132 BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
137 //=================================================================================
140 //=================================================================================
141 void BasicGUI_MarkerDlg::Init()
143 myBlockPreview = false;
144 myConstructorId = -1;
145 myEditCurrentArgument = Group1->LineEdit1;
146 Group1->LineEdit1->setReadOnly( true );
147 Group2->LineEdit1->setReadOnly( true );
148 Group2->LineEdit2->setReadOnly( true );
149 Group2->LineEdit3->setReadOnly( true );
151 connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
152 connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
153 connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
154 connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
155 connect(Group2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
157 connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
158 connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
159 connect(Group2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
160 connect(Group2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
162 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( onClose() ) );
163 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
164 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onClose() ) );
166 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( onOk() ) );
167 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
169 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
170 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
172 initName( tr( "LCS_NAME" ) );
174 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
175 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
177 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
179 anIter.data()->RangeStepAndValidator( -999.999, 999.999, step, 3 );
180 connect( anIter.data(), SIGNAL( valueChanged( double ) ),
181 this, SLOT( onValueChanged( double ) ) );
184 myBlockPreview = true;
185 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
186 anIter.data()->SetValue( 0 );
187 myData[ DX1 ]->SetValue( 1 );
188 myData[ DY2 ]->SetValue( 1 );
189 myBlockPreview = false;
191 ConstructorsClicked( 0 );
196 QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()->
197 getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
199 VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>( aFrame );
202 aVTKFrame->AdjustTrihedrons( true );
206 OCCViewer_ViewFrame* aOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( aFrame );
208 aOCCFrame->AdjustTrihedrons( true );
212 //=================================================================================
213 // function : ConstructorsClicked()
214 // purpose : Radio button management
215 //=================================================================================
216 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
218 if ( myConstructorId == constructorId && myConstructorId == 0 )
220 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
221 activate( GEOM_MARKER );
226 myConstructorId = constructorId;
228 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
230 switch (constructorId)
238 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
239 activate( GEOM_MARKER );
249 globalSelection( GEOM_ALLGEOM );
250 myEditCurrentArgument = Group1->LineEdit1;
251 Group1->LineEdit1->setText("");
261 globalSelection( GEOM_POINT );
262 myEditCurrentArgument = Group2->LineEdit1;
263 Group2->LineEdit1->setText("");
264 Group2->LineEdit2->setText("");
265 Group2->LineEdit3->setText("");
270 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
271 SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone()));
275 //=================================================================================
278 //=================================================================================
279 void BasicGUI_MarkerDlg::onOk()
285 //=======================================================================
286 // function : onClose()
288 //=======================================================================
289 void BasicGUI_MarkerDlg::onClose()
291 GEOMBase_Skeleton::ClickOnCancel();
294 //=================================================================================
295 // function : onApply()
297 //=================================================================================
298 bool BasicGUI_MarkerDlg::onApply()
304 ConstructorsClicked( getConstructorId() );
309 //=================================================================================
310 // function : onSelectionDone0()
311 // purpose : Reaction on selection when first method of creation is current one
312 //=================================================================================
313 void BasicGUI_MarkerDlg::onSelectionDone0()
315 if ( IObjectCount() == 1 )
318 Standard_Boolean aRes = Standard_False;
319 Handle(SALOME_InteractiveObject) anIO = firstIObject();
320 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
322 if ( aRes && !aSelectedObj->_is_nil() )
325 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() )
327 if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE )
329 TopoDS_Face aFace = TopoDS::Face( aShape );
330 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
332 if ( !aPlane.IsNull() )
334 gp_Ax3 anAx3 = aPlane->Pln().Position();
335 gp_Pnt aLoc = anAx3.Location();
336 gp_Dir aXDir = anAx3.XDirection();
337 gp_Dir aYDir = anAx3.YDirection();
339 myData[ X ]->SetValue( aLoc.X() );
340 myData[ Y ]->SetValue( aLoc.Y() );
341 myData[ Z ]->SetValue( aLoc.Z() );
343 myData[ DX1 ]->SetValue( aXDir.X() );
344 myData[ DY1 ]->SetValue( aXDir.Y() );
345 myData[ DZ1 ]->SetValue( aXDir.Z() );
347 myData[ DX2 ]->SetValue( aYDir.X() );
348 myData[ DY2 ]->SetValue( aYDir.Y() );
349 myData[ DZ2 ]->SetValue( aYDir.Z() );
350 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected();
355 TColStd_IndexedMapOfInteger aMap;
356 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap );
357 if ( aMap.Extent() == 1 )
359 int anIndex = aMap( 1 );
360 TopTools_IndexedMapOfShape aShapes;
361 TopExp::MapShapes( aShape, aShapes );
362 aShape = aShapes.FindKey( anIndex );
363 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected();
367 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
369 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
370 myData[ X ]->SetValue( aPnt.X() );
371 myData[ Y ]->SetValue( aPnt.Y() );
372 myData[ Z ]->SetValue( aPnt.Z() );
383 //=================================================================================
384 // function : onSelectionDone()
385 // purpose : Called when selection as changed or other case
386 //=================================================================================
387 void BasicGUI_MarkerDlg::onSelectionDone()
389 if ( getConstructorId() == 0 )
396 myEditCurrentArgument->setText("");
399 if ( IObjectCount() == 1 ) {
400 Standard_Boolean aRes = Standard_False;
401 Handle(SALOME_InteractiveObject) anIO = firstIObject();
402 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
404 if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
405 aName = GEOMBase::GetName( aSelectedObj );
407 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
408 GEOM::short_array anIndexes;
410 TColStd_IndexedMapOfInteger aMap;
411 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap );
413 if ( !aMap.IsEmpty() ) {
414 int anIndex = aMap( 1 );
415 TopTools_IndexedMapOfShape aShapes;
416 TopExp::MapShapes( aShape, aShapes );
417 aShape = aShapes.FindKey( anIndex );
420 if ( getConstructorId() == 1 ) {
421 if ( !aShape.IsNull() ) {
423 if (aShape.ShapeType() == TopAbs_VERTEX) {
424 aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
427 GProp_GProps aSystem;
428 if (aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE)
429 BRepGProp::LinearProperties(aShape, aSystem);
430 else if (aShape.ShapeType() == TopAbs_FACE || aShape.ShapeType() == TopAbs_SHELL)
431 BRepGProp::SurfaceProperties(aShape, aSystem);
433 BRepGProp::VolumeProperties(aShape, aSystem);
435 aPnt = aSystem.CentreOfMass();
439 anAx3.Transform(aShape.Location().Transformation());
440 if(aShape.ShapeType() == TopAbs_FACE) {
441 Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShape ) );
442 if (!aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) {
443 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS );
444 gp_Pln aPln = aGPlane->Pln();
445 anAx3 = aPln.Position();
449 gp_Dir aDirX = anAx3.XDirection();
450 gp_Dir aDirY = anAx3.YDirection();
452 myData[ X ]->SetValue( aPnt.X() );
453 myData[ Y ]->SetValue( aPnt.Y() );
454 myData[ Z ]->SetValue( aPnt.Z() );
456 myData[ DX1 ]->SetValue( aDirX.X() );
457 myData[ DY1 ]->SetValue( aDirX.Y() );
458 myData[ DZ1 ]->SetValue( aDirX.Z() );
460 myData[ DX2 ]->SetValue( aDirY.X() );
461 myData[ DY2 ]->SetValue( aDirY.Y() );
462 myData[ DZ2 ]->SetValue( aDirY.Z() );
464 myEditCurrentArgument->setText( aName );
467 myData[ X ]->SetValue( 0 );
468 myData[ Y ]->SetValue( 0 );
469 myData[ Z ]->SetValue( 0 );
471 myData[ DX1 ]->SetValue( 0 );
472 myData[ DY1 ]->SetValue( 0 );
473 myData[ DZ1 ]->SetValue( 0 );
475 myData[ DX2 ]->SetValue( 0 );
476 myData[ DY2 ]->SetValue( 0 );
477 myData[ DZ2 ]->SetValue( 0 );
480 else if ( getConstructorId() == 2 ) {
481 if (myEditCurrentArgument == Group2->LineEdit1) {
482 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
483 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
484 myData[ X ]->SetValue( aPnt.X() );
485 myData[ Y ]->SetValue( aPnt.Y() );
486 myData[ Z ]->SetValue( aPnt.Z() );
487 myEditCurrentArgument->setText( aName );
490 myData[ X ]->SetValue( 0 );
491 myData[ Y ]->SetValue( 0 );
492 myData[ Z ]->SetValue( 0 );
495 else if (myEditCurrentArgument == Group2->LineEdit2) {
496 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
497 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape)));
498 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape)));
499 gp_Dir aDir(gp_Vec(aP1, aP2));
501 myData[ DX1 ]->SetValue( aDir.X() );
502 myData[ DY1 ]->SetValue( aDir.Y() );
503 myData[ DZ1 ]->SetValue( aDir.Z() );
504 myEditCurrentArgument->setText( aName );
507 myData[ DX1 ]->SetValue( 0 );
508 myData[ DY1 ]->SetValue( 0 );
509 myData[ DZ1 ]->SetValue( 0 );
512 else if (myEditCurrentArgument == Group2->LineEdit3) {
513 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
514 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape)));
515 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape)));
516 gp_Dir aDir(gp_Vec(aP1, aP2));
518 myData[ DX2 ]->SetValue( aDir.X() );
519 myData[ DY2 ]->SetValue( aDir.Y() );
520 myData[ DZ2 ]->SetValue( aDir.Z() );
521 myEditCurrentArgument->setText( aName );
524 myData[ DX2 ]->SetValue( 0 );
525 myData[ DY2 ]->SetValue( 0 );
526 myData[ DZ2 ]->SetValue( 0 );
534 if ( getConstructorId() == 1 ) {
535 myData[ X ]->SetValue( 0 );
536 myData[ Y ]->SetValue( 0 );
537 myData[ Z ]->SetValue( 0 );
539 myData[ DX1 ]->SetValue( 0 );
540 myData[ DY1 ]->SetValue( 0 );
541 myData[ DZ1 ]->SetValue( 0 );
543 myData[ DX2 ]->SetValue( 0 );
544 myData[ DY2 ]->SetValue( 0 );
545 myData[ DZ2 ]->SetValue( 0 );
547 else if ( getConstructorId() == 2 ) {
548 if (myEditCurrentArgument == Group2->LineEdit1) {
549 myData[ X ]->SetValue( 0 );
550 myData[ Y ]->SetValue( 0 );
551 myData[ Z ]->SetValue( 0 );
553 else if (myEditCurrentArgument == Group2->LineEdit2) {
554 myData[ DX1 ]->SetValue( 0 );
555 myData[ DY1 ]->SetValue( 0 );
556 myData[ DZ1 ]->SetValue( 0 );
558 else if (myEditCurrentArgument == Group2->LineEdit3) {
559 myData[ DX2 ]->SetValue( 0 );
560 myData[ DY2 ]->SetValue( 0 );
561 myData[ DZ2 ]->SetValue( 0 );
569 //=================================================================================
570 // function : SetEditCurrentArgument()
572 //=================================================================================
573 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
575 QPushButton* send = (QPushButton*)sender();
577 if(send == Group1->PushButton1) {
578 myEditCurrentArgument = Group1->LineEdit1;
579 globalSelection( GEOM_ALLGEOM );
581 else if(send == Group2->PushButton1) {
582 myEditCurrentArgument = Group2->LineEdit1;
583 globalSelection( GEOM_POINT );
585 else if(send == Group2->PushButton2) {
586 myEditCurrentArgument = Group2->LineEdit2;
587 globalSelection( GEOM_LINE );
589 else if(send == Group2->PushButton3) {
590 myEditCurrentArgument = Group2->LineEdit3;
591 globalSelection( GEOM_LINE );
594 myEditCurrentArgument->setFocus();
598 //=================================================================================
599 // function : LineEditReturnPressed()
601 //=================================================================================
602 void BasicGUI_MarkerDlg::LineEditReturnPressed()
604 QLineEdit* send = (QLineEdit*)sender();
606 myEditCurrentArgument = send;
607 GEOMBase_Skeleton::LineEditReturnPressed();
610 //=================================================================================
611 // function : onActivate()
613 //=================================================================================
614 void BasicGUI_MarkerDlg::onActivate()
616 GEOMBase_Skeleton::ActivateThisDialog();
617 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
618 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
620 ConstructorsClicked( getConstructorId() );
623 //=================================================================================
624 // function : onDeactivate()
625 // purpose : public slot to deactivate if active
626 //=================================================================================
627 void BasicGUI_MarkerDlg::onDeactivate()
629 GEOMBase_Skeleton::DeactivateActiveDialog();
632 //=================================================================================
633 // function : enterEvent()
635 //=================================================================================
636 void BasicGUI_MarkerDlg::enterEvent(QEvent* e)
638 if ( !GroupConstructors->isEnabled() )
642 //=================================================================================
643 // function : createOperation
645 //=================================================================================
646 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
648 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
651 //=================================================================================
652 // function : isValid
654 //=================================================================================
655 bool BasicGUI_MarkerDlg::isValid( QString& msg )
657 const int id = getConstructorId();
658 gp_Vec v1( myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue() ),
659 v2( myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() );
662 // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
663 // Vectors shouldn't be checked for being orthogonal here!
664 if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
665 isOk = !v1.IsParallel( v2, Precision::Angular() );
667 msg += tr( "VEC_PARALLEL" );
675 return !Group1->LineEdit1->text().isEmpty() && isOk;
677 return !Group2->LineEdit1->text().isEmpty() &&
678 !Group2->LineEdit2->text().isEmpty() &&
679 !Group2->LineEdit3->text().isEmpty() && isOk;
684 //=================================================================================
685 // function : execute
687 //=================================================================================
688 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
690 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow(
691 getOperation() )->MakeMarker( myData[ X ]->GetValue(), myData[ Y ]->GetValue(), myData[ Z ]->GetValue(),
692 myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue(),
693 myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() );
695 if ( !anObj->_is_nil() )
696 objects.push_back( anObj._retn() );
701 //=================================================================================
702 // function : closeEvent
704 //=================================================================================
705 void BasicGUI_MarkerDlg::closeEvent( QCloseEvent* e )
707 GEOMBase_Skeleton::closeEvent( e );
710 //=================================================================================
711 // function : onValueChanged
713 //=================================================================================
714 void BasicGUI_MarkerDlg::onValueChanged( double )
719 //=================================================================================
720 // function : displayPreview
722 //=================================================================================
723 void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
725 const bool toRemoveFromEngine,
726 const double lineWidth )
728 if ( !myBlockPreview )
730 GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
731 if ( myConstructorId == 0 )
733 GEOMBase_Skeleton::activate( GEOM_MARKER );