Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/geom.git] / src / GEOMGUI / GeometryGUI_MultiRotationDlg.cxx
1 using namespace std;
2 //  File      : GeometryGUI_MultiTranslationDlg.cxx
3 //  Created   :
4 //  Author    : Damien COQUERET
5 //  Project   : SALOME
6 //  Module    : GeometryGUI
7 //  Copyright : OPEN CASCADE
8 //  $Header$
9
10 #include "GeometryGUI_MultiRotationDlg.h"
11
12 #include "GeometryGUI.h"
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Config.h"
16 #include "utilities.h"
17
18 #include <BRepBuilderAPI_MakeVertex.hxx>
19 #include <GeomAPI_ProjectPointOnCurve.hxx>
20 #include <BRepAdaptor_Curve.hxx>
21 #include <BRep_Builder.hxx>
22 #include <BRepGProp.hxx>
23 #include <GProp_GProps.hxx>
24 #include <TopoDS_Compound.hxx>
25 #include <Geom_Line.hxx>
26 #include <Precision.hxx>
27 #include <BRepBuilderAPI_Transform.hxx>
28
29 #include <qbuttongroup.h>
30 #include <qcheckbox.h>
31 #include <qgroupbox.h>
32 #include <qlabel.h>
33 #include <qlineedit.h>
34 #include <qpushbutton.h>
35 #include <qradiobutton.h>
36 #include <qlayout.h>
37 #include <qvariant.h>
38 #include <qtooltip.h>
39 #include <qwhatsthis.h>
40 #include <qimage.h>
41 #include <qvalidator.h>
42 #include <qpixmap.h>
43 #include <qspinbox.h>
44
45
46 //=================================================================================
47 // class    : GeometryGUI_MultiRotationDlg()
48 // purpose  : Constructs a GeometryGUI_MultiRotationDlg 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 GeometryGUI_MultiRotationDlg::GeometryGUI_MultiRotationDlg( QWidget* parent,  const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
54     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
55 {
56     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTIROTATION_SIMPLE")));
57     QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
58     QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTIROTATION_DOUBLE")));
59
60     if ( !name )
61         setName( "GeometryGUI_MultiTranlationDlg" );
62     resize( 303, 251 ); 
63     setCaption( tr( "GEOM_MULTIROTATION_TITLE"  ) );
64     setSizeGripEnabled( TRUE );
65     GeometryGUI_MultiRotationDlgLayout = new QGridLayout( this ); 
66     GeometryGUI_MultiRotationDlgLayout->setSpacing( 6 );
67     GeometryGUI_MultiRotationDlgLayout->setMargin( 11 );
68
69     GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
70     GroupConstructors->setTitle( tr( "GEOM_MULTIROTATION"  ) );
71     GroupConstructors->setExclusive( TRUE );
72     GroupConstructors->setColumnLayout(0, Qt::Vertical );
73     GroupConstructors->layout()->setSpacing( 0 );
74     GroupConstructors->layout()->setMargin( 0 );
75     GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
76     GroupConstructorsLayout->setAlignment( Qt::AlignTop );
77     GroupConstructorsLayout->setSpacing( 6 );
78     GroupConstructorsLayout->setMargin( 11 );
79
80     Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
81     Constructor1->setText( tr( ""  ) );
82     Constructor1->setPixmap( image0 );
83     Constructor1->setChecked( TRUE );
84     Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
85     Constructor1->setMinimumSize( QSize( 50, 0 ) );
86     GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
87     Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
88     Constructor2->setText( tr( ""  ) );
89     Constructor2->setPixmap( image2 );
90     Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
91     Constructor2->setMinimumSize( QSize( 50, 0 ) );
92     GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
93     QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
94     GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
95     QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
96     GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
97
98     GeometryGUI_MultiRotationDlgLayout->addWidget( GroupConstructors, 0, 0 );
99
100     /***************************************************************/
101     GroupButtons = new QGroupBox( this, "GroupButtons" );
102     GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
103     GroupButtons->setTitle( tr( ""  ) );
104     GroupButtons->setColumnLayout(0, Qt::Vertical );
105     GroupButtons->layout()->setSpacing( 0 );
106     GroupButtons->layout()->setMargin( 0 );
107     GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
108     GroupButtonsLayout->setAlignment( Qt::AlignTop );
109     GroupButtonsLayout->setSpacing( 6 );
110     GroupButtonsLayout->setMargin( 11 );
111     buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
112     buttonCancel->setText( tr( "GEOM_BUT_CLOSE"  ) );
113     buttonCancel->setAutoDefault( TRUE );
114     GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
115     buttonApply = new QPushButton( GroupButtons, "buttonApply" );
116     buttonApply->setText( tr( "GEOM_BUT_APPLY"  ) );
117     buttonApply->setAutoDefault( TRUE );
118     GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
119     QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
120     GroupButtonsLayout->addItem( spacer_9, 0, 2 );
121     buttonOk = new QPushButton( GroupButtons, "buttonOk" );
122     buttonOk->setText( tr( "GEOM_BUT_OK"  ) );
123     buttonOk->setAutoDefault( TRUE );
124     buttonOk->setDefault( TRUE );
125     GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
126     GeometryGUI_MultiRotationDlgLayout->addWidget( GroupButtons, 2, 0 );
127
128     /***************************************************************/
129     GroupC1 = new QGroupBox( this, "GroupC1" );
130     GroupC1->setTitle( tr( "GEOM_MULTIROTATION_SIMPLE"  ) );
131     GroupC1->setMinimumSize( QSize( 0, 0 ) );
132     GroupC1->setFrameShape( QGroupBox::Box );
133     GroupC1->setFrameShadow( QGroupBox::Sunken );
134     GroupC1->setColumnLayout(0, Qt::Vertical );
135     GroupC1->layout()->setSpacing( 0 );
136     GroupC1->layout()->setMargin( 0 );
137     GroupC1Layout = new QGridLayout( GroupC1->layout() );
138     GroupC1Layout->setAlignment( Qt::AlignTop );
139     GroupC1Layout->setSpacing( 6 );
140     GroupC1Layout->setMargin( 11 );
141
142     TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
143     TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT"  ) );
144     TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
145     TextLabelC1A1->setFrameShape( QLabel::NoFrame );
146     TextLabelC1A1->setFrameShadow( QLabel::Plain );
147     GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
148
149     TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
150     TextLabelC1A2->setText( tr( "GEOM_VECTOR"  ) );
151     TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
152     TextLabelC1A2->setFrameShape( QLabel::NoFrame );
153     TextLabelC1A2->setFrameShadow( QLabel::Plain );
154     GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
155
156     TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
157     TextLabelC1A3->setText( tr( "GEOM_NB_TIMES"  ) );
158     TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
159     TextLabelC1A3->setFrameShape( QLabel::NoFrame );
160     TextLabelC1A3->setFrameShadow( QLabel::Plain );
161     GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
162
163     LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
164     GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
165
166     LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
167     GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
168
169     /* a QSpinBox  */
170     SpinBox_C1A3 = new QSpinBox( GroupC1, "SpinBox_C1A3" ) ;
171     SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
172     GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 );
173
174     SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
175     SelectButtonC1A1->setText( tr( ""  ) );
176     SelectButtonC1A1->setPixmap( image1 );
177     SelectButtonC1A1->setToggleButton( FALSE );
178     SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
179     GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
180
181     SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
182     SelectButtonC1A2->setText( tr( ""  ) );
183     SelectButtonC1A2->setPixmap( image1 );
184     SelectButtonC1A2->setToggleButton( FALSE );
185     SelectButtonC1A2->setMaximumSize( QSize( 28, 32767 ) );
186     GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
187
188     GeometryGUI_MultiRotationDlgLayout->addWidget( GroupC1, 1, 0 );
189
190     /***************************************************************/
191
192     GroupC2 = new QGroupBox( this, "GroupC2" );
193     GroupC2->setTitle( tr( "GEOM_MULTIROTATION_DOUBLE"  ) );
194     GroupC2->setMinimumSize( QSize( 0, 0 ) );
195     GroupC2->setFrameShape( QGroupBox::Box );
196     GroupC2->setFrameShadow( QGroupBox::Sunken );
197     GroupC2->setColumnLayout(0, Qt::Vertical );
198     GroupC2->layout()->setSpacing( 0 );
199     GroupC2->layout()->setMargin( 0 );
200     GroupC2Layout = new QGridLayout( GroupC2->layout() );
201     GroupC2Layout->setAlignment( Qt::AlignTop );
202     GroupC2Layout->setSpacing( 6 );
203     GroupC2Layout->setMargin( 11 );
204
205     TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
206     TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT"  ) );
207     TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
208     TextLabelC2A1->setFrameShape( QLabel::NoFrame );
209     TextLabelC2A1->setFrameShadow( QLabel::Plain );
210     GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 );
211
212     TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" );
213     TextLabelC2A2->setText( tr( "GEOM_VECTOR"  ) );
214     TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) );
215     TextLabelC2A2->setFrameShape( QLabel::NoFrame );
216     TextLabelC2A2->setFrameShadow( QLabel::Plain );
217     GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
218
219     TextLabelC2A3 = new QLabel( GroupC2, "TextLabelC2A3" );
220     TextLabelC2A3->setText( tr( "GEOM_ANGLE"  ) );
221     TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) );
222     TextLabelC2A3->setFrameShape( QLabel::NoFrame );
223     TextLabelC2A3->setFrameShadow( QLabel::Plain );
224     GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 );
225
226     TextLabelC2A4 = new QLabel( GroupC2, "TextLabelC2A4" );
227     TextLabelC2A4->setText( tr( "GEOM_NB_TIMES"  ) );
228     TextLabelC2A4->setMinimumSize( QSize( 50, 0 ) );
229     TextLabelC2A4->setFrameShape( QLabel::NoFrame );
230     TextLabelC2A4->setFrameShadow( QLabel::Plain );
231     GroupC2Layout->addWidget( TextLabelC2A4, 3, 0 );
232
233     TextLabelC2A5 = new QLabel( GroupC2, "TextLabelC2A5" );
234     TextLabelC2A5->setText( tr( "GEOM_STEP"  ) );
235     TextLabelC2A5->setMinimumSize( QSize( 50, 0 ) );
236     TextLabelC2A5->setFrameShape( QLabel::NoFrame );
237     TextLabelC2A5->setFrameShadow( QLabel::Plain );
238     GroupC2Layout->addWidget( TextLabelC2A5, 5, 0 );
239
240     TextLabelC2A6 = new QLabel( GroupC2, "TextLabelC2A6" );
241     TextLabelC2A6->setText( tr( "GEOM_NB_TIMES"  ) );
242     TextLabelC2A6->setMinimumSize( QSize( 50, 0 ) );
243     TextLabelC2A6->setFrameShape( QLabel::NoFrame );
244     TextLabelC2A6->setFrameShadow( QLabel::Plain );
245     GroupC2Layout->addWidget( TextLabelC2A6, 6, 0 );
246
247     LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
248     GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
249
250     LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
251     GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
252
253     /* a GeometryGUI_SpinBox */
254     SpinBox_C2A3 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A3" ) ;
255     SpinBox_C2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A3->sizePolicy().hasHeightForWidth() ) );
256     GroupC2Layout->addWidget( SpinBox_C2A3, 2, 2 );
257     /* a QSpinBox            */
258     SpinBox_C2A4 = new QSpinBox( GroupC2, "SpinBox_C2A4" ) ;
259     SpinBox_C2A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A4->sizePolicy().hasHeightForWidth() ) );
260     GroupC2Layout->addWidget( SpinBox_C2A4, 3, 2 );
261
262     /* a GeometryGUI_SpinBox */
263     SpinBox_C2A5 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A5" ) ;
264     SpinBox_C2A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A5->sizePolicy().hasHeightForWidth() ) );
265     GroupC2Layout->addWidget( SpinBox_C2A5, 5, 2 );
266     /* a QSpinBox            */
267     SpinBox_C2A6 = new QSpinBox( GroupC2, "SpinBox_C2A6" ) ;
268     SpinBox_C2A6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A6->sizePolicy().hasHeightForWidth() ) );
269     GroupC2Layout->addWidget( SpinBox_C2A6, 6, 2 );
270
271     CheckBoxReverse = new QCheckBox( GroupC2, "CheckBoxReverse" );
272     CheckBoxReverse->setText( tr( "GEOM_REVERSE"  ) );
273     GroupC2Layout->addWidget( CheckBoxReverse, 4, 0  );
274
275     SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
276     SelectButtonC2A1->setText( tr( ""  ) );
277     SelectButtonC2A1->setPixmap( image1 );
278     SelectButtonC2A1->setToggleButton( FALSE );
279     SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
280     GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
281
282     SelectButtonC2A2 = new QPushButton( GroupC2, "SelectButtonC2A2" );
283     SelectButtonC2A2->setText( tr( ""  ) );
284     SelectButtonC2A2->setPixmap( image1 );
285     SelectButtonC2A2->setToggleButton( FALSE );
286     SelectButtonC2A2->setMaximumSize( QSize( 28, 32767 ) );
287     GroupC2Layout->addWidget( SelectButtonC2A2, 1, 1 );
288
289     GeometryGUI_MultiRotationDlgLayout->addWidget( GroupC2, 1, 0 );
290
291     /***************************************************************/
292
293     Init(Sel) ; /* Initialisations */
294 }
295
296 //=================================================================================
297 // function : ~GeometryGUI_MultiRotationDlg()
298 // purpose  : Destroys the object and frees any allocated resources
299 //=================================================================================
300 GeometryGUI_MultiRotationDlg::~GeometryGUI_MultiRotationDlg()
301 {
302   // no need to delete child widgets, Qt does it all for us
303 }
304
305 //=================================================================================
306 // function : Init()
307 // purpose  :
308 //=================================================================================
309 void GeometryGUI_MultiRotationDlg::Init( SALOME_Selection* Sel )
310 {
311
312  /* Get setting of step value from file configuration */
313   double step ;
314   QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
315   step = St.toDouble() ;
316
317   /* min, max, step and decimals for geom spin boxes */
318   SpinBox_C2A3->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* angle : constructor 2 */
319   SpinBox_C2A3->SetValue( 45.0 ) ;
320   SpinBox_C2A5->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step  : constructor 2 */
321   SpinBox_C2A5->SetValue( 50.0 ) ;
322
323   /* min, max, step for QT spin boxes */
324   SpinBox_C1A3->setMinValue( 2 );    /* myNbTimes : constructor 1 */
325   SpinBox_C1A3->setMaxValue( 10000 );
326   SpinBox_C1A3->setWrapping( TRUE );
327   SpinBox_C1A3->setValue(2) ;
328   
329   SpinBox_C2A4->setMinValue( 2 );    /* myNbTimes1 : constructor 2 */
330   SpinBox_C2A4->setMaxValue( 10000 );
331   SpinBox_C2A4->setWrapping( TRUE );
332   SpinBox_C2A4->setValue(2) ;
333   
334   SpinBox_C2A6->setMinValue( 2 );    /* myNbTimes2 : constructor 2 */
335   SpinBox_C2A6->setMaxValue( 10000 );
336   SpinBox_C2A6->setWrapping( TRUE );
337   SpinBox_C2A6->setValue(2) ;
338
339   myAng = 45.0 ;
340   myStep = 50.0 ;
341   myNbTimes1 = 2;
342   myNbTimes2 = 2;
343
344   GroupC1->show();
345   GroupC2->hide() ;
346   myConstructorId = 0 ;
347   Constructor1->setChecked( TRUE );
348   myEditCurrentArgument = LineEditC1A1 ;        
349   mySelection = Sel;
350   myGeomGUI = GeometryGUI::GetGeometryGUI() ;
351
352   myOkBase = myOkDir  = false ;
353   mySimulationTopoDs.Nullify() ;
354   myBase.Nullify() ;
355   myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
356
357   // TODO : set previous selection into argument ?
358
359   /* Filter definitions */
360   Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
361   myGeom = GEOM::GEOM_Gen::_narrow(comp);
362   myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
363
364   /* signals and slots connections */
365   connect( buttonOk, SIGNAL( clicked() ),     this, SLOT( ClickOnOk() ) );
366   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
367   connect( buttonApply, SIGNAL( clicked() ),  this, SLOT(ClickOnApply() ) );
368   connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );  
369   connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
370   connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
371   connect( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
372   connect( SelectButtonC2A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
373  
374   connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
375   connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
376   connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
377   connect( LineEditC2A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
378  
379   /* GeometryGUI_SpinBox */
380   connect( SpinBox_C2A3, SIGNAL ( valueChanged( double) ), this, SLOT( valueChangedInSpinBox( double) ) ) ;
381   connect( SpinBox_C2A5, SIGNAL ( valueChanged( double) ), this, SLOT( valueChangedInSpinBox( double) ) ) ;
382   
383   /* QSpinBox */
384   connect( SpinBox_C1A3, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; /* Not const ! */
385   connect( SpinBox_C2A4, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
386   connect( SpinBox_C2A6, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
387
388   connect( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle(int) ) ) ;
389
390   connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;  
391   connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
392   /* to close dialog if study change */
393   connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
394  
395   /* Move widget on the botton right corner of main widget */
396   int x, y ;
397   myGeomGUI->DefineDlgPosition( this, x, y ) ;
398   this->move( x, y ) ;
399   this->show() ; /* displays Dialog */
400
401   return ;
402 }
403
404 //=================================================================================
405 // function : ReverseAngle()
406 // purpose  : 'state' not used here
407 //=================================================================================
408 void GeometryGUI_MultiRotationDlg::ReverseAngle(int state)
409 {
410   myAng = -myAng ;
411   SpinBox_C2A3->SetValue( myAng ) ;
412   if( myOkBase && myOkDir ) {
413     MakeMultiRotationSimulationAndDisplay() ;
414   }
415   else {
416     myGeomGUI->EraseSimulationShape() ; 
417     mySimulationTopoDs.Nullify() ;
418   }
419    return ;
420 }
421
422
423 //=================================================================================
424 // function : ConstructorsClicked()
425 // purpose  : Radio button management
426 //=================================================================================
427 void GeometryGUI_MultiRotationDlg::ConstructorsClicked(int constructorId)
428 {
429   myEditCurrentArgument->setText(tr("")) ;
430   myGeomGUI->EraseSimulationShape() ;
431   mySimulationTopoDs.Nullify() ;
432
433   myAng = 45.0 ;
434   myStep = 50.0 ;
435   myNbTimes1 = 2;
436   myNbTimes2 = 2;
437
438   myOkBase = myOkDir  = false ;
439   myConstructorId = constructorId ;
440
441   switch (constructorId)
442     {
443     case 0: /* Rotate simple */
444       {
445         GroupC1->show();
446         GroupC2->hide() ;
447         myEditCurrentArgument = LineEditC1A1 ;
448         SpinBox_C1A3->setValue( 2 ) ;
449         LineEditC1A1->setText(tr("")) ;
450         LineEditC1A2->setText(tr("")) ;
451         break;
452       }
453
454     case 1: /* Rotate double */
455       {
456         GroupC1->hide();
457         GroupC2->show() ;
458         myEditCurrentArgument = LineEditC2A1 ;
459         SpinBox_C2A3->SetValue( 45.0 ) ;
460         SpinBox_C2A4->setValue( 2 ) ;
461         SpinBox_C2A5->SetValue( 50.0 ) ;
462         SpinBox_C2A6->setValue( 2 ) ;
463         LineEditC2A1->setText(tr("")) ;
464         LineEditC2A2->setText(tr("")) ;
465         break ;
466       }      
467     }
468   return ;
469 }
470
471 //=================================================================================
472 // function : ClickOnOk()
473 // purpose  :
474 //=================================================================================
475 void GeometryGUI_MultiRotationDlg::ClickOnOk()
476 {
477   this->ClickOnApply() ;
478   this->ClickOnCancel() ;
479
480   return ;
481 }
482
483 //=================================================================================
484 // function : ClickOnApply()
485 // purpose  :
486 //=================================================================================
487 void GeometryGUI_MultiRotationDlg::ClickOnApply()
488 {
489   myGeomGUI->EraseSimulationShape() ;
490   mySimulationTopoDs.Nullify() ;
491   myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
492   switch(myConstructorId)
493     { 
494     case 0 :
495       { 
496         if(myOkBase && myOkDir) {
497           myGeomGUI->MakeMultiRotation1DAndDisplay( myGeomShape, myDir, myLoc, myNbTimes1 ) ;
498         }
499         break ;
500       }
501     case 1 :
502       { 
503         if(myOkBase && myOkDir) {
504           myGeomGUI->MakeMultiRotation2DAndDisplay( myGeomShape, myDir, myLoc, myAng, myNbTimes1, myStep, myNbTimes2 ) ;
505         }
506         break ;
507       }
508     }
509   return ;
510 }
511
512
513 //=================================================================================
514 // function : ClickOnCancel()
515 // purpose  :
516 //=================================================================================
517 void GeometryGUI_MultiRotationDlg::ClickOnCancel()
518 {
519   mySelection->ClearFilters() ;
520   myGeomGUI->EraseSimulationShape() ;
521   mySimulationTopoDs.Nullify() ;
522   disconnect( mySelection, 0, this, 0 );
523   myGeomGUI->ResetState() ;
524   reject() ;
525   return ;
526 }
527
528
529 //=================================================================================
530 // function : LineEditReturnPressed()
531 // purpose  :
532 //=================================================================================
533 void GeometryGUI_MultiRotationDlg::LineEditReturnPressed()
534 {
535   QLineEdit* send = (QLineEdit*)sender() ; 
536   if( send == LineEditC1A1 )
537     myEditCurrentArgument = LineEditC1A1 ;
538   else if ( send == LineEditC1A2 )
539     myEditCurrentArgument = LineEditC1A2 ; 
540   else if ( send == LineEditC2A1 )
541     myEditCurrentArgument = LineEditC2A1;
542   else if ( send == LineEditC2A2 )
543     myEditCurrentArgument = LineEditC2A2 ; 
544   else
545     return ;
546   
547   /* User name of object input management                          */
548   /* If successfull the selection is changed and signal emitted... */
549   /* so SelectionIntoArgument() is automatically called.           */
550   const QString objectUserName = myEditCurrentArgument->text() ;
551   QWidget* thisWidget = (QWidget*)this ;
552   if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
553     myEditCurrentArgument->setText( objectUserName ) ;
554   }
555   return ;
556 }
557
558
559
560 //=================================================================================
561 // function : SelectionIntoArgument()
562 // purpose  : Called when selection as changed or other case
563 //=================================================================================
564 void GeometryGUI_MultiRotationDlg::SelectionIntoArgument()
565 {
566   myEditCurrentArgument->setText("") ;
567   myGeomGUI->EraseSimulationShape() ; 
568   mySimulationTopoDs.Nullify() ;
569   
570   /* Name of future selection */
571   QString aString = "";
572   int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
573
574   TopoDS_Shape S;
575   Standard_Boolean testResult ;
576   
577   switch (myConstructorId)
578     {
579     case 0 :
580       { 
581         if ( nbSel != 1 ) {
582           if ( myEditCurrentArgument == LineEditC1A1 ) {
583             myEditCurrentArgument->setText("") ;
584             myOkBase = false ;
585           }
586           else if ( myEditCurrentArgument == LineEditC1A2 ) { 
587             myEditCurrentArgument->setText("") ;
588             myOkDir = false ;
589           }
590           return ;
591         }
592
593         Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
594         if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
595           return ;
596
597         if ( myEditCurrentArgument == LineEditC1A1 ) {
598           myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
599           if( !testResult )
600             return ;
601           myEditCurrentArgument->setText(aString) ;
602           myBase = S ;
603           myOkBase = true ;
604         }    
605         else if ( myEditCurrentArgument == LineEditC1A2 ) {
606           BRepAdaptor_Curve curv(TopoDS::Edge(S));
607           myDir = curv.Line().Direction();
608           myLoc = curv.Line().Location();
609           myEditCurrentArgument->setText(aString) ;
610           myOkDir = true ;
611         }
612         
613         if (myOkBase && myOkDir ) {
614           MakeMultiRotationSimulationAndDisplay() ;
615         }
616         else {
617           myGeomGUI->EraseSimulationShape() ; 
618           mySimulationTopoDs.Nullify() ;
619         }
620         break;
621       }
622     case 1 :
623       { 
624         if ( nbSel != 1 ) {
625           if ( myEditCurrentArgument == LineEditC2A1 ) {
626             myEditCurrentArgument->setText("") ;
627             myOkBase = false ;
628           }
629           else if ( myEditCurrentArgument == LineEditC2A2 ) { 
630             myEditCurrentArgument->setText("") ;
631             myOkDir = false ;
632           }
633           return ;
634         }
635
636         Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
637         if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
638           return ; 
639
640         if ( myEditCurrentArgument == LineEditC2A1 ) {
641           myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
642           if( !testResult )
643             return ;
644           myEditCurrentArgument->setText(aString) ;
645           myBase = S ;
646           myOkBase = true ;
647         }    
648         else if ( myEditCurrentArgument == LineEditC2A2 ) {
649           BRepAdaptor_Curve curv(TopoDS::Edge(S));
650           myDir = curv.Line().Direction();
651           myLoc = curv.Line().Location();
652           myEditCurrentArgument->setText(aString) ;
653           myOkDir = true ;
654         }
655         
656         if ( myOkBase && myOkDir ) {
657           MakeMultiRotationSimulationAndDisplay() ;
658         }
659         else {
660           myGeomGUI->EraseSimulationShape() ; 
661           mySimulationTopoDs.Nullify() ;
662         }
663         break;
664       }
665     }
666
667   return ;
668 }
669
670
671 //=================================================================================
672 // function : SetEditCurrentArgument()
673 // purpose  :
674 //=================================================================================
675 void GeometryGUI_MultiRotationDlg::SetEditCurrentArgument()
676 {
677   QPushButton* send = (QPushButton*)sender();
678   switch (myConstructorId)
679     {
680     case 0 :
681       { 
682         if(send == SelectButtonC1A1) {
683           LineEditC1A1->setFocus() ;
684           myEditCurrentArgument = LineEditC1A1;
685           mySelection->ClearFilters() ;
686         }
687         else if(send == SelectButtonC1A2) {
688           LineEditC1A2->setFocus() ;      
689           myEditCurrentArgument = LineEditC1A2;
690           mySelection->AddFilter(myEdgeFilter) ;
691         }       
692         SelectionIntoArgument() ;
693         break;
694       }
695     case 1 :
696       { 
697         if(send == SelectButtonC2A1) {
698           LineEditC2A1->setFocus() ;
699           myEditCurrentArgument = LineEditC2A1;
700           mySelection->ClearFilters() ;
701         }
702         else if(send == SelectButtonC2A2) {
703           LineEditC2A2->setFocus() ;      
704           myEditCurrentArgument = LineEditC2A2;
705           mySelection->AddFilter(myEdgeFilter) ;
706         }
707         SelectionIntoArgument() ;
708         break;
709       }
710     }
711   return ;
712 }
713
714 //=================================================================================
715 // function : ValueChangedInt()
716 // purpose  :
717 //=================================================================================
718 void GeometryGUI_MultiRotationDlg::ValueChangedInt( int newIntValue )
719 {    
720   QSpinBox* send = (QSpinBox*)sender();
721  
722   if( send == SpinBox_C1A3 ) {
723     myNbTimes1 = newIntValue ;
724   }
725   else if(send == SpinBox_C2A4 ) {
726     myNbTimes1 = newIntValue ;
727   }
728   else if(send == SpinBox_C2A6 ) {
729     myNbTimes2 = newIntValue ;
730   }
731
732   switch (myConstructorId)
733     {
734     case 0 :
735       { 
736         if (myOkBase && myOkDir ) {
737           MakeMultiRotationSimulationAndDisplay() ;
738         }
739         else {
740           myGeomGUI->EraseSimulationShape() ; 
741           mySimulationTopoDs.Nullify() ;
742         }
743         break;
744       }
745     case 1 :
746       { 
747         if (myOkBase && myOkDir ) {
748           MakeMultiRotationSimulationAndDisplay() ;
749         }
750         else {
751           myGeomGUI->EraseSimulationShape() ; 
752           mySimulationTopoDs.Nullify() ;
753         }
754         break;
755       }
756     }  
757   return ;
758 }
759
760
761 //=================================================================================
762 // function : ValueChangedInSpinBox()
763 // purpose  : (specifig for GeometryGUI_SpinBox)
764 //=================================================================================
765 void GeometryGUI_MultiRotationDlg::ValueChangedInSpinBox( double newValue )
766 {    
767   GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender();
768   
769   if( send == SpinBox_C2A3 ) {
770     myAng = newValue ;
771   }
772   else if( send == SpinBox_C2A5 ) {
773     myStep = newValue ;
774   }
775   
776   switch (myConstructorId)
777     {
778     case 0 :
779       { 
780         if (myOkBase && myOkDir ) {
781           MakeMultiRotationSimulationAndDisplay() ;
782         }
783         else {
784           myGeomGUI->EraseSimulationShape() ; 
785           mySimulationTopoDs.Nullify() ;
786         }
787         break;
788       }
789     case 1 :
790       { 
791         if (myOkBase && myOkDir ) {
792           MakeMultiRotationSimulationAndDisplay() ;
793         }
794         else {
795           myGeomGUI->EraseSimulationShape() ; 
796           mySimulationTopoDs.Nullify() ;
797         }
798         break;
799       }
800     }  
801   return ;
802 }
803
804
805 //=================================================================================
806 // function : DeactivateActiveDialog()
807 // purpose  :
808 //=================================================================================
809 void GeometryGUI_MultiRotationDlg::DeactivateActiveDialog()
810 {
811   if ( GroupConstructors->isEnabled() ) {
812     GroupConstructors->setEnabled(false) ;
813     GroupC1->setEnabled(false) ;
814     GroupC2->setEnabled(false) ;
815     GroupButtons->setEnabled(false) ;
816     disconnect( mySelection, 0, this, 0 );
817     myGeomGUI->EraseSimulationShape() ;
818     mySelection->ClearFilters() ;
819     myGeomGUI->ResetState() ;    
820     myGeomGUI->SetActiveDialogBox(0) ;
821     myGeomGUI->OnDisplayAll(true) ;
822   }
823   return ;
824 }
825
826
827 //=================================================================================
828 // function : ActivateThisDialog()
829 // purpose  :
830 //=================================================================================
831 void GeometryGUI_MultiRotationDlg::ActivateThisDialog()
832 {
833   /* Emit a signal to deactivate the active dialog */
834   myGeomGUI->EmitSignalDeactivateDialog() ;   
835   GroupConstructors->setEnabled(true) ;
836   GroupC1->setEnabled(true) ;
837   GroupC2->setEnabled(true) ;
838   GroupButtons->setEnabled(true) ;
839   connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
840   myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
841   if( !mySimulationTopoDs.IsNull() )
842     myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
843   return ;
844 }
845
846
847
848 //=================================================================================
849 // function : enterEvent()
850 // purpose  :
851 //=================================================================================
852 void GeometryGUI_MultiRotationDlg::enterEvent(QEvent* e)
853 {
854   if ( GroupConstructors->isEnabled() )
855     return ;  
856   ActivateThisDialog() ;
857   return ;
858 }
859
860
861
862 //=================================================================================
863 // function : closeEvent()
864 // purpose  :
865 //=================================================================================
866 void GeometryGUI_MultiRotationDlg::closeEvent( QCloseEvent* e )
867 {
868   this->ClickOnCancel() ; /* same than click on cancel button */
869   return ;
870 }
871
872
873 //=================================================================================
874 // function : MakeMultiRotationSimulationAndDisplay()
875 // purpose  :
876 //=================================================================================
877 void GeometryGUI_MultiRotationDlg::MakeMultiRotationSimulationAndDisplay() 
878 {
879   myGeomGUI->EraseSimulationShape() ;
880   gp_Trsf theTransformation ;
881   gp_Trsf theTransformation1 ;
882   gp_Trsf theTransformation2 ;
883   mySimulationTopoDs.Nullify() ;
884
885   int i ;
886   int j ;
887   Standard_Real DX ;
888   Standard_Real DY ;
889   Standard_Real DZ ;
890   GProp_GProps System ;
891   gp_Pnt myPoint ;
892   TopoDS_Compound compound;
893   BRep_Builder B;
894
895   B.MakeCompound( compound );  
896
897   if ( myBase.ShapeType() == TopAbs_VERTEX) {
898     myGeomGUI->VertexToPoint( myBase,  myPoint );
899   } 
900   else if ( myBase.ShapeType() == TopAbs_EDGE || myBase.ShapeType() == TopAbs_WIRE ) {
901     BRepGProp::LinearProperties(myBase, System);
902     myPoint = System.CentreOfMass() ;
903   }
904   else if ( myBase.ShapeType() == TopAbs_FACE || myBase.ShapeType() == TopAbs_SHELL ) {
905     BRepGProp::SurfaceProperties(myBase, System);
906     myPoint = System.CentreOfMass() ;
907   }
908   else {
909     BRepGProp::VolumeProperties(myBase, System);
910     myPoint = System.CentreOfMass() ;
911   }
912
913   TopoDS_Shape S = BRepBuilderAPI_MakeVertex(myPoint).Shape();
914
915   try {
916     switch (myConstructorId)
917       {
918       case 0 :
919         { 
920           gp_Ax1 AX1( myLoc, myDir ) ;
921           Standard_Real angle = 360/myNbTimes1;
922           for ( i = 0; i < myNbTimes1; i++ ) {
923             theTransformation.SetRotation(AX1, i*angle*PI180) ;
924             BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ;
925             B.Add( compound, myBRepTransformation.Shape() );
926           }
927           mySimulationTopoDs = compound;
928           myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
929           break;
930         }
931       case 1 :
932         {       
933           gp_Ax1 AX2( myLoc, myDir ) ;
934           Handle(Geom_Line) Line = new Geom_Line(AX2);
935           gp_Pnt P2 = GeomAPI_ProjectPointOnCurve( myPoint, Line ) ;
936           if ( myPoint.IsEqual(P2, Precision::Confusion() ) )
937             return;
938           gp_Vec Vec(P2, myPoint) ;
939           Vec.Normalize();
940
941           for ( i = 0; i < myNbTimes2; i++ ) {
942             for ( j = 0; j < myNbTimes1; j++ ) {
943               DX = i * myStep * Vec.X() ;
944               DY = i * myStep * Vec.Y() ;
945               DZ = i * myStep * Vec.Z() ;
946               myVec.SetCoord( DX, DY, DZ ) ;
947
948               theTransformation1.SetTranslation(myVec) ;
949               theTransformation2.SetRotation(AX2, j*myAng*PI180) ;
950               BRepBuilderAPI_Transform myBRepTransformation1(S, theTransformation1, Standard_False) ;
951               BRepBuilderAPI_Transform myBRepTransformation2(myBRepTransformation1.Shape(), theTransformation2, Standard_False) ;
952               B.Add( compound, myBRepTransformation2.Shape() );
953             }
954           }
955           mySimulationTopoDs = compound ;
956           myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
957           break;
958         }
959       }
960   }
961   catch(Standard_Failure) {
962     MESSAGE( "Exception catched in MakeMultitranslationSimulationAndDisplay" ) ;
963     return ;
964   }
965   return ;
966 }