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