2 // File : GeometryGUI_MultiTranslationDlg.cxx
4 // Author : Damien COQUERET
6 // Module : GeometryGUI
7 // Copyright : OPEN CASCADE
10 #include "GeometryGUI_MultiRotationDlg.h"
12 #include "GeometryGUI.h"
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Config.h"
16 #include "utilities.h"
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>
29 #include <qbuttongroup.h>
30 #include <qcheckbox.h>
31 #include <qgroupbox.h>
33 #include <qlineedit.h>
34 #include <qpushbutton.h>
35 #include <qradiobutton.h>
39 #include <qwhatsthis.h>
41 #include <qvalidator.h>
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 )
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")));
61 setName( "GeometryGUI_MultiTranlationDlg" );
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 );
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 );
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 );
98 GeometryGUI_MultiRotationDlgLayout->addWidget( GroupConstructors, 0, 0 );
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 );
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 );
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 );
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 );
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 );
163 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
164 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
166 LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
167 GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
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 );
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 );
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 );
188 GeometryGUI_MultiRotationDlgLayout->addWidget( GroupC1, 1, 0 );
190 /***************************************************************/
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 );
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 );
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 );
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 );
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 );
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 );
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 );
247 LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
248 GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
250 LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
251 GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
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 );
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 );
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 );
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 );
271 CheckBoxReverse = new QCheckBox( GroupC2, "CheckBoxReverse" );
272 CheckBoxReverse->setText( tr( "GEOM_REVERSE" ) );
273 GroupC2Layout->addWidget( CheckBoxReverse, 4, 0 );
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 );
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 );
289 GeometryGUI_MultiRotationDlgLayout->addWidget( GroupC2, 1, 0 );
291 /***************************************************************/
293 Init(Sel) ; /* Initialisations */
296 //=================================================================================
297 // function : ~GeometryGUI_MultiRotationDlg()
298 // purpose : Destroys the object and frees any allocated resources
299 //=================================================================================
300 GeometryGUI_MultiRotationDlg::~GeometryGUI_MultiRotationDlg()
302 // no need to delete child widgets, Qt does it all for us
305 //=================================================================================
308 //=================================================================================
309 void GeometryGUI_MultiRotationDlg::Init( SALOME_Selection* Sel )
312 /* Get setting of step value from file configuration */
314 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
315 step = St.toDouble() ;
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 ) ;
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) ;
329 SpinBox_C2A4->setMinValue( 2 ); /* myNbTimes1 : constructor 2 */
330 SpinBox_C2A4->setMaxValue( 10000 );
331 SpinBox_C2A4->setWrapping( TRUE );
332 SpinBox_C2A4->setValue(2) ;
334 SpinBox_C2A6->setMinValue( 2 ); /* myNbTimes2 : constructor 2 */
335 SpinBox_C2A6->setMaxValue( 10000 );
336 SpinBox_C2A6->setWrapping( TRUE );
337 SpinBox_C2A6->setValue(2) ;
346 myConstructorId = 0 ;
347 Constructor1->setChecked( TRUE );
348 myEditCurrentArgument = LineEditC1A1 ;
350 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
352 myOkBase = myOkDir = false ;
353 mySimulationTopoDs.Nullify() ;
355 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
357 // TODO : set previous selection into argument ?
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 );
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() ) ) ;
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() ) ) ;
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) ) ) ;
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) ) ) ;
388 connect( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle(int) ) ) ;
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() ) ) ;
395 /* Move widget on the botton right corner of main widget */
397 myGeomGUI->DefineDlgPosition( this, x, y ) ;
399 this->show() ; /* displays Dialog */
404 //=================================================================================
405 // function : ReverseAngle()
406 // purpose : 'state' not used here
407 //=================================================================================
408 void GeometryGUI_MultiRotationDlg::ReverseAngle(int state)
411 SpinBox_C2A3->SetValue( myAng ) ;
412 if( myOkBase && myOkDir ) {
413 MakeMultiRotationSimulationAndDisplay() ;
416 myGeomGUI->EraseSimulationShape() ;
417 mySimulationTopoDs.Nullify() ;
423 //=================================================================================
424 // function : ConstructorsClicked()
425 // purpose : Radio button management
426 //=================================================================================
427 void GeometryGUI_MultiRotationDlg::ConstructorsClicked(int constructorId)
429 myEditCurrentArgument->setText(tr("")) ;
430 myGeomGUI->EraseSimulationShape() ;
431 mySimulationTopoDs.Nullify() ;
438 myOkBase = myOkDir = false ;
439 myConstructorId = constructorId ;
441 switch (constructorId)
443 case 0: /* Rotate simple */
447 myEditCurrentArgument = LineEditC1A1 ;
448 SpinBox_C1A3->setValue( 2 ) ;
449 LineEditC1A1->setText(tr("")) ;
450 LineEditC1A2->setText(tr("")) ;
454 case 1: /* Rotate double */
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("")) ;
471 //=================================================================================
472 // function : ClickOnOk()
474 //=================================================================================
475 void GeometryGUI_MultiRotationDlg::ClickOnOk()
477 this->ClickOnApply() ;
478 this->ClickOnCancel() ;
483 //=================================================================================
484 // function : ClickOnApply()
486 //=================================================================================
487 void GeometryGUI_MultiRotationDlg::ClickOnApply()
489 myGeomGUI->EraseSimulationShape() ;
490 mySimulationTopoDs.Nullify() ;
491 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
492 switch(myConstructorId)
496 if(myOkBase && myOkDir) {
497 myGeomGUI->MakeMultiRotation1DAndDisplay( myGeomShape, myDir, myLoc, myNbTimes1 ) ;
503 if(myOkBase && myOkDir) {
504 myGeomGUI->MakeMultiRotation2DAndDisplay( myGeomShape, myDir, myLoc, myAng, myNbTimes1, myStep, myNbTimes2 ) ;
513 //=================================================================================
514 // function : ClickOnCancel()
516 //=================================================================================
517 void GeometryGUI_MultiRotationDlg::ClickOnCancel()
519 mySelection->ClearFilters() ;
520 myGeomGUI->EraseSimulationShape() ;
521 mySimulationTopoDs.Nullify() ;
522 disconnect( mySelection, 0, this, 0 );
523 myGeomGUI->ResetState() ;
529 //=================================================================================
530 // function : LineEditReturnPressed()
532 //=================================================================================
533 void GeometryGUI_MultiRotationDlg::LineEditReturnPressed()
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 ;
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 ) ;
560 //=================================================================================
561 // function : SelectionIntoArgument()
562 // purpose : Called when selection as changed or other case
563 //=================================================================================
564 void GeometryGUI_MultiRotationDlg::SelectionIntoArgument()
566 myEditCurrentArgument->setText("") ;
567 myGeomGUI->EraseSimulationShape() ;
568 mySimulationTopoDs.Nullify() ;
570 /* Name of future selection */
571 QString aString = "";
572 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
575 Standard_Boolean testResult ;
577 switch (myConstructorId)
582 if ( myEditCurrentArgument == LineEditC1A1 ) {
583 myEditCurrentArgument->setText("") ;
586 else if ( myEditCurrentArgument == LineEditC1A2 ) {
587 myEditCurrentArgument->setText("") ;
593 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
594 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
597 if ( myEditCurrentArgument == LineEditC1A1 ) {
598 myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
601 myEditCurrentArgument->setText(aString) ;
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) ;
613 if (myOkBase && myOkDir ) {
614 MakeMultiRotationSimulationAndDisplay() ;
617 myGeomGUI->EraseSimulationShape() ;
618 mySimulationTopoDs.Nullify() ;
625 if ( myEditCurrentArgument == LineEditC2A1 ) {
626 myEditCurrentArgument->setText("") ;
629 else if ( myEditCurrentArgument == LineEditC2A2 ) {
630 myEditCurrentArgument->setText("") ;
636 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
637 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
640 if ( myEditCurrentArgument == LineEditC2A1 ) {
641 myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
644 myEditCurrentArgument->setText(aString) ;
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) ;
656 if ( myOkBase && myOkDir ) {
657 MakeMultiRotationSimulationAndDisplay() ;
660 myGeomGUI->EraseSimulationShape() ;
661 mySimulationTopoDs.Nullify() ;
671 //=================================================================================
672 // function : SetEditCurrentArgument()
674 //=================================================================================
675 void GeometryGUI_MultiRotationDlg::SetEditCurrentArgument()
677 QPushButton* send = (QPushButton*)sender();
678 switch (myConstructorId)
682 if(send == SelectButtonC1A1) {
683 LineEditC1A1->setFocus() ;
684 myEditCurrentArgument = LineEditC1A1;
685 mySelection->ClearFilters() ;
687 else if(send == SelectButtonC1A2) {
688 LineEditC1A2->setFocus() ;
689 myEditCurrentArgument = LineEditC1A2;
690 mySelection->AddFilter(myEdgeFilter) ;
692 SelectionIntoArgument() ;
697 if(send == SelectButtonC2A1) {
698 LineEditC2A1->setFocus() ;
699 myEditCurrentArgument = LineEditC2A1;
700 mySelection->ClearFilters() ;
702 else if(send == SelectButtonC2A2) {
703 LineEditC2A2->setFocus() ;
704 myEditCurrentArgument = LineEditC2A2;
705 mySelection->AddFilter(myEdgeFilter) ;
707 SelectionIntoArgument() ;
714 //=================================================================================
715 // function : ValueChangedInt()
717 //=================================================================================
718 void GeometryGUI_MultiRotationDlg::ValueChangedInt( int newIntValue )
720 QSpinBox* send = (QSpinBox*)sender();
722 if( send == SpinBox_C1A3 ) {
723 myNbTimes1 = newIntValue ;
725 else if(send == SpinBox_C2A4 ) {
726 myNbTimes1 = newIntValue ;
728 else if(send == SpinBox_C2A6 ) {
729 myNbTimes2 = newIntValue ;
732 switch (myConstructorId)
736 if (myOkBase && myOkDir ) {
737 MakeMultiRotationSimulationAndDisplay() ;
740 myGeomGUI->EraseSimulationShape() ;
741 mySimulationTopoDs.Nullify() ;
747 if (myOkBase && myOkDir ) {
748 MakeMultiRotationSimulationAndDisplay() ;
751 myGeomGUI->EraseSimulationShape() ;
752 mySimulationTopoDs.Nullify() ;
761 //=================================================================================
762 // function : ValueChangedInSpinBox()
763 // purpose : (specifig for GeometryGUI_SpinBox)
764 //=================================================================================
765 void GeometryGUI_MultiRotationDlg::ValueChangedInSpinBox( double newValue )
767 GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender();
769 if( send == SpinBox_C2A3 ) {
772 else if( send == SpinBox_C2A5 ) {
776 switch (myConstructorId)
780 if (myOkBase && myOkDir ) {
781 MakeMultiRotationSimulationAndDisplay() ;
784 myGeomGUI->EraseSimulationShape() ;
785 mySimulationTopoDs.Nullify() ;
791 if (myOkBase && myOkDir ) {
792 MakeMultiRotationSimulationAndDisplay() ;
795 myGeomGUI->EraseSimulationShape() ;
796 mySimulationTopoDs.Nullify() ;
805 //=================================================================================
806 // function : DeactivateActiveDialog()
808 //=================================================================================
809 void GeometryGUI_MultiRotationDlg::DeactivateActiveDialog()
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) ;
827 //=================================================================================
828 // function : ActivateThisDialog()
830 //=================================================================================
831 void GeometryGUI_MultiRotationDlg::ActivateThisDialog()
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 ) ;
848 //=================================================================================
849 // function : enterEvent()
851 //=================================================================================
852 void GeometryGUI_MultiRotationDlg::enterEvent(QEvent* e)
854 if ( GroupConstructors->isEnabled() )
856 ActivateThisDialog() ;
862 //=================================================================================
863 // function : closeEvent()
865 //=================================================================================
866 void GeometryGUI_MultiRotationDlg::closeEvent( QCloseEvent* e )
868 this->ClickOnCancel() ; /* same than click on cancel button */
873 //=================================================================================
874 // function : MakeMultiRotationSimulationAndDisplay()
876 //=================================================================================
877 void GeometryGUI_MultiRotationDlg::MakeMultiRotationSimulationAndDisplay()
879 myGeomGUI->EraseSimulationShape() ;
880 gp_Trsf theTransformation ;
881 gp_Trsf theTransformation1 ;
882 gp_Trsf theTransformation2 ;
883 mySimulationTopoDs.Nullify() ;
890 GProp_GProps System ;
892 TopoDS_Compound compound;
895 B.MakeCompound( compound );
897 if ( myBase.ShapeType() == TopAbs_VERTEX) {
898 myGeomGUI->VertexToPoint( myBase, myPoint );
900 else if ( myBase.ShapeType() == TopAbs_EDGE || myBase.ShapeType() == TopAbs_WIRE ) {
901 BRepGProp::LinearProperties(myBase, System);
902 myPoint = System.CentreOfMass() ;
904 else if ( myBase.ShapeType() == TopAbs_FACE || myBase.ShapeType() == TopAbs_SHELL ) {
905 BRepGProp::SurfaceProperties(myBase, System);
906 myPoint = System.CentreOfMass() ;
909 BRepGProp::VolumeProperties(myBase, System);
910 myPoint = System.CentreOfMass() ;
913 TopoDS_Shape S = BRepBuilderAPI_MakeVertex(myPoint).Shape();
916 switch (myConstructorId)
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() );
927 mySimulationTopoDs = compound;
928 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
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() ) )
938 gp_Vec Vec(P2, myPoint) ;
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 ) ;
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() );
955 mySimulationTopoDs = compound ;
956 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
961 catch(Standard_Failure) {
962 MESSAGE( "Exception catched in MakeMultitranslationSimulationAndDisplay" ) ;