]> SALOME platform Git repositories - modules/geom.git/blob - src/BasicGUI/BasicGUI_CircleDlg.cxx
Salome HOME
Update copyright notes (for 2010)
[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" ) + " (Origin by default)" );
74   GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " (Z axis by 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
275   myEditCurrentArgument->setFocus();
276   globalSelection(); // close local contexts, if any
277   localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
278
279   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
280            this, SLOT( SelectionIntoArgument() ) );
281
282   displayPreview();
283 }
284
285 //=================================================================================
286 // function : ClickOnOk()
287 // purpose  :
288 //=================================================================================
289 void BasicGUI_CircleDlg::ClickOnOk()
290 {
291   if ( ClickOnApply() )
292     ClickOnCancel();
293 }
294
295 //=================================================================================
296 // function : ClickOnApply()
297 // purpose  :
298 //=================================================================================
299 bool BasicGUI_CircleDlg::ClickOnApply()
300 {
301   if ( !onAccept() )
302     return false;
303
304   initName();
305   ConstructorsClicked( getConstructorId() );
306   return true;
307 }
308
309 //=================================================================================
310 // function : SelectionIntoArgument()
311 // purpose  : Called when selection as changed or other case
312 //=================================================================================
313 void BasicGUI_CircleDlg::SelectionIntoArgument()
314 {
315   myEditCurrentArgument->setText( "" );
316   
317   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
318   SALOME_ListIO aList;
319   aSelMgr->selectedObjects( aList );
320
321   if ( aList.Extent() != 1 ) {
322     if      ( myEditCurrentArgument == GroupPntVecR->LineEdit1 )     myPoint  = GEOM::GEOM_Object::_nil();
323     else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )     myDir    = GEOM::GEOM_Object::_nil();
324     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 )       myPoint1 = GEOM::GEOM_Object::_nil();
325     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 )       myPoint2 = GEOM::GEOM_Object::_nil();
326     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 )       myPoint3 = GEOM::GEOM_Object::_nil();
327     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4 = GEOM::GEOM_Object::_nil();
328     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5 = GEOM::GEOM_Object::_nil();
329     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6 = GEOM::GEOM_Object::_nil();
330     return;
331   }
332
333   // nbSel == 1
334   Handle(SALOME_InteractiveObject) anIO = aList.First();
335
336   Standard_Boolean aRes = Standard_False;
337   GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
338   if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
339     QString aName = GEOMBase::GetName( aSelectedObject );
340
341     TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
342     if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )
343       aNeedType = TopAbs_EDGE;
344
345     // If selected Vertex or Edge on the some Shape Get selection Subshape
346     TopoDS_Shape aShape;
347     if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
348       TColStd_IndexedMapOfInteger aMap;
349       aSelMgr->GetIndexes(anIO, aMap);
350       if ( aMap.Extent() == 1 ) { // Local Selection
351         int anIndex = aMap(1);
352         if ( aNeedType == TopAbs_EDGE )
353           aName += QString( ":edge_%1" ).arg( anIndex );
354         else
355           aName += QString( ":vertex_%1" ).arg( anIndex );
356
357         //Find SubShape Object in Father
358         GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
359
360         if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
361           GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
362           aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
363         }
364         else {
365           aSelectedObject = aFindedObject; // get Object from study
366         }
367       }
368       else { // Global Selection
369         if ( aShape.ShapeType() != aNeedType ) {
370           aSelectedObject = GEOM::GEOM_Object::_nil();
371           aName = "";
372         }
373       }
374     }
375     
376     myEditCurrentArgument->setText( aName );
377
378     if (!aSelectedObject->_is_nil()) { // clear selection if something selected
379       globalSelection();
380       localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
381     }
382
383     if      ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
384       myPoint  = aSelectedObject;
385       if ( !myPoint->_is_nil() && myDir->_is_nil() )
386         GroupPntVecR->PushButton2->click();
387     }
388     else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
389       myDir    = aSelectedObject;
390       if ( !myDir->_is_nil() && myPoint->_is_nil() )
391         GroupPntVecR->PushButton1->click();
392     }
393     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
394       myPoint1 = aSelectedObject;
395       if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
396         Group3Pnts->PushButton2->click();
397     }
398     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
399       myPoint2 = aSelectedObject;
400       if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
401         Group3Pnts->PushButton3->click();
402     }
403     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
404       myPoint3 = aSelectedObject;
405       if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
406         Group3Pnts->PushButton1->click();
407     }
408     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
409       myPoint4 = aSelectedObject;
410       if ( !myPoint4->_is_nil() && myPoint5->_is_nil() )
411         GroupCenter2Pnts->PushButton2->click();
412     }
413     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
414       myPoint5 = aSelectedObject;
415       if ( !myPoint5->_is_nil() && myPoint6->_is_nil() )
416         GroupCenter2Pnts->PushButton3->click();
417     }
418     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
419       myPoint6 = aSelectedObject;
420       if ( !myPoint6->_is_nil() && myPoint4->_is_nil() )
421         GroupCenter2Pnts->PushButton1->click();
422     }
423   }
424
425   displayPreview();
426 }
427
428
429 //=================================================================================
430 // function : SetEditCurrentArgument()
431 // purpose  :
432 //=================================================================================
433 void BasicGUI_CircleDlg::SetEditCurrentArgument()
434 {
435   QPushButton* send = (QPushButton*)sender();
436
437   if ( send == GroupPntVecR->PushButton1 ) {
438     myEditCurrentArgument = GroupPntVecR->LineEdit1;
439     GroupPntVecR->PushButton2->setDown(false);
440     GroupPntVecR->LineEdit1->setEnabled( true );
441     GroupPntVecR->LineEdit2->setEnabled( false );
442   }
443   else if ( send == GroupPntVecR->PushButton2 ) {
444     myEditCurrentArgument = GroupPntVecR->LineEdit2;
445     GroupPntVecR->PushButton1->setDown(false);
446     GroupPntVecR->LineEdit1->setEnabled( false );
447     GroupPntVecR->LineEdit2->setEnabled( true );
448   }
449   else if ( send == Group3Pnts->PushButton1 ) {
450     myEditCurrentArgument = Group3Pnts->LineEdit1;
451     Group3Pnts->PushButton2->setDown( false );
452     Group3Pnts->PushButton3->setDown( false );
453     Group3Pnts->LineEdit1->setEnabled( true );
454     Group3Pnts->LineEdit2->setEnabled( false );
455     Group3Pnts->LineEdit3->setEnabled( false );
456   }
457   else if ( send == Group3Pnts->PushButton2 )  {
458     myEditCurrentArgument = Group3Pnts->LineEdit2;
459     Group3Pnts->PushButton1->setDown( false );
460     Group3Pnts->PushButton3->setDown( false );
461     Group3Pnts->LineEdit1->setEnabled( false );
462     Group3Pnts->LineEdit2->setEnabled( true );
463     Group3Pnts->LineEdit3->setEnabled( false );
464   }
465   else if ( send == Group3Pnts->PushButton3 ) {
466     myEditCurrentArgument = Group3Pnts->LineEdit3;
467     Group3Pnts->PushButton1->setDown( false );
468     Group3Pnts->PushButton2->setDown( false );
469     Group3Pnts->LineEdit1->setEnabled( false );
470     Group3Pnts->LineEdit2->setEnabled( false );
471     Group3Pnts->LineEdit3->setEnabled( true );
472   }
473   else if ( send == GroupCenter2Pnts->PushButton1 ) {
474     myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
475     GroupCenter2Pnts->PushButton2->setDown( false );
476     GroupCenter2Pnts->PushButton3->setDown( false );
477     GroupCenter2Pnts->LineEdit1->setEnabled( true );
478     GroupCenter2Pnts->LineEdit2->setEnabled( false );
479     GroupCenter2Pnts->LineEdit3->setEnabled( false );
480   }
481   else if ( send == GroupCenter2Pnts->PushButton2 ) {
482     myEditCurrentArgument = GroupCenter2Pnts->LineEdit2;
483     GroupCenter2Pnts->PushButton1->setDown( false );
484     GroupCenter2Pnts->PushButton3->setDown( false );
485     GroupCenter2Pnts->LineEdit1->setEnabled( false );
486     GroupCenter2Pnts->LineEdit2->setEnabled( true );
487     GroupCenter2Pnts->LineEdit3->setEnabled( false );
488     
489   }
490   else if ( send == GroupCenter2Pnts->PushButton3 ) {
491     myEditCurrentArgument = GroupCenter2Pnts->LineEdit3;
492     GroupCenter2Pnts->PushButton1->setDown( false );
493     GroupCenter2Pnts->PushButton2->setDown( false );
494     GroupCenter2Pnts->LineEdit1->setEnabled( false );
495     GroupCenter2Pnts->LineEdit2->setEnabled( false );
496     GroupCenter2Pnts->LineEdit3->setEnabled( true );
497   }
498
499   
500   myEditCurrentArgument->setFocus();
501
502   if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
503     globalSelection(); // close local contexts, if any
504     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
505   }
506   else {
507     globalSelection(); // close local contexts, if any
508     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
509   }
510
511   myEditCurrentArgument->setFocus();
512   //  SelectionIntoArgument();
513   send->setDown(true);
514   displayPreview();
515 }
516
517 //=================================================================================
518 // function : LineEditReturnPressed()
519 // purpose  :
520 //=================================================================================
521 void BasicGUI_CircleDlg::LineEditReturnPressed()
522 {
523   QLineEdit* send = (QLineEdit*)sender();
524   if ( send == GroupPntVecR->LineEdit1 ||
525        send == GroupPntVecR->LineEdit2 ||
526        send == Group3Pnts->LineEdit1 ||
527        send == Group3Pnts->LineEdit2 ||
528        send == Group3Pnts->LineEdit3 ||
529        send == GroupCenter2Pnts->LineEdit1 ||
530        send == GroupCenter2Pnts->LineEdit2 ||
531        send == GroupCenter2Pnts->LineEdit3 ) {
532     myEditCurrentArgument = send;
533     GEOMBase_Skeleton::LineEditReturnPressed();
534   }
535 }
536
537
538 //=================================================================================
539 // function : ActivateThisDialog()
540 // purpose  :
541 //=================================================================================
542 void BasicGUI_CircleDlg::ActivateThisDialog()
543 {
544   GEOMBase_Skeleton::ActivateThisDialog();
545
546   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
547            this, SLOT( SelectionIntoArgument() ) );
548
549   ConstructorsClicked( getConstructorId() );
550 }
551
552
553 //=================================================================================
554 // function : enterEvent()
555 // purpose  :
556 //=================================================================================
557 void BasicGUI_CircleDlg::enterEvent( QEvent* )
558 {
559   if ( !mainFrame()->GroupConstructors->isEnabled() )
560     ActivateThisDialog();
561 }
562
563 //=================================================================================
564 // function : DeactivateActiveDialog()
565 // purpose  : public slot to deactivate if active
566 //=================================================================================
567 void BasicGUI_CircleDlg::DeactivateActiveDialog()
568 {
569   // myGeomGUI->SetState( -1 );
570   GEOMBase_Skeleton::DeactivateActiveDialog();
571 }
572
573 //=================================================================================
574 // function : ValueChangedInSpinBox()
575 // purpose  :
576 //=================================================================================
577 void BasicGUI_CircleDlg::ValueChangedInSpinBox()
578 {
579   displayPreview();
580 }
581
582 //=================================================================================
583 // function : getRadius()
584 // purpose  :
585 //=================================================================================
586 double BasicGUI_CircleDlg::getRadius() const
587 {
588   double r = 0.;
589   switch ( getConstructorId() ) {
590   case 0:
591     r = GroupPntVecR->SpinBox_DX->value(); break;
592   }
593   return r;
594 }
595
596 //=================================================================================
597 // function : createOperation
598 // purpose  :
599 //=================================================================================
600 GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation()
601 {
602   return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
603 }
604
605 //=================================================================================
606 // function : isEqual
607 // purpose  : it may also be needed to check for min distance between gp_Pnt-s...
608 //=================================================================================
609 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
610 {
611   return thePnt1->_is_equivalent( thePnt2 );
612 }
613
614 //=================================================================================
615 // function : isValid
616 // purpose  :
617 //=================================================================================
618 bool BasicGUI_CircleDlg::isValid( QString& msg )
619 {
620   const int id = getConstructorId();
621   if ( id == 0 ) {
622     //return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0;
623     //nil point means origin of global CS
624     //nil vector means Z axis
625     bool ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview());
626     return getRadius() > 0 && ok;
627   }
628   else if ( id == 1 )
629     return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
630       !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
631   else if ( id == 2 )
632     return !myPoint4->_is_nil() && !myPoint5->_is_nil() && !myPoint6->_is_nil() &&
633       !isEqual( myPoint4, myPoint5 ) && !isEqual( myPoint5, myPoint6 ) && !isEqual( myPoint4, myPoint6 );
634   return false;
635 }
636
637 //=================================================================================
638 // function : execute
639 // purpose  :
640 //=================================================================================
641 bool BasicGUI_CircleDlg::execute( ObjectList& objects )
642 {
643   bool res = false;
644   
645   GEOM::GEOM_Object_var anObj;
646   
647   GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
648
649   switch ( getConstructorId() ) {
650   case 0 :
651     {
652       QStringList aParameters;
653       aParameters << GroupPntVecR->SpinBox_DX->text();
654       anObj = anOper->MakeCirclePntVecR( myPoint, myDir, getRadius() );
655       if ( !anObj->_is_nil() && !IsPreview() )
656         anObj->SetParameters(aParameters.join(":").toLatin1().constData());
657       res = true;
658       break;
659     }
660   case 1 :
661     anObj = anOper->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 );
662     res = true;
663     break;
664   case 2:
665     anObj = anOper->MakeCircleCenter2Pnt( myPoint4, myPoint5, myPoint6 );
666     res = true;
667     break;
668   }
669   
670   if ( !anObj->_is_nil() )
671     objects.push_back( anObj._retn() );
672   else {
673     MESSAGE( "Execute Object is NULL!" );
674   }
675   
676   return res;
677 }
678
679 //=================================================================================
680 // function : addSubshapeToStudy
681 // purpose  : virtual method to add new SubObjects if local selection
682 //=================================================================================
683 void BasicGUI_CircleDlg::addSubshapesToStudy()
684 {
685   QMap<QString, GEOM::GEOM_Object_var> objMap;
686
687   switch ( getConstructorId() ) {
688   case 0:
689     if (!CORBA::is_nil(myPoint))
690       objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
691     if (!CORBA::is_nil(myDir))
692       objMap[GroupPntVecR->LineEdit2->text()] = myDir;
693     break;
694   case 1:
695     objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
696     objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
697     objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
698     break;
699   case 2:
700     objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4;
701     objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5;
702     objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6;
703     break;
704   }
705   addSubshapesToFather( objMap );
706 }