2 // File : GeometryGUI_PlaneDlg.cxx
4 // Author : Lucien PIGNOLONI
6 // Module : GeometryGUI
7 // Copyright : OPEN CASCADE
10 #include "GeometryGUI_PlaneDlg.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 <BRepAdaptor_Surface.hxx>
23 #include <Precision.hxx>
25 #include <qbuttongroup.h>
27 #include <qgroupbox.h>
28 #include <qlineedit.h>
29 #include <qpushbutton.h>
30 #include <qradiobutton.h>
35 #include <qwhatsthis.h>
38 #include <qvalidator.h>
42 //=================================================================================
43 // class : GeometryGUI_PlaneDlg()
44 // purpose : Constructs a GeometryGUI_PlaneDlg 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_PlaneDlg::GeometryGUI_PlaneDlg( 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 /***************************************************************/
53 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_PLANE_PV")));
54 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
55 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_PLANE_DXYZ")));
56 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_PLANE_FACE")));
59 setName( "GeometryGUI_PlaneDlg" );
61 setCaption( tr( "GEOM_PLANE_TITLE" ) );
62 setSizeGripEnabled( TRUE );
63 GeometryGUI_PlaneDlgLayout = new QGridLayout( this );
64 GeometryGUI_PlaneDlgLayout->setSpacing( 6 );
65 GeometryGUI_PlaneDlgLayout->setMargin( 11 );
67 /***************************************************************/
68 GroupButtons = new QGroupBox( this, "GroupButtons" );
69 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
70 GroupButtons->setTitle( tr( "" ) );
71 GroupButtons->setColumnLayout(0, Qt::Vertical );
72 GroupButtons->layout()->setSpacing( 0 );
73 GroupButtons->layout()->setMargin( 0 );
74 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
75 GroupButtonsLayout->setAlignment( Qt::AlignTop );
76 GroupButtonsLayout->setSpacing( 6 );
77 GroupButtonsLayout->setMargin( 11 );
78 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
79 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
80 buttonCancel->setAutoDefault( TRUE );
81 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
82 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
83 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
84 buttonApply->setAutoDefault( TRUE );
85 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
86 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
87 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
88 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
89 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
90 buttonOk->setAutoDefault( TRUE );
91 buttonOk->setDefault( TRUE );
92 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
93 GeometryGUI_PlaneDlgLayout->addWidget( GroupButtons, 2, 0 );
95 /***************************************************************/
96 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
97 GroupConstructors->setTitle( tr( "GEOM_PLANE" ) );
98 GroupConstructors->setExclusive( TRUE );
99 GroupConstructors->setColumnLayout(0, Qt::Vertical );
100 GroupConstructors->layout()->setSpacing( 0 );
101 GroupConstructors->layout()->setMargin( 0 );
102 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
103 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
104 GroupConstructorsLayout->setSpacing( 6 );
105 GroupConstructorsLayout->setMargin( 11 );
106 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
107 Constructor1->setText( tr( "" ) );
108 Constructor1->setPixmap( image0 );
109 Constructor1->setChecked( TRUE );
110 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
111 Constructor1->setMinimumSize( QSize( 50, 0 ) );
112 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
113 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
114 Constructor2->setText( tr( "" ) );
115 Constructor2->setPixmap( image2 );
116 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
117 Constructor2->setMinimumSize( QSize( 50, 0 ) );
118 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
119 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
120 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
121 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
122 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
123 Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" );
124 Constructor3->setText( tr( "" ) );
125 Constructor3->setPixmap( image3 );
126 Constructor3->setMinimumSize( QSize( 50, 0 ) );
127 GroupConstructorsLayout->addWidget( Constructor3, 0, 4 );
128 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
129 GroupConstructorsLayout->addItem( spacer_4, 0, 5 );
130 GeometryGUI_PlaneDlgLayout->addWidget( GroupConstructors, 0, 0 );
132 /***************************************************************/
133 GroupPointDirection = new QGroupBox( this, "GroupPointDirection" );
134 GroupPointDirection->setTitle( tr( "GEOM_PLANE_PV" ) );
135 GroupPointDirection->setColumnLayout(0, Qt::Vertical );
136 GroupPointDirection->layout()->setSpacing( 0 );
137 GroupPointDirection->layout()->setMargin( 0 );
138 GroupPointDirectionLayout = new QGridLayout( GroupPointDirection->layout() );
139 GroupPointDirectionLayout->setAlignment( Qt::AlignTop );
140 GroupPointDirectionLayout->setSpacing( 6 );
141 GroupPointDirectionLayout->setMargin( 11 );
142 LineEditDirection = new QLineEdit( GroupPointDirection, "LineEditDirection" );
143 LineEditDirection->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditDirection->sizePolicy().hasHeightForWidth() ) );
144 GroupPointDirectionLayout->addWidget( LineEditDirection, 1, 2 );
145 LineEditPt1 = new QLineEdit( GroupPointDirection, "LineEditPt1" );
146 LineEditPt1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditPt1->sizePolicy().hasHeightForWidth() ) );
147 GroupPointDirectionLayout->addWidget( LineEditPt1, 0, 2 );
148 SelectButtonPt1 = new QPushButton( GroupPointDirection, "SelectButtonPt1" );
149 SelectButtonPt1->setText( tr( "" ) );
150 SelectButtonPt1->setPixmap( image1 );
151 GroupPointDirectionLayout->addWidget( SelectButtonPt1, 0, 1 );
152 SelectButtonDirection = new QPushButton( GroupPointDirection, "SelectButtonDirection" );
153 SelectButtonDirection->setText( tr( "" ) );
154 SelectButtonDirection->setPixmap( image1 );
155 GroupPointDirectionLayout->addWidget( SelectButtonDirection, 1, 1 );
156 TextLabelDirection = new QLabel( GroupPointDirection, "TextLabelDirection" );
157 TextLabelDirection->setText( tr( "GEOM_VECTOR" ) );
158 TextLabelDirection->setMinimumSize( QSize( 50, 0 ) );
159 TextLabelDirection->setFrameShape( QLabel::NoFrame );
160 TextLabelDirection->setFrameShadow( QLabel::Plain );
161 GroupPointDirectionLayout->addWidget( TextLabelDirection, 1, 0 );
162 TextLabelPt1 = new QLabel( GroupPointDirection, "TextLabelPt1" );
163 TextLabelPt1->setText( tr( "GEOM_POINT" ) );
164 TextLabelPt1->setMinimumSize( QSize( 50, 0 ) );
165 TextLabelPt1->setFrameShape( QLabel::NoFrame );
166 TextLabelPt1->setFrameShadow( QLabel::Plain );
167 GroupPointDirectionLayout->addWidget( TextLabelPt1, 0, 0 );
169 SpinBox_C1Size = new GeometryGUI_SpinBox( GroupPointDirection, "SpinBox_C1Size" );
170 GroupPointDirectionLayout->addWidget( SpinBox_C1Size, 2, 2 );
171 TextLabelC1Size = new QLabel( GroupPointDirection, "TextLabelC1Size" );
172 TextLabelC1Size->setText( tr( "GEOM_PLANE_SIZE" ) );
173 TextLabelC1Size->setMinimumSize( QSize( 60, 0 ) );
174 GroupPointDirectionLayout->addWidget( TextLabelC1Size, 2, 0 );
176 GeometryGUI_PlaneDlgLayout->addWidget( GroupPointDirection, 1, 0 );
178 /***************************************************************/
179 GroupPointPlusCoordinates = new QGroupBox( this, "GroupPointPlusCoordinates" );
180 GroupPointPlusCoordinates->setTitle( tr( "GEOM_PLANE_PVC" ) );
181 GroupPointPlusCoordinates->setColumnLayout(0, Qt::Vertical );
182 GroupPointPlusCoordinates->layout()->setSpacing( 0 );
183 GroupPointPlusCoordinates->layout()->setMargin( 0 );
184 GroupPointPlusCoordinatesLayout = new QGridLayout( GroupPointPlusCoordinates->layout() );
185 GroupPointPlusCoordinatesLayout->setAlignment( Qt::AlignTop );
186 GroupPointPlusCoordinatesLayout->setSpacing( 6 );
187 GroupPointPlusCoordinatesLayout->setMargin( 11 );
189 LineEditPt2 = new QLineEdit( GroupPointPlusCoordinates, "LineEditPt2" );
190 LineEditPt2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditPt2->sizePolicy().hasHeightForWidth() ) );
191 GroupPointPlusCoordinatesLayout->addMultiCellWidget( LineEditPt2, 0, 0, 5, 8 );
193 SelectButtonPt2 = new QPushButton( GroupPointPlusCoordinates, "SelectButtonPt2" );
194 SelectButtonPt2->setText( tr( "" ) );
195 SelectButtonPt2->setPixmap( image1 );
196 SelectButtonPt2->setMaximumSize( QSize( 28, 32767 ) );
197 GroupPointPlusCoordinatesLayout->addWidget( SelectButtonPt2, 0, 4 );
199 TextLabelPt2 = new QLabel( GroupPointPlusCoordinates, "TextLabelPt2" );
200 TextLabelPt2->setText( tr( "GEOM_POINT" ) );
201 TextLabelPt2->setMinimumSize( QSize( 50, 0 ) );
202 TextLabelPt2->setFrameShape( QLabel::NoFrame );
203 TextLabelPt2->setFrameShadow( QLabel::Plain );
204 GroupPointPlusCoordinatesLayout->addMultiCellWidget( TextLabelPt2, 0, 0, 0, 3 );
206 SpinBox_DX = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_DX" );
207 SpinBox_DX->setMinimumSize( QSize( 50, 0 ) );
208 SpinBox_DX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DX->sizePolicy().hasHeightForWidth() ) );
209 GroupPointPlusCoordinatesLayout->addMultiCellWidget( SpinBox_DX, 1, 1, 3, 4 );
211 SpinBox_DY = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_DY" );
212 SpinBox_DY->setMinimumSize( QSize( 50, 0 ) );
213 SpinBox_DY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DY->sizePolicy().hasHeightForWidth() ) );
214 GroupPointPlusCoordinatesLayout->addWidget( SpinBox_DY, 1, 6 );
216 SpinBox_DZ = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_DZ" );
217 SpinBox_DZ->setMinimumSize( QSize( 50, 0 ) );
218 SpinBox_DZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DZ->sizePolicy().hasHeightForWidth() ) );
219 GroupPointPlusCoordinatesLayout->addWidget( SpinBox_DZ, 1, 8 );
221 TextLabel_DX = new QLabel( GroupPointPlusCoordinates, "TextLabel_DX" );
222 TextLabel_DX->setText( tr( "GEOM_DX" ) );
223 GroupPointPlusCoordinatesLayout->addWidget( TextLabel_DX, 1, 2 );
225 TextLabel_DY = new QLabel( GroupPointPlusCoordinates, "TextLabel_DY" );
226 TextLabel_DY->setText( tr( "GEOM_DY" ) );
227 GroupPointPlusCoordinatesLayout->addWidget( TextLabel_DY, 1, 5 );
229 TextLabel_DZ = new QLabel( GroupPointPlusCoordinates, "TextLabel_DZ" );
230 TextLabel_DZ->setText( tr( "GEOM_DZ" ) );
231 GroupPointPlusCoordinatesLayout->addWidget( TextLabel_DZ, 1, 7 );
233 TextLabelCoordinates = new QLabel( GroupPointPlusCoordinates, "TextLabelCoordinates" );
234 TextLabelCoordinates->setText( tr( "GEOM_COOR" ) );
235 TextLabelCoordinates->setMinimumSize( QSize( 50, 0 ) );
236 TextLabelCoordinates->setFrameShape( QLabel::NoFrame );
237 TextLabelCoordinates->setFrameShadow( QLabel::Plain );
238 GroupPointPlusCoordinatesLayout->addWidget( TextLabelCoordinates, 1, 0 );
240 TextLabelC2Size = new QLabel( GroupPointPlusCoordinates, "TextLabelC2Size" );
241 TextLabelC2Size->setText( tr( "GEOM_PLANE_SIZE" ) );
242 TextLabelC2Size->setMinimumSize( QSize( 60, 0 ) );
243 GroupPointPlusCoordinatesLayout->addMultiCellWidget( TextLabelC2Size, 2, 2, 0, 1 );
245 SpinBox_C2Size = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_C2Size" );
246 GroupPointPlusCoordinatesLayout->addMultiCellWidget( SpinBox_C2Size, 2, 2, 5, 8 );
248 QSpacerItem* spacer_c = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
249 GroupPointPlusCoordinatesLayout->addMultiCell( spacer_c, 2, 2, 2, 4 );
250 QSpacerItem* spacer_d = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
251 GroupPointPlusCoordinatesLayout->addItem( spacer_d, 1, 1 );
253 GeometryGUI_PlaneDlgLayout->addWidget( GroupPointPlusCoordinates, 1, 0 );
255 /***************************************************************/
257 GroupFace = new QGroupBox( this, "GroupFace" );
258 GroupFace->setTitle( tr( "GEOM_FACE" ) );
259 GroupFace->setColumnLayout(0, Qt::Vertical );
260 GroupFace->layout()->setSpacing( 0 );
261 GroupFace->layout()->setMargin( 0 );
262 GroupFaceLayout = new QGridLayout( GroupFace->layout() );
263 GroupFaceLayout->setAlignment( Qt::AlignTop );
264 GroupFaceLayout->setSpacing( 6 );
265 GroupFaceLayout->setMargin( 11 );
267 TextLabelFace = new QLabel( GroupFace, "TextLabelFace" );
268 TextLabelFace->setFrameShadow( QLabel::Plain );
269 TextLabelFace->setFrameShape( QLabel::NoFrame );
270 TextLabelFace->setText( tr( "GEOM_SELECTION" ) );
271 TextLabelFace->setMinimumSize( QSize( 50, 0 ) );
272 GroupFaceLayout->addMultiCellWidget( TextLabelFace, 0, 0, 0, 1 );
274 SelectButtonFace = new QPushButton( GroupFace, "SelectButtonFace" );
275 SelectButtonFace->setText( tr( "" ) );
276 SelectButtonFace->setPixmap( image1 );
277 SelectButtonFace->setMaximumSize( QSize( 28, 32767 ) );
278 GroupFaceLayout->addWidget( SelectButtonFace, 0, 2 );
280 LineEditFace = new QLineEdit( GroupFace, "LineEditFace" );
281 LineEditFace->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditFace->sizePolicy().hasHeightForWidth() ) );
282 GroupFaceLayout->addWidget( LineEditFace, 0, 3 );
284 TextLabelC3Size = new QLabel( GroupFace, "TextLabelC3Size" );
285 TextLabelC3Size->setText( tr( "GEOM_PLANE_SIZE" ) );
286 TextLabelC3Size->setMinimumSize( QSize( 60, 0 ) );
287 GroupFaceLayout->addWidget( TextLabelC3Size, 1, 0 );
289 SpinBox_C3Size = new GeometryGUI_SpinBox( GroupFace, "SpinBox_C3Size" );
290 SpinBox_C3Size->setCaption( tr( "" ) );
291 GroupFaceLayout->addWidget( SpinBox_C3Size, 1, 3 );
293 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
294 GroupFaceLayout->addMultiCell( spacer, 1, 1, 1, 2 );
295 QSpacerItem* spacer_e = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
296 GroupFaceLayout->addItem( spacer_e, 2, 3 );
297 GeometryGUI_PlaneDlgLayout->addWidget( GroupFace, 1, 0 );
304 //=================================================================================
305 // function : ~GeometryGUI_PlaneDlg()
306 // purpose : Destroys the object and frees any allocated resources
307 //=================================================================================
308 GeometryGUI_PlaneDlg::~GeometryGUI_PlaneDlg()
310 /* no need to delete child widgets, Qt does it all for us */
311 this->destroy(TRUE, TRUE) ;
315 //=================================================================================
318 //=================================================================================
319 void GeometryGUI_PlaneDlg::Init( SALOME_Selection* Sel )
322 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
323 step = St.toDouble() ;
325 /* min, max, step and decimals for spin boxes */
326 SpinBox_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
327 SpinBox_DX->SetValue( 1.0 ) ;
328 SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
329 SpinBox_DY->SetValue( 1.0 ) ;
330 SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
331 SpinBox_DZ->SetValue( 1.0 ) ;
333 this->myTrimSize = 2000.0 ;
334 SpinBox_C1Size->RangeStepAndValidator( +0.001, 10000000.0, step, 5 ) ;
335 SpinBox_C1Size->SetValue( myTrimSize ) ;
336 SpinBox_C2Size->RangeStepAndValidator( +0.001, 10000000.0, step, 5 ) ;
337 SpinBox_C2Size->SetValue( myTrimSize ) ;
338 SpinBox_C3Size->RangeStepAndValidator( +0.001, 10000000.0, step, 5 ) ;
339 SpinBox_C3Size->SetValue( myTrimSize ) ;
341 GroupPointDirection->show();
342 GroupPointPlusCoordinates->hide() ;
344 myConstructorId = 0 ;
345 Constructor1->setChecked( TRUE );
348 myEditCurrentArgument = LineEditPt1 ;
349 mySimulationTopoDs.Nullify() ;
350 myPoint1.SetCoord( 0.0, 0.0, 0.0 );
351 myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false ;
353 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
354 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
356 // TODO previous selection into argument ?
358 /* Filters definition */
359 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
360 myGeom = GEOM::GEOM_Gen::_narrow(comp);
361 myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
362 myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
363 myFaceFilter = new GEOM_FaceFilter( StdSelect_Plane, myGeom );
364 /* Filter for the next selection */
365 mySelection->AddFilter( myVertexFilter ) ;
367 /* signals and slots connections */
368 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
369 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
370 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
371 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
373 connect( LineEditPt1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
374 connect( LineEditDirection, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
376 connect( LineEditPt2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
377 connect( LineEditFace, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
379 connect( SelectButtonPt1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
380 connect( SelectButtonPt2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
381 connect( SelectButtonFace, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
382 connect( SelectButtonDirection, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
384 connect( SpinBox_DX, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
385 connect( SpinBox_DY, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
386 connect( SpinBox_DZ, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
388 connect( SpinBox_C1Size, SIGNAL ( ValueChangedSignal( const double) ), this, SLOT( ValueChangedInSpinBox( const double) ) ) ;
389 connect( SpinBox_C2Size, SIGNAL ( ValueChangedSignal( const double) ), this, SLOT( ValueChangedInSpinBox( const double) ) ) ;
390 connect( SpinBox_C3Size, SIGNAL ( ValueChangedSignal( const double) ), this, SLOT( ValueChangedInSpinBox( const double) ) ) ;
392 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
393 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
394 /* to close dialog if study change */
395 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
397 /* Move widget on the botton right corner of main widget */
399 myGeomGUI->DefineDlgPosition( this, x, y ) ;
401 this->show() ; /* Displays Dialog */
408 //=================================================================================
409 // function : ConstructorsClicked()
410 // purpose : Radio button management
411 //=================================================================================
412 void GeometryGUI_PlaneDlg::ConstructorsClicked(int constructorId)
414 myGeomGUI->EraseSimulationShape() ;
415 myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false ;
416 mySelection->ClearFilters() ;
417 myConstructorId = constructorId ;
418 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
420 switch (constructorId)
422 case 0: /* plane from a point and a direction (vector, edge...) */
424 GroupPointDirection->show();
425 GroupPointPlusCoordinates->hide() ;
427 myEditCurrentArgument = LineEditPt1 ;
428 LineEditPt1->setText(tr("")) ;
429 LineEditDirection->setText(tr("")) ;
431 /* for the first argument */
432 mySelection->AddFilter(myVertexFilter) ;
436 case 1: /* plane from a point and vector coordinates */
438 GroupPointDirection->hide() ;
439 GroupPointPlusCoordinates->show() ;
441 myEditCurrentArgument = LineEditPt2 ;
442 LineEditPt2->setText(tr("")) ;
443 SpinBox_DX->SetValue( 1.0 ) ;
444 SpinBox_DY->SetValue( 1.0 ) ;
445 SpinBox_DZ->SetValue( 1.0 ) ;
446 myOkCoordinates = true ;
448 /* for the first argument */
449 mySelection->AddFilter(myVertexFilter) ;
453 case 2: /* plane from a planar face selection */
455 GroupPointDirection->hide() ;
456 GroupPointPlusCoordinates->hide() ;
458 myEditCurrentArgument = LineEditFace ;
459 LineEditFace->setText(tr("")) ;
461 /* for the first argument */
462 mySelection->AddFilter(myFaceFilter) ;
470 //=================================================================================
471 // function : ClickOnOk()
473 //=================================================================================
474 void GeometryGUI_PlaneDlg::ClickOnOk()
476 this->ClickOnApply() ;
477 this->ClickOnCancel() ;
482 //=================================================================================
483 // function : ClickOnApply()
485 //=================================================================================
486 void GeometryGUI_PlaneDlg::ClickOnApply()
488 myGeomGUI->EraseSimulationShape() ;
489 mySimulationTopoDs.Nullify() ;
490 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
491 switch(myConstructorId)
493 case 0 : /* args are myPoint1 and myDx, myDy, myDz from a vector(edge) */
495 if(myOkPoint1 && myOkDirection) {
496 myGeomGUI->MakePlaneAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
501 case 1 : /* args are myPoint1 and myDx, myDy, myDz from a Spin Box */
504 myGeomGUI->MakePlaneAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
509 case 2 : /* arg is a planar face selection */
512 myGeomGUI->MakePlaneAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize) ;
521 //=================================================================================
522 // function : ClickOnCancel()
524 //=================================================================================
525 void GeometryGUI_PlaneDlg::ClickOnCancel()
527 mySelection->ClearFilters() ;
528 myGeomGUI->EraseSimulationShape() ;
529 mySimulationTopoDs.Nullify() ;
530 disconnect( mySelection, 0, this, 0 );
531 myGeomGUI->ResetState() ;
537 //=================================================================================
538 // function : SelectionIntoArgument()
539 // purpose : Called when selection has changed
540 //=================================================================================
541 void GeometryGUI_PlaneDlg::SelectionIntoArgument()
544 myGeomGUI->EraseSimulationShape() ;
545 mySimulationTopoDs.Nullify() ;
547 /* Future name of argument */
548 QString aString = "";
550 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
552 switch (myConstructorId)
556 if ( myEditCurrentArgument == LineEditPt1 ) {
557 LineEditPt1->setText("") ;
560 else if ( myEditCurrentArgument == LineEditDirection ) {
561 LineEditDirection->setText("") ;
562 myOkDirection = false ;
568 if ( myEditCurrentArgument == LineEditPt2 ) {
569 LineEditPt2->setText("") ;
577 if ( myEditCurrentArgument == LineEditFace ) {
578 LineEditFace->setText("") ;
579 if ( aString.compare("") == 0 )
580 myOkPlanarFace = false ;
582 myOkPlanarFace = true ;
593 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
597 /* FIRST CONSTRUCTOR */
598 if ( myEditCurrentArgument == LineEditPt1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
599 LineEditPt1->setText(aString) ;
602 else if ( myEditCurrentArgument == LineEditDirection ) {
603 /* We verify if the selection is a linear edge */
604 gp_Pnt Pfirst, Plast ;
605 if( myGeomGUI->LinearEdgeExtremities(S, Pfirst, Plast ) ) {
606 myGeomGUI->GetBipointDxDyDz( Pfirst, Plast, myDx, myDy, myDz) ;
607 LineEditDirection->setText(aString) ;
608 myOkDirection = true ;
609 this->myTrimSize = SpinBox_C1Size->GetValue() ;
613 /* SECOND CONSTRUCTOR */
614 else if ( myEditCurrentArgument == LineEditPt2 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
615 LineEditPt2->setText(aString) ;
617 myDx = SpinBox_DX->GetValue() ;
618 myDy = SpinBox_DY->GetValue() ;
619 myDz = SpinBox_DZ->GetValue() ;
620 this->myTrimSize = SpinBox_C2Size->GetValue() ;
622 myOkCoordinates = true ;
625 /* THIRD CONSTRUCTOR */
626 else if ( myEditCurrentArgument == LineEditFace) {
627 if( myOkPlanarFace ) {
628 LineEditFace->setText(aString) ;
629 BRepAdaptor_Surface surf(TopoDS::Face(S));
630 gp_Pln Plane = surf.Plane();
632 gp_Pnt myPoint1 = Plane.Location();
633 gp_Ax1 ax = Plane.Axis();
634 myDx = (ax.Direction()).X() ;
635 myDy = (ax.Direction()).Y() ;
636 myDz = (ax.Direction()).Z() ;
637 this->myTrimSize = SpinBox_C3Size->GetValue() ;
641 /* Call method simulation */
642 if( ( myOkPoint1 && myOkDirection) || ( myOkPoint1 && myOkCoordinates ) || myOkPlanarFace ) {
643 if ( myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion()*Precision::Confusion() ) {
644 MakePlaneSimulationAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
652 //=================================================================================
653 // function : SetEditCurrentArgument()
655 //=================================================================================
656 void GeometryGUI_PlaneDlg::SetEditCurrentArgument()
658 QPushButton* send = (QPushButton*)sender();
659 mySelection->ClearFilters() ;
661 switch (myConstructorId)
665 if(send == SelectButtonPt1) {
666 LineEditPt1->setFocus() ;
667 myEditCurrentArgument = LineEditPt1;
668 mySelection->AddFilter(myVertexFilter) ;
670 else if(send == SelectButtonDirection) {
671 LineEditDirection->setFocus() ;
672 myEditCurrentArgument = LineEditDirection;
673 /* Edge filter here */
674 mySelection->AddFilter(myEdgeFilter) ;
675 SelectionIntoArgument() ;
682 if(send == SelectButtonPt2) {
683 LineEditPt2->setFocus() ;
684 myEditCurrentArgument = LineEditPt2;
685 /* Vertex filter here */
686 mySelection->AddFilter(myVertexFilter) ;
687 SelectionIntoArgument() ;
694 if(send == SelectButtonFace) {
695 LineEditFace->setFocus() ;
696 myEditCurrentArgument = LineEditFace;
697 /* Face filter here */
698 mySelection->AddFilter(myFaceFilter) ;
699 SelectionIntoArgument() ;
708 //=================================================================================
709 // function : ValueChangedInSpinBox()
711 //=================================================================================
712 void GeometryGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
714 QObject* send = (QObject*)sender() ;
716 if( send == SpinBox_DX ) {
718 myDy = SpinBox_DY->GetValue() ;
719 myDz = SpinBox_DZ->GetValue() ;
720 } else if( send == SpinBox_DY ) {
721 myDx = SpinBox_DX->GetValue() ;
723 myDz = SpinBox_DZ->GetValue() ;
724 } else if( send == SpinBox_DZ ) {
725 myDx = SpinBox_DX->GetValue() ;
726 myDy = SpinBox_DY->GetValue() ;
728 } else if( send == SpinBox_C1Size || send == SpinBox_C2Size || send == SpinBox_C3Size ) {
729 myTrimSize = newValue ;
733 if ( myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion() * Precision::Confusion() ) {
734 MakePlaneSimulationAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
737 myGeomGUI->EraseSimulationShape() ;
738 mySimulationTopoDs.Nullify() ;
744 //=================================================================================
745 // function : LineEditReturnPressed()
747 //=================================================================================
748 void GeometryGUI_PlaneDlg::LineEditReturnPressed()
750 QLineEdit* send = (QLineEdit*)sender();
751 if( send == LineEditPt1 )
752 myEditCurrentArgument = LineEditPt1 ;
753 else if ( send == LineEditDirection )
754 myEditCurrentArgument = LineEditDirection ;
755 else if ( send == LineEditPt2 )
756 myEditCurrentArgument = LineEditPt2 ;
757 else if ( send == LineEditFace )
758 myEditCurrentArgument = LineEditFace ;
762 /* User name of object input management */
763 /* If successfull the selection is changed and signal emitted... */
764 /* so SelectionIntoArgument() is automatically called. */
765 const QString objectUserName = myEditCurrentArgument->text() ;
766 QWidget* thisWidget = (QWidget*)this ;
767 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
768 myEditCurrentArgument->setText( objectUserName ) ;
774 //=================================================================================
775 // function : DeactivateActiveDialog()
777 //=================================================================================
778 void GeometryGUI_PlaneDlg::DeactivateActiveDialog()
780 if ( GroupConstructors->isEnabled() ) {
781 GroupConstructors->setEnabled(false) ;
782 GroupPointDirection->setEnabled(false) ;
783 GroupButtons->setEnabled(false) ;
784 GroupFace->setEnabled(false) ;
785 disconnect( mySelection, 0, this, 0 );
786 myGeomGUI->EraseSimulationShape() ;
792 //=================================================================================
793 // function : ActivateThisDialog()
795 //=================================================================================
796 void GeometryGUI_PlaneDlg::ActivateThisDialog()
798 /* Emit a signal to deactivate the active dialog */
799 myGeomGUI->EmitSignalDeactivateDialog() ;
801 GroupConstructors->setEnabled(true) ;
802 GroupPointDirection->setEnabled(true) ;
803 GroupButtons->setEnabled(true) ;
804 GroupFace->setEnabled(true) ;
805 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
806 if( !mySimulationTopoDs.IsNull() )
807 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
812 //=================================================================================
813 // function : enterEvent()
815 //=================================================================================
816 void GeometryGUI_PlaneDlg::enterEvent( QEvent* e)
818 if ( GroupConstructors->isEnabled() )
820 ActivateThisDialog() ;
824 //=================================================================================
825 // function : closeEvent()
827 //=================================================================================
828 void GeometryGUI_PlaneDlg::closeEvent( QCloseEvent* e )
830 /* same than click on cancel button */
831 this->ClickOnCancel() ;
836 //=================================================================================
837 // function : MakePlaneSimulationAndDisplay(()
839 //=================================================================================
840 void GeometryGUI_PlaneDlg::MakePlaneSimulationAndDisplay( const gp_Pnt& P1,
841 const Standard_Real dx,
842 const Standard_Real dy,
843 const Standard_Real dz,
844 const Standard_Real trimsize )
847 gp_Dir aDirection( dx, dy, dz ) ;
848 /* We make a trimmed plane */
849 gp_Pln gplane(P1, aDirection) ;
850 mySimulationTopoDs = BRepBuilderAPI_MakeFace(gplane, -trimsize, +trimsize, -trimsize, +trimsize) ;
852 catch(Standard_Failure) {
853 MESSAGE( "Exception catched in MakePlaneSimulation" << endl ) ;
857 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;