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