1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
27 #include "EntityGUI_SketcherDlg.h"
28 #include "EntityGUI_Widgets.h"
29 #include <SalomeApp_DoubleSpinBox.h>
31 #include <OCCViewer_ViewPort3d.h>
32 #include <OCCViewer_ViewWindow.h>
33 #include <OCCViewer_ViewSketcher.h>
36 #include <GeometryGUI.h>
37 #include <GEOMImpl_Types.hxx>
38 #include <Geom_Surface.hxx>
39 #include <Geom_Plane.hxx>
41 #include <GeomLib_IsPlanarSurface.hxx>
43 #include <SUIT_Desktop.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_ResourceMgr.h>
47 #include <SalomeApp_Application.h>
48 #include <LightApp_Application.h>
49 #include <LightApp_SelectionMgr.h>
55 #include <BRep_Tool.hxx>
57 #include <TopExp_Explorer.hxx>
58 #include <TopoDS_Vertex.hxx>
60 #include <BRepBuilderAPI_Transform.hxx>
61 #include <BRepBuilderAPI_MakeWire.hxx>
62 #include <BRepBuilderAPI_MakeVertex.hxx>
63 #include <Sketcher_Profile.hxx>
65 #include <SalomeApp_Study.h>
66 #include <SalomeApp_Tools.h>
70 #include <Basics_Utils.hxx>
72 //=================================================================================
73 // class : EntityGUI_SketcherDlg()
74 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
75 // name 'name' and widget flags set to 'f'.
76 // The dialog will by default be modeless, unless you set 'modal' to
77 // TRUE to construct a modal dialog.
78 //=================================================================================
79 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
80 bool modal, Qt::WindowFlags fl,
81 const double lineWidth )
82 : QDialog( parent, fl ),
83 myIsAllAdded( false ),
85 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
87 myLineWidth( lineWidth )
89 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
91 setAttribute( Qt::WA_DeleteOnClose );
93 // Disable rectangular selection
94 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
95 // ((OCCViewer_ViewWindow*)theViewWindow)->setEnabledDrawMode( false );
96 // MESSAGE("((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode();"<<((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode())
97 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
98 // vp->setSketchingEnabled( false );
99 // MESSAGE("vp->isSketchingEnabled()"<<vp->isSketchingEnabled())
100 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(true);
101 // OCCViewer_ViewSketcher* aViewSketcher = ((OCCViewer_ViewWindow*)theViewWindow)->getSketcher( OCCViewer_ViewWindow::Rect );
102 // aViewSketcher->deactivate()
103 // aViewSketcher->setVisible(false);
105 // this->setMouseTracking(false);
107 myGeometryGUI->SetActiveDialogBox(this);
109 MainWidget = new EntityGUI_Skeleton( this );
110 QVBoxLayout* topLayout = new QVBoxLayout( this );
111 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
113 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
114 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_CLOSE" ) );
115 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
116 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
118 QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
119 QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
120 QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
121 QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
122 QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) );
123 QPixmap image5 (aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
124 QPixmap image6 (aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_RECTANGLE" ) ) );
126 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
128 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
129 MainWidget->RadioButton1->setText( "" );
130 MainWidget->RadioButton1->setIcon( image3 );
131 MainWidget->RadioButton2->setText( "" );
132 MainWidget->RadioButton2->setIcon( image4 );
133 MainWidget->RadioButton3->setText( "" );
134 MainWidget->RadioButton3->setIcon( image6 );
135 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
136 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
137 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
138 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
140 /***************************************************************/
142 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
143 QGridLayout* planeLayout = new QGridLayout(GroupBox1);
144 planeLayout->setSpacing(6);
145 planeLayout->setMargin(11);
147 ComboBox1 = new QComboBox(GroupBox1);
148 planeLayout->addWidget(ComboBox1,0,0,1,2);
150 planeButton = new QPushButton (GroupBox1);
151 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
152 planeLayout->addWidget(planeButton,0,2);
154 selButton = new QPushButton (GroupBox1);
155 selButton->setIcon(image5);
156 planeLayout->addWidget(selButton,1,0);
158 WPlaneLineEdit = new QLineEdit (GroupBox1);
159 WPlaneLineEdit->setReadOnly(true);
160 planeLayout->addWidget(WPlaneLineEdit,1,1,1,2);
162 planeLayout->setColumnStretch(1,1);
164 topLayout->addWidget(GroupBox1);
165 topLayout->addWidget( MainWidget );
166 topLayout->setStretch( 1, 1);
168 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
170 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
171 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
172 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
173 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
175 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
177 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
178 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
179 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
180 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
182 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
184 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
185 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
186 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
187 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
188 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
190 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
192 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIST" ) );
193 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
194 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
195 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
197 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
198 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
199 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
200 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
201 Group1Sel->PushButton1->setIcon( image0 );
202 Group1Sel->buttonUndo->setIcon( image1 );
203 Group1Sel->buttonRedo->setIcon( image2 );
204 Group1Sel->LineEdit1->setReadOnly( true );
206 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
207 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
208 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
209 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
210 Group2Sel->PushButton1->setIcon( image0 );
211 Group2Sel->PushButton2->setIcon( image0 );
212 Group2Sel->buttonUndo->setIcon( image1 );
213 Group2Sel->buttonRedo->setIcon( image2 );
214 Group2Sel->LineEdit1->setReadOnly( true );
215 Group2Sel->LineEdit2->setReadOnly( true );
217 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
218 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
219 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
220 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
221 Group1Sel1Spin->PushButton1->setIcon( image0 );
222 Group1Sel1Spin->buttonUndo->setIcon( image1 );
223 Group1Sel1Spin->buttonRedo->setIcon( image2 );
224 Group1Sel1Spin->LineEdit1->setReadOnly( true );
226 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
227 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
228 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
229 Group1Spin->buttonUndo->setIcon( image1 );
230 Group1Spin->buttonRedo->setIcon( image2 );
232 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
233 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
234 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
235 Group2Spin->buttonUndo->setIcon( image1 );
236 Group2Spin->buttonRedo->setIcon( image2 );
238 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
239 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
240 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
241 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
242 Group3Spin->buttonUndo->setIcon( image1 );
243 Group3Spin->buttonRedo->setIcon( image2 );
245 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
246 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
247 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
248 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
249 Group4Spin->buttonUndo->setIcon( image1 );
250 Group4Spin->buttonRedo->setIcon( image2 );
252 GroupRect = new DlgRef_4Spin( MainWidget->SkeletonCnt );
253 GroupRect->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
254 GroupRect->TextLabel1->setText("X1:");
255 GroupRect->TextLabel2->setText("Y1:");
256 GroupRect->TextLabel3->setText("X2:");
257 GroupRect->TextLabel4->setText("Y2:");
259 // Defines a palette for the error message on Group4Spin and Group2Sel
262 palette.setColor(Group4Spin->label->foregroundRole(), color);
263 Group4Spin->label->setPalette(palette);
264 palette.setColor(Group2Sel->label->foregroundRole(), color);
265 Group2Sel->label->setPalette(palette);
267 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
268 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
269 DestCntLayout->addWidget( GroupPt, 0, 0 );
270 DestCntLayout->addWidget( GroupPt2, 0, 1 );
271 DestCntLayout->addWidget( GroupD1, 0, 0 );
272 DestCntLayout->addWidget( GroupD2, 0, 1 );
274 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
275 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
276 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
277 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
278 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
279 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
280 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
281 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
282 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
283 SkeletonCntlayout->addWidget( GroupRect, 0, 0 );
284 //SkeletonCntlayout->setStretch( 0, 1);
285 /***************************************************************/
287 QButtonGroup* ButtonGroup = new QButtonGroup( this );
288 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
289 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
291 /* signals and slots connections */
292 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
293 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
294 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
295 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
297 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
298 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
299 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
300 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
301 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
302 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
303 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
304 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
305 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
306 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
307 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
308 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
309 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
310 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
311 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
312 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
313 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
314 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
315 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
316 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
317 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
319 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
320 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
321 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
322 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
323 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
324 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
326 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
327 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
329 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
330 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
331 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
332 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
334 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
335 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
336 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
338 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
339 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
340 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
341 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
342 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
343 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
344 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
345 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
346 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
347 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
348 connect( GroupRect->SpinBox_DX1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
349 connect( GroupRect->SpinBox_DX2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
350 connect( GroupRect->SpinBox_DY1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
351 connect( GroupRect->SpinBox_DY2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
353 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
354 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
355 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
356 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
358 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ActivateLocalCS() ) );
359 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
360 connect( selButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
362 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
364 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
365 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
367 // install event filter on spin-boxes to provide Apply action on Return pressed
368 Group1Spin->SpinBox_DX->installEventFilter(this);
369 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
370 Group2Spin->SpinBox_DX->installEventFilter(this);
371 Group2Spin->SpinBox_DY->installEventFilter(this);
372 Group3Spin->SpinBox_DX->installEventFilter(this);
373 Group3Spin->SpinBox_DY->installEventFilter(this);
374 Group3Spin->SpinBox_DZ->installEventFilter(this);
375 Group4Spin->SpinBox_DX->installEventFilter(this);
376 Group4Spin->SpinBox_DY->installEventFilter(this);
377 Group4Spin->SpinBox_DZ->installEventFilter(this);
378 Group4Spin->SpinBox_DS->installEventFilter(this);
384 //=================================================================================
385 // function : ~EntityGUI_SketcherDlg()
386 // purpose : Destroys the object and frees any allocated resources
387 //=================================================================================
388 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
390 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
392 myGeometryGUI->SetActiveDialogBox( 0 );
393 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(false);
397 //=================================================================================
398 // function : eventFilter()
399 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
400 //=================================================================================
401 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
403 if (event->type() == QEvent::KeyPress) {
404 QKeyEvent* ke = (QKeyEvent*)event;
405 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
406 if (object == Group1Spin->SpinBox_DX) {
407 Group1Spin->buttonApply->click();
409 } else if (object == Group1Sel1Spin->SpinBox_DX) {
410 Group1Sel1Spin->buttonApply->click();
412 } else if (object == Group2Spin->SpinBox_DX ||
413 object == Group2Spin->SpinBox_DY) {
414 Group2Spin->buttonApply->click();
416 } else if (object == Group3Spin->SpinBox_DX ||
417 object == Group3Spin->SpinBox_DY ||
418 object == Group3Spin->SpinBox_DZ) {
419 Group3Spin->buttonApply->click();
421 } else if (object == Group4Spin->SpinBox_DX ||
422 object == Group4Spin->SpinBox_DY ||
423 object == Group4Spin->SpinBox_DZ ||
424 object == Group4Spin->SpinBox_DS) {
425 Group4Spin->buttonApply->click();
431 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
433 return QDialog::eventFilter(object, event);
437 //=================================================================================
440 //=================================================================================
441 void EntityGUI_SketcherDlg::Init()
446 myEditCurrentArgument = WPlaneLineEdit; // Initiate the parameters selection with the first WPlaneLineEdit
448 myCommand.append( "Sketcher" );
449 myUndoCommand.append( "Sketcher" );
451 mySketchState = FIRST_POINT;
452 globalSelection( GEOM_FACE );
461 myHelpFileName = "create_sketcher_page.html";
463 GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
464 myGlobalCS = aBasicOp->MakeMarker( 0,0,0,
467 myWPlane = myGlobalCS;
468 myLCSList.push_back( WPlaneToLCS(myGlobalCS) );
470 /* Get setting of step value from file configuration */
471 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
473 /* min, max, step and decimals for spin boxes */
474 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
475 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
476 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
477 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
478 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
479 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
480 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
481 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
482 // san: Note specific step values below!
483 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
484 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
485 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
487 initSpinBox( GroupRect->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
488 initSpinBox( GroupRect->SpinBox_DY1, COORD_MIN, COORD_MAX, step, "length_precision" );
489 initSpinBox( GroupRect->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
490 initSpinBox( GroupRect->SpinBox_DY2, COORD_MIN, COORD_MAX, step, "length_precision" );
492 /* displays Dialog */
494 // MainWidget->RadioButton1->setEnabled( false );
495 // MainWidget->RadioButton2->setEnabled( false );
496 // MainWidget->RadioButton3->setEnabled( true );
497 // MainWidget->GroupDest1->setEnabled( false );
498 setEnabledUndo( false );
499 setEnabledRedo( false );
501 MainWidget->RadioButton1->setChecked( true );
505 // If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox
506 // that should be filled with the possibly selected face
510 SelectionIntoArgument();
514 setPrefix(tr("GEOM_SKETCH"));
518 setIsWaitCursorEnabled( false );
519 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
523 //=================================================================================
524 // function : InitClick()
526 //=================================================================================
527 void EntityGUI_SketcherDlg::InitClick()
529 MESSAGE("EntityGUI_SketcherDlg::InitClick()")
530 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
535 Group1Sel1Spin->hide();
541 globalSelection(); // close local selection to clear it
542 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
546 //=================================================================================
547 // function : TypeClicked()
548 // purpose : Radio button management
549 //=================================================================================
550 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
552 myConstructorId = constructorId;
553 MainWidget->buttonEnd->setText(tr("GEOM_BUT_CLOSE"));
554 MainWidget->buttonClose->setEnabled(true);
556 if ( myConstructorId == 0 ) { // SEGMENT
557 GroupPt2->RB_Point1->setChecked( true );
558 GroupPt ->setEnabled( true );
559 GroupPt2->setEnabled( false );
560 GroupD1->setEnabled( true );
561 GroupD2->setEnabled( true );
562 MainWidget->RB_Dest1->setEnabled( true );
563 MainWidget->RB_Dest1->setChecked( true );
565 MainWidget->GroupDest ->setEnabled( true );
566 MainWidget->GroupDest1->setEnabled( true );
567 MainWidget->GroupDest ->show();
568 MainWidget->GroupDest1->show();
570 if (mySketchState == FIRST_POINT)
575 else if ( myConstructorId == 1 ) { // ARC
576 GroupPt ->setEnabled( true );
577 GroupPt2->setEnabled( true );
578 GroupD2->RB_Dir21->setChecked( true );
579 GroupD1->setEnabled( true );
580 GroupD2->setEnabled( false );
581 MainWidget->RB_Dest1->setEnabled( true );
582 MainWidget->RB_Dest1->setChecked( true );
584 MainWidget->GroupDest ->setEnabled( true );
585 MainWidget->GroupDest1->setEnabled( true );
586 MainWidget->GroupDest ->show();
587 MainWidget->GroupDest1->show();
589 if (mySketchState == FIRST_POINT)
594 else if ( myConstructorId == 2 ) { // RECTANGLE
595 GroupPt ->setEnabled( false );
596 GroupPt2->setEnabled( false );
597 GroupD1 ->setEnabled( false );
598 GroupD2 ->setEnabled( false );
599 MainWidget->GroupDest ->setEnabled( false );
600 MainWidget->GroupDest1->setEnabled( false );
606 MainWidget->GroupDest ->hide();
607 MainWidget->GroupDest1->hide();
609 MainWidget->buttonEnd->setText(tr("Apply and Close"));
610 MainWidget->buttonClose->setEnabled(false);
612 GroupRect->setEnabled( true );
613 MainWidget->RadioButton1->setEnabled( true );
614 MainWidget->RadioButton2->setEnabled( true );
620 //=================================================================================
621 // function : RectClicked()
622 // purpose : Radio button management
623 //=================================================================================
624 void EntityGUI_SketcherDlg::RectClicked()
628 // Connect the selction manager (disconnected in InitClick())
629 connect( myGeometryGUI->getApp()->selectionMgr(),
630 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
639 GroupRect->SpinBox_DX1->setValue(myX1);
640 GroupRect->SpinBox_DY1->setValue(myY1);
641 GroupRect->SpinBox_DX2->setValue(myX2);
642 GroupRect->SpinBox_DY2->setValue(myY2);
644 resize( minimumSizeHint() );
646 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
650 //=================================================================================
651 // function : DestClicked()
652 // purpose : Radio button management
653 //=================================================================================
654 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
661 if ( constructorId == 1 ) {
663 GroupPt->RB_Point1->setChecked( true );
666 Group3Spin->checkBox->show();
667 Group4Spin->checkBox->show();
668 PointClicked( 1 ); // XY
670 else if ( constructorId == 0 ) {
672 GroupD1->RB_Dir11->setChecked( true );
675 Group3Spin->checkBox->hide();
676 Group4Spin->checkBox->hide();
677 Dir1Clicked( 2 ); // Angle
679 resize( minimumSizeHint() );
682 //=================================================================================
683 // function : PointClicked()
684 // purpose : Radio button management
685 //=================================================================================
686 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
688 MESSAGE("PointClicked")
689 myConstructorPntId = constructorId;
690 GroupPt->RB_Point3->setEnabled( true );
691 int buttonId = GroupPt2->ButtonGroup->checkedId();
692 if (buttonId >= 0){ // = If a button is checked
693 Point2Clicked(buttonId);
696 GroupPt2->RB_Point1->setChecked( true );
701 //=================================================================================
702 // function : Point2Clicked()
703 // purpose : Radio button management
704 //=================================================================================
705 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
707 MESSAGE("Point2Clicked")
710 // Get setting of step value from file configuration
711 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
713 if ( myConstructorPntId == 1 ) { // XY
714 if ( constructorId == 1 ){ // No additional parameter
715 mySketchType = PT_ABS;
716 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
717 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
718 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
719 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
721 Group2Spin->SpinBox_DX->setValue( myX );
723 Group2Spin->SpinBox_DY->setValue( myY );
725 Group2Spin->buttonApply->setFocus();
727 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
729 else if ( constructorId == 0 ){ // Point + radius
730 mySketchType = PT_ABS_RADIUS;
731 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
732 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
733 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
734 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
735 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
736 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
738 Group3Spin->SpinBox_DX->setValue( myX );
740 Group3Spin->SpinBox_DY->setValue( myY );
742 Group3Spin->SpinBox_DZ->setValue( myRadius );
744 Group3Spin->buttonApply->setFocus();
746 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
748 else if ( constructorId == 2 ){ // Point + center
749 mySketchType = PT_ABS_CENTER;
750 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
751 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
752 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
753 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
754 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
755 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
756 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
757 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
759 Group4Spin->SpinBox_DX->setValue( myXc );
761 Group4Spin->SpinBox_DY->setValue( myYc );
763 Group4Spin->SpinBox_DZ->setValue( myX );
765 Group4Spin->SpinBox_DS->setValue( myY );
767 Group4Spin->buttonApply->setFocus();
769 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
773 else if ( myConstructorPntId == 0 ) { // DXDY
774 if ( constructorId == 1 ){ // No additional parameter
775 mySketchType = PT_RELATIVE;
776 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
777 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
778 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
779 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
781 Group2Spin->SpinBox_DX->setValue( myDX );
783 Group2Spin->SpinBox_DY->setValue( myDY );
785 Group2Spin->buttonApply->setFocus();
787 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
789 else if ( constructorId == 0 ){ // Point + radius
790 mySketchType = PT_REL_RADIUS;
791 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
792 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
793 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
794 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
795 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
796 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
798 Group3Spin->SpinBox_DX->setValue( myDX );
800 Group3Spin->SpinBox_DY->setValue( myDY );
802 Group3Spin->SpinBox_DZ->setValue( myRadius );
804 Group3Spin->buttonApply->setFocus();
806 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
808 else if ( constructorId == 2 ){ // Point + center
809 mySketchType = PT_REL_CENTER;
810 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
811 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
812 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
813 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
814 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
815 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
816 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
817 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
819 Group4Spin->SpinBox_DX->setValue( myDXc );
821 Group4Spin->SpinBox_DY->setValue( myDYc );
823 Group4Spin->SpinBox_DZ->setValue( myDX );
825 Group4Spin->SpinBox_DS->setValue( myDY );
827 Group4Spin->buttonApply->setFocus();
829 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
833 else if ( myConstructorPntId == 2 ) { // Selection
834 if ( constructorId == 1 ){ // No additional parameter
835 mySketchType = PT_SEL;
836 myEditCurrentArgument = Group1Sel->LineEdit1;
837 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
839 Group1Sel->buttonApply->setFocus();
840 SelectionIntoArgument();
842 else if ( constructorId == 0 ){ // Point + radius
843 mySketchType = PT_SEL_RADIUS;
844 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
845 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
846 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
847 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
849 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
851 Group1Sel1Spin->show();
852 Group1Sel1Spin->buttonApply->setFocus();
853 SelectionIntoArgument();
855 else if ( constructorId == 2 ){ // Point + center
856 mySketchType = PT_SEL_CENTER;
857 myEditCurrentArgument = Group2Sel->LineEdit1;
858 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
859 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
860 Group2Sel->LineEdit1->setEnabled(true);
861 Group2Sel->PushButton1->setDown(true);
862 Group2Sel->LineEdit2->setEnabled(false);
863 Group2Sel->PushButton2->setDown(false);
865 Group2Sel->buttonApply->setFocus();
866 SelectionIntoArgument();
870 resize( minimumSizeHint() );
871 connect( myGeometryGUI->getApp()->selectionMgr(),
872 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
877 //=================================================================================
878 // function : Dir1Clicked()
879 // purpose : Radio button management
880 //=================================================================================
881 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
883 myConstructorDirId = constructorId;
884 int dirButtonId = GroupD2->ButtonGroup->checkedId();
885 if (dirButtonId >= 0){ // = If a button is checked
886 Dir2Clicked(dirButtonId);
889 GroupD2->RB_Dir21->setChecked( true );
895 //=================================================================================
896 // function : Dir2Clicked()
897 // purpose : Radio button management
898 //=================================================================================
899 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
904 // Get setting of step value from file configuration
905 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
907 if ( myConstructorId == 0 ) { // SEGMENT
911 if ( myConstructorDirId == 2 ) { // Angle
912 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
913 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
914 Group2Spin->SpinBox_DX->setValue( myAngle );
915 Group2Spin->buttonApply->setFocus();
918 if ( constructorId == 2 ) { // Length
919 mySketchType = DIR_ANGLE_LENGTH;
920 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
921 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
922 Group2Spin->SpinBox_DY->setValue( myLength );
924 else if ( constructorId == 0 ) { // X
925 mySketchType = DIR_ANGLE_X;
926 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
927 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
928 Group2Spin->SpinBox_DY->setValue( myX );
930 else if ( constructorId == 1 ) { // Y
931 mySketchType = DIR_ANGLE_Y;
932 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
933 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
934 Group2Spin->SpinBox_DY->setValue( myY );
937 else if ( myConstructorDirId == 0 ) { // Perpendicular
939 Group1Spin->buttonApply->setFocus();
941 if ( constructorId == 2 ) { // Length
942 mySketchType = DIR_PER_LENGTH;
943 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
944 Group1Spin->SpinBox_DX->setValue( myLength );
946 else if ( constructorId == 0 ) { // X
947 mySketchType = DIR_PER_X;
948 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
949 Group1Spin->SpinBox_DX->setValue( myX );
951 else if ( constructorId == 1 ) { // Y
952 mySketchType = DIR_PER_Y;
953 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
954 Group1Spin->SpinBox_DX->setValue( myY );
957 else if ( myConstructorDirId == 1 ) { // Tangent
959 Group1Spin->buttonApply->setFocus();
961 if ( constructorId == 2 ) { // Length
962 mySketchType = DIR_TAN_LENGTH;
963 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
964 Group1Spin->SpinBox_DX->setValue( myLength );
966 else if ( constructorId == 0 ) { // X
967 mySketchType = DIR_TAN_X;
968 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
969 Group1Spin->SpinBox_DX->setValue( myX );
971 else if ( constructorId == 1 ) { // Y
972 mySketchType = DIR_TAN_Y;
973 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
974 Group1Spin->SpinBox_DX->setValue( myY );
977 else if ( myConstructorDirId == 3 ) { // DXDY
978 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
979 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
980 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
981 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
982 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
984 Group3Spin->SpinBox_DX->setValue( myDX );
986 Group3Spin->SpinBox_DY->setValue( myDY );
988 Group3Spin->buttonApply->setFocus();
990 if ( constructorId == 2 ) { // Length
991 mySketchType = DIR_DXDY_LENGTH;
992 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
993 Group3Spin->SpinBox_DZ->setValue( myLength );
995 else if ( constructorId == 0 ) { // X
996 mySketchType = DIR_DXDY_X;
997 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
998 Group3Spin->SpinBox_DZ->setValue( myX );
1000 else if ( constructorId == 1 ) { // Y
1001 mySketchType = DIR_DXDY_Y;
1002 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
1003 Group3Spin->SpinBox_DZ->setValue( myY );
1007 else if ( myConstructorId == 1 ) { // ARC
1008 if ( myConstructorDirId == 2 ) { // Angle
1009 if ( constructorId == 2 ) { // Length
1010 mySketchType = DIR_ANGLE_LENGTH;
1011 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1012 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1013 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1014 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1015 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1016 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
1017 Group3Spin->SpinBox_DX->setValue( myAngle );
1019 Group3Spin->SpinBox_DY->setValue( myRadius );
1021 Group3Spin->SpinBox_DZ->setValue( myLength );
1023 Group3Spin->buttonApply->setFocus();
1026 else if ( myConstructorDirId == 0 ) { // Perpendicular
1027 if ( constructorId == 2 ) { // Length
1028 mySketchType = DIR_PER_LENGTH;
1029 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1030 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1031 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1032 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1034 Group2Spin->SpinBox_DX->setValue( myRadius );
1036 Group2Spin->SpinBox_DY->setValue( myLength );
1038 Group2Spin->buttonApply->setFocus();
1041 else if ( myConstructorDirId == 1 ) { // Tangent
1042 if ( constructorId == 2 ) { // Length
1043 mySketchType = DIR_TAN_LENGTH;
1044 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1045 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1046 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1047 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1049 Group2Spin->SpinBox_DX->setValue( myRadius );
1051 Group2Spin->SpinBox_DY->setValue( myLength );
1053 Group2Spin->buttonApply->setFocus();
1056 else if ( myConstructorDirId == 3 ) { // DXDY
1057 if ( constructorId == 2 ) { // Length
1058 mySketchType = DIR_DXDY_LENGTH;
1059 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
1060 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
1061 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1062 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1063 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
1064 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
1065 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
1066 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
1068 Group4Spin->SpinBox_DX->setValue( myDX );
1070 Group4Spin->SpinBox_DY->setValue( myDY );
1072 Group4Spin->SpinBox_DZ->setValue( myRadius );
1074 Group4Spin->SpinBox_DS->setValue( myLength );
1076 Group4Spin->buttonApply->setFocus();
1080 resize( minimumSizeHint() );
1081 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1084 //=================================================================================
1085 // function : CheckBoxClicked()
1086 // purpose : CheckBox management
1087 //=================================================================================
1088 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
1090 myCheckFlag = State;
1092 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1096 //=================================================================================
1097 // function : ClickOnCancel()
1099 //=================================================================================
1100 void EntityGUI_SketcherDlg::ClickOnCancel()
1106 //=================================================================================
1107 // function : ClickOnEnd()
1108 // purpose : connected to buttonEnd AND buttonClose
1109 //=================================================================================
1110 void EntityGUI_SketcherDlg::ClickOnEnd()
1112 MESSAGE("EntityGUI_SketcherDlg::ClickOnEnd()")
1113 if ( sender() == MainWidget->buttonClose ) {
1114 // Verify validity of commands
1115 if ( myCommand.count() <= 2 ) {
1116 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
1117 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
1122 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
1123 Sketcher_Profile aProfile( Command.toAscii() );
1125 Command = myCommand.join( "" );
1126 aProfile = Sketcher_Profile( Command.toAscii() );
1127 TopoDS_Shape myShape;
1128 if ( aProfile.IsDone() )
1129 myShape = aProfile.GetShape();
1131 if ( myShape.ShapeType() != TopAbs_VERTEX )
1132 myCommand.append( ":WW" );
1135 /*// PAL16008 (Sketcher Validation should be equal to Apply&Close)
1136 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
1137 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
1138 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
1139 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
1140 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
1141 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
1142 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
1145 // ClickOnApply(); // TEST remove then
1146 myIsAllAdded = true;
1149 if (myConstructorId == 2)
1151 QString aParameters;
1152 myCommand.append( GetNewCommand( aParameters ) );
1153 mySketchState = NEXT_POINT;
1157 if ( myCommand.size() > 2 )
1166 //=================================================================================
1167 // function : ClickOnApply()
1169 //=================================================================================
1170 bool EntityGUI_SketcherDlg::ClickOnApply()
1172 MESSAGE("EntityGUI_SketcherDlg::ClickOnApply()")
1173 if ( sender() && sender()->inherits( "QPushButton" ) )
1174 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1176 // addSubshapesToStudy();
1178 QString aParameters;
1179 myCommand.append( GetNewCommand( aParameters ) );
1180 if (mySketchState == FIRST_POINT)
1182 mySketchState = NEXT_POINT;
1186 myUndoCommand.clear();
1187 myUndoCommand.append( "Sketcher" );
1189 myParameters.append( aParameters );
1190 myUndoParameters.clear();
1192 setEnabledUndo( true );
1193 setEnabledRedo( false );
1196 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1199 // Set focus to SpinBox_DX
1200 if ( sender() == Group1Spin->buttonApply ) {
1201 (Group1Spin->SpinBox_DX)->setFocus();
1202 (Group1Spin->SpinBox_DX)->selectAll();
1204 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1205 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1206 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1208 else if ( sender() == Group2Spin->buttonApply ) {
1209 (Group2Spin->SpinBox_DX)->setFocus();
1210 (Group2Spin->SpinBox_DX)->selectAll();
1212 else if ( sender() == Group3Spin->buttonApply ) {
1213 (Group3Spin->SpinBox_DX)->setFocus();
1214 (Group3Spin->SpinBox_DX)->selectAll();
1216 else if ( sender() == Group4Spin->buttonApply ) {
1217 (Group4Spin->SpinBox_DX)->setFocus();
1218 (Group4Spin->SpinBox_DX)->selectAll();
1224 //=================================================================================
1225 // function : ClickOnHelp()
1227 //=================================================================================
1228 void EntityGUI_SketcherDlg::ClickOnHelp()
1230 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1232 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1236 platform = "winapplication";
1238 platform = "application";
1241 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1242 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1243 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1244 QObject::tr( "BUT_OK" ) );
1248 //=================================================================================
1249 // function : ClickOnUndo()
1251 //=================================================================================
1252 void EntityGUI_SketcherDlg::ClickOnUndo()
1254 myUndoCommand.append( myCommand.last() );
1255 myCommand.pop_back();
1257 myUndoParameters.append( myParameters.last() );
1258 myParameters.pop_back();
1260 if ( myCommand.count() == 1 ) {
1261 mySketchState = FIRST_POINT;
1263 MainWidget->RadioButton1->setChecked( true );
1266 connect( myGeometryGUI->getApp()->selectionMgr(),
1267 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1271 setEnabledUndo( false );
1274 setEnabledRedo( true );
1276 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1279 //=================================================================================
1280 // function : ClickOnRedo()
1282 //=================================================================================
1283 void EntityGUI_SketcherDlg::ClickOnRedo()
1285 myCommand.append( myUndoCommand.last() );
1286 myUndoCommand.pop_back();
1288 myParameters.append( myUndoParameters.last() );
1289 myUndoParameters.pop_back();
1291 mySketchState = NEXT_POINT;
1295 setEnabledUndo( true );
1297 if ( myUndoCommand.count() == 1 )
1298 setEnabledRedo( false );
1300 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1303 //=================================================================================
1304 // function : setEnabledUndo()
1306 //=================================================================================
1307 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1309 Group1Sel->buttonUndo->setEnabled( value );
1310 Group2Sel->buttonUndo->setEnabled( value );
1311 Group1Sel1Spin->buttonUndo->setEnabled( value );
1312 Group1Spin->buttonUndo->setEnabled( value );
1313 Group2Spin->buttonUndo->setEnabled( value );
1314 Group3Spin->buttonUndo->setEnabled( value );
1315 Group4Spin->buttonUndo->setEnabled( value );
1318 //=================================================================================
1319 // function : setEnabledRedo()
1321 //=================================================================================
1322 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1324 Group1Sel->buttonRedo->setEnabled( value );
1325 Group2Sel->buttonRedo->setEnabled( value );
1326 Group1Sel1Spin->buttonRedo->setEnabled( value );
1327 Group1Spin->buttonRedo->setEnabled( value );
1328 Group2Spin->buttonRedo->setEnabled( value );
1329 Group3Spin->buttonRedo->setEnabled( value );
1330 Group4Spin->buttonRedo->setEnabled( value );
1333 //=================================================================================
1334 // function : SelectionIntoArgument()
1335 // purpose : Called when selection as changed
1336 //=================================================================================
1337 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1339 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1340 myEditCurrentArgument->setText( "" );
1342 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1343 SALOME_ListIO aSelList;
1344 aSelMgr->selectedObjects(aSelList);
1346 this->activateWindow();
1348 if (aSelList.Extent() == 0)
1350 selButton->setDown(false);
1351 WPlaneLineEdit->setEnabled(false);
1352 WPlaneLineEdit->setText(tr("GEOM_SKETCHER_WPLANE"));
1355 else if (aSelList.Extent() != 1)
1363 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
1364 if (myEditCurrentArgument == WPlaneLineEdit)
1365 aNeedType = TopAbs_FACE;
1368 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
1369 TopoDS_Shape aShape;
1371 if(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape)
1372 && !aShape.IsNull())
1374 QString aName = GEOMBase::GetName( aSelectedObject.get() );
1375 if (myEditCurrentArgument==WPlaneLineEdit)
1377 // Check if the face is planar
1378 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
1379 GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion());
1381 if (aPlanarCheck.IsPlanar())
1383 myEditCurrentArgument->setText(aName);
1384 AddLocalCS(aSelectedObject.get());
1385 selButton->setDown(false);
1386 WPlaneLineEdit->setEnabled(false);
1387 TypeClicked( myConstructorId );
1391 myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE"));
1392 // The following leads to crash TODO : find a way to return a warning
1393 // Standard_Failure::Raise(tr("GEOM_SKETCHER_NOT_PLANAR").toStdString().c_str());
1399 gp_Ax3 aWPlane = GetActiveLocalCS();
1401 aTrans.SetTransformation(aWPlane);
1402 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1403 aShape = aTransformation.Shape();
1406 if ( GEOMBase::VertexToPoint( aShape, aPnt ) )
1408 myEditCurrentArgument->setText(aName);
1411 double Xcoord = myX;
1412 double Ycoord = myY;
1414 switch (mySketchType)
1417 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1418 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1420 Group2Spin->SpinBox_DX->setValue(Xcoord);
1421 Group2Spin->SpinBox_DY->setValue(Ycoord);
1423 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1424 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1428 if (myLastX1 && myLastY1)
1430 Xcoord = myX - myLastX1;
1431 Ycoord = myY - myLastY1;
1433 else if (mySketchState != FIRST_POINT)
1435 Xcoord = myX - tmpX;
1436 Ycoord = myY - tmpY;
1438 Group2Spin->SpinBox_DX->setValue(Xcoord);
1439 Group2Spin->SpinBox_DY->setValue(Ycoord);
1443 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1444 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1446 Group3Spin->SpinBox_DX->setValue(Xcoord);
1447 Group3Spin->SpinBox_DY->setValue(Ycoord);
1449 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1450 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1454 if (myLastX1 && myLastY1)
1456 Xcoord = myX - myLastX1;
1457 Ycoord = myY - myLastY1;
1459 else if (mySketchState != FIRST_POINT)
1461 Xcoord = myX - tmpX;
1462 Ycoord = myY - tmpY;
1464 Group3Spin->SpinBox_DX->setValue(Xcoord);
1465 Group3Spin->SpinBox_DY->setValue(Ycoord);
1469 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1470 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1472 Group4Spin->SpinBox_DX->setValue(Xcoord);
1473 Group4Spin->SpinBox_DY->setValue(Ycoord);
1475 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1476 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1480 if (myLastX1 && myLastY1)
1482 Xcoord = myXc - myLastX1;
1483 Ycoord = myYc - myLastY1;
1485 else if (mySketchState != FIRST_POINT)
1487 Xcoord = myXc - tmpX;
1488 Ycoord = myYc - tmpY;
1496 Group4Spin->SpinBox_DX->setValue(Xcoord);
1497 Group4Spin->SpinBox_DY->setValue(Ycoord);
1506 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1516 //=================================================================================
1517 // function : SetEditCurrentArgument()
1519 //=================================================================================
1520 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1522 TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX;
1523 if ( sender() == Group1Sel->PushButton1 ) {
1524 myEditCurrentArgument = Group1Sel->LineEdit1;
1525 myEditCurrentArgument->setFocus();
1527 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1528 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1529 myEditCurrentArgument->setFocus();
1531 else if ( sender() == Group2Sel->PushButton1 ) {
1532 myEditCurrentArgument = Group2Sel->LineEdit1;
1533 Group2Sel->PushButton2->setDown(false);
1534 Group2Sel->PushButton1->setDown(true);
1535 Group2Sel->LineEdit2->setEnabled(false);
1536 Group2Sel->LineEdit1->setEnabled(true);
1537 // myEditCurrentArgument->setFocus();
1539 else if ( sender() == Group2Sel->PushButton2 ) {
1540 myEditCurrentArgument = Group2Sel->LineEdit2;
1541 Group2Sel->PushButton1->setDown(false);
1542 Group2Sel->PushButton2->setDown(true);
1543 Group2Sel->LineEdit1->setEnabled(false);
1544 Group2Sel->LineEdit2->setEnabled(true);
1545 // myEditCurrentArgument->setFocus();
1547 else if ( sender() == selButton ) {
1548 myNeedType = TopAbs_FACE;
1549 myEditCurrentArgument = WPlaneLineEdit;
1550 WPlaneLineEdit->setEnabled(true);
1551 selButton->setDown(true);
1553 globalSelection(); // close local selection to clear it
1554 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
1558 //=================================================================================
1559 // function : LineEditReturnPressed()
1561 //=================================================================================
1562 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1564 if ( sender() == Group1Sel->LineEdit1 )
1565 myEditCurrentArgument = Group1Sel->LineEdit1;
1566 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1567 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1568 else if ( sender() == Group2Sel->LineEdit1 )
1569 myEditCurrentArgument = Group2Sel->LineEdit1;
1570 else if ( sender() == Group2Sel->LineEdit2 )
1571 myEditCurrentArgument = Group2Sel->LineEdit2;
1573 /* User name of object input management */
1574 /* If successfull the selection is changed and signal emitted... */
1575 /* so SelectionIntoArgument() is automatically called. */
1576 const QString objectUserName = myEditCurrentArgument->text();
1577 QWidget* thisWidget = (QWidget*)this;
1579 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1580 SALOME_ListIO aSelList;
1581 aSelMgr->selectedObjects(aSelList);
1583 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1584 myEditCurrentArgument->setText( objectUserName );
1588 //=================================================================================
1589 // function : DeactivateActiveDialog()
1591 //=================================================================================
1592 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1594 //myGeometryGUI->SetState( -1 );
1596 setEnabled( false );
1598 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1599 myGeometryGUI->SetActiveDialogBox( 0 );
1603 //=================================================================================
1604 // function : ActivateThisDialog()
1606 //=================================================================================
1607 void EntityGUI_SketcherDlg::ActivateThisDialog()
1609 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1610 myGeometryGUI->EmitSignalDeactivateDialog();
1612 myGeometryGUI->SetActiveDialogBox( this );
1614 connect( myGeometryGUI->getApp()->selectionMgr(),
1615 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1617 //myGeometryGUI->SetState( 0 );
1618 // globalSelection( GEOM_POINT );
1620 myEditCurrentArgument = WPlaneLineEdit;
1621 myEditCurrentArgument->setFocus();
1623 if ( sender() == Group1Sel->LineEdit1 ) {
1624 myEditCurrentArgument = Group1Sel->LineEdit1;
1625 myEditCurrentArgument->setFocus();
1627 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1628 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1629 myEditCurrentArgument->setFocus();
1631 else if ( sender() == Group2Sel->LineEdit1 ) {
1632 myEditCurrentArgument = Group2Sel->LineEdit1;
1633 myEditCurrentArgument->setFocus();
1635 else if ( sender() == Group2Sel->LineEdit2 ) {
1636 myEditCurrentArgument = Group2Sel->LineEdit2;
1637 myEditCurrentArgument->setFocus();
1640 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1644 //=================================================================================
1645 // function : enterEvent [REDEFINED]
1647 //=================================================================================
1648 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1651 ActivateThisDialog();
1655 //=================================================================================
1656 // function : closeEvent()
1658 //=================================================================================
1659 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1661 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1662 //myGeometryGUI->SetState( -1 );
1663 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1664 myGeometryGUI->getApp()->updateActions();
1665 QDialog::closeEvent( e );
1668 //=================================================================================
1669 // function : OnPointSelected
1671 //=================================================================================
1672 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt,
1675 // NOTE Basing the autoapply functionnality on the background picture has no sense anymore
1676 // The import picture functionnality is now used for drawing on top of a picture
1678 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
1679 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
1681 // QString theImgFileName;
1682 // vp->background().texture( theImgFileName ); ////////////// VSR: temporarily
1687 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1688 TopoDS_Shape aShape = mkVertex.Shape();
1690 // Taking into account LocalCS
1691 gp_Ax3 aWPlane = GetActiveLocalCS();
1694 aTrans.SetTransformation(aWPlane);
1695 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1696 aShape = aTransformation.Shape();
1699 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1701 // NOTE autoapply disabled : doesn't seem useful anymore
1702 // autoApply = ( (getPnt2ConstructorId() == 1) && (!theImgFileName.isEmpty()) ); // If no additional argument needed after selection and there is a backgroundimage
1703 // -> apply automatically
1705 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1706 x = aTrsfPnt.X() - myLastX1;
1707 y = aTrsfPnt.Y() - myLastY1;
1713 switch (getPnt2ConstructorId()){
1715 Group2Spin->SpinBox_DX->setValue( x );
1716 Group2Spin->SpinBox_DY->setValue( y );
1717 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1720 Group3Spin->SpinBox_DX->setValue( x );
1721 Group3Spin->SpinBox_DY->setValue( y );
1722 Group3Spin->buttonApply->setFocus();
1725 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1726 Group4Spin->SpinBox_DX->setValue( x );
1727 Group4Spin->SpinBox_DY->setValue( y );
1729 else{ // Select end point
1730 Group4Spin->SpinBox_DZ->setValue( x );
1731 Group4Spin->SpinBox_DS->setValue( y );
1733 Group4Spin->buttonApply->setFocus();
1736 if ( myConstructorId == 2 ) //RECTANGLE
1740 GroupRect->SpinBox_DX1->setValue( aTrsfPnt.X() );
1741 GroupRect->SpinBox_DY1->setValue( aTrsfPnt.Y() );
1742 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1743 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1747 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1748 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1753 //=================================================================================
1754 // function : OnFirstPoint
1756 //=================================================================================
1757 void EntityGUI_SketcherDlg::OnFirstPoint()
1759 MainWidget->RadioButton3->setEnabled( true );
1760 MainWidget->GroupDest1->setEnabled( false );
1761 GroupPt2->setEnabled( false );
1764 //=================================================================================
1765 // function : OnNextPoint
1767 //=================================================================================
1768 void EntityGUI_SketcherDlg::OnNextPoint()
1770 MainWidget->RadioButton3->setEnabled( false );
1771 MainWidget->GroupDest1->setEnabled( true );
1772 TypeClicked(myConstructorId);
1775 //=================================================================================
1776 // function : ValueChangedInSpinBox()
1778 //=================================================================================
1779 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1781 QObject* send = (QObject*)sender();
1782 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1783 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1785 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1786 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1787 double LastDecimal = 0.0;
1789 QString vxStr, vyStr, vzStr, vsStr;
1791 QString newValueStr;
1792 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1793 newValueStr = aDoubleSpinBox->text();
1795 if ( send == Group1Spin->SpinBox_DX ) {
1796 vx = newValue; vxStr = newValueStr;
1798 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1799 vx = newValue; vxStr = newValueStr;
1801 else if ( send == Group2Spin->SpinBox_DX ) {
1802 vx = newValue; vxStr = newValueStr;
1803 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1805 else if ( send == Group2Spin->SpinBox_DY ) {
1806 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1807 vy = newValue; vyStr = newValueStr;
1809 else if ( send == Group3Spin->SpinBox_DX ) {
1810 vx = newValue; vxStr = newValueStr;
1811 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1812 vz = Group3Spin->SpinBox_DZ->value();
1813 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1814 if (mySketchType == PT_ABS_RADIUS){
1822 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1823 if (aPrecision >= 0) // 'f' format in the QString
1824 LastDecimal = aPrecision;
1825 else // 'g' format in the Qstring
1826 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1827 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1828 if ( Abs(vz) < minRad){
1830 Group3Spin->SpinBox_DZ->setValue( - minRad );
1832 Group3Spin->SpinBox_DZ->setValue( minRad );
1835 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1837 else if ( send == Group3Spin->SpinBox_DY ) {
1838 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1839 vy = newValue; vyStr = newValueStr;
1840 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1841 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1842 if (mySketchType == PT_ABS_RADIUS){
1850 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1851 if (aPrecision >= 0) // 'f' format in the QString
1852 LastDecimal = aPrecision;
1853 else // 'g' format in the QString
1854 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1855 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1856 if ( Abs(vz) < minRad){
1858 Group3Spin->SpinBox_DZ->setValue( - minRad );
1860 Group3Spin->SpinBox_DZ->setValue( minRad );
1863 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1865 else if ( send == Group3Spin->SpinBox_DZ ) {
1866 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1867 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1868 vz = newValue; vzStr = newValueStr;
1870 else if ( send == Group4Spin->SpinBox_DX ) {
1871 vx = newValue; vxStr = newValueStr;
1872 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1873 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1874 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1876 else if ( send == Group4Spin->SpinBox_DY ) {
1877 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1878 vy = newValue; vyStr = newValueStr;
1879 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1880 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1882 else if ( send == Group4Spin->SpinBox_DZ ) {
1883 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1884 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1885 vz = newValue; vzStr = newValueStr;
1886 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1888 else if ( send == Group4Spin->SpinBox_DS ) {
1889 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1890 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1891 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1892 vs = newValue; vsStr = newValueStr;
1894 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1896 if ( myConstructorId == 0 ) { // SEGMENT
1897 if ( mySketchType == PT_ABS ) {
1903 else if ( mySketchType == PT_RELATIVE ) {
1909 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1913 myLengthStr = vyStr;
1915 else if ( mySketchType == DIR_ANGLE_X ) {
1921 else if ( mySketchType == DIR_ANGLE_Y ) {
1927 else if ( mySketchType == DIR_PER_LENGTH ) {
1929 myLengthStr = vxStr;
1931 else if ( mySketchType == DIR_PER_X ) {
1935 else if ( mySketchType == DIR_PER_Y ) {
1939 else if ( mySketchType == DIR_TAN_LENGTH ) {
1941 myLengthStr = vxStr;
1943 else if ( mySketchType == DIR_TAN_X ) {
1947 else if ( mySketchType == DIR_TAN_Y ) {
1951 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1957 myLengthStr = vzStr;
1959 else if ( mySketchType == DIR_DXDY_X ) {
1967 else if ( mySketchType == DIR_DXDY_Y ) {
1976 else if ( myConstructorId == 1 ) { // ARC
1977 if ( mySketchType == PT_ABS ) {
1983 else if ( mySketchType == PT_RELATIVE ) {
1989 if ( mySketchType == PT_ABS_RADIUS ) {
1995 myRadiusStr = vzStr;
1997 else if ( mySketchType == PT_REL_RADIUS ) {
2003 myRadiusStr = vzStr;
2005 else if ( mySketchType == PT_SEL_RADIUS ) {
2007 myRadiusStr = vxStr;
2009 if ( mySketchType == PT_ABS_CENTER ) {
2019 else if ( mySketchType == PT_REL_CENTER ) {
2029 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2034 myRadiusStr = vyStr;
2035 myLengthStr = vzStr;
2037 else if ( mySketchType == DIR_PER_LENGTH ) {
2040 myRadiusStr = vxStr;
2041 myLengthStr = vyStr;
2043 else if ( mySketchType == DIR_TAN_LENGTH ) {
2046 myRadiusStr = vxStr;
2047 myLengthStr = vyStr;
2049 else if ( mySketchType == DIR_DXDY_LENGTH ) {
2056 myRadiusStr = vzStr;
2057 myLengthStr = vsStr;
2060 else if ( myConstructorId == 2 ) { // RECTANGLE
2061 myX1 = GroupRect->SpinBox_DX1->value(); myX1Str = GroupRect->SpinBox_DX1->text();
2062 myX2 = GroupRect->SpinBox_DX2->value(); myX2Str = GroupRect->SpinBox_DX2->text();
2063 myY1 = GroupRect->SpinBox_DY1->value(); myY1Str = GroupRect->SpinBox_DY1->text();
2064 myY2 = GroupRect->SpinBox_DY2->value(); myY2Str = GroupRect->SpinBox_DY2->text();
2069 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
2071 double x, y, xc, yc;
2072 x = y = xc = yc = 0.0;
2073 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
2075 if ( mySketchType == PT_REL_CENTER ){
2076 x = myDX + myLastX1;
2077 y = myDY + myLastY1;
2078 xc = myDXc + myLastX1;
2079 yc = myDYc + myLastY1;
2087 displayPntPreview(xc,yc);
2088 displayPntPreview(x,y);
2093 //=================================================================================
2094 // function : GetNewCommand()
2095 // purpose : Build the new command with context
2096 //=================================================================================
2097 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
2099 theParameters.clear();
2100 QString myNewCommand = ":";
2101 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2102 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2103 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2105 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2106 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2108 if ( mySketchState == FIRST_POINT ) {
2109 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2110 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2111 theParameters = myXStr + ":" + myYStr;
2113 if ( mySketchType == PT_RELATIVE) {
2114 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2115 theParameters = myDXStr + ":" + myDYStr;
2117 if (myConstructorId == 2 )
2120 return myNewCommand;
2123 if ( myConstructorId == 0 ) { // SEGMENT
2124 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2125 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2126 theParameters = myXStr + ":" + myYStr;
2128 if ( mySketchType == PT_RELATIVE) {
2129 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2130 theParameters = myDXStr + ":" + myDYStr;
2132 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2133 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2134 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2135 theParameters = myAngleStr + ":" + myLengthStr;
2137 if ( mySketchType == DIR_ANGLE_X ) {
2138 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2139 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2140 theParameters = myAngleStr + ":" + myXStr;
2142 if ( mySketchType == DIR_ANGLE_Y ) {
2143 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2144 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2145 theParameters = myAngleStr + ":" + myYStr;
2147 if ( mySketchType == DIR_PER_LENGTH ) {
2148 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2149 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2150 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
2152 if ( mySketchType == DIR_PER_X ) {
2153 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2154 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2155 theParameters = QString::number( 90.0 ) + ":" + myXStr;
2157 if ( mySketchType == DIR_PER_Y ) {
2158 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2159 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2160 theParameters = QString::number( 90.0 ) + ":" + myYStr;
2162 if ( mySketchType == DIR_TAN_LENGTH ) {
2163 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
2164 theParameters = myLengthStr;
2166 if ( mySketchType == DIR_TAN_X ) {
2167 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
2168 theParameters = myXStr;
2170 if ( mySketchType == DIR_TAN_Y) {
2171 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
2172 theParameters = myYStr;
2174 if ( mySketchType == DIR_DXDY_LENGTH ) {
2175 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2176 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2177 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
2179 if ( mySketchType == DIR_DXDY_X ) {
2180 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2181 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2182 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
2184 if ( mySketchType == DIR_DXDY_Y ) {
2185 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2186 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2187 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
2190 else if ( myConstructorId == 1 ) { // ARC
2191 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2192 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2193 theParameters = myXStr + ":" + myYStr;
2195 if ( mySketchType == PT_RELATIVE) {
2196 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2197 theParameters = myDXStr + ":" + myDYStr;
2199 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
2200 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
2201 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
2203 if ( mySketchType == PT_REL_RADIUS) {
2204 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
2205 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
2207 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2208 myNewCommand = myNewCommand + "EE " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myXc , Format, DigNum) + " " + QString::number( myYc , Format, DigNum)+ " " + QString::number( myCheckFlag ) + " " + QString::number( 0 );
2209 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2211 if ( mySketchType == PT_REL_CENTER) {
2212 myNewCommand = myNewCommand + "E " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myDXc, Format, DigNum )+ " " + QString::number( myDYc, Format, DigNum )+ " " + QString::number( myCheckFlag )+ " " + QString::number( 0 );
2213 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2215 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2216 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2217 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2218 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2220 if ( mySketchType == DIR_PER_LENGTH ) {
2221 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2222 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2223 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2225 if ( mySketchType == DIR_TAN_LENGTH ) {
2226 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2227 theParameters = myRadiusStr + ":" + myLengthStr;
2229 if ( mySketchType == DIR_DXDY_LENGTH ) {
2230 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2231 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2232 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2235 else if ( myConstructorId == 2 ) { // RECTANGLE
2236 myNewCommand = myNewCommand + "F " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2237 + ":TT " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2238 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2239 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2242 theParameters = myX1Str + ":" + myY1Str + ":" + myX2Str + ":" + myY2Str ;
2244 return myNewCommand;
2247 //=================================================================================
2248 // function : createOperation
2250 //=================================================================================
2251 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2253 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2256 //=================================================================================
2257 // function : isValid
2259 //=================================================================================
2260 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2263 bool toCorrect = !IsPreview() || myIsApply;
2265 if( Group1Spin->isVisible() ) {
2266 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2268 else if( Group1Sel1Spin->isVisible() ) {
2269 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2271 else if( Group2Spin->isVisible() ) {
2272 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2273 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2275 else if( Group3Spin->isVisible() ) {
2276 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2277 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2278 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2280 else if( Group4Spin->isVisible() ) {
2281 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2282 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2283 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2284 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2287 if( myIsApply && !ok )
2293 //=================================================================================
2294 // function : execute
2296 //=================================================================================
2297 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2299 MESSAGE("EntityGUI_SketcherDlg::execute")
2300 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2301 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2302 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2304 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2305 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2307 QString aParameters;
2309 if ( mySketchState == FIRST_POINT ) {
2314 //Test if the current point is the same as the last one
2315 TopoDS_Shape myShape1, myShape2;
2317 // Set "C" numeric locale
2318 Kernel_Utils::Localizer loc;
2321 QString Command1 = myCommand.join( "" );
2322 Sketcher_Profile aProfile1( Command1.toAscii() );
2323 if ( aProfile1.IsDone() )
2324 myShape1 = aProfile1.GetShape();
2327 QString Command2 = Command1 + GetNewCommand( aParameters );
2328 Sketcher_Profile aProfile2( Command2.toAscii() );
2331 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2332 if (aProfile2.Error() > Precision::Confusion()){
2333 Group4Spin->label->show();
2334 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2337 Group4Spin->label->hide();
2341 Group4Spin->label->hide();
2342 if ( mySketchType == PT_SEL_CENTER ){
2343 if (aProfile2.Error() > Precision::Confusion()){
2344 Group2Sel->label->show();
2345 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2348 Group2Sel->label->hide();
2352 Group2Sel->label->hide();
2354 if ( aProfile2.IsDone() )
2355 myShape2 = aProfile2.GetShape();
2357 if ( myShape2.IsNull() ) {
2358 //the current point is the same as the last one
2359 myLastX2 = myLastX1;
2360 myLastY2 = myLastY1;
2363 TopoDS_Vertex V1, V2;
2365 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2366 //the last shape is the first point
2367 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2372 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2373 pt = BRep_Tool::Pnt( V2 );
2377 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2378 pt = BRep_Tool::Pnt( V2 );
2385 if ( ( mySketchState != FIRST_POINT &&
2386 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2387 cmd = myCommand.join( "" );
2388 if ( Group1Sel->isVisible() ) {
2389 Group1Sel->buttonApply->setEnabled( false );
2390 //Group1Sel->buttonApply->setFocus();
2392 if ( Group2Sel->isVisible() ) {
2393 Group2Sel->buttonApply->setEnabled( false );
2394 //Group2Sel->buttonApply->setFocus();
2396 if ( Group1Sel1Spin->isVisible() ) {
2397 Group1Sel1Spin->buttonApply->setEnabled( false );
2398 //Group1Sel1Spin->buttonApply->setFocus();
2400 if ( Group1Spin->isVisible() ) {
2401 Group1Spin->buttonApply->setEnabled( false );
2402 //Group1Spin->buttonApply->setFocus();
2404 if ( Group2Spin->isVisible() ) {
2405 Group2Spin->buttonApply->setEnabled( false );
2406 //Group2Spin->buttonApply->setFocus();
2408 if ( Group3Spin->isVisible() ) {
2409 Group3Spin->buttonApply->setEnabled( false );
2410 //Group3Spin->buttonApply->setFocus();
2412 if ( Group4Spin->isVisible() ) {
2413 Group4Spin->buttonApply->setEnabled( false );
2414 //Group4Spin->buttonApply->setFocus();
2418 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2420 if ( Group1Sel->isVisible() ) {
2421 Group1Sel->buttonApply->setEnabled( true );
2423 if ( Group2Sel->isVisible() ) {
2424 Group2Sel->buttonApply->setEnabled( true );
2426 if ( Group1Sel1Spin->isVisible() ) {
2427 Group1Sel1Spin->buttonApply->setEnabled( true );;
2429 if ( Group1Spin->isVisible() ) {
2430 Group1Spin->buttonApply->setEnabled( true );
2432 if ( Group2Spin->isVisible() ) {
2433 Group2Spin->buttonApply->setEnabled( true );
2435 if ( Group3Spin->isVisible() ) {
2436 Group3Spin->buttonApply->setEnabled( true );
2438 if ( Group4Spin->isVisible() ) {
2439 Group4Spin->buttonApply->setEnabled( true );
2443 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2444 GEOM::GEOM_Object_var anObj = NULL;
2446 int index = ComboBox1->currentIndex();
2447 if(index != -1 && !myWPlane->_is_nil()) // The combobox is not empty
2449 anObj = anOper->MakeSketcherOnPlane( cmd.toLatin1().constData(), myWPlane );
2451 if ( !anObj->_is_nil() )
2453 if( !IsPreview() ) {
2454 QStringList aCurrentParameters = myParameters;
2455 aCurrentParameters << aParameters;
2456 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2459 objects.push_back( anObj._retn() );
2465 //================================================================
2466 // Function : displayPreview
2467 // Purpose : Method for displaying preview of resulting shape
2468 // Redefined from GEOMBase_Helper.
2469 //================================================================
2470 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2472 const bool activate,
2474 const double lineWidth,
2475 const int displayMode,
2478 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2480 QColor aColor = resMgr->colorValue("Geometry","line_color",QColor(255,0,0));
2481 Quantity_NameOfColor line_color = SalomeApp_Tools::color( aColor ).Name();
2483 // set width of displayed shape
2486 lw = resMgr->integerValue("Geometry", "preview_edge_width", -1);
2488 getDisplayer()->SetWidth( lw );
2490 // Disable activation of selection
2491 getDisplayer()->SetToActivate( activate );
2493 // Make a reference to GEOM_Object
2494 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2495 getDisplayer()->SetName( objStr.in() );
2497 // Create wire from applied object
2498 TopoDS_Shape anApplyedWire, aLastSegment;
2499 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2503 if( myConstructorId != 2)
2504 getDisplayer()->SetColor( line_color );
2506 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2508 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2509 if ( aPrs != 0 && !aPrs->IsNull() )
2510 GEOMBase_Helper::displayPreview( aPrs, append, update );
2512 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2513 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2515 if ( aPrs != 0 && !aPrs->IsNull() )
2516 GEOMBase_Helper::displayPreview( aPrs, append, update );
2518 getDisplayer()->SetColor( line_color );
2520 getDisplayer()->UnsetName();
2522 // Enable activation of displayed objects
2523 getDisplayer()->SetToActivate( true );
2526 //================================================================
2527 // Function : displayPntPreview
2528 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2529 //================================================================
2530 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2536 // Get globalCS and working plane
2537 gp_Ax3 globalCS = WPlaneToLCS( myGlobalCS );
2538 gp_Ax3 aWPlane = GetActiveLocalCS();
2540 // Build point in localCS
2541 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2543 // Get transfomation from local to global CS
2545 aTrans.SetTransformation(aWPlane, globalCS);
2547 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2548 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2550 // Perform transformation
2551 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2552 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2554 // Build prs with vertex in globalCS
2555 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2556 if ( aPrs != 0 && !aPrs->IsNull() )
2557 GEOMBase_Helper::displayPreview( aPrs, append, update );
2561 //================================================================
2562 // Function : createShapes
2563 // Purpose : Create applyed wire, and last segment from entry object
2564 //================================================================
2565 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2566 TopoDS_Shape& theApplyedWire,
2567 TopoDS_Shape& theLastSegment )
2569 TopoDS_Shape aShape;
2570 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2571 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2574 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2575 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2576 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2577 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2578 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2579 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2580 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2581 theApplyedWire = aShape;
2585 BRepBuilderAPI_MakeWire aBuilder;
2586 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2588 TopoDS_Shape anEdge = anExp.Current();
2590 if ( anExp.More() ) // i.e. non-last edge
2591 aBuilder.Add( TopoDS::Edge( anEdge ) );
2593 theLastSegment = anEdge;
2598 if ( aBuilder.IsDone() )
2599 theApplyedWire = aBuilder.Shape();
2604 //=================================================================================
2605 // function : acceptMouseEvent()
2607 //=================================================================================
2608 bool EntityGUI_SketcherDlg::acceptMouseEvent() const
2610 return ( (getPnt1ConstructorId() == 1
2611 || getPnt1ConstructorId() == 0
2612 || myConstructorId == 2) //accept mouse event only on absolute and relative selection mode
2613 && !WPlaneLineEdit->isEnabled()); //or when the constructor is rectangle
2614 //called by EntityGUI::OnMousePress()
2617 //=================================================================================
2618 // function : keyPressEvent()
2620 //=================================================================================
2621 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2623 QDialog::keyPressEvent( e );
2624 if ( e->isAccepted() )
2627 if ( e->key() == Qt::Key_F1 ) {
2633 //=================================================================================
2634 // function : initSpinBox()
2636 //=================================================================================
2637 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2638 double min, double max,
2639 double step, const char* quantity )
2641 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2642 // TODO: Think how to keep the single piece of code...
2644 // Obtain precision from preferences
2645 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2646 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2648 spinBox->setPrecision( aPrecision );
2649 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2650 // by default Qt rounds boundaries to 2 decimals at setRange
2651 spinBox->setRange( min, max );
2652 spinBox->setSingleStep( step );
2654 // Add a hint for the user saying how to tune precision
2655 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2656 spinBox->setProperty( "validity_tune_hint",
2657 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2660 //=================================================================================
2661 // function : SetDoubleSpinBoxStep()
2662 // purpose : Double spin box management
2663 //=================================================================================
2664 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2666 Group1Spin->SpinBox_DX->setSingleStep(step);
2667 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2668 Group2Spin->SpinBox_DX->setSingleStep(step);
2669 Group2Spin->SpinBox_DY->setSingleStep(step);
2670 Group3Spin->SpinBox_DX->setSingleStep(step);
2671 Group3Spin->SpinBox_DY->setSingleStep(step);
2672 Group3Spin->SpinBox_DZ->setSingleStep(step);
2673 Group4Spin->SpinBox_DZ->setSingleStep(step);
2675 // san: Do NOT override the step when a speicifc step value is used
2676 // in some input fields!
2677 //Group4Spin->SpinBox_DX->setSingleStep(step);
2678 //Group4Spin->SpinBox_DY->setSingleStep(step);
2679 //Group4Spin->SpinBox_DS->setSingleStep(step);
2682 //=================================================================================
2683 // function : AddLocalCS()
2684 // purpose : Add All Coordinates systems in study
2685 //=================================================================================
2686 void EntityGUI_SketcherDlg::AddLocalCS(GEOM::GEOM_Object_var aSelectedObject)
2688 QString aName = GEOMBase::GetName( aSelectedObject );
2690 int index = ComboBox1->findText(aName, Qt::MatchExactly);
2692 if (index==-1) // If the working plane hasn't been added yet
2694 myWPlaneList.push_back(aSelectedObject);
2695 myWPlane = aSelectedObject;
2696 addSubshapesToStudy();
2697 myLCSList.push_back(WPlaneToLCS(aSelectedObject));
2698 ComboBox1->addItem(aName);
2699 index = ComboBox1->count();
2700 ComboBox1->setCurrentIndex(index-1);
2704 ComboBox1->setCurrentIndex(index);
2709 //=================================================================================
2710 // function : FindLocalCS()
2711 // purpose : Find All Coordinates systems in study
2712 //=================================================================================
2713 void EntityGUI_SketcherDlg::FindLocalCS()
2716 myWPlaneList.clear();
2717 SalomeApp_Application* app =
2718 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2722 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2726 _PTR(Study) aStudy = appStudy->studyDS();
2729 ComboBox1->addItem(tr("GEOM_GCS"));
2730 myWPlaneList.push_back(myGlobalCS);
2732 // get GEOM component
2733 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2734 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2737 _PTR(SComponent) fc = obj->GetFatherComponent();
2738 QString geomComp = fc->GetID().c_str();
2739 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2743 // browse through all GEOM data tree
2744 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2745 for ( it->InitEx( true ); it->More(); it->Next() )
2747 _PTR(SObject) child( it->Value() );
2748 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2749 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2750 if( CORBA::is_nil( geomObj ) )
2752 if (geomObj->GetType() == GEOM_MARKER)
2754 myWPlaneList.push_back(geomObj);
2755 myLCSList.push_back(WPlaneToLCS(geomObj));
2756 ComboBox1->addItem(geomObj->GetName());
2761 //=================================================================================
2762 // function : WPlaneToLCS ( aWPlane )
2764 //=================================================================================
2765 gp_Ax3 EntityGUI_SketcherDlg::WPlaneToLCS( GEOM::GEOM_Object_var geomObj )
2767 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2770 if (CORBA::is_nil( geomObj ) || aShape.IsNull())
2772 MESSAGE("CORBA::is_nil( geomObj ) || aShape.IsNull()")
2774 aLCS.Transform(aShape.Location().Transformation());
2775 if (aShape.ShapeType() == TopAbs_FACE)
2777 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
2778 myGeometryGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
2779 double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
2780 aMeasureOp->GetPosition( geomObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
2781 if ( aMeasureOp->IsDone() )
2783 gp_Pnt aPnt ( Ox, Oy, Oz );
2784 gp_Dir aDirN ( Zx, Zy, Zz );
2785 gp_Dir aDirX ( Xx, Xy, Xz );
2786 aLCS = gp_Ax3( aPnt, aDirN, aDirX );
2793 //=================================================================================
2794 // function : getPnt1ConstructorId()
2796 //=================================================================================
2797 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2799 int buttonId = GroupPt->ButtonGroup->checkedId();
2800 // MESSAGE("buttonId = "<<buttonId)
2804 //=================================================================================
2805 // function : getPnt2ConstructorId()
2807 //=================================================================================
2808 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2810 int buttonId = GroupPt2->ButtonGroup->checkedId();
2811 // MESSAGE("buttonId = "<<buttonId)
2815 //=================================================================================
2816 // function : GetActiveLocalCS()
2817 // purpose : Get Working plane
2818 //=================================================================================
2819 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2821 int ind = ComboBox1->currentIndex();
2823 return myGeometryGUI->GetWorkingPlane();
2825 gp_Ax3 aLCS = myLCSList.at(ind);
2826 myWPlane = myWPlaneList.at(ind);
2831 //=================================================================================
2832 // function : ActivateLocalCS()
2833 // purpose : Activate & Fit Working plane
2834 //=================================================================================
2835 void EntityGUI_SketcherDlg::ActivateLocalCS()
2837 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2838 myGeometryGUI->ActiveWorkingPlane();
2841 //=================================================================================
2842 // function : addSubshapeToStudy
2843 // purpose : virtual method to add new SubObjects if local selection
2844 //=================================================================================
2845 void EntityGUI_SketcherDlg::addSubshapesToStudy()
2847 GEOMBase::PublishSubObject(myWPlane);