]> SALOME platform Git repositories - modules/geom.git/blob - src/BasicGUI/BasicGUI_MarkerDlg.cxx
Salome HOME
Bug 0020374: Partition operation leads to missing volume. A fix by PKV.
[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
25 //  Module : GEOM
26 //  $Header$
27 //
28 #include "BasicGUI_MarkerDlg.h"
29 #include "DlgRef_SpinBox.h"
30
31 #include "SUIT_Desktop.h"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "LightApp_SelectionMgr.h"
35
36 #include <qlabel.h>
37
38 #include "GEOMImpl_Types.hxx"
39
40 #include "utilities.h"
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, "BasicGUI_MarkerDlg", false,
61                       WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
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   setCaption( tr( "CAPTION" ) );
69
70   GroupConstructors->setTitle( tr( "LOCALCS" ) );
71   RadioButton1->setPixmap( iconCS1 );
72   RadioButton2->setPixmap( iconCS2 );
73   RadioButton3->setPixmap( iconCS3 );
74
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);
79
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);
88
89   aMainGrp = new QGroupBox( 1, Qt::Horizontal, this );
90   aMainGrp->setFrameStyle( QFrame::NoFrame );
91   aMainGrp->setInsideMargin( 0 );
92
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 );
100
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 );
108
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 );
116
117   Layout1->addWidget( aMainGrp, 2, 0 );
118   Layout1->addWidget( Group1, 2, 0 );
119   Layout1->addWidget( Group2, 2, 0 );
120
121   setHelpFileName("create_lcs_page.html");
122
123   Init();
124 }
125
126 //=================================================================================
127 // function : ~BasicGUI_MarkerDlg()
128 // purpose  : Destroys the object and frees any allocated resources
129 //=================================================================================
130 BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
131 {
132 }
133
134 //=================================================================================
135 // function : Init()
136 // purpose  :
137 //=================================================================================
138 void BasicGUI_MarkerDlg::Init()
139 {
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 );
147
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()));
153
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()));
158
159   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( onClose() ) );
160   connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
161   connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onClose() ) );
162
163   connect( buttonOk, SIGNAL( clicked() ), this, SLOT( onOk() ) );
164   connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
165
166   connect(myGeomGUI->getApp()->selectionMgr(),
167            SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
168
169   initName( tr( "LCS_NAME" ) );
170
171   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
172   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
173
174   for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
175   {
176     anIter.data()->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY );
177     connect( anIter.data(), SIGNAL( valueChanged( double ) ),
178              this, SLOT( onValueChanged( double ) ) );
179   }
180
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;
187
188   ConstructorsClicked( 0 );
189
190   //@
191   /*
192   QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()->
193     getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
194
195   VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>( aFrame );
196   if ( aVTKFrame )
197   {
198     aVTKFrame->AdjustTrihedrons( true );
199     return;
200   }
201
202   OCCViewer_ViewFrame* aOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( aFrame );
203   if ( aOCCFrame )
204     aOCCFrame->AdjustTrihedrons( true );
205   */
206 }
207
208 //=================================================================================
209 // function : ConstructorsClicked()
210 // purpose  : Radio button management
211 //=================================================================================
212 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
213 {
214   if ( myConstructorId == constructorId && myConstructorId == 0 )
215   {
216     globalSelection(); // close local contexts, if any
217     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
218     activate( GEOM_MARKER );
219     displayPreview();
220     return;
221   }
222
223   myConstructorId = constructorId;
224
225   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
226
227   switch (constructorId)
228   {
229   case 0:
230     {
231       Group1->hide();
232       Group2->hide();
233       resize(0, 0);
234       aMainGrp->show();
235       globalSelection(); // close local contexts, if any
236       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
237       activate( GEOM_MARKER );
238       break;
239     }
240   case 1:
241     {
242       Group2->hide();
243       aMainGrp->hide();
244       //PAL6669: resize(0, 0);
245       Group1->show();
246
247       globalSelection( GEOM_ALLGEOM );
248       myEditCurrentArgument = Group1->LineEdit1;
249       Group1->LineEdit1->setText("");
250       break;
251     }
252   case 2:
253     {
254       aMainGrp->hide();
255       Group1->show();
256       //PAL6669: resize(0, 0);
257       Group2->show();
258
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("");
265       break;
266     }
267   }
268
269   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
270           this, SLOT(onSelectionDone()));
271   onSelectionDone();
272 }
273
274 //=================================================================================
275 // function : onOk()
276 // purpose  :
277 //=================================================================================
278 void BasicGUI_MarkerDlg::onOk()
279 {
280   if ( onApply() )
281     onClose();
282 }
283
284 //=======================================================================
285 // function : onClose()
286 // purpose  :
287 //=======================================================================
288 void BasicGUI_MarkerDlg::onClose()
289 {
290   GEOMBase_Skeleton::ClickOnCancel();
291 }
292
293 //=================================================================================
294 // function : onApply()
295 // purpose  :
296 //=================================================================================
297 bool BasicGUI_MarkerDlg::onApply()
298 {
299   if ( !onAccept() )
300     return false;
301
302   initName();
303   ConstructorsClicked( getConstructorId() );
304
305   return true;
306 }
307
308 //=================================================================================
309 // function : onSelectionDone0()
310 // purpose  : Reaction on selection when first method of creation is current one
311 //=================================================================================
312 void BasicGUI_MarkerDlg::onSelectionDone0()
313 {
314   if (IObjectCount() == 1)
315   {
316     Standard_Boolean aRes = Standard_False;
317     Handle(SALOME_InteractiveObject) anIO = firstIObject();
318     GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
319
320     LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
321
322     if (aRes && !aSelectedObj->_is_nil())
323     {
324       TopoDS_Shape aShape;
325       if (GEOMBase::GetShape(aSelectedObj, aShape, TopAbs_SHAPE) && !aShape.IsNull())
326       {
327         // Existing LCS selected
328         if (aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE)
329         {
330           TopoDS_Face aFace = TopoDS::Face(aShape);
331           Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(aFace));
332
333           if (!aPlane.IsNull())
334           {
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();
339
340             myData[ X ]->SetValue( aLoc.X() );
341             myData[ Y ]->SetValue( aLoc.Y() );
342             myData[ Z ]->SetValue( aLoc.Z() );
343
344             myData[ DX1 ]->SetValue( aXDir.X() );
345             myData[ DY1 ]->SetValue( aXDir.Y() );
346             myData[ DZ1 ]->SetValue( aXDir.Z() );
347
348             myData[ DX2 ]->SetValue( aYDir.X() );
349             myData[ DY2 ]->SetValue( aYDir.Y() );
350             myData[ DZ2 ]->SetValue( aYDir.Z() );
351             aSelMgr->clearSelected();
352           }
353         }
354         else
355         {
356           TColStd_IndexedMapOfInteger aMap;
357           aSelMgr->GetIndexes(anIO, aMap);
358           if (aMap.Extent() == 1) // Local Selection
359           {
360             int anIndex = aMap(1);
361             TopTools_IndexedMapOfShape aShapes;
362             TopExp::MapShapes(aShape, aShapes);
363             aShape = aShapes.FindKey(anIndex);
364             aSelMgr->clearSelected(); // ???
365           }
366
367           if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX)
368           {
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() );
373           }
374         }
375       }
376     }
377   }
378
379   displayPreview();
380 }
381
382 //=================================================================================
383 // function : onSelectionDone()
384 // purpose  : Called when selection as changed or other case
385 //=================================================================================
386 void BasicGUI_MarkerDlg::onSelectionDone()
387 {
388   if (getConstructorId() == 0) {
389     onSelectionDone0();
390     return;
391   }
392
393   myEditCurrentArgument->setText("");
394
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);
399
400     if (!CORBA::is_nil(aSelectedObj) && aRes) {
401       QString aName = GEOMBase::GetName(aSelectedObj);
402
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;
407         Zz = Xx = Yy = 1.;
408
409         GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
410           myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId());
411         aMeasureOp->GetPosition(aSelectedObj, Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz);
412
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);
419
420           gp_Dir aDirY = anAx3.YDirection();
421           aDirY.Coord(Yx,Yy,Yz);
422         }
423
424         // Set values
425         myData[ X ]->SetValue( Ox );
426         myData[ Y ]->SetValue( Oy );
427         myData[ Z ]->SetValue( Oz );
428
429         myData[ DX1 ]->SetValue( Xx );
430         myData[ DY1 ]->SetValue( Xy );
431         myData[ DZ1 ]->SetValue( Xz );
432
433         myData[ DX2 ]->SetValue( Yx );
434         myData[ DY2 ]->SetValue( Yy );
435         myData[ DZ2 ]->SetValue( Yz );
436
437         myEditCurrentArgument->setText(aName);
438       }
439       else if (getConstructorId() == 2) { // by point and two vectors
440         TopoDS_Shape aShape;
441         if (GEOMBase::GetShape(aSelectedObj, aShape, TopAbs_SHAPE))
442         {
443           TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
444           if (myEditCurrentArgument == Group2->LineEdit1)
445             aNeedType = TopAbs_VERTEX;
446
447           TColStd_IndexedMapOfInteger aMap;
448           LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
449           aSelMgr->GetIndexes(anIO, aMap);
450
451           if (!aMap.IsEmpty()) {
452             int anIndex = aMap(1);
453             if (aNeedType == TopAbs_EDGE)
454               aName += QString("_edge_%1").arg(anIndex);
455             else
456               aName += QString("_vertex_%1").arg(anIndex);
457
458             TopTools_IndexedMapOfShape aShapes;
459             TopExp::MapShapes(aShape, aShapes);
460             aShape = aShapes.FindKey(anIndex);
461           }
462
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);
470             }
471             else {
472               myData[ X ]->SetValue( 0 );
473               myData[ Y ]->SetValue( 0 );
474               myData[ Z ]->SetValue( 0 );
475             }
476           }
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));
482
483               myData[ DX1 ]->SetValue( aDir.X() );
484               myData[ DY1 ]->SetValue( aDir.Y() );
485               myData[ DZ1 ]->SetValue( aDir.Z() );
486               myEditCurrentArgument->setText(aName);
487             }
488             else {
489               myData[ DX1 ]->SetValue( 0 );
490               myData[ DY1 ]->SetValue( 0 );
491               myData[ DZ1 ]->SetValue( 0 );
492             }
493           }
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));
499
500               myData[ DX2 ]->SetValue( aDir.X() );
501               myData[ DY2 ]->SetValue( aDir.Y() );
502               myData[ DZ2 ]->SetValue( aDir.Z() );
503               myEditCurrentArgument->setText(aName);
504             }
505             else {
506               myData[ DX2 ]->SetValue( 0 );
507               myData[ DY2 ]->SetValue( 0 );
508               myData[ DZ2 ]->SetValue( 0 );
509             }
510           }
511         }
512       }
513     }
514   }
515   else {
516     if ( getConstructorId() == 1 ) {
517       myData[ X ]->SetValue( 0 );
518       myData[ Y ]->SetValue( 0 );
519       myData[ Z ]->SetValue( 0 );
520
521       myData[ DX1 ]->SetValue( 0 );
522       myData[ DY1 ]->SetValue( 0 );
523       myData[ DZ1 ]->SetValue( 0 );
524
525       myData[ DX2 ]->SetValue( 0 );
526       myData[ DY2 ]->SetValue( 0 );
527       myData[ DZ2 ]->SetValue( 0 );
528     }
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 );
534       }
535       else if (myEditCurrentArgument == Group2->LineEdit2) {
536         myData[ DX1 ]->SetValue( 0 );
537         myData[ DY1 ]->SetValue( 0 );
538         myData[ DZ1 ]->SetValue( 0 );
539       }
540       else if (myEditCurrentArgument == Group2->LineEdit3) {
541         myData[ DX2 ]->SetValue( 0 );
542         myData[ DY2 ]->SetValue( 0 );
543         myData[ DZ2 ]->SetValue( 0 );
544       }
545     }
546   }
547
548   displayPreview();
549 }
550
551 //=================================================================================
552 // function : SetEditCurrentArgument()
553 // purpose  :
554 //=================================================================================
555 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
556 {
557   QPushButton* send = (QPushButton*)sender();
558
559   if (send == Group1->PushButton1) {
560     myEditCurrentArgument = Group1->LineEdit1;
561     globalSelection( GEOM_ALLGEOM );
562   }
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 );
568   }
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 );
574   }
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 );
579   }
580
581   myEditCurrentArgument->setFocus();
582   onSelectionDone();
583 }
584
585 //=================================================================================
586 // function : LineEditReturnPressed()
587 // purpose  :
588 //=================================================================================
589 void BasicGUI_MarkerDlg::LineEditReturnPressed()
590 {
591   QLineEdit* send = (QLineEdit*)sender();
592
593   myEditCurrentArgument = send;
594   GEOMBase_Skeleton::LineEditReturnPressed();
595 }
596
597 //=================================================================================
598 // function : onActivate()
599 // purpose  :
600 //=================================================================================
601 void BasicGUI_MarkerDlg::onActivate()
602 {
603   GEOMBase_Skeleton::ActivateThisDialog();
604   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
605           this, SLOT(onSelectionDone()));
606
607   ConstructorsClicked(getConstructorId());
608 }
609
610 //=================================================================================
611 // function : onDeactivate()
612 // purpose  : public slot to deactivate if active
613 //=================================================================================
614 void BasicGUI_MarkerDlg::onDeactivate()
615 {
616   GEOMBase_Skeleton::DeactivateActiveDialog();
617 }
618
619 //=================================================================================
620 // function : enterEvent()
621 // purpose  :
622 //=================================================================================
623 void BasicGUI_MarkerDlg::enterEvent(QEvent* e)
624 {
625   if ( !GroupConstructors->isEnabled() )
626     onActivate();
627 }
628
629 //=================================================================================
630 // function : createOperation
631 // purpose  :
632 //=================================================================================
633 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
634 {
635   return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
636 }
637
638 //=================================================================================
639 // function : isValid
640 // purpose  :
641 //=================================================================================
642 bool BasicGUI_MarkerDlg::isValid( QString& msg )
643 {
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() );
647
648   bool isOk = false;
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() );
653     if ( !isOk )
654       msg += tr( "VEC_PARALLEL" );
655   }
656
657   switch ( id )
658   {
659     case 0:
660       return isOk;
661     case 1:
662       return !Group1->LineEdit1->text().isEmpty() && isOk;
663     case 2:
664       return !Group2->LineEdit1->text().isEmpty() &&
665              !Group2->LineEdit2->text().isEmpty() &&
666              !Group2->LineEdit3->text().isEmpty() && isOk;
667   }
668   return false;
669 }
670
671 //=================================================================================
672 // function : execute
673 // purpose  :
674 //=================================================================================
675 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
676 {
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());
681
682   if ( !anObj->_is_nil() )
683     objects.push_back( anObj._retn() );
684
685   return true;
686 }
687
688 //=================================================================================
689 // function : closeEvent
690 // purpose  :
691 //=================================================================================
692 void BasicGUI_MarkerDlg::closeEvent( QCloseEvent* e )
693 {
694   GEOMBase_Skeleton::closeEvent( e );
695 }
696
697 //=================================================================================
698 // function : onValueChanged
699 // purpose  :
700 //=================================================================================
701 void BasicGUI_MarkerDlg::onValueChanged( double )
702 {
703   displayPreview();
704 }
705
706 //=================================================================================
707 // function : displayPreview
708 // purpose  :
709 //=================================================================================
710 void BasicGUI_MarkerDlg::displayPreview ( const bool   activate,
711                                           const bool   update,
712                                           const bool   toRemoveFromEngine,
713                                           const double lineWidth )
714 {
715   if ( !myBlockPreview )
716   {
717     GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
718     if ( myConstructorId == 0 )
719     {
720       GEOMBase_Skeleton::activate( GEOM_MARKER );
721     }
722   }
723 }