Salome HOME
75c490a49b10acdf8185bca4b758dbd73d3d7188
[modules/geom.git] / src / BasicGUI / BasicGUI_MarkerDlg.cxx
1 //  Copyright (C) 2007-2008  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.
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 // GEOM GEOMGUI : GUI for Geometry component
23 // File   : BasicGUI_MarkerDlg.cxx
24 // Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com)
25 //
26 #include "BasicGUI_MarkerDlg.h"
27
28 #include <DlgRef.h>
29 #include <GeometryGUI.h>
30 #include <GEOMBase.h>
31
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Session.h>
34 #include <SalomeApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
36
37 #include <QLabel>
38
39 #include <GEOMImpl_Types.hxx>
40
41 // OCCT Includes
42 #include <BRep_Tool.hxx>
43 #include <TopExp.hxx>
44 #include <TopAbs.hxx>
45 #include <TopoDS.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>
51 #include <gp_Pnt.hxx>
52 #include <gp_Pln.hxx>
53
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 )
61 {
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" ) ) );
66
67   setWindowTitle( tr( "CAPTION" ) );
68
69   mainFrame()->GroupConstructors->setTitle( tr( "LOCALCS" ) );
70   mainFrame()->RadioButton1->setIcon( iconCS1 );
71   mainFrame()->RadioButton2->setIcon( iconCS2 );
72   mainFrame()->RadioButton3->setIcon( iconCS3 );
73
74   Group1 = new DlgRef_1Sel( centralWidget() );
75
76   Group1->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
77   Group1->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
78   Group1->PushButton1->setIcon( iconSelect );
79   Group1->PushButton1->setDown( true );
80
81   Group2 = new DlgRef_3Sel( centralWidget() );
82
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 );
91
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 );
97   
98   QGroupBox* anOriGrp = new QGroupBox( tr( "ORIGIN" ), aMainGrp );
99   QVBoxLayout* anOriGrpLayout = new QVBoxLayout( anOriGrp );
100
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 ] );
110
111   aMainGrpLayout->addWidget( anOriGrp );
112
113   QGroupBox* aXAxisGrp = new QGroupBox( tr( "XDIR" ), aMainGrp );
114   QVBoxLayout* aXAxisGrpLayout = new QVBoxLayout( aXAxisGrp );
115
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 ] );
125
126   aMainGrpLayout->addWidget( aXAxisGrp );
127
128   QGroupBox* anYAxisGrp = new QGroupBox( tr( "YDIR" ), aMainGrp );
129   QVBoxLayout* anYAxisGrpLayout = new QVBoxLayout( anYAxisGrp );
130
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 ] );
140
141   aMainGrpLayout->addWidget( anYAxisGrp );
142
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 );
148
149   setHelpFileName( "create_lcs_page.html" );
150
151   Init();
152 }
153
154
155 //=================================================================================
156 // function : ~BasicGUI_MarkerDlg()
157 // purpose  : Destroys the object and frees any allocated resources
158 //=================================================================================
159 BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
160 {
161 }
162
163
164 //=================================================================================
165 // function : Init()
166 // purpose  :
167 //=================================================================================
168 void BasicGUI_MarkerDlg::Init()
169 {
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 );
181
182   connect( this,                SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
183
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() ) );
188
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() ) );
193
194   connect( myGeomGUI,           SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
195   connect( myGeomGUI,           SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
196
197   connect( buttonOk(),          SIGNAL( clicked() ), this, SLOT( onOk() ) );
198   connect( buttonApply(),       SIGNAL( clicked() ), this, SLOT( onApply() ) );
199
200   connect( myGeomGUI->getApp()->selectionMgr(),
201            SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
202
203   initName( tr( "LCS_NAME" ) );
204
205   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
206   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
207
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 ) ) );
212   }
213   
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;
220
221   ConstructorsClicked( 0 );
222 }
223
224 //=================================================================================
225 // function : ConstructorsClicked()
226 // purpose  : Radio button management
227 //=================================================================================
228 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
229 {
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 );
234     return;
235   }
236
237   myConstructorId = constructorId;
238
239   disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
240
241   switch ( constructorId ) {
242   case 0:
243     {
244       Group1->hide();
245       Group2->hide();
246       aMainGrp->show();
247       globalSelection(); // close local contexts, if any
248       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
249       activate( GEOM_MARKER );
250       break;
251     }
252   case 1:
253     {
254       aMainGrp->hide();
255       Group2->hide();
256       Group1->show();
257       Group1->PushButton1->setDown( true );
258       globalSelection( GEOM_ALLGEOM );
259       myEditCurrentArgument = Group1->LineEdit1;
260       Group1->LineEdit1->setText( "" );
261       myShape = GEOM::GEOM_Object::_nil();
262       break;
263     }
264   case 2:
265     {
266       aMainGrp->hide();
267       Group1->hide();
268       Group2->show();
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();
284       break;
285     }
286   }
287
288   displayPreview();
289
290   qApp->processEvents();
291   updateGeometry();
292   resize( minimumSizeHint() );
293   
294   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
295            this, SLOT( onSelectionDone() ) );
296   onSelectionDone();
297 }
298
299 //=================================================================================
300 // function : onOk()
301 // purpose  :
302 //=================================================================================
303 void BasicGUI_MarkerDlg::onOk()
304 {
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   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
331   SALOME_ListIO aSelList;
332   aSelMgr->selectedObjects(aSelList);
333
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);
338     
339     if ( aRes && !aSelectedObj->_is_nil() ) {
340       TopoDS_Shape aShape;
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 ) );
346           
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();
352             
353             myData[ X ]->setValue( aLoc.X() );
354             myData[ Y ]->setValue( aLoc.Y() );
355             myData[ Z ]->setValue( aLoc.Z() );
356             
357             myData[ DX1 ]->setValue( aXDir.X() );
358             myData[ DY1 ]->setValue( aXDir.Y() );
359             myData[ DZ1 ]->setValue( aXDir.Z() );
360             
361             myData[ DX2 ]->setValue( aYDir.X() );
362             myData[ DY2 ]->setValue( aYDir.Y() );
363             myData[ DZ2 ]->setValue( aYDir.Z() );
364             aSelMgr->clearSelected();
365           }
366         }
367         else {
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(); // ???
376           }
377
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() );
383           }
384         }
385       }
386     }
387   }
388   
389   displayPreview();
390 }
391
392
393 //=================================================================================
394 // function : onSelectionDone()
395 // purpose  : Called when selection as changed or other case
396 //=================================================================================
397 void BasicGUI_MarkerDlg::onSelectionDone()
398 {
399   if ( getConstructorId() == 0 ) {
400     onSelectionDone0();
401     return;
402   }
403
404   myEditCurrentArgument->setText( "" );
405
406   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
407   SALOME_ListIO aSelList;
408   aSelMgr->selectedObjects(aSelList);
409
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 );
414
415     if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
416       QString aName = GEOMBase::GetName( aSelectedObj );
417       
418       if ( getConstructorId() == 1 ) { // by shape position
419         TopoDS_Shape aShape;
420         if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
421           myShape = aSelectedObj;
422         myEditCurrentArgument->setText( aName );
423       }
424       else if ( getConstructorId() == 2 ) { // by point and two vectors
425         TopoDS_Shape aShape;
426         if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
427           TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
428           if ( myEditCurrentArgument == Group2->LineEdit1 )
429             aNeedType = TopAbs_VERTEX;
430           
431           TColStd_IndexedMapOfInteger aMap;
432           aSelMgr->GetIndexes( anIO, aMap );
433
434           if ( aMap.Extent() == 1 ) { // Local Selection
435             int anIndex = aMap( 1 );
436             if ( aNeedType == TopAbs_EDGE )
437               aName += QString( ":edge_%1" ).arg( anIndex );
438             else
439               aName += QString( ":vertex_%1" ).arg( anIndex );
440             
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 );
446             } 
447             else {
448               aSelectedObj = aFindedObject; // get Object from study
449             }
450           }
451           else { // Global Selection
452             if ( aShape.ShapeType() != aNeedType ) {
453               aSelectedObj = GEOM::GEOM_Object::_nil();
454               aName = "";
455             }
456           }
457           
458           if ( myEditCurrentArgument == Group2->LineEdit1 ) {
459             myPoint = aSelectedObj;
460             myEditCurrentArgument->setText( aName );
461             if (!myPoint->_is_nil() && Group2->LineEdit2->text() == "")
462                 Group2->PushButton2->click();
463           }
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();
469           }
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();
475           }
476         }
477       }
478     }
479   }
480   else {
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();
490     }
491   }
492
493   displayPreview();
494 }
495
496 //=================================================================================
497 // function : SetEditCurrentArgument()
498 // purpose  :
499 //=================================================================================
500 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
501 {
502   QPushButton* send = (QPushButton*)sender();
503   globalSelection(); // close local contexts, if any
504
505   if ( send == Group1->PushButton1 ) {
506     myEditCurrentArgument = Group1->LineEdit1;
507     globalSelection( GEOM_ALLGEOM );
508   }
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 );
517   }
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 );
526   }
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 );
535   }
536   
537   myEditCurrentArgument->setFocus();
538   send->setDown(true);
539   onSelectionDone();
540 }
541
542 //=================================================================================
543 // function : LineEditReturnPressed()
544 // purpose  :
545 //=================================================================================
546 void BasicGUI_MarkerDlg::LineEditReturnPressed()
547 {
548   QLineEdit* send = (QLineEdit*)sender();
549
550   myEditCurrentArgument = send;
551   GEOMBase_Skeleton::LineEditReturnPressed();
552 }
553
554 //=================================================================================
555 // function : onActivate()
556 // purpose  :
557 //=================================================================================
558 void BasicGUI_MarkerDlg::onActivate()
559 {
560   GEOMBase_Skeleton::ActivateThisDialog();
561   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
562            this, SLOT( onSelectionDone() ) );
563
564   ConstructorsClicked( getConstructorId() );
565 }
566
567 //=================================================================================
568 // function : onDeactivate()
569 // purpose  : public slot to deactivate if active
570 //=================================================================================
571 void BasicGUI_MarkerDlg::onDeactivate()
572 {
573   GEOMBase_Skeleton::DeactivateActiveDialog();
574 }
575
576 //=================================================================================
577 // function : enterEvent()
578 // purpose  :
579 //=================================================================================
580 void BasicGUI_MarkerDlg::enterEvent( QEvent* )
581 {
582   if ( !mainFrame()->GroupConstructors->isEnabled() )
583     onActivate();
584 }
585
586 //=================================================================================
587 // function : createOperation
588 // purpose  :
589 //=================================================================================
590 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
591 {
592   return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
593 }
594
595 //=================================================================================
596 // function : isValid
597 // purpose  :
598 //=================================================================================
599 bool BasicGUI_MarkerDlg::isValid( QString& msg )
600 {
601   const int id = getConstructorId();
602   switch ( id ) {
603     case 0: {
604       gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
605         v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
606       
607       bool isOk = false;
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() );
612         if ( !isOk )
613           msg += tr( "VEC_PARALLEL" );
614       }
615       bool ok = true;
616       for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
617         ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
618       return isOk && ok;
619     }
620     case 1:
621       return !myShape->_is_nil();
622     case 2:
623       return !myPoint->_is_nil() && !myVectorX->_is_nil() && !myVectorY->_is_nil();
624   }
625   return false;
626 }
627
628 //=================================================================================
629 // function : execute
630 // purpose  :
631 //=================================================================================
632 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
633 {
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();
638   if (id == 0) {
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 ); 
657   }
658   
659   if ( !anObj->_is_nil() ) {
660     if ( !IsPreview() && id == 0)
661       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
662     objects.push_back( anObj._retn() );
663   }
664
665   return true;
666 }
667
668 //=================================================================================
669 // function : onValueChanged
670 // purpose  :
671 //=================================================================================
672 void BasicGUI_MarkerDlg::onValueChanged( double )
673 {
674   displayPreview();
675 }
676
677 //=================================================================================
678 // function : displayPreview
679 // purpose  :
680 //=================================================================================
681 void BasicGUI_MarkerDlg::displayPreview ( const bool   activate,
682                                           const bool   update,
683                                           const bool   toRemoveFromEngine,
684                                           const double lineWidth )
685 {
686   if ( !myBlockPreview ) {
687     GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
688     if ( myConstructorId == 0 )
689       GEOMBase_Skeleton::activate( GEOM_MARKER );
690   }
691 }