1 // Copyright (C) 2007-2021 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, or (at your option) any later version.
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>
50 #include "utilities.h"
55 #include <QButtonGroup>
57 #include <BRep_Tool.hxx>
59 #include <TopExp_Explorer.hxx>
60 #include <TopoDS_Vertex.hxx>
62 #include <BRepBuilderAPI_Transform.hxx>
63 #include <BRepBuilderAPI_MakeWire.hxx>
64 #include <BRepBuilderAPI_MakeVertex.hxx>
65 #include <Sketcher_Profile.hxx>
67 #include <SalomeApp_Study.h>
68 #include <SalomeApp_Tools.h>
69 #include "utilities.h"
73 #include <Basics_Utils.hxx>
75 //=================================================================================
76 // class : EntityGUI_SketcherDlg()
77 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
78 // name 'name' and widget flags set to 'f'.
79 // The dialog will by default be modeless, unless you set 'modal' to
80 // TRUE to construct a modal dialog.
81 //=================================================================================
82 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
83 bool modal, Qt::WindowFlags fl,
84 const double lineWidth )
85 : QDialog( parent, fl ),
86 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
87 myIsAllAdded( false ),
90 myLineWidth( lineWidth )
92 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
94 setAttribute( Qt::WA_DeleteOnClose );
96 // Disable rectangular selection
97 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
98 // ((OCCViewer_ViewWindow*)theViewWindow)->setEnabledDrawMode( false );
99 // MESSAGE("((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode();"<<((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode())
100 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
101 // vp->setSketchingEnabled( false );
102 // MESSAGE("vp->isSketchingEnabled()"<<vp->isSketchingEnabled())
103 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(true);
104 // OCCViewer_ViewSketcher* aViewSketcher = ((OCCViewer_ViewWindow*)theViewWindow)->getSketcher( OCCViewer_ViewWindow::Rect );
105 // aViewSketcher->deactivate()
106 // aViewSketcher->setVisible(false);
108 // this->setMouseTracking(false);
110 myGeometryGUI->SetActiveDialogBox(this);
112 MainWidget = new EntityGUI_Skeleton( this );
113 QVBoxLayout* topLayout = new QVBoxLayout( this );
114 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
116 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
117 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_CLOSE" ) );
118 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
119 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
121 QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
122 QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
123 QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
124 QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
125 QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) );
126 QPixmap image5 (aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
127 QPixmap image6 (aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_RECTANGLE" ) ) );
129 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
131 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
132 MainWidget->RadioButton1->setText( "" );
133 MainWidget->RadioButton1->setIcon( image3 );
134 MainWidget->RadioButton2->setText( "" );
135 MainWidget->RadioButton2->setIcon( image4 );
136 MainWidget->RadioButton3->setText( "" );
137 MainWidget->RadioButton3->setIcon( image6 );
138 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
139 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
140 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
141 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
143 /***************************************************************/
145 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
146 QGridLayout* planeLayout = new QGridLayout(GroupBox1);
147 planeLayout->setSpacing(6);
148 planeLayout->setMargin(11);
150 ComboBox1 = new QComboBox(GroupBox1);
151 planeLayout->addWidget(ComboBox1,0,0,1,2);
153 planeButton = new QPushButton (GroupBox1);
154 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
155 planeLayout->addWidget(planeButton,0,2);
157 selButton = new QPushButton (GroupBox1);
158 selButton->setIcon(image5);
159 planeLayout->addWidget(selButton,1,0);
161 WPlaneLineEdit = new QLineEdit (GroupBox1);
162 WPlaneLineEdit->setReadOnly(true);
163 planeLayout->addWidget(WPlaneLineEdit,1,1,1,2);
165 planeLayout->setColumnStretch(1,1);
167 topLayout->addWidget(GroupBox1);
168 topLayout->addWidget( MainWidget );
169 topLayout->setStretch( 1, 1);
171 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
173 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
174 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
175 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
176 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
178 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
180 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
181 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
182 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
183 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
185 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
187 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
188 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
189 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
190 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
191 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
193 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
195 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIST" ) );
196 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
197 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
198 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
200 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
201 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
202 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
203 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
204 Group1Sel->PushButton1->setIcon( image0 );
205 Group1Sel->buttonUndo->setIcon( image1 );
206 Group1Sel->buttonRedo->setIcon( image2 );
207 Group1Sel->LineEdit1->setReadOnly( true );
209 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
210 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
211 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
212 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
213 Group2Sel->PushButton1->setIcon( image0 );
214 Group2Sel->PushButton2->setIcon( image0 );
215 Group2Sel->buttonUndo->setIcon( image1 );
216 Group2Sel->buttonRedo->setIcon( image2 );
217 Group2Sel->LineEdit1->setReadOnly( true );
218 Group2Sel->LineEdit2->setReadOnly( true );
220 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
221 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
222 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
223 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
224 Group1Sel1Spin->PushButton1->setIcon( image0 );
225 Group1Sel1Spin->buttonUndo->setIcon( image1 );
226 Group1Sel1Spin->buttonRedo->setIcon( image2 );
227 Group1Sel1Spin->LineEdit1->setReadOnly( true );
229 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
230 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
231 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
232 Group1Spin->buttonUndo->setIcon( image1 );
233 Group1Spin->buttonRedo->setIcon( image2 );
235 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
236 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
237 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
238 Group2Spin->buttonUndo->setIcon( image1 );
239 Group2Spin->buttonRedo->setIcon( image2 );
241 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
242 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
243 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
244 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
245 Group3Spin->buttonUndo->setIcon( image1 );
246 Group3Spin->buttonRedo->setIcon( image2 );
248 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
249 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
250 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
251 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
252 Group4Spin->buttonUndo->setIcon( image1 );
253 Group4Spin->buttonRedo->setIcon( image2 );
255 GroupRect = new DlgRef_4Spin( MainWidget->SkeletonCnt );
256 GroupRect->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
257 GroupRect->TextLabel1->setText("X1:");
258 GroupRect->TextLabel2->setText("Y1:");
259 GroupRect->TextLabel3->setText("X2:");
260 GroupRect->TextLabel4->setText("Y2:");
262 // Defines a palette for the error message on Group4Spin and Group2Sel
265 palette.setColor(Group4Spin->label->foregroundRole(), color);
266 Group4Spin->label->setPalette(palette);
267 palette.setColor(Group2Sel->label->foregroundRole(), color);
268 Group2Sel->label->setPalette(palette);
270 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
271 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
272 DestCntLayout->addWidget( GroupPt, 0, 0 );
273 DestCntLayout->addWidget( GroupPt2, 0, 1 );
274 DestCntLayout->addWidget( GroupD1, 0, 0 );
275 DestCntLayout->addWidget( GroupD2, 0, 1 );
277 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
278 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
279 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
280 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
281 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
282 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
283 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
284 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
285 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
286 SkeletonCntlayout->addWidget( GroupRect, 0, 0 );
287 //SkeletonCntlayout->setStretch( 0, 1);
288 /***************************************************************/
290 QButtonGroup* ButtonGroup = new QButtonGroup( this );
291 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
292 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
294 /* signals and slots connections */
295 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
296 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
297 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
298 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
300 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
301 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
302 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
303 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
304 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
305 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
306 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
307 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
308 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
309 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
310 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
311 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
312 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
313 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
314 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
315 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
316 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
317 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
318 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
319 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
320 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
322 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
323 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
324 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
325 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
326 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
327 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
329 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
330 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
332 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
333 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
334 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
335 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
337 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
338 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
339 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
341 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
342 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
343 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
344 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
345 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
346 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
347 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
348 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
349 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
350 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
351 connect( GroupRect->SpinBox_DX1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
352 connect( GroupRect->SpinBox_DX2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
353 connect( GroupRect->SpinBox_DY1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
354 connect( GroupRect->SpinBox_DY2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
356 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
357 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
358 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
359 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
361 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ActivateLocalCS() ) );
362 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
363 connect( selButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
365 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
367 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
368 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
370 // install event filter on spin-boxes to provide Apply action on Return pressed
371 Group1Spin->SpinBox_DX->installEventFilter(this);
372 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
373 Group2Spin->SpinBox_DX->installEventFilter(this);
374 Group2Spin->SpinBox_DY->installEventFilter(this);
375 Group3Spin->SpinBox_DX->installEventFilter(this);
376 Group3Spin->SpinBox_DY->installEventFilter(this);
377 Group3Spin->SpinBox_DZ->installEventFilter(this);
378 Group4Spin->SpinBox_DX->installEventFilter(this);
379 Group4Spin->SpinBox_DY->installEventFilter(this);
380 Group4Spin->SpinBox_DZ->installEventFilter(this);
381 Group4Spin->SpinBox_DS->installEventFilter(this);
387 //=================================================================================
388 // function : ~EntityGUI_SketcherDlg()
389 // purpose : Destroys the object and frees any allocated resources
390 //=================================================================================
391 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
393 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
395 myGeometryGUI->SetActiveDialogBox( 0 );
396 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(false);
400 //=================================================================================
401 // function : eventFilter()
402 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
403 //=================================================================================
404 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
406 if (event->type() == QEvent::KeyPress) {
407 QKeyEvent* ke = (QKeyEvent*)event;
408 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
409 if (object == Group1Spin->SpinBox_DX) {
410 Group1Spin->buttonApply->click();
412 } else if (object == Group1Sel1Spin->SpinBox_DX) {
413 Group1Sel1Spin->buttonApply->click();
415 } else if (object == Group2Spin->SpinBox_DX ||
416 object == Group2Spin->SpinBox_DY) {
417 Group2Spin->buttonApply->click();
419 } else if (object == Group3Spin->SpinBox_DX ||
420 object == Group3Spin->SpinBox_DY ||
421 object == Group3Spin->SpinBox_DZ) {
422 Group3Spin->buttonApply->click();
424 } else if (object == Group4Spin->SpinBox_DX ||
425 object == Group4Spin->SpinBox_DY ||
426 object == Group4Spin->SpinBox_DZ ||
427 object == Group4Spin->SpinBox_DS) {
428 Group4Spin->buttonApply->click();
434 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
436 return QDialog::eventFilter(object, event);
440 //=================================================================================
443 //=================================================================================
444 void EntityGUI_SketcherDlg::Init()
449 myEditCurrentArgument = WPlaneLineEdit; // Initiate the parameters selection with the first WPlaneLineEdit
451 myCommand.append( "Sketcher" );
452 myUndoCommand.append( "Sketcher" );
454 mySketchState = FIRST_POINT;
455 globalSelection( GEOM_FACE );
464 myHelpFileName = "create_sketcher_page.html";
466 GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations();
467 myGlobalCS = aBasicOp->MakeMarker( 0,0,0,
470 myWPlane = myGlobalCS;
471 myLCSList.push_back( WPlaneToLCS(myGlobalCS) );
473 /* Get setting of step value from file configuration */
474 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
476 /* min, max, step and decimals for spin boxes */
477 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
478 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
479 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
480 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
481 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
482 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
483 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
484 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
485 // san: Note specific step values below!
486 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
487 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
488 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
490 initSpinBox( GroupRect->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
491 initSpinBox( GroupRect->SpinBox_DY1, COORD_MIN, COORD_MAX, step, "length_precision" );
492 initSpinBox( GroupRect->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
493 initSpinBox( GroupRect->SpinBox_DY2, COORD_MIN, COORD_MAX, step, "length_precision" );
495 /* displays Dialog */
497 // MainWidget->RadioButton1->setEnabled( false );
498 // MainWidget->RadioButton2->setEnabled( false );
499 // MainWidget->RadioButton3->setEnabled( true );
500 // MainWidget->GroupDest1->setEnabled( false );
501 setEnabledUndo( false );
502 setEnabledRedo( false );
504 MainWidget->RadioButton1->setChecked( true );
508 // If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox
509 // that should be filled with the possibly selected face
513 SelectionIntoArgument();
517 setPrefix(tr("GEOM_SKETCH"));
521 setIsWaitCursorEnabled( false );
522 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
526 //=================================================================================
527 // function : InitClick()
529 //=================================================================================
530 void EntityGUI_SketcherDlg::InitClick()
532 MESSAGE("EntityGUI_SketcherDlg::InitClick()")
533 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
538 Group1Sel1Spin->hide();
544 globalSelection(); // close local selection to clear it
545 localSelection( TopAbs_VERTEX );
549 //=================================================================================
550 // function : TypeClicked()
551 // purpose : Radio button management
552 //=================================================================================
553 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
555 myConstructorId = constructorId;
556 MainWidget->buttonEnd->setText(tr("GEOM_BUT_CLOSE"));
557 MainWidget->buttonClose->setEnabled(true);
559 if ( myConstructorId == 0 ) { // SEGMENT
560 GroupPt2->RB_Point1->setChecked( true );
561 GroupPt ->setEnabled( true );
562 GroupPt2->setEnabled( false );
563 GroupD1->setEnabled( true );
564 GroupD2->setEnabled( true );
565 MainWidget->RB_Dest1->setEnabled( true );
566 MainWidget->RB_Dest1->setChecked( true );
568 MainWidget->GroupDest ->setEnabled( true );
569 MainWidget->GroupDest1->setEnabled( true );
570 MainWidget->GroupDest ->show();
571 MainWidget->GroupDest1->show();
573 if (mySketchState == FIRST_POINT)
578 else if ( myConstructorId == 1 ) { // ARC
579 GroupPt ->setEnabled( true );
580 GroupPt2->setEnabled( true );
581 GroupD2->RB_Dir21->setChecked( true );
582 GroupD1->setEnabled( true );
583 GroupD2->setEnabled( false );
584 MainWidget->RB_Dest1->setEnabled( true );
585 MainWidget->RB_Dest1->setChecked( true );
587 MainWidget->GroupDest ->setEnabled( true );
588 MainWidget->GroupDest1->setEnabled( true );
589 MainWidget->GroupDest ->show();
590 MainWidget->GroupDest1->show();
592 if (mySketchState == FIRST_POINT)
597 else if ( myConstructorId == 2 ) { // RECTANGLE
598 GroupPt ->setEnabled( false );
599 GroupPt2->setEnabled( false );
600 GroupD1 ->setEnabled( false );
601 GroupD2 ->setEnabled( false );
602 MainWidget->GroupDest ->setEnabled( false );
603 MainWidget->GroupDest1->setEnabled( false );
609 MainWidget->GroupDest ->hide();
610 MainWidget->GroupDest1->hide();
612 MainWidget->buttonEnd->setText(tr("Apply and Close"));
613 MainWidget->buttonClose->setEnabled(false);
615 GroupRect->setEnabled( true );
616 MainWidget->RadioButton1->setEnabled( true );
617 MainWidget->RadioButton2->setEnabled( true );
623 //=================================================================================
624 // function : RectClicked()
625 // purpose : Radio button management
626 //=================================================================================
627 void EntityGUI_SketcherDlg::RectClicked()
631 // Connect the selection manager (disconnected in InitClick())
632 connect( myGeometryGUI->getApp()->selectionMgr(),
633 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
638 GroupRect->SpinBox_DX1->setValue(myX1);
640 GroupRect->SpinBox_DY1->setValue(myY1);
642 GroupRect->SpinBox_DX2->setValue(myX2);
644 GroupRect->SpinBox_DY2->setValue(myY2);
646 resize( minimumSizeHint() );
648 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
652 //=================================================================================
653 // function : DestClicked()
654 // purpose : Radio button management
655 //=================================================================================
656 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
663 if ( constructorId == 1 ) {
665 GroupPt->RB_Point1->setChecked( true );
668 Group3Spin->checkBox->show();
669 Group4Spin->checkBox->show();
670 PointClicked( 1 ); // XY
672 else if ( constructorId == 0 ) {
674 GroupD1->RB_Dir11->setChecked( true );
677 Group3Spin->checkBox->hide();
678 Group4Spin->checkBox->hide();
679 if (myConstructorId == 1) {
686 Dir1Clicked( 2 ); // Angle
688 resize( minimumSizeHint() );
691 //=================================================================================
692 // function : PointClicked()
693 // purpose : Radio button management
694 //=================================================================================
695 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
697 MESSAGE("PointClicked")
698 myConstructorPntId = constructorId;
699 GroupPt->RB_Point3->setEnabled( true );
700 int buttonId = GroupPt2->ButtonGroup->checkedId();
701 if (buttonId >= 0){ // = If a button is checked
702 Point2Clicked(buttonId);
705 GroupPt2->RB_Point1->setChecked( true );
710 //=================================================================================
711 // function : Point2Clicked()
712 // purpose : Radio button management
713 //=================================================================================
714 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
716 MESSAGE("Point2Clicked")
719 // Get setting of step value from file configuration
720 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
722 if ( myConstructorPntId == 1 ) { // XY
723 if ( constructorId == 1 ){ // No additional parameter
724 mySketchType = PT_ABS;
725 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
726 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
727 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
728 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
730 Group2Spin->SpinBox_DX->setValue( myX );
732 Group2Spin->SpinBox_DY->setValue( myY );
734 Group2Spin->buttonApply->setFocus();
736 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
738 else if ( constructorId == 0 ){ // Point + radius
739 mySketchType = PT_ABS_RADIUS;
740 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
741 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
742 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
743 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
744 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
745 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
747 Group3Spin->SpinBox_DX->setValue( myX );
749 Group3Spin->SpinBox_DY->setValue( myY );
751 Group3Spin->SpinBox_DZ->setValue( myRadius );
753 Group3Spin->buttonApply->setFocus();
755 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
757 else if ( constructorId == 2 ){ // Point + center
758 mySketchType = PT_ABS_CENTER;
759 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
760 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
761 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
762 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
763 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
764 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
765 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
766 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
768 Group4Spin->SpinBox_DX->setValue( myXc );
770 Group4Spin->SpinBox_DY->setValue( myYc );
772 Group4Spin->SpinBox_DZ->setValue( myX );
774 Group4Spin->SpinBox_DS->setValue( myY );
776 Group4Spin->buttonApply->setFocus();
778 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
782 else if ( myConstructorPntId == 0 ) { // DXDY
783 if ( constructorId == 1 ){ // No additional parameter
784 mySketchType = PT_RELATIVE;
785 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
786 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
787 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
788 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
790 Group2Spin->SpinBox_DX->setValue( myDX );
792 Group2Spin->SpinBox_DY->setValue( myDY );
794 Group2Spin->buttonApply->setFocus();
796 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
798 else if ( constructorId == 0 ){ // Point + radius
799 mySketchType = PT_REL_RADIUS;
800 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
801 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
802 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
803 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
804 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
805 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
807 Group3Spin->SpinBox_DX->setValue( myDX );
809 Group3Spin->SpinBox_DY->setValue( myDY );
811 Group3Spin->SpinBox_DZ->setValue( myRadius );
813 Group3Spin->buttonApply->setFocus();
815 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
817 else if ( constructorId == 2 ){ // Point + center
818 mySketchType = PT_REL_CENTER;
819 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
820 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
821 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
822 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
823 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
824 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
825 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
826 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
828 Group4Spin->SpinBox_DX->setValue( myDXc );
830 Group4Spin->SpinBox_DY->setValue( myDYc );
832 Group4Spin->SpinBox_DZ->setValue( myDX );
834 Group4Spin->SpinBox_DS->setValue( myDY );
836 Group4Spin->buttonApply->setFocus();
838 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
842 else if ( myConstructorPntId == 2 ) { // Selection
843 if ( constructorId == 1 ){ // No additional parameter
844 mySketchType = PT_SEL;
845 myEditCurrentArgument = Group1Sel->LineEdit1;
846 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
848 Group1Sel->buttonApply->setFocus();
849 SelectionIntoArgument();
851 else if ( constructorId == 0 ){ // Point + radius
852 mySketchType = PT_SEL_RADIUS;
853 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
854 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
855 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
856 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
858 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
860 Group1Sel1Spin->show();
861 Group1Sel1Spin->buttonApply->setFocus();
862 SelectionIntoArgument();
864 else if ( constructorId == 2 ){ // Point + center
865 mySketchType = PT_SEL_CENTER;
866 myEditCurrentArgument = Group2Sel->LineEdit1;
867 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
868 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
869 Group2Sel->LineEdit1->setEnabled(true);
870 Group2Sel->PushButton1->setDown(true);
871 Group2Sel->LineEdit2->setEnabled(false);
872 Group2Sel->PushButton2->setDown(false);
874 Group2Sel->buttonApply->setFocus();
875 SelectionIntoArgument();
879 resize( minimumSizeHint() );
880 connect( myGeometryGUI->getApp()->selectionMgr(),
881 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
886 //=================================================================================
887 // function : Dir1Clicked()
888 // purpose : Radio button management
889 //=================================================================================
890 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
892 myConstructorDirId = constructorId;
893 int dirButtonId = GroupD2->ButtonGroup->checkedId();
894 if (dirButtonId >= 0){ // = If a button is checked
895 Dir2Clicked(dirButtonId);
898 GroupD2->RB_Dir21->setChecked( true );
904 //=================================================================================
905 // function : Dir2Clicked()
906 // purpose : Radio button management
907 //=================================================================================
908 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
911 Group3Spin->SpinBox_DX->blockSignals(true); // Block signals in order not to modify
912 Group3Spin->SpinBox_DY->blockSignals(true); // default values
913 Group3Spin->SpinBox_DZ->blockSignals(true);
915 Group2Spin->SpinBox_DX->blockSignals(true);
916 Group2Spin->SpinBox_DY->blockSignals(true);
918 Group4Spin->SpinBox_DX->blockSignals(true);
919 Group4Spin->SpinBox_DY->blockSignals(true);
920 Group4Spin->SpinBox_DZ->blockSignals(true);
921 Group4Spin->SpinBox_DS->blockSignals(true);
923 // Get setting of step value from file configuration
924 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
926 if ( myConstructorId == 0 ) { // SEGMENT
930 if ( myConstructorDirId == 2 ) { // Angle
931 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
932 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
933 Group2Spin->SpinBox_DX->setValue( myAngle );
934 Group2Spin->buttonApply->setFocus();
937 if ( constructorId == 2 ) { // Length
938 mySketchType = DIR_ANGLE_LENGTH;
939 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
940 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
941 Group2Spin->SpinBox_DY->setValue( myLength );
943 else if ( constructorId == 0 ) { // X
944 mySketchType = DIR_ANGLE_X;
945 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
946 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X2" ) );
947 Group2Spin->SpinBox_DY->setValue( myX );
949 else if ( constructorId == 1 ) { // Y
950 mySketchType = DIR_ANGLE_Y;
951 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
952 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
953 Group2Spin->SpinBox_DY->setValue( myY );
956 else if ( myConstructorDirId == 0 ) { // Perpendicular
958 Group1Spin->buttonApply->setFocus();
960 if ( constructorId == 2 ) { // Length
961 mySketchType = DIR_PER_LENGTH;
962 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
963 Group1Spin->SpinBox_DX->setValue( myLength );
965 else if ( constructorId == 0 ) { // X
966 mySketchType = DIR_PER_X;
967 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
968 Group1Spin->SpinBox_DX->setValue( myX );
970 else if ( constructorId == 1 ) { // Y
971 mySketchType = DIR_PER_Y;
972 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y2" ) );
973 Group1Spin->SpinBox_DX->setValue( myY );
976 else if ( myConstructorDirId == 1 ) { // Tangent
978 Group1Spin->buttonApply->setFocus();
980 if ( constructorId == 2 ) { // Length
981 mySketchType = DIR_TAN_LENGTH;
982 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
983 Group1Spin->SpinBox_DX->setValue( myLength );
985 else if ( constructorId == 0 ) { // X
986 mySketchType = DIR_TAN_X;
987 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
988 Group1Spin->SpinBox_DX->setValue( myX );
990 else if ( constructorId == 1 ) { // Y
991 mySketchType = DIR_TAN_Y;
992 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y2" ) );
993 Group1Spin->SpinBox_DX->setValue( myY );
996 else if ( myConstructorDirId == 3 ) { // DXDY
997 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
998 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
999 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
1000 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
1001 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
1002 Group3Spin->SpinBox_DX->setValue( myDX );
1003 Group3Spin->SpinBox_DY->setValue( myDY );
1005 Group3Spin->buttonApply->setFocus();
1007 if ( constructorId == 2 ) { // Length
1008 mySketchType = DIR_DXDY_LENGTH;
1009 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
1010 Group3Spin->SpinBox_DZ->setValue( myLength );
1012 else if ( constructorId == 0 ) { // X
1013 mySketchType = DIR_DXDY_X;
1014 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
1015 Group3Spin->SpinBox_DZ->setValue( myX );
1017 else if ( constructorId == 1 ) { // Y
1018 mySketchType = DIR_DXDY_Y;
1019 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y2" ) );
1020 Group3Spin->SpinBox_DZ->setValue( myY );
1024 else if ( myConstructorId == 1 ) { // ARC
1025 if ( myConstructorDirId == 2 ) { // Angle
1026 if ( constructorId == 2 ) { // Length
1027 mySketchType = DIR_ANGLE_LENGTH;
1028 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1029 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1030 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1031 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1032 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1033 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
1034 Group3Spin->SpinBox_DX->setValue( myAngle );
1035 Group3Spin->SpinBox_DY->setValue( myRadius );
1036 Group3Spin->SpinBox_DZ->setValue( myLength );
1038 Group3Spin->buttonApply->setFocus();
1041 else if ( myConstructorDirId == 0 ) { // Perpendicular
1042 if ( constructorId == 2 ) { // Length
1043 mySketchType = DIR_PER_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" ) );
1048 // myRadius = 100.0;
1049 Group2Spin->SpinBox_DX->setValue( myRadius );
1051 Group2Spin->SpinBox_DY->setValue( myLength );
1053 Group2Spin->buttonApply->setFocus();
1056 else if ( myConstructorDirId == 1 ) { // Tangent
1057 if ( constructorId == 2 ) { // Length
1058 mySketchType = DIR_TAN_LENGTH;
1059 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1060 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1061 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1062 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1063 // myRadius = 100.0;
1064 Group2Spin->SpinBox_DX->setValue( myRadius );
1066 Group2Spin->SpinBox_DY->setValue( myLength );
1068 Group2Spin->buttonApply->setFocus();
1071 else if ( myConstructorDirId == 3 ) { // DXDY
1072 if ( constructorId == 2 ) { // Length
1073 mySketchType = DIR_DXDY_LENGTH;
1074 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
1075 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
1076 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1077 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1078 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
1079 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
1080 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
1081 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
1082 Group4Spin->SpinBox_DX->setValue( myDX );
1083 Group4Spin->SpinBox_DY->setValue( myDY );
1084 // myRadius = 100.0;
1085 Group4Spin->SpinBox_DZ->setValue( myRadius );
1087 Group4Spin->SpinBox_DS->setValue( myLength );
1089 Group4Spin->buttonApply->setFocus();
1093 Group3Spin->SpinBox_DX->blockSignals(false); // Restore signals
1094 Group3Spin->SpinBox_DY->blockSignals(false);
1095 Group3Spin->SpinBox_DZ->blockSignals(false);
1097 Group2Spin->SpinBox_DX->blockSignals(false);
1098 Group2Spin->SpinBox_DY->blockSignals(false);
1100 Group4Spin->SpinBox_DX->blockSignals(false);
1101 Group4Spin->SpinBox_DY->blockSignals(false);
1102 Group4Spin->SpinBox_DZ->blockSignals(false);
1103 Group4Spin->SpinBox_DS->blockSignals(false);
1105 resize( minimumSizeHint() );
1106 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1109 //=================================================================================
1110 // function : CheckBoxClicked()
1111 // purpose : CheckBox management
1112 //=================================================================================
1113 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
1115 myCheckFlag = State;
1117 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1121 //=================================================================================
1122 // function : ClickOnCancel()
1124 //=================================================================================
1125 void EntityGUI_SketcherDlg::ClickOnCancel()
1131 //=================================================================================
1132 // function : ClickOnEnd()
1133 // purpose : connected to buttonEnd AND buttonClose
1134 //=================================================================================
1135 void EntityGUI_SketcherDlg::ClickOnEnd()
1137 MESSAGE("EntityGUI_SketcherDlg::ClickOnEnd()")
1138 if ( sender() == MainWidget->buttonClose ) {
1139 // Verify validity of commands
1140 if ( myCommand.count() <= 2 ) {
1141 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
1142 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
1146 QString Command = myCommand.join( "" );
1147 Sketcher_Profile aProfile = Sketcher_Profile( Command.toLatin1() );
1148 bool isDone = false;
1149 TopoDS_Shape myShape = aProfile.GetShape( &isDone );
1151 if ( myShape.ShapeType() != TopAbs_VERTEX )
1152 myCommand.append( ":WW" );
1156 /*// PAL16008 (Sketcher Validation should be equal to Apply&Close)
1157 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
1158 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
1159 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
1160 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
1161 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
1162 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
1163 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
1166 // ClickOnApply(); // TEST remove then
1167 myIsAllAdded = true;
1170 if (myConstructorId == 2)
1172 QString aParameters;
1173 myCommand.append( GetNewCommand( aParameters ) );
1174 mySketchState = NEXT_POINT;
1178 if ( myCommand.size() > 2 )
1187 //=================================================================================
1188 // function : ClickOnApply()
1190 //=================================================================================
1191 bool EntityGUI_SketcherDlg::ClickOnApply()
1193 MESSAGE("EntityGUI_SketcherDlg::ClickOnApply()")
1194 if ( sender() && sender()->inherits( "QPushButton" ) )
1195 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1197 // addSubshapesToStudy();
1199 QString aParameters;
1200 myCommand.append( GetNewCommand( aParameters ) );
1201 if (mySketchState == FIRST_POINT)
1203 mySketchState = NEXT_POINT;
1207 myUndoCommand.clear();
1208 myUndoCommand.append( "Sketcher" );
1210 myParameters.append( aParameters );
1211 myUndoParameters.clear();
1213 setEnabledUndo( true );
1214 setEnabledRedo( false );
1217 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1220 // Set focus to SpinBox_DX
1221 if ( sender() == Group1Spin->buttonApply ) {
1222 (Group1Spin->SpinBox_DX)->setFocus();
1223 (Group1Spin->SpinBox_DX)->selectAll();
1225 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1226 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1227 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1229 else if ( sender() == Group2Spin->buttonApply ) {
1230 (Group2Spin->SpinBox_DX)->setFocus();
1231 (Group2Spin->SpinBox_DX)->selectAll();
1233 else if ( sender() == Group3Spin->buttonApply ) {
1234 (Group3Spin->SpinBox_DX)->setFocus();
1235 (Group3Spin->SpinBox_DX)->selectAll();
1237 else if ( sender() == Group4Spin->buttonApply ) {
1238 (Group4Spin->SpinBox_DX)->setFocus();
1239 (Group4Spin->SpinBox_DX)->selectAll();
1245 //=================================================================================
1246 // function : ClickOnHelp()
1248 //=================================================================================
1249 void EntityGUI_SketcherDlg::ClickOnHelp()
1251 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1253 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1257 platform = "winapplication";
1259 platform = "application";
1262 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1263 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1264 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1265 QObject::tr( "BUT_OK" ) );
1269 //=================================================================================
1270 // function : ClickOnUndo()
1272 //=================================================================================
1273 void EntityGUI_SketcherDlg::ClickOnUndo()
1275 myUndoCommand.append( myCommand.last() );
1276 myCommand.pop_back();
1278 myUndoParameters.append( myParameters.last() );
1279 myParameters.pop_back();
1281 if ( myCommand.count() == 1 ) {
1282 mySketchState = FIRST_POINT;
1284 MainWidget->RadioButton1->setChecked( true );
1287 connect( myGeometryGUI->getApp()->selectionMgr(),
1288 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1292 setEnabledUndo( false );
1295 setEnabledRedo( true );
1297 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1300 //=================================================================================
1301 // function : ClickOnRedo()
1303 //=================================================================================
1304 void EntityGUI_SketcherDlg::ClickOnRedo()
1306 myCommand.append( myUndoCommand.last() );
1307 myUndoCommand.pop_back();
1309 myParameters.append( myUndoParameters.last() );
1310 myUndoParameters.pop_back();
1312 mySketchState = NEXT_POINT;
1316 setEnabledUndo( true );
1318 if ( myUndoCommand.count() == 1 )
1319 setEnabledRedo( false );
1321 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1324 //=================================================================================
1325 // function : setEnabledUndo()
1327 //=================================================================================
1328 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1330 Group1Sel->buttonUndo->setEnabled( value );
1331 Group2Sel->buttonUndo->setEnabled( value );
1332 Group1Sel1Spin->buttonUndo->setEnabled( value );
1333 Group1Spin->buttonUndo->setEnabled( value );
1334 Group2Spin->buttonUndo->setEnabled( value );
1335 Group3Spin->buttonUndo->setEnabled( value );
1336 Group4Spin->buttonUndo->setEnabled( value );
1339 //=================================================================================
1340 // function : setEnabledRedo()
1342 //=================================================================================
1343 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1345 Group1Sel->buttonRedo->setEnabled( value );
1346 Group2Sel->buttonRedo->setEnabled( value );
1347 Group1Sel1Spin->buttonRedo->setEnabled( value );
1348 Group1Spin->buttonRedo->setEnabled( value );
1349 Group2Spin->buttonRedo->setEnabled( value );
1350 Group3Spin->buttonRedo->setEnabled( value );
1351 Group4Spin->buttonRedo->setEnabled( value );
1354 //=================================================================================
1355 // function : SelectionIntoArgument()
1356 // purpose : Called when selection as changed
1357 //=================================================================================
1358 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1360 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1361 myEditCurrentArgument->setText( "" );
1363 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1364 SALOME_ListIO aSelList;
1365 aSelMgr->selectedObjects(aSelList);
1367 this->activateWindow();
1369 if (aSelList.Extent() == 0)
1371 selButton->setDown(false);
1372 WPlaneLineEdit->setEnabled(false);
1373 WPlaneLineEdit->setText(tr("GEOM_SKETCHER_WPLANE"));
1376 else if (aSelList.Extent() != 1)
1384 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
1385 if (myEditCurrentArgument == WPlaneLineEdit)
1386 aNeedType = TopAbs_FACE;
1389 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
1390 TopoDS_Shape aShape;
1392 if(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape)
1393 && !aShape.IsNull())
1395 QString aName = GEOMBase::GetName( aSelectedObject.get() );
1396 if (myEditCurrentArgument==WPlaneLineEdit)
1398 // Check if the face is planar
1399 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
1400 GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion());
1402 if (aPlanarCheck.IsPlanar())
1404 myEditCurrentArgument->setText(aName);
1405 AddLocalCS(aSelectedObject.get());
1406 selButton->setDown(false);
1407 WPlaneLineEdit->setEnabled(false);
1408 TypeClicked( myConstructorId );
1412 myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE"));
1413 // The following leads to crash TODO : find a way to return a warning
1414 // Standard_Failure::Raise(tr("GEOM_SKETCHER_NOT_PLANAR").toStdString().c_str());
1420 gp_Ax3 aWPlane = GetActiveLocalCS();
1422 aTrans.SetTransformation(aWPlane);
1423 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1424 aShape = aTransformation.Shape();
1427 if ( GEOMBase::VertexToPoint( aShape, aPnt ) )
1429 myEditCurrentArgument->setText(aName);
1432 double Xcoord = myX;
1433 double Ycoord = myY;
1435 switch (mySketchType)
1438 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1439 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1441 Group2Spin->SpinBox_DX->setValue(Xcoord);
1442 Group2Spin->SpinBox_DY->setValue(Ycoord);
1444 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1445 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1449 if (myLastX1 && myLastY1)
1451 Xcoord = myX - myLastX1;
1452 Ycoord = myY - myLastY1;
1454 else if (mySketchState != FIRST_POINT)
1456 Xcoord = myX - tmpX;
1457 Ycoord = myY - tmpY;
1459 Group2Spin->SpinBox_DX->setValue(Xcoord);
1460 Group2Spin->SpinBox_DY->setValue(Ycoord);
1464 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1465 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1467 Group3Spin->SpinBox_DX->setValue(Xcoord);
1468 Group3Spin->SpinBox_DY->setValue(Ycoord);
1470 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1471 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1475 if (myLastX1 && myLastY1)
1477 Xcoord = myX - myLastX1;
1478 Ycoord = myY - myLastY1;
1480 else if (mySketchState != FIRST_POINT)
1482 Xcoord = myX - tmpX;
1483 Ycoord = myY - tmpY;
1485 Group3Spin->SpinBox_DX->setValue(Xcoord);
1486 Group3Spin->SpinBox_DY->setValue(Ycoord);
1490 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1491 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1493 Group4Spin->SpinBox_DX->setValue(Xcoord);
1494 Group4Spin->SpinBox_DY->setValue(Ycoord);
1496 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1497 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1501 if (myLastX1 && myLastY1)
1503 Xcoord = myXc - myLastX1;
1504 Ycoord = myYc - myLastY1;
1506 else if (mySketchState != FIRST_POINT)
1508 Xcoord = myXc - tmpX;
1509 Ycoord = myYc - tmpY;
1517 Group4Spin->SpinBox_DX->setValue(Xcoord);
1518 Group4Spin->SpinBox_DY->setValue(Ycoord);
1527 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1537 //=================================================================================
1538 // function : SetEditCurrentArgument()
1540 //=================================================================================
1541 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1543 TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX;
1544 if ( sender() == Group1Sel->PushButton1 ) {
1545 myEditCurrentArgument = Group1Sel->LineEdit1;
1546 myEditCurrentArgument->setFocus();
1548 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1549 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1550 myEditCurrentArgument->setFocus();
1552 else if ( sender() == Group2Sel->PushButton1 ) {
1553 myEditCurrentArgument = Group2Sel->LineEdit1;
1554 Group2Sel->PushButton2->setDown(false);
1555 Group2Sel->PushButton1->setDown(true);
1556 Group2Sel->LineEdit2->setEnabled(false);
1557 Group2Sel->LineEdit1->setEnabled(true);
1558 // myEditCurrentArgument->setFocus();
1560 else if ( sender() == Group2Sel->PushButton2 ) {
1561 myEditCurrentArgument = Group2Sel->LineEdit2;
1562 Group2Sel->PushButton1->setDown(false);
1563 Group2Sel->PushButton2->setDown(true);
1564 Group2Sel->LineEdit1->setEnabled(false);
1565 Group2Sel->LineEdit2->setEnabled(true);
1566 // myEditCurrentArgument->setFocus();
1568 else if ( sender() == selButton ) {
1569 myNeedType = TopAbs_FACE;
1570 myEditCurrentArgument = WPlaneLineEdit;
1571 WPlaneLineEdit->setEnabled(true);
1572 selButton->setDown(true);
1574 globalSelection(); // close local selection to clear it
1575 localSelection( myNeedType );
1579 //=================================================================================
1580 // function : LineEditReturnPressed()
1582 //=================================================================================
1583 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1585 if ( sender() == Group1Sel->LineEdit1 )
1586 myEditCurrentArgument = Group1Sel->LineEdit1;
1587 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1588 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1589 else if ( sender() == Group2Sel->LineEdit1 )
1590 myEditCurrentArgument = Group2Sel->LineEdit1;
1591 else if ( sender() == Group2Sel->LineEdit2 )
1592 myEditCurrentArgument = Group2Sel->LineEdit2;
1594 /* User name of object input management */
1595 /* If successful the selection is changed and signal emitted... */
1596 /* so SelectionIntoArgument() is automatically called. */
1597 const QString objectUserName = myEditCurrentArgument->text();
1598 QWidget* thisWidget = (QWidget*)this;
1600 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1601 SALOME_ListIO aSelList;
1602 aSelMgr->selectedObjects(aSelList);
1604 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1605 myEditCurrentArgument->setText( objectUserName );
1609 //=================================================================================
1610 // function : DeactivateActiveDialog()
1612 //=================================================================================
1613 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1615 //myGeometryGUI->SetState( -1 );
1617 setEnabled( false );
1619 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1620 myGeometryGUI->SetActiveDialogBox( 0 );
1624 //=================================================================================
1625 // function : ActivateThisDialog()
1627 //=================================================================================
1628 void EntityGUI_SketcherDlg::ActivateThisDialog()
1630 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1631 myGeometryGUI->EmitSignalDeactivateDialog();
1633 myGeometryGUI->SetActiveDialogBox( this );
1635 connect( myGeometryGUI->getApp()->selectionMgr(),
1636 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1638 //myGeometryGUI->SetState( 0 );
1639 // globalSelection( GEOM_POINT );
1641 myEditCurrentArgument = WPlaneLineEdit;
1642 myEditCurrentArgument->setFocus();
1644 if ( sender() == Group1Sel->LineEdit1 ) {
1645 myEditCurrentArgument = Group1Sel->LineEdit1;
1646 myEditCurrentArgument->setFocus();
1648 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1649 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1650 myEditCurrentArgument->setFocus();
1652 else if ( sender() == Group2Sel->LineEdit1 ) {
1653 myEditCurrentArgument = Group2Sel->LineEdit1;
1654 myEditCurrentArgument->setFocus();
1656 else if ( sender() == Group2Sel->LineEdit2 ) {
1657 myEditCurrentArgument = Group2Sel->LineEdit2;
1658 myEditCurrentArgument->setFocus();
1661 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1665 //=================================================================================
1666 // function : enterEvent [REDEFINED]
1668 //=================================================================================
1669 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1672 ActivateThisDialog();
1676 //=================================================================================
1677 // function : closeEvent()
1679 //=================================================================================
1680 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1682 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1683 //myGeometryGUI->SetState( -1 );
1684 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1685 myGeometryGUI->getApp()->updateActions();
1686 QDialog::closeEvent( e );
1689 //=================================================================================
1690 // function : OnPointSelected
1692 //=================================================================================
1693 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt,
1696 // NOTE Basing the autoapply functionality on the background picture has no sense anymore
1697 // The import picture functionality is now used for drawing on top of a picture
1699 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
1700 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
1702 // QString theImgFileName;
1703 // vp->background().texture( theImgFileName ); ////////////// VSR: temporarily
1708 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1709 TopoDS_Shape aShape = mkVertex.Shape();
1711 // Taking into account LocalCS
1712 gp_Ax3 aWPlane = GetActiveLocalCS();
1715 aTrans.SetTransformation(aWPlane);
1716 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1717 aShape = aTransformation.Shape();
1720 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1722 // NOTE autoapply disabled : doesn't seem useful anymore
1723 // autoApply = ( (getPnt2ConstructorId() == 1) && (!theImgFileName.isEmpty()) ); // If no additional argument needed after selection and there is a backgroundimage
1724 // -> apply automatically
1726 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1727 x = aTrsfPnt.X() - myLastX1;
1728 y = aTrsfPnt.Y() - myLastY1;
1734 switch (getPnt2ConstructorId()){
1736 Group2Spin->SpinBox_DX->setValue( x );
1737 Group2Spin->SpinBox_DY->setValue( y );
1738 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1741 Group3Spin->SpinBox_DX->setValue( x );
1742 Group3Spin->SpinBox_DY->setValue( y );
1743 Group3Spin->buttonApply->setFocus();
1746 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1747 Group4Spin->SpinBox_DX->setValue( x );
1748 Group4Spin->SpinBox_DY->setValue( y );
1750 else{ // Select end point
1751 Group4Spin->SpinBox_DZ->setValue( x );
1752 Group4Spin->SpinBox_DS->setValue( y );
1754 Group4Spin->buttonApply->setFocus();
1757 if ( myConstructorId == 2 ) //RECTANGLE
1761 GroupRect->SpinBox_DX1->setValue( aTrsfPnt.X() );
1762 GroupRect->SpinBox_DY1->setValue( aTrsfPnt.Y() );
1763 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1764 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1768 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1769 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1774 //=================================================================================
1775 // function : OnFirstPoint
1777 //=================================================================================
1778 void EntityGUI_SketcherDlg::OnFirstPoint()
1780 MainWidget->RadioButton3->setEnabled( true );
1781 MainWidget->GroupDest1->setEnabled( false );
1782 GroupPt2->setEnabled( false );
1785 //=================================================================================
1786 // function : OnNextPoint
1788 //=================================================================================
1789 void EntityGUI_SketcherDlg::OnNextPoint()
1791 MainWidget->RadioButton3->setEnabled( false );
1792 MainWidget->GroupDest1->setEnabled( true );
1793 TypeClicked(myConstructorId);
1796 //=================================================================================
1797 // function : ValueChangedInSpinBox()
1799 //=================================================================================
1800 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1802 QObject* send = (QObject*)sender();
1803 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1804 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1806 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1807 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1808 double LastDecimal = 0.0;
1810 QString vxStr, vyStr, vzStr, vsStr;
1812 QString newValueStr;
1813 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1814 newValueStr = aDoubleSpinBox->text();
1816 if ( send == Group1Spin->SpinBox_DX ) {
1817 vx = newValue; vxStr = newValueStr;
1819 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1820 vx = newValue; vxStr = newValueStr;
1822 else if ( send == Group2Spin->SpinBox_DX ) {
1823 vx = newValue; vxStr = newValueStr;
1824 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1826 else if ( send == Group2Spin->SpinBox_DY ) {
1827 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1828 vy = newValue; vyStr = newValueStr;
1830 else if ( send == Group3Spin->SpinBox_DX ) {
1831 vx = newValue; vxStr = newValueStr;
1832 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1833 vz = Group3Spin->SpinBox_DZ->value();
1834 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1835 if (mySketchType == PT_ABS_RADIUS){
1843 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1844 if (aPrecision >= 0) // 'f' format in the QString
1845 LastDecimal = aPrecision;
1846 else // 'g' format in the Qstring
1847 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1848 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1849 if ( Abs(vz) < minRad){
1851 Group3Spin->SpinBox_DZ->setValue( - minRad );
1853 Group3Spin->SpinBox_DZ->setValue( minRad );
1856 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1858 else if ( send == Group3Spin->SpinBox_DY ) {
1859 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1860 vy = newValue; vyStr = newValueStr;
1861 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1862 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1863 if (mySketchType == PT_ABS_RADIUS){
1871 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1872 if (aPrecision >= 0) // 'f' format in the QString
1873 LastDecimal = aPrecision;
1874 else // 'g' format in the QString
1875 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1876 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1877 if ( Abs(vz) < minRad){
1879 Group3Spin->SpinBox_DZ->setValue( - minRad );
1881 Group3Spin->SpinBox_DZ->setValue( minRad );
1884 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1886 else if ( send == Group3Spin->SpinBox_DZ ) {
1887 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1888 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1889 vz = newValue; vzStr = newValueStr;
1891 else if ( send == Group4Spin->SpinBox_DX ) {
1892 vx = newValue; vxStr = newValueStr;
1893 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1894 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1895 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1897 else if ( send == Group4Spin->SpinBox_DY ) {
1898 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1899 vy = newValue; vyStr = newValueStr;
1900 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1901 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1903 else if ( send == Group4Spin->SpinBox_DZ ) {
1904 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1905 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1906 vz = newValue; vzStr = newValueStr;
1907 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1909 else if ( send == Group4Spin->SpinBox_DS ) {
1910 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1911 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1912 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1913 vs = newValue; vsStr = newValueStr;
1915 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1917 if ( myConstructorId == 0 ) { // SEGMENT
1918 if ( mySketchType == PT_ABS ) {
1924 else if ( mySketchType == PT_RELATIVE ) {
1930 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1934 myLengthStr = vyStr;
1936 else if ( mySketchType == DIR_ANGLE_X ) {
1942 else if ( mySketchType == DIR_ANGLE_Y ) {
1948 else if ( mySketchType == DIR_PER_LENGTH ) {
1950 myLengthStr = vxStr;
1952 else if ( mySketchType == DIR_PER_X ) {
1956 else if ( mySketchType == DIR_PER_Y ) {
1960 else if ( mySketchType == DIR_TAN_LENGTH ) {
1962 myLengthStr = vxStr;
1964 else if ( mySketchType == DIR_TAN_X ) {
1968 else if ( mySketchType == DIR_TAN_Y ) {
1972 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1978 myLengthStr = vzStr;
1980 else if ( mySketchType == DIR_DXDY_X ) {
1988 else if ( mySketchType == DIR_DXDY_Y ) {
1997 else if ( myConstructorId == 1 ) { // ARC
1998 if ( mySketchType == PT_ABS ) {
2004 else if ( mySketchType == PT_RELATIVE ) {
2010 if ( mySketchType == PT_ABS_RADIUS ) {
2016 myRadiusStr = vzStr;
2018 else if ( mySketchType == PT_REL_RADIUS ) {
2024 myRadiusStr = vzStr;
2026 else if ( mySketchType == PT_SEL_RADIUS ) {
2028 myRadiusStr = vxStr;
2030 if ( mySketchType == PT_ABS_CENTER ) {
2040 else if ( mySketchType == PT_REL_CENTER ) {
2050 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2055 myRadiusStr = vyStr;
2056 myLengthStr = vzStr;
2058 else if ( mySketchType == DIR_PER_LENGTH ) {
2061 myRadiusStr = vxStr;
2062 myLengthStr = vyStr;
2064 else if ( mySketchType == DIR_TAN_LENGTH ) {
2067 myRadiusStr = vxStr;
2068 myLengthStr = vyStr;
2070 else if ( mySketchType == DIR_DXDY_LENGTH ) {
2077 myRadiusStr = vzStr;
2078 myLengthStr = vsStr;
2081 else if ( myConstructorId == 2 ) { // RECTANGLE
2082 myX1 = GroupRect->SpinBox_DX1->value(); myX1Str = GroupRect->SpinBox_DX1->text();
2083 myX2 = GroupRect->SpinBox_DX2->value(); myX2Str = GroupRect->SpinBox_DX2->text();
2084 myY1 = GroupRect->SpinBox_DY1->value(); myY1Str = GroupRect->SpinBox_DY1->text();
2085 myY2 = GroupRect->SpinBox_DY2->value(); myY2Str = GroupRect->SpinBox_DY2->text();
2090 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
2092 double x, y, xc, yc;
2093 x = y = xc = yc = 0.0;
2094 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
2096 if ( mySketchType == PT_REL_CENTER ){
2097 x = myDX + myLastX1;
2098 y = myDY + myLastY1;
2099 xc = myDXc + myLastX1;
2100 yc = myDYc + myLastY1;
2108 displayPntPreview(xc,yc);
2109 displayPntPreview(x,y);
2114 //=================================================================================
2115 // function : GetNewCommand()
2116 // purpose : Build the new command with context
2117 //=================================================================================
2118 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
2120 theParameters.clear();
2121 QString myNewCommand = ":";
2122 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2123 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2124 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2126 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2127 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2129 if ( mySketchState == FIRST_POINT ) {
2130 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2131 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2132 theParameters = myXStr + ":" + myYStr;
2134 if ( mySketchType == PT_RELATIVE) {
2135 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2136 theParameters = myDXStr + ":" + myDYStr;
2138 if (myConstructorId == 2 )
2141 return myNewCommand;
2144 if ( myConstructorId == 0 ) { // SEGMENT
2145 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2146 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2147 theParameters = myXStr + ":" + myYStr;
2149 if ( mySketchType == PT_RELATIVE) {
2150 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2151 theParameters = myDXStr + ":" + myDYStr;
2153 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2154 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2155 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2156 theParameters = myAngleStr + ":" + myLengthStr;
2158 if ( mySketchType == DIR_ANGLE_X ) {
2159 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2160 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2161 theParameters = myAngleStr + ":" + myXStr;
2163 if ( mySketchType == DIR_ANGLE_Y ) {
2164 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2165 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2166 theParameters = myAngleStr + ":" + myYStr;
2168 if ( mySketchType == DIR_PER_LENGTH ) {
2169 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2170 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2171 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
2173 if ( mySketchType == DIR_PER_X ) {
2174 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2175 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2176 theParameters = QString::number( 90.0 ) + ":" + myXStr;
2178 if ( mySketchType == DIR_PER_Y ) {
2179 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2180 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2181 theParameters = QString::number( 90.0 ) + ":" + myYStr;
2183 if ( mySketchType == DIR_TAN_LENGTH ) {
2184 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
2185 theParameters = myLengthStr;
2187 if ( mySketchType == DIR_TAN_X ) {
2188 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
2189 theParameters = myXStr;
2191 if ( mySketchType == DIR_TAN_Y) {
2192 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
2193 theParameters = myYStr;
2195 if ( mySketchType == DIR_DXDY_LENGTH ) {
2196 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2197 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2198 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
2200 if ( mySketchType == DIR_DXDY_X ) {
2201 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2202 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2203 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
2205 if ( mySketchType == DIR_DXDY_Y ) {
2206 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2207 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2208 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
2211 else if ( myConstructorId == 1 ) { // ARC
2212 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2213 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2214 theParameters = myXStr + ":" + myYStr;
2216 if ( mySketchType == PT_RELATIVE) {
2217 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2218 theParameters = myDXStr + ":" + myDYStr;
2220 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
2221 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
2222 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
2224 if ( mySketchType == PT_REL_RADIUS) {
2225 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
2226 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
2228 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2229 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 );
2230 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2232 if ( mySketchType == PT_REL_CENTER) {
2233 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 );
2234 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2236 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2237 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2238 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2239 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2241 if ( mySketchType == DIR_PER_LENGTH ) {
2242 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2243 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2244 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2246 if ( mySketchType == DIR_TAN_LENGTH ) {
2247 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2248 theParameters = myRadiusStr + ":" + myLengthStr;
2250 if ( mySketchType == DIR_DXDY_LENGTH ) {
2251 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2252 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2253 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2256 else if ( myConstructorId == 2 ) { // RECTANGLE
2257 myNewCommand = myNewCommand + "F " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2258 + ":TT " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2259 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2260 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2263 theParameters = myX1Str + ":" + myY1Str + ":" + myX1Str + ":" + myY2Str + ":" + myX2Str + ":" + myY2Str + ":" + myX2Str + ":" + myY1Str;
2265 return myNewCommand;
2268 //=================================================================================
2269 // function : createOperation
2271 //=================================================================================
2272 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2274 return getGeomEngine()->GetICurvesOperations();
2277 //=================================================================================
2278 // function : isValid
2280 //=================================================================================
2281 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2284 bool toCorrect = !IsPreview() || myIsApply;
2286 if( Group1Spin->isVisible() ) {
2287 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2289 else if( Group1Sel1Spin->isVisible() ) {
2290 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2292 else if( Group2Spin->isVisible() ) {
2293 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2294 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2296 else if( Group3Spin->isVisible() ) {
2297 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2298 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2299 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2301 else if( Group4Spin->isVisible() ) {
2302 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2303 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2304 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2305 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2308 if( myIsApply && !ok )
2314 //=================================================================================
2315 // function : execute
2317 //=================================================================================
2318 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2320 MESSAGE("EntityGUI_SketcherDlg::execute")
2321 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2322 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2323 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2325 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2326 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2328 QString aParameters;
2330 if ( mySketchState == FIRST_POINT ) {
2335 //Test if the current point is the same as the last one
2336 TopoDS_Shape myShape1, myShape2;
2337 bool isDone = false;
2340 // Set "C" numeric locale
2341 Kernel_Utils::Localizer loc;
2344 QString Command1 = myCommand.join( "" );
2345 Sketcher_Profile aProfile1( Command1.toLatin1() );
2346 myShape1 = aProfile1.GetShape();
2349 QString Command2 = Command1 + GetNewCommand( aParameters );
2350 Sketcher_Profile aProfile2( Command2.toLatin1() );
2351 myShape2 = aProfile2.GetShape( &isDone, &error );
2354 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2355 if (error > Precision::Confusion()){
2356 Group4Spin->label->show();
2357 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( error, Format, DigNum));
2360 Group4Spin->label->hide();
2364 Group4Spin->label->hide();
2365 if ( mySketchType == PT_SEL_CENTER ){
2366 if (error > Precision::Confusion()){
2367 Group2Sel->label->show();
2368 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( error, Format, DigNum));
2371 Group2Sel->label->hide();
2375 Group2Sel->label->hide();
2377 if ( myShape2.IsNull() ) {
2378 //the current point is the same as the last one
2379 myLastX2 = myLastX1;
2380 myLastY2 = myLastY1;
2383 TopoDS_Vertex V1, V2;
2385 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2386 //the last shape is the first point
2387 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2392 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2393 pt = BRep_Tool::Pnt( V2 );
2397 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2398 pt = BRep_Tool::Pnt( V2 );
2405 if ( ( mySketchState != FIRST_POINT &&
2406 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2407 cmd = myCommand.join( "" );
2408 if ( Group1Sel->isVisible() ) {
2409 Group1Sel->buttonApply->setEnabled( false );
2410 //Group1Sel->buttonApply->setFocus();
2412 if ( Group2Sel->isVisible() ) {
2413 Group2Sel->buttonApply->setEnabled( false );
2414 //Group2Sel->buttonApply->setFocus();
2416 if ( Group1Sel1Spin->isVisible() ) {
2417 Group1Sel1Spin->buttonApply->setEnabled( false );
2418 //Group1Sel1Spin->buttonApply->setFocus();
2420 if ( Group1Spin->isVisible() ) {
2421 Group1Spin->buttonApply->setEnabled( false );
2422 //Group1Spin->buttonApply->setFocus();
2424 if ( Group2Spin->isVisible() ) {
2425 Group2Spin->buttonApply->setEnabled( false );
2426 //Group2Spin->buttonApply->setFocus();
2428 if ( Group3Spin->isVisible() ) {
2429 Group3Spin->buttonApply->setEnabled( false );
2430 //Group3Spin->buttonApply->setFocus();
2432 if ( Group4Spin->isVisible() ) {
2433 Group4Spin->buttonApply->setEnabled( false );
2434 //Group4Spin->buttonApply->setFocus();
2438 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2440 if ( Group1Sel->isVisible() ) {
2441 Group1Sel->buttonApply->setEnabled( true );
2443 if ( Group2Sel->isVisible() ) {
2444 Group2Sel->buttonApply->setEnabled( true );
2446 if ( Group1Sel1Spin->isVisible() ) {
2447 Group1Sel1Spin->buttonApply->setEnabled( true );;
2449 if ( Group1Spin->isVisible() ) {
2450 Group1Spin->buttonApply->setEnabled( true );
2452 if ( Group2Spin->isVisible() ) {
2453 Group2Spin->buttonApply->setEnabled( true );
2455 if ( Group3Spin->isVisible() ) {
2456 Group3Spin->buttonApply->setEnabled( true );
2458 if ( Group4Spin->isVisible() ) {
2459 Group4Spin->buttonApply->setEnabled( true );
2463 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2464 GEOM::GEOM_Object_var anObj = NULL;
2466 int index = ComboBox1->currentIndex();
2467 if(index != -1 && !myWPlane->_is_nil()) // The combobox is not empty
2469 anObj = anOper->MakeSketcherOnPlane( cmd.toLatin1().constData(), myWPlane );
2471 if ( !anObj->_is_nil() )
2473 if( !IsPreview() ) {
2474 QStringList aCurrentParameters = myParameters;
2475 aCurrentParameters << aParameters;
2476 anObj->SetParameters(aCurrentParameters.join(":").toUtf8().constData());
2479 objects.push_back( anObj._retn() );
2485 //================================================================
2486 // Function : displayPreview
2487 // Purpose : Method for displaying preview of resulting shape
2488 // Redefined from GEOMBase_Helper.
2489 //================================================================
2490 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2492 const bool activate,
2494 const double lineWidth,
2495 const int /*displayMode*/,
2496 const int /*color*/ )
2498 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2500 QColor aColor = resMgr->colorValue("Geometry","line_color",QColor(255,0,0));
2501 Quantity_NameOfColor line_color = SalomeApp_Tools::color( aColor ).Name();
2503 // set width of displayed shape
2506 lw = resMgr->integerValue("Geometry", "preview_edge_width", -1);
2508 getDisplayer()->SetWidth( lw );
2510 // Disable activation of selection
2511 getDisplayer()->SetToActivate( activate );
2513 // Make a reference to GEOM_Object
2514 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2515 getDisplayer()->SetName( objStr.in() );
2517 // Create wire from applied object
2518 TopoDS_Shape anApplyedWire, aLastSegment;
2519 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2523 if( myConstructorId != 2)
2524 getDisplayer()->SetColor( line_color );
2526 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2528 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2529 if ( aPrs != 0 && !aPrs->IsNull() )
2530 GEOMBase_Helper::displayPreview( aPrs, append, update );
2532 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2533 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2535 if ( aPrs != 0 && !aPrs->IsNull() )
2536 GEOMBase_Helper::displayPreview( aPrs, append, update );
2538 getDisplayer()->SetColor( line_color );
2540 getDisplayer()->UnsetName();
2542 // Enable activation of displayed objects
2543 getDisplayer()->SetToActivate( true );
2546 //================================================================
2547 // Function : displayPntPreview
2548 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2549 //================================================================
2550 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2556 // Get globalCS and working plane
2557 gp_Ax3 globalCS = WPlaneToLCS( myGlobalCS );
2558 gp_Ax3 aWPlane = GetActiveLocalCS();
2560 // Build point in localCS
2561 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2563 // Get transfomation from local to global CS
2565 aTrans.SetTransformation(aWPlane, globalCS);
2567 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2568 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2570 // Perform transformation
2571 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2572 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2574 // Build prs with vertex in globalCS
2575 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2576 if ( aPrs != 0 && !aPrs->IsNull() )
2577 GEOMBase_Helper::displayPreview( aPrs, append, update );
2581 //================================================================
2582 // Function : createShapes
2583 // Purpose : Create applyed wire, and last segment from entry object
2584 //================================================================
2585 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2586 TopoDS_Shape& theApplyedWire,
2587 TopoDS_Shape& theLastSegment )
2589 TopoDS_Shape aShape;
2590 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2591 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2594 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2595 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2596 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2597 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2598 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2599 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2600 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2601 theApplyedWire = aShape;
2605 BRepBuilderAPI_MakeWire aBuilder;
2606 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2608 TopoDS_Shape anEdge = anExp.Current();
2610 if ( anExp.More() ) // i.e. non-last edge
2611 aBuilder.Add( TopoDS::Edge( anEdge ) );
2613 theLastSegment = anEdge;
2618 if ( aBuilder.IsDone() )
2619 theApplyedWire = aBuilder.Shape();
2624 //=================================================================================
2625 // function : acceptMouseEvent()
2627 //=================================================================================
2628 bool EntityGUI_SketcherDlg::acceptMouseEvent() const
2630 return ( (getPnt1ConstructorId() == 1
2631 || getPnt1ConstructorId() == 0
2632 || myConstructorId == 2) //accept mouse event only on absolute and relative selection mode
2633 && !WPlaneLineEdit->isEnabled()); //or when the constructor is rectangle
2634 //called by EntityGUI::OnMousePress()
2637 //=================================================================================
2638 // function : keyPressEvent()
2640 //=================================================================================
2641 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2643 QDialog::keyPressEvent( e );
2644 if ( e->isAccepted() )
2647 if ( e->key() == Qt::Key_F1 ) {
2653 //=================================================================================
2654 // function : initSpinBox()
2656 //=================================================================================
2657 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2658 double min, double max,
2659 double step, const char* quantity )
2661 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2662 // TODO: Think how to keep the single piece of code...
2664 // Obtain precision from preferences
2665 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2666 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2668 spinBox->setPrecision( aPrecision );
2669 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2670 // by default Qt rounds boundaries to 2 decimals at setRange
2671 spinBox->setRange( min, max );
2672 spinBox->setSingleStep( step );
2674 // Add a hint for the user saying how to tune precision
2675 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2676 spinBox->setProperty( "validity_tune_hint",
2677 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2680 //=================================================================================
2681 // function : SetDoubleSpinBoxStep()
2682 // purpose : Double spin box management
2683 //=================================================================================
2684 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2686 Group1Spin->SpinBox_DX->setSingleStep(step);
2687 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2688 Group2Spin->SpinBox_DX->setSingleStep(step);
2689 Group2Spin->SpinBox_DY->setSingleStep(step);
2690 Group3Spin->SpinBox_DX->setSingleStep(step);
2691 Group3Spin->SpinBox_DY->setSingleStep(step);
2692 Group3Spin->SpinBox_DZ->setSingleStep(step);
2693 Group4Spin->SpinBox_DZ->setSingleStep(step);
2695 // san: Do NOT override the step when a speicifc step value is used
2696 // in some input fields!
2697 //Group4Spin->SpinBox_DX->setSingleStep(step);
2698 //Group4Spin->SpinBox_DY->setSingleStep(step);
2699 //Group4Spin->SpinBox_DS->setSingleStep(step);
2702 //=================================================================================
2703 // function : AddLocalCS()
2704 // purpose : Add All Coordinates systems in study
2705 //=================================================================================
2706 void EntityGUI_SketcherDlg::AddLocalCS(GEOM::GEOM_Object_var aSelectedObject)
2708 QString aName = GEOMBase::GetName( aSelectedObject );
2710 int index = ComboBox1->findText(aName, Qt::MatchExactly);
2712 if (index==-1) // If the working plane hasn't been added yet
2714 myWPlaneList.push_back(aSelectedObject);
2715 myWPlane = aSelectedObject;
2716 addSubshapesToStudy();
2717 myLCSList.push_back(WPlaneToLCS(aSelectedObject));
2718 ComboBox1->addItem(aName);
2719 index = ComboBox1->count();
2720 ComboBox1->setCurrentIndex(index-1);
2724 ComboBox1->setCurrentIndex(index);
2729 //=================================================================================
2730 // function : FindLocalCS()
2731 // purpose : Find All Coordinates systems in study
2732 //=================================================================================
2733 void EntityGUI_SketcherDlg::FindLocalCS()
2736 myWPlaneList.clear();
2737 SalomeApp_Application* app =
2738 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2742 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2746 _PTR(Study) aStudy = appStudy->studyDS();
2749 ComboBox1->addItem(tr("GEOM_GCS"));
2750 myWPlaneList.push_back(myGlobalCS);
2752 // get GEOM component
2753 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2754 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2757 _PTR(SComponent) fc = obj->GetFatherComponent();
2758 QString geomComp = fc->GetID().c_str();
2759 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toUtf8().data() );
2763 // browse through all GEOM data tree
2764 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2765 for ( it->InitEx( true ); it->More(); it->Next() )
2767 _PTR(SObject) child( it->Value() );
2768 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2769 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2770 if( CORBA::is_nil( geomObj ) )
2772 if (geomObj->GetType() == GEOM_MARKER)
2774 myWPlaneList.push_back(geomObj);
2775 myLCSList.push_back(WPlaneToLCS(geomObj));
2776 ComboBox1->addItem(geomObj->GetName());
2781 //=================================================================================
2782 // function : WPlaneToLCS ( aWPlane )
2784 //=================================================================================
2785 gp_Ax3 EntityGUI_SketcherDlg::WPlaneToLCS( GEOM::GEOM_Object_var geomObj )
2787 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2790 if (CORBA::is_nil( geomObj ) || aShape.IsNull())
2792 MESSAGE("CORBA::is_nil( geomObj ) || aShape.IsNull()")
2794 aLCS.Transform(aShape.Location().Transformation());
2795 if (aShape.ShapeType() == TopAbs_FACE)
2797 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
2798 myGeometryGUI->GetGeomGen()->GetIMeasureOperations();
2799 double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
2800 aMeasureOp->GetPosition( geomObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
2801 if ( aMeasureOp->IsDone() )
2803 gp_Pnt aPnt ( Ox, Oy, Oz );
2804 gp_Dir aDirN ( Zx, Zy, Zz );
2805 gp_Dir aDirX ( Xx, Xy, Xz );
2806 aLCS = gp_Ax3( aPnt, aDirN, aDirX );
2813 //=================================================================================
2814 // function : getPnt1ConstructorId()
2816 //=================================================================================
2817 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2819 int buttonId = GroupPt->ButtonGroup->checkedId();
2820 // MESSAGE("buttonId = "<<buttonId)
2824 //=================================================================================
2825 // function : getPnt2ConstructorId()
2827 //=================================================================================
2828 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2830 int buttonId = GroupPt2->ButtonGroup->checkedId();
2831 // MESSAGE("buttonId = "<<buttonId)
2835 //=================================================================================
2836 // function : GetActiveLocalCS()
2837 // purpose : Get Working plane
2838 //=================================================================================
2839 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2841 int ind = ComboBox1->currentIndex();
2843 return myGeometryGUI->GetWorkingPlane();
2845 gp_Ax3 aLCS = myLCSList.at(ind);
2846 myWPlane = myWPlaneList.at(ind);
2851 //=================================================================================
2852 // function : ActivateLocalCS()
2853 // purpose : Activate & Fit Working plane
2854 //=================================================================================
2855 void EntityGUI_SketcherDlg::ActivateLocalCS()
2857 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2858 myGeometryGUI->ActiveWorkingPlane();
2861 //=================================================================================
2862 // function : addSubshapeToStudy
2863 // purpose : virtual method to add new SubObjects if local selection
2864 //=================================================================================
2865 void EntityGUI_SketcherDlg::addSubshapesToStudy()
2867 GEOMBase::PublishSubObject(myWPlane);