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( theParent, "BasicGUI_MarkerDlg", false,
62 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), myGeometryGUI(theGeometryGUI)
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 );
126 //=================================================================================
127 // function : ~BasicGUI_MarkerDlg()
128 // purpose : Destroys the object and frees any allocated resources
129 //=================================================================================
130 BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
135 //=================================================================================
138 //=================================================================================
139 void BasicGUI_MarkerDlg::Init()
141 myBlockPreview = false;
142 myConstructorId = -1;
143 myEditCurrentArgument = Group1->LineEdit1;
144 Group1->LineEdit1->setReadOnly( true );
145 Group2->LineEdit1->setReadOnly( true );
146 Group2->LineEdit2->setReadOnly( true );
147 Group2->LineEdit3->setReadOnly( true );
149 connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
150 connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
151 connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
152 connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
153 connect(Group2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
155 connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
156 connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
157 connect(Group2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
158 connect(Group2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
160 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( onClose() ) );
161 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
162 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onClose() ) );
164 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( onOk() ) );
165 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
167 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
168 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
170 initName( tr( "LCS_NAME" ) );
172 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
173 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
175 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
177 anIter.data()->RangeStepAndValidator( -999.999, 999.999, step, 3 );
178 connect( anIter.data(), SIGNAL( valueChanged( double ) ),
179 this, SLOT( onValueChanged( double ) ) );
182 myBlockPreview = true;
183 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
184 anIter.data()->SetValue( 0 );
185 myData[ DX1 ]->SetValue( 1 );
186 myData[ DY2 ]->SetValue( 1 );
187 myBlockPreview = false;
189 ConstructorsClicked( 0 );
194 QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()->
195 getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
197 VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>( aFrame );
200 aVTKFrame->AdjustTrihedrons( true );
204 OCCViewer_ViewFrame* aOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( aFrame );
206 aOCCFrame->AdjustTrihedrons( true );
210 //=================================================================================
211 // function : ConstructorsClicked()
212 // purpose : Radio button management
213 //=================================================================================
214 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
216 if ( myConstructorId == constructorId && myConstructorId == 0 )
218 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
219 activate( GEOM_MARKER );
224 myConstructorId = constructorId;
226 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
228 switch (constructorId)
236 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
237 activate( GEOM_MARKER );
247 globalSelection( GEOM_ALLGEOM );
248 myEditCurrentArgument = Group1->LineEdit1;
249 Group1->LineEdit1->setText("");
259 globalSelection( GEOM_POINT );
260 myEditCurrentArgument = Group2->LineEdit1;
261 Group2->LineEdit1->setText("");
262 Group2->LineEdit2->setText("");
263 Group2->LineEdit3->setText("");
268 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
269 SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone()));
273 //=================================================================================
276 //=================================================================================
277 void BasicGUI_MarkerDlg::onOk()
283 //=======================================================================
284 // function : onClose()
286 //=======================================================================
287 void BasicGUI_MarkerDlg::onClose()
289 GEOMBase_Skeleton::ClickOnCancel();
292 //=================================================================================
293 // function : onApply()
295 //=================================================================================
296 bool BasicGUI_MarkerDlg::onApply()
302 ConstructorsClicked( getConstructorId() );
307 //=================================================================================
308 // function : onSelectionDone0()
309 // purpose : Reaction on selection when first method of creation is current one
310 //=================================================================================
311 void BasicGUI_MarkerDlg::onSelectionDone0()
313 if ( IObjectCount() == 1 )
316 Standard_Boolean aRes = Standard_False;
317 Handle(SALOME_InteractiveObject) anIO = firstIObject();
318 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
320 if ( aRes && !aSelectedObj->_is_nil() )
323 if ( myGeomBase->GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() )
325 if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE )
327 TopoDS_Face aFace = TopoDS::Face( aShape );
328 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
330 if ( !aPlane.IsNull() )
332 gp_Ax3 anAx3 = aPlane->Pln().Position();
333 gp_Pnt aLoc = anAx3.Location();
334 gp_Dir aXDir = anAx3.XDirection();
335 gp_Dir aYDir = anAx3.YDirection();
337 myData[ X ]->SetValue( aLoc.X() );
338 myData[ Y ]->SetValue( aLoc.Y() );
339 myData[ Z ]->SetValue( aLoc.Z() );
341 myData[ DX1 ]->SetValue( aXDir.X() );
342 myData[ DY1 ]->SetValue( aXDir.Y() );
343 myData[ DZ1 ]->SetValue( aXDir.Z() );
345 myData[ DX2 ]->SetValue( aYDir.X() );
346 myData[ DY2 ]->SetValue( aYDir.Y() );
347 myData[ DZ2 ]->SetValue( aYDir.Z() );
348 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected();
353 TColStd_IndexedMapOfInteger aMap;
354 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap );
355 if ( aMap.Extent() == 1 )
357 int anIndex = aMap( 1 );
358 TopTools_IndexedMapOfShape aShapes;
359 TopExp::MapShapes( aShape, aShapes );
360 aShape = aShapes.FindKey( anIndex );
361 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected();
365 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
367 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
368 myData[ X ]->SetValue( aPnt.X() );
369 myData[ Y ]->SetValue( aPnt.Y() );
370 myData[ Z ]->SetValue( aPnt.Z() );
381 //=================================================================================
382 // function : onSelectionDone()
383 // purpose : Called when selection as changed or other case
384 //=================================================================================
385 void BasicGUI_MarkerDlg::onSelectionDone()
387 if ( getConstructorId() == 0 )
394 myEditCurrentArgument->setText("");
397 if ( IObjectCount() == 1 ) {
398 Standard_Boolean aRes = Standard_False;
399 Handle(SALOME_InteractiveObject) anIO = firstIObject();
400 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
402 if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
403 aName = GEOMBase::GetName( aSelectedObj );
405 if ( myGeomBase->GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
406 GEOM::short_array anIndexes;
408 TColStd_IndexedMapOfInteger aMap;
409 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap );
411 if ( !aMap.IsEmpty() ) {
412 int anIndex = aMap( 1 );
413 TopTools_IndexedMapOfShape aShapes;
414 TopExp::MapShapes( aShape, aShapes );
415 aShape = aShapes.FindKey( anIndex );
418 if ( getConstructorId() == 1 ) {
419 if ( !aShape.IsNull() ) {
421 if (aShape.ShapeType() == TopAbs_VERTEX) {
422 aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
425 GProp_GProps aSystem;
426 if (aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE)
427 BRepGProp::LinearProperties(aShape, aSystem);
428 else if (aShape.ShapeType() == TopAbs_FACE || aShape.ShapeType() == TopAbs_SHELL)
429 BRepGProp::SurfaceProperties(aShape, aSystem);
431 BRepGProp::VolumeProperties(aShape, aSystem);
433 aPnt = aSystem.CentreOfMass();
437 anAx3.Transform(aShape.Location().Transformation());
438 if(aShape.ShapeType() == TopAbs_FACE) {
439 Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShape ) );
440 if (!aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) {
441 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS );
442 gp_Pln aPln = aGPlane->Pln();
443 anAx3 = aPln.Position();
447 gp_Dir aDirX = anAx3.XDirection();
448 gp_Dir aDirY = anAx3.YDirection();
450 myData[ X ]->SetValue( aPnt.X() );
451 myData[ Y ]->SetValue( aPnt.Y() );
452 myData[ Z ]->SetValue( aPnt.Z() );
454 myData[ DX1 ]->SetValue( aDirX.X() );
455 myData[ DY1 ]->SetValue( aDirX.Y() );
456 myData[ DZ1 ]->SetValue( aDirX.Z() );
458 myData[ DX2 ]->SetValue( aDirY.X() );
459 myData[ DY2 ]->SetValue( aDirY.Y() );
460 myData[ DZ2 ]->SetValue( aDirY.Z() );
462 myEditCurrentArgument->setText( aName );
465 myData[ X ]->SetValue( 0 );
466 myData[ Y ]->SetValue( 0 );
467 myData[ Z ]->SetValue( 0 );
469 myData[ DX1 ]->SetValue( 0 );
470 myData[ DY1 ]->SetValue( 0 );
471 myData[ DZ1 ]->SetValue( 0 );
473 myData[ DX2 ]->SetValue( 0 );
474 myData[ DY2 ]->SetValue( 0 );
475 myData[ DZ2 ]->SetValue( 0 );
478 else if ( getConstructorId() == 2 ) {
479 if (myEditCurrentArgument == Group2->LineEdit1) {
480 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
481 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
482 myData[ X ]->SetValue( aPnt.X() );
483 myData[ Y ]->SetValue( aPnt.Y() );
484 myData[ Z ]->SetValue( aPnt.Z() );
485 myEditCurrentArgument->setText( aName );
488 myData[ X ]->SetValue( 0 );
489 myData[ Y ]->SetValue( 0 );
490 myData[ Z ]->SetValue( 0 );
493 else if (myEditCurrentArgument == Group2->LineEdit2) {
494 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
495 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape)));
496 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape)));
497 gp_Dir aDir(gp_Vec(aP1, aP2));
499 myData[ DX1 ]->SetValue( aDir.X() );
500 myData[ DY1 ]->SetValue( aDir.Y() );
501 myData[ DZ1 ]->SetValue( aDir.Z() );
502 myEditCurrentArgument->setText( aName );
505 myData[ DX1 ]->SetValue( 0 );
506 myData[ DY1 ]->SetValue( 0 );
507 myData[ DZ1 ]->SetValue( 0 );
510 else if (myEditCurrentArgument == Group2->LineEdit3) {
511 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
512 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape)));
513 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape)));
514 gp_Dir aDir(gp_Vec(aP1, aP2));
516 myData[ DX2 ]->SetValue( aDir.X() );
517 myData[ DY2 ]->SetValue( aDir.Y() );
518 myData[ DZ2 ]->SetValue( aDir.Z() );
519 myEditCurrentArgument->setText( aName );
522 myData[ DX2 ]->SetValue( 0 );
523 myData[ DY2 ]->SetValue( 0 );
524 myData[ DZ2 ]->SetValue( 0 );
532 if ( getConstructorId() == 1 ) {
533 myData[ X ]->SetValue( 0 );
534 myData[ Y ]->SetValue( 0 );
535 myData[ Z ]->SetValue( 0 );
537 myData[ DX1 ]->SetValue( 0 );
538 myData[ DY1 ]->SetValue( 0 );
539 myData[ DZ1 ]->SetValue( 0 );
541 myData[ DX2 ]->SetValue( 0 );
542 myData[ DY2 ]->SetValue( 0 );
543 myData[ DZ2 ]->SetValue( 0 );
545 else if ( getConstructorId() == 2 ) {
546 if (myEditCurrentArgument == Group2->LineEdit1) {
547 myData[ X ]->SetValue( 0 );
548 myData[ Y ]->SetValue( 0 );
549 myData[ Z ]->SetValue( 0 );
551 else if (myEditCurrentArgument == Group2->LineEdit2) {
552 myData[ DX1 ]->SetValue( 0 );
553 myData[ DY1 ]->SetValue( 0 );
554 myData[ DZ1 ]->SetValue( 0 );
556 else if (myEditCurrentArgument == Group2->LineEdit3) {
557 myData[ DX2 ]->SetValue( 0 );
558 myData[ DY2 ]->SetValue( 0 );
559 myData[ DZ2 ]->SetValue( 0 );
567 //=================================================================================
568 // function : SetEditCurrentArgument()
570 //=================================================================================
571 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
573 QPushButton* send = (QPushButton*)sender();
575 if(send == Group1->PushButton1) {
576 myEditCurrentArgument = Group1->LineEdit1;
577 globalSelection( GEOM_ALLGEOM );
579 else if(send == Group2->PushButton1) {
580 myEditCurrentArgument = Group2->LineEdit1;
581 globalSelection( GEOM_POINT );
583 else if(send == Group2->PushButton2) {
584 myEditCurrentArgument = Group2->LineEdit2;
585 globalSelection( GEOM_LINE );
587 else if(send == Group2->PushButton3) {
588 myEditCurrentArgument = Group2->LineEdit3;
589 globalSelection( GEOM_LINE );
592 myEditCurrentArgument->setFocus();
596 //=================================================================================
597 // function : LineEditReturnPressed()
599 //=================================================================================
600 void BasicGUI_MarkerDlg::LineEditReturnPressed()
602 QLineEdit* send = (QLineEdit*)sender();
604 myEditCurrentArgument = send;
605 GEOMBase_Skeleton::LineEditReturnPressed();
608 //=================================================================================
609 // function : onActivate()
611 //=================================================================================
612 void BasicGUI_MarkerDlg::onActivate()
614 GEOMBase_Skeleton::ActivateThisDialog();
615 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
616 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
618 ConstructorsClicked( getConstructorId() );
621 //=================================================================================
622 // function : onDeactivate()
623 // purpose : public slot to deactivate if active
624 //=================================================================================
625 void BasicGUI_MarkerDlg::onDeactivate()
627 GEOMBase_Skeleton::DeactivateActiveDialog();
630 //=================================================================================
631 // function : enterEvent()
633 //=================================================================================
634 void BasicGUI_MarkerDlg::enterEvent(QEvent* e)
636 if ( !GroupConstructors->isEnabled() )
640 //=================================================================================
641 // function : createOperation
643 //=================================================================================
644 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
646 return myGeometryGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
649 //=================================================================================
650 // function : isValid
652 //=================================================================================
653 bool BasicGUI_MarkerDlg::isValid( QString& msg )
655 const int id = getConstructorId();
656 gp_Vec v1( myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue() ),
657 v2( myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() );
660 // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
661 // Vectors shouldn't be checked for being orthogonal here!
662 if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
663 isOk = !v1.IsParallel( v2, Precision::Angular() );
665 msg += tr( "VEC_PARALLEL" );
673 return !Group1->LineEdit1->text().isEmpty() && isOk;
675 return !Group2->LineEdit1->text().isEmpty() &&
676 !Group2->LineEdit2->text().isEmpty() &&
677 !Group2->LineEdit3->text().isEmpty() && isOk;
682 //=================================================================================
683 // function : execute
685 //=================================================================================
686 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
688 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow(
689 getOperation() )->MakeMarker( myData[ X ]->GetValue(), myData[ Y ]->GetValue(), myData[ Z ]->GetValue(),
690 myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue(),
691 myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() );
693 if ( !anObj->_is_nil() )
694 objects.push_back( anObj._retn() );
699 //=================================================================================
700 // function : closeEvent
702 //=================================================================================
703 void BasicGUI_MarkerDlg::closeEvent( QCloseEvent* e )
705 GEOMBase_Skeleton::closeEvent( e );
708 //=================================================================================
709 // function : onValueChanged
711 //=================================================================================
712 void BasicGUI_MarkerDlg::onValueChanged( double )
717 //=================================================================================
718 // function : displayPreview
720 //=================================================================================
721 void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
723 const bool toRemoveFromEngine,
724 const double lineWidth )
726 if ( !myBlockPreview )
728 GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
729 if ( myConstructorId == 0 )
731 GEOMBase_Skeleton::activate( GEOM_MARKER );