]> SALOME platform Git repositories - modules/geom.git/blob - src/EntityGUI/EntityGUI_SketcherDlg.cxx
Salome HOME
Update copyright information
[modules/geom.git] / src / EntityGUI / EntityGUI_SketcherDlg.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File   : EntityGUI_SketcherDlg.cxx
24 // Author : Damien COQUERET, Open CASCADE S.A.S.
25 //
26 #include "EntityGUI_SketcherDlg.h"
27 #include "EntityGUI_Widgets.h"
28 #include <QtxDoubleSpinBox.h>
29
30 #include <GEOMBase.h>
31 #include <GeometryGUI.h>
32 #include <GEOMImpl_Types.hxx>
33
34 #include <SUIT_Desktop.h>
35 #include <SUIT_Session.h>
36 #include <SUIT_MessageBox.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SalomeApp_Application.h>
39 #include <LightApp_Application.h>
40 #include <LightApp_SelectionMgr.h>
41
42 #include <QKeyEvent>
43
44 #include <BRep_Tool.hxx>
45 #include <TopExp.hxx>
46 #include <TopExp_Explorer.hxx>
47 #include <TopoDS_Vertex.hxx>
48 #include <TopoDS.hxx>
49 #include <BRepBuilderAPI_Transform.hxx>
50 #include <BRepBuilderAPI_MakeWire.hxx>
51 #include <Sketcher_Profile.hxx>
52
53 //=================================================================================
54 // class    : EntityGUI_SketcherDlg()
55 // purpose  : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
56 //            name 'name' and widget flags set to 'f'.
57 //            The dialog will by default be modeless, unless you set 'modal' to
58 //            TRUE to construct a modal dialog.
59 //=================================================================================
60 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
61                                               bool modal, Qt::WindowFlags fl,
62                                               const double lineWidth )
63   : QDialog( parent, fl ),
64     myIsAllAdded( false ),
65     GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
66     myGeometryGUI( GUI ),
67     myLineWidth( lineWidth )
68 {
69   setModal( modal );
70   setAttribute( Qt::WA_DeleteOnClose );
71
72   myGeometryGUI->SetActiveDialogBox(this);
73
74   MainWidget = new EntityGUI_Skeleton( this );
75   QVBoxLayout* topLayout = new QVBoxLayout( this );
76   topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
77   topLayout->addWidget( MainWidget );
78
79   MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
80   MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
81   MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
82   MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
83
84   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
85   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
86   QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
87
88   setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
89
90   MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
91   MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) );
92   MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) );
93   MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
94   MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
95   MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
96   MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
97
98   /***************************************************************/
99   GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
100
101   GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
102   GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
103   GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
104   GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
105
106   GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
107
108   GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
109   GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
110   GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
111   GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
112   GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
113
114   GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
115
116   GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
117   GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
118   GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
119   GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
120
121   Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
122
123   Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
124   Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
125   Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
126   Group1Sel->PushButton1->setIcon( image0 );
127   Group1Sel->buttonUndo->setIcon( image1 );
128   Group1Sel->buttonRedo->setIcon( image2 );
129   Group1Sel->LineEdit1->setReadOnly( true );
130
131   Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
132   Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
133   Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
134   Group1Spin->buttonUndo->setIcon( image1 );
135   Group1Spin->buttonRedo->setIcon( image2 );
136
137   Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
138   Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
139   Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
140   Group2Spin->buttonUndo->setIcon( image1 );
141   Group2Spin->buttonRedo->setIcon( image2 );
142
143   Group3Spin = new EntityGUI_3Spin( MainWidget->SkeletonCnt );
144   Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
145   Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
146   Group3Spin->buttonUndo->setIcon( image1 );
147   Group3Spin->buttonRedo->setIcon( image2 );
148
149   Group4Spin = new EntityGUI_4Spin( MainWidget->SkeletonCnt );
150   Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
151   Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
152   Group4Spin->buttonUndo->setIcon( image1 );
153   Group4Spin->buttonRedo->setIcon( image2 );
154
155   QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
156   DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
157   DestCntLayout->addWidget( GroupPt, 0, 0, 1, 2 );
158   DestCntLayout->addWidget( GroupD1, 1, 0 );
159   DestCntLayout->addWidget( GroupD2, 1, 1 );
160
161   QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
162   SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
163   SkeletonCntlayout->addWidget( Group1Sel,  0, 0 );
164   SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
165   SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
166   SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
167   SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
168   /***************************************************************/
169
170   QButtonGroup* ButtonGroup = new QButtonGroup( this );
171   ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
172   ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
173
174   /* signals and slots connections */
175   connect( MainWidget->buttonEnd,    SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
176   connect( MainWidget->buttonClose,  SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
177   connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
178   connect( MainWidget->buttonHelp,   SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
179
180   connect( Group1Sel->buttonApply,   SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
181   connect( Group1Sel->buttonUndo,    SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
182   connect( Group1Sel->buttonRedo,    SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
183   connect( Group1Spin->buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
184   connect( Group1Spin->buttonUndo,   SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
185   connect( Group1Spin->buttonRedo,   SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
186   connect( Group2Spin->buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
187   connect( Group2Spin->buttonUndo,   SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
188   connect( Group2Spin->buttonRedo,   SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
189   connect( Group3Spin->buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
190   connect( Group3Spin->buttonUndo,   SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
191   connect( Group3Spin->buttonRedo,   SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
192   connect( Group4Spin->buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
193   connect( Group4Spin->buttonUndo,   SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
194   connect( Group4Spin->buttonRedo,   SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
195
196   connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
197   connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
198   connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
199   connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
200   connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
201
202   connect( Group1Sel->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
203   connect( Group1Sel->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
204
205   connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
206   connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
207   connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
208   connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
209   connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
210   connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
211   connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
212   connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
213   connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
214   connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
215
216   connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
217
218   connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
219   connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
220   
221   // install event filter on spin-boxes to provide Apply action on Return pressed
222   Group1Spin->SpinBox_DX->installEventFilter(this);
223   Group2Spin->SpinBox_DX->installEventFilter(this);
224   Group2Spin->SpinBox_DY->installEventFilter(this);
225   Group3Spin->SpinBox_DX->installEventFilter(this);
226   Group3Spin->SpinBox_DY->installEventFilter(this);
227   Group3Spin->SpinBox_DZ->installEventFilter(this);
228   Group4Spin->SpinBox_DX->installEventFilter(this);
229   Group4Spin->SpinBox_DY->installEventFilter(this);
230   Group4Spin->SpinBox_DZ->installEventFilter(this);
231   Group4Spin->SpinBox_DS->installEventFilter(this);
232
233   Init();
234 }
235
236
237 //=================================================================================
238 // function : ~EntityGUI_SketcherDlg()
239 // purpose  : Destroys the object and frees any allocated resources
240 //=================================================================================
241 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
242 {
243   myGeometryGUI->SetActiveDialogBox( 0 );
244 }
245
246
247 //=================================================================================
248 // function : eventFilter()
249 // purpose  : event filter for spin-boxes to provide Apply action on Return pressed
250 //=================================================================================
251 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
252 {
253   if (event->type() == QEvent::KeyPress) {
254     QKeyEvent* ke = (QKeyEvent*)event;
255     if (ke->key() == Qt::Key_Return) {
256       if (object == Group1Spin->SpinBox_DX) {
257         Group1Spin->buttonApply->animateClick();
258         return true;
259       } else if (object == Group2Spin->SpinBox_DX ||
260                  object == Group2Spin->SpinBox_DY) {
261         Group2Spin->buttonApply->animateClick();
262         return true;
263       } else if (object == Group3Spin->SpinBox_DX ||
264                  object == Group3Spin->SpinBox_DY ||
265                  object == Group3Spin->SpinBox_DZ) {
266         Group3Spin->buttonApply->animateClick();
267         return true;
268       } else if (object == Group4Spin->SpinBox_DX ||
269                  object == Group4Spin->SpinBox_DY ||
270                  object == Group4Spin->SpinBox_DZ ||
271                  object == Group4Spin->SpinBox_DS) {
272         Group4Spin->buttonApply->animateClick();
273         return true;
274       }
275     }
276   }
277
278   if (event->type() == QEvent::KeyRelease) {
279     // NPAL16010 (Sketcher Apply non available if only one line is modified)
280     // To have Apply active as soon as value text changed
281     QtxDoubleSpinBox* aDoubleSpinBox = (QtxDoubleSpinBox*)object;
282     if (aDoubleSpinBox)
283       ValueChangedInSpinBox( aDoubleSpinBox->value() );
284   }
285   
286   return QDialog::eventFilter(object, event);
287 }
288
289
290 //=================================================================================
291 // function : Init()
292 // purpose  :
293 //=================================================================================
294 void EntityGUI_SketcherDlg::Init()
295 {
296   /* init variables */
297   myEditCurrentArgument = Group1Sel->LineEdit1;
298   myCommand.append( "Sketcher" );
299   myUndoCommand.append( "Sketcher" );
300
301   mySketchState = FIRST_POINT;
302   globalSelection( GEOM_POINT );
303
304   myLastX1 = 0.0;
305   myLastY1 = 0.0;
306   myLastX2 = 0.0;
307   myLastY2 = 0.0;
308
309   myHelpFileName = "create_sketcher_page.html";
310
311   /* Get setting of step value from file configuration */
312   double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
313
314   /* min, max, step and decimals for spin boxes */
315   initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
316   initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
317   initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
318   initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
319   initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
320   initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
321   initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
322   initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
323   initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
324   initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
325
326   /* displays Dialog */
327   MainWidget->GroupConstructors->setEnabled( false );
328   MainWidget->GroupDest1->setEnabled( false );
329   setEnabledUndo( false );
330   setEnabledRedo( false );
331
332   MainWidget->RadioButton1->setChecked( true );
333
334   resize( 0, 0 );
335   TypeClicked( 0 );
336
337   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
338 }
339
340
341 //=================================================================================
342 // function : InitClick()
343 // purpose  :
344 //=================================================================================
345 void EntityGUI_SketcherDlg::InitClick()
346 {
347   disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
348
349   Group1Sel->hide();
350   Group1Spin->hide();
351   Group2Spin->hide();
352   Group3Spin->hide();
353   Group4Spin->hide();
354
355   resize( 0, 0 );
356 }
357
358
359 //=================================================================================
360 // function : TypeClicked()
361 // purpose  : Radio button management
362 //=================================================================================
363 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
364 {
365   myConstructorId = constructorId;
366   if ( myConstructorId == 0 ) {    // SEGMENT
367     GroupD2->setEnabled( true );
368     MainWidget->RB_Dest1->setEnabled( true );
369     MainWidget->RB_Dest1->setChecked( true );
370     DestClicked( 1 );
371   }
372   else if (  myConstructorId == 1 ) { // ARC
373     GroupD2->setEnabled( false );
374     MainWidget->RB_Dest1->setEnabled( false );
375     MainWidget->RB_Dest2->setChecked( true );
376     DestClicked( 0 );
377   }
378 }
379
380
381 //=================================================================================
382 // function : DestClicked()
383 // purpose  : Radio button management
384 //=================================================================================
385 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
386 {
387   GroupPt->hide();
388   GroupD1->hide();
389   GroupD2->hide();
390
391   if ( constructorId == 1 ) {
392     // Point
393     GroupPt->RB_Point1->setChecked( true );
394     GroupPt->show();
395     PointClicked( 1 );  // XY
396   }
397   else if (  constructorId == 0 ) {
398     // Direction
399     GroupD1->RB_Dir11->setChecked( true );
400     GroupD1->show();
401     GroupD2->show();
402     Dir1Clicked( 2 );  // Angle
403   }
404 }
405
406
407 //=================================================================================
408 // function : PointClicked()
409 // purpose  : Radio button management
410 //=================================================================================
411 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
412 {
413   InitClick();
414
415   // Get setting of step value from file configuration
416   double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
417
418   if ( myConstructorId == 0 ) {  // SEGMENT
419     if ( constructorId == 1 ) {  // XY
420       mySketchType = PT_ABS;
421       initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
422       initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
423       Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
424       Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
425       myX = 0.0;
426       Group2Spin->SpinBox_DX->setValue( myX );
427       myY = 0.0;
428       Group2Spin->SpinBox_DY->setValue( myY );
429       Group2Spin->show();
430       Group2Spin->buttonApply->setFocus();
431
432       GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
433     }
434     else if ( constructorId == 0 ) {  // DXDY
435       mySketchType = PT_RELATIVE;
436       initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
437       initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
438       Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
439       Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
440       myDX = 0.0;
441       Group2Spin->SpinBox_DX->setValue( myDX );
442       myDY = 0.0;
443       Group2Spin->SpinBox_DY->setValue( myDY );
444       Group2Spin->show();
445       Group2Spin->buttonApply->setFocus();
446
447       GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
448     }
449     else if ( constructorId == 2 ) {  // Selection
450       mySketchType = PT_SEL;
451       myEditCurrentArgument = Group1Sel->LineEdit1;
452       connect( myGeometryGUI->getApp()->selectionMgr(),
453                SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
454       Group1Sel->show();
455       Group1Sel->buttonApply->setFocus();
456       SelectionIntoArgument();
457     }
458   }
459 }
460
461
462 //=================================================================================
463 // function : Dir1Clicked()
464 // purpose  : Radio button management
465 //=================================================================================
466 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
467 {
468   myConstructorDirId = constructorId;
469   GroupD2->RB_Dir21->setChecked( true );
470   Dir2Clicked( 2 );
471 }
472
473
474 //=================================================================================
475 // function : Dir2Clicked()
476 // purpose  : Radio button management
477 //=================================================================================
478 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
479 {
480   InitClick();
481   myAngle = 0.0;
482
483   // Get setting of step value from file configuration
484   double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
485
486   if ( myConstructorId == 0 ) {  // SEGMENT
487     myX = 0.0;
488     myY = 0.0;
489     myLength = 100.0;
490     if ( myConstructorDirId == 2 ) {  // Angle
491       initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
492       initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
493       Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
494       Group2Spin->SpinBox_DX->setValue( myAngle );
495       Group2Spin->buttonApply->setFocus();
496       Group2Spin->show();
497
498       if ( constructorId == 2 ) {  // Length
499         mySketchType = DIR_ANGLE_LENGTH;
500         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
501         Group2Spin->SpinBox_DY->setValue( myLength );
502       }
503       else if ( constructorId == 0 ) {  // X
504         mySketchType = DIR_ANGLE_X;
505         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
506         Group2Spin->SpinBox_DY->setValue( myX );
507       }
508       else if ( constructorId == 1 ) {  // Y
509         mySketchType = DIR_ANGLE_Y;
510         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
511         Group2Spin->SpinBox_DY->setValue( myY );
512       }
513     }
514     else if ( myConstructorDirId == 0 ) {  // Perpendicular
515       Group1Spin->show();
516       Group1Spin->buttonApply->setFocus();
517
518       if ( constructorId == 2 ) {  // Length
519         mySketchType = DIR_PER_LENGTH;
520         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
521         Group1Spin->SpinBox_DX->setValue( myLength );
522       }
523       else if ( constructorId == 0 ) {  // X
524         mySketchType = DIR_PER_X;
525         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
526         Group1Spin->SpinBox_DX->setValue( myX );
527       }
528       else if ( constructorId == 1 ) {  // Y
529         mySketchType = DIR_PER_Y;
530         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
531         Group1Spin->SpinBox_DX->setValue( myY );
532       }
533     }
534     else if ( myConstructorDirId == 1 ) {  // Tangent
535       Group1Spin->show();
536       Group1Spin->buttonApply->setFocus();
537
538       if ( constructorId == 2 ) {  // Length
539         mySketchType = DIR_TAN_LENGTH;
540         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
541         Group1Spin->SpinBox_DX->setValue( myLength );
542       }
543       else if ( constructorId == 0 ) {  // X
544         mySketchType = DIR_TAN_X;
545         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
546         Group1Spin->SpinBox_DX->setValue( myX );
547       }
548       else if ( constructorId == 1 ) {  // Y
549         mySketchType = DIR_TAN_Y;
550         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
551         Group1Spin->SpinBox_DX->setValue( myY );
552       }
553     }
554     else if ( myConstructorDirId == 3 ) {  // DXDY
555       initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
556       initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
557       initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
558       Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
559       Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
560       myDX = 0.0;
561       Group3Spin->SpinBox_DX->setValue( myDX );
562       myDY = 0.0;
563       Group3Spin->SpinBox_DY->setValue( myDY );
564       Group3Spin->show();
565       Group3Spin->buttonApply->setFocus();
566
567       if ( constructorId == 2 ) {  // Length
568         mySketchType = DIR_DXDY_LENGTH;
569         Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
570         Group3Spin->SpinBox_DZ->setValue( myLength );
571       }
572       else if ( constructorId == 0 ) { // X
573         mySketchType = DIR_DXDY_X;
574         Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
575         Group3Spin->SpinBox_DZ->setValue( myX );
576       }
577       else if ( constructorId == 1 ) {  // Y
578         mySketchType = DIR_DXDY_Y;
579         Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
580         Group3Spin->SpinBox_DZ->setValue( myY );
581       }
582     }
583   }
584   else if ( myConstructorId == 1 ) {  // ARC
585     if ( myConstructorDirId == 2 ) {  // Angle
586       if ( constructorId == 2 ) {  // Length
587         mySketchType = DIR_ANGLE_LENGTH;
588         initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
589         initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
590         initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
591         Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
592         Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
593         Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
594         Group3Spin->SpinBox_DX->setValue( myAngle );
595         myRadius = 100.0;
596         Group3Spin->SpinBox_DY->setValue( myRadius );
597         myLength = 30.0;
598         Group3Spin->SpinBox_DZ->setValue( myLength );
599         Group3Spin->show();
600         Group3Spin->buttonApply->setFocus();
601       }
602     }
603     else if ( myConstructorDirId == 0 ) {  // Perpendicular
604       if ( constructorId == 2 ) {  // Length
605         mySketchType = DIR_PER_LENGTH;
606         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
607         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
608         Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
609         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
610         myRadius = 100.0;
611         Group2Spin->SpinBox_DX->setValue( myRadius );
612         myLength = 30.0;
613         Group2Spin->SpinBox_DY->setValue( myLength );
614         Group2Spin->show();
615         Group2Spin->buttonApply->setFocus();
616       }
617     }
618     else if ( myConstructorDirId == 1 ) {  // Tangent
619       if ( constructorId == 2 ) {  // Length
620         mySketchType = DIR_TAN_LENGTH;
621         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
622         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
623         Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
624         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
625         myRadius = 100.0;
626         Group2Spin->SpinBox_DX->setValue( myRadius );
627         myLength = 30.0;
628         Group2Spin->SpinBox_DY->setValue( myLength );
629         Group2Spin->show();
630         Group2Spin->buttonApply->setFocus();
631       }
632     }
633     else if ( myConstructorDirId == 3 ) {  // DXDY
634       if ( constructorId == 2 ) {  // Length
635         mySketchType = DIR_DXDY_LENGTH;
636         Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
637         Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
638         Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
639         Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
640         myDX = 0.0;
641         Group4Spin->SpinBox_DX->setValue( myDX );
642         myDY = 0.0;
643         Group4Spin->SpinBox_DY->setValue( myDY );
644         myRadius = 100.0;
645         Group4Spin->SpinBox_DZ->setValue( myRadius );
646         myLength = 30.0;
647         Group4Spin->SpinBox_DS->setValue( myLength );
648         Group4Spin->show();
649         Group4Spin->buttonApply->setFocus();
650       }
651     }
652   }
653
654   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
655 }
656
657
658 //=================================================================================
659 // function : ClickOnCancel()
660 // purpose  :
661 //=================================================================================
662 void EntityGUI_SketcherDlg::ClickOnCancel()
663 {
664   close();
665 }
666
667
668 //=================================================================================
669 // function : ClickOnEnd()
670 // purpose  : connected to buttonEnd AND buttonClose
671 //=================================================================================
672 void EntityGUI_SketcherDlg::ClickOnEnd()
673 {
674   if ( sender() == MainWidget->buttonClose ) {
675     // Verify validity of commands
676     if ( myCommand.count() <= 2 ) {
677       SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
678                                  tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
679       return;
680     }
681
682     QString Command = myCommand.join( "" ) + GetNewCommand();
683     Sketcher_Profile aProfile( Command.toAscii() );
684
685     Command = myCommand.join( "" );
686     aProfile = Sketcher_Profile( Command.toAscii() );
687     TopoDS_Shape myShape;
688     if ( aProfile.IsDone() )
689       myShape = aProfile.GetShape();
690
691     if ( myShape.ShapeType() != TopAbs_VERTEX )
692       myCommand.append( ":WW" );
693   }
694   else {
695     // PAL16008 (Sketcher Validation should be equal to Apply&Close)
696     if ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ||
697          Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ||
698          Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ||
699          Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ||
700          Group1Sel ->buttonApply->isEnabled() && Group1Sel->isVisible() ) {
701       ClickOnApply();
702     }
703     myIsAllAdded = true;
704   }
705
706   if ( myCommand.size() > 2 )
707     if ( !onAccept() )
708       return;
709
710   close();
711 }
712
713 //=================================================================================
714 // function : ClickOnApply()
715 // purpose  :
716 //=================================================================================
717 bool EntityGUI_SketcherDlg::ClickOnApply()
718 {
719   if ( sender() && sender()->inherits( "QPushButton" ) )
720     ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
721
722   myCommand.append( GetNewCommand() );
723   mySketchState = NEXT_POINT;
724
725   myUndoCommand.clear();
726   myUndoCommand.append( "Sketcher" );
727
728   MainWidget->GroupConstructors->setEnabled( true );
729   MainWidget->GroupDest1->setEnabled( true );
730   setEnabledUndo( true );
731   setEnabledRedo( false );
732
733   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
734
735   // Set focus to SpinBox_DX
736   if ( sender() == Group1Spin->buttonApply ) {
737     (Group1Spin->SpinBox_DX)->setFocus();
738     (Group1Spin->SpinBox_DX)->selectAll();
739   }
740   else if ( sender() == Group2Spin->buttonApply ) {
741     (Group2Spin->SpinBox_DX)->setFocus();
742     (Group2Spin->SpinBox_DX)->selectAll();
743   }
744   else if ( sender() == Group3Spin->buttonApply ) {
745     (Group3Spin->SpinBox_DX)->setFocus();
746     (Group3Spin->SpinBox_DX)->selectAll();
747   }
748   else if ( sender() == Group4Spin->buttonApply ) {
749     (Group4Spin->SpinBox_DX)->setFocus();
750     (Group4Spin->SpinBox_DX)->selectAll();
751   }
752
753   return true;
754 }
755
756 //=================================================================================
757 // function : ClickOnHelp()
758 // purpose  :
759 //=================================================================================
760 void EntityGUI_SketcherDlg::ClickOnHelp()
761 {
762   LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
763   if ( app )
764     app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
765   else {
766     QString platform;
767 #ifdef WIN32
768     platform = "winapplication";
769 #else
770     platform = "application";
771 #endif
772
773     SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
774                               QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
775                               arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
776                               QObject::tr( "BUT_OK" ) );
777   }
778 }
779
780 //=================================================================================
781 // function : ClickOnUndo()
782 // purpose  :
783 //=================================================================================
784 void EntityGUI_SketcherDlg::ClickOnUndo()
785 {
786   myUndoCommand.append( myCommand.last() );
787   myCommand.pop_back();
788
789   if ( myCommand.count() == 1 ) {
790     mySketchState = FIRST_POINT;
791
792     MainWidget->RadioButton1->setChecked( true );
793     TypeClicked( 0 );
794
795     MainWidget->GroupConstructors->setEnabled( false );
796     MainWidget->GroupDest1->setEnabled( false );
797     setEnabledUndo( false );
798   }
799
800   setEnabledRedo( true );
801
802   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
803 }
804
805 //=================================================================================
806 // function : ClickOnRedo()
807 // purpose  :
808 //=================================================================================
809 void EntityGUI_SketcherDlg::ClickOnRedo()
810 {
811   myCommand.append( myUndoCommand.last() );
812   myUndoCommand.pop_back();
813
814   mySketchState = NEXT_POINT;
815
816   MainWidget->GroupConstructors->setEnabled( true );
817   MainWidget->GroupDest1->setEnabled( true );
818   setEnabledUndo( true );
819
820   if ( myUndoCommand.count() == 1 )
821     setEnabledRedo( false );
822
823   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
824 }
825
826 //=================================================================================
827 // function : setEnabledUndo()
828 // purpose  :
829 //=================================================================================
830 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
831 {
832   Group1Sel->buttonUndo->setEnabled( value );
833   Group1Spin->buttonUndo->setEnabled( value );
834   Group2Spin->buttonUndo->setEnabled( value );
835   Group3Spin->buttonUndo->setEnabled( value );
836   Group4Spin->buttonUndo->setEnabled( value );
837 }
838
839 //=================================================================================
840 // function : setEnabledRedo()
841 // purpose  :
842 //=================================================================================
843 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
844 {
845   Group1Sel->buttonRedo->setEnabled( value );
846   Group1Spin->buttonRedo->setEnabled( value );
847   Group2Spin->buttonRedo->setEnabled( value );
848   Group3Spin->buttonRedo->setEnabled( value );
849   Group4Spin->buttonRedo->setEnabled( value );
850 }
851
852 //=================================================================================
853 // function : SelectionIntoArgument()
854 // purpose  : Called when selection as changed
855 //=================================================================================
856 void EntityGUI_SketcherDlg::SelectionIntoArgument()
857 {
858   myEditCurrentArgument->setText( "" );
859   myX = myLastX1;
860   myY = myLastY1;
861
862   LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
863   SALOME_ListIO aSelList;
864   aSelMgr->selectedObjects(aSelList);
865
866   int nbSel = aSelList.Extent();
867   if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
868     Standard_Boolean aRes = Standard_False;
869     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
870     if (!CORBA::is_nil(aSelectedObject) && aRes) {
871       TopoDS_Shape aShape;
872       if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
873         gp_Trsf aTrans;
874         gp_Ax3 aWPlane = myGeometryGUI->GetWorkingPlane();
875
876         aTrans.SetTransformation(aWPlane);
877         BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
878         aShape = aTransformation.Shape();
879
880         gp_Pnt aPnt;
881         if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
882           myX = aPnt.X();
883           myY = aPnt.Y();
884           Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
885         }
886       }
887     }
888   }
889
890   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
891 }
892
893
894 //=================================================================================
895 // function : SetEditCurrentArgument()
896 // purpose  :
897 //=================================================================================
898 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
899 {
900   if ( sender() == Group1Sel->PushButton1 ) {
901     myEditCurrentArgument = Group1Sel->LineEdit1;
902     myEditCurrentArgument->setFocus();
903   }
904   SelectionIntoArgument();
905 }
906
907
908 //=================================================================================
909 // function : LineEditReturnPressed()
910 // purpose  :
911 //=================================================================================
912 void EntityGUI_SketcherDlg::LineEditReturnPressed()
913 {
914   if ( sender() == Group1Sel->LineEdit1 ) {
915     myEditCurrentArgument = Group1Sel->LineEdit1;
916
917     /* User name of object input management                          */
918     /* If successfull the selection is changed and signal emitted... */
919     /* so SelectionIntoArgument() is automatically called.           */
920     const QString objectUserName = myEditCurrentArgument->text();
921     QWidget* thisWidget = (QWidget*)this;
922
923     LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
924     SALOME_ListIO aSelList;
925     aSelMgr->selectedObjects(aSelList);
926
927     if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
928       myEditCurrentArgument->setText( objectUserName );
929   }
930 }
931
932
933 //=================================================================================
934 // function : DeactivateActiveDialog()
935 // purpose  :
936 //=================================================================================
937 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
938 {
939   //myGeometryGUI->SetState( -1 );
940
941   setEnabled( false );
942   globalSelection();
943   disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
944   myGeometryGUI->SetActiveDialogBox( 0 );
945 }
946
947
948 //=================================================================================
949 // function : ActivateThisDialog()
950 // purpose  :
951 //=================================================================================
952 void EntityGUI_SketcherDlg::ActivateThisDialog()
953 {
954   myGeometryGUI->EmitSignalDeactivateDialog();
955   setEnabled( true );
956   myGeometryGUI->SetActiveDialogBox( this );
957
958   connect( myGeometryGUI->getApp()->selectionMgr(),
959           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
960
961   //myGeometryGUI->SetState( 0 );
962   globalSelection( GEOM_POINT );
963
964   myEditCurrentArgument = Group1Sel->LineEdit1;
965   myEditCurrentArgument->setFocus();
966
967   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
968 }
969
970
971 //=================================================================================
972 // function : enterEvent [REDEFINED]
973 // purpose  :
974 //=================================================================================
975 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
976 {
977   if ( !MainWidget->GroupConstructors->isEnabled() )
978     ActivateThisDialog();
979 }
980
981
982 //=================================================================================
983 // function : closeEvent()
984 // purpose  :
985 //=================================================================================
986 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
987 {
988   //myGeometryGUI->SetState( -1 );
989   disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
990   myGeometryGUI->getApp()->updateActions();
991   QDialog::closeEvent( e );
992 }
993
994
995 //=================================================================================
996 // function : ValueChangedInSpinBox()
997 // purpose  :
998 //=================================================================================
999 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1000 {
1001   QObject* send = (QObject*)sender();
1002   Standard_Real vx, vy, vz, vs;
1003   vx = vy = vz = vs = 0.0;
1004
1005   if ( send == Group1Spin->SpinBox_DX ) {
1006     vx = newValue;
1007   }
1008   else if ( send == Group2Spin->SpinBox_DX ) {
1009     vx = newValue;
1010     vy = Group2Spin->SpinBox_DY->value();
1011   }
1012   else if ( send == Group2Spin->SpinBox_DY ) {
1013     vx = Group2Spin->SpinBox_DX->value();
1014     vy = newValue;
1015   }
1016   else if ( send == Group3Spin->SpinBox_DX ) {
1017     vx = newValue;
1018     vy = Group3Spin->SpinBox_DY->value();
1019     vz = Group3Spin->SpinBox_DZ->value();
1020   }
1021   else if ( send == Group3Spin->SpinBox_DY ) {
1022     vx = Group3Spin->SpinBox_DX->value();
1023     vy = newValue;
1024     vz = Group3Spin->SpinBox_DZ->value();
1025   }
1026   else if ( send == Group3Spin->SpinBox_DZ ) {
1027     vx = Group3Spin->SpinBox_DX->value();
1028     vy = Group3Spin->SpinBox_DY->value();
1029     vz = newValue;
1030   }
1031   else if ( send == Group4Spin->SpinBox_DX ) {
1032     vx = newValue;
1033     vy = Group4Spin->SpinBox_DY->value();
1034     vz = Group4Spin->SpinBox_DZ->value();
1035     vs = Group4Spin->SpinBox_DS->value();
1036   }
1037   else if ( send == Group4Spin->SpinBox_DY ) {
1038     vx = Group4Spin->SpinBox_DX->value();
1039     vy = newValue;
1040     vz = Group4Spin->SpinBox_DZ->value();
1041     vs = Group4Spin->SpinBox_DS->value();
1042   }
1043   else if ( send == Group4Spin->SpinBox_DZ ) {
1044     vx = Group4Spin->SpinBox_DX->value();
1045     vy = Group4Spin->SpinBox_DY->value();
1046     vz = newValue;
1047     vs = Group4Spin->SpinBox_DS->value();
1048   }
1049   else if ( send == Group4Spin->SpinBox_DS ) {
1050     vx = Group4Spin->SpinBox_DX->value();
1051     vy = Group4Spin->SpinBox_DY->value();
1052     vz = Group4Spin->SpinBox_DZ->value();
1053     vs = newValue;
1054   }
1055   // NPAL16010 (Sketcher Apply non available if only one line is modified)
1056   // if ValueChangedInSpinBox() called from eventFilter()
1057   else if ( Group1Spin->SpinBox_DX->hasFocus() ) {
1058     vx = newValue;
1059   }
1060   else if ( Group2Spin->SpinBox_DX ->hasFocus() ) {
1061     vx = newValue;
1062     vy = Group2Spin->SpinBox_DY->value();
1063   }
1064   else if ( Group2Spin->SpinBox_DY->hasFocus() ) {
1065     vx = Group2Spin->SpinBox_DX->value();
1066     vy = newValue;
1067   }
1068   else if ( Group3Spin->SpinBox_DX->hasFocus() ) {
1069     vx = newValue;
1070     vy = Group3Spin->SpinBox_DY->value();
1071     vz = Group3Spin->SpinBox_DZ->value();
1072   }
1073   else if ( Group3Spin->SpinBox_DY->hasFocus() ) {
1074     vx = Group3Spin->SpinBox_DX->value();
1075     vy = newValue;
1076     vz = Group3Spin->SpinBox_DZ->value();
1077   }
1078   else if ( Group3Spin->SpinBox_DZ->hasFocus() ) {
1079     vx = Group3Spin->SpinBox_DX->value();
1080     vy = Group3Spin->SpinBox_DY->value();
1081     vz = newValue;
1082   }
1083   else if ( Group4Spin->SpinBox_DX->hasFocus() ) {
1084     vx = newValue;
1085     vy = Group4Spin->SpinBox_DY->value();
1086     vz = Group4Spin->SpinBox_DZ->value();
1087     vs = Group4Spin->SpinBox_DS->value();
1088   }
1089   else if ( Group4Spin->SpinBox_DY->hasFocus() ) {
1090     vx = Group4Spin->SpinBox_DX->value();
1091     vy = newValue;
1092     vz = Group4Spin->SpinBox_DZ->value();
1093     vs = Group4Spin->SpinBox_DS->value();
1094   }
1095   else if ( Group4Spin->SpinBox_DZ->hasFocus() ) {
1096     vx = Group4Spin->SpinBox_DX->value();
1097     vy = Group4Spin->SpinBox_DY->value();
1098     vz = newValue;
1099     vs = Group4Spin->SpinBox_DS->value();
1100   }
1101   else if ( Group4Spin->SpinBox_DS->hasFocus() ) {
1102     vx = Group4Spin->SpinBox_DX->value();
1103     vy = Group4Spin->SpinBox_DY->value();
1104     vz = Group4Spin->SpinBox_DZ->value();
1105     vs = newValue;
1106   }
1107
1108   if ( myConstructorId == 0 ) {  // SEGMENT
1109     if ( mySketchType == PT_ABS ) {
1110       myX = vx;
1111       myY = vy;
1112     }
1113     else if ( mySketchType == PT_RELATIVE ) {
1114       myDX = vx;
1115       myDY = vy;
1116     }
1117     else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1118       myAngle = vx;
1119       myLength = vy;
1120     }
1121     else if ( mySketchType == DIR_ANGLE_X ) {
1122       myAngle = vx;
1123       myX = vy;
1124     }
1125     else if ( mySketchType == DIR_ANGLE_Y ) {
1126       myAngle = vx;
1127       myY = vy;
1128     }
1129     else if ( mySketchType == DIR_PER_LENGTH ) {
1130       myLength = vx;
1131     }
1132     else if ( mySketchType == DIR_PER_X ) {
1133       myX = vx;
1134     }
1135     else if ( mySketchType == DIR_PER_Y ) {
1136       myY = vx;
1137     }
1138     else if ( mySketchType == DIR_TAN_LENGTH ) {
1139       myLength = vx;
1140     }
1141     else if ( mySketchType == DIR_TAN_X ) {
1142       myX = vx;
1143     }
1144     else if ( mySketchType == DIR_TAN_Y ) {
1145       myY = vx;
1146     }
1147     else if ( mySketchType == DIR_DXDY_LENGTH ) {
1148       myDX = vx;
1149       myDY = vy;
1150       myLength = vz;
1151     }
1152     else if ( mySketchType == DIR_DXDY_X ) {
1153       myDX = vx;
1154       myDY = vy;
1155       myX = vz;
1156     }
1157     else if ( mySketchType == DIR_DXDY_Y ) {
1158       myDX = vx;
1159       myDY = vy;
1160       myY = vz;
1161     }
1162   }
1163   else if ( myConstructorId == 1 ) {  // ARC
1164     if ( mySketchType == DIR_ANGLE_LENGTH ) {
1165       myAngle = vx;
1166       myRadius = vy;
1167       myLength = vz;
1168     }
1169     else if ( mySketchType == DIR_PER_LENGTH ) {
1170       myRadius = vx;
1171       myLength = vy;
1172     }
1173     else if ( mySketchType == DIR_TAN_LENGTH ) {
1174       myRadius = vx;
1175       myLength = vy;
1176     }
1177     else if ( mySketchType == DIR_DXDY_LENGTH ) {
1178       myDX = vx;
1179       myDY = vy;
1180       myRadius = vz;
1181       myLength = vs;
1182     }
1183   }
1184
1185   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1186 }
1187
1188
1189 //=================================================================================
1190 // function : GetNewCommand()
1191 // purpose  : Build the new command with context
1192 //=================================================================================
1193 QString EntityGUI_SketcherDlg::GetNewCommand()
1194 {
1195   QString myNewCommand = ":";
1196   if ( mySketchState == FIRST_POINT ) {
1197     if ( mySketchType == PT_ABS || mySketchType == PT_SEL )
1198       myNewCommand = myNewCommand + "F " + QString::number( myX ) + " " + QString::number( myY );
1199     if ( mySketchType == PT_RELATIVE)
1200       myNewCommand = myNewCommand + "F " + QString::number( myDX ) + " " + QString::number( myDY );
1201     return myNewCommand;
1202   }
1203
1204   if ( myConstructorId == 0  ) {  // SEGMENT
1205     if ( mySketchType == PT_ABS || mySketchType == PT_SEL )
1206       myNewCommand = myNewCommand + "TT " + QString::number( myX ) + " " + QString::number( myY );
1207     if ( mySketchType == PT_RELATIVE)
1208       myNewCommand = myNewCommand + "T " + QString::number( myDX ) + " " + QString::number( myDY );
1209     if ( mySketchType == DIR_ANGLE_LENGTH ) {
1210       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1211       myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength );
1212     }
1213     if ( mySketchType == DIR_ANGLE_X ) {
1214       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1215       myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX );
1216     }
1217     if ( mySketchType == DIR_ANGLE_Y ) {
1218       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1219       myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY );
1220     }
1221     if ( mySketchType == DIR_PER_LENGTH ) {
1222       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1223       myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength );
1224     }
1225     if ( mySketchType == DIR_PER_X ) {
1226       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1227       myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX );
1228     }
1229     if ( mySketchType == DIR_PER_Y ) {
1230       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1231       myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY );
1232     }
1233     if ( mySketchType == DIR_TAN_LENGTH )
1234       myNewCommand = myNewCommand + "L " + QString::number( myLength );
1235     if ( mySketchType == DIR_TAN_X )
1236       myNewCommand = myNewCommand + "IX " + QString::number( myX );
1237     if ( mySketchType == DIR_TAN_Y)
1238       myNewCommand = myNewCommand + "IY " + QString::number(myY);
1239     if ( mySketchType == DIR_DXDY_LENGTH ) {
1240       myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY );
1241       myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength );
1242     }
1243     if ( mySketchType == DIR_DXDY_X ) {
1244       myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY );
1245       myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX );
1246     }
1247     if ( mySketchType == DIR_DXDY_Y ) {
1248       myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY );
1249       myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY );
1250     }
1251   }
1252   else if ( myConstructorId == 1 ) {  // ARC
1253     if ( mySketchType == DIR_ANGLE_LENGTH ) {
1254       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1255       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
1256     }
1257     if ( mySketchType == DIR_PER_LENGTH ) {
1258       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1259       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
1260     }
1261     if ( mySketchType == DIR_TAN_LENGTH ) {
1262       myNewCommand = myNewCommand + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
1263     }
1264     if ( mySketchType == DIR_DXDY_LENGTH ) {
1265       myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY );
1266       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
1267     }
1268   }
1269   return myNewCommand;
1270 }
1271
1272 //=================================================================================
1273 // function : createOperation
1274 // purpose  :
1275 //=================================================================================
1276 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1277 {
1278   return getGeomEngine()->GetICurvesOperations( getStudyId() );
1279 }
1280
1281 //=================================================================================
1282 // function : isValid
1283 // purpose  :
1284 //=================================================================================
1285 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1286 {
1287   return true;
1288 }
1289
1290 //=================================================================================
1291 // function : execute
1292 // purpose  :
1293 //=================================================================================
1294 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1295 {
1296   if ( mySketchState == FIRST_POINT ) {
1297     myLastX2 = myX;
1298     myLastY2 = myY;
1299   }
1300   else {
1301     //Test if the current point is the same as the last one
1302     TopoDS_Shape myShape1, myShape2;
1303
1304     //Last Shape
1305     QString Command1 = myCommand.join( "" );
1306     Sketcher_Profile aProfile1( Command1.toAscii() );
1307     if ( aProfile1.IsDone() )
1308       myShape1 = aProfile1.GetShape();
1309
1310     //Current Shape
1311     QString Command2 = Command1 + GetNewCommand();
1312     Sketcher_Profile aProfile2( Command2.toAscii() );
1313     if ( aProfile2.IsDone() )
1314       myShape2 = aProfile2.GetShape();
1315
1316     if ( myShape2.IsNull() ) {
1317       //the current point is the same as the last one
1318       myLastX2 = myLastX1;
1319       myLastY2 = myLastY1;
1320     }
1321     else {
1322       TopoDS_Vertex V1, V2;
1323       gp_Pnt pt;
1324       if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
1325         //the last shape is the first point
1326         pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
1327         myLastX1 = pt.X();
1328         myLastY1 = pt.Y();
1329       }
1330       else {
1331         TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
1332         pt = BRep_Tool::Pnt( V2 );
1333         myLastX1 = pt.X();
1334         myLastY1 = pt.Y();
1335       }
1336       TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
1337       pt = BRep_Tool::Pnt( V2 );
1338       myLastX2 = pt.X();
1339       myLastY2 = pt.Y();
1340     }
1341   }
1342
1343   QString cmd;
1344   if ( ( mySketchState != FIRST_POINT &&
1345          myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
1346     cmd = myCommand.join( "" );
1347
1348     if ( Group1Sel->isVisible() ) {
1349       Group1Sel->buttonApply->setEnabled( false );
1350       //Group1Sel->buttonApply->setFocus();
1351     }
1352     if ( Group1Spin->isVisible() ) {
1353       Group1Spin->buttonApply->setEnabled( false );
1354       //Group1Spin->buttonApply->setFocus();
1355     }
1356     if ( Group2Spin->isVisible() ) {
1357       Group2Spin->buttonApply->setEnabled( false );
1358       //Group2Spin->buttonApply->setFocus();
1359     }
1360     if ( Group3Spin->isVisible() ) {
1361       Group3Spin->buttonApply->setEnabled( false );
1362       //Group3Spin->buttonApply->setFocus();
1363     }
1364     if ( Group4Spin->isVisible() ) {
1365       Group4Spin->buttonApply->setEnabled( false );
1366       //Group4Spin->buttonApply->setFocus();
1367     }
1368   }
1369   else {
1370     cmd = myCommand.join( "" ) + GetNewCommand();
1371
1372     if ( Group1Sel->isVisible() ) {
1373       Group1Sel->buttonApply->setEnabled( true );
1374       //Group1Sel->buttonApply->setFocus();
1375     }
1376     if ( Group1Spin->isVisible() ) {
1377       Group1Spin->buttonApply->setEnabled( true );
1378       //Group1Spin->buttonApply->setFocus();
1379     }
1380     if ( Group2Spin->isVisible() ) {
1381       Group2Spin->buttonApply->setEnabled( true );
1382       //Group2Spin->buttonApply->setFocus();
1383     }
1384     if ( Group3Spin->isVisible() ) {
1385       Group3Spin->buttonApply->setEnabled( true );
1386       //Group3Spin->buttonApply->setFocus();
1387     }
1388     if ( Group4Spin->isVisible() ) {
1389       Group4Spin->buttonApply->setEnabled( true );
1390       //Group4Spin->buttonApply->setFocus();
1391     }
1392   }
1393
1394   gp_Ax3 myWPlane = myGeometryGUI->GetWorkingPlane();
1395   GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
1396   WPlane->length( 9 );
1397   WPlane[0] = myWPlane.Location().X();
1398   WPlane[1] = myWPlane.Location().Y();
1399   WPlane[2] = myWPlane.Location().Z();
1400
1401   WPlane[3] = myWPlane.Direction().X();
1402   WPlane[4] = myWPlane.Direction().Y();
1403   WPlane[5] = myWPlane.Direction().Z();
1404
1405   WPlane[6] = myWPlane.XDirection().X();
1406   WPlane[7] = myWPlane.XDirection().Y();
1407   WPlane[8] = myWPlane.XDirection().Z();
1408
1409   GEOM::GEOM_Object_var anObj =
1410     GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeSketcher( cmd.toLatin1(), WPlane );
1411
1412   if ( !anObj->_is_nil() )
1413     objects.push_back( anObj._retn() );
1414
1415   return true;
1416 }
1417
1418 //================================================================
1419 // Function : displayPreview
1420 // Purpose  : Method for displaying preview of resulting shape
1421 //            Redefined from GEOMBase_Helper.
1422 //================================================================
1423 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
1424                                             const bool            append,
1425                                             const bool            activate,
1426                                             const bool            update,
1427                                             const double          lineWidth,
1428                                             const int             displayMode,
1429                                             const int             color )
1430 {
1431   // Set color for preview shape
1432   getDisplayer()->SetColor( Quantity_NOC_RED );
1433
1434   // set width of displayed shape
1435   getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
1436
1437   // Disable activation of selection
1438   getDisplayer()->SetToActivate( activate );
1439
1440   // Make a reference to GEOM_Object
1441   CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
1442   getDisplayer()->SetName( objStr.in() );
1443
1444   // Create wire from applayed object
1445   TopoDS_Shape anApplyedWire, aLastSegment;
1446   if ( !createShapes( object, anApplyedWire, aLastSegment ) )
1447     return;
1448
1449   // Build prs
1450   SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
1451   if ( aPrs != 0 && !aPrs->IsNull() )
1452     GEOMBase_Helper::displayPreview( aPrs, append, update );
1453
1454   getDisplayer()->SetColor( Quantity_NOC_VIOLET );
1455   aPrs = getDisplayer()->BuildPrs( aLastSegment );
1456   if ( aPrs != 0 && !aPrs->IsNull() )
1457     GEOMBase_Helper::displayPreview( aPrs, append, update );
1458
1459   getDisplayer()->UnsetName();
1460
1461   // Enable activation of displayed objects
1462   getDisplayer()->SetToActivate( true );
1463 }
1464
1465 //================================================================
1466 // Function : createShapes
1467 // Purpose  : Create applyed wire, and last segment from entry object
1468 //================================================================
1469 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
1470                                           TopoDS_Shape&         theApplyedWire,
1471                                           TopoDS_Shape&         theLastSegment )
1472 {
1473   TopoDS_Shape aShape;
1474   if ( !GEOMBase::GetShape( theObject, aShape ) ||
1475        aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
1476     return false;
1477
1478   if ( Group1Sel->isVisible()  && !Group1Sel->buttonApply->isEnabled()  ||
1479        Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
1480        Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
1481        Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
1482        Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) {
1483      theApplyedWire = aShape;
1484      return true;
1485   }
1486
1487   BRepBuilderAPI_MakeWire aBuilder;
1488   TopExp_Explorer anExp( aShape, TopAbs_EDGE );
1489   while ( 1 ) {
1490     TopoDS_Shape anEdge = anExp.Current();
1491     anExp.Next();
1492     if ( anExp.More() ) // i.e. non-last edge
1493       aBuilder.Add( TopoDS::Edge( anEdge ) );
1494     else {
1495       theLastSegment = anEdge;
1496       break;
1497     }
1498   }
1499
1500   if ( aBuilder.IsDone() )
1501     theApplyedWire = aBuilder.Shape();
1502
1503   return true;
1504 }
1505
1506 //=================================================================================
1507 // function : keyPressEvent()
1508 // purpose  :
1509 //=================================================================================
1510 void  EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
1511 {
1512   QDialog::keyPressEvent( e );
1513   if ( e->isAccepted() )
1514     return;
1515
1516   if ( e->key() == Qt::Key_F1 ) {
1517     e->accept();
1518     ClickOnHelp();
1519   }
1520 }
1521
1522 void EntityGUI_SketcherDlg::initSpinBox( QDoubleSpinBox* spinBox,
1523                                          double min,  double max,
1524                                          double step, int decimals )
1525 {
1526   spinBox->setDecimals( decimals );
1527   spinBox->setRange( min, max );
1528   spinBox->setSingleStep( step );
1529 }
1530
1531 //=================================================================================
1532 // function : SetDoubleSpinBoxStep()
1533 // purpose  : Double spin box management
1534 //=================================================================================
1535 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
1536 {
1537   Group1Spin->SpinBox_DX->setSingleStep(step);
1538   Group2Spin->SpinBox_DX->setSingleStep(step);
1539   Group2Spin->SpinBox_DY->setSingleStep(step);
1540   Group3Spin->SpinBox_DX->setSingleStep(step);
1541   Group3Spin->SpinBox_DY->setSingleStep(step);
1542   Group3Spin->SpinBox_DZ->setSingleStep(step);
1543   Group4Spin->SpinBox_DX->setSingleStep(step);
1544   Group4Spin->SpinBox_DY->setSingleStep(step);
1545   Group4Spin->SpinBox_DZ->setSingleStep(step);
1546   Group4Spin->SpinBox_DS->setSingleStep(step);
1547 }