]> SALOME platform Git repositories - modules/geom.git/blob - src/BasicGUI/BasicGUI_CircleDlg.cxx
Salome HOME
Mantis issue 0021071: Regression in GetInPlace. A fix by PKV on Partition error.
[modules/geom.git] / src / BasicGUI / BasicGUI_CircleDlg.cxx
1 //  Copyright (C) 2007-2010  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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : BasicGUI_CircleDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 //
27 #include "BasicGUI_CircleDlg.h"
28
29 #include <DlgRef.h>
30
31 #include <GeometryGUI.h>
32 #include <GEOMBase.h>
33
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Session.h>
36 #include <SalomeApp_Application.h>
37 #include <LightApp_SelectionMgr.h>
38
39 #include <TColStd_IndexedMapOfInteger.hxx>
40 #include <TopTools_IndexedMapOfShape.hxx>
41 #include <TopoDS_Shape.hxx>
42 #include <TopoDS_Edge.hxx>
43 #include <TopoDS.hxx>
44 #include <TopExp.hxx>
45
46 //=================================================================================
47 // class    : BasicGUI_CircleDlg()
48 // purpose  : Constructs a BasicGUI_CircleDlg which is a child of 'parent', with the 
49 //            name 'name' and widget flags set to 'f'.
50 //            The dialog will by default be modeless, unless you set 'modal' to
51 //            TRUE to construct a modal dialog.
52 //=================================================================================
53 BasicGUI_CircleDlg::BasicGUI_CircleDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
54                                         bool modal, Qt::WindowFlags fl )
55   : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
56 {
57   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PV" ) ) );
58   QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PNTS" ) ) );
59   QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_C2P" ) ) );
60   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
61
62   setWindowTitle( tr( "GEOM_CIRCLE_TITLE" ) );
63
64   /***************************************************************/
65   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CIRCLE" ) );
66   mainFrame()->RadioButton1->setIcon( image0 );
67   mainFrame()->RadioButton2->setIcon( image2 );
68   mainFrame()->RadioButton3->setIcon( image3 );
69
70   GroupPntVecR = new DlgRef_2Sel1Spin( centralWidget() );
71   GroupPntVecR->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
72   
73   GroupPntVecR->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) + " " + tr( "GEOM_CENTER_DEFAULT" )  );
74   GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " " + tr( "GEOM_AXIS_DEFAULT" ) );
75   GroupPntVecR->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
76   GroupPntVecR->PushButton1->setIcon( image1 );
77   GroupPntVecR->PushButton2->setIcon( image1 );
78   GroupPntVecR->PushButton1->setDown( true );
79
80   GroupPntVecR->LineEdit1->setReadOnly( true );
81   GroupPntVecR->LineEdit2->setReadOnly( true );
82
83   GroupPntVecR->LineEdit1->setEnabled( true );
84   GroupPntVecR->LineEdit2->setEnabled( false );
85
86   Group3Pnts = new DlgRef_3Sel( centralWidget() );
87
88   Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
89   Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
90   Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
91   Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
92   Group3Pnts->PushButton1->setIcon( image1 );
93   Group3Pnts->PushButton2->setIcon( image1 );
94   Group3Pnts->PushButton3->setIcon( image1 );
95   Group3Pnts->PushButton1->setDown( true );
96
97   Group3Pnts->LineEdit1->setReadOnly( true );
98   Group3Pnts->LineEdit2->setReadOnly( true );
99   Group3Pnts->LineEdit3->setReadOnly( true );
100   Group3Pnts->LineEdit1->setEnabled( true );
101   Group3Pnts->LineEdit2->setEnabled( false );
102   Group3Pnts->LineEdit3->setEnabled( false );
103
104   GroupCenter2Pnts = new DlgRef_3Sel( centralWidget() );
105   GroupCenter2Pnts->GroupBox1->setTitle( tr( "GEOM_CENTER_2POINTS" ) );
106   GroupCenter2Pnts->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) );
107   GroupCenter2Pnts->TextLabel2->setText( tr( "GEOM_POINT1" ) );
108   GroupCenter2Pnts->TextLabel3->setText( tr( "GEOM_POINT2" ) );
109   GroupCenter2Pnts->PushButton1->setIcon( image1 );
110   GroupCenter2Pnts->PushButton2->setIcon( image1 );
111   GroupCenter2Pnts->PushButton3->setIcon( image1 );
112   GroupCenter2Pnts->PushButton1->setDown( true );
113
114   GroupCenter2Pnts->LineEdit1->setReadOnly( true );
115   GroupCenter2Pnts->LineEdit2->setReadOnly( true );
116   GroupCenter2Pnts->LineEdit3->setReadOnly( true );
117
118   GroupCenter2Pnts->LineEdit1->setEnabled( true );
119   GroupCenter2Pnts->LineEdit2->setEnabled( false );
120   GroupCenter2Pnts->LineEdit3->setEnabled( false );
121
122   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
123   layout->setMargin( 0 ); layout->setSpacing( 6 );
124   layout->addWidget( GroupPntVecR );
125   layout->addWidget( Group3Pnts );
126   layout->addWidget( GroupCenter2Pnts );
127   /***************************************************************/
128
129   setHelpFileName( "create_circle_page.html" );
130
131   Init();
132 }
133
134
135 //=================================================================================
136 // function : ~BasicGUI_CircleDlg()
137 // purpose  : Destroys the object and frees any allocated resources
138 //=================================================================================
139 BasicGUI_CircleDlg::~BasicGUI_CircleDlg()
140 {
141 }
142
143
144 //=================================================================================
145 // function : Init()
146 // purpose  :
147 //=================================================================================
148 void BasicGUI_CircleDlg::Init()
149 {
150   /* init variables */
151   myEditCurrentArgument = GroupPntVecR->LineEdit1;
152
153   myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
154
155   // myGeomGUI->SetState( 0 );
156
157   /* Get setting of step value from file configuration */
158   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
159   double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
160
161   /* min, max, step and decimals for spin boxes & initial values */
162   initSpinBox( GroupPntVecR->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
163   GroupPntVecR->SpinBox_DX->setValue( 100 );
164
165   /* signals and slots connections */
166   connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
167   connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
168   
169   connect( buttonOk(),     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
170   connect( buttonApply(),  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
171
172   connect( this,           SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
173
174   connect( GroupPntVecR->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
175   connect( GroupPntVecR->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
176   connect( Group3Pnts->PushButton1,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
177   connect( Group3Pnts->PushButton2,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
178   connect( Group3Pnts->PushButton3,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
179
180   connect( GroupCenter2Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
181   connect( GroupCenter2Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
182   connect( GroupCenter2Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
183
184   connect( GroupPntVecR->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
185   connect( GroupPntVecR->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
186
187   connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) );
188   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
189
190   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
191            this, SLOT( SelectionIntoArgument() ) );
192
193   initName( tr( "GEOM_CIRCLE" ) );
194
195   ConstructorsClicked( 0 );
196 }
197
198 //=================================================================================
199 // function : SetDoubleSpinBoxStep()
200 // purpose  : Double spin box management
201 //=================================================================================
202 void BasicGUI_CircleDlg::SetDoubleSpinBoxStep( double step )
203 {
204   GroupPntVecR->SpinBox_DX->setSingleStep(step);
205 }
206
207 //=================================================================================
208 // function : ConstructorsClicked()
209 // purpose  : Radio button management
210 //=================================================================================
211 void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId )
212 {
213   disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
214
215   myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
216
217   switch ( constructorId ) {
218   case 0:
219     {
220       Group3Pnts->hide();
221       GroupCenter2Pnts->hide();
222       GroupPntVecR->show();
223       
224       myEditCurrentArgument = GroupPntVecR->LineEdit1;
225       GroupPntVecR->LineEdit1->setText( "" );
226       GroupPntVecR->LineEdit2->setText( "" );
227       GroupPntVecR->PushButton1->setDown( true );
228       GroupPntVecR->PushButton2->setDown( false );
229       GroupPntVecR->LineEdit1->setEnabled( true );
230       GroupPntVecR->LineEdit2->setEnabled( false );
231       break;
232     }
233   case 1:
234     {
235       GroupPntVecR->hide();
236       GroupCenter2Pnts->hide();
237       Group3Pnts->show();
238       
239       myEditCurrentArgument = Group3Pnts->LineEdit1;
240       Group3Pnts->LineEdit1->setText( "" );
241       Group3Pnts->LineEdit2->setText( "" );
242       Group3Pnts->LineEdit3->setText( "" );
243       Group3Pnts->PushButton1->setDown( true );
244       Group3Pnts->PushButton2->setDown( false );
245       Group3Pnts->PushButton3->setDown( false );
246       Group3Pnts->LineEdit1->setEnabled( true );
247       Group3Pnts->LineEdit2->setEnabled( false );
248       Group3Pnts->LineEdit3->setEnabled( false );
249       break;
250     }
251   case 2:
252     {
253       GroupPntVecR->hide();
254       Group3Pnts->hide();               
255       GroupCenter2Pnts->show();
256       
257       myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
258       GroupCenter2Pnts->LineEdit1->setText( "" );
259       GroupCenter2Pnts->LineEdit2->setText( "" );
260       GroupCenter2Pnts->LineEdit3->setText( "" );
261       GroupCenter2Pnts->PushButton1->setDown( true );
262       GroupCenter2Pnts->PushButton2->setDown( false );
263       GroupCenter2Pnts->PushButton3->setDown( false );
264       GroupCenter2Pnts->LineEdit1->setEnabled( true );
265       GroupCenter2Pnts->LineEdit2->setEnabled( false );
266       GroupCenter2Pnts->LineEdit3->setEnabled( false );
267       break;
268     }
269   }
270   
271   qApp->processEvents();
272   updateGeometry();
273   resize( minimumSizeHint() );
274   SelectionIntoArgument();
275
276   myEditCurrentArgument->setFocus();
277   globalSelection(); // close local contexts, if any
278   localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
279
280   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
281            this, SLOT( SelectionIntoArgument() ) );
282
283   displayPreview();
284 }
285
286 //=================================================================================
287 // function : ClickOnOk()
288 // purpose  :
289 //=================================================================================
290 void BasicGUI_CircleDlg::ClickOnOk()
291 {
292   if ( ClickOnApply() )
293     ClickOnCancel();
294 }
295
296 //=================================================================================
297 // function : ClickOnApply()
298 // purpose  :
299 //=================================================================================
300 bool BasicGUI_CircleDlg::ClickOnApply()
301 {
302   if ( !onAccept() )
303     return false;
304
305   initName();
306   ConstructorsClicked( getConstructorId() );
307   return true;
308 }
309
310 //=================================================================================
311 // function : SelectionIntoArgument()
312 // purpose  : Called when selection as changed or other case
313 //=================================================================================
314 void BasicGUI_CircleDlg::SelectionIntoArgument()
315 {
316   myEditCurrentArgument->setText( "" );
317   
318   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
319   SALOME_ListIO aList;
320   aSelMgr->selectedObjects( aList );
321
322   if ( aList.Extent() != 1 ) {
323     if      ( myEditCurrentArgument == GroupPntVecR->LineEdit1 )     myPoint  = GEOM::GEOM_Object::_nil();
324     else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )     myDir    = GEOM::GEOM_Object::_nil();
325     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 )       myPoint1 = GEOM::GEOM_Object::_nil();
326     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 )       myPoint2 = GEOM::GEOM_Object::_nil();
327     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 )       myPoint3 = GEOM::GEOM_Object::_nil();
328     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4 = GEOM::GEOM_Object::_nil();
329     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5 = GEOM::GEOM_Object::_nil();
330     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6 = GEOM::GEOM_Object::_nil();
331     return;
332   }
333
334   // nbSel == 1
335   Handle(SALOME_InteractiveObject) anIO = aList.First();
336
337   Standard_Boolean aRes = Standard_False;
338   GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
339   if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
340     QString aName = GEOMBase::GetName( aSelectedObject );
341
342     TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
343     if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )
344       aNeedType = TopAbs_EDGE;
345
346     // If selected Vertex or Edge on the some Shape Get selection Subshape
347     TopoDS_Shape aShape;
348     if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
349       TColStd_IndexedMapOfInteger aMap;
350       aSelMgr->GetIndexes(anIO, aMap);
351       if ( aMap.Extent() == 1 ) { // Local Selection
352         int anIndex = aMap(1);
353         if ( aNeedType == TopAbs_EDGE )
354           aName += QString( ":edge_%1" ).arg( anIndex );
355         else
356           aName += QString( ":vertex_%1" ).arg( anIndex );
357
358         //Find SubShape Object in Father
359         GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
360
361                 if ( aFindedObject->_is_nil() ) { // Object not found in study
362           GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
363           aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
364         }
365         else {
366           aSelectedObject = aFindedObject; // get Object from study
367         }
368       }
369       else { // Global Selection
370         if ( aShape.ShapeType() != aNeedType ) {
371           aSelectedObject = GEOM::GEOM_Object::_nil();
372           aName = "";
373         }
374       }
375     }
376     
377     myEditCurrentArgument->setText( aName );
378
379     if (!aSelectedObject->_is_nil()) { // clear selection if something selected
380       globalSelection();
381       localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
382     }
383
384     if      ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
385       myPoint  = aSelectedObject;
386       if ( !myPoint->_is_nil() && myDir->_is_nil() )
387         GroupPntVecR->PushButton2->click();
388     }
389     else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
390       myDir    = aSelectedObject;
391       if ( !myDir->_is_nil() && myPoint->_is_nil() )
392         GroupPntVecR->PushButton1->click();
393     }
394     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
395       myPoint1 = aSelectedObject;
396       if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
397         Group3Pnts->PushButton2->click();
398     }
399     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
400       myPoint2 = aSelectedObject;
401       if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
402         Group3Pnts->PushButton3->click();
403     }
404     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
405       myPoint3 = aSelectedObject;
406       if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
407         Group3Pnts->PushButton1->click();
408     }
409     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
410       myPoint4 = aSelectedObject;
411       if ( !myPoint4->_is_nil() && myPoint5->_is_nil() )
412         GroupCenter2Pnts->PushButton2->click();
413     }
414     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
415       myPoint5 = aSelectedObject;
416       if ( !myPoint5->_is_nil() && myPoint6->_is_nil() )
417         GroupCenter2Pnts->PushButton3->click();
418     }
419     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
420       myPoint6 = aSelectedObject;
421       if ( !myPoint6->_is_nil() && myPoint4->_is_nil() )
422         GroupCenter2Pnts->PushButton1->click();
423     }
424   }
425
426   displayPreview();
427 }
428
429
430 //=================================================================================
431 // function : SetEditCurrentArgument()
432 // purpose  :
433 //=================================================================================
434 void BasicGUI_CircleDlg::SetEditCurrentArgument()
435 {
436   QPushButton* send = (QPushButton*)sender();
437
438   if ( send == GroupPntVecR->PushButton1 ) {
439     myEditCurrentArgument = GroupPntVecR->LineEdit1;
440     GroupPntVecR->PushButton2->setDown(false);
441     GroupPntVecR->LineEdit1->setEnabled( true );
442     GroupPntVecR->LineEdit2->setEnabled( false );
443   }
444   else if ( send == GroupPntVecR->PushButton2 ) {
445     myEditCurrentArgument = GroupPntVecR->LineEdit2;
446     GroupPntVecR->PushButton1->setDown(false);
447     GroupPntVecR->LineEdit1->setEnabled( false );
448     GroupPntVecR->LineEdit2->setEnabled( true );
449   }
450   else if ( send == Group3Pnts->PushButton1 ) {
451     myEditCurrentArgument = Group3Pnts->LineEdit1;
452     Group3Pnts->PushButton2->setDown( false );
453     Group3Pnts->PushButton3->setDown( false );
454     Group3Pnts->LineEdit1->setEnabled( true );
455     Group3Pnts->LineEdit2->setEnabled( false );
456     Group3Pnts->LineEdit3->setEnabled( false );
457   }
458   else if ( send == Group3Pnts->PushButton2 )  {
459     myEditCurrentArgument = Group3Pnts->LineEdit2;
460     Group3Pnts->PushButton1->setDown( false );
461     Group3Pnts->PushButton3->setDown( false );
462     Group3Pnts->LineEdit1->setEnabled( false );
463     Group3Pnts->LineEdit2->setEnabled( true );
464     Group3Pnts->LineEdit3->setEnabled( false );
465   }
466   else if ( send == Group3Pnts->PushButton3 ) {
467     myEditCurrentArgument = Group3Pnts->LineEdit3;
468     Group3Pnts->PushButton1->setDown( false );
469     Group3Pnts->PushButton2->setDown( false );
470     Group3Pnts->LineEdit1->setEnabled( false );
471     Group3Pnts->LineEdit2->setEnabled( false );
472     Group3Pnts->LineEdit3->setEnabled( true );
473   }
474   else if ( send == GroupCenter2Pnts->PushButton1 ) {
475     myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
476     GroupCenter2Pnts->PushButton2->setDown( false );
477     GroupCenter2Pnts->PushButton3->setDown( false );
478     GroupCenter2Pnts->LineEdit1->setEnabled( true );
479     GroupCenter2Pnts->LineEdit2->setEnabled( false );
480     GroupCenter2Pnts->LineEdit3->setEnabled( false );
481   }
482   else if ( send == GroupCenter2Pnts->PushButton2 ) {
483     myEditCurrentArgument = GroupCenter2Pnts->LineEdit2;
484     GroupCenter2Pnts->PushButton1->setDown( false );
485     GroupCenter2Pnts->PushButton3->setDown( false );
486     GroupCenter2Pnts->LineEdit1->setEnabled( false );
487     GroupCenter2Pnts->LineEdit2->setEnabled( true );
488     GroupCenter2Pnts->LineEdit3->setEnabled( false );
489     
490   }
491   else if ( send == GroupCenter2Pnts->PushButton3 ) {
492     myEditCurrentArgument = GroupCenter2Pnts->LineEdit3;
493     GroupCenter2Pnts->PushButton1->setDown( false );
494     GroupCenter2Pnts->PushButton2->setDown( false );
495     GroupCenter2Pnts->LineEdit1->setEnabled( false );
496     GroupCenter2Pnts->LineEdit2->setEnabled( false );
497     GroupCenter2Pnts->LineEdit3->setEnabled( true );
498   }
499
500   
501   myEditCurrentArgument->setFocus();
502
503   if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
504     globalSelection(); // close local contexts, if any
505     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
506   }
507   else {
508     globalSelection(); // close local contexts, if any
509     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
510   }
511
512   myEditCurrentArgument->setFocus();
513   //  SelectionIntoArgument();
514   send->setDown(true);
515   displayPreview();
516 }
517
518 //=================================================================================
519 // function : LineEditReturnPressed()
520 // purpose  :
521 //=================================================================================
522 void BasicGUI_CircleDlg::LineEditReturnPressed()
523 {
524   QLineEdit* send = (QLineEdit*)sender();
525   if ( send == GroupPntVecR->LineEdit1 ||
526        send == GroupPntVecR->LineEdit2 ||
527        send == Group3Pnts->LineEdit1 ||
528        send == Group3Pnts->LineEdit2 ||
529        send == Group3Pnts->LineEdit3 ||
530        send == GroupCenter2Pnts->LineEdit1 ||
531        send == GroupCenter2Pnts->LineEdit2 ||
532        send == GroupCenter2Pnts->LineEdit3 ) {
533     myEditCurrentArgument = send;
534     GEOMBase_Skeleton::LineEditReturnPressed();
535   }
536 }
537
538
539 //=================================================================================
540 // function : ActivateThisDialog()
541 // purpose  :
542 //=================================================================================
543 void BasicGUI_CircleDlg::ActivateThisDialog()
544 {
545   GEOMBase_Skeleton::ActivateThisDialog();
546
547   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
548            this, SLOT( SelectionIntoArgument() ) );
549
550   ConstructorsClicked( getConstructorId() );
551 }
552
553
554 //=================================================================================
555 // function : enterEvent()
556 // purpose  :
557 //=================================================================================
558 void BasicGUI_CircleDlg::enterEvent( QEvent* )
559 {
560   if ( !mainFrame()->GroupConstructors->isEnabled() )
561     ActivateThisDialog();
562 }
563
564 //=================================================================================
565 // function : DeactivateActiveDialog()
566 // purpose  : public slot to deactivate if active
567 //=================================================================================
568 void BasicGUI_CircleDlg::DeactivateActiveDialog()
569 {
570   // myGeomGUI->SetState( -1 );
571   GEOMBase_Skeleton::DeactivateActiveDialog();
572 }
573
574 //=================================================================================
575 // function : ValueChangedInSpinBox()
576 // purpose  :
577 //=================================================================================
578 void BasicGUI_CircleDlg::ValueChangedInSpinBox()
579 {
580   displayPreview();
581 }
582
583 //=================================================================================
584 // function : getRadius()
585 // purpose  :
586 //=================================================================================
587 double BasicGUI_CircleDlg::getRadius() const
588 {
589   double r = 0.;
590   switch ( getConstructorId() ) {
591   case 0:
592     r = GroupPntVecR->SpinBox_DX->value(); break;
593   }
594   return r;
595 }
596
597 //=================================================================================
598 // function : createOperation
599 // purpose  :
600 //=================================================================================
601 GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation()
602 {
603   return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
604 }
605
606 //=================================================================================
607 // function : isEqual
608 // purpose  : it may also be needed to check for min distance between gp_Pnt-s...
609 //=================================================================================
610 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
611 {
612   return thePnt1->_is_equivalent( thePnt2 );
613 }
614
615 //=================================================================================
616 // function : isValid
617 // purpose  :
618 //=================================================================================
619 bool BasicGUI_CircleDlg::isValid( QString& msg )
620 {
621   const int id = getConstructorId();
622   if ( id == 0 ) {
623     //return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0;
624     //nil point means origin of global CS
625     //nil vector means Z axis
626     bool ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview());
627     return getRadius() > 0 && ok;
628   }
629   else if ( id == 1 )
630     return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
631       !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
632   else if ( id == 2 )
633     return !myPoint4->_is_nil() && !myPoint5->_is_nil() && !myPoint6->_is_nil() &&
634       !isEqual( myPoint4, myPoint5 ) && !isEqual( myPoint5, myPoint6 ) && !isEqual( myPoint4, myPoint6 );
635   return false;
636 }
637
638 //=================================================================================
639 // function : execute
640 // purpose  :
641 //=================================================================================
642 bool BasicGUI_CircleDlg::execute( ObjectList& objects )
643 {
644   bool res = false;
645   
646   GEOM::GEOM_Object_var anObj;
647   
648   GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
649
650   switch ( getConstructorId() ) {
651   case 0 :
652     {
653       QStringList aParameters;
654       aParameters << GroupPntVecR->SpinBox_DX->text();
655       anObj = anOper->MakeCirclePntVecR( myPoint, myDir, getRadius() );
656       if ( !anObj->_is_nil() && !IsPreview() )
657         anObj->SetParameters(aParameters.join(":").toLatin1().constData());
658       res = true;
659       break;
660     }
661   case 1 :
662     anObj = anOper->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 );
663     res = true;
664     break;
665   case 2:
666     anObj = anOper->MakeCircleCenter2Pnt( myPoint4, myPoint5, myPoint6 );
667     res = true;
668     break;
669   }
670   
671   if ( !anObj->_is_nil() )
672     objects.push_back( anObj._retn() );
673   else {
674     MESSAGE( "Execute Object is NULL!" );
675   }
676   
677   return res;
678 }
679
680 //=================================================================================
681 // function : addSubshapeToStudy
682 // purpose  : virtual method to add new SubObjects if local selection
683 //=================================================================================
684 void BasicGUI_CircleDlg::addSubshapesToStudy()
685 {
686   QMap<QString, GEOM::GEOM_Object_var> objMap;
687
688   switch ( getConstructorId() ) {
689   case 0:
690     if (!CORBA::is_nil(myPoint))
691       objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
692     if (!CORBA::is_nil(myDir))
693       objMap[GroupPntVecR->LineEdit2->text()] = myDir;
694     break;
695   case 1:
696     objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
697     objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
698     objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
699     break;
700   case 2:
701     objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4;
702     objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5;
703     objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6;
704     break;
705   }
706   addSubshapesToFather( objMap );
707 }