1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : BasicGUI_MarkerDlg.cxx
24 // Author : Sergey LITONIN
28 #include "BasicGUI_MarkerDlg.h"
29 #include "DlgRef_SpinBox.h"
31 #include "SUIT_Desktop.h"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "LightApp_SelectionMgr.h"
38 #include "GEOMImpl_Types.hxx"
40 #include "utilities.h"
43 #include <BRep_Tool.hxx>
47 #include <TopoDS_Vertex.hxx>
48 #include <TopoDS_Face.hxx>
49 #include <Geom_Plane.hxx>
50 #include <TopTools_IndexedMapOfShape.hxx>
51 #include <TColStd_IndexedMapOfInteger.hxx>
55 //=================================================================================
56 // class : BasicGUI_MarkerDlg()
57 // purpose : Constructor
58 //=================================================================================
59 BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* theParent )
60 : GEOMBase_Skeleton(theGeometryGUI, theParent, "BasicGUI_MarkerDlg", false,
61 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
63 QPixmap iconCS1 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER" ) ) );
64 QPixmap iconCS2 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER2" ) ) );
65 QPixmap iconCS3 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER3" ) ) );
66 QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
68 setCaption( tr( "CAPTION" ) );
70 GroupConstructors->setTitle( tr( "LOCALCS" ) );
71 RadioButton1->setPixmap( iconCS1 );
72 RadioButton2->setPixmap( iconCS2 );
73 RadioButton3->setPixmap( iconCS3 );
75 Group1 = new DlgRef_1Sel_QTD(this, "Group1");
76 Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
77 Group1->TextLabel1->setText(tr("GEOM_OBJECT"));
78 Group1->PushButton1->setPixmap(iconSelect);
80 Group2 = new DlgRef_3Sel_QTD(this, "Group2");
81 Group2->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
82 Group2->TextLabel1->setText(tr("GEOM_POINT"));
83 Group2->TextLabel2->setText(tr("XDIR"));
84 Group2->TextLabel3->setText(tr("YDIR"));
85 Group2->PushButton1->setPixmap(iconSelect);
86 Group2->PushButton2->setPixmap(iconSelect);
87 Group2->PushButton3->setPixmap(iconSelect);
89 aMainGrp = new QGroupBox( 1, Qt::Horizontal, this );
90 aMainGrp->setFrameStyle( QFrame::NoFrame );
91 aMainGrp->setInsideMargin( 0 );
93 QGroupBox* anOriGrp = new QGroupBox( 1, Qt::Vertical, tr( "ORIGIN" ), aMainGrp );
94 new QLabel( tr( "GEOM_X" ), anOriGrp );
95 myData[ X ] = new DlgRef_SpinBox( anOriGrp );
96 new QLabel( tr( "GEOM_Y" ), anOriGrp );
97 myData[ Y ] = new DlgRef_SpinBox( anOriGrp );
98 new QLabel( tr( "GEOM_Z" ), anOriGrp );
99 myData[ Z ] = new DlgRef_SpinBox( anOriGrp );
101 QGroupBox* aXAxisGrp = new QGroupBox( 1, Qt::Vertical, tr( "XDIR" ), aMainGrp );
102 new QLabel( tr( "DX" ), aXAxisGrp );
103 myData[ DX1 ] = new DlgRef_SpinBox( aXAxisGrp );
104 new QLabel( tr( "DY" ), aXAxisGrp );
105 myData[ DY1 ] = new DlgRef_SpinBox( aXAxisGrp );
106 new QLabel( tr( "DZ" ), aXAxisGrp );
107 myData[ DZ1 ] = new DlgRef_SpinBox( aXAxisGrp );
109 QGroupBox* anYAxisGrp = new QGroupBox( 1, Qt::Vertical, tr( "YDIR" ), aMainGrp );
110 new QLabel( tr( "DX" ), anYAxisGrp );
111 myData[ DX2 ] = new DlgRef_SpinBox( anYAxisGrp );
112 new QLabel( tr( "DY" ), anYAxisGrp );
113 myData[ DY2 ] = new DlgRef_SpinBox( anYAxisGrp );
114 new QLabel( tr( "DZ" ), anYAxisGrp );
115 myData[ DZ2 ] = new DlgRef_SpinBox( anYAxisGrp );
117 Layout1->addWidget( aMainGrp, 2, 0 );
118 Layout1->addWidget( Group1, 2, 0 );
119 Layout1->addWidget( Group2, 2, 0 );
121 setHelpFileName("create_lcs_page.html");
126 //=================================================================================
127 // function : ~BasicGUI_MarkerDlg()
128 // purpose : Destroys the object and frees any allocated resources
129 //=================================================================================
130 BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
134 //=================================================================================
137 //=================================================================================
138 void BasicGUI_MarkerDlg::Init()
140 myBlockPreview = false;
141 myConstructorId = -1;
142 myEditCurrentArgument = Group1->LineEdit1;
143 Group1->LineEdit1->setReadOnly( true );
144 Group2->LineEdit1->setReadOnly( true );
145 Group2->LineEdit2->setReadOnly( true );
146 Group2->LineEdit3->setReadOnly( true );
148 connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
149 connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
150 connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
151 connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
152 connect(Group2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
154 connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
155 connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
156 connect(Group2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
157 connect(Group2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
159 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( onClose() ) );
160 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
161 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onClose() ) );
163 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( onOk() ) );
164 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
166 connect(myGeomGUI->getApp()->selectionMgr(),
167 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
169 initName( tr( "LCS_NAME" ) );
171 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
172 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
174 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
176 anIter.data()->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY );
177 connect( anIter.data(), SIGNAL( valueChanged( double ) ),
178 this, SLOT( onValueChanged( double ) ) );
181 myBlockPreview = true;
182 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
183 anIter.data()->SetValue( 0 );
184 myData[ DX1 ]->SetValue( 1 );
185 myData[ DY2 ]->SetValue( 1 );
186 myBlockPreview = false;
188 ConstructorsClicked( 0 );
192 QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()->
193 getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
195 VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>( aFrame );
198 aVTKFrame->AdjustTrihedrons( true );
202 OCCViewer_ViewFrame* aOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( aFrame );
204 aOCCFrame->AdjustTrihedrons( true );
208 //=================================================================================
209 // function : ConstructorsClicked()
210 // purpose : Radio button management
211 //=================================================================================
212 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
214 if ( myConstructorId == constructorId && myConstructorId == 0 )
216 globalSelection(); // close local contexts, if any
217 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
218 activate( GEOM_MARKER );
223 myConstructorId = constructorId;
225 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
227 switch (constructorId)
235 globalSelection(); // close local contexts, if any
236 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
237 activate( GEOM_MARKER );
244 //PAL6669: resize(0, 0);
247 globalSelection( GEOM_ALLGEOM );
248 myEditCurrentArgument = Group1->LineEdit1;
249 Group1->LineEdit1->setText("");
256 //PAL6669: resize(0, 0);
259 globalSelection(); // close local contexts, if any
260 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
261 myEditCurrentArgument = Group2->LineEdit1;
262 Group2->LineEdit1->setText("");
263 Group2->LineEdit2->setText("");
264 Group2->LineEdit3->setText("");
269 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
270 this, SLOT(onSelectionDone()));
274 //=================================================================================
277 //=================================================================================
278 void BasicGUI_MarkerDlg::onOk()
284 //=======================================================================
285 // function : onClose()
287 //=======================================================================
288 void BasicGUI_MarkerDlg::onClose()
290 GEOMBase_Skeleton::ClickOnCancel();
293 //=================================================================================
294 // function : onApply()
296 //=================================================================================
297 bool BasicGUI_MarkerDlg::onApply()
303 ConstructorsClicked( getConstructorId() );
308 //=================================================================================
309 // function : onSelectionDone0()
310 // purpose : Reaction on selection when first method of creation is current one
311 //=================================================================================
312 void BasicGUI_MarkerDlg::onSelectionDone0()
314 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 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
322 if (aRes && !aSelectedObj->_is_nil())
325 if (GEOMBase::GetShape(aSelectedObj, aShape, TopAbs_SHAPE) && !aShape.IsNull())
327 // Existing LCS selected
328 if (aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE)
330 TopoDS_Face aFace = TopoDS::Face(aShape);
331 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(aFace));
333 if (!aPlane.IsNull())
335 gp_Ax3 anAx3 = aPlane->Pln().Position();
336 gp_Pnt aLoc = anAx3.Location();
337 gp_Dir aXDir = anAx3.XDirection();
338 gp_Dir aYDir = anAx3.YDirection();
340 myData[ X ]->SetValue( aLoc.X() );
341 myData[ Y ]->SetValue( aLoc.Y() );
342 myData[ Z ]->SetValue( aLoc.Z() );
344 myData[ DX1 ]->SetValue( aXDir.X() );
345 myData[ DY1 ]->SetValue( aXDir.Y() );
346 myData[ DZ1 ]->SetValue( aXDir.Z() );
348 myData[ DX2 ]->SetValue( aYDir.X() );
349 myData[ DY2 ]->SetValue( aYDir.Y() );
350 myData[ DZ2 ]->SetValue( aYDir.Z() );
351 aSelMgr->clearSelected();
356 TColStd_IndexedMapOfInteger aMap;
357 aSelMgr->GetIndexes(anIO, aMap);
358 if (aMap.Extent() == 1) // Local Selection
360 int anIndex = aMap(1);
361 TopTools_IndexedMapOfShape aShapes;
362 TopExp::MapShapes(aShape, aShapes);
363 aShape = aShapes.FindKey(anIndex);
364 aSelMgr->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() );
382 //=================================================================================
383 // function : onSelectionDone()
384 // purpose : Called when selection as changed or other case
385 //=================================================================================
386 void BasicGUI_MarkerDlg::onSelectionDone()
388 if (getConstructorId() == 0) {
393 myEditCurrentArgument->setText("");
395 if (IObjectCount() == 1) {
396 Standard_Boolean aRes = Standard_False;
397 Handle(SALOME_InteractiveObject) anIO = firstIObject();
398 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
400 if (!CORBA::is_nil(aSelectedObj) && aRes) {
401 QString aName = GEOMBase::GetName(aSelectedObj);
403 if (getConstructorId() == 1) { // by shape position
404 // Get shape's position
405 CORBA::Double Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz, Yx,Yy,Yz;
406 Ox = Oy = Oz = Zx = Zy = Xy = Xz = Yx = Yz = 0;
409 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
410 myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId());
411 aMeasureOp->GetPosition(aSelectedObj, Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz);
413 // Calculate Y direction
414 if (aMeasureOp->IsDone()) {
415 gp_Pnt aPnt (Ox,Oy,Oz);
416 gp_Dir aDirN (Zx,Zy,Zz);
417 gp_Dir aDirX (Xx,Xy,Xz);
418 gp_Ax3 anAx3 (aPnt, aDirN, aDirX);
420 gp_Dir aDirY = anAx3.YDirection();
421 aDirY.Coord(Yx,Yy,Yz);
425 myData[ X ]->SetValue( Ox );
426 myData[ Y ]->SetValue( Oy );
427 myData[ Z ]->SetValue( Oz );
429 myData[ DX1 ]->SetValue( Xx );
430 myData[ DY1 ]->SetValue( Xy );
431 myData[ DZ1 ]->SetValue( Xz );
433 myData[ DX2 ]->SetValue( Yx );
434 myData[ DY2 ]->SetValue( Yy );
435 myData[ DZ2 ]->SetValue( Yz );
437 myEditCurrentArgument->setText(aName);
439 else if (getConstructorId() == 2) { // by point and two vectors
441 if (GEOMBase::GetShape(aSelectedObj, aShape, TopAbs_SHAPE))
443 TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
444 if (myEditCurrentArgument == Group2->LineEdit1)
445 aNeedType = TopAbs_VERTEX;
447 TColStd_IndexedMapOfInteger aMap;
448 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
449 aSelMgr->GetIndexes(anIO, aMap);
451 if (!aMap.IsEmpty()) {
452 int anIndex = aMap(1);
453 if (aNeedType == TopAbs_EDGE)
454 aName += QString("_edge_%1").arg(anIndex);
456 aName += QString("_vertex_%1").arg(anIndex);
458 TopTools_IndexedMapOfShape aShapes;
459 TopExp::MapShapes(aShape, aShapes);
460 aShape = aShapes.FindKey(anIndex);
463 if (myEditCurrentArgument == Group2->LineEdit1) {
464 if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) {
465 gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
466 myData[ X ]->SetValue( aPnt.X() );
467 myData[ Y ]->SetValue( aPnt.Y() );
468 myData[ Z ]->SetValue( aPnt.Z() );
469 myEditCurrentArgument->setText(aName);
472 myData[ X ]->SetValue( 0 );
473 myData[ Y ]->SetValue( 0 );
474 myData[ Z ]->SetValue( 0 );
477 else if (myEditCurrentArgument == Group2->LineEdit2) {
478 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
479 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape)));
480 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape)));
481 gp_Dir aDir (gp_Vec(aP1, aP2));
483 myData[ DX1 ]->SetValue( aDir.X() );
484 myData[ DY1 ]->SetValue( aDir.Y() );
485 myData[ DZ1 ]->SetValue( aDir.Z() );
486 myEditCurrentArgument->setText(aName);
489 myData[ DX1 ]->SetValue( 0 );
490 myData[ DY1 ]->SetValue( 0 );
491 myData[ DZ1 ]->SetValue( 0 );
494 else if (myEditCurrentArgument == Group2->LineEdit3) {
495 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
496 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape)));
497 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape)));
498 gp_Dir aDir(gp_Vec(aP1, aP2));
500 myData[ DX2 ]->SetValue( aDir.X() );
501 myData[ DY2 ]->SetValue( aDir.Y() );
502 myData[ DZ2 ]->SetValue( aDir.Z() );
503 myEditCurrentArgument->setText(aName);
506 myData[ DX2 ]->SetValue( 0 );
507 myData[ DY2 ]->SetValue( 0 );
508 myData[ DZ2 ]->SetValue( 0 );
516 if ( getConstructorId() == 1 ) {
517 myData[ X ]->SetValue( 0 );
518 myData[ Y ]->SetValue( 0 );
519 myData[ Z ]->SetValue( 0 );
521 myData[ DX1 ]->SetValue( 0 );
522 myData[ DY1 ]->SetValue( 0 );
523 myData[ DZ1 ]->SetValue( 0 );
525 myData[ DX2 ]->SetValue( 0 );
526 myData[ DY2 ]->SetValue( 0 );
527 myData[ DZ2 ]->SetValue( 0 );
529 else if ( getConstructorId() == 2 ) {
530 if (myEditCurrentArgument == Group2->LineEdit1) {
531 myData[ X ]->SetValue( 0 );
532 myData[ Y ]->SetValue( 0 );
533 myData[ Z ]->SetValue( 0 );
535 else if (myEditCurrentArgument == Group2->LineEdit2) {
536 myData[ DX1 ]->SetValue( 0 );
537 myData[ DY1 ]->SetValue( 0 );
538 myData[ DZ1 ]->SetValue( 0 );
540 else if (myEditCurrentArgument == Group2->LineEdit3) {
541 myData[ DX2 ]->SetValue( 0 );
542 myData[ DY2 ]->SetValue( 0 );
543 myData[ DZ2 ]->SetValue( 0 );
551 //=================================================================================
552 // function : SetEditCurrentArgument()
554 //=================================================================================
555 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
557 QPushButton* send = (QPushButton*)sender();
559 if (send == Group1->PushButton1) {
560 myEditCurrentArgument = Group1->LineEdit1;
561 globalSelection( GEOM_ALLGEOM );
563 else if (send == Group2->PushButton1) {
564 myEditCurrentArgument = Group2->LineEdit1;
565 //globalSelection( GEOM_POINT );
566 globalSelection(); // close local contexts, if any
567 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
569 else if (send == Group2->PushButton2) {
570 myEditCurrentArgument = Group2->LineEdit2;
571 //globalSelection( GEOM_LINE );
572 globalSelection(); // close local contexts, if any
573 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
575 else if (send == Group2->PushButton3) {
576 myEditCurrentArgument = Group2->LineEdit3;
577 globalSelection(); // close local contexts, if any
578 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
581 myEditCurrentArgument->setFocus();
585 //=================================================================================
586 // function : LineEditReturnPressed()
588 //=================================================================================
589 void BasicGUI_MarkerDlg::LineEditReturnPressed()
591 QLineEdit* send = (QLineEdit*)sender();
593 myEditCurrentArgument = send;
594 GEOMBase_Skeleton::LineEditReturnPressed();
597 //=================================================================================
598 // function : onActivate()
600 //=================================================================================
601 void BasicGUI_MarkerDlg::onActivate()
603 GEOMBase_Skeleton::ActivateThisDialog();
604 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
605 this, SLOT(onSelectionDone()));
607 ConstructorsClicked(getConstructorId());
610 //=================================================================================
611 // function : onDeactivate()
612 // purpose : public slot to deactivate if active
613 //=================================================================================
614 void BasicGUI_MarkerDlg::onDeactivate()
616 GEOMBase_Skeleton::DeactivateActiveDialog();
619 //=================================================================================
620 // function : enterEvent()
622 //=================================================================================
623 void BasicGUI_MarkerDlg::enterEvent(QEvent* e)
625 if ( !GroupConstructors->isEnabled() )
629 //=================================================================================
630 // function : createOperation
632 //=================================================================================
633 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
635 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
638 //=================================================================================
639 // function : isValid
641 //=================================================================================
642 bool BasicGUI_MarkerDlg::isValid( QString& msg )
644 const int id = getConstructorId();
645 gp_Vec v1( myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue() ),
646 v2( myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() );
649 // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
650 // Vectors shouldn't be checked for being orthogonal here!
651 if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
652 isOk = !v1.IsParallel( v2, Precision::Angular() );
654 msg += tr( "VEC_PARALLEL" );
662 return !Group1->LineEdit1->text().isEmpty() && isOk;
664 return !Group2->LineEdit1->text().isEmpty() &&
665 !Group2->LineEdit2->text().isEmpty() &&
666 !Group2->LineEdit3->text().isEmpty() && isOk;
671 //=================================================================================
672 // function : execute
674 //=================================================================================
675 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
677 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow(getOperation())->
678 MakeMarker(myData[ X ]->GetValue(), myData[ Y ]->GetValue(), myData[ Z ]->GetValue(),
679 myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue(),
680 myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue());
682 if ( !anObj->_is_nil() )
683 objects.push_back( anObj._retn() );
688 //=================================================================================
689 // function : closeEvent
691 //=================================================================================
692 void BasicGUI_MarkerDlg::closeEvent( QCloseEvent* e )
694 GEOMBase_Skeleton::closeEvent( e );
697 //=================================================================================
698 // function : onValueChanged
700 //=================================================================================
701 void BasicGUI_MarkerDlg::onValueChanged( double )
706 //=================================================================================
707 // function : displayPreview
709 //=================================================================================
710 void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
712 const bool toRemoveFromEngine,
713 const double lineWidth )
715 if ( !myBlockPreview )
717 GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
718 if ( myConstructorId == 0 )
720 GEOMBase_Skeleton::activate( GEOM_MARKER );