1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GeometryGUI_MultiTranslationDlg.cxx
25 // Author : Damien COQUERET
30 #include "GeometryGUI_MultiRotationDlg.h"
32 #include "GeometryGUI.h"
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "QAD_Config.h"
36 #include "utilities.h"
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>
49 #include <qbuttongroup.h>
50 #include <qcheckbox.h>
51 #include <qgroupbox.h>
53 #include <qlineedit.h>
54 #include <qpushbutton.h>
55 #include <qradiobutton.h>
59 #include <qwhatsthis.h>
61 #include <qvalidator.h>
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 )
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")));
81 setName( "GeometryGUI_MultiTranlationDlg" );
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 );
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 );
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 );
118 GeometryGUI_MultiRotationDlgLayout->addWidget( GroupConstructors, 0, 0 );
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 );
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 );
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 );
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 );
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 );
183 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
184 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
186 LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
187 GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
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 );
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 );
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 );
208 GeometryGUI_MultiRotationDlgLayout->addWidget( GroupC1, 1, 0 );
210 /***************************************************************/
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 );
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 );
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 );
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 );
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 );
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 );
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 );
267 LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
268 GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
270 LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
271 GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
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 );
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 );
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 );
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 );
291 CheckBoxReverse = new QCheckBox( GroupC2, "CheckBoxReverse" );
292 CheckBoxReverse->setText( tr( "GEOM_REVERSE" ) );
293 GroupC2Layout->addWidget( CheckBoxReverse, 4, 0 );
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 );
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 );
309 GeometryGUI_MultiRotationDlgLayout->addWidget( GroupC2, 1, 0 );
311 /***************************************************************/
313 Init(Sel) ; /* Initialisations */
316 //=================================================================================
317 // function : ~GeometryGUI_MultiRotationDlg()
318 // purpose : Destroys the object and frees any allocated resources
319 //=================================================================================
320 GeometryGUI_MultiRotationDlg::~GeometryGUI_MultiRotationDlg()
322 // no need to delete child widgets, Qt does it all for us
325 //=================================================================================
328 //=================================================================================
329 void GeometryGUI_MultiRotationDlg::Init( SALOME_Selection* Sel )
332 /* Get setting of step value from file configuration */
334 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
335 step = St.toDouble() ;
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 ) ;
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) ;
349 SpinBox_C2A4->setMinValue( 2 ); /* myNbTimes1 : constructor 2 */
350 SpinBox_C2A4->setMaxValue( 10000 );
351 SpinBox_C2A4->setWrapping( TRUE );
352 SpinBox_C2A4->setValue(2) ;
354 SpinBox_C2A6->setMinValue( 2 ); /* myNbTimes2 : constructor 2 */
355 SpinBox_C2A6->setMaxValue( 10000 );
356 SpinBox_C2A6->setWrapping( TRUE );
357 SpinBox_C2A6->setValue(2) ;
366 myConstructorId = 0 ;
367 Constructor1->setChecked( TRUE );
368 myEditCurrentArgument = LineEditC1A1 ;
370 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
372 myOkBase = myOkDir = false ;
373 mySimulationTopoDs.Nullify() ;
375 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
377 // TODO : set previous selection into argument ?
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 );
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() ) ) ;
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() ) ) ;
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) ) ) ;
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) ) ) ;
408 connect( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle(int) ) ) ;
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() ) ) ;
415 /* Move widget on the botton right corner of main widget */
417 myGeomGUI->DefineDlgPosition( this, x, y ) ;
419 this->show() ; /* displays Dialog */
424 //=================================================================================
425 // function : ReverseAngle()
426 // purpose : 'state' not used here
427 //=================================================================================
428 void GeometryGUI_MultiRotationDlg::ReverseAngle(int state)
431 SpinBox_C2A3->SetValue( myAng ) ;
432 if( myOkBase && myOkDir ) {
433 MakeMultiRotationSimulationAndDisplay() ;
436 myGeomGUI->EraseSimulationShape() ;
437 mySimulationTopoDs.Nullify() ;
443 //=================================================================================
444 // function : ConstructorsClicked()
445 // purpose : Radio button management
446 //=================================================================================
447 void GeometryGUI_MultiRotationDlg::ConstructorsClicked(int constructorId)
449 myEditCurrentArgument->setText(tr("")) ;
450 myGeomGUI->EraseSimulationShape() ;
451 mySimulationTopoDs.Nullify() ;
458 myOkBase = myOkDir = false ;
459 myConstructorId = constructorId ;
461 switch (constructorId)
463 case 0: /* Rotate simple */
467 myEditCurrentArgument = LineEditC1A1 ;
468 SpinBox_C1A3->setValue( 2 ) ;
469 LineEditC1A1->setText(tr("")) ;
470 LineEditC1A2->setText(tr("")) ;
474 case 1: /* Rotate double */
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("")) ;
491 //=================================================================================
492 // function : ClickOnOk()
494 //=================================================================================
495 void GeometryGUI_MultiRotationDlg::ClickOnOk()
497 this->ClickOnApply() ;
498 this->ClickOnCancel() ;
503 //=================================================================================
504 // function : ClickOnApply()
506 //=================================================================================
507 void GeometryGUI_MultiRotationDlg::ClickOnApply()
509 myGeomGUI->EraseSimulationShape() ;
510 mySimulationTopoDs.Nullify() ;
511 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
512 switch(myConstructorId)
516 if(myOkBase && myOkDir) {
517 myGeomGUI->MakeMultiRotation1DAndDisplay( myGeomShape, myDir, myLoc, myNbTimes1 ) ;
523 if(myOkBase && myOkDir) {
524 myGeomGUI->MakeMultiRotation2DAndDisplay( myGeomShape, myDir, myLoc, myAng, myNbTimes1, myStep, myNbTimes2 ) ;
533 //=================================================================================
534 // function : ClickOnCancel()
536 //=================================================================================
537 void GeometryGUI_MultiRotationDlg::ClickOnCancel()
539 mySelection->ClearFilters() ;
540 myGeomGUI->EraseSimulationShape() ;
541 mySimulationTopoDs.Nullify() ;
542 disconnect( mySelection, 0, this, 0 );
543 myGeomGUI->ResetState() ;
549 //=================================================================================
550 // function : LineEditReturnPressed()
552 //=================================================================================
553 void GeometryGUI_MultiRotationDlg::LineEditReturnPressed()
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 ;
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 ) ;
580 //=================================================================================
581 // function : SelectionIntoArgument()
582 // purpose : Called when selection as changed or other case
583 //=================================================================================
584 void GeometryGUI_MultiRotationDlg::SelectionIntoArgument()
586 myEditCurrentArgument->setText("") ;
587 myGeomGUI->EraseSimulationShape() ;
588 mySimulationTopoDs.Nullify() ;
590 /* Name of future selection */
591 QString aString = "";
592 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
595 Standard_Boolean testResult ;
597 switch (myConstructorId)
602 if ( myEditCurrentArgument == LineEditC1A1 ) {
603 myEditCurrentArgument->setText("") ;
606 else if ( myEditCurrentArgument == LineEditC1A2 ) {
607 myEditCurrentArgument->setText("") ;
613 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
614 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
617 if ( myEditCurrentArgument == LineEditC1A1 ) {
618 myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
621 myEditCurrentArgument->setText(aString) ;
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) ;
633 if (myOkBase && myOkDir ) {
634 MakeMultiRotationSimulationAndDisplay() ;
637 myGeomGUI->EraseSimulationShape() ;
638 mySimulationTopoDs.Nullify() ;
645 if ( myEditCurrentArgument == LineEditC2A1 ) {
646 myEditCurrentArgument->setText("") ;
649 else if ( myEditCurrentArgument == LineEditC2A2 ) {
650 myEditCurrentArgument->setText("") ;
656 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
657 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
660 if ( myEditCurrentArgument == LineEditC2A1 ) {
661 myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
664 myEditCurrentArgument->setText(aString) ;
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) ;
676 if ( myOkBase && myOkDir ) {
677 MakeMultiRotationSimulationAndDisplay() ;
680 myGeomGUI->EraseSimulationShape() ;
681 mySimulationTopoDs.Nullify() ;
691 //=================================================================================
692 // function : SetEditCurrentArgument()
694 //=================================================================================
695 void GeometryGUI_MultiRotationDlg::SetEditCurrentArgument()
697 QPushButton* send = (QPushButton*)sender();
698 switch (myConstructorId)
702 if(send == SelectButtonC1A1) {
703 LineEditC1A1->setFocus() ;
704 myEditCurrentArgument = LineEditC1A1;
705 mySelection->ClearFilters() ;
707 else if(send == SelectButtonC1A2) {
708 LineEditC1A2->setFocus() ;
709 myEditCurrentArgument = LineEditC1A2;
710 mySelection->AddFilter(myEdgeFilter) ;
712 SelectionIntoArgument() ;
717 if(send == SelectButtonC2A1) {
718 LineEditC2A1->setFocus() ;
719 myEditCurrentArgument = LineEditC2A1;
720 mySelection->ClearFilters() ;
722 else if(send == SelectButtonC2A2) {
723 LineEditC2A2->setFocus() ;
724 myEditCurrentArgument = LineEditC2A2;
725 mySelection->AddFilter(myEdgeFilter) ;
727 SelectionIntoArgument() ;
734 //=================================================================================
735 // function : ValueChangedInt()
737 //=================================================================================
738 void GeometryGUI_MultiRotationDlg::ValueChangedInt( int newIntValue )
740 QSpinBox* send = (QSpinBox*)sender();
742 if( send == SpinBox_C1A3 ) {
743 myNbTimes1 = newIntValue ;
745 else if(send == SpinBox_C2A4 ) {
746 myNbTimes1 = newIntValue ;
748 else if(send == SpinBox_C2A6 ) {
749 myNbTimes2 = newIntValue ;
752 switch (myConstructorId)
756 if (myOkBase && myOkDir ) {
757 MakeMultiRotationSimulationAndDisplay() ;
760 myGeomGUI->EraseSimulationShape() ;
761 mySimulationTopoDs.Nullify() ;
767 if (myOkBase && myOkDir ) {
768 MakeMultiRotationSimulationAndDisplay() ;
771 myGeomGUI->EraseSimulationShape() ;
772 mySimulationTopoDs.Nullify() ;
781 //=================================================================================
782 // function : ValueChangedInSpinBox()
783 // purpose : (specifig for GeometryGUI_SpinBox)
784 //=================================================================================
785 void GeometryGUI_MultiRotationDlg::ValueChangedInSpinBox( double newValue )
787 GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender();
789 if( send == SpinBox_C2A3 ) {
792 else if( send == SpinBox_C2A5 ) {
796 switch (myConstructorId)
800 if (myOkBase && myOkDir ) {
801 MakeMultiRotationSimulationAndDisplay() ;
804 myGeomGUI->EraseSimulationShape() ;
805 mySimulationTopoDs.Nullify() ;
811 if (myOkBase && myOkDir ) {
812 MakeMultiRotationSimulationAndDisplay() ;
815 myGeomGUI->EraseSimulationShape() ;
816 mySimulationTopoDs.Nullify() ;
825 //=================================================================================
826 // function : DeactivateActiveDialog()
828 //=================================================================================
829 void GeometryGUI_MultiRotationDlg::DeactivateActiveDialog()
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) ;
847 //=================================================================================
848 // function : ActivateThisDialog()
850 //=================================================================================
851 void GeometryGUI_MultiRotationDlg::ActivateThisDialog()
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 ) ;
868 //=================================================================================
869 // function : enterEvent()
871 //=================================================================================
872 void GeometryGUI_MultiRotationDlg::enterEvent(QEvent* e)
874 if ( GroupConstructors->isEnabled() )
876 ActivateThisDialog() ;
882 //=================================================================================
883 // function : closeEvent()
885 //=================================================================================
886 void GeometryGUI_MultiRotationDlg::closeEvent( QCloseEvent* e )
888 this->ClickOnCancel() ; /* same than click on cancel button */
893 //=================================================================================
894 // function : MakeMultiRotationSimulationAndDisplay()
896 //=================================================================================
897 void GeometryGUI_MultiRotationDlg::MakeMultiRotationSimulationAndDisplay()
899 myGeomGUI->EraseSimulationShape() ;
900 gp_Trsf theTransformation ;
901 gp_Trsf theTransformation1 ;
902 gp_Trsf theTransformation2 ;
903 mySimulationTopoDs.Nullify() ;
910 GProp_GProps System ;
912 TopoDS_Compound compound;
915 B.MakeCompound( compound );
917 if ( myBase.ShapeType() == TopAbs_VERTEX) {
918 myGeomGUI->VertexToPoint( myBase, myPoint );
920 else if ( myBase.ShapeType() == TopAbs_EDGE || myBase.ShapeType() == TopAbs_WIRE ) {
921 BRepGProp::LinearProperties(myBase, System);
922 myPoint = System.CentreOfMass() ;
924 else if ( myBase.ShapeType() == TopAbs_FACE || myBase.ShapeType() == TopAbs_SHELL ) {
925 BRepGProp::SurfaceProperties(myBase, System);
926 myPoint = System.CentreOfMass() ;
929 BRepGProp::VolumeProperties(myBase, System);
930 myPoint = System.CentreOfMass() ;
933 TopoDS_Shape S = BRepBuilderAPI_MakeVertex(myPoint).Shape();
936 switch (myConstructorId)
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() );
947 mySimulationTopoDs = compound;
948 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
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() ) )
958 gp_Vec Vec(P2, myPoint) ;
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 ) ;
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() );
975 mySimulationTopoDs = compound ;
976 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
981 catch(Standard_Failure) {
982 MESSAGE( "Exception catched in MakeMultitranslationSimulationAndDisplay" ) ;