1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
27 #include "EntityGUI_SketcherDlg.h"
28 #include "EntityGUI_Widgets.h"
29 #include <SalomeApp_DoubleSpinBox.h>
31 #include <OCCViewer_ViewPort3d.h>
32 #include <OCCViewer_ViewWindow.h>
33 #include <OCCViewer_ViewSketcher.h>
36 #include <GeometryGUI.h>
37 #include <GEOMImpl_Types.hxx>
38 #include <Geom_Surface.hxx>
39 #include <Geom_Plane.hxx>
41 #include <GeomLib_IsPlanarSurface.hxx>
43 #include <SUIT_Desktop.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_ResourceMgr.h>
47 #include <SalomeApp_Application.h>
48 #include <LightApp_Application.h>
49 #include <LightApp_SelectionMgr.h>
55 #include <BRep_Tool.hxx>
57 #include <TopExp_Explorer.hxx>
58 #include <TopoDS_Vertex.hxx>
60 #include <BRepBuilderAPI_Transform.hxx>
61 #include <BRepBuilderAPI_MakeWire.hxx>
62 #include <BRepBuilderAPI_MakeVertex.hxx>
63 #include <Sketcher_Profile.hxx>
65 #include <SalomeApp_Study.h>
66 #include <SalomeApp_Tools.h>
70 #include <Basics_Utils.hxx>
72 //=================================================================================
73 // class : EntityGUI_SketcherDlg()
74 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
75 // name 'name' and widget flags set to 'f'.
76 // The dialog will by default be modeless, unless you set 'modal' to
77 // TRUE to construct a modal dialog.
78 //=================================================================================
79 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
80 bool modal, Qt::WindowFlags fl,
81 const double lineWidth )
82 : QDialog( parent, fl ),
83 myIsAllAdded( false ),
85 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
87 myLineWidth( lineWidth )
89 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
91 setAttribute( Qt::WA_DeleteOnClose );
93 // Disable rectangular selection
94 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
95 // ((OCCViewer_ViewWindow*)theViewWindow)->setEnabledDrawMode( false );
96 // MESSAGE("((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode();"<<((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode())
97 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
98 // vp->setSketchingEnabled( false );
99 // MESSAGE("vp->isSketchingEnabled()"<<vp->isSketchingEnabled())
100 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(true);
101 // OCCViewer_ViewSketcher* aViewSketcher = ((OCCViewer_ViewWindow*)theViewWindow)->getSketcher( OCCViewer_ViewWindow::Rect );
102 // aViewSketcher->deactivate()
103 // aViewSketcher->setVisible(false);
105 // this->setMouseTracking(false);
107 myGeometryGUI->SetActiveDialogBox(this);
109 MainWidget = new EntityGUI_Skeleton( this );
110 QVBoxLayout* topLayout = new QVBoxLayout( this );
111 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
113 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
114 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_CLOSE" ) );
115 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
116 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
118 QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
119 QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
120 QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
121 QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
122 QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) );
123 QPixmap image5 (aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
124 QPixmap image6 (aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_RECTANGLE" ) ) );
126 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
128 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
129 MainWidget->RadioButton1->setText( "" );
130 MainWidget->RadioButton1->setIcon( image3 );
131 MainWidget->RadioButton2->setText( "" );
132 MainWidget->RadioButton2->setIcon( image4 );
133 MainWidget->RadioButton3->setText( "" );
134 MainWidget->RadioButton3->setIcon( image6 );
135 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
136 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
137 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
138 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
140 /***************************************************************/
142 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
143 QGridLayout* planeLayout = new QGridLayout(GroupBox1);
144 planeLayout->setSpacing(6);
145 planeLayout->setMargin(11);
147 ComboBox1 = new QComboBox(GroupBox1);
148 planeLayout->addWidget(ComboBox1,0,0,1,2);
150 planeButton = new QPushButton (GroupBox1);
151 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
152 planeLayout->addWidget(planeButton,0,2);
154 selButton = new QPushButton (GroupBox1);
155 selButton->setIcon(image5);
156 planeLayout->addWidget(selButton,1,0);
158 WPlaneLineEdit = new QLineEdit (GroupBox1);
159 WPlaneLineEdit->setReadOnly(true);
160 planeLayout->addWidget(WPlaneLineEdit,1,1,1,2);
162 planeLayout->setColumnStretch(1,1);
164 topLayout->addWidget(GroupBox1);
165 topLayout->addWidget( MainWidget );
166 topLayout->setStretch( 1, 1);
168 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
170 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
171 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
172 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
173 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
175 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
177 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
178 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
179 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
180 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
182 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
184 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
185 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
186 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
187 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
188 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
190 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
192 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIST" ) );
193 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
194 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
195 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
197 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
198 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
199 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
200 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
201 Group1Sel->PushButton1->setIcon( image0 );
202 Group1Sel->buttonUndo->setIcon( image1 );
203 Group1Sel->buttonRedo->setIcon( image2 );
204 Group1Sel->LineEdit1->setReadOnly( true );
206 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
207 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
208 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
209 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
210 Group2Sel->PushButton1->setIcon( image0 );
211 Group2Sel->PushButton2->setIcon( image0 );
212 Group2Sel->buttonUndo->setIcon( image1 );
213 Group2Sel->buttonRedo->setIcon( image2 );
214 Group2Sel->LineEdit1->setReadOnly( true );
215 Group2Sel->LineEdit2->setReadOnly( true );
217 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
218 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
219 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
220 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
221 Group1Sel1Spin->PushButton1->setIcon( image0 );
222 Group1Sel1Spin->buttonUndo->setIcon( image1 );
223 Group1Sel1Spin->buttonRedo->setIcon( image2 );
224 Group1Sel1Spin->LineEdit1->setReadOnly( true );
226 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
227 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
228 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
229 Group1Spin->buttonUndo->setIcon( image1 );
230 Group1Spin->buttonRedo->setIcon( image2 );
232 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
233 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
234 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
235 Group2Spin->buttonUndo->setIcon( image1 );
236 Group2Spin->buttonRedo->setIcon( image2 );
238 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
239 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
240 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
241 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
242 Group3Spin->buttonUndo->setIcon( image1 );
243 Group3Spin->buttonRedo->setIcon( image2 );
245 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
246 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
247 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
248 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
249 Group4Spin->buttonUndo->setIcon( image1 );
250 Group4Spin->buttonRedo->setIcon( image2 );
252 GroupRect = new DlgRef_4Spin( MainWidget->SkeletonCnt );
253 GroupRect->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
254 GroupRect->TextLabel1->setText("X1:");
255 GroupRect->TextLabel2->setText("Y1:");
256 GroupRect->TextLabel3->setText("X2:");
257 GroupRect->TextLabel4->setText("Y2:");
259 // Defines a palette for the error message on Group4Spin and Group2Sel
262 palette.setColor(Group4Spin->label->foregroundRole(), color);
263 Group4Spin->label->setPalette(palette);
264 palette.setColor(Group2Sel->label->foregroundRole(), color);
265 Group2Sel->label->setPalette(palette);
267 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
268 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
269 DestCntLayout->addWidget( GroupPt, 0, 0 );
270 DestCntLayout->addWidget( GroupPt2, 0, 1 );
271 DestCntLayout->addWidget( GroupD1, 0, 0 );
272 DestCntLayout->addWidget( GroupD2, 0, 1 );
274 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
275 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
276 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
277 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
278 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
279 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
280 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
281 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
282 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
283 SkeletonCntlayout->addWidget( GroupRect, 0, 0 );
284 //SkeletonCntlayout->setStretch( 0, 1);
285 /***************************************************************/
287 QButtonGroup* ButtonGroup = new QButtonGroup( this );
288 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
289 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
291 /* signals and slots connections */
292 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
293 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
294 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
295 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
297 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
298 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
299 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
300 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
301 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
302 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
303 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
304 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
305 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
306 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
307 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
308 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
309 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
310 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
311 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
312 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
313 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
314 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
315 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
316 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
317 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
319 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
320 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
321 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
322 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
323 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
324 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
326 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
327 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
329 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
330 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
331 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
332 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
334 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
335 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
336 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
338 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
339 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
340 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
341 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
342 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
343 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
344 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
345 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
346 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
347 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
348 connect( GroupRect->SpinBox_DX1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
349 connect( GroupRect->SpinBox_DX2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
350 connect( GroupRect->SpinBox_DY1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
351 connect( GroupRect->SpinBox_DY2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
353 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
354 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
355 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
356 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
358 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ActivateLocalCS() ) );
359 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
360 connect( selButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
362 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
364 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
365 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
367 // install event filter on spin-boxes to provide Apply action on Return pressed
368 Group1Spin->SpinBox_DX->installEventFilter(this);
369 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
370 Group2Spin->SpinBox_DX->installEventFilter(this);
371 Group2Spin->SpinBox_DY->installEventFilter(this);
372 Group3Spin->SpinBox_DX->installEventFilter(this);
373 Group3Spin->SpinBox_DY->installEventFilter(this);
374 Group3Spin->SpinBox_DZ->installEventFilter(this);
375 Group4Spin->SpinBox_DX->installEventFilter(this);
376 Group4Spin->SpinBox_DY->installEventFilter(this);
377 Group4Spin->SpinBox_DZ->installEventFilter(this);
378 Group4Spin->SpinBox_DS->installEventFilter(this);
384 //=================================================================================
385 // function : ~EntityGUI_SketcherDlg()
386 // purpose : Destroys the object and frees any allocated resources
387 //=================================================================================
388 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
390 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
392 myGeometryGUI->SetActiveDialogBox( 0 );
393 // ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(false);
397 //=================================================================================
398 // function : eventFilter()
399 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
400 //=================================================================================
401 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
403 if (event->type() == QEvent::KeyPress) {
404 QKeyEvent* ke = (QKeyEvent*)event;
405 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
406 if (object == Group1Spin->SpinBox_DX) {
407 Group1Spin->buttonApply->click();
409 } else if (object == Group1Sel1Spin->SpinBox_DX) {
410 Group1Sel1Spin->buttonApply->click();
412 } else if (object == Group2Spin->SpinBox_DX ||
413 object == Group2Spin->SpinBox_DY) {
414 Group2Spin->buttonApply->click();
416 } else if (object == Group3Spin->SpinBox_DX ||
417 object == Group3Spin->SpinBox_DY ||
418 object == Group3Spin->SpinBox_DZ) {
419 Group3Spin->buttonApply->click();
421 } else if (object == Group4Spin->SpinBox_DX ||
422 object == Group4Spin->SpinBox_DY ||
423 object == Group4Spin->SpinBox_DZ ||
424 object == Group4Spin->SpinBox_DS) {
425 Group4Spin->buttonApply->click();
431 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
433 return QDialog::eventFilter(object, event);
437 //=================================================================================
440 //=================================================================================
441 void EntityGUI_SketcherDlg::Init()
446 myEditCurrentArgument = WPlaneLineEdit; // Initiate the parameters selection with the first WPlaneLineEdit
448 myCommand.append( "Sketcher" );
449 myUndoCommand.append( "Sketcher" );
451 mySketchState = FIRST_POINT;
452 globalSelection( GEOM_FACE );
461 myHelpFileName = "create_sketcher_page.html";
463 GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
464 myGlobalCS = aBasicOp->MakeMarker( 0,0,0,
467 myWPlane = myGlobalCS;
468 myLCSList.push_back( WPlaneToLCS(myGlobalCS) );
470 /* Get setting of step value from file configuration */
471 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
473 /* min, max, step and decimals for spin boxes */
474 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
475 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
476 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
477 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
478 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
479 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
480 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
481 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
482 // san: Note specific step values below!
483 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
484 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
485 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
487 initSpinBox( GroupRect->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
488 initSpinBox( GroupRect->SpinBox_DY1, COORD_MIN, COORD_MAX, step, "length_precision" );
489 initSpinBox( GroupRect->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
490 initSpinBox( GroupRect->SpinBox_DY2, COORD_MIN, COORD_MAX, step, "length_precision" );
492 /* displays Dialog */
494 // MainWidget->RadioButton1->setEnabled( false );
495 // MainWidget->RadioButton2->setEnabled( false );
496 // MainWidget->RadioButton3->setEnabled( true );
497 // MainWidget->GroupDest1->setEnabled( false );
498 setEnabledUndo( false );
499 setEnabledRedo( false );
501 MainWidget->RadioButton1->setChecked( true );
505 // If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox
506 // that should be filled with the possibly selected face
510 SelectionIntoArgument();
514 setPrefix(tr("GEOM_SKETCH"));
518 setIsWaitCursorEnabled( false );
519 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
523 //=================================================================================
524 // function : InitClick()
526 //=================================================================================
527 void EntityGUI_SketcherDlg::InitClick()
529 MESSAGE("EntityGUI_SketcherDlg::InitClick()")
530 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
535 Group1Sel1Spin->hide();
541 globalSelection(); // close local selection to clear it
542 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
546 //=================================================================================
547 // function : TypeClicked()
548 // purpose : Radio button management
549 //=================================================================================
550 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
552 myConstructorId = constructorId;
553 MainWidget->buttonEnd->setText(tr("GEOM_BUT_CLOSE"));
554 MainWidget->buttonClose->setEnabled(true);
556 if ( myConstructorId == 0 ) { // SEGMENT
557 GroupPt2->RB_Point1->setChecked( true );
558 GroupPt ->setEnabled( true );
559 GroupPt2->setEnabled( false );
560 GroupD1->setEnabled( true );
561 GroupD2->setEnabled( true );
562 MainWidget->RB_Dest1->setEnabled( true );
563 MainWidget->RB_Dest1->setChecked( true );
565 MainWidget->GroupDest ->setEnabled( true );
566 MainWidget->GroupDest1->setEnabled( true );
567 MainWidget->GroupDest ->show();
568 MainWidget->GroupDest1->show();
570 if (mySketchState == FIRST_POINT)
575 else if ( myConstructorId == 1 ) { // ARC
576 GroupPt ->setEnabled( true );
577 GroupPt2->setEnabled( true );
578 GroupD2->RB_Dir21->setChecked( true );
579 GroupD1->setEnabled( true );
580 GroupD2->setEnabled( false );
581 MainWidget->RB_Dest1->setEnabled( true );
582 MainWidget->RB_Dest1->setChecked( true );
584 MainWidget->GroupDest ->setEnabled( true );
585 MainWidget->GroupDest1->setEnabled( true );
586 MainWidget->GroupDest ->show();
587 MainWidget->GroupDest1->show();
589 if (mySketchState == FIRST_POINT)
594 else if ( myConstructorId == 2 ) { // RECTANGLE
595 GroupPt ->setEnabled( false );
596 GroupPt2->setEnabled( false );
597 GroupD1 ->setEnabled( false );
598 GroupD2 ->setEnabled( false );
599 MainWidget->GroupDest ->setEnabled( false );
600 MainWidget->GroupDest1->setEnabled( false );
606 MainWidget->GroupDest ->hide();
607 MainWidget->GroupDest1->hide();
609 MainWidget->buttonEnd->setText(tr("Apply and Close"));
610 MainWidget->buttonClose->setEnabled(false);
612 GroupRect->setEnabled( true );
613 MainWidget->RadioButton1->setEnabled( true );
614 MainWidget->RadioButton2->setEnabled( true );
620 //=================================================================================
621 // function : RectClicked()
622 // purpose : Radio button management
623 //=================================================================================
624 void EntityGUI_SketcherDlg::RectClicked()
628 // Connect the selction manager (disconnected in InitClick())
629 connect( myGeometryGUI->getApp()->selectionMgr(),
630 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
639 GroupRect->SpinBox_DX1->setValue(myX1);
640 GroupRect->SpinBox_DY1->setValue(myY1);
641 GroupRect->SpinBox_DX2->setValue(myX2);
642 GroupRect->SpinBox_DY2->setValue(myY2);
644 resize( minimumSizeHint() );
646 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
650 //=================================================================================
651 // function : DestClicked()
652 // purpose : Radio button management
653 //=================================================================================
654 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
661 if ( constructorId == 1 ) {
663 GroupPt->RB_Point1->setChecked( true );
666 Group3Spin->checkBox->show();
667 Group4Spin->checkBox->show();
668 PointClicked( 1 ); // XY
670 else if ( constructorId == 0 ) {
672 GroupD1->RB_Dir11->setChecked( true );
675 Group3Spin->checkBox->hide();
676 Group4Spin->checkBox->hide();
677 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" ) );
1145 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
1146 Sketcher_Profile aProfile( Command.toAscii() );
1148 Command = myCommand.join( "" );
1149 aProfile = Sketcher_Profile( Command.toAscii() );
1150 TopoDS_Shape myShape;
1151 if ( aProfile.IsDone() )
1152 myShape = aProfile.GetShape();
1154 if ( myShape.ShapeType() != TopAbs_VERTEX )
1155 myCommand.append( ":WW" );
1158 /*// PAL16008 (Sketcher Validation should be equal to Apply&Close)
1159 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
1160 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
1161 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
1162 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
1163 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
1164 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
1165 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
1168 // ClickOnApply(); // TEST remove then
1169 myIsAllAdded = true;
1172 if (myConstructorId == 2)
1174 QString aParameters;
1175 myCommand.append( GetNewCommand( aParameters ) );
1176 mySketchState = NEXT_POINT;
1180 if ( myCommand.size() > 2 )
1189 //=================================================================================
1190 // function : ClickOnApply()
1192 //=================================================================================
1193 bool EntityGUI_SketcherDlg::ClickOnApply()
1195 MESSAGE("EntityGUI_SketcherDlg::ClickOnApply()")
1196 if ( sender() && sender()->inherits( "QPushButton" ) )
1197 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1199 // addSubshapesToStudy();
1201 QString aParameters;
1202 myCommand.append( GetNewCommand( aParameters ) );
1203 if (mySketchState == FIRST_POINT)
1205 mySketchState = NEXT_POINT;
1209 myUndoCommand.clear();
1210 myUndoCommand.append( "Sketcher" );
1212 myParameters.append( aParameters );
1213 myUndoParameters.clear();
1215 setEnabledUndo( true );
1216 setEnabledRedo( false );
1219 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1222 // Set focus to SpinBox_DX
1223 if ( sender() == Group1Spin->buttonApply ) {
1224 (Group1Spin->SpinBox_DX)->setFocus();
1225 (Group1Spin->SpinBox_DX)->selectAll();
1227 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1228 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1229 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1231 else if ( sender() == Group2Spin->buttonApply ) {
1232 (Group2Spin->SpinBox_DX)->setFocus();
1233 (Group2Spin->SpinBox_DX)->selectAll();
1235 else if ( sender() == Group3Spin->buttonApply ) {
1236 (Group3Spin->SpinBox_DX)->setFocus();
1237 (Group3Spin->SpinBox_DX)->selectAll();
1239 else if ( sender() == Group4Spin->buttonApply ) {
1240 (Group4Spin->SpinBox_DX)->setFocus();
1241 (Group4Spin->SpinBox_DX)->selectAll();
1247 //=================================================================================
1248 // function : ClickOnHelp()
1250 //=================================================================================
1251 void EntityGUI_SketcherDlg::ClickOnHelp()
1253 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1255 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1259 platform = "winapplication";
1261 platform = "application";
1264 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1265 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1266 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1267 QObject::tr( "BUT_OK" ) );
1271 //=================================================================================
1272 // function : ClickOnUndo()
1274 //=================================================================================
1275 void EntityGUI_SketcherDlg::ClickOnUndo()
1277 myUndoCommand.append( myCommand.last() );
1278 myCommand.pop_back();
1280 myUndoParameters.append( myParameters.last() );
1281 myParameters.pop_back();
1283 if ( myCommand.count() == 1 ) {
1284 mySketchState = FIRST_POINT;
1286 MainWidget->RadioButton1->setChecked( true );
1289 connect( myGeometryGUI->getApp()->selectionMgr(),
1290 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1294 setEnabledUndo( false );
1297 setEnabledRedo( true );
1299 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1302 //=================================================================================
1303 // function : ClickOnRedo()
1305 //=================================================================================
1306 void EntityGUI_SketcherDlg::ClickOnRedo()
1308 myCommand.append( myUndoCommand.last() );
1309 myUndoCommand.pop_back();
1311 myParameters.append( myUndoParameters.last() );
1312 myUndoParameters.pop_back();
1314 mySketchState = NEXT_POINT;
1318 setEnabledUndo( true );
1320 if ( myUndoCommand.count() == 1 )
1321 setEnabledRedo( false );
1323 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1326 //=================================================================================
1327 // function : setEnabledUndo()
1329 //=================================================================================
1330 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1332 Group1Sel->buttonUndo->setEnabled( value );
1333 Group2Sel->buttonUndo->setEnabled( value );
1334 Group1Sel1Spin->buttonUndo->setEnabled( value );
1335 Group1Spin->buttonUndo->setEnabled( value );
1336 Group2Spin->buttonUndo->setEnabled( value );
1337 Group3Spin->buttonUndo->setEnabled( value );
1338 Group4Spin->buttonUndo->setEnabled( value );
1341 //=================================================================================
1342 // function : setEnabledRedo()
1344 //=================================================================================
1345 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1347 Group1Sel->buttonRedo->setEnabled( value );
1348 Group2Sel->buttonRedo->setEnabled( value );
1349 Group1Sel1Spin->buttonRedo->setEnabled( value );
1350 Group1Spin->buttonRedo->setEnabled( value );
1351 Group2Spin->buttonRedo->setEnabled( value );
1352 Group3Spin->buttonRedo->setEnabled( value );
1353 Group4Spin->buttonRedo->setEnabled( value );
1356 //=================================================================================
1357 // function : SelectionIntoArgument()
1358 // purpose : Called when selection as changed
1359 //=================================================================================
1360 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1362 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1363 myEditCurrentArgument->setText( "" );
1365 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1366 SALOME_ListIO aSelList;
1367 aSelMgr->selectedObjects(aSelList);
1369 this->activateWindow();
1371 if (aSelList.Extent() == 0)
1373 selButton->setDown(false);
1374 WPlaneLineEdit->setEnabled(false);
1375 WPlaneLineEdit->setText(tr("GEOM_SKETCHER_WPLANE"));
1378 else if (aSelList.Extent() != 1)
1386 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
1387 if (myEditCurrentArgument == WPlaneLineEdit)
1388 aNeedType = TopAbs_FACE;
1391 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
1392 TopoDS_Shape aShape;
1394 if(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape)
1395 && !aShape.IsNull())
1397 QString aName = GEOMBase::GetName( aSelectedObject.get() );
1398 if (myEditCurrentArgument==WPlaneLineEdit)
1400 // Check if the face is planar
1401 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
1402 GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion());
1404 if (aPlanarCheck.IsPlanar())
1406 myEditCurrentArgument->setText(aName);
1407 AddLocalCS(aSelectedObject.get());
1408 selButton->setDown(false);
1409 WPlaneLineEdit->setEnabled(false);
1410 TypeClicked( myConstructorId );
1414 myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE"));
1415 // The following leads to crash TODO : find a way to return a warning
1416 // Standard_Failure::Raise(tr("GEOM_SKETCHER_NOT_PLANAR").toStdString().c_str());
1422 gp_Ax3 aWPlane = GetActiveLocalCS();
1424 aTrans.SetTransformation(aWPlane);
1425 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1426 aShape = aTransformation.Shape();
1429 if ( GEOMBase::VertexToPoint( aShape, aPnt ) )
1431 myEditCurrentArgument->setText(aName);
1434 double Xcoord = myX;
1435 double Ycoord = myY;
1437 switch (mySketchType)
1440 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1441 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1443 Group2Spin->SpinBox_DX->setValue(Xcoord);
1444 Group2Spin->SpinBox_DY->setValue(Ycoord);
1446 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1447 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1451 if (myLastX1 && myLastY1)
1453 Xcoord = myX - myLastX1;
1454 Ycoord = myY - myLastY1;
1456 else if (mySketchState != FIRST_POINT)
1458 Xcoord = myX - tmpX;
1459 Ycoord = myY - tmpY;
1461 Group2Spin->SpinBox_DX->setValue(Xcoord);
1462 Group2Spin->SpinBox_DY->setValue(Ycoord);
1466 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1467 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1469 Group3Spin->SpinBox_DX->setValue(Xcoord);
1470 Group3Spin->SpinBox_DY->setValue(Ycoord);
1472 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1473 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1477 if (myLastX1 && myLastY1)
1479 Xcoord = myX - myLastX1;
1480 Ycoord = myY - myLastY1;
1482 else if (mySketchState != FIRST_POINT)
1484 Xcoord = myX - tmpX;
1485 Ycoord = myY - tmpY;
1487 Group3Spin->SpinBox_DX->setValue(Xcoord);
1488 Group3Spin->SpinBox_DY->setValue(Ycoord);
1492 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1493 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1495 Group4Spin->SpinBox_DX->setValue(Xcoord);
1496 Group4Spin->SpinBox_DY->setValue(Ycoord);
1498 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1499 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1503 if (myLastX1 && myLastY1)
1505 Xcoord = myXc - myLastX1;
1506 Ycoord = myYc - myLastY1;
1508 else if (mySketchState != FIRST_POINT)
1510 Xcoord = myXc - tmpX;
1511 Ycoord = myYc - tmpY;
1519 Group4Spin->SpinBox_DX->setValue(Xcoord);
1520 Group4Spin->SpinBox_DY->setValue(Ycoord);
1529 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1539 //=================================================================================
1540 // function : SetEditCurrentArgument()
1542 //=================================================================================
1543 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1545 TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX;
1546 if ( sender() == Group1Sel->PushButton1 ) {
1547 myEditCurrentArgument = Group1Sel->LineEdit1;
1548 myEditCurrentArgument->setFocus();
1550 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1551 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1552 myEditCurrentArgument->setFocus();
1554 else if ( sender() == Group2Sel->PushButton1 ) {
1555 myEditCurrentArgument = Group2Sel->LineEdit1;
1556 Group2Sel->PushButton2->setDown(false);
1557 Group2Sel->PushButton1->setDown(true);
1558 Group2Sel->LineEdit2->setEnabled(false);
1559 Group2Sel->LineEdit1->setEnabled(true);
1560 // myEditCurrentArgument->setFocus();
1562 else if ( sender() == Group2Sel->PushButton2 ) {
1563 myEditCurrentArgument = Group2Sel->LineEdit2;
1564 Group2Sel->PushButton1->setDown(false);
1565 Group2Sel->PushButton2->setDown(true);
1566 Group2Sel->LineEdit1->setEnabled(false);
1567 Group2Sel->LineEdit2->setEnabled(true);
1568 // myEditCurrentArgument->setFocus();
1570 else if ( sender() == selButton ) {
1571 myNeedType = TopAbs_FACE;
1572 myEditCurrentArgument = WPlaneLineEdit;
1573 WPlaneLineEdit->setEnabled(true);
1574 selButton->setDown(true);
1576 globalSelection(); // close local selection to clear it
1577 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
1581 //=================================================================================
1582 // function : LineEditReturnPressed()
1584 //=================================================================================
1585 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1587 if ( sender() == Group1Sel->LineEdit1 )
1588 myEditCurrentArgument = Group1Sel->LineEdit1;
1589 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1590 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1591 else if ( sender() == Group2Sel->LineEdit1 )
1592 myEditCurrentArgument = Group2Sel->LineEdit1;
1593 else if ( sender() == Group2Sel->LineEdit2 )
1594 myEditCurrentArgument = Group2Sel->LineEdit2;
1596 /* User name of object input management */
1597 /* If successfull the selection is changed and signal emitted... */
1598 /* so SelectionIntoArgument() is automatically called. */
1599 const QString objectUserName = myEditCurrentArgument->text();
1600 QWidget* thisWidget = (QWidget*)this;
1602 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1603 SALOME_ListIO aSelList;
1604 aSelMgr->selectedObjects(aSelList);
1606 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1607 myEditCurrentArgument->setText( objectUserName );
1611 //=================================================================================
1612 // function : DeactivateActiveDialog()
1614 //=================================================================================
1615 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1617 //myGeometryGUI->SetState( -1 );
1619 setEnabled( false );
1621 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1622 myGeometryGUI->SetActiveDialogBox( 0 );
1626 //=================================================================================
1627 // function : ActivateThisDialog()
1629 //=================================================================================
1630 void EntityGUI_SketcherDlg::ActivateThisDialog()
1632 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1633 myGeometryGUI->EmitSignalDeactivateDialog();
1635 myGeometryGUI->SetActiveDialogBox( this );
1637 connect( myGeometryGUI->getApp()->selectionMgr(),
1638 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1640 //myGeometryGUI->SetState( 0 );
1641 // globalSelection( GEOM_POINT );
1643 myEditCurrentArgument = WPlaneLineEdit;
1644 myEditCurrentArgument->setFocus();
1646 if ( sender() == Group1Sel->LineEdit1 ) {
1647 myEditCurrentArgument = Group1Sel->LineEdit1;
1648 myEditCurrentArgument->setFocus();
1650 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1651 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1652 myEditCurrentArgument->setFocus();
1654 else if ( sender() == Group2Sel->LineEdit1 ) {
1655 myEditCurrentArgument = Group2Sel->LineEdit1;
1656 myEditCurrentArgument->setFocus();
1658 else if ( sender() == Group2Sel->LineEdit2 ) {
1659 myEditCurrentArgument = Group2Sel->LineEdit2;
1660 myEditCurrentArgument->setFocus();
1663 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1667 //=================================================================================
1668 // function : enterEvent [REDEFINED]
1670 //=================================================================================
1671 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1674 ActivateThisDialog();
1678 //=================================================================================
1679 // function : closeEvent()
1681 //=================================================================================
1682 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1684 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1685 //myGeometryGUI->SetState( -1 );
1686 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1687 myGeometryGUI->getApp()->updateActions();
1688 QDialog::closeEvent( e );
1691 //=================================================================================
1692 // function : OnPointSelected
1694 //=================================================================================
1695 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt,
1698 // NOTE Basing the autoapply functionnality on the background picture has no sense anymore
1699 // The import picture functionnality is now used for drawing on top of a picture
1701 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
1702 // OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
1704 // QString theImgFileName;
1705 // vp->background().texture( theImgFileName ); ////////////// VSR: temporarily
1710 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1711 TopoDS_Shape aShape = mkVertex.Shape();
1713 // Taking into account LocalCS
1714 gp_Ax3 aWPlane = GetActiveLocalCS();
1717 aTrans.SetTransformation(aWPlane);
1718 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1719 aShape = aTransformation.Shape();
1722 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1724 // NOTE autoapply disabled : doesn't seem useful anymore
1725 // autoApply = ( (getPnt2ConstructorId() == 1) && (!theImgFileName.isEmpty()) ); // If no additional argument needed after selection and there is a backgroundimage
1726 // -> apply automatically
1728 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1729 x = aTrsfPnt.X() - myLastX1;
1730 y = aTrsfPnt.Y() - myLastY1;
1736 switch (getPnt2ConstructorId()){
1738 Group2Spin->SpinBox_DX->setValue( x );
1739 Group2Spin->SpinBox_DY->setValue( y );
1740 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1743 Group3Spin->SpinBox_DX->setValue( x );
1744 Group3Spin->SpinBox_DY->setValue( y );
1745 Group3Spin->buttonApply->setFocus();
1748 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1749 Group4Spin->SpinBox_DX->setValue( x );
1750 Group4Spin->SpinBox_DY->setValue( y );
1752 else{ // Select end point
1753 Group4Spin->SpinBox_DZ->setValue( x );
1754 Group4Spin->SpinBox_DS->setValue( y );
1756 Group4Spin->buttonApply->setFocus();
1759 if ( myConstructorId == 2 ) //RECTANGLE
1763 GroupRect->SpinBox_DX1->setValue( aTrsfPnt.X() );
1764 GroupRect->SpinBox_DY1->setValue( aTrsfPnt.Y() );
1765 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1766 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1770 GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
1771 GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
1776 //=================================================================================
1777 // function : OnFirstPoint
1779 //=================================================================================
1780 void EntityGUI_SketcherDlg::OnFirstPoint()
1782 MainWidget->RadioButton3->setEnabled( true );
1783 MainWidget->GroupDest1->setEnabled( false );
1784 GroupPt2->setEnabled( false );
1787 //=================================================================================
1788 // function : OnNextPoint
1790 //=================================================================================
1791 void EntityGUI_SketcherDlg::OnNextPoint()
1793 MainWidget->RadioButton3->setEnabled( false );
1794 MainWidget->GroupDest1->setEnabled( true );
1795 TypeClicked(myConstructorId);
1798 //=================================================================================
1799 // function : ValueChangedInSpinBox()
1801 //=================================================================================
1802 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1804 QObject* send = (QObject*)sender();
1805 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1806 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1808 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1809 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1810 double LastDecimal = 0.0;
1812 QString vxStr, vyStr, vzStr, vsStr;
1814 QString newValueStr;
1815 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1816 newValueStr = aDoubleSpinBox->text();
1818 if ( send == Group1Spin->SpinBox_DX ) {
1819 vx = newValue; vxStr = newValueStr;
1821 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1822 vx = newValue; vxStr = newValueStr;
1824 else if ( send == Group2Spin->SpinBox_DX ) {
1825 vx = newValue; vxStr = newValueStr;
1826 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1828 else if ( send == Group2Spin->SpinBox_DY ) {
1829 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1830 vy = newValue; vyStr = newValueStr;
1832 else if ( send == Group3Spin->SpinBox_DX ) {
1833 vx = newValue; vxStr = newValueStr;
1834 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1835 vz = Group3Spin->SpinBox_DZ->value();
1836 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1837 if (mySketchType == PT_ABS_RADIUS){
1845 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1846 if (aPrecision >= 0) // 'f' format in the QString
1847 LastDecimal = aPrecision;
1848 else // 'g' format in the Qstring
1849 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1850 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1851 if ( Abs(vz) < minRad){
1853 Group3Spin->SpinBox_DZ->setValue( - minRad );
1855 Group3Spin->SpinBox_DZ->setValue( minRad );
1858 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1860 else if ( send == Group3Spin->SpinBox_DY ) {
1861 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1862 vy = newValue; vyStr = newValueStr;
1863 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1864 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1865 if (mySketchType == PT_ABS_RADIUS){
1873 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1874 if (aPrecision >= 0) // 'f' format in the QString
1875 LastDecimal = aPrecision;
1876 else // 'g' format in the QString
1877 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1878 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1879 if ( Abs(vz) < minRad){
1881 Group3Spin->SpinBox_DZ->setValue( - minRad );
1883 Group3Spin->SpinBox_DZ->setValue( minRad );
1886 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1888 else if ( send == Group3Spin->SpinBox_DZ ) {
1889 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1890 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1891 vz = newValue; vzStr = newValueStr;
1893 else if ( send == Group4Spin->SpinBox_DX ) {
1894 vx = newValue; vxStr = newValueStr;
1895 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1896 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1897 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1899 else if ( send == Group4Spin->SpinBox_DY ) {
1900 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1901 vy = newValue; vyStr = newValueStr;
1902 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1903 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1905 else if ( send == Group4Spin->SpinBox_DZ ) {
1906 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1907 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1908 vz = newValue; vzStr = newValueStr;
1909 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1911 else if ( send == Group4Spin->SpinBox_DS ) {
1912 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1913 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1914 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1915 vs = newValue; vsStr = newValueStr;
1917 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1919 if ( myConstructorId == 0 ) { // SEGMENT
1920 if ( mySketchType == PT_ABS ) {
1926 else if ( mySketchType == PT_RELATIVE ) {
1932 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1936 myLengthStr = vyStr;
1938 else if ( mySketchType == DIR_ANGLE_X ) {
1944 else if ( mySketchType == DIR_ANGLE_Y ) {
1950 else if ( mySketchType == DIR_PER_LENGTH ) {
1952 myLengthStr = vxStr;
1954 else if ( mySketchType == DIR_PER_X ) {
1958 else if ( mySketchType == DIR_PER_Y ) {
1962 else if ( mySketchType == DIR_TAN_LENGTH ) {
1964 myLengthStr = vxStr;
1966 else if ( mySketchType == DIR_TAN_X ) {
1970 else if ( mySketchType == DIR_TAN_Y ) {
1974 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1980 myLengthStr = vzStr;
1982 else if ( mySketchType == DIR_DXDY_X ) {
1990 else if ( mySketchType == DIR_DXDY_Y ) {
1999 else if ( myConstructorId == 1 ) { // ARC
2000 if ( mySketchType == PT_ABS ) {
2006 else if ( mySketchType == PT_RELATIVE ) {
2012 if ( mySketchType == PT_ABS_RADIUS ) {
2018 myRadiusStr = vzStr;
2020 else if ( mySketchType == PT_REL_RADIUS ) {
2026 myRadiusStr = vzStr;
2028 else if ( mySketchType == PT_SEL_RADIUS ) {
2030 myRadiusStr = vxStr;
2032 if ( mySketchType == PT_ABS_CENTER ) {
2042 else if ( mySketchType == PT_REL_CENTER ) {
2052 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2057 myRadiusStr = vyStr;
2058 myLengthStr = vzStr;
2060 else if ( mySketchType == DIR_PER_LENGTH ) {
2063 myRadiusStr = vxStr;
2064 myLengthStr = vyStr;
2066 else if ( mySketchType == DIR_TAN_LENGTH ) {
2069 myRadiusStr = vxStr;
2070 myLengthStr = vyStr;
2072 else if ( mySketchType == DIR_DXDY_LENGTH ) {
2079 myRadiusStr = vzStr;
2080 myLengthStr = vsStr;
2083 else if ( myConstructorId == 2 ) { // RECTANGLE
2084 myX1 = GroupRect->SpinBox_DX1->value(); myX1Str = GroupRect->SpinBox_DX1->text();
2085 myX2 = GroupRect->SpinBox_DX2->value(); myX2Str = GroupRect->SpinBox_DX2->text();
2086 myY1 = GroupRect->SpinBox_DY1->value(); myY1Str = GroupRect->SpinBox_DY1->text();
2087 myY2 = GroupRect->SpinBox_DY2->value(); myY2Str = GroupRect->SpinBox_DY2->text();
2092 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
2094 double x, y, xc, yc;
2095 x = y = xc = yc = 0.0;
2096 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
2098 if ( mySketchType == PT_REL_CENTER ){
2099 x = myDX + myLastX1;
2100 y = myDY + myLastY1;
2101 xc = myDXc + myLastX1;
2102 yc = myDYc + myLastY1;
2110 displayPntPreview(xc,yc);
2111 displayPntPreview(x,y);
2116 //=================================================================================
2117 // function : GetNewCommand()
2118 // purpose : Build the new command with context
2119 //=================================================================================
2120 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
2122 theParameters.clear();
2123 QString myNewCommand = ":";
2124 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2125 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2126 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2128 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2129 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2131 if ( mySketchState == FIRST_POINT ) {
2132 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2133 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2134 theParameters = myXStr + ":" + myYStr;
2136 if ( mySketchType == PT_RELATIVE) {
2137 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2138 theParameters = myDXStr + ":" + myDYStr;
2140 if (myConstructorId == 2 )
2143 return myNewCommand;
2146 if ( myConstructorId == 0 ) { // SEGMENT
2147 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2148 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2149 theParameters = myXStr + ":" + myYStr;
2151 if ( mySketchType == PT_RELATIVE) {
2152 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2153 theParameters = myDXStr + ":" + myDYStr;
2155 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2156 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2157 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2158 theParameters = myAngleStr + ":" + myLengthStr;
2160 if ( mySketchType == DIR_ANGLE_X ) {
2161 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2162 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2163 theParameters = myAngleStr + ":" + myXStr;
2165 if ( mySketchType == DIR_ANGLE_Y ) {
2166 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2167 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2168 theParameters = myAngleStr + ":" + myYStr;
2170 if ( mySketchType == DIR_PER_LENGTH ) {
2171 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2172 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2173 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
2175 if ( mySketchType == DIR_PER_X ) {
2176 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2177 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2178 theParameters = QString::number( 90.0 ) + ":" + myXStr;
2180 if ( mySketchType == DIR_PER_Y ) {
2181 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2182 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2183 theParameters = QString::number( 90.0 ) + ":" + myYStr;
2185 if ( mySketchType == DIR_TAN_LENGTH ) {
2186 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
2187 theParameters = myLengthStr;
2189 if ( mySketchType == DIR_TAN_X ) {
2190 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
2191 theParameters = myXStr;
2193 if ( mySketchType == DIR_TAN_Y) {
2194 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
2195 theParameters = myYStr;
2197 if ( mySketchType == DIR_DXDY_LENGTH ) {
2198 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2199 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
2200 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
2202 if ( mySketchType == DIR_DXDY_X ) {
2203 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2204 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
2205 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
2207 if ( mySketchType == DIR_DXDY_Y ) {
2208 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2209 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
2210 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
2213 else if ( myConstructorId == 1 ) { // ARC
2214 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
2215 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
2216 theParameters = myXStr + ":" + myYStr;
2218 if ( mySketchType == PT_RELATIVE) {
2219 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2220 theParameters = myDXStr + ":" + myDYStr;
2222 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
2223 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
2224 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
2226 if ( mySketchType == PT_REL_RADIUS) {
2227 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
2228 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
2230 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2231 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 );
2232 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2234 if ( mySketchType == PT_REL_CENTER) {
2235 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 );
2236 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2238 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2239 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2240 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2241 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2243 if ( mySketchType == DIR_PER_LENGTH ) {
2244 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2245 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2246 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2248 if ( mySketchType == DIR_TAN_LENGTH ) {
2249 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2250 theParameters = myRadiusStr + ":" + myLengthStr;
2252 if ( mySketchType == DIR_DXDY_LENGTH ) {
2253 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2254 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2255 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2258 else if ( myConstructorId == 2 ) { // RECTANGLE
2259 myNewCommand = myNewCommand + "F " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2260 + ":TT " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2261 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
2262 + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
2265 theParameters = myX1Str + ":" + myY1Str + ":" + myX2Str + ":" + myY2Str ;
2267 return myNewCommand;
2270 //=================================================================================
2271 // function : createOperation
2273 //=================================================================================
2274 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2276 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2279 //=================================================================================
2280 // function : isValid
2282 //=================================================================================
2283 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2286 bool toCorrect = !IsPreview() || myIsApply;
2288 if( Group1Spin->isVisible() ) {
2289 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2291 else if( Group1Sel1Spin->isVisible() ) {
2292 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2294 else if( Group2Spin->isVisible() ) {
2295 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2296 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2298 else if( Group3Spin->isVisible() ) {
2299 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2300 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2301 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2303 else if( Group4Spin->isVisible() ) {
2304 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2305 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2306 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2307 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2310 if( myIsApply && !ok )
2316 //=================================================================================
2317 // function : execute
2319 //=================================================================================
2320 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2322 MESSAGE("EntityGUI_SketcherDlg::execute")
2323 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2324 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2325 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2327 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2328 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2330 QString aParameters;
2332 if ( mySketchState == FIRST_POINT ) {
2337 //Test if the current point is the same as the last one
2338 TopoDS_Shape myShape1, myShape2;
2340 // Set "C" numeric locale
2341 Kernel_Utils::Localizer loc;
2344 QString Command1 = myCommand.join( "" );
2345 Sketcher_Profile aProfile1( Command1.toAscii() );
2346 if ( aProfile1.IsDone() )
2347 myShape1 = aProfile1.GetShape();
2350 QString Command2 = Command1 + GetNewCommand( aParameters );
2351 Sketcher_Profile aProfile2( Command2.toAscii() );
2354 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2355 if (aProfile2.Error() > Precision::Confusion()){
2356 Group4Spin->label->show();
2357 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2360 Group4Spin->label->hide();
2364 Group4Spin->label->hide();
2365 if ( mySketchType == PT_SEL_CENTER ){
2366 if (aProfile2.Error() > Precision::Confusion()){
2367 Group2Sel->label->show();
2368 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2371 Group2Sel->label->hide();
2375 Group2Sel->label->hide();
2377 if ( aProfile2.IsDone() )
2378 myShape2 = aProfile2.GetShape();
2380 if ( myShape2.IsNull() ) {
2381 //the current point is the same as the last one
2382 myLastX2 = myLastX1;
2383 myLastY2 = myLastY1;
2386 TopoDS_Vertex V1, V2;
2388 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2389 //the last shape is the first point
2390 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2395 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2396 pt = BRep_Tool::Pnt( V2 );
2400 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2401 pt = BRep_Tool::Pnt( V2 );
2408 if ( ( mySketchState != FIRST_POINT &&
2409 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2410 cmd = myCommand.join( "" );
2411 if ( Group1Sel->isVisible() ) {
2412 Group1Sel->buttonApply->setEnabled( false );
2413 //Group1Sel->buttonApply->setFocus();
2415 if ( Group2Sel->isVisible() ) {
2416 Group2Sel->buttonApply->setEnabled( false );
2417 //Group2Sel->buttonApply->setFocus();
2419 if ( Group1Sel1Spin->isVisible() ) {
2420 Group1Sel1Spin->buttonApply->setEnabled( false );
2421 //Group1Sel1Spin->buttonApply->setFocus();
2423 if ( Group1Spin->isVisible() ) {
2424 Group1Spin->buttonApply->setEnabled( false );
2425 //Group1Spin->buttonApply->setFocus();
2427 if ( Group2Spin->isVisible() ) {
2428 Group2Spin->buttonApply->setEnabled( false );
2429 //Group2Spin->buttonApply->setFocus();
2431 if ( Group3Spin->isVisible() ) {
2432 Group3Spin->buttonApply->setEnabled( false );
2433 //Group3Spin->buttonApply->setFocus();
2435 if ( Group4Spin->isVisible() ) {
2436 Group4Spin->buttonApply->setEnabled( false );
2437 //Group4Spin->buttonApply->setFocus();
2441 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2443 if ( Group1Sel->isVisible() ) {
2444 Group1Sel->buttonApply->setEnabled( true );
2446 if ( Group2Sel->isVisible() ) {
2447 Group2Sel->buttonApply->setEnabled( true );
2449 if ( Group1Sel1Spin->isVisible() ) {
2450 Group1Sel1Spin->buttonApply->setEnabled( true );;
2452 if ( Group1Spin->isVisible() ) {
2453 Group1Spin->buttonApply->setEnabled( true );
2455 if ( Group2Spin->isVisible() ) {
2456 Group2Spin->buttonApply->setEnabled( true );
2458 if ( Group3Spin->isVisible() ) {
2459 Group3Spin->buttonApply->setEnabled( true );
2461 if ( Group4Spin->isVisible() ) {
2462 Group4Spin->buttonApply->setEnabled( true );
2466 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2467 GEOM::GEOM_Object_var anObj = NULL;
2469 int index = ComboBox1->currentIndex();
2470 if(index != -1 && !myWPlane->_is_nil()) // The combobox is not empty
2472 anObj = anOper->MakeSketcherOnPlane( cmd.toLatin1().constData(), myWPlane );
2474 if ( !anObj->_is_nil() )
2476 if( !IsPreview() ) {
2477 QStringList aCurrentParameters = myParameters;
2478 aCurrentParameters << aParameters;
2479 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2482 objects.push_back( anObj._retn() );
2488 //================================================================
2489 // Function : displayPreview
2490 // Purpose : Method for displaying preview of resulting shape
2491 // Redefined from GEOMBase_Helper.
2492 //================================================================
2493 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2495 const bool activate,
2497 const double lineWidth,
2498 const int displayMode,
2501 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2503 QColor aColor = resMgr->colorValue("Geometry","line_color",QColor(255,0,0));
2504 Quantity_NameOfColor line_color = SalomeApp_Tools::color( aColor ).Name();
2506 // set width of displayed shape
2509 lw = resMgr->integerValue("Geometry", "preview_edge_width", -1);
2511 getDisplayer()->SetWidth( lw );
2513 // Disable activation of selection
2514 getDisplayer()->SetToActivate( activate );
2516 // Make a reference to GEOM_Object
2517 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2518 getDisplayer()->SetName( objStr.in() );
2520 // Create wire from applied object
2521 TopoDS_Shape anApplyedWire, aLastSegment;
2522 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2526 if( myConstructorId != 2)
2527 getDisplayer()->SetColor( line_color );
2529 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2531 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2532 if ( aPrs != 0 && !aPrs->IsNull() )
2533 GEOMBase_Helper::displayPreview( aPrs, append, update );
2535 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2536 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2538 if ( aPrs != 0 && !aPrs->IsNull() )
2539 GEOMBase_Helper::displayPreview( aPrs, append, update );
2541 getDisplayer()->SetColor( line_color );
2543 getDisplayer()->UnsetName();
2545 // Enable activation of displayed objects
2546 getDisplayer()->SetToActivate( true );
2549 //================================================================
2550 // Function : displayPntPreview
2551 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2552 //================================================================
2553 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2559 // Get globalCS and working plane
2560 gp_Ax3 globalCS = WPlaneToLCS( myGlobalCS );
2561 gp_Ax3 aWPlane = GetActiveLocalCS();
2563 // Build point in localCS
2564 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2566 // Get transfomation from local to global CS
2568 aTrans.SetTransformation(aWPlane, globalCS);
2570 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2571 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2573 // Perform transformation
2574 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2575 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2577 // Build prs with vertex in globalCS
2578 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2579 if ( aPrs != 0 && !aPrs->IsNull() )
2580 GEOMBase_Helper::displayPreview( aPrs, append, update );
2584 //================================================================
2585 // Function : createShapes
2586 // Purpose : Create applyed wire, and last segment from entry object
2587 //================================================================
2588 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2589 TopoDS_Shape& theApplyedWire,
2590 TopoDS_Shape& theLastSegment )
2592 TopoDS_Shape aShape;
2593 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2594 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2597 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2598 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2599 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2600 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2601 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2602 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2603 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2604 theApplyedWire = aShape;
2608 BRepBuilderAPI_MakeWire aBuilder;
2609 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2611 TopoDS_Shape anEdge = anExp.Current();
2613 if ( anExp.More() ) // i.e. non-last edge
2614 aBuilder.Add( TopoDS::Edge( anEdge ) );
2616 theLastSegment = anEdge;
2621 if ( aBuilder.IsDone() )
2622 theApplyedWire = aBuilder.Shape();
2627 //=================================================================================
2628 // function : acceptMouseEvent()
2630 //=================================================================================
2631 bool EntityGUI_SketcherDlg::acceptMouseEvent() const
2633 return ( (getPnt1ConstructorId() == 1
2634 || getPnt1ConstructorId() == 0
2635 || myConstructorId == 2) //accept mouse event only on absolute and relative selection mode
2636 && !WPlaneLineEdit->isEnabled()); //or when the constructor is rectangle
2637 //called by EntityGUI::OnMousePress()
2640 //=================================================================================
2641 // function : keyPressEvent()
2643 //=================================================================================
2644 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2646 QDialog::keyPressEvent( e );
2647 if ( e->isAccepted() )
2650 if ( e->key() == Qt::Key_F1 ) {
2656 //=================================================================================
2657 // function : initSpinBox()
2659 //=================================================================================
2660 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2661 double min, double max,
2662 double step, const char* quantity )
2664 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2665 // TODO: Think how to keep the single piece of code...
2667 // Obtain precision from preferences
2668 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2669 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2671 spinBox->setPrecision( aPrecision );
2672 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2673 // by default Qt rounds boundaries to 2 decimals at setRange
2674 spinBox->setRange( min, max );
2675 spinBox->setSingleStep( step );
2677 // Add a hint for the user saying how to tune precision
2678 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2679 spinBox->setProperty( "validity_tune_hint",
2680 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2683 //=================================================================================
2684 // function : SetDoubleSpinBoxStep()
2685 // purpose : Double spin box management
2686 //=================================================================================
2687 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2689 Group1Spin->SpinBox_DX->setSingleStep(step);
2690 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2691 Group2Spin->SpinBox_DX->setSingleStep(step);
2692 Group2Spin->SpinBox_DY->setSingleStep(step);
2693 Group3Spin->SpinBox_DX->setSingleStep(step);
2694 Group3Spin->SpinBox_DY->setSingleStep(step);
2695 Group3Spin->SpinBox_DZ->setSingleStep(step);
2696 Group4Spin->SpinBox_DZ->setSingleStep(step);
2698 // san: Do NOT override the step when a speicifc step value is used
2699 // in some input fields!
2700 //Group4Spin->SpinBox_DX->setSingleStep(step);
2701 //Group4Spin->SpinBox_DY->setSingleStep(step);
2702 //Group4Spin->SpinBox_DS->setSingleStep(step);
2705 //=================================================================================
2706 // function : AddLocalCS()
2707 // purpose : Add All Coordinates systems in study
2708 //=================================================================================
2709 void EntityGUI_SketcherDlg::AddLocalCS(GEOM::GEOM_Object_var aSelectedObject)
2711 QString aName = GEOMBase::GetName( aSelectedObject );
2713 int index = ComboBox1->findText(aName, Qt::MatchExactly);
2715 if (index==-1) // If the working plane hasn't been added yet
2717 myWPlaneList.push_back(aSelectedObject);
2718 myWPlane = aSelectedObject;
2719 addSubshapesToStudy();
2720 myLCSList.push_back(WPlaneToLCS(aSelectedObject));
2721 ComboBox1->addItem(aName);
2722 index = ComboBox1->count();
2723 ComboBox1->setCurrentIndex(index-1);
2727 ComboBox1->setCurrentIndex(index);
2732 //=================================================================================
2733 // function : FindLocalCS()
2734 // purpose : Find All Coordinates systems in study
2735 //=================================================================================
2736 void EntityGUI_SketcherDlg::FindLocalCS()
2739 myWPlaneList.clear();
2740 SalomeApp_Application* app =
2741 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2745 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2749 _PTR(Study) aStudy = appStudy->studyDS();
2752 ComboBox1->addItem(tr("GEOM_GCS"));
2753 myWPlaneList.push_back(myGlobalCS);
2755 // get GEOM component
2756 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2757 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2760 _PTR(SComponent) fc = obj->GetFatherComponent();
2761 QString geomComp = fc->GetID().c_str();
2762 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2766 // browse through all GEOM data tree
2767 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2768 for ( it->InitEx( true ); it->More(); it->Next() )
2770 _PTR(SObject) child( it->Value() );
2771 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2772 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2773 if( CORBA::is_nil( geomObj ) )
2775 if (geomObj->GetType() == GEOM_MARKER)
2777 myWPlaneList.push_back(geomObj);
2778 myLCSList.push_back(WPlaneToLCS(geomObj));
2779 ComboBox1->addItem(geomObj->GetName());
2784 //=================================================================================
2785 // function : WPlaneToLCS ( aWPlane )
2787 //=================================================================================
2788 gp_Ax3 EntityGUI_SketcherDlg::WPlaneToLCS( GEOM::GEOM_Object_var geomObj )
2790 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2793 if (CORBA::is_nil( geomObj ) || aShape.IsNull())
2795 MESSAGE("CORBA::is_nil( geomObj ) || aShape.IsNull()")
2797 aLCS.Transform(aShape.Location().Transformation());
2798 if (aShape.ShapeType() == TopAbs_FACE)
2800 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
2801 myGeometryGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
2802 double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
2803 aMeasureOp->GetPosition( geomObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
2804 if ( aMeasureOp->IsDone() )
2806 gp_Pnt aPnt ( Ox, Oy, Oz );
2807 gp_Dir aDirN ( Zx, Zy, Zz );
2808 gp_Dir aDirX ( Xx, Xy, Xz );
2809 aLCS = gp_Ax3( aPnt, aDirN, aDirX );
2816 //=================================================================================
2817 // function : getPnt1ConstructorId()
2819 //=================================================================================
2820 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2822 int buttonId = GroupPt->ButtonGroup->checkedId();
2823 // MESSAGE("buttonId = "<<buttonId)
2827 //=================================================================================
2828 // function : getPnt2ConstructorId()
2830 //=================================================================================
2831 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2833 int buttonId = GroupPt2->ButtonGroup->checkedId();
2834 // MESSAGE("buttonId = "<<buttonId)
2838 //=================================================================================
2839 // function : GetActiveLocalCS()
2840 // purpose : Get Working plane
2841 //=================================================================================
2842 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2844 int ind = ComboBox1->currentIndex();
2846 return myGeometryGUI->GetWorkingPlane();
2848 gp_Ax3 aLCS = myLCSList.at(ind);
2849 myWPlane = myWPlaneList.at(ind);
2854 //=================================================================================
2855 // function : ActivateLocalCS()
2856 // purpose : Activate & Fit Working plane
2857 //=================================================================================
2858 void EntityGUI_SketcherDlg::ActivateLocalCS()
2860 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2861 myGeometryGUI->ActiveWorkingPlane();
2864 //=================================================================================
2865 // function : addSubshapeToStudy
2866 // purpose : virtual method to add new SubObjects if local selection
2867 //=================================================================================
2868 void EntityGUI_SketcherDlg::addSubshapesToStudy()
2870 GEOMBase::PublishSubObject(myWPlane);