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_MultiTranslationDlg.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 <BRepBuilderAPI_Transform.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>
46 #include <qbuttongroup.h>
47 #include <qcheckbox.h>
48 #include <qgroupbox.h>
50 #include <qlineedit.h>
51 #include <qpushbutton.h>
52 #include <qradiobutton.h>
56 #include <qwhatsthis.h>
62 //=================================================================================
63 // class : GeometryGUI_MultiTranslationDlg()
64 // purpose : Constructs a GeometryGUI_MultiTranslationDlg which is a child of 'parent', with the
65 // name 'name' and widget flags set to 'f'.
66 // The dialog will by default be modeless, unless you set 'modal' to
67 // TRUE to construct a modal dialog.
68 //=================================================================================
69 GeometryGUI_MultiTranslationDlg::GeometryGUI_MultiTranslationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
70 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
72 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
73 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
74 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
77 setName( "GeometryGUI_MultiTranlationDlg" );
79 setCaption( tr( "GEOM_MULTITRANSLATION_TITLE" ) );
80 setSizeGripEnabled( TRUE );
81 GeometryGUI_MultiTranslationDlgLayout = new QGridLayout( this );
82 GeometryGUI_MultiTranslationDlgLayout->setSpacing( 6 );
83 GeometryGUI_MultiTranslationDlgLayout->setMargin( 11 );
85 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
86 GroupConstructors->setTitle( tr( "GEOM_MULTITRANSLATION" ) );
87 GroupConstructors->setExclusive( TRUE );
88 GroupConstructors->setColumnLayout(0, Qt::Vertical );
89 GroupConstructors->layout()->setSpacing( 0 );
90 GroupConstructors->layout()->setMargin( 0 );
91 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
92 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
93 GroupConstructorsLayout->setSpacing( 6 );
94 GroupConstructorsLayout->setMargin( 11 );
96 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
97 Constructor1->setText( tr( "" ) );
98 Constructor1->setPixmap( image0 );
99 Constructor1->setChecked( TRUE );
100 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
101 Constructor1->setMinimumSize( QSize( 50, 0 ) );
102 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
103 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
104 Constructor2->setText( tr( "" ) );
105 Constructor2->setPixmap( image2 );
106 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
107 Constructor2->setMinimumSize( QSize( 50, 0 ) );
108 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
109 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
110 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
111 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
112 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
114 GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupConstructors, 0, 0 );
116 /***************************************************************/
117 GroupButtons = new QGroupBox( this, "GroupButtons" );
118 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
119 GroupButtons->setTitle( tr( "" ) );
120 GroupButtons->setColumnLayout(0, Qt::Vertical );
121 GroupButtons->layout()->setSpacing( 0 );
122 GroupButtons->layout()->setMargin( 0 );
123 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
124 GroupButtonsLayout->setAlignment( Qt::AlignTop );
125 GroupButtonsLayout->setSpacing( 6 );
126 GroupButtonsLayout->setMargin( 11 );
127 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
128 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
129 buttonCancel->setAutoDefault( TRUE );
130 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
131 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
132 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
133 buttonApply->setAutoDefault( TRUE );
134 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
135 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
136 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
137 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
138 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
139 buttonOk->setAutoDefault( TRUE );
140 buttonOk->setDefault( TRUE );
141 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
142 GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupButtons, 2, 0 );
144 /***************************************************************/
145 GroupC1 = new QGroupBox( this, "GroupC1" );
146 GroupC1->setTitle( tr( "GEOM_MULTITRANSLATION_SIMPLE" ) );
147 GroupC1->setMinimumSize( QSize( 0, 0 ) );
148 GroupC1->setFrameShape( QGroupBox::Box );
149 GroupC1->setFrameShadow( QGroupBox::Sunken );
150 GroupC1->setColumnLayout(0, Qt::Vertical );
151 GroupC1->layout()->setSpacing( 0 );
152 GroupC1->layout()->setMargin( 0 );
153 GroupC1Layout = new QGridLayout( GroupC1->layout() );
154 GroupC1Layout->setAlignment( Qt::AlignTop );
155 GroupC1Layout->setSpacing( 6 );
156 GroupC1Layout->setMargin( 11 );
158 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
159 TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
160 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
161 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
162 TextLabelC1A1->setFrameShadow( QLabel::Plain );
163 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
165 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
166 TextLabelC1A2->setText( tr( "GEOM_VECTOR_U" ) );
167 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
168 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
169 TextLabelC1A2->setFrameShadow( QLabel::Plain );
170 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
172 TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
173 TextLabelC1A3->setText( tr( "GEOM_STEP_U" ) );
174 TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
175 TextLabelC1A3->setFrameShape( QLabel::NoFrame );
176 TextLabelC1A3->setFrameShadow( QLabel::Plain );
177 GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
179 TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
180 TextLabelC1A4->setText( tr( "GEOM_NB_TIMES_U" ) );
181 TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
182 TextLabelC1A4->setFrameShape( QLabel::NoFrame );
183 TextLabelC1A4->setFrameShadow( QLabel::Plain );
184 GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
186 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
187 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
189 LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
190 GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
192 /* a GeometryGUI_SpinBox */
193 SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
194 SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
195 GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 );
197 SpinBox_C1A4 = new QSpinBox( GroupC1, "SpinBox_C1A4" ) ;
198 SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) );
199 GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 );
201 CheckBoxReverse0 = new QCheckBox( GroupC1, "CheckBoxReverse0" );
202 CheckBoxReverse0->setText( tr( "GEOM_REVERSE_U" ) );
203 GroupC1Layout->addWidget( CheckBoxReverse0, 5, 0 );
205 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
206 SelectButtonC1A1->setText( tr( "" ) );
207 SelectButtonC1A1->setPixmap( image1 );
208 SelectButtonC1A1->setToggleButton( FALSE );
209 SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
210 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
212 SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
213 SelectButtonC1A2->setText( tr( "" ) );
214 SelectButtonC1A2->setPixmap( image1 );
215 SelectButtonC1A2->setToggleButton( FALSE );
216 SelectButtonC1A2->setMaximumSize( QSize( 28, 32767 ) );
217 GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
219 GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupC1, 1, 0 );
221 /***************************************************************/
223 GroupC2 = new QGroupBox( this, "GroupC2" );
224 GroupC2->setTitle( tr( "GEOM_MULTITRANSLATION_DOUBLE" ) );
225 GroupC2->setMinimumSize( QSize( 0, 0 ) );
226 GroupC2->setFrameShape( QGroupBox::Box );
227 GroupC2->setFrameShadow( QGroupBox::Sunken );
228 GroupC2->setColumnLayout(0, Qt::Vertical );
229 GroupC2->layout()->setSpacing( 0 );
230 GroupC2->layout()->setMargin( 0 );
231 GroupC2Layout = new QGridLayout( GroupC2->layout() );
232 GroupC2Layout->setAlignment( Qt::AlignTop );
233 GroupC2Layout->setSpacing( 6 );
234 GroupC2Layout->setMargin( 11 );
236 TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
237 TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
238 TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
239 TextLabelC2A1->setFrameShape( QLabel::NoFrame );
240 TextLabelC2A1->setFrameShadow( QLabel::Plain );
241 GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 );
243 TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" );
244 TextLabelC2A2->setText( tr( "GEOM_VECTOR_U" ) );
245 TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) );
246 TextLabelC2A2->setFrameShape( QLabel::NoFrame );
247 TextLabelC2A2->setFrameShadow( QLabel::Plain );
248 GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
250 TextLabelC2A3 = new QLabel( GroupC2, "TextLabelC2A3" );
251 TextLabelC2A3->setText( tr( "GEOM_VECTOR_V" ) );
252 TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) );
253 TextLabelC2A3->setFrameShape( QLabel::NoFrame );
254 TextLabelC2A3->setFrameShadow( QLabel::Plain );
255 GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 );
257 TextLabelC2A4 = new QLabel( GroupC2, "TextLabelC2A4" );
258 TextLabelC2A4->setText( tr( "GEOM_STEP_U" ) );
259 TextLabelC2A4->setMinimumSize( QSize( 50, 0 ) );
260 TextLabelC2A4->setFrameShape( QLabel::NoFrame );
261 TextLabelC2A4->setFrameShadow( QLabel::Plain );
262 GroupC2Layout->addWidget( TextLabelC2A4, 3, 0 );
264 TextLabelC2A5 = new QLabel( GroupC2, "TextLabelC2A5" );
265 TextLabelC2A5->setText( tr( "GEOM_NB_TIMES_U" ) );
266 TextLabelC2A5->setMinimumSize( QSize( 50, 0 ) );
267 TextLabelC2A5->setFrameShape( QLabel::NoFrame );
268 TextLabelC2A5->setFrameShadow( QLabel::Plain );
269 GroupC2Layout->addWidget( TextLabelC2A5, 4, 0 );
271 TextLabelC2A6 = new QLabel( GroupC2, "TextLabelC2A6" );
272 TextLabelC2A6->setText( tr( "GEOM_STEP_V" ) );
273 TextLabelC2A6->setMinimumSize( QSize( 50, 0 ) );
274 TextLabelC2A6->setFrameShape( QLabel::NoFrame );
275 TextLabelC2A6->setFrameShadow( QLabel::Plain );
276 GroupC2Layout->addWidget( TextLabelC2A6, 6, 0 );
278 TextLabelC2A7 = new QLabel( GroupC2, "TextLabelC2A7" );
279 TextLabelC2A7->setText( tr( "GEOM_NB_TIMES_V" ) );
280 TextLabelC2A7->setMinimumSize( QSize( 50, 0 ) );
281 TextLabelC2A7->setFrameShape( QLabel::NoFrame );
282 TextLabelC2A7->setFrameShadow( QLabel::Plain );
283 GroupC2Layout->addWidget( TextLabelC2A7, 7, 0 );
285 LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
286 GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
288 LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
289 GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
291 LineEditC2A3 = new QLineEdit( GroupC2, "LineEditC2A3" );
292 GroupC2Layout->addWidget( LineEditC2A3, 2, 2 );
294 /* a GeometryGUI_SpinBox */
295 SpinBox_C2A4 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A4" ) ;
296 SpinBox_C2A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A4->sizePolicy().hasHeightForWidth() ) );
297 GroupC2Layout->addWidget( SpinBox_C2A4, 3, 2 );
299 SpinBox_C2A5 = new QSpinBox( GroupC2, "SpinBox_C2A5" ) ;
300 SpinBox_C2A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A5->sizePolicy().hasHeightForWidth() ) );
301 GroupC2Layout->addWidget( SpinBox_C2A5, 4, 2 );
303 /* a GeometryGUI_SpinBox */
304 SpinBox_C2A6 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A6" ) ;
305 SpinBox_C2A6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A6->sizePolicy().hasHeightForWidth() ) );
306 GroupC2Layout->addWidget( SpinBox_C2A6, 6, 2 );
308 SpinBox_C2A7 = new QSpinBox( GroupC2, "SpinBox_C2A7" ) ;
309 SpinBox_C2A7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A7->sizePolicy().hasHeightForWidth() ) );
310 GroupC2Layout->addWidget( SpinBox_C2A7, 7, 2 );
313 CheckBoxReverse1 = new QCheckBox( GroupC2, "CheckBoxReverse1" );
314 CheckBoxReverse1->setText( tr( "GEOM_REVERSE_U" ) );
315 GroupC2Layout->addWidget( CheckBoxReverse1, 5, 0 );
317 CheckBoxReverse2 = new QCheckBox( GroupC2, "CheckBoxReverse2" );
318 CheckBoxReverse2->setText( tr( "GEOM_REVERSE_V" ) );
319 GroupC2Layout->addWidget( CheckBoxReverse2, 8, 0 );
321 SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
322 SelectButtonC2A1->setText( tr( "" ) );
323 SelectButtonC2A1->setPixmap( image1 );
324 SelectButtonC2A1->setToggleButton( FALSE );
325 SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
326 GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
328 SelectButtonC2A2 = new QPushButton( GroupC2, "SelectButtonC2A2" );
329 SelectButtonC2A2->setText( tr( "" ) );
330 SelectButtonC2A2->setPixmap( image1 );
331 SelectButtonC2A2->setToggleButton( FALSE );
332 SelectButtonC2A2->setMaximumSize( QSize( 28, 32767 ) );
333 GroupC2Layout->addWidget( SelectButtonC2A2, 1, 1 );
335 SelectButtonC2A3 = new QPushButton( GroupC2, "SelectButtonC2A3" );
336 SelectButtonC2A3->setText( tr( "" ) );
337 SelectButtonC2A3->setPixmap( image1 );
338 SelectButtonC2A3->setToggleButton( FALSE );
339 SelectButtonC2A3->setMaximumSize( QSize( 28, 32767 ) );
340 GroupC2Layout->addWidget( SelectButtonC2A3, 2, 1 );
342 GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupC2, 1, 0 );
344 /***************************************************************/
347 Init(Sel) ; /* Initialisations */
350 //=================================================================================
351 // function : ~GeometryGUI_MultiTranslationDlg()
352 // purpose : Destroys the object and frees any allocated resources
353 //=================================================================================
354 GeometryGUI_MultiTranslationDlg::~GeometryGUI_MultiTranslationDlg()
356 // no need to delete child widgets, Qt does it all for us
357 this->destroy(TRUE, TRUE) ;
360 //=================================================================================
363 //=================================================================================
364 void GeometryGUI_MultiTranslationDlg::Init( SALOME_Selection* Sel )
367 /* Get setting of step value from file configuration */
369 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
370 step = St.toDouble() ;
372 /* min, max, step and decimals for geom spin boxes */
373 SpinBox_C1A3->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step U : constructor 1 */
374 SpinBox_C1A3->SetValue( 50 ) ;
375 SpinBox_C2A4->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step U : constructor 2 */
376 SpinBox_C2A4->SetValue( 50 ) ;
377 SpinBox_C2A6->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step V : constructor 2 */
378 SpinBox_C2A6->SetValue( 50 ) ;
380 /* min, max, step for QT spin boxes */
381 SpinBox_C1A4->setMinValue( 1 ); /* myNbTimes1 : constructor 1 */
382 SpinBox_C1A4->setMaxValue( 10000 );
383 SpinBox_C1A4->setWrapping( TRUE );
384 SpinBox_C1A4->setValue(2) ;
386 SpinBox_C2A5->setMinValue( 1 ); /* myNbTimes1 : constructor 2 */
387 SpinBox_C2A5->setMaxValue( 10000 );
388 SpinBox_C2A5->setWrapping( TRUE );
389 SpinBox_C2A5->setValue(2) ;
391 SpinBox_C2A7->setMinValue( 1 ); /* myNbTimes2 : constructor 2 */
392 SpinBox_C2A7->setMaxValue( 10000 );
393 SpinBox_C2A7->setWrapping( TRUE );
394 SpinBox_C2A7->setValue(2) ;
403 myConstructorId = 0 ;
404 Constructor1->setChecked( TRUE );
405 myEditCurrentArgument = LineEditC1A1 ;
407 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
409 myOkBase = myOkDir1 = myOkDir2 = false ;
410 mySimulationTopoDs.Nullify() ;
412 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
414 // TODO : set previous selection into argument ?
416 /* Filter definitions */
417 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
418 myGeom = GEOM::GEOM_Gen::_narrow(comp);
419 myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
421 /* signals and slots connections */
422 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
423 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
424 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
426 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
427 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
428 connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
429 connect( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
430 connect( SelectButtonC2A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
431 connect( SelectButtonC2A3, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
433 /* GeometryGUI_SpinBox */
434 connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
435 connect( SpinBox_C2A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
436 connect( SpinBox_C2A6, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
438 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
439 connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
440 connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
441 connect( LineEditC2A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
442 connect( LineEditC2A3, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
445 connect( SpinBox_C1A4, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; /* Not const ! */
446 connect( SpinBox_C2A5, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
447 connect( SpinBox_C2A7, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
449 connect( CheckBoxReverse0, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle1(int) ) ) ;
450 connect( CheckBoxReverse1, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle1(int) ) ) ;
451 connect( CheckBoxReverse2, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle2(int) ) ) ;
453 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
454 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
455 /* to close dialog if study change */
456 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
458 /* Move widget on the botton right corner of main widget */
460 myGeomGUI->DefineDlgPosition( this, x, y ) ;
462 this->show() ; /* displays Dialog */
467 //=================================================================================
468 // function : ReverseAngle1()
469 // purpose : 'state' not used here
470 //=================================================================================
471 void GeometryGUI_MultiTranslationDlg::ReverseAngle1(int state)
474 SpinBox_C1A3->SetValue( myStep1 ) ;
475 SpinBox_C2A4->SetValue( myStep1 ) ;
476 if( myOkBase && myOkDir1 ) {
477 MakeMultiTranslationSimulationAndDisplay() ;
480 myGeomGUI->EraseSimulationShape() ;
481 mySimulationTopoDs.Nullify() ;
487 //=================================================================================
488 // function : ReverseAngle2()
489 // purpose : 'state' not used here
490 //=================================================================================
491 void GeometryGUI_MultiTranslationDlg::ReverseAngle2(int state)
494 SpinBox_C2A6->SetValue( myStep2 ) ;
495 if( myOkBase && myOkDir1 && myOkDir2 ) {
496 MakeMultiTranslationSimulationAndDisplay() ;
499 myGeomGUI->EraseSimulationShape() ;
500 mySimulationTopoDs.Nullify() ;
506 //=================================================================================
507 // function : ConstructorsClicked()
508 // purpose : Radio button management
509 //=================================================================================
510 void GeometryGUI_MultiTranslationDlg::ConstructorsClicked(int constructorId)
512 myEditCurrentArgument->setText(tr("")) ;
513 myGeomGUI->EraseSimulationShape() ;
514 mySimulationTopoDs.Nullify() ;
521 myOkBase = myOkDir1 = myOkDir2 = false ;
522 myConstructorId = constructorId ;
524 switch (constructorId)
526 case 0: /* Translate simple */
530 myEditCurrentArgument = LineEditC1A1 ;
531 SpinBox_C1A3->SetValue(50) ;
532 SpinBox_C1A4->setValue(2) ;
533 LineEditC1A1->setText(tr("")) ;
534 LineEditC1A2->setText(tr("")) ;
538 case 1: /* Translate double */
542 myEditCurrentArgument = LineEditC2A1 ;
543 SpinBox_C2A4->SetValue(50) ;
544 SpinBox_C2A5->setValue(2) ;
545 SpinBox_C2A6->SetValue(50) ;
546 SpinBox_C2A7->setValue(2) ;
547 LineEditC2A1->setText(tr("")) ;
548 LineEditC2A2->setText(tr("")) ;
549 LineEditC2A3->setText(tr("")) ;
558 //=================================================================================
559 // function : ClickOnOk()
561 //=================================================================================
562 void GeometryGUI_MultiTranslationDlg::ClickOnOk()
564 this->ClickOnApply() ;
565 this->ClickOnCancel() ;
570 //=================================================================================
571 // function : ClickOnApply()
573 //=================================================================================
574 void GeometryGUI_MultiTranslationDlg::ClickOnApply()
576 myGeomGUI->EraseSimulationShape() ;
577 mySimulationTopoDs.Nullify() ;
578 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
579 switch(myConstructorId)
583 if(myOkBase && myOkDir1 ) {
584 myGeomGUI->MakeMultiTranslation1DAndDisplay( myGeomShape, myDir1, myStep1, myNbTimes1 ) ;
590 if(myOkBase && myOkDir1 && myOkDir2 ) {
591 myGeomGUI->MakeMultiTranslation2DAndDisplay( myGeomShape, myDir1, myStep1, myNbTimes1, myDir2, myStep2, myNbTimes2 ) ;
600 //=================================================================================
601 // function : ClickOnCancel()
603 //=================================================================================
604 void GeometryGUI_MultiTranslationDlg::ClickOnCancel()
606 mySelection->ClearFilters() ;
607 myGeomGUI->EraseSimulationShape() ;
608 mySimulationTopoDs.Nullify() ;
609 disconnect( mySelection, 0, this, 0 );
610 myGeomGUI->ResetState() ;
616 //=================================================================================
617 // function : LineEditReturnPressed()
619 //=================================================================================
620 void GeometryGUI_MultiTranslationDlg::LineEditReturnPressed()
622 QLineEdit* send = (QLineEdit*)sender() ;
623 if( send == LineEditC1A1 )
624 myEditCurrentArgument = LineEditC1A1 ;
625 else if ( send == LineEditC1A2 )
626 myEditCurrentArgument = LineEditC1A2 ;
627 else if ( send == LineEditC2A1 )
628 myEditCurrentArgument = LineEditC2A1;
629 else if ( send == LineEditC2A2 )
630 myEditCurrentArgument = LineEditC2A2 ;
631 else if ( send == LineEditC2A3 )
632 myEditCurrentArgument = LineEditC2A3 ;
636 /* User name of object input management */
637 /* If successfull the selection is changed and signal emitted... */
638 /* so SelectionIntoArgument() is automatically called. */
639 const QString objectUserName = myEditCurrentArgument->text() ;
640 QWidget* thisWidget = (QWidget*)this ;
641 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
642 myEditCurrentArgument->setText( objectUserName ) ;
649 //=================================================================================
650 // function : SelectionIntoArgument()
651 // purpose : Called when selection as changed or other case
652 //=================================================================================
653 void GeometryGUI_MultiTranslationDlg::SelectionIntoArgument()
655 myEditCurrentArgument->setText("") ;
656 myGeomGUI->EraseSimulationShape() ;
657 mySimulationTopoDs.Nullify() ;
659 /* Future name of selection */
660 QString aString = "";
661 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
664 Standard_Boolean testResult ;
666 switch (myConstructorId)
671 if ( myEditCurrentArgument == LineEditC1A1 ) {
672 myEditCurrentArgument->setText("") ;
675 else if ( myEditCurrentArgument == LineEditC1A2 ) {
676 myEditCurrentArgument->setText("") ;
682 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
683 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
686 if ( myEditCurrentArgument == LineEditC1A1 ) {
687 myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
690 myEditCurrentArgument->setText(aString) ;
694 else if ( myEditCurrentArgument == LineEditC1A2 ) {
695 BRepAdaptor_Curve curv(TopoDS::Edge(S));
696 myDir1 = curv.Line().Direction();
697 myEditCurrentArgument->setText(aString) ;
701 if (myOkBase && myOkDir1 ) {
702 MakeMultiTranslationSimulationAndDisplay() ;
705 myGeomGUI->EraseSimulationShape() ;
706 mySimulationTopoDs.Nullify() ;
713 if ( myEditCurrentArgument == LineEditC2A1 ) {
714 myEditCurrentArgument->setText("") ;
717 else if ( myEditCurrentArgument == LineEditC2A2 ) {
718 myEditCurrentArgument->setText("") ;
721 else if ( myEditCurrentArgument == LineEditC2A3 ) {
722 myEditCurrentArgument->setText("") ;
728 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
729 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
732 if ( myEditCurrentArgument == LineEditC2A1 ) {
733 myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
736 myEditCurrentArgument->setText(aString) ;
740 else if ( myEditCurrentArgument == LineEditC2A2 ) {
741 BRepAdaptor_Curve curv(TopoDS::Edge(S));
742 myDir1 = curv.Line().Direction();
743 myEditCurrentArgument->setText(aString) ;
746 else if ( myEditCurrentArgument == LineEditC2A3 ) {
747 BRepAdaptor_Curve curv(TopoDS::Edge(S));
748 myDir2 = curv.Line().Direction();
749 myEditCurrentArgument->setText(aString) ;
753 if (myOkBase && myOkDir1 && myOkDir2 ) {
754 MakeMultiTranslationSimulationAndDisplay() ;
757 myGeomGUI->EraseSimulationShape() ;
758 mySimulationTopoDs.Nullify() ;
768 //=================================================================================
769 // function : SetEditCurrentArgument()
771 //=================================================================================
772 void GeometryGUI_MultiTranslationDlg::SetEditCurrentArgument()
774 QPushButton* send = (QPushButton*)sender();
775 switch (myConstructorId)
779 if(send == SelectButtonC1A1) {
780 LineEditC1A1->setFocus() ;
781 myEditCurrentArgument = LineEditC1A1;
782 mySelection->ClearFilters() ;
784 else if(send == SelectButtonC1A2) {
785 LineEditC1A2->setFocus() ;
786 myEditCurrentArgument = LineEditC1A2;
787 mySelection->AddFilter(myEdgeFilter) ;
789 SelectionIntoArgument() ;
794 if(send == SelectButtonC2A1) {
795 LineEditC2A1->setFocus() ;
796 myEditCurrentArgument = LineEditC2A1;
797 mySelection->ClearFilters() ;
799 else if(send == SelectButtonC2A2) {
800 LineEditC2A2->setFocus() ;
801 myEditCurrentArgument = LineEditC2A2;
802 mySelection->AddFilter(myEdgeFilter) ;
804 else if(send == SelectButtonC2A3) {
805 LineEditC2A3->setFocus() ;
806 myEditCurrentArgument = LineEditC2A3;
807 mySelection->AddFilter(myEdgeFilter) ;
809 SelectionIntoArgument() ;
817 //=================================================================================
818 // function : ValueChangedInt()
819 // purpose : (General QT SpinBox)
820 //=================================================================================
821 void GeometryGUI_MultiTranslationDlg::ValueChangedInt( int newIntValue )
823 QSpinBox* send = (QSpinBox*)sender();
825 /* First constructor */
826 if( send == SpinBox_C1A4 ) {
827 myNbTimes1 = newIntValue ;
829 /* Second constructor */
830 else if( send == SpinBox_C2A5 ) {
831 myNbTimes1 = newIntValue ;
833 else if( send == SpinBox_C2A7 ) {
834 myNbTimes2 = newIntValue ;
837 switch (myConstructorId)
841 if (myOkBase && myOkDir1 ) {
842 MakeMultiTranslationSimulationAndDisplay() ;
845 myGeomGUI->EraseSimulationShape() ;
846 mySimulationTopoDs.Nullify() ;
852 if (myOkBase && myOkDir1 && myOkDir2 ) {
853 MakeMultiTranslationSimulationAndDisplay() ;
856 myGeomGUI->EraseSimulationShape() ;
857 mySimulationTopoDs.Nullify() ;
866 //=================================================================================
867 // function : ValueChangedInSpinBox()
868 // purpose : (specifig for GeometryGUI_SpinBox)
869 //=================================================================================
870 void GeometryGUI_MultiTranslationDlg::ValueChangedInSpinBox( double newValue )
872 GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender();
874 /* First constructor */
875 if( send == SpinBox_C1A3 ) {
878 /* Second constructor */
879 else if( send == SpinBox_C2A4 ) {
882 else if( send == SpinBox_C2A6 ) {
886 switch (myConstructorId)
890 if (myOkBase && myOkDir1 ) {
891 MakeMultiTranslationSimulationAndDisplay() ;
894 myGeomGUI->EraseSimulationShape() ;
895 mySimulationTopoDs.Nullify() ;
901 if (myOkBase && myOkDir1 && myOkDir2 ) {
902 MakeMultiTranslationSimulationAndDisplay() ;
905 myGeomGUI->EraseSimulationShape() ;
906 mySimulationTopoDs.Nullify() ;
915 //=================================================================================
916 // function : DeactivateActiveDialog()
918 //=================================================================================
919 void GeometryGUI_MultiTranslationDlg::DeactivateActiveDialog()
921 if ( GroupConstructors->isEnabled() ) {
922 GroupConstructors->setEnabled(false) ;
923 GroupC1->setEnabled(false) ;
924 GroupC2->setEnabled(false) ;
925 GroupButtons->setEnabled(false) ;
926 disconnect( mySelection, 0, this, 0 );
927 myGeomGUI->EraseSimulationShape() ;
928 mySelection->ClearFilters() ;
929 myGeomGUI->ResetState() ;
930 myGeomGUI->SetActiveDialogBox(0) ;
931 myGeomGUI->OnDisplayAll(true) ;
937 //=================================================================================
938 // function : ActivateThisDialog()
940 //=================================================================================
941 void GeometryGUI_MultiTranslationDlg::ActivateThisDialog()
943 /* Emit a signal to deactivate the active dialog */
944 myGeomGUI->EmitSignalDeactivateDialog() ;
945 GroupConstructors->setEnabled(true) ;
946 GroupC1->setEnabled(true) ;
947 GroupC2->setEnabled(true) ;
948 GroupButtons->setEnabled(true) ;
949 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
950 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
951 if( !mySimulationTopoDs.IsNull() )
952 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
958 //=================================================================================
959 // function : enterEvent()
961 //=================================================================================
962 void GeometryGUI_MultiTranslationDlg::enterEvent(QEvent* e)
964 if ( GroupConstructors->isEnabled() )
966 ActivateThisDialog() ;
972 //=================================================================================
973 // function : closeEvent()
975 //=================================================================================
976 void GeometryGUI_MultiTranslationDlg::closeEvent( QCloseEvent* e )
978 this->ClickOnCancel() ; /* same than click on cancel button */
983 //=================================================================================
984 // function : MakeMultiTranslationSimulationAndDisplay()
986 //=================================================================================
987 void GeometryGUI_MultiTranslationDlg::MakeMultiTranslationSimulationAndDisplay()
989 myGeomGUI->EraseSimulationShape() ;
990 gp_Trsf theTransformation ;
991 mySimulationTopoDs.Nullify() ;
998 GProp_GProps System ;
1000 TopoDS_Compound compound;
1003 B.MakeCompound( compound );
1008 BRepGProp::LinearProperties(myBase, System);
1009 myPoint = System.CentreOfMass() ;
1010 S = BRepBuilderAPI_MakeVertex(myPoint).Shape();
1012 switch (myConstructorId)
1016 gp_Vec Vec(myDir1) ;
1019 for ( i = 0; i < myNbTimes1; i++ ) {
1020 DX = i * myStep1 * Vec.X() ;
1021 DY = i * myStep1 * Vec.Y() ;
1022 DZ = i * myStep1 * Vec.Z() ;
1023 myVec.SetCoord( DX, DY, DZ ) ;
1025 theTransformation.SetTranslation(myVec) ;
1026 BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ;
1027 B.Add( compound, myBRepTransformation.Shape() );
1029 mySimulationTopoDs = compound;
1030 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
1035 gp_Vec Vec1(myDir1) ;
1037 gp_Vec Vec2(myDir2) ;
1040 for ( i = 0; i < myNbTimes1; i++ ) {
1041 for ( j = 0; j < myNbTimes2; j++ ) {
1042 DX = i * myStep1 * Vec1.X() + j * myStep2 * Vec2.X() ;
1043 DY = i * myStep1 * Vec1.Y() + j * myStep2 * Vec2.Y() ;
1044 DZ = i * myStep1 * Vec1.Z() + j * myStep2 * Vec2.Z() ;
1045 myVec.SetCoord( DX, DY, DZ ) ;
1047 theTransformation.SetTranslation(myVec) ;
1048 BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ;
1049 B.Add( compound, myBRepTransformation.Shape() );
1052 mySimulationTopoDs = compound ;
1053 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
1058 catch(Standard_Failure) {
1059 MESSAGE( "Exception catched in MakeMultitranslationSimulationAndDisplay" ) ;