1 // Copyright (C) 2007-2016 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"
56 #include <BRep_Tool.hxx>
58 #include <TopExp_Explorer.hxx>
59 #include <TopoDS_Vertex.hxx>
61 #include <BRepBuilderAPI_Transform.hxx>
62 #include <BRepBuilderAPI_MakeWire.hxx>
63 #include <BRepBuilderAPI_MakeVertex.hxx>
64 #include <Sketcher_Profile.hxx>
66 #include <SalomeApp_Study.h>
67 #include <SalomeApp_Tools.h>
68 #include "utilities.h"
72 #include <Basics_Utils.hxx>
74 //=================================================================================
75 // class : EntityGUI_SketcherDlg()
76 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
77 // name 'name' and widget flags set to 'f'.
78 // The dialog will by default be modeless, unless you set 'modal' to
79 // TRUE to construct a modal dialog.
80 //=================================================================================
81 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
82 bool modal, Qt::WindowFlags fl,
83 const double lineWidth )
84 : QDialog( parent, fl ),
85 myIsAllAdded( false ),
87 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
89 myLineWidth( lineWidth )
91 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
93 setAttribute( Qt::WA_DeleteOnClose );
95 // Disable rectangular selection
96 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
97 // ((OCCViewer_ViewWindow*)theViewWindow)->setEnabledDrawMode( false );
98 // MESSAGE("((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode();"<<((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode())
99 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
100 // vp->setSketchingEnabled( false );
101 // MESSAGE("vp->isSketchingEnabled()"<<vp->isSketchingEnabled())
102 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(true);
103 // OCCViewer_ViewSketcher* aViewSketcher = ((OCCViewer_ViewWindow*)theViewWindow)->getSketcher( OCCViewer_ViewWindow::Rect );
104 // aViewSketcher->deactivate()
105 // aViewSketcher->setVisible(false);
107 // this->setMouseTracking(false);
109 myGeometryGUI->SetActiveDialogBox(this);
111 MainWidget = new EntityGUI_Skeleton( this );
112 QVBoxLayout* topLayout = new QVBoxLayout( this );
113 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
115 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
116 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_CLOSE" ) );
117 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
118 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
120 QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
121 QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
122 QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
123 QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
124 QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) );
125 QPixmap image5 (aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
126 QPixmap image6 (aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_RECTANGLE" ) ) );
128 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
130 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
131 MainWidget->RadioButton1->setText( "" );
132 MainWidget->RadioButton1->setIcon( image3 );
133 MainWidget->RadioButton2->setText( "" );
134 MainWidget->RadioButton2->setIcon( image4 );
135 MainWidget->RadioButton3->setText( "" );
136 MainWidget->RadioButton3->setIcon( image6 );
137 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
138 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
139 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
140 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
142 /***************************************************************/
144 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
145 QGridLayout* planeLayout = new QGridLayout(GroupBox1);
146 planeLayout->setSpacing(6);
147 planeLayout->setMargin(11);
149 ComboBox1 = new QComboBox(GroupBox1);
150 planeLayout->addWidget(ComboBox1,0,0,1,2);
152 planeButton = new QPushButton (GroupBox1);
153 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
154 planeLayout->addWidget(planeButton,0,2);
156 selButton = new QPushButton (GroupBox1);
157 selButton->setIcon(image5);
158 planeLayout->addWidget(selButton,1,0);
160 WPlaneLineEdit = new QLineEdit (GroupBox1);
161 WPlaneLineEdit->setReadOnly(true);
162 planeLayout->addWidget(WPlaneLineEdit,1,1,1,2);
164 planeLayout->setColumnStretch(1,1);
166 topLayout->addWidget(GroupBox1);
167 topLayout->addWidget( MainWidget );
168 topLayout->setStretch( 1, 1);
170 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
172 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
173 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
174 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
175 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
177 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
179 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
180 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
181 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
182 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
184 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
186 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
187 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
188 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
189 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
190 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
192 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
194 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIST" ) );
195 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
196 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
197 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
199 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
200 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
201 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
202 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
203 Group1Sel->PushButton1->setIcon( image0 );
204 Group1Sel->buttonUndo->setIcon( image1 );
205 Group1Sel->buttonRedo->setIcon( image2 );
206 Group1Sel->LineEdit1->setReadOnly( true );
208 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
209 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
210 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
211 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
212 Group2Sel->PushButton1->setIcon( image0 );
213 Group2Sel->PushButton2->setIcon( image0 );
214 Group2Sel->buttonUndo->setIcon( image1 );
215 Group2Sel->buttonRedo->setIcon( image2 );
216 Group2Sel->LineEdit1->setReadOnly( true );
217 Group2Sel->LineEdit2->setReadOnly( true );
219 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
220 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
221 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
222 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
223 Group1Sel1Spin->PushButton1->setIcon( image0 );
224 Group1Sel1Spin->buttonUndo->setIcon( image1 );
225 Group1Sel1Spin->buttonRedo->setIcon( image2 );
226 Group1Sel1Spin->LineEdit1->setReadOnly( true );
228 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
229 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
230 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
231 Group1Spin->buttonUndo->setIcon( image1 );
232 Group1Spin->buttonRedo->setIcon( image2 );
234 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
235 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
236 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
237 Group2Spin->buttonUndo->setIcon( image1 );
238 Group2Spin->buttonRedo->setIcon( image2 );
240 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
241 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
242 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
243 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
244 Group3Spin->buttonUndo->setIcon( image1 );
245 Group3Spin->buttonRedo->setIcon( image2 );
247 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
248 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
249 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
250 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
251 Group4Spin->buttonUndo->setIcon( image1 );
252 Group4Spin->buttonRedo->setIcon( image2 );
254 GroupRect = new DlgRef_4Spin( MainWidget->SkeletonCnt );
255 GroupRect->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
256 GroupRect->TextLabel1->setText("X1:");
257 GroupRect->TextLabel2->setText("Y1:");
258 GroupRect->TextLabel3->setText("X2:");
259 GroupRect->TextLabel4->setText("Y2:");
261 // Defines a palette for the error message on Group4Spin and Group2Sel
264 palette.setColor(Group4Spin->label->foregroundRole(), color);
265 Group4Spin->label->setPalette(palette);
266 palette.setColor(Group2Sel->label->foregroundRole(), color);
267 Group2Sel->label->setPalette(palette);
269 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
270 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
271 DestCntLayout->addWidget( GroupPt, 0, 0 );
272 DestCntLayout->addWidget( GroupPt2, 0, 1 );
273 DestCntLayout->addWidget( GroupD1, 0, 0 );
274 DestCntLayout->addWidget( GroupD2, 0, 1 );
276 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
277 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
278 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
279 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
280 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
281 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
282 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
283 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
284 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
285 SkeletonCntlayout->addWidget( GroupRect, 0, 0 );
286 //SkeletonCntlayout->setStretch( 0, 1);
287 /***************************************************************/
289 QButtonGroup* ButtonGroup = new QButtonGroup( this );
290 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
291 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
293 /* signals and slots connections */
294 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
295 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
296 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
297 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
299 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
300 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
301 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
302 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
303 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
304 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
305 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
306 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
307 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
308 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
309 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
310 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
311 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
312 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
313 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
314 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
315 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
316 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
317 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
318 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
319 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
321 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
322 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
323 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
324 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
325 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
326 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
328 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
329 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
331 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
332 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
333 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
334 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
336 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
337 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
338 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
340 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
341 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
342 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
343 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
344 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
345 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
346 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
347 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
348 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
349 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
350 connect( GroupRect->SpinBox_DX1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
351 connect( GroupRect->SpinBox_DX2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
352 connect( GroupRect->SpinBox_DY1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
353 connect( GroupRect->SpinBox_DY2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
355 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
356 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
357 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
358 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
360 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ActivateLocalCS() ) );
361 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
362 connect( selButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
364 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
366 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
367 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
369 // install event filter on spin-boxes to provide Apply action on Return pressed
370 Group1Spin->SpinBox_DX->installEventFilter(this);
371 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
372 Group2Spin->SpinBox_DX->installEventFilter(this);
373 Group2Spin->SpinBox_DY->installEventFilter(this);
374 Group3Spin->SpinBox_DX->installEventFilter(this);
375 Group3Spin->SpinBox_DY->installEventFilter(this);
376 Group3Spin->SpinBox_DZ->installEventFilter(this);
377 Group4Spin->SpinBox_DX->installEventFilter(this);
378 Group4Spin->SpinBox_DY->installEventFilter(this);
379 Group4Spin->SpinBox_DZ->installEventFilter(this);
380 Group4Spin->SpinBox_DS->installEventFilter(this);
386 //=================================================================================
387 // function : ~EntityGUI_SketcherDlg()
388 // purpose : Destroys the object and frees any allocated resources
389 //=================================================================================
390 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
392 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
394 myGeometryGUI->SetActiveDialogBox( 0 );
395 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(false);
399 //=================================================================================
400 // function : eventFilter()
401 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
402 //=================================================================================
403 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
405 if (event->type() == QEvent::KeyPress) {
406 QKeyEvent* ke = (QKeyEvent*)event;
407 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
408 if (object == Group1Spin->SpinBox_DX) {
409 Group1Spin->buttonApply->click();
411 } else if (object == Group1Sel1Spin->SpinBox_DX) {
412 Group1Sel1Spin->buttonApply->click();
414 } else if (object == Group2Spin->SpinBox_DX ||
415 object == Group2Spin->SpinBox_DY) {
416 Group2Spin->buttonApply->click();
418 } else if (object == Group3Spin->SpinBox_DX ||
419 object == Group3Spin->SpinBox_DY ||
420 object == Group3Spin->SpinBox_DZ) {
421 Group3Spin->buttonApply->click();
423 } else if (object == Group4Spin->SpinBox_DX ||
424 object == Group4Spin->SpinBox_DY ||
425 object == Group4Spin->SpinBox_DZ ||
426 object == Group4Spin->SpinBox_DS) {
427 Group4Spin->buttonApply->click();
433 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
435 return QDialog::eventFilter(object, event);
439 //=================================================================================
442 //=================================================================================
443 void EntityGUI_SketcherDlg::Init()
448 myEditCurrentArgument = WPlaneLineEdit; // Initiate the parameters selection with the first WPlaneLineEdit
450 myCommand.append( "Sketcher" );
451 myUndoCommand.append( "Sketcher" );
453 mySketchState = FIRST_POINT;
454 globalSelection( GEOM_FACE );
463 myHelpFileName = "create_sketcher_page.html";
465 GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
466 myGlobalCS = aBasicOp->MakeMarker( 0,0,0,
469 myWPlane = myGlobalCS;
470 myLCSList.push_back( WPlaneToLCS(myGlobalCS) );
472 /* Get setting of step value from file configuration */
473 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
475 /* min, max, step and decimals for spin boxes */
476 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
477 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
478 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
479 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
480 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
481 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
482 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
483 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
484 // san: Note specific step values below!
485 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
486 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
487 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
489 initSpinBox( GroupRect->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
490 initSpinBox( GroupRect->SpinBox_DY1, COORD_MIN, COORD_MAX, step, "length_precision" );
491 initSpinBox( GroupRect->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
492 initSpinBox( GroupRect->SpinBox_DY2, COORD_MIN, COORD_MAX, step, "length_precision" );
494 /* displays Dialog */
496 // MainWidget->RadioButton1->setEnabled( false );
497 // MainWidget->RadioButton2->setEnabled( false );
498 // MainWidget->RadioButton3->setEnabled( true );
499 // MainWidget->GroupDest1->setEnabled( false );
500 setEnabledUndo( false );
501 setEnabledRedo( false );
503 MainWidget->RadioButton1->setChecked( true );
507 // If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox
508 // that should be filled with the possibly selected face
512 SelectionIntoArgument();
516 setPrefix(tr("GEOM_SKETCH"));
520 setIsWaitCursorEnabled( false );
521 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
525 //=================================================================================
526 // function : InitClick()
528 //=================================================================================
529 void EntityGUI_SketcherDlg::InitClick()
531 MESSAGE("EntityGUI_SketcherDlg::InitClick()")
532 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
537 Group1Sel1Spin->hide();
543 globalSelection(); // close local selection to clear it
544 localSelection( TopAbs_VERTEX );
548 //=================================================================================
549 // function : TypeClicked()
550 // purpose : Radio button management
551 //=================================================================================
552 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
554 myConstructorId = constructorId;
555 MainWidget->buttonEnd->setText(tr("GEOM_BUT_CLOSE"));
556 MainWidget->buttonClose->setEnabled(true);
558 if ( myConstructorId == 0 ) { // SEGMENT
559 GroupPt2->RB_Point1->setChecked( true );
560 GroupPt ->setEnabled( true );
561 GroupPt2->setEnabled( false );
562 GroupD1->setEnabled( true );
563 GroupD2->setEnabled( true );
564 MainWidget->RB_Dest1->setEnabled( true );
565 MainWidget->RB_Dest1->setChecked( true );
567 MainWidget->GroupDest ->setEnabled( true );
568 MainWidget->GroupDest1->setEnabled( true );
569 MainWidget->GroupDest ->show();
570 MainWidget->GroupDest1->show();
572 if (mySketchState == FIRST_POINT)
577 else if ( myConstructorId == 1 ) { // ARC
578 GroupPt ->setEnabled( true );
579 GroupPt2->setEnabled( true );
580 GroupD2->RB_Dir21->setChecked( true );
581 GroupD1->setEnabled( true );
582 GroupD2->setEnabled( false );
583 MainWidget->RB_Dest1->setEnabled( true );
584 MainWidget->RB_Dest1->setChecked( true );
586 MainWidget->GroupDest ->setEnabled( true );
587 MainWidget->GroupDest1->setEnabled( true );
588 MainWidget->GroupDest ->show();
589 MainWidget->GroupDest1->show();
591 if (mySketchState == FIRST_POINT)
596 else if ( myConstructorId == 2 ) { // RECTANGLE
597 GroupPt ->setEnabled( false );
598 GroupPt2->setEnabled( false );
599 GroupD1 ->setEnabled( false );
600 GroupD2 ->setEnabled( false );
601 MainWidget->GroupDest ->setEnabled( false );
602 MainWidget->GroupDest1->setEnabled( false );
608 MainWidget->GroupDest ->hide();
609 MainWidget->GroupDest1->hide();
611 MainWidget->buttonEnd->setText(tr("Apply and Close"));
612 MainWidget->buttonClose->setEnabled(false);
614 GroupRect->setEnabled( true );
615 MainWidget->RadioButton1->setEnabled( true );
616 MainWidget->RadioButton2->setEnabled( true );
622 //=================================================================================
623 // function : RectClicked()
624 // purpose : Radio button management
625 //=================================================================================
626 void EntityGUI_SketcherDlg::RectClicked()
630 // Connect the selection manager (disconnected in InitClick())
631 connect( myGeometryGUI->getApp()->selectionMgr(),
632 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
637 GroupRect->SpinBox_DX1->setValue(myX1);
639 GroupRect->SpinBox_DY1->setValue(myY1);
641 GroupRect->SpinBox_DX2->setValue(myX2);
643 GroupRect->SpinBox_DY2->setValue(myY2);
645 resize( minimumSizeHint() );
647 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
651 //=================================================================================
652 // function : DestClicked()
653 // purpose : Radio button management
654 //=================================================================================
655 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
662 if ( constructorId == 1 ) {
664 GroupPt->RB_Point1->setChecked( true );
667 Group3Spin->checkBox->show();
668 Group4Spin->checkBox->show();
669 PointClicked( 1 ); // XY
671 else if ( constructorId == 0 ) {
673 GroupD1->RB_Dir11->setChecked( true );
676 Group3Spin->checkBox->hide();
677 Group4Spin->checkBox->hide();
678 if (myConstructorId == 1) {
685 Dir1Clicked( 2 ); // Angle
687 resize( minimumSizeHint() );
690 //=================================================================================
691 // function : PointClicked()
692 // purpose : Radio button management
693 //=================================================================================
694 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
696 MESSAGE("PointClicked")
697 myConstructorPntId = constructorId;
698 GroupPt->RB_Point3->setEnabled( true );
699 int buttonId = GroupPt2->ButtonGroup->checkedId();
700 if (buttonId >= 0){ // = If a button is checked
701 Point2Clicked(buttonId);
704 GroupPt2->RB_Point1->setChecked( true );
709 //=================================================================================
710 // function : Point2Clicked()
711 // purpose : Radio button management
712 //=================================================================================
713 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
715 MESSAGE("Point2Clicked")
718 // Get setting of step value from file configuration
719 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
721 if ( myConstructorPntId == 1 ) { // XY
722 if ( constructorId == 1 ){ // No additional parameter
723 mySketchType = PT_ABS;
724 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
725 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
726 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
727 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
729 Group2Spin->SpinBox_DX->setValue( myX );
731 Group2Spin->SpinBox_DY->setValue( myY );
733 Group2Spin->buttonApply->setFocus();
735 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
737 else if ( constructorId == 0 ){ // Point + radius
738 mySketchType = PT_ABS_RADIUS;
739 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
740 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
741 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
742 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
743 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
744 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
746 Group3Spin->SpinBox_DX->setValue( myX );
748 Group3Spin->SpinBox_DY->setValue( myY );
750 Group3Spin->SpinBox_DZ->setValue( myRadius );
752 Group3Spin->buttonApply->setFocus();
754 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
756 else if ( constructorId == 2 ){ // Point + center
757 mySketchType = PT_ABS_CENTER;
758 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
759 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
760 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
761 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
762 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
763 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
764 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
765 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
767 Group4Spin->SpinBox_DX->setValue( myXc );
769 Group4Spin->SpinBox_DY->setValue( myYc );
771 Group4Spin->SpinBox_DZ->setValue( myX );
773 Group4Spin->SpinBox_DS->setValue( myY );
775 Group4Spin->buttonApply->setFocus();
777 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
781 else if ( myConstructorPntId == 0 ) { // DXDY
782 if ( constructorId == 1 ){ // No additional parameter
783 mySketchType = PT_RELATIVE;
784 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
785 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
786 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
787 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
789 Group2Spin->SpinBox_DX->setValue( myDX );
791 Group2Spin->SpinBox_DY->setValue( myDY );
793 Group2Spin->buttonApply->setFocus();
795 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
797 else if ( constructorId == 0 ){ // Point + radius
798 mySketchType = PT_REL_RADIUS;
799 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
800 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
801 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
802 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
803 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
804 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
806 Group3Spin->SpinBox_DX->setValue( myDX );
808 Group3Spin->SpinBox_DY->setValue( myDY );
810 Group3Spin->SpinBox_DZ->setValue( myRadius );
812 Group3Spin->buttonApply->setFocus();
814 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
816 else if ( constructorId == 2 ){ // Point + center
817 mySketchType = PT_REL_CENTER;
818 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
819 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
820 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
821 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
822 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
823 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
824 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
825 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
827 Group4Spin->SpinBox_DX->setValue( myDXc );
829 Group4Spin->SpinBox_DY->setValue( myDYc );
831 Group4Spin->SpinBox_DZ->setValue( myDX );
833 Group4Spin->SpinBox_DS->setValue( myDY );
835 Group4Spin->buttonApply->setFocus();
837 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
841 else if ( myConstructorPntId == 2 ) { // Selection
842 if ( constructorId == 1 ){ // No additional parameter
843 mySketchType = PT_SEL;
844 myEditCurrentArgument = Group1Sel->LineEdit1;
845 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
847 Group1Sel->buttonApply->setFocus();
848 SelectionIntoArgument();
850 else if ( constructorId == 0 ){ // Point + radius
851 mySketchType = PT_SEL_RADIUS;
852 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
853 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
854 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
855 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
857 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
859 Group1Sel1Spin->show();
860 Group1Sel1Spin->buttonApply->setFocus();
861 SelectionIntoArgument();
863 else if ( constructorId == 2 ){ // Point + center
864 mySketchType = PT_SEL_CENTER;
865 myEditCurrentArgument = Group2Sel->LineEdit1;
866 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
867 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
868 Group2Sel->LineEdit1->setEnabled(true);
869 Group2Sel->PushButton1->setDown(true);
870 Group2Sel->LineEdit2->setEnabled(false);
871 Group2Sel->PushButton2->setDown(false);
873 Group2Sel->buttonApply->setFocus();
874 SelectionIntoArgument();
878 resize( minimumSizeHint() );
879 connect( myGeometryGUI->getApp()->selectionMgr(),
880 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
885 //=================================================================================
886 // function : Dir1Clicked()
887 // purpose : Radio button management
888 //=================================================================================
889 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
891 myConstructorDirId = constructorId;
892 int dirButtonId = GroupD2->ButtonGroup->checkedId();
893 if (dirButtonId >= 0){ // = If a button is checked
894 Dir2Clicked(dirButtonId);
897 GroupD2->RB_Dir21->setChecked( true );
903 //=================================================================================
904 // function : Dir2Clicked()
905 // purpose : Radio button management
906 //=================================================================================
907 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
910 Group3Spin->SpinBox_DX->blockSignals(true); // Block signals in order not to modify
911 Group3Spin->SpinBox_DY->blockSignals(true); // default values
912 Group3Spin->SpinBox_DZ->blockSignals(true);
914 Group2Spin->SpinBox_DX->blockSignals(true);
915 Group2Spin->SpinBox_DY->blockSignals(true);
917 Group4Spin->SpinBox_DX->blockSignals(true);
918 Group4Spin->SpinBox_DY->blockSignals(true);
919 Group4Spin->SpinBox_DZ->blockSignals(true);
920 Group4Spin->SpinBox_DS->blockSignals(true);
922 // Get setting of step value from file configuration
923 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
925 if ( myConstructorId == 0 ) { // SEGMENT
929 if ( myConstructorDirId == 2 ) { // Angle
930 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
931 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
932 Group2Spin->SpinBox_DX->setValue( myAngle );
933 Group2Spin->buttonApply->setFocus();
936 if ( constructorId == 2 ) { // Length
937 mySketchType = DIR_ANGLE_LENGTH;
938 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
939 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
940 Group2Spin->SpinBox_DY->setValue( myLength );
942 else if ( constructorId == 0 ) { // X
943 mySketchType = DIR_ANGLE_X;
944 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
945 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X2" ) );
946 Group2Spin->SpinBox_DY->setValue( myX );
948 else if ( constructorId == 1 ) { // Y
949 mySketchType = DIR_ANGLE_Y;
950 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
951 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
952 Group2Spin->SpinBox_DY->setValue( myY );
955 else if ( myConstructorDirId == 0 ) { // Perpendicular
957 Group1Spin->buttonApply->setFocus();
959 if ( constructorId == 2 ) { // Length
960 mySketchType = DIR_PER_LENGTH;
961 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
962 Group1Spin->SpinBox_DX->setValue( myLength );
964 else if ( constructorId == 0 ) { // X
965 mySketchType = DIR_PER_X;
966 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
967 Group1Spin->SpinBox_DX->setValue( myX );
969 else if ( constructorId == 1 ) { // Y
970 mySketchType = DIR_PER_Y;
971 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y2" ) );
972 Group1Spin->SpinBox_DX->setValue( myY );
975 else if ( myConstructorDirId == 1 ) { // Tangent
977 Group1Spin->buttonApply->setFocus();
979 if ( constructorId == 2 ) { // Length
980 mySketchType = DIR_TAN_LENGTH;
981 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
982 Group1Spin->SpinBox_DX->setValue( myLength );
984 else if ( constructorId == 0 ) { // X
985 mySketchType = DIR_TAN_X;
986 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
987 Group1Spin->SpinBox_DX->setValue( myX );
989 else if ( constructorId == 1 ) { // Y
990 mySketchType = DIR_TAN_Y;
991 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y2" ) );
992 Group1Spin->SpinBox_DX->setValue( myY );
995 else if ( myConstructorDirId == 3 ) { // DXDY
996 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
997 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
998 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
999 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
1000 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
1001 Group3Spin->SpinBox_DX->setValue( myDX );
1002 Group3Spin->SpinBox_DY->setValue( myDY );
1004 Group3Spin->buttonApply->setFocus();
1006 if ( constructorId == 2 ) { // Length
1007 mySketchType = DIR_DXDY_LENGTH;
1008 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
1009 Group3Spin->SpinBox_DZ->setValue( myLength );
1011 else if ( constructorId == 0 ) { // X
1012 mySketchType = DIR_DXDY_X;
1013 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
1014 Group3Spin->SpinBox_DZ->setValue( myX );
1016 else if ( constructorId == 1 ) { // Y
1017 mySketchType = DIR_DXDY_Y;
1018 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y2" ) );
1019 Group3Spin->SpinBox_DZ->setValue( myY );
1023 else if ( myConstructorId == 1 ) { // ARC
1024 if ( myConstructorDirId == 2 ) { // Angle
1025 if ( constructorId == 2 ) { // Length
1026 mySketchType = DIR_ANGLE_LENGTH;
1027 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1028 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1029 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1030 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1031 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1032 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
1033 Group3Spin->SpinBox_DX->setValue( myAngle );
1034 Group3Spin->SpinBox_DY->setValue( myRadius );
1035 Group3Spin->SpinBox_DZ->setValue( myLength );
1037 Group3Spin->buttonApply->setFocus();
1040 else if ( myConstructorDirId == 0 ) { // Perpendicular
1041 if ( constructorId == 2 ) { // Length
1042 mySketchType = DIR_PER_LENGTH;
1043 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1044 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1045 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1046 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1047 // myRadius = 100.0;
1048 Group2Spin->SpinBox_DX->setValue( myRadius );
1050 Group2Spin->SpinBox_DY->setValue( myLength );
1052 Group2Spin->buttonApply->setFocus();
1055 else if ( myConstructorDirId == 1 ) { // Tangent
1056 if ( constructorId == 2 ) { // Length
1057 mySketchType = DIR_TAN_LENGTH;
1058 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1059 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1060 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1061 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1062 // myRadius = 100.0;
1063 Group2Spin->SpinBox_DX->setValue( myRadius );
1065 Group2Spin->SpinBox_DY->setValue( myLength );
1067 Group2Spin->buttonApply->setFocus();
1070 else if ( myConstructorDirId == 3 ) { // DXDY
1071 if ( constructorId == 2 ) { // Length
1072 mySketchType = DIR_DXDY_LENGTH;
1073 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
1074 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
1075 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1076 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1077 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
1078 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
1079 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
1080 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
1081 Group4Spin->SpinBox_DX->setValue( myDX );
1082 Group4Spin->SpinBox_DY->setValue( myDY );
1083 // myRadius = 100.0;
1084 Group4Spin->SpinBox_DZ->setValue( myRadius );
1086 Group4Spin->SpinBox_DS->setValue( myLength );
1088 Group4Spin->buttonApply->setFocus();
1092 Group3Spin->SpinBox_DX->blockSignals(false); // Restore signals
1093 Group3Spin->SpinBox_DY->blockSignals(false);
1094 Group3Spin->SpinBox_DZ->blockSignals(false);
1096 Group2Spin->SpinBox_DX->blockSignals(false);
1097 Group2Spin->SpinBox_DY->blockSignals(false);
1099 Group4Spin->SpinBox_DX->blockSignals(false);
1100 Group4Spin->SpinBox_DY->blockSignals(false);
1101 Group4Spin->SpinBox_DZ->blockSignals(false);
1102 Group4Spin->SpinBox_DS->blockSignals(false);
1104 resize( minimumSizeHint() );
1105 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1108 //=================================================================================
1109 // function : CheckBoxClicked()
1110 // purpose : CheckBox management
1111 //=================================================================================
1112 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
1114 myCheckFlag = State;
1116 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1120 //=================================================================================
1121 // function : ClickOnCancel()
1123 //=================================================================================
1124 void EntityGUI_SketcherDlg::ClickOnCancel()
1130 //=================================================================================
1131 // function : ClickOnEnd()
1132 // purpose : connected to buttonEnd AND buttonClose
1133 //=================================================================================
1134 void EntityGUI_SketcherDlg::ClickOnEnd()
1136 MESSAGE("EntityGUI_SketcherDlg::ClickOnEnd()")
1137 if ( sender() == MainWidget->buttonClose ) {
1138 // Verify validity of commands
1139 if ( myCommand.count() <= 2 ) {
1140 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
1141 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
1145 QString Command = myCommand.join( "" );
1146 Sketcher_Profile aProfile = Sketcher_Profile( Command.toLatin1() );
1147 bool isDone = false;
1148 TopoDS_Shape myShape = aProfile.GetShape( &isDone );
1150 if ( myShape.ShapeType() != TopAbs_VERTEX )
1151 myCommand.append( ":WW" );
1155 /*// PAL16008 (Sketcher Validation should be equal to Apply&Close)
1156 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
1157 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
1158 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
1159 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
1160 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
1161 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
1162 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
1165 // ClickOnApply(); // TEST remove then
1166 myIsAllAdded = true;
1169 if (myConstructorId == 2)
1171 QString aParameters;
1172 myCommand.append( GetNewCommand( aParameters ) );
1173 mySketchState = NEXT_POINT;
1177 if ( myCommand.size() > 2 )
1186 //=================================================================================
1187 // function : ClickOnApply()
1189 //=================================================================================
1190 bool EntityGUI_SketcherDlg::ClickOnApply()
1192 MESSAGE("EntityGUI_SketcherDlg::ClickOnApply()")
1193 if ( sender() && sender()->inherits( "QPushButton" ) )
1194 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1196 // addSubshapesToStudy();
1198 QString aParameters;
1199 myCommand.append( GetNewCommand( aParameters ) );
1200 if (mySketchState == FIRST_POINT)
1202 mySketchState = NEXT_POINT;
1206 myUndoCommand.clear();
1207 myUndoCommand.append( "Sketcher" );
1209 myParameters.append( aParameters );
1210 myUndoParameters.clear();
1212 setEnabledUndo( true );
1213 setEnabledRedo( false );
1216 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1219 // Set focus to SpinBox_DX
1220 if ( sender() == Group1Spin->buttonApply ) {
1221 (Group1Spin->SpinBox_DX)->setFocus();
1222 (Group1Spin->SpinBox_DX)->selectAll();
1224 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1225 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1226 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1228 else if ( sender() == Group2Spin->buttonApply ) {
1229 (Group2Spin->SpinBox_DX)->setFocus();
1230 (Group2Spin->SpinBox_DX)->selectAll();
1232 else if ( sender() == Group3Spin->buttonApply ) {
1233 (Group3Spin->SpinBox_DX)->setFocus();
1234 (Group3Spin->SpinBox_DX)->selectAll();
1236 else if ( sender() == Group4Spin->buttonApply ) {
1237 (Group4Spin->SpinBox_DX)->setFocus();
1238 (Group4Spin->SpinBox_DX)->selectAll();
1244 //=================================================================================
1245 // function : ClickOnHelp()
1247 //=================================================================================
1248 void EntityGUI_SketcherDlg::ClickOnHelp()
1250 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1252 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1256 platform = "winapplication";
1258 platform = "application";
1261 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1262 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1263 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1264 QObject::tr( "BUT_OK" ) );
1268 //=================================================================================
1269 // function : ClickOnUndo()
1271 //=================================================================================
1272 void EntityGUI_SketcherDlg::ClickOnUndo()
1274 myUndoCommand.append( myCommand.last() );
1275 myCommand.pop_back();
1277 myUndoParameters.append( myParameters.last() );
1278 myParameters.pop_back();
1280 if ( myCommand.count() == 1 ) {
1281 mySketchState = FIRST_POINT;
1283 MainWidget->RadioButton1->setChecked( true );
1286 connect( myGeometryGUI->getApp()->selectionMgr(),
1287 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1291 setEnabledUndo( false );
1294 setEnabledRedo( true );
1296 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1299 //=================================================================================
1300 // function : ClickOnRedo()
1302 //=================================================================================
1303 void EntityGUI_SketcherDlg::ClickOnRedo()
1305 myCommand.append( myUndoCommand.last() );
1306 myUndoCommand.pop_back();
1308 myParameters.append( myUndoParameters.last() );
1309 myUndoParameters.pop_back();
1311 mySketchState = NEXT_POINT;
1315 setEnabledUndo( true );
1317 if ( myUndoCommand.count() == 1 )
1318 setEnabledRedo( false );
1320 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1323 //=================================================================================
1324 // function : setEnabledUndo()
1326 //=================================================================================
1327 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1329 Group1Sel->buttonUndo->setEnabled( value );
1330 Group2Sel->buttonUndo->setEnabled( value );
1331 Group1Sel1Spin->buttonUndo->setEnabled( value );
1332 Group1Spin->buttonUndo->setEnabled( value );
1333 Group2Spin->buttonUndo->setEnabled( value );
1334 Group3Spin->buttonUndo->setEnabled( value );
1335 Group4Spin->buttonUndo->setEnabled( value );
1338 //=================================================================================
1339 // function : setEnabledRedo()
1341 //=================================================================================
1342 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1344 Group1Sel->buttonRedo->setEnabled( value );
1345 Group2Sel->buttonRedo->setEnabled( value );
1346 Group1Sel1Spin->buttonRedo->setEnabled( value );
1347 Group1Spin->buttonRedo->setEnabled( value );
1348 Group2Spin->buttonRedo->setEnabled( value );
1349 Group3Spin->buttonRedo->setEnabled( value );
1350 Group4Spin->buttonRedo->setEnabled( value );
1353 //=================================================================================
1354 // function : SelectionIntoArgument()
1355 // purpose : Called when selection as changed
1356 //=================================================================================
1357 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1359 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1360 myEditCurrentArgument->setText( "" );
1362 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1363 SALOME_ListIO aSelList;
1364 aSelMgr->selectedObjects(aSelList);
1366 this->activateWindow();
1368 if (aSelList.Extent() == 0)
1370 selButton->setDown(false);
1371 WPlaneLineEdit->setEnabled(false);
1372 WPlaneLineEdit->setText(tr("GEOM_SKETCHER_WPLANE"));
1375 else if (aSelList.Extent() != 1)
1383 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
1384 if (myEditCurrentArgument == WPlaneLineEdit)
1385 aNeedType = TopAbs_FACE;
1388 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
1389 TopoDS_Shape aShape;
1391 if(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape)
1392 && !aShape.IsNull())
1394 QString aName = GEOMBase::GetName( aSelectedObject.get() );
1395 if (myEditCurrentArgument==WPlaneLineEdit)
1397 // Check if the face is planar
1398 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
1399 GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion());
1401 if (aPlanarCheck.IsPlanar())
1403 myEditCurrentArgument->setText(aName);
1404 AddLocalCS(aSelectedObject.get());
1405 selButton->setDown(false);
1406 WPlaneLineEdit->setEnabled(false);
1407 TypeClicked( myConstructorId );
1411 myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE"));
1412 // The following leads to crash TODO : find a way to return a warning
1413 // Standard_Failure::Raise(tr("GEOM_SKETCHER_NOT_PLANAR").toStdString().c_str());
1419 gp_Ax3 aWPlane = GetActiveLocalCS();
1421 aTrans.SetTransformation(aWPlane);
1422 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1423 aShape = aTransformation.Shape();
1426 if ( GEOMBase::VertexToPoint( aShape, aPnt ) )
1428 myEditCurrentArgument->setText(aName);
1431 double Xcoord = myX;
1432 double Ycoord = myY;
1434 switch (mySketchType)
1437 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1438 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1440 Group2Spin->SpinBox_DX->setValue(Xcoord);
1441 Group2Spin->SpinBox_DY->setValue(Ycoord);
1443 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1444 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1448 if (myLastX1 && myLastY1)
1450 Xcoord = myX - myLastX1;
1451 Ycoord = myY - myLastY1;
1453 else if (mySketchState != FIRST_POINT)
1455 Xcoord = myX - tmpX;
1456 Ycoord = myY - tmpY;
1458 Group2Spin->SpinBox_DX->setValue(Xcoord);
1459 Group2Spin->SpinBox_DY->setValue(Ycoord);
1463 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1464 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1466 Group3Spin->SpinBox_DX->setValue(Xcoord);
1467 Group3Spin->SpinBox_DY->setValue(Ycoord);
1469 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1470 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1474 if (myLastX1 && myLastY1)
1476 Xcoord = myX - myLastX1;
1477 Ycoord = myY - myLastY1;
1479 else if (mySketchState != FIRST_POINT)
1481 Xcoord = myX - tmpX;
1482 Ycoord = myY - tmpY;
1484 Group3Spin->SpinBox_DX->setValue(Xcoord);
1485 Group3Spin->SpinBox_DY->setValue(Ycoord);
1489 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1490 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1492 Group4Spin->SpinBox_DX->setValue(Xcoord);
1493 Group4Spin->SpinBox_DY->setValue(Ycoord);
1495 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1496 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1500 if (myLastX1 && myLastY1)
1502 Xcoord = myXc - myLastX1;
1503 Ycoord = myYc - myLastY1;
1505 else if (mySketchState != FIRST_POINT)
1507 Xcoord = myXc - tmpX;
1508 Ycoord = myYc - tmpY;
1516 Group4Spin->SpinBox_DX->setValue(Xcoord);
1517 Group4Spin->SpinBox_DY->setValue(Ycoord);
1526 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1536 //=================================================================================
1537 // function : SetEditCurrentArgument()
1539 //=================================================================================
1540 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1542 TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX;
1543 if ( sender() == Group1Sel->PushButton1 ) {
1544 myEditCurrentArgument = Group1Sel->LineEdit1;
1545 myEditCurrentArgument->setFocus();
1547 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1548 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1549 myEditCurrentArgument->setFocus();
1551 else if ( sender() == Group2Sel->PushButton1 ) {
1552 myEditCurrentArgument = Group2Sel->LineEdit1;
1553 Group2Sel->PushButton2->setDown(false);
1554 Group2Sel->PushButton1->setDown(true);
1555 Group2Sel->LineEdit2->setEnabled(false);
1556 Group2Sel->LineEdit1->setEnabled(true);
1557 // myEditCurrentArgument->setFocus();
1559 else if ( sender() == Group2Sel->PushButton2 ) {
1560 myEditCurrentArgument = Group2Sel->LineEdit2;
1561 Group2Sel->PushButton1->setDown(false);
1562 Group2Sel->PushButton2->setDown(true);
1563 Group2Sel->LineEdit1->setEnabled(false);
1564 Group2Sel->LineEdit2->setEnabled(true);
1565 // myEditCurrentArgument->setFocus();
1567 else if ( sender() == selButton ) {
1568 myNeedType = TopAbs_FACE;
1569 myEditCurrentArgument = WPlaneLineEdit;
1570 WPlaneLineEdit->setEnabled(true);
1571 selButton->setDown(true);
1573 globalSelection(); // close local selection to clear it
1574 localSelection( myNeedType );
1578 //=================================================================================
1579 // function : LineEditReturnPressed()
1581 //=================================================================================
1582 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1584 if ( sender() == Group1Sel->LineEdit1 )
1585 myEditCurrentArgument = Group1Sel->LineEdit1;
1586 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1587 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1588 else if ( sender() == Group2Sel->LineEdit1 )
1589 myEditCurrentArgument = Group2Sel->LineEdit1;
1590 else if ( sender() == Group2Sel->LineEdit2 )
1591 myEditCurrentArgument = Group2Sel->LineEdit2;
1593 /* User name of object input management */
1594 /* If successful the selection is changed and signal emitted... */
1595 /* so SelectionIntoArgument() is automatically called. */
1596 const QString objectUserName = myEditCurrentArgument->text();
1597 QWidget* thisWidget = (QWidget*)this;
1599 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1600 SALOME_ListIO aSelList;
1601 aSelMgr->selectedObjects(aSelList);
1603 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1604 myEditCurrentArgument->setText( objectUserName );
1608 //=================================================================================
1609 // function : DeactivateActiveDialog()
1611 //=================================================================================
1612 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1614 //myGeometryGUI->SetState( -1 );
1616 setEnabled( false );
1618 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1619 myGeometryGUI->SetActiveDialogBox( 0 );
1623 //=================================================================================
1624 // function : ActivateThisDialog()
1626 //=================================================================================
1627 void EntityGUI_SketcherDlg::ActivateThisDialog()
1629 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1630 myGeometryGUI->EmitSignalDeactivateDialog();
1632 myGeometryGUI->SetActiveDialogBox( this );
1634 connect( myGeometryGUI->getApp()->selectionMgr(),
1635 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1637 //myGeometryGUI->SetState( 0 );
1638 // globalSelection( GEOM_POINT );
1640 myEditCurrentArgument = WPlaneLineEdit;
1641 myEditCurrentArgument->setFocus();
1643 if ( sender() == Group1Sel->LineEdit1 ) {
1644 myEditCurrentArgument = Group1Sel->LineEdit1;
1645 myEditCurrentArgument->setFocus();
1647 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1648 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1649 myEditCurrentArgument->setFocus();
1651 else if ( sender() == Group2Sel->LineEdit1 ) {
1652 myEditCurrentArgument = Group2Sel->LineEdit1;
1653 myEditCurrentArgument->setFocus();
1655 else if ( sender() == Group2Sel->LineEdit2 ) {
1656 myEditCurrentArgument = Group2Sel->LineEdit2;
1657 myEditCurrentArgument->setFocus();
1660 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1664 //=================================================================================
1665 // function : enterEvent [REDEFINED]
1667 //=================================================================================
1668 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1671 ActivateThisDialog();
1675 //=================================================================================
1676 // function : closeEvent()
1678 //=================================================================================
1679 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1681 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1682 //myGeometryGUI->SetState( -1 );
1683 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1684 myGeometryGUI->getApp()->updateActions();
1685 QDialog::closeEvent( e );
1688 //=================================================================================
1689 // function : OnPointSelected
1691 //=================================================================================
1692 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt,
1695 // NOTE Basing the autoapply functionality on the background picture has no sense anymore
1696 // The import picture functionality is now used for drawing on top of a picture
1698 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
1699 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
1701 // QString theImgFileName;
1702 // vp->background().texture( theImgFileName ); ////////////// VSR: temporarily
1707 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1708 TopoDS_Shape aShape = mkVertex.Shape();
1710 // Taking into account LocalCS
1711 gp_Ax3 aWPlane = GetActiveLocalCS();
1714 aTrans.SetTransformation(aWPlane);
1715 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1716 aShape = aTransformation.Shape();
1719 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1721 // NOTE autoapply disabled : doesn't seem useful anymore
1722 // autoApply = ( (getPnt2ConstructorId() == 1) && (!theImgFileName.isEmpty()) ); // If no additional argument needed after selection and there is a backgroundimage
1723 // -> apply automatically
1725 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1726 x = aTrsfPnt.X() - myLastX1;
1727 y = aTrsfPnt.Y() - myLastY1;
1733 switch (getPnt2ConstructorId()){
1735 Group2Spin->SpinBox_DX->setValue( x );
1736 Group2Spin->SpinBox_DY->setValue( y );
1737 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1740 Group3Spin->SpinBox_DX->setValue( x );
1741 Group3Spin->SpinBox_DY->setValue( y );
1742 Group3Spin->buttonApply->setFocus();
1745 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1746 Group4Spin->SpinBox_DX->setValue( x );
1747 Group4Spin->SpinBox_DY->setValue( y );
1749 else{ // Select end point
1750 Group4Spin->SpinBox_DZ->setValue( x );
1751 Group4Spin->SpinBox_DS->setValue( y );
1753 Group4Spin->buttonApply->setFocus();
1756 if ( myConstructorId == 2 ) //RECTANGLE
1760 GroupRect->SpinBox_DX1->setValue( aTrsfPnt.X() );
1761 GroupRect->SpinBox_DY1->setValue( aTrsfPnt.Y() );
1762 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1763 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1767 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1768 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1773 //=================================================================================
1774 // function : OnFirstPoint
1776 //=================================================================================
1777 void EntityGUI_SketcherDlg::OnFirstPoint()
1779 MainWidget->RadioButton3->setEnabled( true );
1780 MainWidget->GroupDest1->setEnabled( false );
1781 GroupPt2->setEnabled( false );
1784 //=================================================================================
1785 // function : OnNextPoint
1787 //=================================================================================
1788 void EntityGUI_SketcherDlg::OnNextPoint()
1790 MainWidget->RadioButton3->setEnabled( false );
1791 MainWidget->GroupDest1->setEnabled( true );
1792 TypeClicked(myConstructorId);
1795 //=================================================================================
1796 // function : ValueChangedInSpinBox()
1798 //=================================================================================
1799 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1801 QObject* send = (QObject*)sender();
1802 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1803 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1805 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1806 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1807 double LastDecimal = 0.0;
1809 QString vxStr, vyStr, vzStr, vsStr;
1811 QString newValueStr;
1812 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1813 newValueStr = aDoubleSpinBox->text();
1815 if ( send == Group1Spin->SpinBox_DX ) {
1816 vx = newValue; vxStr = newValueStr;
1818 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1819 vx = newValue; vxStr = newValueStr;
1821 else if ( send == Group2Spin->SpinBox_DX ) {
1822 vx = newValue; vxStr = newValueStr;
1823 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1825 else if ( send == Group2Spin->SpinBox_DY ) {
1826 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1827 vy = newValue; vyStr = newValueStr;
1829 else if ( send == Group3Spin->SpinBox_DX ) {
1830 vx = newValue; vxStr = newValueStr;
1831 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1832 vz = Group3Spin->SpinBox_DZ->value();
1833 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1834 if (mySketchType == PT_ABS_RADIUS){
1842 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1843 if (aPrecision >= 0) // 'f' format in the QString
1844 LastDecimal = aPrecision;
1845 else // 'g' format in the Qstring
1846 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1847 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1848 if ( Abs(vz) < minRad){
1850 Group3Spin->SpinBox_DZ->setValue( - minRad );
1852 Group3Spin->SpinBox_DZ->setValue( minRad );
1855 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1857 else if ( send == Group3Spin->SpinBox_DY ) {
1858 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1859 vy = newValue; vyStr = newValueStr;
1860 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1861 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1862 if (mySketchType == PT_ABS_RADIUS){
1870 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1871 if (aPrecision >= 0) // 'f' format in the QString
1872 LastDecimal = aPrecision;
1873 else // 'g' format in the QString
1874 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1875 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1876 if ( Abs(vz) < minRad){
1878 Group3Spin->SpinBox_DZ->setValue( - minRad );
1880 Group3Spin->SpinBox_DZ->setValue( minRad );
1883 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1885 else if ( send == Group3Spin->SpinBox_DZ ) {
1886 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1887 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1888 vz = newValue; vzStr = newValueStr;
1890 else if ( send == Group4Spin->SpinBox_DX ) {
1891 vx = newValue; vxStr = newValueStr;
1892 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1893 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1894 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1896 else if ( send == Group4Spin->SpinBox_DY ) {
1897 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1898 vy = newValue; vyStr = newValueStr;
1899 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1900 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1902 else if ( send == Group4Spin->SpinBox_DZ ) {
1903 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1904 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1905 vz = newValue; vzStr = newValueStr;
1906 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1908 else if ( send == Group4Spin->SpinBox_DS ) {
1909 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1910 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1911 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1912 vs = newValue; vsStr = newValueStr;
1914 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1916 if ( myConstructorId == 0 ) { // SEGMENT
1917 if ( mySketchType == PT_ABS ) {
1923 else if ( mySketchType == PT_RELATIVE ) {
1929 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1933 myLengthStr = vyStr;
1935 else if ( mySketchType == DIR_ANGLE_X ) {
1941 else if ( mySketchType == DIR_ANGLE_Y ) {
1947 else if ( mySketchType == DIR_PER_LENGTH ) {
1949 myLengthStr = vxStr;
1951 else if ( mySketchType == DIR_PER_X ) {
1955 else if ( mySketchType == DIR_PER_Y ) {
1959 else if ( mySketchType == DIR_TAN_LENGTH ) {
1961 myLengthStr = vxStr;
1963 else if ( mySketchType == DIR_TAN_X ) {
1967 else if ( mySketchType == DIR_TAN_Y ) {
1971 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1977 myLengthStr = vzStr;
1979 else if ( mySketchType == DIR_DXDY_X ) {
1987 else if ( mySketchType == DIR_DXDY_Y ) {
1996 else if ( myConstructorId == 1 ) { // ARC
1997 if ( mySketchType == PT_ABS ) {
2003 else if ( mySketchType == PT_RELATIVE ) {
2009 if ( mySketchType == PT_ABS_RADIUS ) {
2015 myRadiusStr = vzStr;
2017 else if ( mySketchType == PT_REL_RADIUS ) {
2023 myRadiusStr = vzStr;
2025 else if ( mySketchType == PT_SEL_RADIUS ) {
2027 myRadiusStr = vxStr;
2029 if ( mySketchType == PT_ABS_CENTER ) {
2039 else if ( mySketchType == PT_REL_CENTER ) {
2049 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2054 myRadiusStr = vyStr;
2055 myLengthStr = vzStr;
2057 else if ( mySketchType == DIR_PER_LENGTH ) {
2060 myRadiusStr = vxStr;
2061 myLengthStr = vyStr;
2063 else if ( mySketchType == DIR_TAN_LENGTH ) {
2066 myRadiusStr = vxStr;
2067 myLengthStr = vyStr;
2069 else if ( mySketchType == DIR_DXDY_LENGTH ) {
2076 myRadiusStr = vzStr;
2077 myLengthStr = vsStr;
2080 else if ( myConstructorId == 2 ) { // RECTANGLE
2081 myX1 = GroupRect->SpinBox_DX1->value(); myX1Str = GroupRect->SpinBox_DX1->text();
2082 myX2 = GroupRect->SpinBox_DX2->value(); myX2Str = GroupRect->SpinBox_DX2->text();
2083 myY1 = GroupRect->SpinBox_DY1->value(); myY1Str = GroupRect->SpinBox_DY1->text();
2084 myY2 = GroupRect->SpinBox_DY2->value(); myY2Str = GroupRect->SpinBox_DY2->text();
2089 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
2091 double x, y, xc, yc;
2092 x = y = xc = yc = 0.0;
2093 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
2095 if ( mySketchType == PT_REL_CENTER ){
2096 x = myDX + myLastX1;
2097 y = myDY + myLastY1;
2098 xc = myDXc + myLastX1;
2099 yc = myDYc + myLastY1;
2107 displayPntPreview(xc,yc);
2108 displayPntPreview(x,y);
2113 //=================================================================================
2114 // function : GetNewCommand()
2115 // purpose : Build the new command with context
2116 //=================================================================================
2117 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
2119 theParameters.clear();
2120 QString myNewCommand = ":";
2121 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2122 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2123 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2125 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2126 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2128 if ( mySketchState == FIRST_POINT ) {
2129 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2130 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2131 theParameters = myXStr + ":" + myYStr;
2133 if ( mySketchType == PT_RELATIVE) {
2134 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2135 theParameters = myDXStr + ":" + myDYStr;
2137 if (myConstructorId == 2 )
2140 return myNewCommand;
2143 if ( myConstructorId == 0 ) { // SEGMENT
2144 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2145 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2146 theParameters = myXStr + ":" + myYStr;
2148 if ( mySketchType == PT_RELATIVE) {
2149 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2150 theParameters = myDXStr + ":" + myDYStr;
2152 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2153 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2154 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2155 theParameters = myAngleStr + ":" + myLengthStr;
2157 if ( mySketchType == DIR_ANGLE_X ) {
2158 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2159 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2160 theParameters = myAngleStr + ":" + myXStr;
2162 if ( mySketchType == DIR_ANGLE_Y ) {
2163 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2164 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2165 theParameters = myAngleStr + ":" + myYStr;
2167 if ( mySketchType == DIR_PER_LENGTH ) {
2168 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2169 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2170 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
2172 if ( mySketchType == DIR_PER_X ) {
2173 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2174 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2175 theParameters = QString::number( 90.0 ) + ":" + myXStr;
2177 if ( mySketchType == DIR_PER_Y ) {
2178 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2179 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2180 theParameters = QString::number( 90.0 ) + ":" + myYStr;
2182 if ( mySketchType == DIR_TAN_LENGTH ) {
2183 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
2184 theParameters = myLengthStr;
2186 if ( mySketchType == DIR_TAN_X ) {
2187 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
2188 theParameters = myXStr;
2190 if ( mySketchType == DIR_TAN_Y) {
2191 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
2192 theParameters = myYStr;
2194 if ( mySketchType == DIR_DXDY_LENGTH ) {
2195 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2196 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2197 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
2199 if ( mySketchType == DIR_DXDY_X ) {
2200 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2201 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2202 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
2204 if ( mySketchType == DIR_DXDY_Y ) {
2205 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2206 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2207 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
2210 else if ( myConstructorId == 1 ) { // ARC
2211 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2212 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2213 theParameters = myXStr + ":" + myYStr;
2215 if ( mySketchType == PT_RELATIVE) {
2216 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2217 theParameters = myDXStr + ":" + myDYStr;
2219 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
2220 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
2221 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
2223 if ( mySketchType == PT_REL_RADIUS) {
2224 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
2225 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
2227 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2228 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 );
2229 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2231 if ( mySketchType == PT_REL_CENTER) {
2232 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 );
2233 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2235 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2236 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2237 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2238 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2240 if ( mySketchType == DIR_PER_LENGTH ) {
2241 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2242 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2243 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2245 if ( mySketchType == DIR_TAN_LENGTH ) {
2246 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2247 theParameters = myRadiusStr + ":" + myLengthStr;
2249 if ( mySketchType == DIR_DXDY_LENGTH ) {
2250 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2251 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2252 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2255 else if ( myConstructorId == 2 ) { // RECTANGLE
2256 myNewCommand = myNewCommand + "F " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2257 + ":TT " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2258 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2259 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2262 theParameters = myX1Str + ":" + myY1Str + ":" + myX1Str + ":" + myY2Str + ":" + myX2Str + ":" + myY2Str + ":" + myX2Str + ":" + myY1Str;
2264 return myNewCommand;
2267 //=================================================================================
2268 // function : createOperation
2270 //=================================================================================
2271 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2273 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2276 //=================================================================================
2277 // function : isValid
2279 //=================================================================================
2280 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2283 bool toCorrect = !IsPreview() || myIsApply;
2285 if( Group1Spin->isVisible() ) {
2286 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2288 else if( Group1Sel1Spin->isVisible() ) {
2289 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2291 else if( Group2Spin->isVisible() ) {
2292 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2293 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2295 else if( Group3Spin->isVisible() ) {
2296 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2297 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2298 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2300 else if( Group4Spin->isVisible() ) {
2301 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2302 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2303 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2304 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2307 if( myIsApply && !ok )
2313 //=================================================================================
2314 // function : execute
2316 //=================================================================================
2317 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2319 MESSAGE("EntityGUI_SketcherDlg::execute")
2320 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2321 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2322 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2324 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2325 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2327 QString aParameters;
2329 if ( mySketchState == FIRST_POINT ) {
2334 //Test if the current point is the same as the last one
2335 TopoDS_Shape myShape1, myShape2;
2336 bool isDone = false;
2339 // Set "C" numeric locale
2340 Kernel_Utils::Localizer loc;
2343 QString Command1 = myCommand.join( "" );
2344 Sketcher_Profile aProfile1( Command1.toLatin1() );
2345 myShape1 = aProfile1.GetShape();
2348 QString Command2 = Command1 + GetNewCommand( aParameters );
2349 Sketcher_Profile aProfile2( Command2.toLatin1() );
2350 myShape2 = aProfile2.GetShape( &isDone, &error );
2353 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2354 if (error > Precision::Confusion()){
2355 Group4Spin->label->show();
2356 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( error, Format, DigNum));
2359 Group4Spin->label->hide();
2363 Group4Spin->label->hide();
2364 if ( mySketchType == PT_SEL_CENTER ){
2365 if (error > Precision::Confusion()){
2366 Group2Sel->label->show();
2367 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( error, Format, DigNum));
2370 Group2Sel->label->hide();
2374 Group2Sel->label->hide();
2376 if ( myShape2.IsNull() ) {
2377 //the current point is the same as the last one
2378 myLastX2 = myLastX1;
2379 myLastY2 = myLastY1;
2382 TopoDS_Vertex V1, V2;
2384 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2385 //the last shape is the first point
2386 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2391 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2392 pt = BRep_Tool::Pnt( V2 );
2396 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2397 pt = BRep_Tool::Pnt( V2 );
2404 if ( ( mySketchState != FIRST_POINT &&
2405 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2406 cmd = myCommand.join( "" );
2407 if ( Group1Sel->isVisible() ) {
2408 Group1Sel->buttonApply->setEnabled( false );
2409 //Group1Sel->buttonApply->setFocus();
2411 if ( Group2Sel->isVisible() ) {
2412 Group2Sel->buttonApply->setEnabled( false );
2413 //Group2Sel->buttonApply->setFocus();
2415 if ( Group1Sel1Spin->isVisible() ) {
2416 Group1Sel1Spin->buttonApply->setEnabled( false );
2417 //Group1Sel1Spin->buttonApply->setFocus();
2419 if ( Group1Spin->isVisible() ) {
2420 Group1Spin->buttonApply->setEnabled( false );
2421 //Group1Spin->buttonApply->setFocus();
2423 if ( Group2Spin->isVisible() ) {
2424 Group2Spin->buttonApply->setEnabled( false );
2425 //Group2Spin->buttonApply->setFocus();
2427 if ( Group3Spin->isVisible() ) {
2428 Group3Spin->buttonApply->setEnabled( false );
2429 //Group3Spin->buttonApply->setFocus();
2431 if ( Group4Spin->isVisible() ) {
2432 Group4Spin->buttonApply->setEnabled( false );
2433 //Group4Spin->buttonApply->setFocus();
2437 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2439 if ( Group1Sel->isVisible() ) {
2440 Group1Sel->buttonApply->setEnabled( true );
2442 if ( Group2Sel->isVisible() ) {
2443 Group2Sel->buttonApply->setEnabled( true );
2445 if ( Group1Sel1Spin->isVisible() ) {
2446 Group1Sel1Spin->buttonApply->setEnabled( true );;
2448 if ( Group1Spin->isVisible() ) {
2449 Group1Spin->buttonApply->setEnabled( true );
2451 if ( Group2Spin->isVisible() ) {
2452 Group2Spin->buttonApply->setEnabled( true );
2454 if ( Group3Spin->isVisible() ) {
2455 Group3Spin->buttonApply->setEnabled( true );
2457 if ( Group4Spin->isVisible() ) {
2458 Group4Spin->buttonApply->setEnabled( true );
2462 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2463 GEOM::GEOM_Object_var anObj = NULL;
2465 int index = ComboBox1->currentIndex();
2466 if(index != -1 && !myWPlane->_is_nil()) // The combobox is not empty
2468 anObj = anOper->MakeSketcherOnPlane( cmd.toLatin1().constData(), myWPlane );
2470 if ( !anObj->_is_nil() )
2472 if( !IsPreview() ) {
2473 QStringList aCurrentParameters = myParameters;
2474 aCurrentParameters << aParameters;
2475 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2478 objects.push_back( anObj._retn() );
2484 //================================================================
2485 // Function : displayPreview
2486 // Purpose : Method for displaying preview of resulting shape
2487 // Redefined from GEOMBase_Helper.
2488 //================================================================
2489 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2491 const bool activate,
2493 const double lineWidth,
2494 const int displayMode,
2497 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2499 QColor aColor = resMgr->colorValue("Geometry","line_color",QColor(255,0,0));
2500 Quantity_NameOfColor line_color = SalomeApp_Tools::color( aColor ).Name();
2502 // set width of displayed shape
2505 lw = resMgr->integerValue("Geometry", "preview_edge_width", -1);
2507 getDisplayer()->SetWidth( lw );
2509 // Disable activation of selection
2510 getDisplayer()->SetToActivate( activate );
2512 // Make a reference to GEOM_Object
2513 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2514 getDisplayer()->SetName( objStr.in() );
2516 // Create wire from applied object
2517 TopoDS_Shape anApplyedWire, aLastSegment;
2518 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2522 if( myConstructorId != 2)
2523 getDisplayer()->SetColor( line_color );
2525 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2527 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2528 if ( aPrs != 0 && !aPrs->IsNull() )
2529 GEOMBase_Helper::displayPreview( aPrs, append, update );
2531 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2532 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2534 if ( aPrs != 0 && !aPrs->IsNull() )
2535 GEOMBase_Helper::displayPreview( aPrs, append, update );
2537 getDisplayer()->SetColor( line_color );
2539 getDisplayer()->UnsetName();
2541 // Enable activation of displayed objects
2542 getDisplayer()->SetToActivate( true );
2545 //================================================================
2546 // Function : displayPntPreview
2547 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2548 //================================================================
2549 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2555 // Get globalCS and working plane
2556 gp_Ax3 globalCS = WPlaneToLCS( myGlobalCS );
2557 gp_Ax3 aWPlane = GetActiveLocalCS();
2559 // Build point in localCS
2560 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2562 // Get transfomation from local to global CS
2564 aTrans.SetTransformation(aWPlane, globalCS);
2566 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2567 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2569 // Perform transformation
2570 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2571 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2573 // Build prs with vertex in globalCS
2574 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2575 if ( aPrs != 0 && !aPrs->IsNull() )
2576 GEOMBase_Helper::displayPreview( aPrs, append, update );
2580 //================================================================
2581 // Function : createShapes
2582 // Purpose : Create applyed wire, and last segment from entry object
2583 //================================================================
2584 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2585 TopoDS_Shape& theApplyedWire,
2586 TopoDS_Shape& theLastSegment )
2588 TopoDS_Shape aShape;
2589 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2590 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2593 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2594 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2595 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2596 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2597 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2598 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2599 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2600 theApplyedWire = aShape;
2604 BRepBuilderAPI_MakeWire aBuilder;
2605 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2607 TopoDS_Shape anEdge = anExp.Current();
2609 if ( anExp.More() ) // i.e. non-last edge
2610 aBuilder.Add( TopoDS::Edge( anEdge ) );
2612 theLastSegment = anEdge;
2617 if ( aBuilder.IsDone() )
2618 theApplyedWire = aBuilder.Shape();
2623 //=================================================================================
2624 // function : acceptMouseEvent()
2626 //=================================================================================
2627 bool EntityGUI_SketcherDlg::acceptMouseEvent() const
2629 return ( (getPnt1ConstructorId() == 1
2630 || getPnt1ConstructorId() == 0
2631 || myConstructorId == 2) //accept mouse event only on absolute and relative selection mode
2632 && !WPlaneLineEdit->isEnabled()); //or when the constructor is rectangle
2633 //called by EntityGUI::OnMousePress()
2636 //=================================================================================
2637 // function : keyPressEvent()
2639 //=================================================================================
2640 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2642 QDialog::keyPressEvent( e );
2643 if ( e->isAccepted() )
2646 if ( e->key() == Qt::Key_F1 ) {
2652 //=================================================================================
2653 // function : initSpinBox()
2655 //=================================================================================
2656 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2657 double min, double max,
2658 double step, const char* quantity )
2660 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2661 // TODO: Think how to keep the single piece of code...
2663 // Obtain precision from preferences
2664 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2665 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2667 spinBox->setPrecision( aPrecision );
2668 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2669 // by default Qt rounds boundaries to 2 decimals at setRange
2670 spinBox->setRange( min, max );
2671 spinBox->setSingleStep( step );
2673 // Add a hint for the user saying how to tune precision
2674 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2675 spinBox->setProperty( "validity_tune_hint",
2676 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2679 //=================================================================================
2680 // function : SetDoubleSpinBoxStep()
2681 // purpose : Double spin box management
2682 //=================================================================================
2683 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2685 Group1Spin->SpinBox_DX->setSingleStep(step);
2686 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2687 Group2Spin->SpinBox_DX->setSingleStep(step);
2688 Group2Spin->SpinBox_DY->setSingleStep(step);
2689 Group3Spin->SpinBox_DX->setSingleStep(step);
2690 Group3Spin->SpinBox_DY->setSingleStep(step);
2691 Group3Spin->SpinBox_DZ->setSingleStep(step);
2692 Group4Spin->SpinBox_DZ->setSingleStep(step);
2694 // san: Do NOT override the step when a speicifc step value is used
2695 // in some input fields!
2696 //Group4Spin->SpinBox_DX->setSingleStep(step);
2697 //Group4Spin->SpinBox_DY->setSingleStep(step);
2698 //Group4Spin->SpinBox_DS->setSingleStep(step);
2701 //=================================================================================
2702 // function : AddLocalCS()
2703 // purpose : Add All Coordinates systems in study
2704 //=================================================================================
2705 void EntityGUI_SketcherDlg::AddLocalCS(GEOM::GEOM_Object_var aSelectedObject)
2707 QString aName = GEOMBase::GetName( aSelectedObject );
2709 int index = ComboBox1->findText(aName, Qt::MatchExactly);
2711 if (index==-1) // If the working plane hasn't been added yet
2713 myWPlaneList.push_back(aSelectedObject);
2714 myWPlane = aSelectedObject;
2715 addSubshapesToStudy();
2716 myLCSList.push_back(WPlaneToLCS(aSelectedObject));
2717 ComboBox1->addItem(aName);
2718 index = ComboBox1->count();
2719 ComboBox1->setCurrentIndex(index-1);
2723 ComboBox1->setCurrentIndex(index);
2728 //=================================================================================
2729 // function : FindLocalCS()
2730 // purpose : Find All Coordinates systems in study
2731 //=================================================================================
2732 void EntityGUI_SketcherDlg::FindLocalCS()
2735 myWPlaneList.clear();
2736 SalomeApp_Application* app =
2737 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2741 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2745 _PTR(Study) aStudy = appStudy->studyDS();
2748 ComboBox1->addItem(tr("GEOM_GCS"));
2749 myWPlaneList.push_back(myGlobalCS);
2751 // get GEOM component
2752 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2753 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2756 _PTR(SComponent) fc = obj->GetFatherComponent();
2757 QString geomComp = fc->GetID().c_str();
2758 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2762 // browse through all GEOM data tree
2763 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2764 for ( it->InitEx( true ); it->More(); it->Next() )
2766 _PTR(SObject) child( it->Value() );
2767 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2768 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2769 if( CORBA::is_nil( geomObj ) )
2771 if (geomObj->GetType() == GEOM_MARKER)
2773 myWPlaneList.push_back(geomObj);
2774 myLCSList.push_back(WPlaneToLCS(geomObj));
2775 ComboBox1->addItem(geomObj->GetName());
2780 //=================================================================================
2781 // function : WPlaneToLCS ( aWPlane )
2783 //=================================================================================
2784 gp_Ax3 EntityGUI_SketcherDlg::WPlaneToLCS( GEOM::GEOM_Object_var geomObj )
2786 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2789 if (CORBA::is_nil( geomObj ) || aShape.IsNull())
2791 MESSAGE("CORBA::is_nil( geomObj ) || aShape.IsNull()")
2793 aLCS.Transform(aShape.Location().Transformation());
2794 if (aShape.ShapeType() == TopAbs_FACE)
2796 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
2797 myGeometryGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
2798 double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
2799 aMeasureOp->GetPosition( geomObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
2800 if ( aMeasureOp->IsDone() )
2802 gp_Pnt aPnt ( Ox, Oy, Oz );
2803 gp_Dir aDirN ( Zx, Zy, Zz );
2804 gp_Dir aDirX ( Xx, Xy, Xz );
2805 aLCS = gp_Ax3( aPnt, aDirN, aDirX );
2812 //=================================================================================
2813 // function : getPnt1ConstructorId()
2815 //=================================================================================
2816 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2818 int buttonId = GroupPt->ButtonGroup->checkedId();
2819 // MESSAGE("buttonId = "<<buttonId)
2823 //=================================================================================
2824 // function : getPnt2ConstructorId()
2826 //=================================================================================
2827 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2829 int buttonId = GroupPt2->ButtonGroup->checkedId();
2830 // MESSAGE("buttonId = "<<buttonId)
2834 //=================================================================================
2835 // function : GetActiveLocalCS()
2836 // purpose : Get Working plane
2837 //=================================================================================
2838 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2840 int ind = ComboBox1->currentIndex();
2842 return myGeometryGUI->GetWorkingPlane();
2844 gp_Ax3 aLCS = myLCSList.at(ind);
2845 myWPlane = myWPlaneList.at(ind);
2850 //=================================================================================
2851 // function : ActivateLocalCS()
2852 // purpose : Activate & Fit Working plane
2853 //=================================================================================
2854 void EntityGUI_SketcherDlg::ActivateLocalCS()
2856 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2857 myGeometryGUI->ActiveWorkingPlane();
2860 //=================================================================================
2861 // function : addSubshapeToStudy
2862 // purpose : virtual method to add new SubObjects if local selection
2863 //=================================================================================
2864 void EntityGUI_SketcherDlg::addSubshapesToStudy()
2866 GEOMBase::PublishSubObject(myWPlane);