1 // Copyright (C) 2007-2014 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>
55 #include <BRep_Tool.hxx>
57 #include <TopExp_Explorer.hxx>
58 #include <TopoDS_Vertex.hxx>
60 #include <BRepBuilderAPI_Transform.hxx>
61 #include <BRepBuilderAPI_MakeWire.hxx>
62 #include <BRepBuilderAPI_MakeVertex.hxx>
63 #include <Sketcher_Profile.hxx>
65 #include <SalomeApp_Study.h>
66 #include <SalomeApp_Tools.h>
70 #include <Basics_Utils.hxx>
72 //=================================================================================
73 // class : EntityGUI_SketcherDlg()
74 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
75 // name 'name' and widget flags set to 'f'.
76 // The dialog will by default be modeless, unless you set 'modal' to
77 // TRUE to construct a modal dialog.
78 //=================================================================================
79 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
80 bool modal, Qt::WindowFlags fl,
81 const double lineWidth )
82 : QDialog( parent, fl ),
83 myIsAllAdded( false ),
85 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
87 myLineWidth( lineWidth )
89 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
91 setAttribute( Qt::WA_DeleteOnClose );
93 // Disable rectangular selection
94 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
95 // ((OCCViewer_ViewWindow*)theViewWindow)->setEnabledDrawMode( false );
96 // MESSAGE("((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode();"<<((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode())
97 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
98 // vp->setSketchingEnabled( false );
99 // MESSAGE("vp->isSketchingEnabled()"<<vp->isSketchingEnabled())
100 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(true);
101 // OCCViewer_ViewSketcher* aViewSketcher = ((OCCViewer_ViewWindow*)theViewWindow)->getSketcher( OCCViewer_ViewWindow::Rect );
102 // aViewSketcher->deactivate()
103 // aViewSketcher->setVisible(false);
105 // this->setMouseTracking(false);
107 myGeometryGUI->SetActiveDialogBox(this);
109 MainWidget = new EntityGUI_Skeleton( this );
110 QVBoxLayout* topLayout = new QVBoxLayout( this );
111 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
113 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
114 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_CLOSE" ) );
115 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
116 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
118 QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
119 QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
120 QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
121 QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
122 QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) );
123 QPixmap image5 (aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
124 QPixmap image6 (aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_RECTANGLE" ) ) );
126 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
128 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
129 MainWidget->RadioButton1->setText( "" );
130 MainWidget->RadioButton1->setIcon( image3 );
131 MainWidget->RadioButton2->setText( "" );
132 MainWidget->RadioButton2->setIcon( image4 );
133 MainWidget->RadioButton3->setText( "" );
134 MainWidget->RadioButton3->setIcon( image6 );
135 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
136 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
137 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
138 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
140 /***************************************************************/
142 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
143 QGridLayout* planeLayout = new QGridLayout(GroupBox1);
144 planeLayout->setSpacing(6);
145 planeLayout->setMargin(11);
147 ComboBox1 = new QComboBox(GroupBox1);
148 planeLayout->addWidget(ComboBox1,0,0,1,2);
150 planeButton = new QPushButton (GroupBox1);
151 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
152 planeLayout->addWidget(planeButton,0,2);
154 selButton = new QPushButton (GroupBox1);
155 selButton->setIcon(image5);
156 planeLayout->addWidget(selButton,1,0);
158 WPlaneLineEdit = new QLineEdit (GroupBox1);
159 WPlaneLineEdit->setReadOnly(true);
160 planeLayout->addWidget(WPlaneLineEdit,1,1,1,2);
162 planeLayout->setColumnStretch(1,1);
164 topLayout->addWidget(GroupBox1);
165 topLayout->addWidget( MainWidget );
166 topLayout->setStretch( 1, 1);
168 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
170 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
171 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
172 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
173 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
175 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
177 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
178 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
179 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
180 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
182 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
184 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
185 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
186 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
187 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
188 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
190 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
192 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIST" ) );
193 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
194 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
195 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
197 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
198 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
199 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
200 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
201 Group1Sel->PushButton1->setIcon( image0 );
202 Group1Sel->buttonUndo->setIcon( image1 );
203 Group1Sel->buttonRedo->setIcon( image2 );
204 Group1Sel->LineEdit1->setReadOnly( true );
206 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
207 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
208 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
209 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
210 Group2Sel->PushButton1->setIcon( image0 );
211 Group2Sel->PushButton2->setIcon( image0 );
212 Group2Sel->buttonUndo->setIcon( image1 );
213 Group2Sel->buttonRedo->setIcon( image2 );
214 Group2Sel->LineEdit1->setReadOnly( true );
215 Group2Sel->LineEdit2->setReadOnly( true );
217 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
218 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
219 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
220 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
221 Group1Sel1Spin->PushButton1->setIcon( image0 );
222 Group1Sel1Spin->buttonUndo->setIcon( image1 );
223 Group1Sel1Spin->buttonRedo->setIcon( image2 );
224 Group1Sel1Spin->LineEdit1->setReadOnly( true );
226 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
227 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
228 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
229 Group1Spin->buttonUndo->setIcon( image1 );
230 Group1Spin->buttonRedo->setIcon( image2 );
232 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
233 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
234 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
235 Group2Spin->buttonUndo->setIcon( image1 );
236 Group2Spin->buttonRedo->setIcon( image2 );
238 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
239 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
240 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
241 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
242 Group3Spin->buttonUndo->setIcon( image1 );
243 Group3Spin->buttonRedo->setIcon( image2 );
245 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
246 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
247 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
248 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
249 Group4Spin->buttonUndo->setIcon( image1 );
250 Group4Spin->buttonRedo->setIcon( image2 );
252 GroupRect = new DlgRef_4Spin( MainWidget->SkeletonCnt );
253 GroupRect->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
254 GroupRect->TextLabel1->setText("X1:");
255 GroupRect->TextLabel2->setText("Y1:");
256 GroupRect->TextLabel3->setText("X2:");
257 GroupRect->TextLabel4->setText("Y2:");
259 // Defines a palette for the error message on Group4Spin and Group2Sel
262 palette.setColor(Group4Spin->label->foregroundRole(), color);
263 Group4Spin->label->setPalette(palette);
264 palette.setColor(Group2Sel->label->foregroundRole(), color);
265 Group2Sel->label->setPalette(palette);
267 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
268 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
269 DestCntLayout->addWidget( GroupPt, 0, 0 );
270 DestCntLayout->addWidget( GroupPt2, 0, 1 );
271 DestCntLayout->addWidget( GroupD1, 0, 0 );
272 DestCntLayout->addWidget( GroupD2, 0, 1 );
274 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
275 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
276 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
277 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
278 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
279 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
280 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
281 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
282 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
283 SkeletonCntlayout->addWidget( GroupRect, 0, 0 );
284 //SkeletonCntlayout->setStretch( 0, 1);
285 /***************************************************************/
287 QButtonGroup* ButtonGroup = new QButtonGroup( this );
288 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
289 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
291 /* signals and slots connections */
292 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
293 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
294 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
295 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
297 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
298 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
299 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
300 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
301 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
302 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
303 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
304 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
305 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
306 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
307 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
308 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
309 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
310 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
311 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
312 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
313 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
314 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
315 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
316 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
317 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
319 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
320 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
321 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
322 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
323 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
324 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
326 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
327 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
329 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
330 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
331 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
332 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
334 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
335 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
336 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
338 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
339 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
340 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
341 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
342 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
343 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
344 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
345 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
346 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
347 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
348 connect( GroupRect->SpinBox_DX1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
349 connect( GroupRect->SpinBox_DX2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
350 connect( GroupRect->SpinBox_DY1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
351 connect( GroupRect->SpinBox_DY2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
353 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
354 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
355 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
356 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
358 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ActivateLocalCS() ) );
359 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
360 connect( selButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
362 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
364 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
365 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
367 // install event filter on spin-boxes to provide Apply action on Return pressed
368 Group1Spin->SpinBox_DX->installEventFilter(this);
369 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
370 Group2Spin->SpinBox_DX->installEventFilter(this);
371 Group2Spin->SpinBox_DY->installEventFilter(this);
372 Group3Spin->SpinBox_DX->installEventFilter(this);
373 Group3Spin->SpinBox_DY->installEventFilter(this);
374 Group3Spin->SpinBox_DZ->installEventFilter(this);
375 Group4Spin->SpinBox_DX->installEventFilter(this);
376 Group4Spin->SpinBox_DY->installEventFilter(this);
377 Group4Spin->SpinBox_DZ->installEventFilter(this);
378 Group4Spin->SpinBox_DS->installEventFilter(this);
384 //=================================================================================
385 // function : ~EntityGUI_SketcherDlg()
386 // purpose : Destroys the object and frees any allocated resources
387 //=================================================================================
388 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
390 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
392 myGeometryGUI->SetActiveDialogBox( 0 );
393 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(false);
397 //=================================================================================
398 // function : eventFilter()
399 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
400 //=================================================================================
401 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
403 if (event->type() == QEvent::KeyPress) {
404 QKeyEvent* ke = (QKeyEvent*)event;
405 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
406 if (object == Group1Spin->SpinBox_DX) {
407 Group1Spin->buttonApply->click();
409 } else if (object == Group1Sel1Spin->SpinBox_DX) {
410 Group1Sel1Spin->buttonApply->click();
412 } else if (object == Group2Spin->SpinBox_DX ||
413 object == Group2Spin->SpinBox_DY) {
414 Group2Spin->buttonApply->click();
416 } else if (object == Group3Spin->SpinBox_DX ||
417 object == Group3Spin->SpinBox_DY ||
418 object == Group3Spin->SpinBox_DZ) {
419 Group3Spin->buttonApply->click();
421 } else if (object == Group4Spin->SpinBox_DX ||
422 object == Group4Spin->SpinBox_DY ||
423 object == Group4Spin->SpinBox_DZ ||
424 object == Group4Spin->SpinBox_DS) {
425 Group4Spin->buttonApply->click();
431 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
433 return QDialog::eventFilter(object, event);
437 //=================================================================================
440 //=================================================================================
441 void EntityGUI_SketcherDlg::Init()
446 myEditCurrentArgument = WPlaneLineEdit; // Initiate the parameters selection with the first WPlaneLineEdit
448 myCommand.append( "Sketcher" );
449 myUndoCommand.append( "Sketcher" );
451 mySketchState = FIRST_POINT;
452 globalSelection( GEOM_FACE );
461 myHelpFileName = "create_sketcher_page.html";
463 GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
464 myGlobalCS = aBasicOp->MakeMarker( 0,0,0,
467 myWPlane = myGlobalCS;
468 myLCSList.push_back( WPlaneToLCS(myGlobalCS) );
470 /* Get setting of step value from file configuration */
471 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
473 /* min, max, step and decimals for spin boxes */
474 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
475 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
476 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
477 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
478 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
479 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
480 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
481 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
482 // san: Note specific step values below!
483 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
484 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
485 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
487 initSpinBox( GroupRect->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
488 initSpinBox( GroupRect->SpinBox_DY1, COORD_MIN, COORD_MAX, step, "length_precision" );
489 initSpinBox( GroupRect->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
490 initSpinBox( GroupRect->SpinBox_DY2, COORD_MIN, COORD_MAX, step, "length_precision" );
492 /* displays Dialog */
494 // MainWidget->RadioButton1->setEnabled( false );
495 // MainWidget->RadioButton2->setEnabled( false );
496 // MainWidget->RadioButton3->setEnabled( true );
497 // MainWidget->GroupDest1->setEnabled( false );
498 setEnabledUndo( false );
499 setEnabledRedo( false );
501 MainWidget->RadioButton1->setChecked( true );
505 // If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox
506 // that should be filled with the possibly selected face
510 SelectionIntoArgument();
514 setPrefix(tr("GEOM_SKETCH"));
518 setIsWaitCursorEnabled( false );
519 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
523 //=================================================================================
524 // function : InitClick()
526 //=================================================================================
527 void EntityGUI_SketcherDlg::InitClick()
529 MESSAGE("EntityGUI_SketcherDlg::InitClick()")
530 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
535 Group1Sel1Spin->hide();
541 globalSelection(); // close local selection to clear it
542 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
546 //=================================================================================
547 // function : TypeClicked()
548 // purpose : Radio button management
549 //=================================================================================
550 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
552 myConstructorId = constructorId;
553 MainWidget->buttonEnd->setText(tr("GEOM_BUT_CLOSE"));
554 MainWidget->buttonClose->setEnabled(true);
556 if ( myConstructorId == 0 ) { // SEGMENT
557 GroupPt2->RB_Point1->setChecked( true );
558 GroupPt ->setEnabled( true );
559 GroupPt2->setEnabled( false );
560 GroupD1->setEnabled( true );
561 GroupD2->setEnabled( true );
562 MainWidget->RB_Dest1->setEnabled( true );
563 MainWidget->RB_Dest1->setChecked( true );
565 MainWidget->GroupDest ->setEnabled( true );
566 MainWidget->GroupDest1->setEnabled( true );
567 MainWidget->GroupDest ->show();
568 MainWidget->GroupDest1->show();
570 if (mySketchState == FIRST_POINT)
575 else if ( myConstructorId == 1 ) { // ARC
576 GroupPt ->setEnabled( true );
577 GroupPt2->setEnabled( true );
578 GroupD2->RB_Dir21->setChecked( true );
579 GroupD1->setEnabled( true );
580 GroupD2->setEnabled( false );
581 MainWidget->RB_Dest1->setEnabled( true );
582 MainWidget->RB_Dest1->setChecked( true );
584 MainWidget->GroupDest ->setEnabled( true );
585 MainWidget->GroupDest1->setEnabled( true );
586 MainWidget->GroupDest ->show();
587 MainWidget->GroupDest1->show();
589 if (mySketchState == FIRST_POINT)
594 else if ( myConstructorId == 2 ) { // RECTANGLE
595 GroupPt ->setEnabled( false );
596 GroupPt2->setEnabled( false );
597 GroupD1 ->setEnabled( false );
598 GroupD2 ->setEnabled( false );
599 MainWidget->GroupDest ->setEnabled( false );
600 MainWidget->GroupDest1->setEnabled( false );
606 MainWidget->GroupDest ->hide();
607 MainWidget->GroupDest1->hide();
609 MainWidget->buttonEnd->setText(tr("Apply and Close"));
610 MainWidget->buttonClose->setEnabled(false);
612 GroupRect->setEnabled( true );
613 MainWidget->RadioButton1->setEnabled( true );
614 MainWidget->RadioButton2->setEnabled( true );
620 //=================================================================================
621 // function : RectClicked()
622 // purpose : Radio button management
623 //=================================================================================
624 void EntityGUI_SketcherDlg::RectClicked()
628 // Connect the selction manager (disconnected in InitClick())
629 connect( myGeometryGUI->getApp()->selectionMgr(),
630 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
639 GroupRect->SpinBox_DX1->setValue(myX1);
640 GroupRect->SpinBox_DY1->setValue(myY1);
641 GroupRect->SpinBox_DX2->setValue(myX2);
642 GroupRect->SpinBox_DY2->setValue(myY2);
644 resize( minimumSizeHint() );
646 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
650 //=================================================================================
651 // function : DestClicked()
652 // purpose : Radio button management
653 //=================================================================================
654 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
661 if ( constructorId == 1 ) {
663 GroupPt->RB_Point1->setChecked( true );
666 Group3Spin->checkBox->show();
667 Group4Spin->checkBox->show();
668 PointClicked( 1 ); // XY
670 else if ( constructorId == 0 ) {
672 GroupD1->RB_Dir11->setChecked( true );
675 Group3Spin->checkBox->hide();
676 Group4Spin->checkBox->hide();
677 if (myConstructorId == 1) {
684 Dir1Clicked( 2 ); // Angle
686 resize( minimumSizeHint() );
689 //=================================================================================
690 // function : PointClicked()
691 // purpose : Radio button management
692 //=================================================================================
693 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
695 MESSAGE("PointClicked")
696 myConstructorPntId = constructorId;
697 GroupPt->RB_Point3->setEnabled( true );
698 int buttonId = GroupPt2->ButtonGroup->checkedId();
699 if (buttonId >= 0){ // = If a button is checked
700 Point2Clicked(buttonId);
703 GroupPt2->RB_Point1->setChecked( true );
708 //=================================================================================
709 // function : Point2Clicked()
710 // purpose : Radio button management
711 //=================================================================================
712 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
714 MESSAGE("Point2Clicked")
717 // Get setting of step value from file configuration
718 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
720 if ( myConstructorPntId == 1 ) { // XY
721 if ( constructorId == 1 ){ // No additional parameter
722 mySketchType = PT_ABS;
723 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
724 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
725 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
726 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
728 Group2Spin->SpinBox_DX->setValue( myX );
730 Group2Spin->SpinBox_DY->setValue( myY );
732 Group2Spin->buttonApply->setFocus();
734 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
736 else if ( constructorId == 0 ){ // Point + radius
737 mySketchType = PT_ABS_RADIUS;
738 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
739 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
740 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
741 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
742 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
743 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
745 Group3Spin->SpinBox_DX->setValue( myX );
747 Group3Spin->SpinBox_DY->setValue( myY );
749 Group3Spin->SpinBox_DZ->setValue( myRadius );
751 Group3Spin->buttonApply->setFocus();
753 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
755 else if ( constructorId == 2 ){ // Point + center
756 mySketchType = PT_ABS_CENTER;
757 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
758 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
759 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
760 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
761 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
762 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
763 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
764 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
766 Group4Spin->SpinBox_DX->setValue( myXc );
768 Group4Spin->SpinBox_DY->setValue( myYc );
770 Group4Spin->SpinBox_DZ->setValue( myX );
772 Group4Spin->SpinBox_DS->setValue( myY );
774 Group4Spin->buttonApply->setFocus();
776 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
780 else if ( myConstructorPntId == 0 ) { // DXDY
781 if ( constructorId == 1 ){ // No additional parameter
782 mySketchType = PT_RELATIVE;
783 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
784 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
785 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
786 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
788 Group2Spin->SpinBox_DX->setValue( myDX );
790 Group2Spin->SpinBox_DY->setValue( myDY );
792 Group2Spin->buttonApply->setFocus();
794 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
796 else if ( constructorId == 0 ){ // Point + radius
797 mySketchType = PT_REL_RADIUS;
798 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
799 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
800 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
801 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
802 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
803 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
805 Group3Spin->SpinBox_DX->setValue( myDX );
807 Group3Spin->SpinBox_DY->setValue( myDY );
809 Group3Spin->SpinBox_DZ->setValue( myRadius );
811 Group3Spin->buttonApply->setFocus();
813 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
815 else if ( constructorId == 2 ){ // Point + center
816 mySketchType = PT_REL_CENTER;
817 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
818 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
819 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
820 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
821 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
822 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
823 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
824 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
826 Group4Spin->SpinBox_DX->setValue( myDXc );
828 Group4Spin->SpinBox_DY->setValue( myDYc );
830 Group4Spin->SpinBox_DZ->setValue( myDX );
832 Group4Spin->SpinBox_DS->setValue( myDY );
834 Group4Spin->buttonApply->setFocus();
836 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
840 else if ( myConstructorPntId == 2 ) { // Selection
841 if ( constructorId == 1 ){ // No additional parameter
842 mySketchType = PT_SEL;
843 myEditCurrentArgument = Group1Sel->LineEdit1;
844 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
846 Group1Sel->buttonApply->setFocus();
847 SelectionIntoArgument();
849 else if ( constructorId == 0 ){ // Point + radius
850 mySketchType = PT_SEL_RADIUS;
851 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
852 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
853 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
854 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
856 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
858 Group1Sel1Spin->show();
859 Group1Sel1Spin->buttonApply->setFocus();
860 SelectionIntoArgument();
862 else if ( constructorId == 2 ){ // Point + center
863 mySketchType = PT_SEL_CENTER;
864 myEditCurrentArgument = Group2Sel->LineEdit1;
865 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
866 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
867 Group2Sel->LineEdit1->setEnabled(true);
868 Group2Sel->PushButton1->setDown(true);
869 Group2Sel->LineEdit2->setEnabled(false);
870 Group2Sel->PushButton2->setDown(false);
872 Group2Sel->buttonApply->setFocus();
873 SelectionIntoArgument();
877 resize( minimumSizeHint() );
878 connect( myGeometryGUI->getApp()->selectionMgr(),
879 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
884 //=================================================================================
885 // function : Dir1Clicked()
886 // purpose : Radio button management
887 //=================================================================================
888 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
890 myConstructorDirId = constructorId;
891 int dirButtonId = GroupD2->ButtonGroup->checkedId();
892 if (dirButtonId >= 0){ // = If a button is checked
893 Dir2Clicked(dirButtonId);
896 GroupD2->RB_Dir21->setChecked( true );
902 //=================================================================================
903 // function : Dir2Clicked()
904 // purpose : Radio button management
905 //=================================================================================
906 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
909 Group3Spin->SpinBox_DX->blockSignals(true); // Block signals in order not to modify
910 Group3Spin->SpinBox_DY->blockSignals(true); // defaut values
911 Group3Spin->SpinBox_DZ->blockSignals(true);
913 Group2Spin->SpinBox_DX->blockSignals(true);
914 Group2Spin->SpinBox_DY->blockSignals(true);
916 Group4Spin->SpinBox_DX->blockSignals(true);
917 Group4Spin->SpinBox_DY->blockSignals(true);
918 Group4Spin->SpinBox_DZ->blockSignals(true);
919 Group4Spin->SpinBox_DS->blockSignals(true);
921 // Get setting of step value from file configuration
922 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
924 if ( myConstructorId == 0 ) { // SEGMENT
928 if ( myConstructorDirId == 2 ) { // Angle
929 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
930 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
931 Group2Spin->SpinBox_DX->setValue( myAngle );
932 Group2Spin->buttonApply->setFocus();
935 if ( constructorId == 2 ) { // Length
936 mySketchType = DIR_ANGLE_LENGTH;
937 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
938 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
939 Group2Spin->SpinBox_DY->setValue( myLength );
941 else if ( constructorId == 0 ) { // X
942 mySketchType = DIR_ANGLE_X;
943 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
944 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
945 Group2Spin->SpinBox_DY->setValue( myX );
947 else if ( constructorId == 1 ) { // Y
948 mySketchType = DIR_ANGLE_Y;
949 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
950 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
951 Group2Spin->SpinBox_DY->setValue( myY );
954 else if ( myConstructorDirId == 0 ) { // Perpendicular
956 Group1Spin->buttonApply->setFocus();
958 if ( constructorId == 2 ) { // Length
959 mySketchType = DIR_PER_LENGTH;
960 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
961 Group1Spin->SpinBox_DX->setValue( myLength );
963 else if ( constructorId == 0 ) { // X
964 mySketchType = DIR_PER_X;
965 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
966 Group1Spin->SpinBox_DX->setValue( myX );
968 else if ( constructorId == 1 ) { // Y
969 mySketchType = DIR_PER_Y;
970 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
971 Group1Spin->SpinBox_DX->setValue( myY );
974 else if ( myConstructorDirId == 1 ) { // Tangent
976 Group1Spin->buttonApply->setFocus();
978 if ( constructorId == 2 ) { // Length
979 mySketchType = DIR_TAN_LENGTH;
980 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
981 Group1Spin->SpinBox_DX->setValue( myLength );
983 else if ( constructorId == 0 ) { // X
984 mySketchType = DIR_TAN_X;
985 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
986 Group1Spin->SpinBox_DX->setValue( myX );
988 else if ( constructorId == 1 ) { // Y
989 mySketchType = DIR_TAN_Y;
990 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
991 Group1Spin->SpinBox_DX->setValue( myY );
994 else if ( myConstructorDirId == 3 ) { // DXDY
995 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
996 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
997 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
998 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
999 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
1000 Group3Spin->SpinBox_DX->setValue( myDX );
1001 Group3Spin->SpinBox_DY->setValue( myDY );
1003 Group3Spin->buttonApply->setFocus();
1005 if ( constructorId == 2 ) { // Length
1006 mySketchType = DIR_DXDY_LENGTH;
1007 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
1008 Group3Spin->SpinBox_DZ->setValue( myLength );
1010 else if ( constructorId == 0 ) { // X
1011 mySketchType = DIR_DXDY_X;
1012 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
1013 Group3Spin->SpinBox_DZ->setValue( myX );
1015 else if ( constructorId == 1 ) { // Y
1016 mySketchType = DIR_DXDY_Y;
1017 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
1018 Group3Spin->SpinBox_DZ->setValue( myY );
1022 else if ( myConstructorId == 1 ) { // ARC
1023 if ( myConstructorDirId == 2 ) { // Angle
1024 if ( constructorId == 2 ) { // Length
1025 mySketchType = DIR_ANGLE_LENGTH;
1026 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1027 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1028 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1029 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1030 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1031 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
1032 Group3Spin->SpinBox_DX->setValue( myAngle );
1033 Group3Spin->SpinBox_DY->setValue( myRadius );
1034 Group3Spin->SpinBox_DZ->setValue( myLength );
1036 Group3Spin->buttonApply->setFocus();
1039 else if ( myConstructorDirId == 0 ) { // Perpendicular
1040 if ( constructorId == 2 ) { // Length
1041 mySketchType = DIR_PER_LENGTH;
1042 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1043 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1044 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1045 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1046 // myRadius = 100.0;
1047 Group2Spin->SpinBox_DX->setValue( myRadius );
1049 Group2Spin->SpinBox_DY->setValue( myLength );
1051 Group2Spin->buttonApply->setFocus();
1054 else if ( myConstructorDirId == 1 ) { // Tangent
1055 if ( constructorId == 2 ) { // Length
1056 mySketchType = DIR_TAN_LENGTH;
1057 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
1058 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
1059 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1060 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1061 // myRadius = 100.0;
1062 Group2Spin->SpinBox_DX->setValue( myRadius );
1064 Group2Spin->SpinBox_DY->setValue( myLength );
1066 Group2Spin->buttonApply->setFocus();
1069 else if ( myConstructorDirId == 3 ) { // DXDY
1070 if ( constructorId == 2 ) { // Length
1071 mySketchType = DIR_DXDY_LENGTH;
1072 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
1073 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
1074 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
1075 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
1076 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
1077 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
1078 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
1079 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
1080 Group4Spin->SpinBox_DX->setValue( myDX );
1081 Group4Spin->SpinBox_DY->setValue( myDY );
1082 // myRadius = 100.0;
1083 Group4Spin->SpinBox_DZ->setValue( myRadius );
1085 Group4Spin->SpinBox_DS->setValue( myLength );
1087 Group4Spin->buttonApply->setFocus();
1091 Group3Spin->SpinBox_DX->blockSignals(false); // Restore signals
1092 Group3Spin->SpinBox_DY->blockSignals(false);
1093 Group3Spin->SpinBox_DZ->blockSignals(false);
1095 Group2Spin->SpinBox_DX->blockSignals(false);
1096 Group2Spin->SpinBox_DY->blockSignals(false);
1098 Group4Spin->SpinBox_DX->blockSignals(false);
1099 Group4Spin->SpinBox_DY->blockSignals(false);
1100 Group4Spin->SpinBox_DZ->blockSignals(false);
1101 Group4Spin->SpinBox_DS->blockSignals(false);
1103 resize( minimumSizeHint() );
1104 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1107 //=================================================================================
1108 // function : CheckBoxClicked()
1109 // purpose : CheckBox management
1110 //=================================================================================
1111 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
1113 myCheckFlag = State;
1115 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1119 //=================================================================================
1120 // function : ClickOnCancel()
1122 //=================================================================================
1123 void EntityGUI_SketcherDlg::ClickOnCancel()
1129 //=================================================================================
1130 // function : ClickOnEnd()
1131 // purpose : connected to buttonEnd AND buttonClose
1132 //=================================================================================
1133 void EntityGUI_SketcherDlg::ClickOnEnd()
1135 MESSAGE("EntityGUI_SketcherDlg::ClickOnEnd()")
1136 if ( sender() == MainWidget->buttonClose ) {
1137 // Verify validity of commands
1138 if ( myCommand.count() <= 2 ) {
1139 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
1140 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
1144 QString Command = myCommand.join( "" );
1145 Sketcher_Profile aProfile = Sketcher_Profile( Command.toAscii() );
1146 bool isDone = false;
1147 TopoDS_Shape myShape = aProfile.GetShape( &isDone );
1149 if ( myShape.ShapeType() != TopAbs_VERTEX )
1150 myCommand.append( ":WW" );
1154 /*// PAL16008 (Sketcher Validation should be equal to Apply&Close)
1155 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
1156 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
1157 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
1158 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
1159 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
1160 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
1161 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
1164 // ClickOnApply(); // TEST remove then
1165 myIsAllAdded = true;
1168 if (myConstructorId == 2)
1170 QString aParameters;
1171 myCommand.append( GetNewCommand( aParameters ) );
1172 mySketchState = NEXT_POINT;
1176 if ( myCommand.size() > 2 )
1185 //=================================================================================
1186 // function : ClickOnApply()
1188 //=================================================================================
1189 bool EntityGUI_SketcherDlg::ClickOnApply()
1191 MESSAGE("EntityGUI_SketcherDlg::ClickOnApply()")
1192 if ( sender() && sender()->inherits( "QPushButton" ) )
1193 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1195 // addSubshapesToStudy();
1197 QString aParameters;
1198 myCommand.append( GetNewCommand( aParameters ) );
1199 if (mySketchState == FIRST_POINT)
1201 mySketchState = NEXT_POINT;
1205 myUndoCommand.clear();
1206 myUndoCommand.append( "Sketcher" );
1208 myParameters.append( aParameters );
1209 myUndoParameters.clear();
1211 setEnabledUndo( true );
1212 setEnabledRedo( false );
1215 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1218 // Set focus to SpinBox_DX
1219 if ( sender() == Group1Spin->buttonApply ) {
1220 (Group1Spin->SpinBox_DX)->setFocus();
1221 (Group1Spin->SpinBox_DX)->selectAll();
1223 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1224 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1225 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1227 else if ( sender() == Group2Spin->buttonApply ) {
1228 (Group2Spin->SpinBox_DX)->setFocus();
1229 (Group2Spin->SpinBox_DX)->selectAll();
1231 else if ( sender() == Group3Spin->buttonApply ) {
1232 (Group3Spin->SpinBox_DX)->setFocus();
1233 (Group3Spin->SpinBox_DX)->selectAll();
1235 else if ( sender() == Group4Spin->buttonApply ) {
1236 (Group4Spin->SpinBox_DX)->setFocus();
1237 (Group4Spin->SpinBox_DX)->selectAll();
1243 //=================================================================================
1244 // function : ClickOnHelp()
1246 //=================================================================================
1247 void EntityGUI_SketcherDlg::ClickOnHelp()
1249 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1251 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1255 platform = "winapplication";
1257 platform = "application";
1260 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1261 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1262 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1263 QObject::tr( "BUT_OK" ) );
1267 //=================================================================================
1268 // function : ClickOnUndo()
1270 //=================================================================================
1271 void EntityGUI_SketcherDlg::ClickOnUndo()
1273 myUndoCommand.append( myCommand.last() );
1274 myCommand.pop_back();
1276 myUndoParameters.append( myParameters.last() );
1277 myParameters.pop_back();
1279 if ( myCommand.count() == 1 ) {
1280 mySketchState = FIRST_POINT;
1282 MainWidget->RadioButton1->setChecked( true );
1285 connect( myGeometryGUI->getApp()->selectionMgr(),
1286 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1290 setEnabledUndo( false );
1293 setEnabledRedo( true );
1295 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1298 //=================================================================================
1299 // function : ClickOnRedo()
1301 //=================================================================================
1302 void EntityGUI_SketcherDlg::ClickOnRedo()
1304 myCommand.append( myUndoCommand.last() );
1305 myUndoCommand.pop_back();
1307 myParameters.append( myUndoParameters.last() );
1308 myUndoParameters.pop_back();
1310 mySketchState = NEXT_POINT;
1314 setEnabledUndo( true );
1316 if ( myUndoCommand.count() == 1 )
1317 setEnabledRedo( false );
1319 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1322 //=================================================================================
1323 // function : setEnabledUndo()
1325 //=================================================================================
1326 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1328 Group1Sel->buttonUndo->setEnabled( value );
1329 Group2Sel->buttonUndo->setEnabled( value );
1330 Group1Sel1Spin->buttonUndo->setEnabled( value );
1331 Group1Spin->buttonUndo->setEnabled( value );
1332 Group2Spin->buttonUndo->setEnabled( value );
1333 Group3Spin->buttonUndo->setEnabled( value );
1334 Group4Spin->buttonUndo->setEnabled( value );
1337 //=================================================================================
1338 // function : setEnabledRedo()
1340 //=================================================================================
1341 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1343 Group1Sel->buttonRedo->setEnabled( value );
1344 Group2Sel->buttonRedo->setEnabled( value );
1345 Group1Sel1Spin->buttonRedo->setEnabled( value );
1346 Group1Spin->buttonRedo->setEnabled( value );
1347 Group2Spin->buttonRedo->setEnabled( value );
1348 Group3Spin->buttonRedo->setEnabled( value );
1349 Group4Spin->buttonRedo->setEnabled( value );
1352 //=================================================================================
1353 // function : SelectionIntoArgument()
1354 // purpose : Called when selection as changed
1355 //=================================================================================
1356 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1358 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1359 myEditCurrentArgument->setText( "" );
1361 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1362 SALOME_ListIO aSelList;
1363 aSelMgr->selectedObjects(aSelList);
1365 this->activateWindow();
1367 if (aSelList.Extent() == 0)
1369 selButton->setDown(false);
1370 WPlaneLineEdit->setEnabled(false);
1371 WPlaneLineEdit->setText(tr("GEOM_SKETCHER_WPLANE"));
1374 else if (aSelList.Extent() != 1)
1382 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
1383 if (myEditCurrentArgument == WPlaneLineEdit)
1384 aNeedType = TopAbs_FACE;
1387 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
1388 TopoDS_Shape aShape;
1390 if(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape)
1391 && !aShape.IsNull())
1393 QString aName = GEOMBase::GetName( aSelectedObject.get() );
1394 if (myEditCurrentArgument==WPlaneLineEdit)
1396 // Check if the face is planar
1397 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
1398 GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion());
1400 if (aPlanarCheck.IsPlanar())
1402 myEditCurrentArgument->setText(aName);
1403 AddLocalCS(aSelectedObject.get());
1404 selButton->setDown(false);
1405 WPlaneLineEdit->setEnabled(false);
1406 TypeClicked( myConstructorId );
1410 myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE"));
1411 // The following leads to crash TODO : find a way to return a warning
1412 // Standard_Failure::Raise(tr("GEOM_SKETCHER_NOT_PLANAR").toStdString().c_str());
1418 gp_Ax3 aWPlane = GetActiveLocalCS();
1420 aTrans.SetTransformation(aWPlane);
1421 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1422 aShape = aTransformation.Shape();
1425 if ( GEOMBase::VertexToPoint( aShape, aPnt ) )
1427 myEditCurrentArgument->setText(aName);
1430 double Xcoord = myX;
1431 double Ycoord = myY;
1433 switch (mySketchType)
1436 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1437 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1439 Group2Spin->SpinBox_DX->setValue(Xcoord);
1440 Group2Spin->SpinBox_DY->setValue(Ycoord);
1442 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1443 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1447 if (myLastX1 && myLastY1)
1449 Xcoord = myX - myLastX1;
1450 Ycoord = myY - myLastY1;
1452 else if (mySketchState != FIRST_POINT)
1454 Xcoord = myX - tmpX;
1455 Ycoord = myY - tmpY;
1457 Group2Spin->SpinBox_DX->setValue(Xcoord);
1458 Group2Spin->SpinBox_DY->setValue(Ycoord);
1462 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1463 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1465 Group3Spin->SpinBox_DX->setValue(Xcoord);
1466 Group3Spin->SpinBox_DY->setValue(Ycoord);
1468 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1469 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1473 if (myLastX1 && myLastY1)
1475 Xcoord = myX - myLastX1;
1476 Ycoord = myY - myLastY1;
1478 else if (mySketchState != FIRST_POINT)
1480 Xcoord = myX - tmpX;
1481 Ycoord = myY - tmpY;
1483 Group3Spin->SpinBox_DX->setValue(Xcoord);
1484 Group3Spin->SpinBox_DY->setValue(Ycoord);
1488 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1489 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1491 Group4Spin->SpinBox_DX->setValue(Xcoord);
1492 Group4Spin->SpinBox_DY->setValue(Ycoord);
1494 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1495 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1499 if (myLastX1 && myLastY1)
1501 Xcoord = myXc - myLastX1;
1502 Ycoord = myYc - myLastY1;
1504 else if (mySketchState != FIRST_POINT)
1506 Xcoord = myXc - tmpX;
1507 Ycoord = myYc - tmpY;
1515 Group4Spin->SpinBox_DX->setValue(Xcoord);
1516 Group4Spin->SpinBox_DY->setValue(Ycoord);
1525 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1535 //=================================================================================
1536 // function : SetEditCurrentArgument()
1538 //=================================================================================
1539 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1541 TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX;
1542 if ( sender() == Group1Sel->PushButton1 ) {
1543 myEditCurrentArgument = Group1Sel->LineEdit1;
1544 myEditCurrentArgument->setFocus();
1546 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1547 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1548 myEditCurrentArgument->setFocus();
1550 else if ( sender() == Group2Sel->PushButton1 ) {
1551 myEditCurrentArgument = Group2Sel->LineEdit1;
1552 Group2Sel->PushButton2->setDown(false);
1553 Group2Sel->PushButton1->setDown(true);
1554 Group2Sel->LineEdit2->setEnabled(false);
1555 Group2Sel->LineEdit1->setEnabled(true);
1556 // myEditCurrentArgument->setFocus();
1558 else if ( sender() == Group2Sel->PushButton2 ) {
1559 myEditCurrentArgument = Group2Sel->LineEdit2;
1560 Group2Sel->PushButton1->setDown(false);
1561 Group2Sel->PushButton2->setDown(true);
1562 Group2Sel->LineEdit1->setEnabled(false);
1563 Group2Sel->LineEdit2->setEnabled(true);
1564 // myEditCurrentArgument->setFocus();
1566 else if ( sender() == selButton ) {
1567 myNeedType = TopAbs_FACE;
1568 myEditCurrentArgument = WPlaneLineEdit;
1569 WPlaneLineEdit->setEnabled(true);
1570 selButton->setDown(true);
1572 globalSelection(); // close local selection to clear it
1573 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
1577 //=================================================================================
1578 // function : LineEditReturnPressed()
1580 //=================================================================================
1581 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1583 if ( sender() == Group1Sel->LineEdit1 )
1584 myEditCurrentArgument = Group1Sel->LineEdit1;
1585 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1586 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1587 else if ( sender() == Group2Sel->LineEdit1 )
1588 myEditCurrentArgument = Group2Sel->LineEdit1;
1589 else if ( sender() == Group2Sel->LineEdit2 )
1590 myEditCurrentArgument = Group2Sel->LineEdit2;
1592 /* User name of object input management */
1593 /* If successfull the selection is changed and signal emitted... */
1594 /* so SelectionIntoArgument() is automatically called. */
1595 const QString objectUserName = myEditCurrentArgument->text();
1596 QWidget* thisWidget = (QWidget*)this;
1598 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1599 SALOME_ListIO aSelList;
1600 aSelMgr->selectedObjects(aSelList);
1602 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1603 myEditCurrentArgument->setText( objectUserName );
1607 //=================================================================================
1608 // function : DeactivateActiveDialog()
1610 //=================================================================================
1611 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1613 //myGeometryGUI->SetState( -1 );
1615 setEnabled( false );
1617 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1618 myGeometryGUI->SetActiveDialogBox( 0 );
1622 //=================================================================================
1623 // function : ActivateThisDialog()
1625 //=================================================================================
1626 void EntityGUI_SketcherDlg::ActivateThisDialog()
1628 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1629 myGeometryGUI->EmitSignalDeactivateDialog();
1631 myGeometryGUI->SetActiveDialogBox( this );
1633 connect( myGeometryGUI->getApp()->selectionMgr(),
1634 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1636 //myGeometryGUI->SetState( 0 );
1637 // globalSelection( GEOM_POINT );
1639 myEditCurrentArgument = WPlaneLineEdit;
1640 myEditCurrentArgument->setFocus();
1642 if ( sender() == Group1Sel->LineEdit1 ) {
1643 myEditCurrentArgument = Group1Sel->LineEdit1;
1644 myEditCurrentArgument->setFocus();
1646 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1647 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1648 myEditCurrentArgument->setFocus();
1650 else if ( sender() == Group2Sel->LineEdit1 ) {
1651 myEditCurrentArgument = Group2Sel->LineEdit1;
1652 myEditCurrentArgument->setFocus();
1654 else if ( sender() == Group2Sel->LineEdit2 ) {
1655 myEditCurrentArgument = Group2Sel->LineEdit2;
1656 myEditCurrentArgument->setFocus();
1659 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1663 //=================================================================================
1664 // function : enterEvent [REDEFINED]
1666 //=================================================================================
1667 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1670 ActivateThisDialog();
1674 //=================================================================================
1675 // function : closeEvent()
1677 //=================================================================================
1678 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1680 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1681 //myGeometryGUI->SetState( -1 );
1682 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1683 myGeometryGUI->getApp()->updateActions();
1684 QDialog::closeEvent( e );
1687 //=================================================================================
1688 // function : OnPointSelected
1690 //=================================================================================
1691 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt,
1694 // NOTE Basing the autoapply functionnality on the background picture has no sense anymore
1695 // The import picture functionnality is now used for drawing on top of a picture
1697 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
1698 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
1700 // QString theImgFileName;
1701 // vp->background().texture( theImgFileName ); ////////////// VSR: temporarily
1706 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1707 TopoDS_Shape aShape = mkVertex.Shape();
1709 // Taking into account LocalCS
1710 gp_Ax3 aWPlane = GetActiveLocalCS();
1713 aTrans.SetTransformation(aWPlane);
1714 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1715 aShape = aTransformation.Shape();
1718 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1720 // NOTE autoapply disabled : doesn't seem useful anymore
1721 // autoApply = ( (getPnt2ConstructorId() == 1) && (!theImgFileName.isEmpty()) ); // If no additional argument needed after selection and there is a backgroundimage
1722 // -> apply automatically
1724 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1725 x = aTrsfPnt.X() - myLastX1;
1726 y = aTrsfPnt.Y() - myLastY1;
1732 switch (getPnt2ConstructorId()){
1734 Group2Spin->SpinBox_DX->setValue( x );
1735 Group2Spin->SpinBox_DY->setValue( y );
1736 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1739 Group3Spin->SpinBox_DX->setValue( x );
1740 Group3Spin->SpinBox_DY->setValue( y );
1741 Group3Spin->buttonApply->setFocus();
1744 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1745 Group4Spin->SpinBox_DX->setValue( x );
1746 Group4Spin->SpinBox_DY->setValue( y );
1748 else{ // Select end point
1749 Group4Spin->SpinBox_DZ->setValue( x );
1750 Group4Spin->SpinBox_DS->setValue( y );
1752 Group4Spin->buttonApply->setFocus();
1755 if ( myConstructorId == 2 ) //RECTANGLE
1759 GroupRect->SpinBox_DX1->setValue( aTrsfPnt.X() );
1760 GroupRect->SpinBox_DY1->setValue( aTrsfPnt.Y() );
1761 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1762 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1766 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1767 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1772 //=================================================================================
1773 // function : OnFirstPoint
1775 //=================================================================================
1776 void EntityGUI_SketcherDlg::OnFirstPoint()
1778 MainWidget->RadioButton3->setEnabled( true );
1779 MainWidget->GroupDest1->setEnabled( false );
1780 GroupPt2->setEnabled( false );
1783 //=================================================================================
1784 // function : OnNextPoint
1786 //=================================================================================
1787 void EntityGUI_SketcherDlg::OnNextPoint()
1789 MainWidget->RadioButton3->setEnabled( false );
1790 MainWidget->GroupDest1->setEnabled( true );
1791 TypeClicked(myConstructorId);
1794 //=================================================================================
1795 // function : ValueChangedInSpinBox()
1797 //=================================================================================
1798 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1800 QObject* send = (QObject*)sender();
1801 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1802 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1804 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1805 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1806 double LastDecimal = 0.0;
1808 QString vxStr, vyStr, vzStr, vsStr;
1810 QString newValueStr;
1811 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1812 newValueStr = aDoubleSpinBox->text();
1814 if ( send == Group1Spin->SpinBox_DX ) {
1815 vx = newValue; vxStr = newValueStr;
1817 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1818 vx = newValue; vxStr = newValueStr;
1820 else if ( send == Group2Spin->SpinBox_DX ) {
1821 vx = newValue; vxStr = newValueStr;
1822 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1824 else if ( send == Group2Spin->SpinBox_DY ) {
1825 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1826 vy = newValue; vyStr = newValueStr;
1828 else if ( send == Group3Spin->SpinBox_DX ) {
1829 vx = newValue; vxStr = newValueStr;
1830 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1831 vz = Group3Spin->SpinBox_DZ->value();
1832 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1833 if (mySketchType == PT_ABS_RADIUS){
1841 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1842 if (aPrecision >= 0) // 'f' format in the QString
1843 LastDecimal = aPrecision;
1844 else // 'g' format in the Qstring
1845 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1846 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1847 if ( Abs(vz) < minRad){
1849 Group3Spin->SpinBox_DZ->setValue( - minRad );
1851 Group3Spin->SpinBox_DZ->setValue( minRad );
1854 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1856 else if ( send == Group3Spin->SpinBox_DY ) {
1857 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1858 vy = newValue; vyStr = newValueStr;
1859 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1860 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1861 if (mySketchType == PT_ABS_RADIUS){
1869 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1870 if (aPrecision >= 0) // 'f' format in the QString
1871 LastDecimal = aPrecision;
1872 else // 'g' format in the QString
1873 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1874 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1875 if ( Abs(vz) < minRad){
1877 Group3Spin->SpinBox_DZ->setValue( - minRad );
1879 Group3Spin->SpinBox_DZ->setValue( minRad );
1882 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1884 else if ( send == Group3Spin->SpinBox_DZ ) {
1885 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1886 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1887 vz = newValue; vzStr = newValueStr;
1889 else if ( send == Group4Spin->SpinBox_DX ) {
1890 vx = newValue; vxStr = newValueStr;
1891 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1892 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1893 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1895 else if ( send == Group4Spin->SpinBox_DY ) {
1896 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1897 vy = newValue; vyStr = newValueStr;
1898 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1899 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1901 else if ( send == Group4Spin->SpinBox_DZ ) {
1902 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1903 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1904 vz = newValue; vzStr = newValueStr;
1905 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1907 else if ( send == Group4Spin->SpinBox_DS ) {
1908 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1909 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1910 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1911 vs = newValue; vsStr = newValueStr;
1913 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1915 if ( myConstructorId == 0 ) { // SEGMENT
1916 if ( mySketchType == PT_ABS ) {
1922 else if ( mySketchType == PT_RELATIVE ) {
1928 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1932 myLengthStr = vyStr;
1934 else if ( mySketchType == DIR_ANGLE_X ) {
1940 else if ( mySketchType == DIR_ANGLE_Y ) {
1946 else if ( mySketchType == DIR_PER_LENGTH ) {
1948 myLengthStr = vxStr;
1950 else if ( mySketchType == DIR_PER_X ) {
1954 else if ( mySketchType == DIR_PER_Y ) {
1958 else if ( mySketchType == DIR_TAN_LENGTH ) {
1960 myLengthStr = vxStr;
1962 else if ( mySketchType == DIR_TAN_X ) {
1966 else if ( mySketchType == DIR_TAN_Y ) {
1970 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1976 myLengthStr = vzStr;
1978 else if ( mySketchType == DIR_DXDY_X ) {
1986 else if ( mySketchType == DIR_DXDY_Y ) {
1995 else if ( myConstructorId == 1 ) { // ARC
1996 if ( mySketchType == PT_ABS ) {
2002 else if ( mySketchType == PT_RELATIVE ) {
2008 if ( mySketchType == PT_ABS_RADIUS ) {
2014 myRadiusStr = vzStr;
2016 else if ( mySketchType == PT_REL_RADIUS ) {
2022 myRadiusStr = vzStr;
2024 else if ( mySketchType == PT_SEL_RADIUS ) {
2026 myRadiusStr = vxStr;
2028 if ( mySketchType == PT_ABS_CENTER ) {
2038 else if ( mySketchType == PT_REL_CENTER ) {
2048 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2053 myRadiusStr = vyStr;
2054 myLengthStr = vzStr;
2056 else if ( mySketchType == DIR_PER_LENGTH ) {
2059 myRadiusStr = vxStr;
2060 myLengthStr = vyStr;
2062 else if ( mySketchType == DIR_TAN_LENGTH ) {
2065 myRadiusStr = vxStr;
2066 myLengthStr = vyStr;
2068 else if ( mySketchType == DIR_DXDY_LENGTH ) {
2075 myRadiusStr = vzStr;
2076 myLengthStr = vsStr;
2079 else if ( myConstructorId == 2 ) { // RECTANGLE
2080 myX1 = GroupRect->SpinBox_DX1->value(); myX1Str = GroupRect->SpinBox_DX1->text();
2081 myX2 = GroupRect->SpinBox_DX2->value(); myX2Str = GroupRect->SpinBox_DX2->text();
2082 myY1 = GroupRect->SpinBox_DY1->value(); myY1Str = GroupRect->SpinBox_DY1->text();
2083 myY2 = GroupRect->SpinBox_DY2->value(); myY2Str = GroupRect->SpinBox_DY2->text();
2088 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
2090 double x, y, xc, yc;
2091 x = y = xc = yc = 0.0;
2092 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
2094 if ( mySketchType == PT_REL_CENTER ){
2095 x = myDX + myLastX1;
2096 y = myDY + myLastY1;
2097 xc = myDXc + myLastX1;
2098 yc = myDYc + myLastY1;
2106 displayPntPreview(xc,yc);
2107 displayPntPreview(x,y);
2112 //=================================================================================
2113 // function : GetNewCommand()
2114 // purpose : Build the new command with context
2115 //=================================================================================
2116 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
2118 theParameters.clear();
2119 QString myNewCommand = ":";
2120 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2121 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2122 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2124 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2125 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2127 if ( mySketchState == FIRST_POINT ) {
2128 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2129 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2130 theParameters = myXStr + ":" + myYStr;
2132 if ( mySketchType == PT_RELATIVE) {
2133 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2134 theParameters = myDXStr + ":" + myDYStr;
2136 if (myConstructorId == 2 )
2139 return myNewCommand;
2142 if ( myConstructorId == 0 ) { // SEGMENT
2143 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2144 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2145 theParameters = myXStr + ":" + myYStr;
2147 if ( mySketchType == PT_RELATIVE) {
2148 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2149 theParameters = myDXStr + ":" + myDYStr;
2151 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2152 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2153 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2154 theParameters = myAngleStr + ":" + myLengthStr;
2156 if ( mySketchType == DIR_ANGLE_X ) {
2157 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2158 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2159 theParameters = myAngleStr + ":" + myXStr;
2161 if ( mySketchType == DIR_ANGLE_Y ) {
2162 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2163 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2164 theParameters = myAngleStr + ":" + myYStr;
2166 if ( mySketchType == DIR_PER_LENGTH ) {
2167 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2168 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2169 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
2171 if ( mySketchType == DIR_PER_X ) {
2172 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2173 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2174 theParameters = QString::number( 90.0 ) + ":" + myXStr;
2176 if ( mySketchType == DIR_PER_Y ) {
2177 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2178 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2179 theParameters = QString::number( 90.0 ) + ":" + myYStr;
2181 if ( mySketchType == DIR_TAN_LENGTH ) {
2182 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
2183 theParameters = myLengthStr;
2185 if ( mySketchType == DIR_TAN_X ) {
2186 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
2187 theParameters = myXStr;
2189 if ( mySketchType == DIR_TAN_Y) {
2190 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
2191 theParameters = myYStr;
2193 if ( mySketchType == DIR_DXDY_LENGTH ) {
2194 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2195 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2196 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
2198 if ( mySketchType == DIR_DXDY_X ) {
2199 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2200 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2201 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
2203 if ( mySketchType == DIR_DXDY_Y ) {
2204 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2205 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2206 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
2209 else if ( myConstructorId == 1 ) { // ARC
2210 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2211 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2212 theParameters = myXStr + ":" + myYStr;
2214 if ( mySketchType == PT_RELATIVE) {
2215 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2216 theParameters = myDXStr + ":" + myDYStr;
2218 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
2219 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
2220 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
2222 if ( mySketchType == PT_REL_RADIUS) {
2223 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
2224 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
2226 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2227 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 );
2228 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2230 if ( mySketchType == PT_REL_CENTER) {
2231 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 );
2232 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2234 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2235 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2236 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2237 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2239 if ( mySketchType == DIR_PER_LENGTH ) {
2240 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2241 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2242 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2244 if ( mySketchType == DIR_TAN_LENGTH ) {
2245 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2246 theParameters = myRadiusStr + ":" + myLengthStr;
2248 if ( mySketchType == DIR_DXDY_LENGTH ) {
2249 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2250 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2251 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2254 else if ( myConstructorId == 2 ) { // RECTANGLE
2255 myNewCommand = myNewCommand + "F " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2256 + ":TT " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2257 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2258 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2261 theParameters = myX1Str + ":" + myY1Str + ":" + myX2Str + ":" + myY2Str ;
2263 return myNewCommand;
2266 //=================================================================================
2267 // function : createOperation
2269 //=================================================================================
2270 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2272 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2275 //=================================================================================
2276 // function : isValid
2278 //=================================================================================
2279 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2282 bool toCorrect = !IsPreview() || myIsApply;
2284 if( Group1Spin->isVisible() ) {
2285 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2287 else if( Group1Sel1Spin->isVisible() ) {
2288 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2290 else if( Group2Spin->isVisible() ) {
2291 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2292 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2294 else if( Group3Spin->isVisible() ) {
2295 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2296 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2297 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2299 else if( Group4Spin->isVisible() ) {
2300 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2301 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2302 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2303 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2306 if( myIsApply && !ok )
2312 //=================================================================================
2313 // function : execute
2315 //=================================================================================
2316 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2318 MESSAGE("EntityGUI_SketcherDlg::execute")
2319 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2320 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2321 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2323 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2324 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2326 QString aParameters;
2328 if ( mySketchState == FIRST_POINT ) {
2333 //Test if the current point is the same as the last one
2334 TopoDS_Shape myShape1, myShape2;
2335 bool isDone = false;
2338 // Set "C" numeric locale
2339 Kernel_Utils::Localizer loc;
2342 QString Command1 = myCommand.join( "" );
2343 Sketcher_Profile aProfile1( Command1.toAscii() );
2344 myShape1 = aProfile1.GetShape();
2347 QString Command2 = Command1 + GetNewCommand( aParameters );
2348 Sketcher_Profile aProfile2( Command2.toAscii() );
2349 myShape2 = aProfile2.GetShape( &isDone, &error );
2352 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2353 if (error > Precision::Confusion()){
2354 Group4Spin->label->show();
2355 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( error, Format, DigNum));
2358 Group4Spin->label->hide();
2362 Group4Spin->label->hide();
2363 if ( mySketchType == PT_SEL_CENTER ){
2364 if (error > Precision::Confusion()){
2365 Group2Sel->label->show();
2366 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( error, Format, DigNum));
2369 Group2Sel->label->hide();
2373 Group2Sel->label->hide();
2375 if ( myShape2.IsNull() ) {
2376 //the current point is the same as the last one
2377 myLastX2 = myLastX1;
2378 myLastY2 = myLastY1;
2381 TopoDS_Vertex V1, V2;
2383 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2384 //the last shape is the first point
2385 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2390 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2391 pt = BRep_Tool::Pnt( V2 );
2395 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2396 pt = BRep_Tool::Pnt( V2 );
2403 if ( ( mySketchState != FIRST_POINT &&
2404 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2405 cmd = myCommand.join( "" );
2406 if ( Group1Sel->isVisible() ) {
2407 Group1Sel->buttonApply->setEnabled( false );
2408 //Group1Sel->buttonApply->setFocus();
2410 if ( Group2Sel->isVisible() ) {
2411 Group2Sel->buttonApply->setEnabled( false );
2412 //Group2Sel->buttonApply->setFocus();
2414 if ( Group1Sel1Spin->isVisible() ) {
2415 Group1Sel1Spin->buttonApply->setEnabled( false );
2416 //Group1Sel1Spin->buttonApply->setFocus();
2418 if ( Group1Spin->isVisible() ) {
2419 Group1Spin->buttonApply->setEnabled( false );
2420 //Group1Spin->buttonApply->setFocus();
2422 if ( Group2Spin->isVisible() ) {
2423 Group2Spin->buttonApply->setEnabled( false );
2424 //Group2Spin->buttonApply->setFocus();
2426 if ( Group3Spin->isVisible() ) {
2427 Group3Spin->buttonApply->setEnabled( false );
2428 //Group3Spin->buttonApply->setFocus();
2430 if ( Group4Spin->isVisible() ) {
2431 Group4Spin->buttonApply->setEnabled( false );
2432 //Group4Spin->buttonApply->setFocus();
2436 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2438 if ( Group1Sel->isVisible() ) {
2439 Group1Sel->buttonApply->setEnabled( true );
2441 if ( Group2Sel->isVisible() ) {
2442 Group2Sel->buttonApply->setEnabled( true );
2444 if ( Group1Sel1Spin->isVisible() ) {
2445 Group1Sel1Spin->buttonApply->setEnabled( true );;
2447 if ( Group1Spin->isVisible() ) {
2448 Group1Spin->buttonApply->setEnabled( true );
2450 if ( Group2Spin->isVisible() ) {
2451 Group2Spin->buttonApply->setEnabled( true );
2453 if ( Group3Spin->isVisible() ) {
2454 Group3Spin->buttonApply->setEnabled( true );
2456 if ( Group4Spin->isVisible() ) {
2457 Group4Spin->buttonApply->setEnabled( true );
2461 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2462 GEOM::GEOM_Object_var anObj = NULL;
2464 int index = ComboBox1->currentIndex();
2465 if(index != -1 && !myWPlane->_is_nil()) // The combobox is not empty
2467 anObj = anOper->MakeSketcherOnPlane( cmd.toLatin1().constData(), myWPlane );
2469 if ( !anObj->_is_nil() )
2471 if( !IsPreview() ) {
2472 QStringList aCurrentParameters = myParameters;
2473 aCurrentParameters << aParameters;
2474 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2477 objects.push_back( anObj._retn() );
2483 //================================================================
2484 // Function : displayPreview
2485 // Purpose : Method for displaying preview of resulting shape
2486 // Redefined from GEOMBase_Helper.
2487 //================================================================
2488 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2490 const bool activate,
2492 const double lineWidth,
2493 const int displayMode,
2496 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2498 QColor aColor = resMgr->colorValue("Geometry","line_color",QColor(255,0,0));
2499 Quantity_NameOfColor line_color = SalomeApp_Tools::color( aColor ).Name();
2501 // set width of displayed shape
2504 lw = resMgr->integerValue("Geometry", "preview_edge_width", -1);
2506 getDisplayer()->SetWidth( lw );
2508 // Disable activation of selection
2509 getDisplayer()->SetToActivate( activate );
2511 // Make a reference to GEOM_Object
2512 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2513 getDisplayer()->SetName( objStr.in() );
2515 // Create wire from applied object
2516 TopoDS_Shape anApplyedWire, aLastSegment;
2517 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2521 if( myConstructorId != 2)
2522 getDisplayer()->SetColor( line_color );
2524 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2526 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2527 if ( aPrs != 0 && !aPrs->IsNull() )
2528 GEOMBase_Helper::displayPreview( aPrs, append, update );
2530 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2531 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2533 if ( aPrs != 0 && !aPrs->IsNull() )
2534 GEOMBase_Helper::displayPreview( aPrs, append, update );
2536 getDisplayer()->SetColor( line_color );
2538 getDisplayer()->UnsetName();
2540 // Enable activation of displayed objects
2541 getDisplayer()->SetToActivate( true );
2544 //================================================================
2545 // Function : displayPntPreview
2546 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2547 //================================================================
2548 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2554 // Get globalCS and working plane
2555 gp_Ax3 globalCS = WPlaneToLCS( myGlobalCS );
2556 gp_Ax3 aWPlane = GetActiveLocalCS();
2558 // Build point in localCS
2559 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2561 // Get transfomation from local to global CS
2563 aTrans.SetTransformation(aWPlane, globalCS);
2565 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2566 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2568 // Perform transformation
2569 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2570 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2572 // Build prs with vertex in globalCS
2573 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2574 if ( aPrs != 0 && !aPrs->IsNull() )
2575 GEOMBase_Helper::displayPreview( aPrs, append, update );
2579 //================================================================
2580 // Function : createShapes
2581 // Purpose : Create applyed wire, and last segment from entry object
2582 //================================================================
2583 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2584 TopoDS_Shape& theApplyedWire,
2585 TopoDS_Shape& theLastSegment )
2587 TopoDS_Shape aShape;
2588 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2589 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2592 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2593 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2594 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2595 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2596 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2597 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2598 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2599 theApplyedWire = aShape;
2603 BRepBuilderAPI_MakeWire aBuilder;
2604 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2606 TopoDS_Shape anEdge = anExp.Current();
2608 if ( anExp.More() ) // i.e. non-last edge
2609 aBuilder.Add( TopoDS::Edge( anEdge ) );
2611 theLastSegment = anEdge;
2616 if ( aBuilder.IsDone() )
2617 theApplyedWire = aBuilder.Shape();
2622 //=================================================================================
2623 // function : acceptMouseEvent()
2625 //=================================================================================
2626 bool EntityGUI_SketcherDlg::acceptMouseEvent() const
2628 return ( (getPnt1ConstructorId() == 1
2629 || getPnt1ConstructorId() == 0
2630 || myConstructorId == 2) //accept mouse event only on absolute and relative selection mode
2631 && !WPlaneLineEdit->isEnabled()); //or when the constructor is rectangle
2632 //called by EntityGUI::OnMousePress()
2635 //=================================================================================
2636 // function : keyPressEvent()
2638 //=================================================================================
2639 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2641 QDialog::keyPressEvent( e );
2642 if ( e->isAccepted() )
2645 if ( e->key() == Qt::Key_F1 ) {
2651 //=================================================================================
2652 // function : initSpinBox()
2654 //=================================================================================
2655 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2656 double min, double max,
2657 double step, const char* quantity )
2659 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2660 // TODO: Think how to keep the single piece of code...
2662 // Obtain precision from preferences
2663 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2664 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2666 spinBox->setPrecision( aPrecision );
2667 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2668 // by default Qt rounds boundaries to 2 decimals at setRange
2669 spinBox->setRange( min, max );
2670 spinBox->setSingleStep( step );
2672 // Add a hint for the user saying how to tune precision
2673 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2674 spinBox->setProperty( "validity_tune_hint",
2675 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2678 //=================================================================================
2679 // function : SetDoubleSpinBoxStep()
2680 // purpose : Double spin box management
2681 //=================================================================================
2682 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2684 Group1Spin->SpinBox_DX->setSingleStep(step);
2685 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2686 Group2Spin->SpinBox_DX->setSingleStep(step);
2687 Group2Spin->SpinBox_DY->setSingleStep(step);
2688 Group3Spin->SpinBox_DX->setSingleStep(step);
2689 Group3Spin->SpinBox_DY->setSingleStep(step);
2690 Group3Spin->SpinBox_DZ->setSingleStep(step);
2691 Group4Spin->SpinBox_DZ->setSingleStep(step);
2693 // san: Do NOT override the step when a speicifc step value is used
2694 // in some input fields!
2695 //Group4Spin->SpinBox_DX->setSingleStep(step);
2696 //Group4Spin->SpinBox_DY->setSingleStep(step);
2697 //Group4Spin->SpinBox_DS->setSingleStep(step);
2700 //=================================================================================
2701 // function : AddLocalCS()
2702 // purpose : Add All Coordinates systems in study
2703 //=================================================================================
2704 void EntityGUI_SketcherDlg::AddLocalCS(GEOM::GEOM_Object_var aSelectedObject)
2706 QString aName = GEOMBase::GetName( aSelectedObject );
2708 int index = ComboBox1->findText(aName, Qt::MatchExactly);
2710 if (index==-1) // If the working plane hasn't been added yet
2712 myWPlaneList.push_back(aSelectedObject);
2713 myWPlane = aSelectedObject;
2714 addSubshapesToStudy();
2715 myLCSList.push_back(WPlaneToLCS(aSelectedObject));
2716 ComboBox1->addItem(aName);
2717 index = ComboBox1->count();
2718 ComboBox1->setCurrentIndex(index-1);
2722 ComboBox1->setCurrentIndex(index);
2727 //=================================================================================
2728 // function : FindLocalCS()
2729 // purpose : Find All Coordinates systems in study
2730 //=================================================================================
2731 void EntityGUI_SketcherDlg::FindLocalCS()
2734 myWPlaneList.clear();
2735 SalomeApp_Application* app =
2736 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2740 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2744 _PTR(Study) aStudy = appStudy->studyDS();
2747 ComboBox1->addItem(tr("GEOM_GCS"));
2748 myWPlaneList.push_back(myGlobalCS);
2750 // get GEOM component
2751 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2752 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2755 _PTR(SComponent) fc = obj->GetFatherComponent();
2756 QString geomComp = fc->GetID().c_str();
2757 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2761 // browse through all GEOM data tree
2762 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2763 for ( it->InitEx( true ); it->More(); it->Next() )
2765 _PTR(SObject) child( it->Value() );
2766 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2767 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2768 if( CORBA::is_nil( geomObj ) )
2770 if (geomObj->GetType() == GEOM_MARKER)
2772 myWPlaneList.push_back(geomObj);
2773 myLCSList.push_back(WPlaneToLCS(geomObj));
2774 ComboBox1->addItem(geomObj->GetName());
2779 //=================================================================================
2780 // function : WPlaneToLCS ( aWPlane )
2782 //=================================================================================
2783 gp_Ax3 EntityGUI_SketcherDlg::WPlaneToLCS( GEOM::GEOM_Object_var geomObj )
2785 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2788 if (CORBA::is_nil( geomObj ) || aShape.IsNull())
2790 MESSAGE("CORBA::is_nil( geomObj ) || aShape.IsNull()")
2792 aLCS.Transform(aShape.Location().Transformation());
2793 if (aShape.ShapeType() == TopAbs_FACE)
2795 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
2796 myGeometryGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
2797 double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
2798 aMeasureOp->GetPosition( geomObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
2799 if ( aMeasureOp->IsDone() )
2801 gp_Pnt aPnt ( Ox, Oy, Oz );
2802 gp_Dir aDirN ( Zx, Zy, Zz );
2803 gp_Dir aDirX ( Xx, Xy, Xz );
2804 aLCS = gp_Ax3( aPnt, aDirN, aDirX );
2811 //=================================================================================
2812 // function : getPnt1ConstructorId()
2814 //=================================================================================
2815 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2817 int buttonId = GroupPt->ButtonGroup->checkedId();
2818 // MESSAGE("buttonId = "<<buttonId)
2822 //=================================================================================
2823 // function : getPnt2ConstructorId()
2825 //=================================================================================
2826 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2828 int buttonId = GroupPt2->ButtonGroup->checkedId();
2829 // MESSAGE("buttonId = "<<buttonId)
2833 //=================================================================================
2834 // function : GetActiveLocalCS()
2835 // purpose : Get Working plane
2836 //=================================================================================
2837 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2839 int ind = ComboBox1->currentIndex();
2841 return myGeometryGUI->GetWorkingPlane();
2843 gp_Ax3 aLCS = myLCSList.at(ind);
2844 myWPlane = myWPlaneList.at(ind);
2849 //=================================================================================
2850 // function : ActivateLocalCS()
2851 // purpose : Activate & Fit Working plane
2852 //=================================================================================
2853 void EntityGUI_SketcherDlg::ActivateLocalCS()
2855 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2856 myGeometryGUI->ActiveWorkingPlane();
2859 //=================================================================================
2860 // function : addSubshapeToStudy
2861 // purpose : virtual method to add new SubObjects if local selection
2862 //=================================================================================
2863 void EntityGUI_SketcherDlg::addSubshapesToStudy()
2865 GEOMBase::PublishSubObject(myWPlane);