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, Open CASCADE S.A.S. (sergey.litonin@opencascade.com)
26 #include "BasicGUI_MarkerDlg.h"
29 #include <GeometryGUI.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Session.h>
34 #include <SalomeApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
39 #include <GEOMImpl_Types.hxx>
42 #include <BRep_Tool.hxx>
46 #include <TopoDS_Vertex.hxx>
47 #include <TopoDS_Face.hxx>
48 #include <Geom_Plane.hxx>
49 #include <TopTools_IndexedMapOfShape.hxx>
50 #include <TColStd_IndexedMapOfInteger.hxx>
54 //=================================================================================
55 // class : BasicGUI_MarkerDlg()
56 // purpose : Constructor
57 //=================================================================================
58 BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* theParent )
59 : GEOMBase_Skeleton( theGeometryGUI, theParent, false,
60 Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
62 QPixmap iconCS1 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER" ) ) );
63 QPixmap iconCS2 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER2" ) ) );
64 QPixmap iconCS3 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER3" ) ) );
65 QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
67 setWindowTitle( tr( "CAPTION" ) );
69 mainFrame()->GroupConstructors->setTitle( tr( "LOCALCS" ) );
70 mainFrame()->RadioButton1->setIcon( iconCS1 );
71 mainFrame()->RadioButton2->setIcon( iconCS2 );
72 mainFrame()->RadioButton3->setIcon( iconCS3 );
74 Group1 = new DlgRef_1Sel( centralWidget() );
76 Group1->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
77 Group1->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
78 Group1->PushButton1->setIcon( iconSelect );
79 Group1->PushButton1->setDown( true );
81 Group2 = new DlgRef_3Sel( centralWidget() );
83 Group2->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
84 Group2->TextLabel1->setText( tr( "GEOM_POINT" ) );
85 Group2->TextLabel2->setText( tr( "XDIR" ) );
86 Group2->TextLabel3->setText( tr( "YDIR" ) );
87 Group2->PushButton1->setIcon( iconSelect );
88 Group2->PushButton2->setIcon( iconSelect );
89 Group2->PushButton3->setIcon( iconSelect );
90 Group2->PushButton1->setDown( true );
92 aMainGrp = new QFrame( centralWidget() );
93 aMainGrp->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
94 aMainGrp->setContentsMargins( 0, 0, 0, 0 );
95 QHBoxLayout* aMainGrpLayout = new QHBoxLayout( aMainGrp );
96 aMainGrpLayout->setMargin( 0 );
98 QGroupBox* anOriGrp = new QGroupBox( tr( "ORIGIN" ), aMainGrp );
99 QVBoxLayout* anOriGrpLayout = new QVBoxLayout( anOriGrp );
101 anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), anOriGrp ) );
102 myData[ X ] = new SalomeApp_DoubleSpinBox( anOriGrp );
103 anOriGrpLayout->addWidget( myData[ X ] );
104 anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), anOriGrp ) );
105 myData[ Y ] = new SalomeApp_DoubleSpinBox( anOriGrp );
106 anOriGrpLayout->addWidget( myData[ Y ] );
107 anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), anOriGrp ) );
108 myData[ Z ] = new SalomeApp_DoubleSpinBox( anOriGrp );
109 anOriGrpLayout->addWidget( myData[ Z ] );
111 aMainGrpLayout->addWidget( anOriGrp );
113 QGroupBox* aXAxisGrp = new QGroupBox( tr( "XDIR" ), aMainGrp );
114 QVBoxLayout* aXAxisGrpLayout = new QVBoxLayout( aXAxisGrp );
116 aXAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), aXAxisGrp ) );
117 myData[ DX1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
118 aXAxisGrpLayout->addWidget( myData[ DX1 ] );
119 aXAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), aXAxisGrp ) );
120 myData[ DY1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
121 aXAxisGrpLayout->addWidget( myData[ DY1 ] );
122 aXAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), aXAxisGrp ) );
123 myData[ DZ1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
124 aXAxisGrpLayout->addWidget( myData[ DZ1 ] );
126 aMainGrpLayout->addWidget( aXAxisGrp );
128 QGroupBox* anYAxisGrp = new QGroupBox( tr( "YDIR" ), aMainGrp );
129 QVBoxLayout* anYAxisGrpLayout = new QVBoxLayout( anYAxisGrp );
131 anYAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), anYAxisGrp ) );
132 myData[ DX2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
133 anYAxisGrpLayout->addWidget( myData[ DX2 ] );
134 anYAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), anYAxisGrp ) );
135 myData[ DY2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
136 anYAxisGrpLayout->addWidget( myData[ DY2 ] );
137 anYAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), anYAxisGrp ) );
138 myData[ DZ2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
139 anYAxisGrpLayout->addWidget( myData[ DZ2 ] );
141 aMainGrpLayout->addWidget( anYAxisGrp );
143 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
144 layout->setMargin( 0 ); layout->setSpacing( 6 );
145 layout->addWidget( aMainGrp );
146 layout->addWidget( Group1 );
147 layout->addWidget( Group2 );
149 setHelpFileName( "create_lcs_page.html" );
155 //=================================================================================
156 // function : ~BasicGUI_MarkerDlg()
157 // purpose : Destroys the object and frees any allocated resources
158 //=================================================================================
159 BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
164 //=================================================================================
167 //=================================================================================
168 void BasicGUI_MarkerDlg::Init()
170 myShape = myPoint = myVectorX = myVectorY = GEOM::GEOM_Object::_nil();
171 myBlockPreview = false;
172 myConstructorId = -1;
173 myEditCurrentArgument = Group1->LineEdit1;
174 Group1->LineEdit1->setReadOnly( true );
175 Group2->LineEdit1->setReadOnly( true );
176 Group2->LineEdit2->setReadOnly( true );
177 Group2->LineEdit3->setReadOnly( true );
178 Group2->LineEdit1->setEnabled( true );
179 Group2->LineEdit2->setEnabled( false );
180 Group2->LineEdit3->setEnabled( false );
182 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
184 connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
185 connect( Group2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
186 connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
187 connect( Group2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
189 connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
190 connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
191 connect( Group2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
192 connect( Group2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
194 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
195 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
197 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() ) );
198 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() ) );
200 connect( myGeomGUI->getApp()->selectionMgr(),
201 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
203 initName( tr( "LCS_NAME" ) );
205 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
206 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
208 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) {
209 initSpinBox( anIter.value(), COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
210 connect( anIter.value(), SIGNAL( valueChanged( double ) ),
211 this, SLOT( onValueChanged( double ) ) );
214 myBlockPreview = true;
215 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
216 anIter.value()->setValue( 0 );
217 myData[ DX1 ]->setValue( 1 );
218 myData[ DY2 ]->setValue( 1 );
219 myBlockPreview = false;
221 ConstructorsClicked( 0 );
224 //=================================================================================
225 // function : ConstructorsClicked()
226 // purpose : Radio button management
227 //=================================================================================
228 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
230 if ( myConstructorId == constructorId && myConstructorId == 0 ) {
231 globalSelection(); // close local contexts, if any
232 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
233 activate( GEOM_MARKER );
237 myConstructorId = constructorId;
239 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
241 switch ( constructorId ) {
247 globalSelection(); // close local contexts, if any
248 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
249 activate( GEOM_MARKER );
257 Group1->PushButton1->setDown( true );
258 globalSelection( GEOM_ALLGEOM );
259 myEditCurrentArgument = Group1->LineEdit1;
260 Group1->LineEdit1->setText( "" );
261 myShape = GEOM::GEOM_Object::_nil();
269 Group2->PushButton1->setDown( true );
270 Group2->PushButton2->setDown( false );
271 Group2->PushButton3->setDown( false );
272 globalSelection(); // close local contexts, if any
273 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
274 myEditCurrentArgument = Group2->LineEdit1;
275 Group2->LineEdit1->setText( "" );
276 Group2->LineEdit2->setText( "" );
277 Group2->LineEdit3->setText( "" );
278 Group2->LineEdit1->setEnabled( true );
279 Group2->LineEdit2->setEnabled( false );
280 Group2->LineEdit3->setEnabled( false );
281 myPoint = GEOM::GEOM_Object::_nil();
282 myVectorX = GEOM::GEOM_Object::_nil();
283 myVectorY = GEOM::GEOM_Object::_nil();
290 qApp->processEvents();
292 resize( minimumSizeHint() );
294 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
295 this, SLOT( onSelectionDone() ) );
299 //=================================================================================
302 //=================================================================================
303 void BasicGUI_MarkerDlg::onOk()
309 //=================================================================================
310 // function : onApply()
312 //=================================================================================
313 bool BasicGUI_MarkerDlg::onApply()
319 ConstructorsClicked( getConstructorId() );
324 //=================================================================================
325 // function : onSelectionDone0()
326 // purpose : Reaction on selection when first method of creation is current one
327 //=================================================================================
328 void BasicGUI_MarkerDlg::onSelectionDone0()
330 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
331 SALOME_ListIO aSelList;
332 aSelMgr->selectedObjects(aSelList);
334 if (aSelList.Extent() == 1) {
335 Standard_Boolean aRes = Standard_False;
336 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
337 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
339 if ( aRes && !aSelectedObj->_is_nil() ) {
341 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
342 // Existing LCS selected
343 if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) {
344 TopoDS_Face aFace = TopoDS::Face( aShape );
345 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
347 if ( !aPlane.IsNull() ) {
348 gp_Ax3 anAx3 = aPlane->Pln().Position();
349 gp_Pnt aLoc = anAx3.Location();
350 gp_Dir aXDir = anAx3.XDirection();
351 gp_Dir aYDir = anAx3.YDirection();
353 myData[ X ]->setValue( aLoc.X() );
354 myData[ Y ]->setValue( aLoc.Y() );
355 myData[ Z ]->setValue( aLoc.Z() );
357 myData[ DX1 ]->setValue( aXDir.X() );
358 myData[ DY1 ]->setValue( aXDir.Y() );
359 myData[ DZ1 ]->setValue( aXDir.Z() );
361 myData[ DX2 ]->setValue( aYDir.X() );
362 myData[ DY2 ]->setValue( aYDir.Y() );
363 myData[ DZ2 ]->setValue( aYDir.Z() );
364 aSelMgr->clearSelected();
368 TColStd_IndexedMapOfInteger aMap;
369 aSelMgr->GetIndexes( anIO, aMap );
370 if ( aMap.Extent() == 1 ) { // Local Selection
371 int anIndex = aMap( 1 );
372 TopTools_IndexedMapOfShape aShapes;
373 TopExp::MapShapes( aShape, aShapes );
374 aShape = aShapes.FindKey( anIndex );
375 aSelMgr->clearSelected(); // ???
378 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
379 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
380 myData[ X ]->setValue( aPnt.X() );
381 myData[ Y ]->setValue( aPnt.Y() );
382 myData[ Z ]->setValue( aPnt.Z() );
393 //=================================================================================
394 // function : onSelectionDone()
395 // purpose : Called when selection as changed or other case
396 //=================================================================================
397 void BasicGUI_MarkerDlg::onSelectionDone()
399 if ( getConstructorId() == 0 ) {
404 myEditCurrentArgument->setText( "" );
406 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
407 SALOME_ListIO aSelList;
408 aSelMgr->selectedObjects(aSelList);
410 if (aSelList.Extent() == 1) {
411 Standard_Boolean aRes = Standard_False;
412 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
413 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
415 if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
416 QString aName = GEOMBase::GetName( aSelectedObj );
418 if ( getConstructorId() == 1 ) { // by shape position
420 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
421 myShape = aSelectedObj;
422 myEditCurrentArgument->setText( aName );
424 else if ( getConstructorId() == 2 ) { // by point and two vectors
426 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
427 TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
428 if ( myEditCurrentArgument == Group2->LineEdit1 )
429 aNeedType = TopAbs_VERTEX;
431 TColStd_IndexedMapOfInteger aMap;
432 aSelMgr->GetIndexes( anIO, aMap );
434 if ( aMap.Extent() == 1 ) { // Local Selection
435 int anIndex = aMap( 1 );
436 if ( aNeedType == TopAbs_EDGE )
437 aName += QString( ":edge_%1" ).arg( anIndex );
439 aName += QString( ":vertex_%1" ).arg( anIndex );
441 //Find SubShape Object in Father
442 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObj, aName );
443 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
444 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
445 aSelectedObj = aShapesOp->GetSubShape( aSelectedObj, anIndex );
448 aSelectedObj = aFindedObject; // get Object from study
451 else { // Global Selection
452 if ( aShape.ShapeType() != aNeedType ) {
453 aSelectedObj = GEOM::GEOM_Object::_nil();
458 if ( myEditCurrentArgument == Group2->LineEdit1 ) {
459 myPoint = aSelectedObj;
460 myEditCurrentArgument->setText( aName );
461 if (!myPoint->_is_nil() && Group2->LineEdit2->text() == "")
462 Group2->PushButton2->click();
464 else if (myEditCurrentArgument == Group2->LineEdit2) {
465 myVectorX = aSelectedObj;
466 myEditCurrentArgument->setText( aName );
467 if (!myVectorX->_is_nil() && Group2->LineEdit3->text() == "")
468 Group2->PushButton3->click();
470 else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
471 myVectorY = aSelectedObj;
472 myEditCurrentArgument->setText( aName );
473 if (!myVectorX->_is_nil() && Group2->LineEdit1->text() == "")
474 Group2->PushButton1->click();
481 if ( getConstructorId() == 1 ) {
482 myShape = GEOM::GEOM_Object::_nil();
483 } else if ( getConstructorId() == 2 ) {
484 if ( myEditCurrentArgument == Group2->LineEdit1 )
485 myPoint = GEOM::GEOM_Object::_nil();
486 else if ( myEditCurrentArgument == Group2->LineEdit2 )
487 myVectorX = GEOM::GEOM_Object::_nil();
488 else if ( myEditCurrentArgument == Group2->LineEdit3 )
489 myVectorY = GEOM::GEOM_Object::_nil();
496 //=================================================================================
497 // function : SetEditCurrentArgument()
499 //=================================================================================
500 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
502 QPushButton* send = (QPushButton*)sender();
503 globalSelection(); // close local contexts, if any
505 if ( send == Group1->PushButton1 ) {
506 myEditCurrentArgument = Group1->LineEdit1;
507 globalSelection( GEOM_ALLGEOM );
509 else if ( send == Group2->PushButton1 ) {
510 myEditCurrentArgument = Group2->LineEdit1;
511 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
512 Group2->PushButton2->setDown( false );
513 Group2->PushButton3->setDown( false );
514 Group2->LineEdit1->setEnabled( true );
515 Group2->LineEdit2->setEnabled( false );
516 Group2->LineEdit3->setEnabled( false );
518 else if ( send == Group2->PushButton2 ) {
519 myEditCurrentArgument = Group2->LineEdit2;
520 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
521 Group2->PushButton1->setDown( false );
522 Group2->PushButton3->setDown( false );
523 Group2->LineEdit1->setEnabled( false );
524 Group2->LineEdit2->setEnabled( true );
525 Group2->LineEdit3->setEnabled( false );
527 else if ( send == Group2->PushButton3 ) {
528 myEditCurrentArgument = Group2->LineEdit3;
529 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
530 Group2->PushButton1->setDown( false );
531 Group2->PushButton2->setDown( false );
532 Group2->LineEdit1->setEnabled( false );
533 Group2->LineEdit2->setEnabled( false );
534 Group2->LineEdit3->setEnabled( true );
537 myEditCurrentArgument->setFocus();
542 //=================================================================================
543 // function : LineEditReturnPressed()
545 //=================================================================================
546 void BasicGUI_MarkerDlg::LineEditReturnPressed()
548 QLineEdit* send = (QLineEdit*)sender();
550 myEditCurrentArgument = send;
551 GEOMBase_Skeleton::LineEditReturnPressed();
554 //=================================================================================
555 // function : onActivate()
557 //=================================================================================
558 void BasicGUI_MarkerDlg::onActivate()
560 GEOMBase_Skeleton::ActivateThisDialog();
561 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
562 this, SLOT( onSelectionDone() ) );
564 ConstructorsClicked( getConstructorId() );
567 //=================================================================================
568 // function : onDeactivate()
569 // purpose : public slot to deactivate if active
570 //=================================================================================
571 void BasicGUI_MarkerDlg::onDeactivate()
573 GEOMBase_Skeleton::DeactivateActiveDialog();
576 //=================================================================================
577 // function : enterEvent()
579 //=================================================================================
580 void BasicGUI_MarkerDlg::enterEvent( QEvent* )
582 if ( !mainFrame()->GroupConstructors->isEnabled() )
586 //=================================================================================
587 // function : createOperation
589 //=================================================================================
590 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
592 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
595 //=================================================================================
596 // function : isValid
598 //=================================================================================
599 bool BasicGUI_MarkerDlg::isValid( QString& msg )
601 const int id = getConstructorId();
604 gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
605 v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
608 // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
609 // Vectors shouldn't be checked for being orthogonal here!
610 if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
611 isOk = !v1.IsParallel( v2, Precision::Angular() );
613 msg += tr( "VEC_PARALLEL" );
616 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
617 ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
621 return !myShape->_is_nil();
623 return !myPoint->_is_nil() && !myVectorX->_is_nil() && !myVectorY->_is_nil();
628 //=================================================================================
629 // function : execute
631 //=================================================================================
632 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
634 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
635 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil();
636 QStringList aParameters;
637 const int id = getConstructorId();
639 anObj = anOper->MakeMarker( myData[ X ]->value(), myData[ Y ]->value(),
640 myData[ Z ]->value(), myData[ DX1 ]->value(),
641 myData[ DY1 ]->value(), myData[ DZ1 ]->value(),
642 myData[ DX2 ]->value(), myData[ DY2 ]->value(),
643 myData[ DZ2 ]->value() );
644 aParameters<<myData[X]->text();
645 aParameters<<myData[Y]->text();
646 aParameters<<myData[Z]->text();
647 aParameters<<myData[ DX1 ]->text();
648 aParameters<<myData[ DY1 ]->text();
649 aParameters<<myData[ DZ1 ]->text();
650 aParameters<<myData[ DX2 ]->text();
651 aParameters<<myData[ DY2 ]->text();
652 aParameters<<myData[ DZ2 ]->text();
653 } else if (id == 1) {
654 anObj = anOper->MakeMarkerFromShape( myShape );
655 } else if (id == 2) {
656 anObj = anOper->MakeMarkerPntTwoVec( myPoint, myVectorX, myVectorY );
659 if ( !anObj->_is_nil() ) {
660 if ( !IsPreview() && id == 0)
661 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
662 objects.push_back( anObj._retn() );
668 //=================================================================================
669 // function : onValueChanged
671 //=================================================================================
672 void BasicGUI_MarkerDlg::onValueChanged( double )
677 //=================================================================================
678 // function : displayPreview
680 //=================================================================================
681 void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
683 const bool toRemoveFromEngine,
684 const double lineWidth )
686 if ( !myBlockPreview ) {
687 GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
688 if ( myConstructorId == 0 )
689 GEOMBase_Skeleton::activate( GEOM_MARKER );