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