]> SALOME platform Git repositories - modules/geom.git/blob - src/BasicGUI/BasicGUI_MarkerDlg.cxx
Salome HOME
Using files from package LightApp instead of SalomeApp
[modules/geom.git] / src / BasicGUI / BasicGUI_MarkerDlg.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : BasicGUI_MarkerDlg.cxx
25 //  Author : Sergey LITONIN
26 //  Module : GEOM
27 //  $Header$
28
29 #include "BasicGUI_MarkerDlg.h"
30 #include "DlgRef_SpinBox.h"
31
32 #include "SUIT_Desktop.h"
33 #include "SUIT_Session.h"
34 #include "SalomeApp_Application.h"
35 #include "LightApp_SelectionMgr.h"
36
37 #include <qlabel.h>
38
39 #include "GEOMImpl_Types.hxx"
40 #include "utilities.h"
41
42 #include <TopExp.hxx>
43 #include <TopAbs.hxx>
44 #include <TopoDS.hxx>
45 #include <TopoDS_Vertex.hxx>
46 #include <TopoDS_Face.hxx>
47 #include <TColStd_IndexedMapOfInteger.hxx>
48 #include <TopTools_IndexedMapOfShape.hxx>
49 #include <BRep_Tool.hxx>
50 #include <gp_Pnt.hxx>
51 #include <gp_Pln.hxx>
52 #include <Geom_Plane.hxx>
53 #include <GProp_GProps.hxx>
54 #include <BRepGProp.hxx>
55
56 //=================================================================================
57 // class    : BasicGUI_MarkerDlg()
58 // purpose  : Constructor
59 //=================================================================================
60 BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* theParent )
61 : GEOMBase_Skeleton( theParent, "BasicGUI_MarkerDlg", false,
62                      WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), myGeometryGUI(theGeometryGUI)
63 {
64   QPixmap iconCS1   ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER" ) ) );
65   QPixmap iconCS2   ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER2" ) ) );
66   QPixmap iconCS3   ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER3" ) ) );
67   QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
68
69   setCaption( tr( "CAPTION" ) );
70
71   GroupConstructors->setTitle( tr( "LOCALCS" ) );
72   RadioButton1->setPixmap( iconCS1 );
73   RadioButton2->setPixmap( iconCS2 );
74   RadioButton3->setPixmap( iconCS3 );
75
76   Group1 = new DlgRef_1Sel_QTD(this, "Group1");
77   Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
78   Group1->TextLabel1->setText(tr("GEOM_OBJECT"));
79   Group1->PushButton1->setPixmap(iconSelect);
80
81   Group2 = new DlgRef_3Sel_QTD(this, "Group2");
82   Group2->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
83   Group2->TextLabel1->setText(tr("GEOM_POINT"));
84   Group2->TextLabel2->setText(tr("XDIR"));
85   Group2->TextLabel3->setText(tr("YDIR"));
86   Group2->PushButton1->setPixmap(iconSelect);
87   Group2->PushButton2->setPixmap(iconSelect);
88   Group2->PushButton3->setPixmap(iconSelect);
89
90   aMainGrp = new QGroupBox( 1, Qt::Horizontal, this );
91   aMainGrp->setFrameStyle( QFrame::NoFrame );
92   aMainGrp->setInsideMargin( 0 );
93
94   QGroupBox* anOriGrp = new QGroupBox( 1, Qt::Vertical, tr( "ORIGIN" ), aMainGrp );
95   new QLabel( tr( "GEOM_X" ), anOriGrp );
96   myData[ X ] = new DlgRef_SpinBox( anOriGrp );
97   new QLabel( tr( "GEOM_Y" ), anOriGrp );
98   myData[ Y ] = new DlgRef_SpinBox( anOriGrp );
99   new QLabel( tr( "GEOM_Z" ), anOriGrp );
100   myData[ Z ] = new DlgRef_SpinBox( anOriGrp );
101
102   QGroupBox* aXAxisGrp = new QGroupBox( 1, Qt::Vertical, tr( "XDIR" ), aMainGrp );
103   new QLabel( tr( "DX" ), aXAxisGrp );
104   myData[ DX1 ] = new DlgRef_SpinBox( aXAxisGrp );
105   new QLabel( tr( "DY" ), aXAxisGrp );
106   myData[ DY1 ] = new DlgRef_SpinBox( aXAxisGrp );
107   new QLabel( tr( "DZ" ), aXAxisGrp );
108   myData[ DZ1 ] = new DlgRef_SpinBox( aXAxisGrp );
109
110   QGroupBox* anYAxisGrp = new QGroupBox( 1, Qt::Vertical, tr( "YDIR" ), aMainGrp );
111   new QLabel( tr( "DX" ), anYAxisGrp );
112   myData[ DX2 ] = new DlgRef_SpinBox( anYAxisGrp );
113   new QLabel( tr( "DY" ), anYAxisGrp );
114   myData[ DY2 ] = new DlgRef_SpinBox( anYAxisGrp );
115   new QLabel( tr( "DZ" ), anYAxisGrp );
116   myData[ DZ2 ] = new DlgRef_SpinBox( anYAxisGrp );
117   
118   Layout1->addWidget( aMainGrp, 2, 0 );
119   Layout1->addWidget( Group1, 2, 0 );
120   Layout1->addWidget( Group2, 2, 0 );
121
122   Init();
123 }
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 //=================================================================================
136 // function : Init()
137 // purpose  :
138 //=================================================================================
139 void BasicGUI_MarkerDlg::Init()
140 {
141   myBlockPreview = false;
142   myConstructorId = -1;
143   myEditCurrentArgument = Group1->LineEdit1;
144   Group1->LineEdit1->setReadOnly( true );
145   Group2->LineEdit1->setReadOnly( true );
146   Group2->LineEdit2->setReadOnly( true );
147   Group2->LineEdit3->setReadOnly( true );
148   
149   connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
150   connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
151   connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
152   connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
153   connect(Group2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
154
155   connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
156   connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
157   connect(Group2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
158   connect(Group2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
159
160   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( onClose() ) );
161   connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
162   connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onClose() ) );
163
164   connect( buttonOk, SIGNAL( clicked() ), this, SLOT( onOk() ) );
165   connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
166
167   connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
168            SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
169
170   initName( tr( "LCS_NAME" ) );
171
172   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
173   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
174   
175   for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
176   {
177     anIter.data()->RangeStepAndValidator( -999.999, 999.999, step, 3 );
178     connect( anIter.data(), SIGNAL( valueChanged( double ) ),
179              this, SLOT( onValueChanged( double ) ) );
180   }
181
182   myBlockPreview = true;
183   for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
184     anIter.data()->SetValue( 0 );
185   myData[ DX1 ]->SetValue( 1 );
186   myData[ DY2 ]->SetValue( 1 );
187   myBlockPreview = false;
188
189   ConstructorsClicked( 0 );
190
191
192   //@
193   /*
194   QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()->
195     getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
196
197   VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>( aFrame );
198   if ( aVTKFrame )
199   {
200     aVTKFrame->AdjustTrihedrons( true );
201     return;
202   }
203
204   OCCViewer_ViewFrame* aOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( aFrame );
205   if ( aOCCFrame )
206     aOCCFrame->AdjustTrihedrons( true );
207   */
208 }
209
210 //=================================================================================
211 // function : ConstructorsClicked()
212 // purpose  : Radio button management
213 //=================================================================================
214 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
215 {
216   if ( myConstructorId == constructorId && myConstructorId == 0 )
217   {
218     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
219     activate( GEOM_MARKER );
220     displayPreview();
221     return;
222   }
223
224   myConstructorId = constructorId;
225
226   disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
227
228   switch (constructorId)
229     {
230     case 0:
231     {
232       Group1->hide();
233       Group2->hide();
234       resize(0, 0);
235       aMainGrp->show();
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         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         resize(0, 0);
257         Group2->show();
258
259         globalSelection( GEOM_POINT );
260         myEditCurrentArgument = Group2->LineEdit1;
261         Group2->LineEdit1->setText("");
262         Group2->LineEdit2->setText("");
263         Group2->LineEdit3->setText("");
264         break;
265       }
266     }
267
268   connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
269           SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone()));
270   onSelectionDone();
271 }
272
273 //=================================================================================
274 // function : onOk()
275 // purpose  :
276 //=================================================================================
277 void BasicGUI_MarkerDlg::onOk()
278 {
279   if ( onApply() )
280     onClose();
281 }
282
283 //=======================================================================
284 // function : onClose()
285 // purpose  :
286 //=======================================================================
287 void BasicGUI_MarkerDlg::onClose()
288 {
289   GEOMBase_Skeleton::ClickOnCancel();
290 }
291
292 //=================================================================================
293 // function : onApply()
294 // purpose  :
295 //=================================================================================
296 bool BasicGUI_MarkerDlg::onApply()
297 {
298   if ( !onAccept() )
299     return false;
300
301   initName();
302   ConstructorsClicked( getConstructorId() );
303   
304   return true;
305 }
306
307 //=================================================================================
308 // function : onSelectionDone0()
309 // purpose  : Reaction on selection when first method of creation is current one
310 //=================================================================================
311 void BasicGUI_MarkerDlg::onSelectionDone0()
312 {
313   if ( IObjectCount() == 1 )
314   {
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     if ( aRes && !aSelectedObj->_is_nil() )
321     {
322       TopoDS_Shape aShape;
323       if ( myGeomBase->GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() )
324       {
325         if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE )
326         {
327           TopoDS_Face aFace = TopoDS::Face( aShape );
328           Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
329
330           if ( !aPlane.IsNull() )
331           {
332             gp_Ax3 anAx3 = aPlane->Pln().Position();
333             gp_Pnt aLoc = anAx3.Location();
334             gp_Dir aXDir = anAx3.XDirection();
335             gp_Dir aYDir = anAx3.YDirection();
336
337             myData[ X ]->SetValue( aLoc.X() );
338             myData[ Y ]->SetValue( aLoc.Y() );
339             myData[ Z ]->SetValue( aLoc.Z() );
340
341             myData[ DX1 ]->SetValue( aXDir.X() );
342             myData[ DY1 ]->SetValue( aXDir.Y() );
343             myData[ DZ1 ]->SetValue( aXDir.Z() );
344
345             myData[ DX2 ]->SetValue( aYDir.X() );
346             myData[ DY2 ]->SetValue( aYDir.Y() );
347             myData[ DZ2 ]->SetValue( aYDir.Z() );
348             ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected();
349           }
350         }
351         else
352         {
353           TColStd_IndexedMapOfInteger aMap;
354           ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap );
355           if ( aMap.Extent() == 1 )
356           {
357             int anIndex = aMap( 1 );
358             TopTools_IndexedMapOfShape aShapes;
359             TopExp::MapShapes( aShape, aShapes );
360             aShape = aShapes.FindKey( anIndex );
361             ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected();
362           }
363           
364
365           if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
366           {
367             gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
368             myData[ X ]->SetValue( aPnt.X() );
369             myData[ Y ]->SetValue( aPnt.Y() );
370             myData[ Z ]->SetValue( aPnt.Z() );
371           }
372         }
373       }
374     }
375   }
376
377   displayPreview();
378 }
379
380
381 //=================================================================================
382 // function : onSelectionDone()
383 // purpose  : Called when selection as changed or other case
384 //=================================================================================
385 void BasicGUI_MarkerDlg::onSelectionDone()
386 {
387   if ( getConstructorId() == 0 )
388   {
389     onSelectionDone0();
390     return;
391   }
392     
393
394   myEditCurrentArgument->setText("");
395   QString aName;
396
397   if ( IObjectCount() == 1 ) {
398     Standard_Boolean aRes = Standard_False;
399     Handle(SALOME_InteractiveObject) anIO = firstIObject();
400     GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
401
402     if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
403       aName = GEOMBase::GetName( aSelectedObj );
404       TopoDS_Shape aShape;
405       if ( myGeomBase->GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
406         GEOM::short_array anIndexes;
407
408         TColStd_IndexedMapOfInteger aMap;
409         ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap );
410         
411         if ( !aMap.IsEmpty() ) { 
412           int anIndex = aMap( 1 );
413           TopTools_IndexedMapOfShape aShapes;
414           TopExp::MapShapes( aShape, aShapes );
415           aShape = aShapes.FindKey( anIndex );
416         }
417
418         if ( getConstructorId() == 1 ) {
419           if ( !aShape.IsNull() ) {
420             gp_Pnt aPnt;
421             if (aShape.ShapeType() == TopAbs_VERTEX) {
422               aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
423             } 
424             else {
425               GProp_GProps aSystem;
426               if (aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE)
427                 BRepGProp::LinearProperties(aShape, aSystem);
428               else if (aShape.ShapeType() == TopAbs_FACE || aShape.ShapeType() == TopAbs_SHELL)
429                 BRepGProp::SurfaceProperties(aShape, aSystem);
430               else
431                 BRepGProp::VolumeProperties(aShape, aSystem);
432               
433               aPnt = aSystem.CentreOfMass();
434             }
435             
436             gp_Ax3 anAx3;
437             anAx3.Transform(aShape.Location().Transformation());
438             if(aShape.ShapeType() == TopAbs_FACE) {
439               Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShape ) );
440               if (!aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) {
441                 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS );
442                 gp_Pln aPln = aGPlane->Pln();
443                 anAx3 = aPln.Position();
444               }
445             }
446             
447             gp_Dir aDirX = anAx3.XDirection();
448             gp_Dir aDirY = anAx3.YDirection();
449             
450             myData[ X ]->SetValue( aPnt.X() );
451             myData[ Y ]->SetValue( aPnt.Y() );
452             myData[ Z ]->SetValue( aPnt.Z() );
453             
454             myData[ DX1 ]->SetValue( aDirX.X() );
455             myData[ DY1 ]->SetValue( aDirX.Y() );
456             myData[ DZ1 ]->SetValue( aDirX.Z() );
457             
458             myData[ DX2 ]->SetValue( aDirY.X() );
459             myData[ DY2 ]->SetValue( aDirY.Y() );
460             myData[ DZ2 ]->SetValue( aDirY.Z() );
461             
462             myEditCurrentArgument->setText( aName );
463           }
464           else {
465             myData[ X ]->SetValue( 0 );
466             myData[ Y ]->SetValue( 0 );
467             myData[ Z ]->SetValue( 0 );
468             
469             myData[ DX1 ]->SetValue( 0 );
470             myData[ DY1 ]->SetValue( 0 );
471             myData[ DZ1 ]->SetValue( 0 );
472             
473             myData[ DX2 ]->SetValue( 0 );
474             myData[ DY2 ]->SetValue( 0 );
475             myData[ DZ2 ]->SetValue( 0 );
476           }
477         }
478         else if ( getConstructorId() == 2 ) {
479           if (myEditCurrentArgument == Group2->LineEdit1) {
480             if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
481               gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
482               myData[ X ]->SetValue( aPnt.X() );
483               myData[ Y ]->SetValue( aPnt.Y() );
484               myData[ Z ]->SetValue( aPnt.Z() );
485               myEditCurrentArgument->setText( aName );
486             }
487             else {
488               myData[ X ]->SetValue( 0 );
489               myData[ Y ]->SetValue( 0 );
490               myData[ Z ]->SetValue( 0 );
491             }
492           }
493           else if (myEditCurrentArgument == Group2->LineEdit2) {
494             if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
495               gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape)));
496               gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape)));
497               gp_Dir aDir(gp_Vec(aP1, aP2));
498               
499               myData[ DX1 ]->SetValue( aDir.X() );
500               myData[ DY1 ]->SetValue( aDir.Y() );
501               myData[ DZ1 ]->SetValue( aDir.Z() );
502               myEditCurrentArgument->setText( aName );
503             }
504             else {
505               myData[ DX1 ]->SetValue( 0 );
506               myData[ DY1 ]->SetValue( 0 );
507               myData[ DZ1 ]->SetValue( 0 );
508             }
509           }
510           else if (myEditCurrentArgument == Group2->LineEdit3) {
511             if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
512               gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape)));
513               gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape)));
514               gp_Dir aDir(gp_Vec(aP1, aP2));
515               
516               myData[ DX2 ]->SetValue( aDir.X() );
517               myData[ DY2 ]->SetValue( aDir.Y() );
518               myData[ DZ2 ]->SetValue( aDir.Z() );
519               myEditCurrentArgument->setText( aName );
520             }
521             else {
522               myData[ DX2 ]->SetValue( 0 );
523               myData[ DY2 ]->SetValue( 0 );
524               myData[ DZ2 ]->SetValue( 0 );
525             }
526           }
527         }
528       }
529     }
530   }
531   else {
532     if ( getConstructorId() == 1 ) {
533       myData[ X ]->SetValue( 0 );
534       myData[ Y ]->SetValue( 0 );
535       myData[ Z ]->SetValue( 0 );
536       
537       myData[ DX1 ]->SetValue( 0 );
538       myData[ DY1 ]->SetValue( 0 );
539       myData[ DZ1 ]->SetValue( 0 );
540       
541       myData[ DX2 ]->SetValue( 0 );
542       myData[ DY2 ]->SetValue( 0 );
543       myData[ DZ2 ]->SetValue( 0 );
544     }
545     else if ( getConstructorId() == 2 ) {
546       if (myEditCurrentArgument == Group2->LineEdit1) {
547         myData[ X ]->SetValue( 0 );
548         myData[ Y ]->SetValue( 0 );
549         myData[ Z ]->SetValue( 0 );
550       }
551       else if (myEditCurrentArgument == Group2->LineEdit2) {
552         myData[ DX1 ]->SetValue( 0 );
553         myData[ DY1 ]->SetValue( 0 );
554         myData[ DZ1 ]->SetValue( 0 );
555       }
556       else if (myEditCurrentArgument == Group2->LineEdit3) {
557         myData[ DX2 ]->SetValue( 0 );
558         myData[ DY2 ]->SetValue( 0 );
559         myData[ DZ2 ]->SetValue( 0 );
560       }
561     }    
562   }
563   
564   displayPreview();
565 }
566
567 //=================================================================================
568 // function : SetEditCurrentArgument()
569 // purpose  :
570 //=================================================================================
571 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
572 {
573   QPushButton* send = (QPushButton*)sender();
574   
575   if(send == Group1->PushButton1) {
576     myEditCurrentArgument = Group1->LineEdit1;
577     globalSelection( GEOM_ALLGEOM );
578   }
579   else if(send == Group2->PushButton1) {
580     myEditCurrentArgument = Group2->LineEdit1;
581     globalSelection( GEOM_POINT );
582   }
583   else if(send == Group2->PushButton2) {
584     myEditCurrentArgument = Group2->LineEdit2;
585       globalSelection( GEOM_LINE );
586   }
587   else if(send == Group2->PushButton3) {
588     myEditCurrentArgument = Group2->LineEdit3;
589     globalSelection( GEOM_LINE );
590   }
591   
592   myEditCurrentArgument->setFocus();
593   onSelectionDone();
594 }
595
596 //=================================================================================
597 // function : LineEditReturnPressed()
598 // purpose  :
599 //=================================================================================
600 void BasicGUI_MarkerDlg::LineEditReturnPressed()
601 {
602   QLineEdit* send = (QLineEdit*)sender();
603
604   myEditCurrentArgument = send;
605   GEOMBase_Skeleton::LineEditReturnPressed();
606 }
607
608 //=================================================================================
609 // function : onActivate()
610 // purpose  :
611 //=================================================================================
612 void BasicGUI_MarkerDlg::onActivate()
613 {
614   GEOMBase_Skeleton::ActivateThisDialog();
615   connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
616            SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
617
618   ConstructorsClicked( getConstructorId() );
619 }
620
621 //=================================================================================
622 // function : onDeactivate()
623 // purpose  : public slot to deactivate if active
624 //=================================================================================
625 void BasicGUI_MarkerDlg::onDeactivate()
626 {
627   GEOMBase_Skeleton::DeactivateActiveDialog();
628 }
629
630 //=================================================================================
631 // function : enterEvent()
632 // purpose  :
633 //=================================================================================
634 void BasicGUI_MarkerDlg::enterEvent(QEvent* e)
635 {                       
636   if ( !GroupConstructors->isEnabled() )
637     onActivate();
638 }
639
640 //=================================================================================
641 // function : createOperation
642 // purpose  :
643 //=================================================================================
644 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
645 {
646   return myGeometryGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
647 }
648
649 //=================================================================================
650 // function : isValid
651 // purpose  :
652 //=================================================================================
653 bool BasicGUI_MarkerDlg::isValid( QString& msg )
654 {
655   const int id = getConstructorId();
656   gp_Vec v1( myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue() ),
657          v2( myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() );
658
659   bool isOk = false;
660   // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
661   // Vectors shouldn't be checked for being orthogonal here!
662   if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
663     isOk = !v1.IsParallel( v2, Precision::Angular() );
664     if ( !isOk )
665       msg += tr( "VEC_PARALLEL" );
666   }
667
668   switch ( id )
669   {
670     case 0:
671       return isOk;
672     case 1:
673       return !Group1->LineEdit1->text().isEmpty() && isOk;
674     case 2:
675       return !Group2->LineEdit1->text().isEmpty() && 
676              !Group2->LineEdit2->text().isEmpty() && 
677              !Group2->LineEdit3->text().isEmpty() && isOk;
678   }
679   return false;
680 }
681
682 //=================================================================================
683 // function : execute
684 // purpose  :
685 //=================================================================================
686 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
687 {
688   GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow(
689     getOperation() )->MakeMarker( myData[ X   ]->GetValue(), myData[ Y   ]->GetValue(), myData[ Z   ]->GetValue(),
690                                   myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue(),
691                                   myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() );
692
693   if ( !anObj->_is_nil() )
694     objects.push_back( anObj._retn() );
695
696   return true;
697 }
698
699 //=================================================================================
700 // function : closeEvent
701 // purpose  :
702 //=================================================================================
703 void BasicGUI_MarkerDlg::closeEvent( QCloseEvent* e )
704 {
705   GEOMBase_Skeleton::closeEvent( e );
706 }
707
708 //=================================================================================
709 // function : onValueChanged
710 // purpose  :
711 //=================================================================================
712 void BasicGUI_MarkerDlg::onValueChanged( double )
713 {
714   displayPreview();
715 }
716
717 //=================================================================================
718 // function : displayPreview
719 // purpose  :
720 //=================================================================================
721 void BasicGUI_MarkerDlg::displayPreview ( const bool   activate,
722                                           const bool   update,
723                                           const bool   toRemoveFromEngine,
724                                           const double lineWidth )
725 {
726   if ( !myBlockPreview )
727   {
728     GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
729     if ( myConstructorId == 0 )
730     {
731       GEOMBase_Skeleton::activate( GEOM_MARKER );
732     }
733   }
734 }
735
736
737
738
739
740
741
742
743
744
745
746
747
748