Salome HOME
316de759a967f85fcf6918dbb5682b28c04903d0
[modules/geom.git] / src / BasicGUI / BasicGUI_MarkerDlg.cxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : BasicGUI_MarkerDlg.cxx
25 // Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com)
26 //
27 #include "BasicGUI_MarkerDlg.h"
28
29 #include <DlgRef.h>
30 #include <GeometryGUI.h>
31 #include <GEOMBase.h>
32
33 #include <SUIT_ResourceMgr.h>
34 #include <SUIT_Session.h>
35 #include <SalomeApp_Application.h>
36 #include <LightApp_SelectionMgr.h>
37
38 #include <QLabel>
39
40 #include <GEOMImpl_Types.hxx>
41
42 // OCCT Includes
43 #include <BRep_Tool.hxx>
44 #include <TopExp.hxx>
45 #include <TopAbs.hxx>
46 #include <TopoDS.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>
52 #include <gp_Pnt.hxx>
53 #include <gp_Pln.hxx>
54
55 //=================================================================================
56 // class    : BasicGUI_MarkerDlg()
57 // purpose  : Constructor
58 //=================================================================================
59 BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* theParent )
60   : GEOMBase_Skeleton( theGeometryGUI, theParent, false,
61                        Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
62 {
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" ) ) );
67
68   setWindowTitle( tr( "CAPTION" ) );
69
70   mainFrame()->GroupConstructors->setTitle( tr( "LOCALCS" ) );
71   mainFrame()->RadioButton1->setIcon( iconCS1 );
72   mainFrame()->RadioButton2->setIcon( iconCS2 );
73   mainFrame()->RadioButton3->setIcon( iconCS3 );
74
75   Group1 = new DlgRef_1Sel( centralWidget() );
76
77   Group1->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
78   Group1->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
79   Group1->PushButton1->setIcon( iconSelect );
80   Group1->PushButton1->setDown( true );
81
82   Group2 = new DlgRef_3Sel( centralWidget() );
83
84   Group2->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
85   Group2->TextLabel1->setText( tr( "GEOM_POINT" ) );
86   Group2->TextLabel2->setText( tr( "XDIR" ) );
87   Group2->TextLabel3->setText( tr( "YDIR" ) );
88   Group2->PushButton1->setIcon( iconSelect );
89   Group2->PushButton2->setIcon( iconSelect );
90   Group2->PushButton3->setIcon( iconSelect );
91   Group2->PushButton1->setDown( true );
92
93   aMainGrp = new QFrame( centralWidget() );
94   aMainGrp->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
95   aMainGrp->setContentsMargins( 0, 0, 0, 0 );
96   QHBoxLayout* aMainGrpLayout = new QHBoxLayout( aMainGrp );
97   aMainGrpLayout->setMargin( 0 );
98   
99   QGroupBox* anOriGrp = new QGroupBox( tr( "ORIGIN" ), aMainGrp );
100   QVBoxLayout* anOriGrpLayout = new QVBoxLayout( anOriGrp );
101
102   anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), anOriGrp ) );
103   myData[ X ] = new SalomeApp_DoubleSpinBox( anOriGrp );
104   anOriGrpLayout->addWidget( myData[ X ] );
105   anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), anOriGrp ) );
106   myData[ Y ] = new SalomeApp_DoubleSpinBox( anOriGrp );
107   anOriGrpLayout->addWidget( myData[ Y ] );
108   anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), anOriGrp ) );
109   myData[ Z ] = new SalomeApp_DoubleSpinBox( anOriGrp );
110   anOriGrpLayout->addWidget( myData[ Z ] );
111
112   aMainGrpLayout->addWidget( anOriGrp );
113
114   QGroupBox* aXAxisGrp = new QGroupBox( tr( "XDIR" ), aMainGrp );
115   QVBoxLayout* aXAxisGrpLayout = new QVBoxLayout( aXAxisGrp );
116
117   aXAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), aXAxisGrp ) );
118   myData[ DX1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
119   aXAxisGrpLayout->addWidget( myData[ DX1 ] );
120   aXAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), aXAxisGrp ) );
121   myData[ DY1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
122   aXAxisGrpLayout->addWidget( myData[ DY1 ] );
123   aXAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), aXAxisGrp ) );
124   myData[ DZ1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
125   aXAxisGrpLayout->addWidget( myData[ DZ1 ] );
126
127   aMainGrpLayout->addWidget( aXAxisGrp );
128
129   QGroupBox* anYAxisGrp = new QGroupBox( tr( "YDIR" ), aMainGrp );
130   QVBoxLayout* anYAxisGrpLayout = new QVBoxLayout( anYAxisGrp );
131
132   anYAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), anYAxisGrp ) );
133   myData[ DX2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
134   anYAxisGrpLayout->addWidget( myData[ DX2 ] );
135   anYAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), anYAxisGrp ) );
136   myData[ DY2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
137   anYAxisGrpLayout->addWidget( myData[ DY2 ] );
138   anYAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), anYAxisGrp ) );
139   myData[ DZ2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
140   anYAxisGrpLayout->addWidget( myData[ DZ2 ] );
141
142   aMainGrpLayout->addWidget( anYAxisGrp );
143
144   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
145   layout->setMargin( 0 ); layout->setSpacing( 6 );
146   layout->addWidget( aMainGrp );
147   layout->addWidget( Group1 );
148   layout->addWidget( Group2 );
149
150   setHelpFileName( "create_lcs_page.html" );
151
152   Init();
153 }
154
155
156 //=================================================================================
157 // function : ~BasicGUI_MarkerDlg()
158 // purpose  : Destroys the object and frees any allocated resources
159 //=================================================================================
160 BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
161 {
162 }
163
164
165 //=================================================================================
166 // function : Init()
167 // purpose  :
168 //=================================================================================
169 void BasicGUI_MarkerDlg::Init()
170 {
171   myShape.nullify();
172   myPoint.nullify();
173   myVectorX.nullify();
174   myVectorY.nullify();
175   myBlockPreview = false;
176   myConstructorId = -1;
177   myEditCurrentArgument = Group1->LineEdit1;
178   Group1->LineEdit1->setReadOnly( true );
179   Group2->LineEdit1->setReadOnly( true );
180   Group2->LineEdit2->setReadOnly( true );
181   Group2->LineEdit3->setReadOnly( true );
182   Group2->LineEdit1->setEnabled( true );
183   Group2->LineEdit2->setEnabled( false );
184   Group2->LineEdit3->setEnabled( false );
185
186   connect( this,                SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
187
188   connect( Group1->PushButton1, SIGNAL( clicked() ),      this, SLOT( SetEditCurrentArgument() ) );
189   connect( Group2->PushButton1, SIGNAL( clicked() ),      this, SLOT( SetEditCurrentArgument() ) );
190   connect( Group2->PushButton2, SIGNAL( clicked() ),      this, SLOT( SetEditCurrentArgument() ) );
191   connect( Group2->PushButton3, SIGNAL( clicked() ),      this, SLOT( SetEditCurrentArgument() ) );
192
193   connect( myGeomGUI,           SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
194   connect( myGeomGUI,           SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
195
196   connect( buttonOk(),          SIGNAL( clicked() ), this, SLOT( onOk() ) );
197   connect( buttonApply(),       SIGNAL( clicked() ), this, SLOT( onApply() ) );
198
199   connect( myGeomGUI->getApp()->selectionMgr(),
200            SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
201
202   initName( tr( "LCS_NAME" ) );
203
204   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
205   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
206
207   for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) {
208     initSpinBox( anIter.value(), COORD_MIN, COORD_MAX, step, "length_precision" );
209     connect( anIter.value(), SIGNAL( valueChanged( double ) ),
210              this, SLOT( onValueChanged( double ) ) );
211   }
212   
213   myBlockPreview = true;
214   for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
215     anIter.value()->setValue( 0 );
216   myData[ DX1 ]->setValue( 1 );
217   myData[ DY2 ]->setValue( 1 );
218   myBlockPreview = false;
219
220   ConstructorsClicked( 0 );
221 }
222
223 //=================================================================================
224 // function : ConstructorsClicked()
225 // purpose  : Radio button management
226 //=================================================================================
227 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
228 {
229   if ( myConstructorId == constructorId && myConstructorId == 0 ) {
230     globalSelection(); // close local contexts, if any
231     localSelection( TopAbs_VERTEX );
232     activate( GEOM_MARKER );
233     return;
234   }
235
236   myConstructorId = constructorId;
237
238   disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
239
240   switch ( constructorId ) {
241   case 0:
242     {
243       Group1->hide();
244       Group2->hide();
245       aMainGrp->show();
246       globalSelection(); // close local contexts, if any
247       localSelection( TopAbs_VERTEX );
248       activate( GEOM_MARKER );
249       break;
250     }
251   case 1:
252     {
253       aMainGrp->hide();
254       Group2->hide();
255       Group1->show();
256       Group1->PushButton1->setDown( true );
257       globalSelection( GEOM_ALLGEOM );
258       myEditCurrentArgument = Group1->LineEdit1;
259       Group1->LineEdit1->setText( "" );
260       myShape.nullify();
261       break;
262     }
263   case 2:
264     {
265       aMainGrp->hide();
266       Group1->hide();
267       Group2->show();
268       Group2->PushButton1->setDown( true );
269       Group2->PushButton2->setDown( false );
270       Group2->PushButton3->setDown( false );
271       globalSelection(); // close local contexts, if any
272       localSelection( TopAbs_VERTEX );
273       myEditCurrentArgument = Group2->LineEdit1;
274       Group2->LineEdit1->setText( "" );
275       Group2->LineEdit2->setText( "" );
276       Group2->LineEdit3->setText( "" );
277       Group2->LineEdit1->setEnabled( true );
278       Group2->LineEdit2->setEnabled( false );
279       Group2->LineEdit3->setEnabled( false );
280       myPoint.nullify();
281       myVectorX.nullify();
282       myVectorY.nullify();
283       break;
284     }
285   }
286
287   displayPreview();
288
289   qApp->processEvents();
290   updateGeometry();
291   resize( minimumSizeHint() );
292   
293   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
294            this, SLOT( onSelectionDone() ) );
295   onSelectionDone();
296 }
297
298 //=================================================================================
299 // function : onOk()
300 // purpose  :
301 //=================================================================================
302 void BasicGUI_MarkerDlg::onOk()
303 {
304   setIsApplyAndClose( true );
305   if ( onApply() )
306     ClickOnCancel();
307 }
308
309 //=================================================================================
310 // function : onApply()
311 // purpose  :
312 //=================================================================================
313 bool BasicGUI_MarkerDlg::onApply()
314 {
315   if ( !onAccept() )
316     return false;
317
318   initName();
319   ConstructorsClicked( getConstructorId() );
320
321   return true;
322 }
323
324 //=================================================================================
325 // function : onSelectionDone0()
326 // purpose  : Reaction on selection when first method of creation is current one
327 //=================================================================================
328 void BasicGUI_MarkerDlg::onSelectionDone0()
329 {
330   GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_FACE );
331   TopoDS_Shape aShape;
332   if ( aSelectedObject && aSelectedObject->GetType() == GEOM_MARKER && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
333     // Existing LCS selected
334     TopoDS_Face aFace = TopoDS::Face( aShape );
335     Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
336     
337     if ( !aPlane.IsNull() ) {
338       gp_Ax3 anAx3 = aPlane->Pln().Position();
339       gp_Pnt aLoc = anAx3.Location();
340       gp_Dir aXDir = anAx3.XDirection();
341       gp_Dir aYDir = anAx3.YDirection();
342       
343       myData[ X ]->setValue( aLoc.X() );
344       myData[ Y ]->setValue( aLoc.Y() );
345       myData[ Z ]->setValue( aLoc.Z() );
346       
347       myData[ DX1 ]->setValue( aXDir.X() );
348       myData[ DY1 ]->setValue( aXDir.Y() );
349       myData[ DZ1 ]->setValue( aXDir.Z() );
350       
351       myData[ DX2 ]->setValue( aYDir.X() );
352       myData[ DY2 ]->setValue( aYDir.Y() );
353       myData[ DZ2 ]->setValue( aYDir.Z() );
354     }
355     displayPreview();
356     return;
357   }
358   aSelectedObject = getSelected( TopAbs_VERTEX );
359   if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
360     gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
361     myData[ X ]->setValue( aPnt.X() );
362     myData[ Y ]->setValue( aPnt.Y() );
363     myData[ Z ]->setValue( aPnt.Z() );
364     displayPreview();
365     return;
366   }
367 }
368
369
370 //=================================================================================
371 // function : onSelectionDone()
372 // purpose  : Called when selection as changed or other case
373 //=================================================================================
374 void BasicGUI_MarkerDlg::onSelectionDone()
375 {
376   if ( getConstructorId() == 0 ) {
377     onSelectionDone0();
378     return;
379   }
380
381   TopAbs_ShapeEnum aNeedType = TopAbs_SHAPE; // todo: aNeedType must be explicitly initialized to avoid warning (see below)
382   if ( getConstructorId() == 1 ) // by shape position
383     aNeedType = TopAbs_SHAPE;
384   else if ( getConstructorId() == 2 ) // by point and two vectors
385     aNeedType = myEditCurrentArgument == Group2->LineEdit1 ? TopAbs_VERTEX : TopAbs_EDGE;
386   
387   GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); // todo: aNeedType must be explicitly initialized to avoid warning (see above)
388   TopoDS_Shape aShape;
389   if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
390     QString aName = GEOMBase::GetName( aSelectedObject.get() );
391     myEditCurrentArgument->setText( aName );
392     if ( getConstructorId() == 1 ) { // by shape position
393       myShape = aSelectedObject;
394     }
395     else if ( getConstructorId() == 2 ) { // by point and two vectors
396       if ( myEditCurrentArgument == Group2->LineEdit1 ) {
397         myPoint = aSelectedObject;
398         if (myPoint && !myVectorX)
399           Group2->PushButton2->click();
400       }
401       else if (myEditCurrentArgument == Group2->LineEdit2) {
402         myVectorX = aSelectedObject;
403         if (myVectorX && !myVectorY)
404           Group2->PushButton3->click();
405       }
406       else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
407         myVectorY = aSelectedObject;
408         if (myVectorY && !myPoint)
409           Group2->PushButton1->click();
410       }
411     }
412   }
413   else {
414     if ( getConstructorId() == 1 ) {
415       myShape.nullify();
416     }
417     else if ( getConstructorId() == 2 ) {
418       if ( myEditCurrentArgument == Group2->LineEdit1 )
419         myPoint.nullify();
420       else if ( myEditCurrentArgument == Group2->LineEdit2 )
421         myVectorX.nullify();
422       else if ( myEditCurrentArgument == Group2->LineEdit3 )
423         myVectorY.nullify();
424     }
425   }
426
427   displayPreview();
428 }
429
430 //=================================================================================
431 // function : SetEditCurrentArgument()
432 // purpose  :
433 //=================================================================================
434 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
435 {
436   QPushButton* send = (QPushButton*)sender();
437   globalSelection(); // close local contexts, if any
438
439   if ( send == Group1->PushButton1 ) {
440     myEditCurrentArgument = Group1->LineEdit1;
441     globalSelection( GEOM_ALLGEOM );
442   }
443   else if ( send == Group2->PushButton1 ) {
444     myEditCurrentArgument = Group2->LineEdit1;
445     localSelection( TopAbs_VERTEX );
446     Group2->PushButton2->setDown( false );
447     Group2->PushButton3->setDown( false );
448     Group2->LineEdit1->setEnabled( true );
449     Group2->LineEdit2->setEnabled( false );
450     Group2->LineEdit3->setEnabled( false );
451   }
452   else if ( send == Group2->PushButton2 ) {
453     myEditCurrentArgument = Group2->LineEdit2;
454     localSelection( TopAbs_EDGE );
455     Group2->PushButton1->setDown( false );
456     Group2->PushButton3->setDown( false );
457     Group2->LineEdit1->setEnabled( false );
458     Group2->LineEdit2->setEnabled( true );
459     Group2->LineEdit3->setEnabled( false );
460   }
461   else if ( send == Group2->PushButton3 ) {
462     myEditCurrentArgument = Group2->LineEdit3;
463     localSelection( TopAbs_EDGE );
464     Group2->PushButton1->setDown( false );
465     Group2->PushButton2->setDown( false );
466     Group2->LineEdit1->setEnabled( false );
467     Group2->LineEdit2->setEnabled( false );
468     Group2->LineEdit3->setEnabled( true );
469   }
470   
471   myEditCurrentArgument->setFocus();
472   send->setDown(true);
473   onSelectionDone();
474 }
475
476 //=================================================================================
477 // function : onActivate()
478 // purpose  :
479 //=================================================================================
480 void BasicGUI_MarkerDlg::onActivate()
481 {
482   GEOMBase_Skeleton::ActivateThisDialog();
483   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
484            this, SLOT( onSelectionDone() ) );
485
486   ConstructorsClicked( getConstructorId() );
487 }
488
489 //=================================================================================
490 // function : onDeactivate()
491 // purpose  : public slot to deactivate if active
492 //=================================================================================
493 void BasicGUI_MarkerDlg::onDeactivate()
494 {
495   GEOMBase_Skeleton::DeactivateActiveDialog();
496 }
497
498 //=================================================================================
499 // function : enterEvent()
500 // purpose  :
501 //=================================================================================
502 void BasicGUI_MarkerDlg::enterEvent( QEvent* )
503 {
504   if ( !mainFrame()->GroupConstructors->isEnabled() )
505     onActivate();
506 }
507
508 //=================================================================================
509 // function : createOperation
510 // purpose  :
511 //=================================================================================
512 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
513 {
514   return myGeomGUI->GetGeomGen()->GetIBasicOperations();
515 }
516
517 //=================================================================================
518 // function : isValid
519 // purpose  :
520 //=================================================================================
521 bool BasicGUI_MarkerDlg::isValid( QString& msg )
522 {
523   bool ok = false;
524   switch ( getConstructorId() ) {
525   case 0: {
526     gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
527       v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
528       
529     // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
530     // Vectors shouldn't be checked for being orthogonal here!
531     if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
532       ok = !v1.IsParallel( v2, Precision::Angular() );
533       if ( !ok )
534         msg += tr( "VEC_PARALLEL" );
535     }
536     for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end() && ok; ++anIter )
537       ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
538     break;
539   }
540   case 1:
541     ok = myShape;
542     break;
543   case 2:
544     ok = myPoint && myVectorX && myVectorY;
545     break;
546   default:
547     break;
548   }
549   return ok;
550 }
551
552 //=================================================================================
553 // function : execute
554 // purpose  :
555 //=================================================================================
556 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
557 {
558   GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
559   GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil();
560   QStringList aParameters;
561   const int id = getConstructorId();
562   if (id == 0) {
563     anObj = anOper->MakeMarker( myData[ X   ]->value(), myData[ Y   ]->value(), 
564                                 myData[ Z   ]->value(), myData[ DX1 ]->value(),
565                                 myData[ DY1 ]->value(), myData[ DZ1 ]->value(),
566                                 myData[ DX2 ]->value(), myData[ DY2 ]->value(),
567                                 myData[ DZ2 ]->value() );
568     aParameters<<myData[X]->text();
569     aParameters<<myData[Y]->text();
570     aParameters<<myData[Z]->text();
571     aParameters<<myData[ DX1 ]->text(); 
572     aParameters<<myData[ DY1 ]->text(); 
573     aParameters<<myData[ DZ1 ]->text();
574     aParameters<<myData[ DX2 ]->text();
575     aParameters<<myData[ DY2 ]->text();
576     aParameters<<myData[ DZ2 ]->text();
577   } else if (id == 1) {
578     anObj = anOper->MakeMarkerFromShape( myShape.get() ); 
579   } else if (id == 2) {
580     anObj = anOper->MakeMarkerPntTwoVec( myPoint.get(), myVectorX.get(), myVectorY.get() ); 
581   }
582   
583   if ( !anObj->_is_nil() ) {
584     if ( !IsPreview() && id == 0)
585       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
586     objects.push_back( anObj._retn() );
587   }
588
589   return true;
590 }
591
592 //=================================================================================
593 // function : addSubshapeToStudy
594 // purpose  : virtual method to add new SubObjects if local selection
595 //=================================================================================
596 void BasicGUI_MarkerDlg::addSubshapesToStudy()
597 {
598   switch ( getConstructorId() ) {
599   case 0 :
600     break;
601   case 1 :
602     GEOMBase::PublishSubObject( myShape.get() );
603     break;
604   case 2:
605     GEOMBase::PublishSubObject( myPoint.get() );
606     GEOMBase::PublishSubObject( myVectorX.get() );
607     GEOMBase::PublishSubObject( myVectorY.get() );
608     break;
609   default:
610     break;
611   }
612 }
613
614 //=================================================================================
615 // function : getSourceObjects
616 // purpose  : virtual method to get source objects
617 //=================================================================================
618 QList<GEOM::GeomObjPtr> BasicGUI_MarkerDlg::getSourceObjects()
619 {
620   QList<GEOM::GeomObjPtr> res;
621   res << myShape << myPoint << myVectorX << myVectorY;
622   return res;
623 }
624
625 //=================================================================================
626 // function : onValueChanged
627 // purpose  :
628 //=================================================================================
629 void BasicGUI_MarkerDlg::onValueChanged( double )
630 {
631   displayPreview();
632 }
633
634 //=================================================================================
635 // function : displayPreview
636 // purpose  :
637 //=================================================================================
638 void BasicGUI_MarkerDlg::displayPreview ( const bool   activate,
639                                           const bool   update,
640                                           const bool   toRemoveFromEngine,
641                                           const double lineWidth )
642 {
643   if ( !myBlockPreview ) {
644     GEOMBase_Skeleton::displayPreview( true, activate, update, toRemoveFromEngine, lineWidth );
645     if ( myConstructorId == 0 )
646       GEOMBase_Skeleton::activate( GEOM_MARKER );
647   }
648 }