2 // File : GeometryGUI_MultiTranslationDlg.cxx
4 // Author : Damien COQUERET
6 // Module : GeometryGUI
7 // Copyright : OPEN CASCADE
10 #include "GeometryGUI_MultiTranslationDlg.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 <BRepBuilderAPI_Transform.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>
26 #include <qbuttongroup.h>
27 #include <qcheckbox.h>
28 #include <qgroupbox.h>
30 #include <qlineedit.h>
31 #include <qpushbutton.h>
32 #include <qradiobutton.h>
36 #include <qwhatsthis.h>
42 //=================================================================================
43 // class : GeometryGUI_MultiTranslationDlg()
44 // purpose : Constructs a GeometryGUI_MultiTranslationDlg which is a child of 'parent', with the
45 // name 'name' and widget flags set to 'f'.
46 // The dialog will by default be modeless, unless you set 'modal' to
47 // TRUE to construct a modal dialog.
48 //=================================================================================
49 GeometryGUI_MultiTranslationDlg::GeometryGUI_MultiTranslationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
50 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
52 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
53 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
54 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
57 setName( "GeometryGUI_MultiTranlationDlg" );
59 setCaption( tr( "GEOM_MULTITRANSLATION_TITLE" ) );
60 setSizeGripEnabled( TRUE );
61 GeometryGUI_MultiTranslationDlgLayout = new QGridLayout( this );
62 GeometryGUI_MultiTranslationDlgLayout->setSpacing( 6 );
63 GeometryGUI_MultiTranslationDlgLayout->setMargin( 11 );
65 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
66 GroupConstructors->setTitle( tr( "GEOM_MULTITRANSLATION" ) );
67 GroupConstructors->setExclusive( TRUE );
68 GroupConstructors->setColumnLayout(0, Qt::Vertical );
69 GroupConstructors->layout()->setSpacing( 0 );
70 GroupConstructors->layout()->setMargin( 0 );
71 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
72 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
73 GroupConstructorsLayout->setSpacing( 6 );
74 GroupConstructorsLayout->setMargin( 11 );
76 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
77 Constructor1->setText( tr( "" ) );
78 Constructor1->setPixmap( image0 );
79 Constructor1->setChecked( TRUE );
80 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
81 Constructor1->setMinimumSize( QSize( 50, 0 ) );
82 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
83 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
84 Constructor2->setText( tr( "" ) );
85 Constructor2->setPixmap( image2 );
86 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
87 Constructor2->setMinimumSize( QSize( 50, 0 ) );
88 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
89 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
90 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
91 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
92 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
94 GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupConstructors, 0, 0 );
96 /***************************************************************/
97 GroupButtons = new QGroupBox( this, "GroupButtons" );
98 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
99 GroupButtons->setTitle( tr( "" ) );
100 GroupButtons->setColumnLayout(0, Qt::Vertical );
101 GroupButtons->layout()->setSpacing( 0 );
102 GroupButtons->layout()->setMargin( 0 );
103 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
104 GroupButtonsLayout->setAlignment( Qt::AlignTop );
105 GroupButtonsLayout->setSpacing( 6 );
106 GroupButtonsLayout->setMargin( 11 );
107 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
108 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
109 buttonCancel->setAutoDefault( TRUE );
110 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
111 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
112 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
113 buttonApply->setAutoDefault( TRUE );
114 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
115 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
116 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
117 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
118 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
119 buttonOk->setAutoDefault( TRUE );
120 buttonOk->setDefault( TRUE );
121 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
122 GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupButtons, 2, 0 );
124 /***************************************************************/
125 GroupC1 = new QGroupBox( this, "GroupC1" );
126 GroupC1->setTitle( tr( "GEOM_MULTITRANSLATION_SIMPLE" ) );
127 GroupC1->setMinimumSize( QSize( 0, 0 ) );
128 GroupC1->setFrameShape( QGroupBox::Box );
129 GroupC1->setFrameShadow( QGroupBox::Sunken );
130 GroupC1->setColumnLayout(0, Qt::Vertical );
131 GroupC1->layout()->setSpacing( 0 );
132 GroupC1->layout()->setMargin( 0 );
133 GroupC1Layout = new QGridLayout( GroupC1->layout() );
134 GroupC1Layout->setAlignment( Qt::AlignTop );
135 GroupC1Layout->setSpacing( 6 );
136 GroupC1Layout->setMargin( 11 );
138 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
139 TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
140 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
141 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
142 TextLabelC1A1->setFrameShadow( QLabel::Plain );
143 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
145 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
146 TextLabelC1A2->setText( tr( "GEOM_VECTOR_U" ) );
147 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
148 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
149 TextLabelC1A2->setFrameShadow( QLabel::Plain );
150 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
152 TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
153 TextLabelC1A3->setText( tr( "GEOM_STEP_U" ) );
154 TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
155 TextLabelC1A3->setFrameShape( QLabel::NoFrame );
156 TextLabelC1A3->setFrameShadow( QLabel::Plain );
157 GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
159 TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
160 TextLabelC1A4->setText( tr( "GEOM_NB_TIMES_U" ) );
161 TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
162 TextLabelC1A4->setFrameShape( QLabel::NoFrame );
163 TextLabelC1A4->setFrameShadow( QLabel::Plain );
164 GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
166 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
167 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
169 LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
170 GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
172 /* a GeometryGUI_SpinBox */
173 SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
174 SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
175 GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 );
177 SpinBox_C1A4 = new QSpinBox( GroupC1, "SpinBox_C1A4" ) ;
178 SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) );
179 GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 );
181 CheckBoxReverse0 = new QCheckBox( GroupC1, "CheckBoxReverse0" );
182 CheckBoxReverse0->setText( tr( "GEOM_REVERSE_U" ) );
183 GroupC1Layout->addWidget( CheckBoxReverse0, 5, 0 );
185 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
186 SelectButtonC1A1->setText( tr( "" ) );
187 SelectButtonC1A1->setPixmap( image1 );
188 SelectButtonC1A1->setToggleButton( FALSE );
189 SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
190 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
192 SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
193 SelectButtonC1A2->setText( tr( "" ) );
194 SelectButtonC1A2->setPixmap( image1 );
195 SelectButtonC1A2->setToggleButton( FALSE );
196 SelectButtonC1A2->setMaximumSize( QSize( 28, 32767 ) );
197 GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
199 GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupC1, 1, 0 );
201 /***************************************************************/
203 GroupC2 = new QGroupBox( this, "GroupC2" );
204 GroupC2->setTitle( tr( "GEOM_MULTITRANSLATION_DOUBLE" ) );
205 GroupC2->setMinimumSize( QSize( 0, 0 ) );
206 GroupC2->setFrameShape( QGroupBox::Box );
207 GroupC2->setFrameShadow( QGroupBox::Sunken );
208 GroupC2->setColumnLayout(0, Qt::Vertical );
209 GroupC2->layout()->setSpacing( 0 );
210 GroupC2->layout()->setMargin( 0 );
211 GroupC2Layout = new QGridLayout( GroupC2->layout() );
212 GroupC2Layout->setAlignment( Qt::AlignTop );
213 GroupC2Layout->setSpacing( 6 );
214 GroupC2Layout->setMargin( 11 );
216 TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
217 TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
218 TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
219 TextLabelC2A1->setFrameShape( QLabel::NoFrame );
220 TextLabelC2A1->setFrameShadow( QLabel::Plain );
221 GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 );
223 TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" );
224 TextLabelC2A2->setText( tr( "GEOM_VECTOR_U" ) );
225 TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) );
226 TextLabelC2A2->setFrameShape( QLabel::NoFrame );
227 TextLabelC2A2->setFrameShadow( QLabel::Plain );
228 GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
230 TextLabelC2A3 = new QLabel( GroupC2, "TextLabelC2A3" );
231 TextLabelC2A3->setText( tr( "GEOM_VECTOR_V" ) );
232 TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) );
233 TextLabelC2A3->setFrameShape( QLabel::NoFrame );
234 TextLabelC2A3->setFrameShadow( QLabel::Plain );
235 GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 );
237 TextLabelC2A4 = new QLabel( GroupC2, "TextLabelC2A4" );
238 TextLabelC2A4->setText( tr( "GEOM_STEP_U" ) );
239 TextLabelC2A4->setMinimumSize( QSize( 50, 0 ) );
240 TextLabelC2A4->setFrameShape( QLabel::NoFrame );
241 TextLabelC2A4->setFrameShadow( QLabel::Plain );
242 GroupC2Layout->addWidget( TextLabelC2A4, 3, 0 );
244 TextLabelC2A5 = new QLabel( GroupC2, "TextLabelC2A5" );
245 TextLabelC2A5->setText( tr( "GEOM_NB_TIMES_U" ) );
246 TextLabelC2A5->setMinimumSize( QSize( 50, 0 ) );
247 TextLabelC2A5->setFrameShape( QLabel::NoFrame );
248 TextLabelC2A5->setFrameShadow( QLabel::Plain );
249 GroupC2Layout->addWidget( TextLabelC2A5, 4, 0 );
251 TextLabelC2A6 = new QLabel( GroupC2, "TextLabelC2A6" );
252 TextLabelC2A6->setText( tr( "GEOM_STEP_V" ) );
253 TextLabelC2A6->setMinimumSize( QSize( 50, 0 ) );
254 TextLabelC2A6->setFrameShape( QLabel::NoFrame );
255 TextLabelC2A6->setFrameShadow( QLabel::Plain );
256 GroupC2Layout->addWidget( TextLabelC2A6, 6, 0 );
258 TextLabelC2A7 = new QLabel( GroupC2, "TextLabelC2A7" );
259 TextLabelC2A7->setText( tr( "GEOM_NB_TIMES_V" ) );
260 TextLabelC2A7->setMinimumSize( QSize( 50, 0 ) );
261 TextLabelC2A7->setFrameShape( QLabel::NoFrame );
262 TextLabelC2A7->setFrameShadow( QLabel::Plain );
263 GroupC2Layout->addWidget( TextLabelC2A7, 7, 0 );
265 LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
266 GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
268 LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
269 GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
271 LineEditC2A3 = new QLineEdit( GroupC2, "LineEditC2A3" );
272 GroupC2Layout->addWidget( LineEditC2A3, 2, 2 );
274 /* a GeometryGUI_SpinBox */
275 SpinBox_C2A4 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A4" ) ;
276 SpinBox_C2A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A4->sizePolicy().hasHeightForWidth() ) );
277 GroupC2Layout->addWidget( SpinBox_C2A4, 3, 2 );
279 SpinBox_C2A5 = new QSpinBox( GroupC2, "SpinBox_C2A5" ) ;
280 SpinBox_C2A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A5->sizePolicy().hasHeightForWidth() ) );
281 GroupC2Layout->addWidget( SpinBox_C2A5, 4, 2 );
283 /* a GeometryGUI_SpinBox */
284 SpinBox_C2A6 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A6" ) ;
285 SpinBox_C2A6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A6->sizePolicy().hasHeightForWidth() ) );
286 GroupC2Layout->addWidget( SpinBox_C2A6, 6, 2 );
288 SpinBox_C2A7 = new QSpinBox( GroupC2, "SpinBox_C2A7" ) ;
289 SpinBox_C2A7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A7->sizePolicy().hasHeightForWidth() ) );
290 GroupC2Layout->addWidget( SpinBox_C2A7, 7, 2 );
293 CheckBoxReverse1 = new QCheckBox( GroupC2, "CheckBoxReverse1" );
294 CheckBoxReverse1->setText( tr( "GEOM_REVERSE_U" ) );
295 GroupC2Layout->addWidget( CheckBoxReverse1, 5, 0 );
297 CheckBoxReverse2 = new QCheckBox( GroupC2, "CheckBoxReverse2" );
298 CheckBoxReverse2->setText( tr( "GEOM_REVERSE_V" ) );
299 GroupC2Layout->addWidget( CheckBoxReverse2, 8, 0 );
301 SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
302 SelectButtonC2A1->setText( tr( "" ) );
303 SelectButtonC2A1->setPixmap( image1 );
304 SelectButtonC2A1->setToggleButton( FALSE );
305 SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
306 GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
308 SelectButtonC2A2 = new QPushButton( GroupC2, "SelectButtonC2A2" );
309 SelectButtonC2A2->setText( tr( "" ) );
310 SelectButtonC2A2->setPixmap( image1 );
311 SelectButtonC2A2->setToggleButton( FALSE );
312 SelectButtonC2A2->setMaximumSize( QSize( 28, 32767 ) );
313 GroupC2Layout->addWidget( SelectButtonC2A2, 1, 1 );
315 SelectButtonC2A3 = new QPushButton( GroupC2, "SelectButtonC2A3" );
316 SelectButtonC2A3->setText( tr( "" ) );
317 SelectButtonC2A3->setPixmap( image1 );
318 SelectButtonC2A3->setToggleButton( FALSE );
319 SelectButtonC2A3->setMaximumSize( QSize( 28, 32767 ) );
320 GroupC2Layout->addWidget( SelectButtonC2A3, 2, 1 );
322 GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupC2, 1, 0 );
324 /***************************************************************/
327 Init(Sel) ; /* Initialisations */
330 //=================================================================================
331 // function : ~GeometryGUI_MultiTranslationDlg()
332 // purpose : Destroys the object and frees any allocated resources
333 //=================================================================================
334 GeometryGUI_MultiTranslationDlg::~GeometryGUI_MultiTranslationDlg()
336 // no need to delete child widgets, Qt does it all for us
337 this->destroy(TRUE, TRUE) ;
340 //=================================================================================
343 //=================================================================================
344 void GeometryGUI_MultiTranslationDlg::Init( SALOME_Selection* Sel )
347 /* Get setting of step value from file configuration */
349 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
350 step = St.toDouble() ;
352 /* min, max, step and decimals for geom spin boxes */
353 SpinBox_C1A3->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step U : constructor 1 */
354 SpinBox_C1A3->SetValue( 50 ) ;
355 SpinBox_C2A4->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step U : constructor 2 */
356 SpinBox_C2A4->SetValue( 50 ) ;
357 SpinBox_C2A6->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step V : constructor 2 */
358 SpinBox_C2A6->SetValue( 50 ) ;
360 /* min, max, step for QT spin boxes */
361 SpinBox_C1A4->setMinValue( 1 ); /* myNbTimes1 : constructor 1 */
362 SpinBox_C1A4->setMaxValue( 10000 );
363 SpinBox_C1A4->setWrapping( TRUE );
364 SpinBox_C1A4->setValue(2) ;
366 SpinBox_C2A5->setMinValue( 1 ); /* myNbTimes1 : constructor 2 */
367 SpinBox_C2A5->setMaxValue( 10000 );
368 SpinBox_C2A5->setWrapping( TRUE );
369 SpinBox_C2A5->setValue(2) ;
371 SpinBox_C2A7->setMinValue( 1 ); /* myNbTimes2 : constructor 2 */
372 SpinBox_C2A7->setMaxValue( 10000 );
373 SpinBox_C2A7->setWrapping( TRUE );
374 SpinBox_C2A7->setValue(2) ;
383 myConstructorId = 0 ;
384 Constructor1->setChecked( TRUE );
385 myEditCurrentArgument = LineEditC1A1 ;
387 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
389 myOkBase = myOkDir1 = myOkDir2 = false ;
390 mySimulationTopoDs.Nullify() ;
392 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
394 // TODO : set previous selection into argument ?
396 /* Filter definitions */
397 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
398 myGeom = GEOM::GEOM_Gen::_narrow(comp);
399 myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
401 /* signals and slots connections */
402 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
403 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
404 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
406 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
407 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
408 connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
409 connect( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
410 connect( SelectButtonC2A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
411 connect( SelectButtonC2A3, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
413 /* GeometryGUI_SpinBox */
414 connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
415 connect( SpinBox_C2A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
416 connect( SpinBox_C2A6, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
418 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
419 connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
420 connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
421 connect( LineEditC2A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
422 connect( LineEditC2A3, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
425 connect( SpinBox_C1A4, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; /* Not const ! */
426 connect( SpinBox_C2A5, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
427 connect( SpinBox_C2A7, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
429 connect( CheckBoxReverse0, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle1(int) ) ) ;
430 connect( CheckBoxReverse1, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle1(int) ) ) ;
431 connect( CheckBoxReverse2, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle2(int) ) ) ;
433 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
434 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
435 /* to close dialog if study change */
436 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
438 /* Move widget on the botton right corner of main widget */
440 myGeomGUI->DefineDlgPosition( this, x, y ) ;
442 this->show() ; /* displays Dialog */
447 //=================================================================================
448 // function : ReverseAngle1()
449 // purpose : 'state' not used here
450 //=================================================================================
451 void GeometryGUI_MultiTranslationDlg::ReverseAngle1(int state)
454 SpinBox_C1A3->SetValue( myStep1 ) ;
455 SpinBox_C2A4->SetValue( myStep1 ) ;
456 if( myOkBase && myOkDir1 ) {
457 MakeMultiTranslationSimulationAndDisplay() ;
460 myGeomGUI->EraseSimulationShape() ;
461 mySimulationTopoDs.Nullify() ;
467 //=================================================================================
468 // function : ReverseAngle2()
469 // purpose : 'state' not used here
470 //=================================================================================
471 void GeometryGUI_MultiTranslationDlg::ReverseAngle2(int state)
474 SpinBox_C2A6->SetValue( myStep2 ) ;
475 if( myOkBase && myOkDir1 && myOkDir2 ) {
476 MakeMultiTranslationSimulationAndDisplay() ;
479 myGeomGUI->EraseSimulationShape() ;
480 mySimulationTopoDs.Nullify() ;
486 //=================================================================================
487 // function : ConstructorsClicked()
488 // purpose : Radio button management
489 //=================================================================================
490 void GeometryGUI_MultiTranslationDlg::ConstructorsClicked(int constructorId)
492 myEditCurrentArgument->setText(tr("")) ;
493 myGeomGUI->EraseSimulationShape() ;
494 mySimulationTopoDs.Nullify() ;
501 myOkBase = myOkDir1 = myOkDir2 = false ;
502 myConstructorId = constructorId ;
504 switch (constructorId)
506 case 0: /* Translate simple */
510 myEditCurrentArgument = LineEditC1A1 ;
511 SpinBox_C1A3->SetValue(50) ;
512 SpinBox_C1A4->setValue(2) ;
513 LineEditC1A1->setText(tr("")) ;
514 LineEditC1A2->setText(tr("")) ;
518 case 1: /* Translate double */
522 myEditCurrentArgument = LineEditC2A1 ;
523 SpinBox_C2A4->SetValue(50) ;
524 SpinBox_C2A5->setValue(2) ;
525 SpinBox_C2A6->SetValue(50) ;
526 SpinBox_C2A7->setValue(2) ;
527 LineEditC2A1->setText(tr("")) ;
528 LineEditC2A2->setText(tr("")) ;
529 LineEditC2A3->setText(tr("")) ;
538 //=================================================================================
539 // function : ClickOnOk()
541 //=================================================================================
542 void GeometryGUI_MultiTranslationDlg::ClickOnOk()
544 this->ClickOnApply() ;
545 this->ClickOnCancel() ;
550 //=================================================================================
551 // function : ClickOnApply()
553 //=================================================================================
554 void GeometryGUI_MultiTranslationDlg::ClickOnApply()
556 myGeomGUI->EraseSimulationShape() ;
557 mySimulationTopoDs.Nullify() ;
558 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
559 switch(myConstructorId)
563 if(myOkBase && myOkDir1 ) {
564 myGeomGUI->MakeMultiTranslation1DAndDisplay( myGeomShape, myDir1, myStep1, myNbTimes1 ) ;
570 if(myOkBase && myOkDir1 && myOkDir2 ) {
571 myGeomGUI->MakeMultiTranslation2DAndDisplay( myGeomShape, myDir1, myStep1, myNbTimes1, myDir2, myStep2, myNbTimes2 ) ;
580 //=================================================================================
581 // function : ClickOnCancel()
583 //=================================================================================
584 void GeometryGUI_MultiTranslationDlg::ClickOnCancel()
586 mySelection->ClearFilters() ;
587 myGeomGUI->EraseSimulationShape() ;
588 mySimulationTopoDs.Nullify() ;
589 disconnect( mySelection, 0, this, 0 );
590 myGeomGUI->ResetState() ;
596 //=================================================================================
597 // function : LineEditReturnPressed()
599 //=================================================================================
600 void GeometryGUI_MultiTranslationDlg::LineEditReturnPressed()
602 QLineEdit* send = (QLineEdit*)sender() ;
603 if( send == LineEditC1A1 )
604 myEditCurrentArgument = LineEditC1A1 ;
605 else if ( send == LineEditC1A2 )
606 myEditCurrentArgument = LineEditC1A2 ;
607 else if ( send == LineEditC2A1 )
608 myEditCurrentArgument = LineEditC2A1;
609 else if ( send == LineEditC2A2 )
610 myEditCurrentArgument = LineEditC2A2 ;
611 else if ( send == LineEditC2A3 )
612 myEditCurrentArgument = LineEditC2A3 ;
616 /* User name of object input management */
617 /* If successfull the selection is changed and signal emitted... */
618 /* so SelectionIntoArgument() is automatically called. */
619 const QString objectUserName = myEditCurrentArgument->text() ;
620 QWidget* thisWidget = (QWidget*)this ;
621 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
622 myEditCurrentArgument->setText( objectUserName ) ;
629 //=================================================================================
630 // function : SelectionIntoArgument()
631 // purpose : Called when selection as changed or other case
632 //=================================================================================
633 void GeometryGUI_MultiTranslationDlg::SelectionIntoArgument()
635 myEditCurrentArgument->setText("") ;
636 myGeomGUI->EraseSimulationShape() ;
637 mySimulationTopoDs.Nullify() ;
639 /* Future name of selection */
640 QString aString = "";
641 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
644 Standard_Boolean testResult ;
646 switch (myConstructorId)
651 if ( myEditCurrentArgument == LineEditC1A1 ) {
652 myEditCurrentArgument->setText("") ;
655 else if ( myEditCurrentArgument == LineEditC1A2 ) {
656 myEditCurrentArgument->setText("") ;
662 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
663 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
666 if ( myEditCurrentArgument == LineEditC1A1 ) {
667 myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
670 myEditCurrentArgument->setText(aString) ;
674 else if ( myEditCurrentArgument == LineEditC1A2 ) {
675 BRepAdaptor_Curve curv(TopoDS::Edge(S));
676 myDir1 = curv.Line().Direction();
677 myEditCurrentArgument->setText(aString) ;
681 if (myOkBase && myOkDir1 ) {
682 MakeMultiTranslationSimulationAndDisplay() ;
685 myGeomGUI->EraseSimulationShape() ;
686 mySimulationTopoDs.Nullify() ;
693 if ( myEditCurrentArgument == LineEditC2A1 ) {
694 myEditCurrentArgument->setText("") ;
697 else if ( myEditCurrentArgument == LineEditC2A2 ) {
698 myEditCurrentArgument->setText("") ;
701 else if ( myEditCurrentArgument == LineEditC2A3 ) {
702 myEditCurrentArgument->setText("") ;
708 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
709 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
712 if ( myEditCurrentArgument == LineEditC2A1 ) {
713 myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
716 myEditCurrentArgument->setText(aString) ;
720 else if ( myEditCurrentArgument == LineEditC2A2 ) {
721 BRepAdaptor_Curve curv(TopoDS::Edge(S));
722 myDir1 = curv.Line().Direction();
723 myEditCurrentArgument->setText(aString) ;
726 else if ( myEditCurrentArgument == LineEditC2A3 ) {
727 BRepAdaptor_Curve curv(TopoDS::Edge(S));
728 myDir2 = curv.Line().Direction();
729 myEditCurrentArgument->setText(aString) ;
733 if (myOkBase && myOkDir1 && myOkDir2 ) {
734 MakeMultiTranslationSimulationAndDisplay() ;
737 myGeomGUI->EraseSimulationShape() ;
738 mySimulationTopoDs.Nullify() ;
748 //=================================================================================
749 // function : SetEditCurrentArgument()
751 //=================================================================================
752 void GeometryGUI_MultiTranslationDlg::SetEditCurrentArgument()
754 QPushButton* send = (QPushButton*)sender();
755 switch (myConstructorId)
759 if(send == SelectButtonC1A1) {
760 LineEditC1A1->setFocus() ;
761 myEditCurrentArgument = LineEditC1A1;
762 mySelection->ClearFilters() ;
764 else if(send == SelectButtonC1A2) {
765 LineEditC1A2->setFocus() ;
766 myEditCurrentArgument = LineEditC1A2;
767 mySelection->AddFilter(myEdgeFilter) ;
769 SelectionIntoArgument() ;
774 if(send == SelectButtonC2A1) {
775 LineEditC2A1->setFocus() ;
776 myEditCurrentArgument = LineEditC2A1;
777 mySelection->ClearFilters() ;
779 else if(send == SelectButtonC2A2) {
780 LineEditC2A2->setFocus() ;
781 myEditCurrentArgument = LineEditC2A2;
782 mySelection->AddFilter(myEdgeFilter) ;
784 else if(send == SelectButtonC2A3) {
785 LineEditC2A3->setFocus() ;
786 myEditCurrentArgument = LineEditC2A3;
787 mySelection->AddFilter(myEdgeFilter) ;
789 SelectionIntoArgument() ;
797 //=================================================================================
798 // function : ValueChangedInt()
799 // purpose : (General QT SpinBox)
800 //=================================================================================
801 void GeometryGUI_MultiTranslationDlg::ValueChangedInt( int newIntValue )
803 QSpinBox* send = (QSpinBox*)sender();
805 /* First constructor */
806 if( send == SpinBox_C1A4 ) {
807 myNbTimes1 = newIntValue ;
809 /* Second constructor */
810 else if( send == SpinBox_C2A5 ) {
811 myNbTimes1 = newIntValue ;
813 else if( send == SpinBox_C2A7 ) {
814 myNbTimes2 = newIntValue ;
817 switch (myConstructorId)
821 if (myOkBase && myOkDir1 ) {
822 MakeMultiTranslationSimulationAndDisplay() ;
825 myGeomGUI->EraseSimulationShape() ;
826 mySimulationTopoDs.Nullify() ;
832 if (myOkBase && myOkDir1 && myOkDir2 ) {
833 MakeMultiTranslationSimulationAndDisplay() ;
836 myGeomGUI->EraseSimulationShape() ;
837 mySimulationTopoDs.Nullify() ;
846 //=================================================================================
847 // function : ValueChangedInSpinBox()
848 // purpose : (specifig for GeometryGUI_SpinBox)
849 //=================================================================================
850 void GeometryGUI_MultiTranslationDlg::ValueChangedInSpinBox( double newValue )
852 GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender();
854 /* First constructor */
855 if( send == SpinBox_C1A3 ) {
858 /* Second constructor */
859 else if( send == SpinBox_C2A4 ) {
862 else if( send == SpinBox_C2A6 ) {
866 switch (myConstructorId)
870 if (myOkBase && myOkDir1 ) {
871 MakeMultiTranslationSimulationAndDisplay() ;
874 myGeomGUI->EraseSimulationShape() ;
875 mySimulationTopoDs.Nullify() ;
881 if (myOkBase && myOkDir1 && myOkDir2 ) {
882 MakeMultiTranslationSimulationAndDisplay() ;
885 myGeomGUI->EraseSimulationShape() ;
886 mySimulationTopoDs.Nullify() ;
895 //=================================================================================
896 // function : DeactivateActiveDialog()
898 //=================================================================================
899 void GeometryGUI_MultiTranslationDlg::DeactivateActiveDialog()
901 if ( GroupConstructors->isEnabled() ) {
902 GroupConstructors->setEnabled(false) ;
903 GroupC1->setEnabled(false) ;
904 GroupC2->setEnabled(false) ;
905 GroupButtons->setEnabled(false) ;
906 disconnect( mySelection, 0, this, 0 );
907 myGeomGUI->EraseSimulationShape() ;
908 mySelection->ClearFilters() ;
909 myGeomGUI->ResetState() ;
910 myGeomGUI->SetActiveDialogBox(0) ;
911 myGeomGUI->OnDisplayAll(true) ;
917 //=================================================================================
918 // function : ActivateThisDialog()
920 //=================================================================================
921 void GeometryGUI_MultiTranslationDlg::ActivateThisDialog()
923 /* Emit a signal to deactivate the active dialog */
924 myGeomGUI->EmitSignalDeactivateDialog() ;
925 GroupConstructors->setEnabled(true) ;
926 GroupC1->setEnabled(true) ;
927 GroupC2->setEnabled(true) ;
928 GroupButtons->setEnabled(true) ;
929 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
930 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
931 if( !mySimulationTopoDs.IsNull() )
932 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
938 //=================================================================================
939 // function : enterEvent()
941 //=================================================================================
942 void GeometryGUI_MultiTranslationDlg::enterEvent(QEvent* e)
944 if ( GroupConstructors->isEnabled() )
946 ActivateThisDialog() ;
952 //=================================================================================
953 // function : closeEvent()
955 //=================================================================================
956 void GeometryGUI_MultiTranslationDlg::closeEvent( QCloseEvent* e )
958 this->ClickOnCancel() ; /* same than click on cancel button */
963 //=================================================================================
964 // function : MakeMultiTranslationSimulationAndDisplay()
966 //=================================================================================
967 void GeometryGUI_MultiTranslationDlg::MakeMultiTranslationSimulationAndDisplay()
969 myGeomGUI->EraseSimulationShape() ;
970 gp_Trsf theTransformation ;
971 mySimulationTopoDs.Nullify() ;
978 GProp_GProps System ;
980 TopoDS_Compound compound;
983 B.MakeCompound( compound );
988 BRepGProp::LinearProperties(myBase, System);
989 myPoint = System.CentreOfMass() ;
990 S = BRepBuilderAPI_MakeVertex(myPoint).Shape();
992 switch (myConstructorId)
999 for ( i = 0; i < myNbTimes1; i++ ) {
1000 DX = i * myStep1 * Vec.X() ;
1001 DY = i * myStep1 * Vec.Y() ;
1002 DZ = i * myStep1 * Vec.Z() ;
1003 myVec.SetCoord( DX, DY, DZ ) ;
1005 theTransformation.SetTranslation(myVec) ;
1006 BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ;
1007 B.Add( compound, myBRepTransformation.Shape() );
1009 mySimulationTopoDs = compound;
1010 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
1015 gp_Vec Vec1(myDir1) ;
1017 gp_Vec Vec2(myDir2) ;
1020 for ( i = 0; i < myNbTimes1; i++ ) {
1021 for ( j = 0; j < myNbTimes2; j++ ) {
1022 DX = i * myStep1 * Vec1.X() + j * myStep2 * Vec2.X() ;
1023 DY = i * myStep1 * Vec1.Y() + j * myStep2 * Vec2.Y() ;
1024 DZ = i * myStep1 * Vec1.Z() + j * myStep2 * Vec2.Z() ;
1025 myVec.SetCoord( DX, DY, DZ ) ;
1027 theTransformation.SetTranslation(myVec) ;
1028 BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ;
1029 B.Add( compound, myBRepTransformation.Shape() );
1032 mySimulationTopoDs = compound ;
1033 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
1038 catch(Standard_Failure) {
1039 MESSAGE( "Exception catched in MakeMultitranslationSimulationAndDisplay" ) ;