1 // Copyright (C) 2007-2010 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>
32 #include <GeometryGUI.h>
33 #include <GEOMImpl_Types.hxx>
34 #include <Geom_Surface.hxx>
35 #include <Geom_Plane.hxx>
37 #include <SUIT_Desktop.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Application.h>
42 #include <LightApp_Application.h>
43 #include <LightApp_SelectionMgr.h>
47 #include <BRep_Tool.hxx>
49 #include <TopExp_Explorer.hxx>
50 #include <TopoDS_Vertex.hxx>
52 #include <BRepBuilderAPI_Transform.hxx>
53 #include <BRepBuilderAPI_MakeWire.hxx>
54 #include <Sketcher_Profile.hxx>
56 #include <SalomeApp_Study.h>
60 #include <Basics_Utils.hxx>
62 //=================================================================================
63 // class : EntityGUI_SketcherDlg()
64 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
65 // name 'name' and widget flags set to 'f'.
66 // The dialog will by default be modeless, unless you set 'modal' to
67 // TRUE to construct a modal dialog.
68 //=================================================================================
69 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
70 bool modal, Qt::WindowFlags fl,
71 const double lineWidth )
72 : QDialog( parent, fl ),
73 myIsAllAdded( false ),
75 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
77 myLineWidth( lineWidth )
80 setAttribute( Qt::WA_DeleteOnClose );
82 myGeometryGUI->SetActiveDialogBox(this);
84 MainWidget = new EntityGUI_Skeleton( this );
85 QVBoxLayout* topLayout = new QVBoxLayout( this );
86 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
88 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
89 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
90 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
91 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
93 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
94 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
95 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
97 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
99 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
100 MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) );
101 MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) );
102 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
103 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
104 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
105 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
107 /***************************************************************/
109 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
110 QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
111 planeLayout->setSpacing(6);
112 planeLayout->setMargin(11);
114 ComboBox1 = new QComboBox(GroupBox1);
115 ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
116 planeLayout->addWidget(ComboBox1);
118 planeButton = new QPushButton (GroupBox1);
119 planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
120 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
121 planeLayout->addWidget(planeButton);
123 topLayout->addWidget(GroupBox1);
124 topLayout->addWidget( MainWidget );
126 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
128 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
129 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
130 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
131 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
133 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
135 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
136 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
137 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
138 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
140 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
142 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
143 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
144 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
145 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
146 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
148 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
150 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
151 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
152 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
153 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
155 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
156 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
157 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
158 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
159 Group1Sel->PushButton1->setIcon( image0 );
160 Group1Sel->buttonUndo->setIcon( image1 );
161 Group1Sel->buttonRedo->setIcon( image2 );
162 Group1Sel->LineEdit1->setReadOnly( true );
164 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
165 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
166 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
167 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
168 Group2Sel->PushButton1->setIcon( image0 );
169 Group2Sel->PushButton2->setIcon( image0 );
170 Group2Sel->buttonUndo->setIcon( image1 );
171 Group2Sel->buttonRedo->setIcon( image2 );
172 Group2Sel->LineEdit1->setReadOnly( true );
173 Group2Sel->LineEdit2->setReadOnly( true );
175 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
176 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
177 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
178 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
179 Group1Sel1Spin->PushButton1->setIcon( image0 );
180 Group1Sel1Spin->buttonUndo->setIcon( image1 );
181 Group1Sel1Spin->buttonRedo->setIcon( image2 );
182 Group1Sel1Spin->LineEdit1->setReadOnly( true );
184 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
185 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
186 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
187 Group1Spin->buttonUndo->setIcon( image1 );
188 Group1Spin->buttonRedo->setIcon( image2 );
190 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
191 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
192 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
193 Group2Spin->buttonUndo->setIcon( image1 );
194 Group2Spin->buttonRedo->setIcon( image2 );
196 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
197 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
198 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
199 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
200 Group3Spin->buttonUndo->setIcon( image1 );
201 Group3Spin->buttonRedo->setIcon( image2 );
203 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
204 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
205 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
206 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
207 Group4Spin->buttonUndo->setIcon( image1 );
208 Group4Spin->buttonRedo->setIcon( image2 );
210 // Defines a palette for the error message on Group4Spin and Group2Sel
213 palette.setColor(Group4Spin->label->foregroundRole(), color);
214 Group4Spin->label->setPalette(palette);
215 palette.setColor(Group2Sel->label->foregroundRole(), color);
216 Group2Sel->label->setPalette(palette);
218 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
219 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
220 DestCntLayout->addWidget( GroupPt, 0, 0 );
221 DestCntLayout->addWidget( GroupPt2, 0, 1 );
222 DestCntLayout->addWidget( GroupD1, 0, 0 );
223 DestCntLayout->addWidget( GroupD2, 0, 1 );
225 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
226 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
227 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
228 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
229 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
230 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
231 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
232 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
233 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
234 /***************************************************************/
236 QButtonGroup* ButtonGroup = new QButtonGroup( this );
237 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
238 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
240 /* signals and slots connections */
241 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
242 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
243 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
244 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
246 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
247 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
248 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
249 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
250 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
251 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
252 connect( Group1Sel1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
253 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
254 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
255 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
256 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
257 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
258 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
259 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
260 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
261 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
262 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
263 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
264 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
265 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
266 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
268 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
269 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
270 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
271 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
272 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
273 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
275 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
276 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
278 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
279 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
280 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
281 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
283 connect( Group1Sel1Spin->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
284 connect( Group1Sel1Spin->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
285 connect( Group1Sel1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
287 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
288 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
289 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
290 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
291 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
292 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
293 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
294 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
295 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
296 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
298 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
299 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
300 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
301 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
303 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
304 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
306 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
308 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
309 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
311 // install event filter on spin-boxes to provide Apply action on Return pressed
312 Group1Spin->SpinBox_DX->installEventFilter(this);
313 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
314 Group2Spin->SpinBox_DX->installEventFilter(this);
315 Group2Spin->SpinBox_DY->installEventFilter(this);
316 Group3Spin->SpinBox_DX->installEventFilter(this);
317 Group3Spin->SpinBox_DY->installEventFilter(this);
318 Group3Spin->SpinBox_DZ->installEventFilter(this);
319 Group4Spin->SpinBox_DX->installEventFilter(this);
320 Group4Spin->SpinBox_DY->installEventFilter(this);
321 Group4Spin->SpinBox_DZ->installEventFilter(this);
322 Group4Spin->SpinBox_DS->installEventFilter(this);
328 //=================================================================================
329 // function : ~EntityGUI_SketcherDlg()
330 // purpose : Destroys the object and frees any allocated resources
331 //=================================================================================
332 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
334 myGeometryGUI->SetActiveDialogBox( 0 );
338 //=================================================================================
339 // function : eventFilter()
340 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
341 //=================================================================================
342 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
344 if (event->type() == QEvent::KeyPress) {
345 QKeyEvent* ke = (QKeyEvent*)event;
346 if (ke->key() == Qt::Key_Return) {
347 if (object == Group1Spin->SpinBox_DX) {
348 Group1Spin->buttonApply->animateClick();
350 } else if (object == Group1Sel1Spin->SpinBox_DX) {
351 Group1Sel1Spin->buttonApply->animateClick();
353 } else if (object == Group2Spin->SpinBox_DX ||
354 object == Group2Spin->SpinBox_DY) {
355 Group2Spin->buttonApply->animateClick();
357 } else if (object == Group3Spin->SpinBox_DX ||
358 object == Group3Spin->SpinBox_DY ||
359 object == Group3Spin->SpinBox_DZ) {
360 Group3Spin->buttonApply->animateClick();
362 } else if (object == Group4Spin->SpinBox_DX ||
363 object == Group4Spin->SpinBox_DY ||
364 object == Group4Spin->SpinBox_DZ ||
365 object == Group4Spin->SpinBox_DS) {
366 Group4Spin->buttonApply->animateClick();
372 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
374 return QDialog::eventFilter(object, event);
378 //=================================================================================
381 //=================================================================================
382 void EntityGUI_SketcherDlg::Init()
385 myEditCurrentArgument = Group1Sel->LineEdit1;
386 myCommand.append( "Sketcher" );
387 myUndoCommand.append( "Sketcher" );
389 mySketchState = FIRST_POINT;
390 globalSelection( GEOM_POINT );
399 myHelpFileName = "create_sketcher_page.html";
401 /* Get setting of step value from file configuration */
402 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
404 /* min, max, step and decimals for spin boxes */
405 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
406 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
407 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
408 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
409 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
410 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
411 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
412 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
413 // san: Note specific step values below!
414 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
415 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
416 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
418 /* displays Dialog */
419 MainWidget->GroupConstructors->setEnabled( false );
420 MainWidget->GroupDest1->setEnabled( false );
421 setEnabledUndo( false );
422 setEnabledRedo( false );
424 MainWidget->RadioButton1->setChecked( true );
432 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
436 //=================================================================================
437 // function : InitClick()
439 //=================================================================================
440 void EntityGUI_SketcherDlg::InitClick()
442 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
447 Group1Sel1Spin->hide();
455 //=================================================================================
456 // function : TypeClicked()
457 // purpose : Radio button management
458 //=================================================================================
459 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
461 myConstructorId = constructorId;
462 if ( myConstructorId == 0 ) { // SEGMENT
463 GroupPt2->setEnabled( false );
464 GroupD2->setEnabled( true );
465 MainWidget->RB_Dest1->setEnabled( true );
466 MainWidget->RB_Dest1->setChecked( true );
469 else if ( myConstructorId == 1 ) { // ARC
470 GroupPt2->setEnabled( true );
471 GroupD2->setEnabled( false );
472 MainWidget->RB_Dest1->setEnabled( true );
473 MainWidget->RB_Dest1->setChecked( true );
479 //=================================================================================
480 // function : DestClicked()
481 // purpose : Radio button management
482 //=================================================================================
483 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
490 if ( constructorId == 1 ) {
492 GroupPt->RB_Point1->setChecked( true );
495 Group3Spin->checkBox->show();
496 Group4Spin->checkBox->show();
497 PointClicked( 1 ); // XY
499 else if ( constructorId == 0 ) {
501 GroupD1->RB_Dir11->setChecked( true );
504 Group3Spin->checkBox->hide();
505 Group4Spin->checkBox->hide();
506 Dir1Clicked( 2 ); // Angle
510 //=================================================================================
511 // function : PointClicked()
512 // purpose : Radio button management
513 //=================================================================================
514 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
516 myConstructorPntId = constructorId;
517 GroupPt2->RB_Point1->setChecked( true );
518 GroupPt->RB_Point3->setEnabled( true );
522 //=================================================================================
523 // function : Point2Clicked()
524 // purpose : Radio button management
525 //=================================================================================
526 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
530 // Get setting of step value from file configuration
531 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
533 if ( myConstructorPntId == 1 ) { // XY
534 if ( constructorId == 1 ){ // No additional parameter
535 mySketchType = PT_ABS;
536 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
537 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
538 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
539 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
541 Group2Spin->SpinBox_DX->setValue( myX );
543 Group2Spin->SpinBox_DY->setValue( myY );
545 Group2Spin->buttonApply->setFocus();
547 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
549 else if ( constructorId == 0 ){ // Point + radius
550 mySketchType = PT_ABS_RADIUS;
551 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
552 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
553 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
554 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
555 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
556 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
558 Group3Spin->SpinBox_DX->setValue( myDX );
560 Group3Spin->SpinBox_DY->setValue( myDY );
562 Group3Spin->SpinBox_DZ->setValue( myRadius );
564 Group3Spin->buttonApply->setFocus();
566 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
568 else if ( constructorId == 2 ){ // Point + center
569 mySketchType = PT_ABS_CENTER;
570 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
571 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
572 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
573 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
574 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
575 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
576 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
577 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
579 Group4Spin->SpinBox_DX->setValue( myDX );
581 Group4Spin->SpinBox_DY->setValue( myDY );
583 Group4Spin->SpinBox_DZ->setValue( myXc );
585 Group4Spin->SpinBox_DS->setValue( myYc );
587 Group4Spin->buttonApply->setFocus();
589 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
593 else if ( myConstructorPntId == 0 ) { // DXDY
594 if ( constructorId == 1 ){ // No additional parameter
595 mySketchType = PT_RELATIVE;
596 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
597 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
598 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
599 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
601 Group2Spin->SpinBox_DX->setValue( myDX );
603 Group2Spin->SpinBox_DY->setValue( myDY );
605 Group2Spin->buttonApply->setFocus();
607 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
609 else if ( constructorId == 0 ){ // Point + radius
610 mySketchType = PT_REL_RADIUS;
611 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
612 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
613 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
614 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
615 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
616 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
618 Group3Spin->SpinBox_DX->setValue( myDX );
620 Group3Spin->SpinBox_DY->setValue( myDY );
622 Group3Spin->SpinBox_DZ->setValue( myRadius );
624 Group3Spin->buttonApply->setFocus();
626 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
628 else if ( constructorId == 2 ){ // Point + center
629 mySketchType = PT_REL_CENTER;
630 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
631 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
632 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
633 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
634 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
635 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
636 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
637 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
639 Group4Spin->SpinBox_DX->setValue( myDX );
641 Group4Spin->SpinBox_DY->setValue( myDY );
643 Group4Spin->SpinBox_DZ->setValue( myDXc );
645 Group4Spin->SpinBox_DS->setValue( myDYc );
647 Group4Spin->buttonApply->setFocus();
649 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
653 else if ( myConstructorPntId == 2 ) { // Selection
654 if ( constructorId == 1 ){ // No additional parameter
655 mySketchType = PT_SEL;
656 myEditCurrentArgument = Group1Sel->LineEdit1;
657 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
659 Group1Sel->buttonApply->setFocus();
660 SelectionIntoArgument();
662 else if ( constructorId == 0 ){ // Point + radius
663 mySketchType = PT_SEL_RADIUS;
664 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
665 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
666 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
667 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
669 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
671 Group1Sel1Spin->show();
672 Group1Sel1Spin->buttonApply->setFocus();
673 SelectionIntoArgument();
675 else if ( constructorId == 2 ){ // Point + center
676 mySketchType = PT_SEL_CENTER;
677 myEditCurrentArgument = Group2Sel->LineEdit1;
678 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
679 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
680 Group2Sel->LineEdit1->setEnabled(true);
681 Group2Sel->PushButton1->setDown(true);
682 Group2Sel->LineEdit2->setEnabled(false);
683 Group2Sel->PushButton2->setDown(false);
685 Group2Sel->buttonApply->setFocus();
686 SelectionIntoArgument();
690 connect( myGeometryGUI->getApp()->selectionMgr(),
691 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
696 //=================================================================================
697 // function : Dir1Clicked()
698 // purpose : Radio button management
699 //=================================================================================
700 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
702 myConstructorDirId = constructorId;
703 GroupD2->RB_Dir21->setChecked( true );
708 //=================================================================================
709 // function : Dir2Clicked()
710 // purpose : Radio button management
711 //=================================================================================
712 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
717 // Get setting of step value from file configuration
718 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
720 if ( myConstructorId == 0 ) { // SEGMENT
724 if ( myConstructorDirId == 2 ) { // Angle
725 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
726 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
727 Group2Spin->SpinBox_DX->setValue( myAngle );
728 Group2Spin->buttonApply->setFocus();
731 if ( constructorId == 2 ) { // Length
732 mySketchType = DIR_ANGLE_LENGTH;
733 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
734 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
735 Group2Spin->SpinBox_DY->setValue( myLength );
737 else if ( constructorId == 0 ) { // X
738 mySketchType = DIR_ANGLE_X;
739 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
740 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
741 Group2Spin->SpinBox_DY->setValue( myX );
743 else if ( constructorId == 1 ) { // Y
744 mySketchType = DIR_ANGLE_Y;
745 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
746 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
747 Group2Spin->SpinBox_DY->setValue( myY );
750 else if ( myConstructorDirId == 0 ) { // Perpendicular
752 Group1Spin->buttonApply->setFocus();
754 if ( constructorId == 2 ) { // Length
755 mySketchType = DIR_PER_LENGTH;
756 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
757 Group1Spin->SpinBox_DX->setValue( myLength );
759 else if ( constructorId == 0 ) { // X
760 mySketchType = DIR_PER_X;
761 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
762 Group1Spin->SpinBox_DX->setValue( myX );
764 else if ( constructorId == 1 ) { // Y
765 mySketchType = DIR_PER_Y;
766 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
767 Group1Spin->SpinBox_DX->setValue( myY );
770 else if ( myConstructorDirId == 1 ) { // Tangent
772 Group1Spin->buttonApply->setFocus();
774 if ( constructorId == 2 ) { // Length
775 mySketchType = DIR_TAN_LENGTH;
776 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
777 Group1Spin->SpinBox_DX->setValue( myLength );
779 else if ( constructorId == 0 ) { // X
780 mySketchType = DIR_TAN_X;
781 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
782 Group1Spin->SpinBox_DX->setValue( myX );
784 else if ( constructorId == 1 ) { // Y
785 mySketchType = DIR_TAN_Y;
786 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
787 Group1Spin->SpinBox_DX->setValue( myY );
790 else if ( myConstructorDirId == 3 ) { // DXDY
791 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
792 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
793 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
794 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
795 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
797 Group3Spin->SpinBox_DX->setValue( myDX );
799 Group3Spin->SpinBox_DY->setValue( myDY );
801 Group3Spin->buttonApply->setFocus();
803 if ( constructorId == 2 ) { // Length
804 mySketchType = DIR_DXDY_LENGTH;
805 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
806 Group3Spin->SpinBox_DZ->setValue( myLength );
808 else if ( constructorId == 0 ) { // X
809 mySketchType = DIR_DXDY_X;
810 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
811 Group3Spin->SpinBox_DZ->setValue( myX );
813 else if ( constructorId == 1 ) { // Y
814 mySketchType = DIR_DXDY_Y;
815 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
816 Group3Spin->SpinBox_DZ->setValue( myY );
820 else if ( myConstructorId == 1 ) { // ARC
821 if ( myConstructorDirId == 2 ) { // Angle
822 if ( constructorId == 2 ) { // Length
823 mySketchType = DIR_ANGLE_LENGTH;
824 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
825 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
826 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
827 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
828 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
829 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
830 Group3Spin->SpinBox_DX->setValue( myAngle );
832 Group3Spin->SpinBox_DY->setValue( myRadius );
834 Group3Spin->SpinBox_DZ->setValue( myLength );
836 Group3Spin->buttonApply->setFocus();
839 else if ( myConstructorDirId == 0 ) { // Perpendicular
840 if ( constructorId == 2 ) { // Length
841 mySketchType = DIR_PER_LENGTH;
842 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
843 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
844 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
845 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
847 Group2Spin->SpinBox_DX->setValue( myRadius );
849 Group2Spin->SpinBox_DY->setValue( myLength );
851 Group2Spin->buttonApply->setFocus();
854 else if ( myConstructorDirId == 1 ) { // Tangent
855 if ( constructorId == 2 ) { // Length
856 mySketchType = DIR_TAN_LENGTH;
857 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
858 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
859 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
860 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
862 Group2Spin->SpinBox_DX->setValue( myRadius );
864 Group2Spin->SpinBox_DY->setValue( myLength );
866 Group2Spin->buttonApply->setFocus();
869 else if ( myConstructorDirId == 3 ) { // DXDY
870 if ( constructorId == 2 ) { // Length
871 mySketchType = DIR_DXDY_LENGTH;
872 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
873 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
874 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
875 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
876 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
877 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
878 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
879 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
881 Group4Spin->SpinBox_DX->setValue( myDX );
883 Group4Spin->SpinBox_DY->setValue( myDY );
885 Group4Spin->SpinBox_DZ->setValue( myRadius );
887 Group4Spin->SpinBox_DS->setValue( myLength );
889 Group4Spin->buttonApply->setFocus();
894 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
897 //=================================================================================
898 // function : CheckBoxClicked()
899 // purpose : CheckBox management
900 //=================================================================================
901 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
905 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
909 //=================================================================================
910 // function : ClickOnCancel()
912 //=================================================================================
913 void EntityGUI_SketcherDlg::ClickOnCancel()
919 //=================================================================================
920 // function : ClickOnEnd()
921 // purpose : connected to buttonEnd AND buttonClose
922 //=================================================================================
923 void EntityGUI_SketcherDlg::ClickOnEnd()
925 if ( sender() == MainWidget->buttonClose ) {
926 // Verify validity of commands
927 if ( myCommand.count() <= 2 ) {
928 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
929 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
934 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
935 Sketcher_Profile aProfile( Command.toAscii() );
937 Command = myCommand.join( "" );
938 aProfile = Sketcher_Profile( Command.toAscii() );
939 TopoDS_Shape myShape;
940 if ( aProfile.IsDone() )
941 myShape = aProfile.GetShape();
943 if ( myShape.ShapeType() != TopAbs_VERTEX )
944 myCommand.append( ":WW" );
947 // PAL16008 (Sketcher Validation should be equal to Apply&Close)
948 if ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ||
949 Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ||
950 Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ||
951 Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ||
952 Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ||
953 Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ||
954 Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) {
960 if ( myCommand.size() > 2 )
967 //=================================================================================
968 // function : ClickOnApply()
970 //=================================================================================
971 bool EntityGUI_SketcherDlg::ClickOnApply()
973 if ( sender() && sender()->inherits( "QPushButton" ) )
974 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
977 myCommand.append( GetNewCommand( aParameters ) );
978 mySketchState = NEXT_POINT;
980 myUndoCommand.clear();
981 myUndoCommand.append( "Sketcher" );
983 myParameters.append( aParameters );
984 myUndoParameters.clear();
986 MainWidget->GroupConstructors->setEnabled( true );
987 MainWidget->GroupDest1->setEnabled( true );
988 setEnabledUndo( true );
989 setEnabledRedo( false );
992 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
995 // Set focus to SpinBox_DX
996 if ( sender() == Group1Spin->buttonApply ) {
997 (Group1Spin->SpinBox_DX)->setFocus();
998 (Group1Spin->SpinBox_DX)->selectAll();
1000 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1001 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1002 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1004 else if ( sender() == Group2Spin->buttonApply ) {
1005 (Group2Spin->SpinBox_DX)->setFocus();
1006 (Group2Spin->SpinBox_DX)->selectAll();
1008 else if ( sender() == Group3Spin->buttonApply ) {
1009 (Group3Spin->SpinBox_DX)->setFocus();
1010 (Group3Spin->SpinBox_DX)->selectAll();
1012 else if ( sender() == Group4Spin->buttonApply ) {
1013 (Group4Spin->SpinBox_DX)->setFocus();
1014 (Group4Spin->SpinBox_DX)->selectAll();
1020 //=================================================================================
1021 // function : ClickOnHelp()
1023 //=================================================================================
1024 void EntityGUI_SketcherDlg::ClickOnHelp()
1026 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1028 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1032 platform = "winapplication";
1034 platform = "application";
1037 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1038 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1039 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1040 QObject::tr( "BUT_OK" ) );
1044 //=================================================================================
1045 // function : ClickOnUndo()
1047 //=================================================================================
1048 void EntityGUI_SketcherDlg::ClickOnUndo()
1050 myUndoCommand.append( myCommand.last() );
1051 myCommand.pop_back();
1053 myUndoParameters.append( myParameters.last() );
1054 myParameters.pop_back();
1056 if ( myCommand.count() == 1 ) {
1057 mySketchState = FIRST_POINT;
1059 MainWidget->RadioButton1->setChecked( true );
1062 connect( myGeometryGUI->getApp()->selectionMgr(),
1063 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1065 MainWidget->GroupConstructors->setEnabled( false );
1066 MainWidget->GroupDest1->setEnabled( false );
1067 setEnabledUndo( false );
1070 setEnabledRedo( true );
1072 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1075 //=================================================================================
1076 // function : ClickOnRedo()
1078 //=================================================================================
1079 void EntityGUI_SketcherDlg::ClickOnRedo()
1081 myCommand.append( myUndoCommand.last() );
1082 myUndoCommand.pop_back();
1084 myParameters.append( myUndoParameters.last() );
1085 myUndoParameters.pop_back();
1087 mySketchState = NEXT_POINT;
1089 MainWidget->GroupConstructors->setEnabled( true );
1090 MainWidget->GroupDest1->setEnabled( true );
1091 setEnabledUndo( true );
1093 if ( myUndoCommand.count() == 1 )
1094 setEnabledRedo( false );
1096 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1099 //=================================================================================
1100 // function : setEnabledUndo()
1102 //=================================================================================
1103 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1105 Group1Sel->buttonUndo->setEnabled( value );
1106 Group2Sel->buttonUndo->setEnabled( value );
1107 Group1Sel1Spin->buttonUndo->setEnabled( value );
1108 Group1Spin->buttonUndo->setEnabled( value );
1109 Group2Spin->buttonUndo->setEnabled( value );
1110 Group3Spin->buttonUndo->setEnabled( value );
1111 Group4Spin->buttonUndo->setEnabled( value );
1114 //=================================================================================
1115 // function : setEnabledRedo()
1117 //=================================================================================
1118 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1120 Group1Sel->buttonRedo->setEnabled( value );
1121 Group2Sel->buttonRedo->setEnabled( value );
1122 Group1Sel1Spin->buttonRedo->setEnabled( value );
1123 Group1Spin->buttonRedo->setEnabled( value );
1124 Group2Spin->buttonRedo->setEnabled( value );
1125 Group3Spin->buttonRedo->setEnabled( value );
1126 Group4Spin->buttonRedo->setEnabled( value );
1129 //=================================================================================
1130 // function : SelectionIntoArgument()
1131 // purpose : Called when selection as changed
1132 //=================================================================================
1133 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1135 myEditCurrentArgument->setText( "" );
1140 // printf ("\nmyX = %f myY = %f", myX, myY);
1141 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
1142 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
1144 if ( sender() == ComboBox1 )
1147 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1148 SALOME_ListIO aSelList;
1149 aSelMgr->selectedObjects(aSelList);
1151 int nbSel = aSelList.Extent();
1152 if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1153 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1154 if ( !CORBA::is_nil(aSelectedObject) ) {
1155 TopoDS_Shape aShape;
1156 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1158 gp_Ax3 aWPlane = GetActiveLocalCS();
1160 aTrans.SetTransformation(aWPlane);
1161 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1162 aShape = aTransformation.Shape();
1165 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1168 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1169 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1170 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1171 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1172 Group2Spin->SpinBox_DX->setValue(myX);
1173 Group2Spin->SpinBox_DY->setValue(myY);
1174 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1175 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1176 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1177 if ( myLastX1 && myLastY1 ) {
1178 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1179 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1181 if ( mySketchState != FIRST_POINT ) {
1182 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1183 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1185 Group2Spin->SpinBox_DX->setValue(myX);
1186 Group2Spin->SpinBox_DY->setValue(myY);
1195 if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1196 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1197 if ( !CORBA::is_nil(aSelectedObject) ) {
1198 TopoDS_Shape aShape;
1199 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1201 gp_Ax3 aWPlane = GetActiveLocalCS();
1203 aTrans.SetTransformation(aWPlane);
1204 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1205 aShape = aTransformation.Shape();
1208 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1211 Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1212 if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1213 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1214 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1215 Group3Spin->SpinBox_DX->setValue(myX);
1216 Group3Spin->SpinBox_DY->setValue(myY);
1217 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1218 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1219 } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1220 if ( myLastX1 && myLastY1 ) {
1221 Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1222 Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1224 if ( mySketchState != FIRST_POINT ) {
1225 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1226 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1228 Group3Spin->SpinBox_DX->setValue(myX);
1229 Group3Spin->SpinBox_DY->setValue(myY);
1238 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1239 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1240 if ( !CORBA::is_nil(aSelectedObject) ) {
1241 TopoDS_Shape aShape;
1242 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1244 gp_Ax3 aWPlane = GetActiveLocalCS();
1246 aTrans.SetTransformation(aWPlane);
1247 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1248 aShape = aTransformation.Shape();
1251 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1254 Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1255 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1256 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1257 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1258 Group4Spin->SpinBox_DX->setValue(myX);
1259 Group4Spin->SpinBox_DY->setValue(myY);
1260 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1261 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1262 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1263 if ( myLastX1 && myLastY1 ) {
1264 Group4Spin->SpinBox_DX->setValue(myX - myLastX1);
1265 Group4Spin->SpinBox_DY->setValue(myY - myLastY1);
1267 if ( mySketchState != FIRST_POINT ) {
1268 Group4Spin->SpinBox_DX->setValue(myX - tmpX);
1269 Group4Spin->SpinBox_DY->setValue(myY - tmpY);
1271 Group4Spin->SpinBox_DX->setValue(myX);
1272 Group4Spin->SpinBox_DY->setValue(myY);
1281 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1282 if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
1283 myX=tmpX; // If yes keep the old values of X and Y
1286 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1287 if ( !CORBA::is_nil(aSelectedObject) ) {
1288 TopoDS_Shape aShape;
1289 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1291 gp_Ax3 aWPlane = GetActiveLocalCS();
1293 aTrans.SetTransformation(aWPlane);
1294 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1295 aShape = aTransformation.Shape();
1298 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1301 Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1302 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1303 disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1304 disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1305 Group4Spin->SpinBox_DZ->setValue(myXc);
1306 Group4Spin->SpinBox_DS->setValue(myYc);
1307 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1308 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1309 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1310 if ( myLastX1 && myLastY1 ) {
1311 Group4Spin->SpinBox_DZ->setValue(myXc - myLastX1);
1312 Group4Spin->SpinBox_DS->setValue(myYc - myLastY1);
1314 if ( mySketchState != FIRST_POINT ) {
1315 Group4Spin->SpinBox_DZ->setValue(myXc - tmpX);
1316 Group4Spin->SpinBox_DS->setValue(myYc - tmpY);
1318 Group4Spin->SpinBox_DZ->setValue(myXc);
1319 Group4Spin->SpinBox_DS->setValue(myYc);
1330 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1334 //=================================================================================
1335 // function : SetEditCurrentArgument()
1337 //=================================================================================
1338 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1340 if ( sender() == Group1Sel->PushButton1 ) {
1341 myEditCurrentArgument = Group1Sel->LineEdit1;
1342 myEditCurrentArgument->setFocus();
1344 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1345 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1346 myEditCurrentArgument->setFocus();
1348 else if ( sender() == Group2Sel->PushButton1 ) {
1349 myEditCurrentArgument = Group2Sel->LineEdit1;
1350 Group2Sel->PushButton2->setDown(false);
1351 Group2Sel->PushButton1->setDown(true);
1352 Group2Sel->LineEdit2->setEnabled(false);
1353 Group2Sel->LineEdit1->setEnabled(true);
1354 // myEditCurrentArgument->setFocus();
1356 else if ( sender() == Group2Sel->PushButton2 ) {
1357 myEditCurrentArgument = Group2Sel->LineEdit2;
1358 Group2Sel->PushButton1->setDown(false);
1359 Group2Sel->PushButton2->setDown(true);
1360 Group2Sel->LineEdit1->setEnabled(false);
1361 Group2Sel->LineEdit2->setEnabled(true);
1362 // myEditCurrentArgument->setFocus();
1364 SelectionIntoArgument();
1368 //=================================================================================
1369 // function : LineEditReturnPressed()
1371 //=================================================================================
1372 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1374 if ( sender() == Group1Sel->LineEdit1 )
1375 myEditCurrentArgument = Group1Sel->LineEdit1;
1376 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1377 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1378 else if ( sender() == Group2Sel->LineEdit1 )
1379 myEditCurrentArgument = Group2Sel->LineEdit1;
1380 else if ( sender() == Group2Sel->LineEdit2 )
1381 myEditCurrentArgument = Group2Sel->LineEdit2;
1383 /* User name of object input management */
1384 /* If successfull the selection is changed and signal emitted... */
1385 /* so SelectionIntoArgument() is automatically called. */
1386 const QString objectUserName = myEditCurrentArgument->text();
1387 QWidget* thisWidget = (QWidget*)this;
1389 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1390 SALOME_ListIO aSelList;
1391 aSelMgr->selectedObjects(aSelList);
1393 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1394 myEditCurrentArgument->setText( objectUserName );
1398 //=================================================================================
1399 // function : DeactivateActiveDialog()
1401 //=================================================================================
1402 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1404 //myGeometryGUI->SetState( -1 );
1406 setEnabled( false );
1408 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1409 myGeometryGUI->SetActiveDialogBox( 0 );
1413 //=================================================================================
1414 // function : ActivateThisDialog()
1416 //=================================================================================
1417 void EntityGUI_SketcherDlg::ActivateThisDialog()
1419 myGeometryGUI->EmitSignalDeactivateDialog();
1421 myGeometryGUI->SetActiveDialogBox( this );
1423 connect( myGeometryGUI->getApp()->selectionMgr(),
1424 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1426 //myGeometryGUI->SetState( 0 );
1427 globalSelection( GEOM_POINT );
1429 myEditCurrentArgument = Group1Sel->LineEdit1;
1430 myEditCurrentArgument->setFocus();
1432 if ( sender() == Group1Sel->LineEdit1 ) {
1433 myEditCurrentArgument = Group1Sel->LineEdit1;
1434 myEditCurrentArgument->setFocus();
1436 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1437 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1438 myEditCurrentArgument->setFocus();
1440 else if ( sender() == Group2Sel->LineEdit1 ) {
1441 myEditCurrentArgument = Group2Sel->LineEdit1;
1442 myEditCurrentArgument->setFocus();
1444 else if ( sender() == Group2Sel->LineEdit2 ) {
1445 myEditCurrentArgument = Group2Sel->LineEdit2;
1446 myEditCurrentArgument->setFocus();
1449 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1453 //=================================================================================
1454 // function : enterEvent [REDEFINED]
1456 //=================================================================================
1457 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1460 ActivateThisDialog();
1464 //=================================================================================
1465 // function : closeEvent()
1467 //=================================================================================
1468 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1470 //myGeometryGUI->SetState( -1 );
1471 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1472 myGeometryGUI->getApp()->updateActions();
1473 QDialog::closeEvent( e );
1477 //=================================================================================
1478 // function : ValueChangedInSpinBox()
1480 //=================================================================================
1481 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1483 QObject* send = (QObject*)sender();
1484 Standard_Real vx, vy, vz, vs, minRad;
1485 vx = vy = vz = vs = minRad =0.0;
1487 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1488 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1489 double LastDecimal = 0.0;
1491 QString vxStr, vyStr, vzStr, vsStr;
1493 QString newValueStr;
1494 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1495 newValueStr = aDoubleSpinBox->text();
1497 if ( send == Group1Spin->SpinBox_DX ) {
1498 vx = newValue; vxStr = newValueStr;
1500 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1501 vx = newValue; vxStr = newValueStr;
1503 else if ( send == Group2Spin->SpinBox_DX ) {
1504 vx = newValue; vxStr = newValueStr;
1505 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1507 else if ( send == Group2Spin->SpinBox_DY ) {
1508 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1509 vy = newValue; vyStr = newValueStr;
1511 else if ( send == Group3Spin->SpinBox_DX ) {
1512 vx = newValue; vxStr = newValueStr;
1513 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1514 vz = Group3Spin->SpinBox_DZ->value();
1515 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1516 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1517 if (aPrecision >= 0) // 'f' format in the QString
1518 LastDecimal = aPrecision;
1519 else // 'g' format in the Qstring
1520 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1521 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1522 if ( Abs(vz) < minRad){
1524 Group3Spin->SpinBox_DZ->setValue( - minRad );
1526 Group3Spin->SpinBox_DZ->setValue( minRad );
1529 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1531 else if ( send == Group3Spin->SpinBox_DY ) {
1532 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1533 vy = newValue; vyStr = newValueStr;
1534 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1535 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1536 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1537 if (aPrecision >= 0) // 'f' format in the QString
1538 LastDecimal = aPrecision;
1539 else // 'g' format in the QString
1540 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1541 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1542 if ( Abs(vz) < minRad){
1544 Group3Spin->SpinBox_DZ->setValue( - minRad );
1546 Group3Spin->SpinBox_DZ->setValue( minRad );
1549 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1551 else if ( send == Group3Spin->SpinBox_DZ ) {
1552 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1553 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1554 vz = newValue; vzStr = newValueStr;
1556 else if ( send == Group4Spin->SpinBox_DX ) {
1557 vx = newValue; vxStr = newValueStr;
1558 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1559 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1560 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1562 else if ( send == Group4Spin->SpinBox_DY ) {
1563 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1564 vy = newValue; vyStr = newValueStr;
1565 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1566 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1568 else if ( send == Group4Spin->SpinBox_DZ ) {
1569 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1570 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1571 vz = newValue; vzStr = newValueStr;
1572 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1574 else if ( send == Group4Spin->SpinBox_DS ) {
1575 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1576 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1577 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1578 vs = newValue; vsStr = newValueStr;
1580 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1582 if ( myConstructorId == 0 ) { // SEGMENT
1583 if ( mySketchType == PT_ABS ) {
1589 else if ( mySketchType == PT_RELATIVE ) {
1595 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1599 myLengthStr = vyStr;
1601 else if ( mySketchType == DIR_ANGLE_X ) {
1607 else if ( mySketchType == DIR_ANGLE_Y ) {
1613 else if ( mySketchType == DIR_PER_LENGTH ) {
1615 myLengthStr = vxStr;
1617 else if ( mySketchType == DIR_PER_X ) {
1621 else if ( mySketchType == DIR_PER_Y ) {
1625 else if ( mySketchType == DIR_TAN_LENGTH ) {
1627 myLengthStr = vxStr;
1629 else if ( mySketchType == DIR_TAN_X ) {
1633 else if ( mySketchType == DIR_TAN_Y ) {
1637 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1643 myLengthStr = vzStr;
1645 else if ( mySketchType == DIR_DXDY_X ) {
1653 else if ( mySketchType == DIR_DXDY_Y ) {
1662 else if ( myConstructorId == 1 ) { // ARC
1663 if ( mySketchType == PT_ABS ) {
1669 else if ( mySketchType == PT_RELATIVE ) {
1675 if ( mySketchType == PT_ABS_RADIUS ) {
1681 myRadiusStr = vzStr;
1683 else if ( mySketchType == PT_REL_RADIUS ) {
1689 myRadiusStr = vzStr;
1691 else if ( mySketchType == PT_SEL_RADIUS ) {
1693 myRadiusStr = vxStr;
1695 if ( mySketchType == PT_ABS_CENTER ) {
1705 else if ( mySketchType == PT_REL_CENTER ) {
1715 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1720 myRadiusStr = vyStr;
1721 myLengthStr = vzStr;
1723 else if ( mySketchType == DIR_PER_LENGTH ) {
1726 myRadiusStr = vxStr;
1727 myLengthStr = vyStr;
1729 else if ( mySketchType == DIR_TAN_LENGTH ) {
1732 myRadiusStr = vxStr;
1733 myLengthStr = vyStr;
1735 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1742 myRadiusStr = vzStr;
1743 myLengthStr = vsStr;
1747 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1751 //=================================================================================
1752 // function : GetNewCommand()
1753 // purpose : Build the new command with context
1754 //=================================================================================
1755 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1757 theParameters.clear();
1758 QString myNewCommand = ":";
1759 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1760 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1761 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1763 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1764 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1766 if ( mySketchState == FIRST_POINT ) {
1767 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1768 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1769 theParameters = myXStr + ":" + myYStr;
1771 if ( mySketchType == PT_RELATIVE) {
1772 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1773 theParameters = myDXStr + ":" + myDYStr;
1775 return myNewCommand;
1778 if ( myConstructorId == 0 ) { // SEGMENT
1779 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1780 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1781 theParameters = myXStr + ":" + myYStr;
1783 if ( mySketchType == PT_RELATIVE) {
1784 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1785 theParameters = myDXStr + ":" + myDYStr;
1787 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1788 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1789 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1790 theParameters = myAngleStr + ":" + myLengthStr;
1792 if ( mySketchType == DIR_ANGLE_X ) {
1793 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1794 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1795 theParameters = myAngleStr + ":" + myXStr;
1797 if ( mySketchType == DIR_ANGLE_Y ) {
1798 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1799 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1800 theParameters = myAngleStr + ":" + myYStr;
1802 if ( mySketchType == DIR_PER_LENGTH ) {
1803 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1804 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1805 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1807 if ( mySketchType == DIR_PER_X ) {
1808 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1809 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1810 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1812 if ( mySketchType == DIR_PER_Y ) {
1813 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1814 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1815 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1817 if ( mySketchType == DIR_TAN_LENGTH ) {
1818 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1819 theParameters = myLengthStr;
1821 if ( mySketchType == DIR_TAN_X ) {
1822 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1823 theParameters = myXStr;
1825 if ( mySketchType == DIR_TAN_Y) {
1826 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1827 theParameters = myYStr;
1829 if ( mySketchType == DIR_DXDY_LENGTH ) {
1830 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1831 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1832 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1834 if ( mySketchType == DIR_DXDY_X ) {
1835 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1836 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1837 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1839 if ( mySketchType == DIR_DXDY_Y ) {
1840 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1841 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1842 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1845 else if ( myConstructorId == 1 ) { // ARC
1846 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1847 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1848 theParameters = myXStr + ":" + myYStr;
1850 if ( mySketchType == PT_RELATIVE) {
1851 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1852 theParameters = myDXStr + ":" + myDYStr;
1854 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1855 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1856 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
1858 if ( mySketchType == PT_REL_RADIUS) {
1859 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1860 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
1862 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
1863 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 );
1864 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
1866 if ( mySketchType == PT_REL_CENTER) {
1867 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 );
1868 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
1870 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1871 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1872 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1873 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1875 if ( mySketchType == DIR_PER_LENGTH ) {
1876 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1877 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1878 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
1880 if ( mySketchType == DIR_TAN_LENGTH ) {
1881 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1882 theParameters = myRadiusStr + ":" + myLengthStr;
1884 if ( mySketchType == DIR_DXDY_LENGTH ) {
1885 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1886 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1887 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
1890 return myNewCommand;
1893 //=================================================================================
1894 // function : createOperation
1896 //=================================================================================
1897 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1899 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1902 //=================================================================================
1903 // function : isValid
1905 //=================================================================================
1906 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1909 bool toCorrect = !IsPreview() || myIsApply;
1911 if( Group1Spin->isVisible() ) {
1912 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1914 else if( Group1Sel1Spin->isVisible() ) {
1915 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1917 else if( Group2Spin->isVisible() ) {
1918 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1919 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1921 else if( Group3Spin->isVisible() ) {
1922 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1923 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1924 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1926 else if( Group4Spin->isVisible() ) {
1927 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1928 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1929 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1930 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
1933 if( myIsApply && !ok )
1939 //=================================================================================
1940 // function : execute
1942 //=================================================================================
1943 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1945 QString aParameters;
1947 if ( mySketchState == FIRST_POINT ) {
1952 //Test if the current point is the same as the last one
1953 TopoDS_Shape myShape1, myShape2;
1955 // Set "C" numeric locale
1956 Kernel_Utils::Localizer loc;
1959 QString Command1 = myCommand.join( "" );
1960 Sketcher_Profile aProfile1( Command1.toAscii() );
1961 if ( aProfile1.IsDone() )
1962 myShape1 = aProfile1.GetShape();
1965 QString Command2 = Command1 + GetNewCommand( aParameters );
1966 Sketcher_Profile aProfile2( Command2.toAscii() );
1969 if ( mySketchType == PT_ABS_CENTER ||
1970 mySketchType == PT_REL_CENTER ){
1971 Group4Spin->label->show();
1972 Group4Spin->label->setText(QString(aProfile2.ErrMsg().c_str()));
1975 Group4Spin->label->hide();
1976 if ( mySketchType == PT_SEL_CENTER ){
1977 Group2Sel->label->show();
1978 Group2Sel->label->setText(QString(aProfile2.ErrMsg().c_str()));
1981 Group2Sel->label->hide();
1983 if ( aProfile2.IsDone() )
1984 myShape2 = aProfile2.GetShape();
1986 if ( myShape2.IsNull() ) {
1987 //the current point is the same as the last one
1988 myLastX2 = myLastX1;
1989 myLastY2 = myLastY1;
1992 TopoDS_Vertex V1, V2;
1994 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
1995 //the last shape is the first point
1996 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2001 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2002 pt = BRep_Tool::Pnt( V2 );
2006 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2007 pt = BRep_Tool::Pnt( V2 );
2014 if ( ( mySketchState != FIRST_POINT &&
2015 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2016 cmd = myCommand.join( "" );
2017 if ( Group1Sel->isVisible() ) {
2018 Group1Sel->buttonApply->setEnabled( false );
2019 //Group1Sel->buttonApply->setFocus();
2021 if ( Group2Sel->isVisible() ) {
2022 Group2Sel->buttonApply->setEnabled( false );
2023 //Group2Sel->buttonApply->setFocus();
2025 if ( Group1Sel1Spin->isVisible() ) {
2026 Group1Sel1Spin->buttonApply->setEnabled( false );
2027 //Group1Sel1Spin->buttonApply->setFocus();
2029 if ( Group1Spin->isVisible() ) {
2030 Group1Spin->buttonApply->setEnabled( false );
2031 //Group1Spin->buttonApply->setFocus();
2033 if ( Group2Spin->isVisible() ) {
2034 Group2Spin->buttonApply->setEnabled( false );
2035 //Group2Spin->buttonApply->setFocus();
2037 if ( Group3Spin->isVisible() ) {
2038 Group3Spin->buttonApply->setEnabled( false );
2039 //Group3Spin->buttonApply->setFocus();
2041 if ( Group4Spin->isVisible() ) {
2042 Group4Spin->buttonApply->setEnabled( false );
2043 //Group4Spin->buttonApply->setFocus();
2047 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2049 if ( Group1Sel->isVisible() ) {
2050 Group1Sel->buttonApply->setEnabled( true );
2051 //Group1Sel->buttonApply->setFocus();
2053 if ( Group2Sel->isVisible() ) {
2054 Group2Sel->buttonApply->setEnabled( true );
2055 //Group2Sel->buttonApply->setFocus();
2057 if ( Group1Sel1Spin->isVisible() ) {
2058 Group1Sel1Spin->buttonApply->setEnabled( true );
2059 //Group1Sel1Spin->buttonApply->setFocus();
2061 if ( Group1Spin->isVisible() ) {
2062 Group1Spin->buttonApply->setEnabled( true );
2063 //Group1Spin->buttonApply->setFocus();
2065 if ( Group2Spin->isVisible() ) {
2066 Group2Spin->buttonApply->setEnabled( true );
2067 //Group2Spin->buttonApply->setFocus();
2069 if ( Group3Spin->isVisible() ) {
2070 Group3Spin->buttonApply->setEnabled( true );
2071 //Group3Spin->buttonApply->setFocus();
2073 if ( Group4Spin->isVisible() ) {
2074 Group4Spin->buttonApply->setEnabled( true );
2075 //Group4Spin->buttonApply->setFocus();
2079 gp_Ax3 myWPlane = GetActiveLocalCS();
2080 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2081 WPlane->length( 9 );
2082 WPlane[0] = myWPlane.Location().X();
2083 WPlane[1] = myWPlane.Location().Y();
2084 WPlane[2] = myWPlane.Location().Z();
2086 WPlane[3] = myWPlane.Direction().X();
2087 WPlane[4] = myWPlane.Direction().Y();
2088 WPlane[5] = myWPlane.Direction().Z();
2090 WPlane[6] = myWPlane.XDirection().X();
2091 WPlane[7] = myWPlane.XDirection().Y();
2092 WPlane[8] = myWPlane.XDirection().Z();
2094 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2095 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2097 if ( !anObj->_is_nil() )
2099 if( !IsPreview() ) {
2100 QStringList aCurrentParameters = myParameters;
2101 aCurrentParameters << aParameters;
2102 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2105 objects.push_back( anObj._retn() );
2111 //================================================================
2112 // Function : displayPreview
2113 // Purpose : Method for displaying preview of resulting shape
2114 // Redefined from GEOMBase_Helper.
2115 //================================================================
2116 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2118 const bool activate,
2120 const double lineWidth,
2121 const int displayMode,
2124 // Set color for preview shape
2125 getDisplayer()->SetColor( Quantity_NOC_RED );
2127 // set width of displayed shape
2128 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2130 // Disable activation of selection
2131 getDisplayer()->SetToActivate( activate );
2133 // Make a reference to GEOM_Object
2134 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2135 getDisplayer()->SetName( objStr.in() );
2137 // Create wire from applayed object
2138 TopoDS_Shape anApplyedWire, aLastSegment;
2139 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2143 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2144 if ( aPrs != 0 && !aPrs->IsNull() )
2145 GEOMBase_Helper::displayPreview( aPrs, append, update );
2147 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2148 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2149 if ( aPrs != 0 && !aPrs->IsNull() )
2150 GEOMBase_Helper::displayPreview( aPrs, append, update );
2152 getDisplayer()->UnsetName();
2154 // Enable activation of displayed objects
2155 getDisplayer()->SetToActivate( true );
2158 //================================================================
2159 // Function : createShapes
2160 // Purpose : Create applyed wire, and last segment from entry object
2161 //================================================================
2162 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2163 TopoDS_Shape& theApplyedWire,
2164 TopoDS_Shape& theLastSegment )
2166 TopoDS_Shape aShape;
2167 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2168 aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
2171 if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() ||
2172 Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ||
2173 Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ||
2174 Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
2175 Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
2176 Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
2177 Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) {
2178 theApplyedWire = aShape;
2182 BRepBuilderAPI_MakeWire aBuilder;
2183 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2185 TopoDS_Shape anEdge = anExp.Current();
2187 if ( anExp.More() ) // i.e. non-last edge
2188 aBuilder.Add( TopoDS::Edge( anEdge ) );
2190 theLastSegment = anEdge;
2195 if ( aBuilder.IsDone() )
2196 theApplyedWire = aBuilder.Shape();
2201 //=================================================================================
2202 // function : keyPressEvent()
2204 //=================================================================================
2205 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2207 QDialog::keyPressEvent( e );
2208 if ( e->isAccepted() )
2211 if ( e->key() == Qt::Key_F1 ) {
2217 //=================================================================================
2218 // function : initSpinBox()
2220 //=================================================================================
2221 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2222 double min, double max,
2223 double step, const char* quantity )
2225 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2226 // TODO: Think how to keep the single piece of code...
2228 // Obtain precision from preferences
2229 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2230 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2232 spinBox->setPrecision( aPrecision );
2233 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2234 // by default Qt rounds boundaries to 2 decimals at setRange
2235 spinBox->setRange( min, max );
2236 spinBox->setSingleStep( step );
2238 // Add a hint for the user saying how to tune precision
2239 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2240 spinBox->setProperty( "validity_tune_hint",
2241 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2244 //=================================================================================
2245 // function : SetDoubleSpinBoxStep()
2246 // purpose : Double spin box management
2247 //=================================================================================
2248 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2250 Group1Spin->SpinBox_DX->setSingleStep(step);
2251 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2252 Group2Spin->SpinBox_DX->setSingleStep(step);
2253 Group2Spin->SpinBox_DY->setSingleStep(step);
2254 Group3Spin->SpinBox_DX->setSingleStep(step);
2255 Group3Spin->SpinBox_DY->setSingleStep(step);
2256 Group3Spin->SpinBox_DZ->setSingleStep(step);
2257 Group4Spin->SpinBox_DZ->setSingleStep(step);
2259 // san: Do NOT override the step when a speicifc step value is used
2260 // in some input fields!
2261 //Group4Spin->SpinBox_DX->setSingleStep(step);
2262 //Group4Spin->SpinBox_DY->setSingleStep(step);
2263 //Group4Spin->SpinBox_DS->setSingleStep(step);
2266 //=================================================================================
2267 // function : FindLocalCS()
2268 // purpose : Find All Coordinates systems in study
2269 //=================================================================================
2270 void EntityGUI_SketcherDlg::FindLocalCS()
2274 SalomeApp_Application* app =
2275 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2279 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2283 _PTR(Study) aStudy = appStudy->studyDS();
2286 ComboBox1->addItem(tr("GEOM_GCS"));
2287 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2288 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2289 gp_Dir aDirX = gp_Dir(1, 0, 0);
2290 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2291 myLCSList.push_back(globalCS);
2293 // get GEOM component
2294 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2295 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2298 _PTR(SComponent) fc = obj->GetFatherComponent();
2299 QString geomComp = fc->GetID().c_str();
2300 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2304 // browse through all GEOM data tree
2305 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2306 for ( it->InitEx( true ); it->More(); it->Next() ) {
2307 _PTR(SObject) child( it->Value() );
2308 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2309 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2310 if( CORBA::is_nil( geomObj ) )
2312 if (geomObj->GetType() == GEOM_MARKER) {
2313 ComboBox1->addItem(geomObj->GetName());
2314 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2317 aLCS.Transform(aShape.Location().Transformation());
2318 if (aShape.ShapeType() == TopAbs_FACE) {
2319 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2320 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2321 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2322 gp_Pln aPln = aGPlane->Pln();
2323 aLCS = aPln.Position();
2326 myLCSList.push_back(aLCS);
2331 //=================================================================================
2332 // function : GetActiveLocalCS()
2333 // purpose : Get Working plane
2334 //=================================================================================
2335 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2337 int ind = ComboBox1->currentIndex();
2339 return myGeometryGUI->GetWorkingPlane();
2341 gp_Ax3 aLCS = myLCSList.at(ind);
2346 //=================================================================================
2347 // function : ActivateLocalCS()
2348 // purpose : Activate & Fit Working plane
2349 //=================================================================================
2350 void EntityGUI_SketcherDlg::ActivateLocalCS()
2352 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2353 myGeometryGUI->ActiveWorkingPlane();