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_PlaneDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI_PlaneDlg.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 <BRepAdaptor_Surface.hxx>
43 #include <Precision.hxx>
45 #include <qbuttongroup.h>
47 #include <qgroupbox.h>
48 #include <qlineedit.h>
49 #include <qpushbutton.h>
50 #include <qradiobutton.h>
55 #include <qwhatsthis.h>
58 #include <qvalidator.h>
62 //=================================================================================
63 // class : GeometryGUI_PlaneDlg()
64 // purpose : Constructs a GeometryGUI_PlaneDlg 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_PlaneDlg::GeometryGUI_PlaneDlg( 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 /***************************************************************/
73 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_PLANE_PV")));
74 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
75 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_PLANE_DXYZ")));
76 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_PLANE_FACE")));
79 setName( "GeometryGUI_PlaneDlg" );
81 setCaption( tr( "GEOM_PLANE_TITLE" ) );
82 setSizeGripEnabled( TRUE );
83 GeometryGUI_PlaneDlgLayout = new QGridLayout( this );
84 GeometryGUI_PlaneDlgLayout->setSpacing( 6 );
85 GeometryGUI_PlaneDlgLayout->setMargin( 11 );
87 /***************************************************************/
88 GroupButtons = new QGroupBox( this, "GroupButtons" );
89 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
90 GroupButtons->setTitle( tr( "" ) );
91 GroupButtons->setColumnLayout(0, Qt::Vertical );
92 GroupButtons->layout()->setSpacing( 0 );
93 GroupButtons->layout()->setMargin( 0 );
94 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
95 GroupButtonsLayout->setAlignment( Qt::AlignTop );
96 GroupButtonsLayout->setSpacing( 6 );
97 GroupButtonsLayout->setMargin( 11 );
98 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
99 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
100 buttonCancel->setAutoDefault( TRUE );
101 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
102 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
103 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
104 buttonApply->setAutoDefault( TRUE );
105 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
106 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
107 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
108 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
109 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
110 buttonOk->setAutoDefault( TRUE );
111 buttonOk->setDefault( TRUE );
112 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
113 GeometryGUI_PlaneDlgLayout->addWidget( GroupButtons, 2, 0 );
115 /***************************************************************/
116 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
117 GroupConstructors->setTitle( tr( "GEOM_PLANE" ) );
118 GroupConstructors->setExclusive( TRUE );
119 GroupConstructors->setColumnLayout(0, Qt::Vertical );
120 GroupConstructors->layout()->setSpacing( 0 );
121 GroupConstructors->layout()->setMargin( 0 );
122 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
123 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
124 GroupConstructorsLayout->setSpacing( 6 );
125 GroupConstructorsLayout->setMargin( 11 );
126 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
127 Constructor1->setText( tr( "" ) );
128 Constructor1->setPixmap( image0 );
129 Constructor1->setChecked( TRUE );
130 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
131 Constructor1->setMinimumSize( QSize( 50, 0 ) );
132 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
133 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
134 Constructor2->setText( tr( "" ) );
135 Constructor2->setPixmap( image2 );
136 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
137 Constructor2->setMinimumSize( QSize( 50, 0 ) );
138 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
139 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
140 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
141 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
142 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
143 Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" );
144 Constructor3->setText( tr( "" ) );
145 Constructor3->setPixmap( image3 );
146 Constructor3->setMinimumSize( QSize( 50, 0 ) );
147 GroupConstructorsLayout->addWidget( Constructor3, 0, 4 );
148 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
149 GroupConstructorsLayout->addItem( spacer_4, 0, 5 );
150 GeometryGUI_PlaneDlgLayout->addWidget( GroupConstructors, 0, 0 );
152 /***************************************************************/
153 GroupPointDirection = new QGroupBox( this, "GroupPointDirection" );
154 GroupPointDirection->setTitle( tr( "GEOM_PLANE_PV" ) );
155 GroupPointDirection->setColumnLayout(0, Qt::Vertical );
156 GroupPointDirection->layout()->setSpacing( 0 );
157 GroupPointDirection->layout()->setMargin( 0 );
158 GroupPointDirectionLayout = new QGridLayout( GroupPointDirection->layout() );
159 GroupPointDirectionLayout->setAlignment( Qt::AlignTop );
160 GroupPointDirectionLayout->setSpacing( 6 );
161 GroupPointDirectionLayout->setMargin( 11 );
162 LineEditDirection = new QLineEdit( GroupPointDirection, "LineEditDirection" );
163 LineEditDirection->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditDirection->sizePolicy().hasHeightForWidth() ) );
164 GroupPointDirectionLayout->addWidget( LineEditDirection, 1, 2 );
165 LineEditPt1 = new QLineEdit( GroupPointDirection, "LineEditPt1" );
166 LineEditPt1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditPt1->sizePolicy().hasHeightForWidth() ) );
167 GroupPointDirectionLayout->addWidget( LineEditPt1, 0, 2 );
168 SelectButtonPt1 = new QPushButton( GroupPointDirection, "SelectButtonPt1" );
169 SelectButtonPt1->setText( tr( "" ) );
170 SelectButtonPt1->setPixmap( image1 );
171 GroupPointDirectionLayout->addWidget( SelectButtonPt1, 0, 1 );
172 SelectButtonDirection = new QPushButton( GroupPointDirection, "SelectButtonDirection" );
173 SelectButtonDirection->setText( tr( "" ) );
174 SelectButtonDirection->setPixmap( image1 );
175 GroupPointDirectionLayout->addWidget( SelectButtonDirection, 1, 1 );
176 TextLabelDirection = new QLabel( GroupPointDirection, "TextLabelDirection" );
177 TextLabelDirection->setText( tr( "GEOM_VECTOR" ) );
178 TextLabelDirection->setMinimumSize( QSize( 50, 0 ) );
179 TextLabelDirection->setFrameShape( QLabel::NoFrame );
180 TextLabelDirection->setFrameShadow( QLabel::Plain );
181 GroupPointDirectionLayout->addWidget( TextLabelDirection, 1, 0 );
182 TextLabelPt1 = new QLabel( GroupPointDirection, "TextLabelPt1" );
183 TextLabelPt1->setText( tr( "GEOM_POINT" ) );
184 TextLabelPt1->setMinimumSize( QSize( 50, 0 ) );
185 TextLabelPt1->setFrameShape( QLabel::NoFrame );
186 TextLabelPt1->setFrameShadow( QLabel::Plain );
187 GroupPointDirectionLayout->addWidget( TextLabelPt1, 0, 0 );
189 SpinBox_C1Size = new GeometryGUI_SpinBox( GroupPointDirection, "SpinBox_C1Size" );
190 GroupPointDirectionLayout->addWidget( SpinBox_C1Size, 2, 2 );
191 TextLabelC1Size = new QLabel( GroupPointDirection, "TextLabelC1Size" );
192 TextLabelC1Size->setText( tr( "GEOM_PLANE_SIZE" ) );
193 TextLabelC1Size->setMinimumSize( QSize( 60, 0 ) );
194 GroupPointDirectionLayout->addWidget( TextLabelC1Size, 2, 0 );
196 GeometryGUI_PlaneDlgLayout->addWidget( GroupPointDirection, 1, 0 );
198 /***************************************************************/
199 GroupPointPlusCoordinates = new QGroupBox( this, "GroupPointPlusCoordinates" );
200 GroupPointPlusCoordinates->setTitle( tr( "GEOM_PLANE_PVC" ) );
201 GroupPointPlusCoordinates->setColumnLayout(0, Qt::Vertical );
202 GroupPointPlusCoordinates->layout()->setSpacing( 0 );
203 GroupPointPlusCoordinates->layout()->setMargin( 0 );
204 GroupPointPlusCoordinatesLayout = new QGridLayout( GroupPointPlusCoordinates->layout() );
205 GroupPointPlusCoordinatesLayout->setAlignment( Qt::AlignTop );
206 GroupPointPlusCoordinatesLayout->setSpacing( 6 );
207 GroupPointPlusCoordinatesLayout->setMargin( 11 );
209 LineEditPt2 = new QLineEdit( GroupPointPlusCoordinates, "LineEditPt2" );
210 LineEditPt2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditPt2->sizePolicy().hasHeightForWidth() ) );
211 GroupPointPlusCoordinatesLayout->addMultiCellWidget( LineEditPt2, 0, 0, 5, 8 );
213 SelectButtonPt2 = new QPushButton( GroupPointPlusCoordinates, "SelectButtonPt2" );
214 SelectButtonPt2->setText( tr( "" ) );
215 SelectButtonPt2->setPixmap( image1 );
216 SelectButtonPt2->setMaximumSize( QSize( 28, 32767 ) );
217 GroupPointPlusCoordinatesLayout->addWidget( SelectButtonPt2, 0, 4 );
219 TextLabelPt2 = new QLabel( GroupPointPlusCoordinates, "TextLabelPt2" );
220 TextLabelPt2->setText( tr( "GEOM_POINT" ) );
221 TextLabelPt2->setMinimumSize( QSize( 50, 0 ) );
222 TextLabelPt2->setFrameShape( QLabel::NoFrame );
223 TextLabelPt2->setFrameShadow( QLabel::Plain );
224 GroupPointPlusCoordinatesLayout->addMultiCellWidget( TextLabelPt2, 0, 0, 0, 3 );
226 SpinBox_DX = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_DX" );
227 SpinBox_DX->setMinimumSize( QSize( 50, 0 ) );
228 SpinBox_DX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DX->sizePolicy().hasHeightForWidth() ) );
229 GroupPointPlusCoordinatesLayout->addMultiCellWidget( SpinBox_DX, 1, 1, 3, 4 );
231 SpinBox_DY = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_DY" );
232 SpinBox_DY->setMinimumSize( QSize( 50, 0 ) );
233 SpinBox_DY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DY->sizePolicy().hasHeightForWidth() ) );
234 GroupPointPlusCoordinatesLayout->addWidget( SpinBox_DY, 1, 6 );
236 SpinBox_DZ = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_DZ" );
237 SpinBox_DZ->setMinimumSize( QSize( 50, 0 ) );
238 SpinBox_DZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DZ->sizePolicy().hasHeightForWidth() ) );
239 GroupPointPlusCoordinatesLayout->addWidget( SpinBox_DZ, 1, 8 );
241 TextLabel_DX = new QLabel( GroupPointPlusCoordinates, "TextLabel_DX" );
242 TextLabel_DX->setText( tr( "GEOM_DX" ) );
243 GroupPointPlusCoordinatesLayout->addWidget( TextLabel_DX, 1, 2 );
245 TextLabel_DY = new QLabel( GroupPointPlusCoordinates, "TextLabel_DY" );
246 TextLabel_DY->setText( tr( "GEOM_DY" ) );
247 GroupPointPlusCoordinatesLayout->addWidget( TextLabel_DY, 1, 5 );
249 TextLabel_DZ = new QLabel( GroupPointPlusCoordinates, "TextLabel_DZ" );
250 TextLabel_DZ->setText( tr( "GEOM_DZ" ) );
251 GroupPointPlusCoordinatesLayout->addWidget( TextLabel_DZ, 1, 7 );
253 TextLabelCoordinates = new QLabel( GroupPointPlusCoordinates, "TextLabelCoordinates" );
254 TextLabelCoordinates->setText( tr( "GEOM_COOR" ) );
255 TextLabelCoordinates->setMinimumSize( QSize( 50, 0 ) );
256 TextLabelCoordinates->setFrameShape( QLabel::NoFrame );
257 TextLabelCoordinates->setFrameShadow( QLabel::Plain );
258 GroupPointPlusCoordinatesLayout->addWidget( TextLabelCoordinates, 1, 0 );
260 TextLabelC2Size = new QLabel( GroupPointPlusCoordinates, "TextLabelC2Size" );
261 TextLabelC2Size->setText( tr( "GEOM_PLANE_SIZE" ) );
262 TextLabelC2Size->setMinimumSize( QSize( 60, 0 ) );
263 GroupPointPlusCoordinatesLayout->addMultiCellWidget( TextLabelC2Size, 2, 2, 0, 1 );
265 SpinBox_C2Size = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_C2Size" );
266 GroupPointPlusCoordinatesLayout->addMultiCellWidget( SpinBox_C2Size, 2, 2, 5, 8 );
268 QSpacerItem* spacer_c = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
269 GroupPointPlusCoordinatesLayout->addMultiCell( spacer_c, 2, 2, 2, 4 );
270 QSpacerItem* spacer_d = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
271 GroupPointPlusCoordinatesLayout->addItem( spacer_d, 1, 1 );
273 GeometryGUI_PlaneDlgLayout->addWidget( GroupPointPlusCoordinates, 1, 0 );
275 /***************************************************************/
277 GroupFace = new QGroupBox( this, "GroupFace" );
278 GroupFace->setTitle( tr( "GEOM_FACE" ) );
279 GroupFace->setColumnLayout(0, Qt::Vertical );
280 GroupFace->layout()->setSpacing( 0 );
281 GroupFace->layout()->setMargin( 0 );
282 GroupFaceLayout = new QGridLayout( GroupFace->layout() );
283 GroupFaceLayout->setAlignment( Qt::AlignTop );
284 GroupFaceLayout->setSpacing( 6 );
285 GroupFaceLayout->setMargin( 11 );
287 TextLabelFace = new QLabel( GroupFace, "TextLabelFace" );
288 TextLabelFace->setFrameShadow( QLabel::Plain );
289 TextLabelFace->setFrameShape( QLabel::NoFrame );
290 TextLabelFace->setText( tr( "GEOM_SELECTION" ) );
291 TextLabelFace->setMinimumSize( QSize( 50, 0 ) );
292 GroupFaceLayout->addMultiCellWidget( TextLabelFace, 0, 0, 0, 1 );
294 SelectButtonFace = new QPushButton( GroupFace, "SelectButtonFace" );
295 SelectButtonFace->setText( tr( "" ) );
296 SelectButtonFace->setPixmap( image1 );
297 SelectButtonFace->setMaximumSize( QSize( 28, 32767 ) );
298 GroupFaceLayout->addWidget( SelectButtonFace, 0, 2 );
300 LineEditFace = new QLineEdit( GroupFace, "LineEditFace" );
301 LineEditFace->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditFace->sizePolicy().hasHeightForWidth() ) );
302 GroupFaceLayout->addWidget( LineEditFace, 0, 3 );
304 TextLabelC3Size = new QLabel( GroupFace, "TextLabelC3Size" );
305 TextLabelC3Size->setText( tr( "GEOM_PLANE_SIZE" ) );
306 TextLabelC3Size->setMinimumSize( QSize( 60, 0 ) );
307 GroupFaceLayout->addWidget( TextLabelC3Size, 1, 0 );
309 SpinBox_C3Size = new GeometryGUI_SpinBox( GroupFace, "SpinBox_C3Size" );
310 SpinBox_C3Size->setCaption( tr( "" ) );
311 GroupFaceLayout->addWidget( SpinBox_C3Size, 1, 3 );
313 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
314 GroupFaceLayout->addMultiCell( spacer, 1, 1, 1, 2 );
315 QSpacerItem* spacer_e = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
316 GroupFaceLayout->addItem( spacer_e, 2, 3 );
317 GeometryGUI_PlaneDlgLayout->addWidget( GroupFace, 1, 0 );
324 //=================================================================================
325 // function : ~GeometryGUI_PlaneDlg()
326 // purpose : Destroys the object and frees any allocated resources
327 //=================================================================================
328 GeometryGUI_PlaneDlg::~GeometryGUI_PlaneDlg()
330 /* no need to delete child widgets, Qt does it all for us */
331 this->destroy(TRUE, TRUE) ;
335 //=================================================================================
338 //=================================================================================
339 void GeometryGUI_PlaneDlg::Init( SALOME_Selection* Sel )
342 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
343 step = St.toDouble() ;
345 /* min, max, step and decimals for spin boxes */
346 SpinBox_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
347 SpinBox_DX->SetValue( 1.0 ) ;
348 SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
349 SpinBox_DY->SetValue( 1.0 ) ;
350 SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
351 SpinBox_DZ->SetValue( 1.0 ) ;
353 this->myTrimSize = 2000.0 ;
354 SpinBox_C1Size->RangeStepAndValidator( +0.001, 10000000.0, step, 5 ) ;
355 SpinBox_C1Size->SetValue( myTrimSize ) ;
356 SpinBox_C2Size->RangeStepAndValidator( +0.001, 10000000.0, step, 5 ) ;
357 SpinBox_C2Size->SetValue( myTrimSize ) ;
358 SpinBox_C3Size->RangeStepAndValidator( +0.001, 10000000.0, step, 5 ) ;
359 SpinBox_C3Size->SetValue( myTrimSize ) ;
361 GroupPointDirection->show();
362 GroupPointPlusCoordinates->hide() ;
364 myConstructorId = 0 ;
365 Constructor1->setChecked( TRUE );
368 myEditCurrentArgument = LineEditPt1 ;
369 mySimulationTopoDs.Nullify() ;
370 myPoint1.SetCoord( 0.0, 0.0, 0.0 );
371 myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false ;
373 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
374 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
376 // TODO previous selection into argument ?
378 /* Filters definition */
379 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
380 myGeom = GEOM::GEOM_Gen::_narrow(comp);
381 myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
382 myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
383 myFaceFilter = new GEOM_FaceFilter( StdSelect_Plane, myGeom );
384 /* Filter for the next selection */
385 mySelection->AddFilter( myVertexFilter ) ;
387 /* signals and slots connections */
388 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
389 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
390 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
391 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
393 connect( LineEditPt1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
394 connect( LineEditDirection, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
396 connect( LineEditPt2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
397 connect( LineEditFace, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
399 connect( SelectButtonPt1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
400 connect( SelectButtonPt2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
401 connect( SelectButtonFace, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
402 connect( SelectButtonDirection, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
404 connect( SpinBox_DX, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
405 connect( SpinBox_DY, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
406 connect( SpinBox_DZ, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
408 connect( SpinBox_C1Size, SIGNAL ( ValueChangedSignal( const double) ), this, SLOT( ValueChangedInSpinBox( const double) ) ) ;
409 connect( SpinBox_C2Size, SIGNAL ( ValueChangedSignal( const double) ), this, SLOT( ValueChangedInSpinBox( const double) ) ) ;
410 connect( SpinBox_C3Size, SIGNAL ( ValueChangedSignal( const double) ), this, SLOT( ValueChangedInSpinBox( const double) ) ) ;
412 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
413 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
414 /* to close dialog if study change */
415 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
417 /* Move widget on the botton right corner of main widget */
419 myGeomGUI->DefineDlgPosition( this, x, y ) ;
421 this->show() ; /* Displays Dialog */
428 //=================================================================================
429 // function : ConstructorsClicked()
430 // purpose : Radio button management
431 //=================================================================================
432 void GeometryGUI_PlaneDlg::ConstructorsClicked(int constructorId)
434 myGeomGUI->EraseSimulationShape() ;
435 myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false ;
436 mySelection->ClearFilters() ;
437 myConstructorId = constructorId ;
438 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
440 switch (constructorId)
442 case 0: /* plane from a point and a direction (vector, edge...) */
444 GroupPointDirection->show();
445 GroupPointPlusCoordinates->hide() ;
447 myEditCurrentArgument = LineEditPt1 ;
448 LineEditPt1->setText(tr("")) ;
449 LineEditDirection->setText(tr("")) ;
451 /* for the first argument */
452 mySelection->AddFilter(myVertexFilter) ;
456 case 1: /* plane from a point and vector coordinates */
458 GroupPointDirection->hide() ;
459 GroupPointPlusCoordinates->show() ;
461 myEditCurrentArgument = LineEditPt2 ;
462 LineEditPt2->setText(tr("")) ;
463 SpinBox_DX->SetValue( 1.0 ) ;
464 SpinBox_DY->SetValue( 1.0 ) ;
465 SpinBox_DZ->SetValue( 1.0 ) ;
466 myOkCoordinates = true ;
468 /* for the first argument */
469 mySelection->AddFilter(myVertexFilter) ;
473 case 2: /* plane from a planar face selection */
475 GroupPointDirection->hide() ;
476 GroupPointPlusCoordinates->hide() ;
478 myEditCurrentArgument = LineEditFace ;
479 LineEditFace->setText(tr("")) ;
481 /* for the first argument */
482 mySelection->AddFilter(myFaceFilter) ;
490 //=================================================================================
491 // function : ClickOnOk()
493 //=================================================================================
494 void GeometryGUI_PlaneDlg::ClickOnOk()
496 this->ClickOnApply() ;
497 this->ClickOnCancel() ;
502 //=================================================================================
503 // function : ClickOnApply()
505 //=================================================================================
506 void GeometryGUI_PlaneDlg::ClickOnApply()
508 myGeomGUI->EraseSimulationShape() ;
509 mySimulationTopoDs.Nullify() ;
510 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
511 switch(myConstructorId)
513 case 0 : /* args are myPoint1 and myDx, myDy, myDz from a vector(edge) */
515 if(myOkPoint1 && myOkDirection) {
516 myGeomGUI->MakePlaneAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
521 case 1 : /* args are myPoint1 and myDx, myDy, myDz from a Spin Box */
524 myGeomGUI->MakePlaneAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
529 case 2 : /* arg is a planar face selection */
532 myGeomGUI->MakePlaneAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize) ;
541 //=================================================================================
542 // function : ClickOnCancel()
544 //=================================================================================
545 void GeometryGUI_PlaneDlg::ClickOnCancel()
547 mySelection->ClearFilters() ;
548 myGeomGUI->EraseSimulationShape() ;
549 mySimulationTopoDs.Nullify() ;
550 disconnect( mySelection, 0, this, 0 );
551 myGeomGUI->ResetState() ;
557 //=================================================================================
558 // function : SelectionIntoArgument()
559 // purpose : Called when selection has changed
560 //=================================================================================
561 void GeometryGUI_PlaneDlg::SelectionIntoArgument()
564 myGeomGUI->EraseSimulationShape() ;
565 mySimulationTopoDs.Nullify() ;
567 /* Future name of argument */
568 QString aString = "";
570 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
572 switch (myConstructorId)
576 if ( myEditCurrentArgument == LineEditPt1 ) {
577 LineEditPt1->setText("") ;
580 else if ( myEditCurrentArgument == LineEditDirection ) {
581 LineEditDirection->setText("") ;
582 myOkDirection = false ;
588 if ( myEditCurrentArgument == LineEditPt2 ) {
589 LineEditPt2->setText("") ;
597 if ( myEditCurrentArgument == LineEditFace ) {
598 LineEditFace->setText("") ;
599 if ( aString.compare("") == 0 )
600 myOkPlanarFace = false ;
602 myOkPlanarFace = true ;
613 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
617 /* FIRST CONSTRUCTOR */
618 if ( myEditCurrentArgument == LineEditPt1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
619 LineEditPt1->setText(aString) ;
622 else if ( myEditCurrentArgument == LineEditDirection ) {
623 /* We verify if the selection is a linear edge */
624 gp_Pnt Pfirst, Plast ;
625 if( myGeomGUI->LinearEdgeExtremities(S, Pfirst, Plast ) ) {
626 myGeomGUI->GetBipointDxDyDz( Pfirst, Plast, myDx, myDy, myDz) ;
627 LineEditDirection->setText(aString) ;
628 myOkDirection = true ;
629 this->myTrimSize = SpinBox_C1Size->GetValue() ;
633 /* SECOND CONSTRUCTOR */
634 else if ( myEditCurrentArgument == LineEditPt2 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
635 LineEditPt2->setText(aString) ;
637 myDx = SpinBox_DX->GetValue() ;
638 myDy = SpinBox_DY->GetValue() ;
639 myDz = SpinBox_DZ->GetValue() ;
640 this->myTrimSize = SpinBox_C2Size->GetValue() ;
642 myOkCoordinates = true ;
645 /* THIRD CONSTRUCTOR */
646 else if ( myEditCurrentArgument == LineEditFace) {
647 if( myOkPlanarFace ) {
648 LineEditFace->setText(aString) ;
649 BRepAdaptor_Surface surf(TopoDS::Face(S));
650 gp_Pln Plane = surf.Plane();
652 gp_Pnt myPoint1 = Plane.Location();
653 gp_Ax1 ax = Plane.Axis();
654 myDx = (ax.Direction()).X() ;
655 myDy = (ax.Direction()).Y() ;
656 myDz = (ax.Direction()).Z() ;
657 this->myTrimSize = SpinBox_C3Size->GetValue() ;
661 /* Call method simulation */
662 if( ( myOkPoint1 && myOkDirection) || ( myOkPoint1 && myOkCoordinates ) || myOkPlanarFace ) {
663 if ( myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion()*Precision::Confusion() ) {
664 MakePlaneSimulationAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
672 //=================================================================================
673 // function : SetEditCurrentArgument()
675 //=================================================================================
676 void GeometryGUI_PlaneDlg::SetEditCurrentArgument()
678 QPushButton* send = (QPushButton*)sender();
679 mySelection->ClearFilters() ;
681 switch (myConstructorId)
685 if(send == SelectButtonPt1) {
686 LineEditPt1->setFocus() ;
687 myEditCurrentArgument = LineEditPt1;
688 mySelection->AddFilter(myVertexFilter) ;
690 else if(send == SelectButtonDirection) {
691 LineEditDirection->setFocus() ;
692 myEditCurrentArgument = LineEditDirection;
693 /* Edge filter here */
694 mySelection->AddFilter(myEdgeFilter) ;
695 SelectionIntoArgument() ;
702 if(send == SelectButtonPt2) {
703 LineEditPt2->setFocus() ;
704 myEditCurrentArgument = LineEditPt2;
705 /* Vertex filter here */
706 mySelection->AddFilter(myVertexFilter) ;
707 SelectionIntoArgument() ;
714 if(send == SelectButtonFace) {
715 LineEditFace->setFocus() ;
716 myEditCurrentArgument = LineEditFace;
717 /* Face filter here */
718 mySelection->AddFilter(myFaceFilter) ;
719 SelectionIntoArgument() ;
728 //=================================================================================
729 // function : ValueChangedInSpinBox()
731 //=================================================================================
732 void GeometryGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
734 QObject* send = (QObject*)sender() ;
736 if( send == SpinBox_DX ) {
738 myDy = SpinBox_DY->GetValue() ;
739 myDz = SpinBox_DZ->GetValue() ;
740 } else if( send == SpinBox_DY ) {
741 myDx = SpinBox_DX->GetValue() ;
743 myDz = SpinBox_DZ->GetValue() ;
744 } else if( send == SpinBox_DZ ) {
745 myDx = SpinBox_DX->GetValue() ;
746 myDy = SpinBox_DY->GetValue() ;
748 } else if( send == SpinBox_C1Size || send == SpinBox_C2Size || send == SpinBox_C3Size ) {
749 myTrimSize = newValue ;
753 if ( myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion() * Precision::Confusion() ) {
754 MakePlaneSimulationAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
757 myGeomGUI->EraseSimulationShape() ;
758 mySimulationTopoDs.Nullify() ;
764 //=================================================================================
765 // function : LineEditReturnPressed()
767 //=================================================================================
768 void GeometryGUI_PlaneDlg::LineEditReturnPressed()
770 QLineEdit* send = (QLineEdit*)sender();
771 if( send == LineEditPt1 )
772 myEditCurrentArgument = LineEditPt1 ;
773 else if ( send == LineEditDirection )
774 myEditCurrentArgument = LineEditDirection ;
775 else if ( send == LineEditPt2 )
776 myEditCurrentArgument = LineEditPt2 ;
777 else if ( send == LineEditFace )
778 myEditCurrentArgument = LineEditFace ;
782 /* User name of object input management */
783 /* If successfull the selection is changed and signal emitted... */
784 /* so SelectionIntoArgument() is automatically called. */
785 const QString objectUserName = myEditCurrentArgument->text() ;
786 QWidget* thisWidget = (QWidget*)this ;
787 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
788 myEditCurrentArgument->setText( objectUserName ) ;
794 //=================================================================================
795 // function : DeactivateActiveDialog()
797 //=================================================================================
798 void GeometryGUI_PlaneDlg::DeactivateActiveDialog()
800 if ( GroupConstructors->isEnabled() ) {
801 GroupConstructors->setEnabled(false) ;
802 GroupPointDirection->setEnabled(false) ;
803 GroupButtons->setEnabled(false) ;
804 GroupFace->setEnabled(false) ;
805 disconnect( mySelection, 0, this, 0 );
806 myGeomGUI->EraseSimulationShape() ;
812 //=================================================================================
813 // function : ActivateThisDialog()
815 //=================================================================================
816 void GeometryGUI_PlaneDlg::ActivateThisDialog()
818 /* Emit a signal to deactivate the active dialog */
819 myGeomGUI->EmitSignalDeactivateDialog() ;
821 GroupConstructors->setEnabled(true) ;
822 GroupPointDirection->setEnabled(true) ;
823 GroupButtons->setEnabled(true) ;
824 GroupFace->setEnabled(true) ;
825 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
826 if( !mySimulationTopoDs.IsNull() )
827 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
832 //=================================================================================
833 // function : enterEvent()
835 //=================================================================================
836 void GeometryGUI_PlaneDlg::enterEvent( QEvent* e)
838 if ( GroupConstructors->isEnabled() )
840 ActivateThisDialog() ;
844 //=================================================================================
845 // function : closeEvent()
847 //=================================================================================
848 void GeometryGUI_PlaneDlg::closeEvent( QCloseEvent* e )
850 /* same than click on cancel button */
851 this->ClickOnCancel() ;
856 //=================================================================================
857 // function : MakePlaneSimulationAndDisplay(()
859 //=================================================================================
860 void GeometryGUI_PlaneDlg::MakePlaneSimulationAndDisplay( const gp_Pnt& P1,
861 const Standard_Real dx,
862 const Standard_Real dy,
863 const Standard_Real dz,
864 const Standard_Real trimsize )
867 gp_Dir aDirection( dx, dy, dz ) ;
868 /* We make a trimmed plane */
869 gp_Pln gplane(P1, aDirection) ;
870 mySimulationTopoDs = BRepBuilderAPI_MakeFace(gplane, -trimsize, +trimsize, -trimsize, +trimsize) ;
872 catch(Standard_Failure) {
873 MESSAGE( "Exception catched in MakePlaneSimulation" << endl ) ;
877 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;