Salome HOME
NRI : First integration.
[modules/geom.git] / src / GEOMGUI / GeometryGUI_BoxDlg.cxx
1 using namespace std;
2 //  File      : GeometryGUI_BoxDlg.cxx
3 //  Created   :
4 //  Author    : Lucien PIGNOLONI
5 //  Project   : SALOME
6 //  Module    : GeometryGUI
7 //  Copyright : OPEN CASCADE
8 //  $Header$
9     
10
11 #include "GeometryGUI_BoxDlg.h"
12 #include "GeometryGUI_SpinBox.h"
13
14 #include "GeometryGUI.h"
15 #include "QAD_Application.h"
16 #include "QAD_Desktop.h"
17 #include "QAD_Config.h"
18 #include "utilities.h"
19
20 #include <qbuttongroup.h>
21 #include <qframe.h>
22 #include <qgroupbox.h>
23 #include <qlineedit.h>
24 #include <qpushbutton.h>
25 #include <qradiobutton.h>
26 #include <qlayout.h>
27 #include <qvariant.h>
28 #include <qtooltip.h>
29 #include <qwhatsthis.h>
30 #include <qimage.h>
31 #include <qpixmap.h>
32 #include <qlabel.h>
33 #include <qvalidator.h>
34 #include <qevent.h>
35 #include <qmessagebox.h>
36
37
38
39 //=================================================================================
40 // class    : GeometryGUI_BoxDlg()
41 // purpose  : Constructs a GeometryGUI_BoxDlg which is a child of 'parent', with the 
42 //            name 'name' and widget flags set to 'f'.
43 //            The dialog will by default be modeless, unless you set 'modal' to
44 //            TRUE to construct a modal dialog.
45 //=================================================================================
46 GeometryGUI_BoxDlg::GeometryGUI_BoxDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
47     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
48 {
49     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_BOX_2P")));
50     QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
51     QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_BOX_DXYZ")));
52
53     if ( !name )
54         setName( "GeometryGUI_BoxDlg" );
55     resize( 335, 220 ); 
56     setCaption( tr( "GEOM_BOX_TITLE"  ) );
57     setSizeGripEnabled( TRUE );
58     GeometryGUI_BoxDlgLayout = new QGridLayout( this ); 
59     GeometryGUI_BoxDlgLayout->setSpacing( 6 );
60     GeometryGUI_BoxDlgLayout->setMargin( 11 );
61     
62     /***************************************************************/
63     GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
64     GroupConstructors->setTitle( tr( "GEOM_BOX"  ) );
65     GroupConstructors->setExclusive( TRUE );
66     GroupConstructors->setColumnLayout(0, Qt::Vertical );
67     GroupConstructors->layout()->setSpacing( 0 );
68     GroupConstructors->layout()->setMargin( 0 );
69     GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
70     GroupConstructorsLayout->setAlignment( Qt::AlignTop );
71     GroupConstructorsLayout->setSpacing( 6 );
72     GroupConstructorsLayout->setMargin( 11 );
73     QSpacerItem* spacer_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
74     GroupConstructorsLayout->addItem( spacer_1, 0, 3 );
75     Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
76     Constructor1->setText( tr( ""  ) );
77     Constructor1->setPixmap( image0 );
78     Constructor1->setChecked( TRUE );
79     Constructor1->setMinimumSize( QSize( 50, 0 ) );
80     GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
81     Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
82     Constructor2->setText( tr( ""  ) );
83     Constructor2->setPixmap( image2 );
84     Constructor2->setMinimumSize( QSize( 50, 0 ) );
85     GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
86     QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
87     GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
88     GeometryGUI_BoxDlgLayout->addWidget( GroupConstructors, 0, 0 );
89
90     /***************************************************************/
91     GroupButtons = new QGroupBox( this, "GroupButtons" );
92     GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
93     GroupButtons->setTitle( tr( ""  ) );
94     GroupButtons->setColumnLayout(0, Qt::Vertical );
95     GroupButtons->layout()->setSpacing( 0 );
96     GroupButtons->layout()->setMargin( 0 );
97     GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
98     GroupButtonsLayout->setAlignment( Qt::AlignTop );
99     GroupButtonsLayout->setSpacing( 6 );
100     GroupButtonsLayout->setMargin( 11 );
101     buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
102     buttonCancel->setText( tr( "GEOM_BUT_CLOSE"  ) );
103     buttonCancel->setAutoDefault( TRUE );
104     GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
105     buttonApply = new QPushButton( GroupButtons, "buttonApply" );
106     buttonApply->setText( tr( "GEOM_BUT_APPLY"  ) );
107     buttonApply->setAutoDefault( TRUE );
108     GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
109     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
110     GroupButtonsLayout->addItem( spacer, 0, 2 );
111     buttonOk = new QPushButton( GroupButtons, "buttonOk" );
112     buttonOk->setText( tr( "GEOM_BUT_OK"  ) );
113     buttonOk->setAutoDefault( TRUE );
114     buttonOk->setDefault( TRUE );
115     GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
116     GeometryGUI_BoxDlgLayout->addWidget( GroupButtons, 2, 0 ); 
117
118     /***************************************************************/
119     GroupPoints = new QGroupBox( this, "GroupPoints" );
120     GroupPoints->setGeometry( QRect( 10, 10, 280, 90 ) ); 
121     GroupPoints->setTitle( tr( "GEOM_DIAGONAL_POINTS"  ) );
122     GroupPoints->setFrameShape( QGroupBox::Box );
123     GroupPoints->setFrameShadow( QGroupBox::Sunken );
124     GroupPoints->setColumnLayout(0, Qt::Vertical );
125     GroupPoints->layout()->setSpacing( 0 );
126     GroupPoints->layout()->setMargin( 0 );
127     GroupPointsLayout = new QGridLayout( GroupPoints->layout() );
128     GroupPointsLayout->setAlignment( Qt::AlignTop );
129     GroupPointsLayout->setSpacing( 6 );
130     GroupPointsLayout->setMargin( 11 );
131     SelectButtonPt2 = new QPushButton( GroupPoints, "SelectButtonPt2" );
132     SelectButtonPt2->setText( tr( ""  ) );
133     SelectButtonPt2->setPixmap( image1 );
134     GroupPointsLayout->addWidget( SelectButtonPt2, 1, 1 );
135     LineEditPt1 = new QLineEdit( GroupPoints, "LineEditPt1" );
136     GroupPointsLayout->addWidget( LineEditPt1, 0, 2 );
137     LineEditPt2 = new QLineEdit( GroupPoints, "LineEditPt2" );
138     GroupPointsLayout->addWidget( LineEditPt2, 1, 2 );
139     SelectButtonPt1 = new QPushButton( GroupPoints, "SelectButtonPt1" );
140     SelectButtonPt1->setText( tr( ""  ) );
141     SelectButtonPt1->setPixmap( image1 );
142     SelectButtonPt1->setToggleButton( FALSE );
143     GroupPointsLayout->addWidget( SelectButtonPt1, 0, 1 );
144     TextLabelPt1 = new QLabel( GroupPoints, "TextLabelPt1" );
145     TextLabelPt1->setText( tr( "GEOM_POINT_I"  ).arg("1") );
146     TextLabelPt1->setMinimumSize( QSize( 50, 0 ) );
147     TextLabelPt1->setFrameShape( QLabel::NoFrame );
148     TextLabelPt1->setFrameShadow( QLabel::Plain );
149     GroupPointsLayout->addWidget( TextLabelPt1, 0, 0 );
150     TextLabelPt2 = new QLabel( GroupPoints, "TextLabelPt2" );
151     TextLabelPt2->setText( tr( "GEOM_POINT_I"  ).arg("2") );
152     TextLabelPt2->setMinimumSize( QSize( 50, 0 ) );
153     GroupPointsLayout->addWidget( TextLabelPt2, 1, 0 );
154     GeometryGUI_BoxDlgLayout->addWidget( GroupPoints, 1, 0 );
155
156     /***************************************************************/
157     GroupDimensions = new QGroupBox( this, "GroupDimensions" );
158     GroupDimensions->setGeometry( QRect( 11, 75, 310, 80 ) ); 
159     GroupDimensions->setTitle( tr( "GEOM_BOX_OBJ"  ) );
160     GroupDimensions->setColumnLayout(0, Qt::Vertical );
161     GroupDimensions->setMinimumSize( QSize( 0, 90 ) );
162     GroupDimensions->layout()->setSpacing( 0 );
163     GroupDimensions->layout()->setMargin( 0 );
164     GroupDimensionsLayout = new QGridLayout( GroupDimensions->layout() );
165     GroupDimensionsLayout->setAlignment( Qt::AlignTop );
166     GroupDimensionsLayout->setSpacing( 6 );
167     GroupDimensionsLayout->setMargin( 11 );
168
169     TextLabel_DZ = new QLabel( GroupDimensions, "TextLabel_DZ" );
170     TextLabel_DZ->setText( tr( "GEOM_DZ"  ) );
171     GroupDimensionsLayout->addWidget( TextLabel_DZ, 0, 4 );
172     TextLabel_DY = new QLabel( GroupDimensions, "TextLabel_DY" );
173     TextLabel_DY->setText( tr( "GEOM_DY"  ) );
174     GroupDimensionsLayout->addWidget( TextLabel_DY, 0, 2 );
175     TextLabel_DX = new QLabel( GroupDimensions, "TextLabel_DX" );
176     TextLabel_DX->setText( tr( "GEOM_DX"  ) );
177     GroupDimensionsLayout->addWidget( TextLabel_DX, 0, 0 );
178  
179     /* Spin boxes construction */
180     SpinBox_DX = new GeometryGUI_SpinBox( GroupDimensions, "GeomSpinBox_DX" ) ;
181     GroupDimensionsLayout->addWidget( SpinBox_DX, 0, 1 );
182     SpinBox_DY = new GeometryGUI_SpinBox( GroupDimensions, "GeomSpinBox_DY" ) ;
183     GroupDimensionsLayout->addWidget( SpinBox_DY, 0, 3 );
184     SpinBox_DZ = new GeometryGUI_SpinBox( GroupDimensions, "GeomSpinBox_DZ" ) ;
185     GroupDimensionsLayout->addWidget( SpinBox_DZ, 0, 5 );
186
187     QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed );
188     GroupDimensionsLayout->addItem( spacer1, 1, 3 );
189
190     GeometryGUI_BoxDlgLayout->addWidget( GroupDimensions, 1, 0 );
191
192     /* Initialisations */
193     Init(Sel) ;
194 }
195
196
197 //=================================================================================
198 // function : ~DialogBox_Box()
199 // purpose  : Destroys the object and frees any allocated resources
200 //=================================================================================
201 GeometryGUI_BoxDlg::~GeometryGUI_BoxDlg()
202 {
203   // no need to delete child widgets, Qt does it all for us
204   this->destroy(TRUE, TRUE) ;
205 }
206
207
208 //=================================================================================
209 // function : Init()
210 // purpose  :
211 //=================================================================================
212 void GeometryGUI_BoxDlg::Init(SALOME_Selection *Sel)
213 {
214
215
216   /* Get setting of step value from file configuration */
217   double step ;
218   QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
219   step = St.toDouble() ;
220
221   /* min, max, step and decimals for spin boxes */
222   SpinBox_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
223   SpinBox_DX->SetValue( 200.0 ) ;  
224   SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
225   SpinBox_DY->SetValue( 200.0 ) ;
226   SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
227   SpinBox_DZ->SetValue( 200.0 ) ; 
228
229   GroupPoints->show();
230   GroupDimensions->hide() ;
231   myConstructorId = 0 ;
232   Constructor1->setChecked( TRUE );
233   myEditCurrentArgument = LineEditPt1 ;
234   mySelection = Sel;
235   myGeomGUI = GeometryGUI::GetGeometryGUI() ;
236   myPoint1.SetCoord( 0.0, 0.0, 0.0 );
237   myPoint2.SetCoord( 0.0, 0.0, 0.0 );
238   myOkPoint1 = myOkPoint2 = false ;
239   mySimulationTopoDs.Nullify() ;
240   
241   myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
242   
243   // TODO previous selection into argument ?
244   
245   /*  Vertices Filter for all arguments */
246   Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
247   myGeom = GEOM::GEOM_Gen::_narrow(comp);
248   myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
249   mySelection->AddFilter( myVertexFilter ); /* filter for next selection */
250   
251   /* signals and slots connections */
252   connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ) ;
253   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
254   connect( buttonApply, SIGNAL( clicked() ),  this, SLOT( ClickOnApply() ) ) ;
255   connect( GroupConstructors, SIGNAL(clicked(int) ), this, SLOT( ConstructorsClicked(int) ) ) ;
256   connect( SelectButtonPt1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
257   connect( SelectButtonPt2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
258  
259   connect( SpinBox_DX, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
260   connect( SpinBox_DY, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
261   connect( SpinBox_DZ, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
262
263   connect( LineEditPt1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
264   connect( LineEditPt2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
265   
266   connect( myGeomGUI,   SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;      
267   connect( mySelection, SIGNAL ( currentSelectionChanged() ),      this, SLOT( SelectionIntoArgument() ) ) ;
268   /* To close dialog if study change */
269   connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
270
271   /* Move widget on the botton right corner of main widget */
272   int x, y ;
273   myGeomGUI->DefineDlgPosition( this, x, y ) ;
274   this->move( x, y ) ;
275   
276   this->show() ; /* displays Dialog */
277 }
278
279
280
281 //=================================================================================
282 // function : ConstructorsClicked()
283 // purpose  : Radio button management
284 //=================================================================================
285 void GeometryGUI_BoxDlg::ConstructorsClicked(int constructorId)
286 {
287
288   mySelection->ClearFilters() ;
289   myGeomGUI->EraseSimulationShape() ;
290
291   switch (constructorId)
292     {
293     case 0:
294       {
295         GroupPoints->show();
296         GroupDimensions->hide() ;
297         myConstructorId = constructorId ;
298         myEditCurrentArgument = LineEditPt1 ;
299         Constructor1->setChecked( TRUE );
300         LineEditPt1->setText("") ;
301         LineEditPt2->setText("") ;
302         myOkPoint1 = myOkPoint2 = false ;
303         
304         /* filter for next selection */
305         mySelection->AddFilter( myVertexFilter );
306         connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
307         break;
308       }
309     case 1:
310       {
311         GroupPoints->hide();
312         GroupDimensions->show();
313         myConstructorId = constructorId ;
314         myOkPoint1 = myOkPoint2 = false ;
315
316         disconnect( mySelection, 0, this, 0 );
317         
318         double initValue = 200.0 ;
319         SpinBox_DX->SetValue( initValue ) ;
320         SpinBox_DY->SetValue( initValue ) ;
321         SpinBox_DZ->SetValue( initValue ) ;
322
323         myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
324         myPoint2.SetCoord( initValue, initValue,initValue  ) ;
325
326         mySimulationTopoDs = BRepPrimAPI_MakeBox( myPoint1, myPoint2 ).Shape();
327         myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; 
328         break;
329       }
330     }
331  return ;
332 }
333
334 //=================================================================================
335 // function : ClickOnOk()
336 // purpose  :
337 //=================================================================================
338 void GeometryGUI_BoxDlg::ClickOnOk()
339 {
340   this->ClickOnApply() ;
341   this->ClickOnCancel() ;
342   return ;
343 }
344
345 //=================================================================================
346 // function : ClickOnApply()
347 // purpose  :
348 //=================================================================================
349 void GeometryGUI_BoxDlg::ClickOnApply()
350 {
351 //NRI+ : 02/12/2202 - BugID 1065
352 //    if (mySimulationTopoDs.IsNull())
353 //      return;
354   myGeomGUI->EraseSimulationShape() ;
355   mySimulationTopoDs.Nullify() ;
356   myGeomGUI->GetDesktop()->putInfo( tr("") ) ; 
357
358   switch(myConstructorId)
359     { 
360     case 0 :
361       {
362         //NRI+ : 02/12/2202 - BugID 1065        mySelection->ClearFilters() ;
363         if(myOkPoint1 && myOkPoint2) 
364           myGeomGUI->MakeBoxAndDisplay( myPoint1, myPoint2 ) ;
365         break ;
366       }
367     case 1 :
368       {
369         /* Recup args and call method */
370         double vx = SpinBox_DX->GetValue() ;
371         double vy = SpinBox_DY->GetValue() ;
372         double vz = SpinBox_DZ->GetValue() ;
373         myPoint1.SetCoord(0.0, 0.0, 0.0) ;
374         myPoint2.SetCoord(vx, vy, vz) ;
375         myGeomGUI->MakeBoxAndDisplay( myPoint1, myPoint2 ) ;
376         break ;
377       }
378     }
379   return ;
380 }
381
382
383 //=================================================================================
384 // function : ClickOnCancel()
385 // purpose  :
386 //=================================================================================
387 void GeometryGUI_BoxDlg::ClickOnCancel()
388 {
389   mySelection->ClearFilters() ;
390   myGeomGUI->EraseSimulationShape() ;
391   mySimulationTopoDs.Nullify() ;
392   disconnect( mySelection, 0, this, 0 );
393   myGeomGUI->ResetState() ;
394   reject() ;
395   return ;
396 }
397
398
399 //=================================================================================
400 // function : SelectionIntoArgument()
401 // purpose  : Called when selection as changed
402 //=================================================================================
403 void GeometryGUI_BoxDlg::SelectionIntoArgument()
404 {
405   myEditCurrentArgument->setText("") ;
406   myGeomGUI->EraseSimulationShape() ; 
407   mySimulationTopoDs.Nullify() ;
408
409   QString aString = "" ; /* name of selection */
410
411   int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
412   if ( nbSel != 1 ) {
413     if ( myEditCurrentArgument == LineEditPt1 ) {
414       myOkPoint1 = false ;
415     }
416     else if ( myEditCurrentArgument == LineEditPt2 ) {
417       myOkPoint2 = false ;
418     }
419     return ;
420   }
421
422   // nbSel == 1
423   TopoDS_Shape S; 
424   if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
425     return ;
426
427   if ( myEditCurrentArgument == LineEditPt1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
428     myEditCurrentArgument->setText( aString ) ;
429     myOkPoint1 = true ;
430   }
431   else if ( myEditCurrentArgument == LineEditPt2 && myGeomGUI->VertexToPoint(S, myPoint2) ) {
432     myEditCurrentArgument->setText( aString ) ;
433     myOkPoint2 = true ;
434   }
435
436   if( myOkPoint1 && myOkPoint2 && TestBoxDimensions( myPoint1, myPoint2 ) ) {    
437     mySimulationTopoDs = BRepPrimAPI_MakeBox( myPoint1, myPoint2 ).Shape();
438     myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; 
439   }
440   return ;
441 }
442
443
444 //=================================================================================
445 // function : SetEditCurrentArgument()
446 // purpose  :
447 //=================================================================================
448 void GeometryGUI_BoxDlg::SetEditCurrentArgument()
449 {
450   QPushButton* send = (QPushButton*)sender();
451   switch (myConstructorId)
452     {
453     case 0: // default constructor
454       { 
455         if(send == SelectButtonPt1) {
456           LineEditPt1->setFocus() ;
457           myEditCurrentArgument = LineEditPt1;
458         }
459         else if(send == SelectButtonPt2) {
460           LineEditPt2->setFocus() ;
461           myEditCurrentArgument = LineEditPt2;
462         }       
463         mySelection->AddFilter(myVertexFilter) ;
464         SelectionIntoArgument() ;
465         break;
466       }
467     case 1:
468       { 
469         /* nothing to do here */
470         break;
471       }
472     }
473   return ;
474 }
475
476 //=================================================================================
477 // function : ValueChangedInSpinBox()
478 // purpose  :
479 //=================================================================================
480 void GeometryGUI_BoxDlg::ValueChangedInSpinBox( double newValue )
481 {
482   if(myConstructorId != 1)
483     return ;
484   
485   myGeomGUI->EraseSimulationShape() ; 
486   mySimulationTopoDs.Nullify() ;
487
488   QObject* send = (QObject*)sender() ; 
489   double vx, vy, vz ;
490   
491   if( send == SpinBox_DX ) {
492     vx = newValue ;
493     vy = SpinBox_DY->GetValue() ;
494     vz = SpinBox_DZ->GetValue() ;
495   } else if ( send == SpinBox_DY ) {
496     vx = SpinBox_DX->GetValue() ;
497     vy = newValue ;
498     vz = SpinBox_DZ->GetValue() ;
499   } else if (send == SpinBox_DZ ) {
500     vx = SpinBox_DX->GetValue() ;
501     vy = SpinBox_DY->GetValue() ;
502     vz = newValue ;
503   }
504   
505   myPoint1.SetCoord(0.0, 0.0, 0.0) ;
506   myPoint2.SetCoord(vx, vy, vz) ;
507   
508   if ( TestBoxDimensions( myPoint1, myPoint2 ) ) {
509     mySimulationTopoDs = BRepPrimAPI_MakeBox( myPoint1, myPoint2 ).Shape();
510     myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; 
511   }
512   return ;
513 }
514
515
516 //=================================================================================
517 // function : LineEditReturnPressed()
518 // purpose  :
519 //=================================================================================
520 void GeometryGUI_BoxDlg::LineEditReturnPressed()
521 {
522   QLineEdit* send = (QLineEdit*)sender();  
523   if( send == LineEditPt1 )
524     myEditCurrentArgument = LineEditPt1 ;
525   else if ( send == LineEditPt2 )
526     myEditCurrentArgument = LineEditPt2 ; 
527   else
528     return ;
529   
530   /* User name of object input management                          */
531   /* If successfull the selection is changed and signal emitted... */
532   /* so SelectionIntoArgument() is automatically called.           */
533   const QString objectUserName = myEditCurrentArgument->text() ;
534   QWidget* thisWidget = (QWidget*)this ;
535   if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
536     myEditCurrentArgument->setText( objectUserName ) ;
537   }
538   return ;
539 }
540
541
542 //=================================================================================
543 // function : DeactivateActiveDialog()
544 // purpose  :
545 //=================================================================================
546 void GeometryGUI_BoxDlg::DeactivateActiveDialog()
547 {
548   if ( GroupConstructors->isEnabled() ) {
549
550     GroupConstructors->setEnabled(false) ;
551     GroupDimensions->setEnabled(false) ;
552     GroupButtons->setEnabled(false) ;
553     GroupPoints->setEnabled(false) ;
554
555     mySelection->ClearFilters() ;
556     disconnect( mySelection, 0, this, 0 );
557     myGeomGUI->SetActiveDialogBox(0) ;
558     myGeomGUI->EraseSimulationShape() ;
559   }
560   return ;
561 }
562
563
564 //=================================================================================
565 // function : ActivateThisDialog()
566 // purpose  :
567 //=================================================================================
568 void GeometryGUI_BoxDlg::ActivateThisDialog()
569 {
570
571   /* Emit a signal to deactivate the active dialog */
572   myGeomGUI->EmitSignalDeactivateDialog() ; 
573
574   GroupConstructors->setEnabled(true) ;
575   GroupDimensions->setEnabled(true) ;
576   GroupButtons->setEnabled(true) ;
577   GroupPoints->setEnabled(true) ;  
578
579   connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
580   myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
581   if( !mySimulationTopoDs.IsNull() )
582     myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
583   return ;
584 }
585
586
587 //=================================================================================
588 // function : enterEvent [REDEFINED]
589 // purpose  :
590 //=================================================================================
591 void GeometryGUI_BoxDlg::enterEvent(QEvent* e)
592 {
593   if ( GroupConstructors->isEnabled() )
594     return ;
595   ActivateThisDialog() ;
596 }
597
598
599 //=================================================================================
600 // function : closeEvent()
601 // purpose  :
602 //=================================================================================
603 void GeometryGUI_BoxDlg::closeEvent( QCloseEvent* e )
604 {
605   this->ClickOnCancel() ; /* same than click on cancel button */
606 }
607
608
609 //=================================================================================
610 // function : TestBoxDimensions()
611 // purpose  :
612 //=================================================================================
613 bool GeometryGUI_BoxDlg::TestBoxDimensions(gp_Pnt P1,  gp_Pnt P2)
614 {
615   if ( ( fabs( P1.X() - P2.X() ) > Precision::Confusion() ) &&
616        ( fabs( P1.Y() - P2.Y() ) > Precision::Confusion() ) &&
617        ( fabs( P1.Z() - P2.Z() ) > Precision::Confusion() ) )
618     return true ;
619   return false ;
620 }