]> SALOME platform Git repositories - modules/geom.git/blob - src/EntityGUI/EntityGUI_SketcherDlg.cxx
Salome HOME
Merge from V5_1_main branch 24/11/2010
[modules/geom.git] / src / EntityGUI / EntityGUI_SketcherDlg.cxx
1 //  Copyright (C) 2007-2010  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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
26 //
27 #include "EntityGUI_SketcherDlg.h"
28 #include "EntityGUI_Widgets.h"
29 #include <SalomeApp_DoubleSpinBox.h>
30
31 #include <GEOMBase.h>
32 #include <GeometryGUI.h>
33 #include <GEOMImpl_Types.hxx>
34 #include <Geom_Surface.hxx>
35 #include <Geom_Plane.hxx>
36
37 #include <SUIT_Desktop.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Application.h>
42 #include <LightApp_Application.h>
43 #include <LightApp_SelectionMgr.h>
44
45 #include <QKeyEvent>
46
47 #include <BRep_Tool.hxx>
48 #include <TopExp.hxx>
49 #include <TopExp_Explorer.hxx>
50 #include <TopoDS_Vertex.hxx>
51 #include <TopoDS.hxx>
52 #include <BRepBuilderAPI_Transform.hxx>
53 #include <BRepBuilderAPI_MakeWire.hxx>
54 #include <Sketcher_Profile.hxx>
55
56 #include <SalomeApp_Study.h>
57
58 #include <gp_Pln.hxx>
59
60 #include <Basics_Utils.hxx>
61
62 //=================================================================================
63 // class    : EntityGUI_SketcherDlg()
64 // purpose  : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
65 //            name 'name' and widget flags set to 'f'.
66 //            The dialog will by default be modeless, unless you set 'modal' to
67 //            TRUE to construct a modal dialog.
68 //=================================================================================
69 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
70                                               bool modal, Qt::WindowFlags fl,
71                                               const double lineWidth )
72   : QDialog( parent, fl ),
73     myIsAllAdded( false ),
74     myIsApply( false ),
75     GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
76     myGeometryGUI( GUI ),
77     myLineWidth( lineWidth )
78 {
79   setModal( modal );
80   setAttribute( Qt::WA_DeleteOnClose );
81
82   myGeometryGUI->SetActiveDialogBox(this);
83
84   MainWidget = new EntityGUI_Skeleton( this );
85   QVBoxLayout* topLayout = new QVBoxLayout( this );
86   topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
87
88   MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
89   MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
90   MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
91   MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
92
93   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
94   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
95   QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
96
97   setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
98
99   MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
100   MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) );
101   MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) );
102   MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
103   MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
104   MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
105   MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
106
107   /***************************************************************/
108
109   GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
110   QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
111   planeLayout->setSpacing(6);
112   planeLayout->setMargin(11);
113
114   ComboBox1 = new QComboBox(GroupBox1);
115   ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
116   planeLayout->addWidget(ComboBox1);
117
118   planeButton = new QPushButton (GroupBox1);
119   planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
120   planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
121   planeLayout->addWidget(planeButton);
122
123   topLayout->addWidget(GroupBox1);
124   topLayout->addWidget( MainWidget );
125
126   GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
127
128   GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
129   GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
130   GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
131   GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
132
133   GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
134
135   GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) ); 
136   GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
137   GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
138   GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) ); 
139
140   GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
141
142   GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
143   GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
144   GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
145   GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
146   GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
147
148   GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
149
150   GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
151   GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
152   GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
153   GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
154
155   Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
156   Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
157   Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
158   Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
159   Group1Sel->PushButton1->setIcon( image0 );
160   Group1Sel->buttonUndo->setIcon( image1 );
161   Group1Sel->buttonRedo->setIcon( image2 );
162   Group1Sel->LineEdit1->setReadOnly( true );
163
164   Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
165   Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
166   Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
167   Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
168   Group2Sel->PushButton1->setIcon( image0 );
169   Group2Sel->PushButton2->setIcon( image0 );
170   Group2Sel->buttonUndo->setIcon( image1 );
171   Group2Sel->buttonRedo->setIcon( image2 );
172   Group2Sel->LineEdit1->setReadOnly( true );
173   Group2Sel->LineEdit2->setReadOnly( true );
174
175   Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
176   Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
177   Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
178   Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
179   Group1Sel1Spin->PushButton1->setIcon( image0 );
180   Group1Sel1Spin->buttonUndo->setIcon( image1 );
181   Group1Sel1Spin->buttonRedo->setIcon( image2 );
182   Group1Sel1Spin->LineEdit1->setReadOnly( true );
183
184   Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
185   Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
186   Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
187   Group1Spin->buttonUndo->setIcon( image1 );
188   Group1Spin->buttonRedo->setIcon( image2 );
189
190   Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
191   Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
192   Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
193   Group2Spin->buttonUndo->setIcon( image1 );
194   Group2Spin->buttonRedo->setIcon( image2 );
195
196   Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
197   Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
198   Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
199   Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
200   Group3Spin->buttonUndo->setIcon( image1 );
201   Group3Spin->buttonRedo->setIcon( image2 );
202
203   Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
204   Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
205   Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
206   Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
207   Group4Spin->buttonUndo->setIcon( image1 );
208   Group4Spin->buttonRedo->setIcon( image2 );
209
210   //myErrLabel = new QLabel( MainWidget->DestCnt );
211
212   QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
213   DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
214   DestCntLayout->addWidget( GroupPt, 0, 0 );
215   DestCntLayout->addWidget( GroupPt2, 0, 1 );
216   DestCntLayout->addWidget( GroupD1, 0, 0 );
217   DestCntLayout->addWidget( GroupD2, 0, 1 );
218
219   QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
220   SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
221   SkeletonCntlayout->addWidget( Group1Sel,  0, 0 );
222   SkeletonCntlayout->addWidget( Group2Sel,  0, 0 );
223   SkeletonCntlayout->addWidget( Group1Sel1Spin,  0, 0 );
224   SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
225   SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
226   SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
227   SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
228   /***************************************************************/
229
230   QButtonGroup* ButtonGroup = new QButtonGroup( this );
231   ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
232   ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
233
234   /* signals and slots connections */
235   connect( MainWidget->buttonEnd,    SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
236   connect( MainWidget->buttonClose,  SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
237   connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
238   connect( MainWidget->buttonHelp,   SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
239
240   connect( Group1Sel->buttonApply,   SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
241   connect( Group1Sel->buttonUndo,    SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
242   connect( Group1Sel->buttonRedo,    SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
243   connect( Group2Sel->buttonApply,   SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
244   connect( Group2Sel->buttonUndo,    SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
245   connect( Group2Sel->buttonRedo,    SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
246   connect( Group1Sel1Spin->buttonApply,   SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
247   connect( Group1Sel1Spin->buttonUndo,    SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
248   connect( Group1Sel1Spin->buttonRedo,    SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
249   connect( Group1Spin->buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
250   connect( Group1Spin->buttonUndo,   SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
251   connect( Group1Spin->buttonRedo,   SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
252   connect( Group2Spin->buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
253   connect( Group2Spin->buttonUndo,   SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
254   connect( Group2Spin->buttonRedo,   SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
255   connect( Group3Spin->buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
256   connect( Group3Spin->buttonUndo,   SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
257   connect( Group3Spin->buttonRedo,   SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
258   connect( Group4Spin->buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
259   connect( Group4Spin->buttonUndo,   SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
260   connect( Group4Spin->buttonRedo,   SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
261
262   connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
263   connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
264   connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
265   connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
266   connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
267   connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
268
269   connect( Group1Sel->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
270   connect( Group1Sel->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
271
272   connect( Group2Sel->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
273   connect( Group2Sel->LineEdit2,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
274   connect( Group2Sel->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
275   connect( Group2Sel->PushButton2, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
276
277   connect( Group1Sel1Spin->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
278   connect( Group1Sel1Spin->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
279   connect( Group1Sel1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
280
281   connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
282   connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
283   connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
284   connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
285   connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
286   connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
287   connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
288   connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
289   connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
290   connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
291
292   connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
293   connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
294   connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
295   connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
296
297   connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
298   connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
299
300   connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
301
302   connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
303   connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
304   
305   // install event filter on spin-boxes to provide Apply action on Return pressed
306   Group1Spin->SpinBox_DX->installEventFilter(this);
307   Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
308   Group2Spin->SpinBox_DX->installEventFilter(this);
309   Group2Spin->SpinBox_DY->installEventFilter(this);
310   Group3Spin->SpinBox_DX->installEventFilter(this);
311   Group3Spin->SpinBox_DY->installEventFilter(this);
312   Group3Spin->SpinBox_DZ->installEventFilter(this);
313   Group4Spin->SpinBox_DX->installEventFilter(this);
314   Group4Spin->SpinBox_DY->installEventFilter(this);
315   Group4Spin->SpinBox_DZ->installEventFilter(this);
316   Group4Spin->SpinBox_DS->installEventFilter(this);
317
318   Init();
319 }
320
321
322 //=================================================================================
323 // function : ~EntityGUI_SketcherDlg()
324 // purpose  : Destroys the object and frees any allocated resources
325 //=================================================================================
326 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
327 {
328   myGeometryGUI->SetActiveDialogBox( 0 );
329 }
330
331
332 //=================================================================================
333 // function : eventFilter()
334 // purpose  : event filter for spin-boxes to provide Apply action on Return pressed
335 //=================================================================================
336 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
337 {
338   if (event->type() == QEvent::KeyPress) {
339     QKeyEvent* ke = (QKeyEvent*)event;
340     if (ke->key() == Qt::Key_Return) {
341       if (object == Group1Spin->SpinBox_DX) {
342         Group1Spin->buttonApply->animateClick();
343         return true;
344       } else if (object == Group1Sel1Spin->SpinBox_DX) {
345         Group1Sel1Spin->buttonApply->animateClick();
346         return true;
347       } else if (object == Group2Spin->SpinBox_DX ||
348                  object == Group2Spin->SpinBox_DY) {
349         Group2Spin->buttonApply->animateClick();
350         return true;
351       } else if (object == Group3Spin->SpinBox_DX ||
352                  object == Group3Spin->SpinBox_DY ||
353                  object == Group3Spin->SpinBox_DZ) {
354         Group3Spin->buttonApply->animateClick();
355         return true;
356       } else if (object == Group4Spin->SpinBox_DX ||
357                  object == Group4Spin->SpinBox_DY ||
358                  object == Group4Spin->SpinBox_DZ ||
359                  object == Group4Spin->SpinBox_DS) {
360         Group4Spin->buttonApply->animateClick();
361         return true;
362       }
363     }
364   }
365
366   // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
367
368   return QDialog::eventFilter(object, event);
369 }
370
371
372 //=================================================================================
373 // function : Init()
374 // purpose  :
375 //=================================================================================
376 void EntityGUI_SketcherDlg::Init()
377 {
378   /* init variables */
379   myEditCurrentArgument = Group1Sel->LineEdit1;
380   myCommand.append( "Sketcher" );
381   myUndoCommand.append( "Sketcher" );
382
383   mySketchState = FIRST_POINT;
384   globalSelection( GEOM_POINT );
385
386   myCheckFlag = 0;
387
388   myLastX1 = 0.0;
389   myLastY1 = 0.0;
390   myLastX2 = 0.0;
391   myLastY2 = 0.0;
392
393   myHelpFileName = "create_sketcher_page.html";
394
395   /* Get setting of step value from file configuration */
396   double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
397
398   /* min, max, step and decimals for spin boxes */
399   initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
400   initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
401   initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
402   initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
403   initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
404   initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
405   initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
406   initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
407   // san: Note specific step values below!
408   initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
409   initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
410   initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
411
412   /* displays Dialog */
413   MainWidget->GroupConstructors->setEnabled( false );
414   MainWidget->GroupDest1->setEnabled( false );
415   setEnabledUndo( false );
416   setEnabledRedo( false );
417
418   MainWidget->RadioButton1->setChecked( true );
419
420   TypeClicked( 0 );
421
422   FindLocalCS();
423   resize(100,100);
424
425   ActivateLocalCS();
426   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
427 }
428
429
430 //=================================================================================
431 // function : InitClick()
432 // purpose  :
433 //=================================================================================
434 void EntityGUI_SketcherDlg::InitClick()
435 {
436   disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
437   myCheckFlag = 0;
438
439   Group1Sel->hide();
440   Group2Sel->hide();
441   Group1Sel1Spin->hide();
442   Group1Spin->hide();
443   Group2Spin->hide();
444   Group3Spin->hide();
445   Group4Spin->hide();
446 }
447
448
449 //=================================================================================
450 // function : TypeClicked()
451 // purpose  : Radio button management
452 //=================================================================================
453 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
454 {
455   myConstructorId = constructorId;
456   if ( myConstructorId == 0 ) {    // SEGMENT
457     GroupPt2->setEnabled( false );
458     GroupD2->setEnabled( true );
459     MainWidget->RB_Dest1->setEnabled( true );
460     MainWidget->RB_Dest1->setChecked( true );
461     DestClicked( 1 );
462   }
463   else if (  myConstructorId == 1 ) { // ARC
464     GroupPt2->setEnabled( true );
465     GroupD2->setEnabled( false );
466     MainWidget->RB_Dest1->setEnabled( true ); 
467     MainWidget->RB_Dest1->setChecked( true );
468     DestClicked( 1 );
469   }
470 }
471
472
473 //=================================================================================
474 // function : DestClicked()
475 // purpose  : Radio button management
476 //=================================================================================
477 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
478 {
479   GroupPt->hide();
480   GroupPt2->hide();
481   GroupD1->hide();
482   GroupD2->hide();
483
484   if ( constructorId == 1 ) {
485     // Point
486     GroupPt->RB_Point1->setChecked( true );
487     GroupPt->show();
488     GroupPt2->show();
489     Group3Spin->checkBox->show();
490     Group4Spin->checkBox->show();
491     PointClicked( 1 );  // XY
492   }
493   else if (  constructorId == 0 ) {
494     // Direction
495     GroupD1->RB_Dir11->setChecked( true );
496     GroupD1->show();
497     GroupD2->show();
498     Group3Spin->checkBox->hide();
499     Group4Spin->checkBox->hide();
500     Dir1Clicked( 2 );  // Angle
501   }
502 }
503
504 //=================================================================================
505 // function : PointClicked()
506 // purpose  : Radio button management
507 //=================================================================================
508 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
509 {
510   myConstructorPntId = constructorId;  
511   GroupPt2->RB_Point1->setChecked( true );
512   GroupPt->RB_Point3->setEnabled( true ); 
513   Point2Clicked( 1 );
514 }
515
516 //=================================================================================
517 // function : Point2Clicked()
518 // purpose  : Radio button management
519 //=================================================================================
520 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
521 {
522   InitClick();
523
524   // Get setting of step value from file configuration
525   double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
526
527   if ( myConstructorPntId == 1 ) {  // XY
528     if ( constructorId == 1 ){      // No additional parameter
529       mySketchType = PT_ABS;
530       initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
531       initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
532       Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
533       Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
534       myX = 0.0;
535       Group2Spin->SpinBox_DX->setValue( myX );
536       myY = 0.0;
537       Group2Spin->SpinBox_DY->setValue( myY );
538       Group2Spin->show();
539       Group2Spin->buttonApply->setFocus();
540
541       GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
542     }
543     else if ( constructorId == 0 ){   // Point + radius
544       mySketchType = PT_ABS_RADIUS;
545       initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); 
546       initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
547       initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
548       Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
549       Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
550       Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); 
551       myDX = 0.0;
552       Group3Spin->SpinBox_DX->setValue( myDX );
553       myDY = 0.0;
554       Group3Spin->SpinBox_DY->setValue( myDY );
555       myRadius=0.0;
556       Group3Spin->SpinBox_DZ->setValue( myRadius ); 
557       Group3Spin->show();
558       Group3Spin->buttonApply->setFocus();
559
560       GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
561     }
562     else if ( constructorId == 2 ){   // Point + center
563       mySketchType = PT_ABS_CENTER;
564       initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); 
565       initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
566       initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
567       initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
568       Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
569       Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
570       Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
571       Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) ); 
572       myDX = 0.0;
573       Group4Spin->SpinBox_DX->setValue( myDX );
574       myDY = 0.0;
575       Group4Spin->SpinBox_DY->setValue( myDY );
576       myXc = 0.0;
577       Group4Spin->SpinBox_DZ->setValue( myXc ); 
578       myYc = 0.0;
579       Group4Spin->SpinBox_DS->setValue( myYc );
580       Group4Spin->show();
581       Group4Spin->buttonApply->setFocus();
582
583       GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
584     }
585
586   }
587   else if ( myConstructorPntId == 0 ) {  // DXDY
588     if ( constructorId == 1 ){    // No additional parameter
589       mySketchType = PT_RELATIVE;
590       initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
591       initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
592       Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
593       Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
594       myDX = 0.0;
595       Group2Spin->SpinBox_DX->setValue( myDX );
596       myDY = 0.0;
597       Group2Spin->SpinBox_DY->setValue( myDY );
598       Group2Spin->show();
599       Group2Spin->buttonApply->setFocus();
600
601       GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
602     }
603     else if ( constructorId == 0 ){   // Point + radius 
604       mySketchType = PT_REL_RADIUS;
605       initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); 
606       initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
607       initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
608       Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
609       Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
610       Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); 
611       myDX = 10.0;
612       Group3Spin->SpinBox_DX->setValue( myDX );
613       myDY = 0.0;
614       Group3Spin->SpinBox_DY->setValue( myDY );
615       myRadius=5.0;
616       Group3Spin->SpinBox_DZ->setValue( myRadius );
617       Group3Spin->show();
618       Group3Spin->buttonApply->setFocus();
619
620       GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
621     }
622     else if ( constructorId == 2 ){   // Point + center
623       mySketchType = PT_REL_CENTER;
624       initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); 
625       initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
626       initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
627       initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
628       Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
629       Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
630       Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
631       Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) ); 
632       myDX = 0.0;
633       Group4Spin->SpinBox_DX->setValue( myDX );
634       myDY = 0.0;
635       Group4Spin->SpinBox_DY->setValue( myDY );
636       myDXc = 0.0;
637       Group4Spin->SpinBox_DZ->setValue( myDXc ); 
638       myDYc = 0.0;
639       Group4Spin->SpinBox_DS->setValue( myDYc );
640       Group4Spin->show();
641       Group4Spin->buttonApply->setFocus();
642
643       GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
644     }
645
646   }
647   else if ( myConstructorPntId == 2 ) {  // Selection
648     if ( constructorId == 1 ){    // No additional parameter
649       mySketchType = PT_SEL;
650       myEditCurrentArgument = Group1Sel->LineEdit1;
651       Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) ); 
652       Group1Sel->show();
653       Group1Sel->buttonApply->setFocus();
654       SelectionIntoArgument();
655     }
656     else if ( constructorId == 0 ){   // Point + radius 
657       mySketchType = PT_SEL_RADIUS;
658       myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
659       initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
660       Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) ); 
661       Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); 
662       myRadius=0.0;
663       Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
664
665       Group1Sel1Spin->show();
666       Group1Sel1Spin->buttonApply->setFocus();
667       SelectionIntoArgument();
668     }
669     else if ( constructorId == 2 ){   // Point + center 
670       mySketchType = PT_SEL_CENTER;
671       myEditCurrentArgument = Group2Sel->LineEdit1;
672       Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );  
673       Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
674       Group2Sel->LineEdit1->setEnabled(true);
675       Group2Sel->PushButton1->setDown(true);
676       Group2Sel->LineEdit2->setEnabled(false);
677       Group2Sel->PushButton2->setDown(false);
678       Group2Sel->show();
679       Group2Sel->buttonApply->setFocus();
680       SelectionIntoArgument();
681     }
682
683   }
684   connect( myGeometryGUI->getApp()->selectionMgr(),
685            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
686   
687 }
688
689
690 //=================================================================================
691 // function : Dir1Clicked()
692 // purpose  : Radio button management
693 //=================================================================================
694 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
695 {
696   myConstructorDirId = constructorId;
697   GroupD2->RB_Dir21->setChecked( true );
698   Dir2Clicked( 2 );
699 }
700
701
702 //=================================================================================
703 // function : Dir2Clicked()
704 // purpose  : Radio button management
705 //=================================================================================
706 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
707 {
708   InitClick();
709   myAngle = 0.0;
710
711   // Get setting of step value from file configuration
712   double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
713
714   if ( myConstructorId == 0 ) {  // SEGMENT
715     myX = 0.0;
716     myY = 0.0;
717     myLength = 100.0;
718     if ( myConstructorDirId == 2 ) {  // Angle
719       initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
720       Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
721       Group2Spin->SpinBox_DX->setValue( myAngle );
722       Group2Spin->buttonApply->setFocus();
723       Group2Spin->show();
724
725       if ( constructorId == 2 ) {  // Length
726         mySketchType = DIR_ANGLE_LENGTH;
727         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
728         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
729         Group2Spin->SpinBox_DY->setValue( myLength );
730       }
731       else if ( constructorId == 0 ) {  // X
732         mySketchType = DIR_ANGLE_X;
733         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
734         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
735         Group2Spin->SpinBox_DY->setValue( myX );
736       }
737       else if ( constructorId == 1 ) {  // Y
738         mySketchType = DIR_ANGLE_Y;
739         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );        
740         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
741         Group2Spin->SpinBox_DY->setValue( myY );
742       }
743     }
744     else if ( myConstructorDirId == 0 ) {  // Perpendicular
745       Group1Spin->show();
746       Group1Spin->buttonApply->setFocus();
747
748       if ( constructorId == 2 ) {  // Length
749         mySketchType = DIR_PER_LENGTH;
750         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
751         Group1Spin->SpinBox_DX->setValue( myLength );
752       }
753       else if ( constructorId == 0 ) {  // X
754         mySketchType = DIR_PER_X;
755         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
756         Group1Spin->SpinBox_DX->setValue( myX );
757       }
758       else if ( constructorId == 1 ) {  // Y
759         mySketchType = DIR_PER_Y;
760         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
761         Group1Spin->SpinBox_DX->setValue( myY );
762       }
763     }
764     else if ( myConstructorDirId == 1 ) {  // Tangent
765       Group1Spin->show();
766       Group1Spin->buttonApply->setFocus();
767
768       if ( constructorId == 2 ) {  // Length
769         mySketchType = DIR_TAN_LENGTH;
770         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
771         Group1Spin->SpinBox_DX->setValue( myLength );
772       }
773       else if ( constructorId == 0 ) {  // X
774         mySketchType = DIR_TAN_X;
775         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
776         Group1Spin->SpinBox_DX->setValue( myX );
777       }
778       else if ( constructorId == 1 ) {  // Y
779         mySketchType = DIR_TAN_Y;
780         Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
781         Group1Spin->SpinBox_DX->setValue( myY );
782       }
783     }
784     else if ( myConstructorDirId == 3 ) {  // DXDY
785       initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
786       initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
787       initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
788       Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
789       Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
790       myDX = 0.0;
791       Group3Spin->SpinBox_DX->setValue( myDX );
792       myDY = 0.0;
793       Group3Spin->SpinBox_DY->setValue( myDY );
794       Group3Spin->show();
795       Group3Spin->buttonApply->setFocus();
796
797       if ( constructorId == 2 ) {  // Length
798         mySketchType = DIR_DXDY_LENGTH;
799         Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
800         Group3Spin->SpinBox_DZ->setValue( myLength );
801       }
802       else if ( constructorId == 0 ) { // X
803         mySketchType = DIR_DXDY_X;
804         Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
805         Group3Spin->SpinBox_DZ->setValue( myX );
806       }
807       else if ( constructorId == 1 ) {  // Y
808         mySketchType = DIR_DXDY_Y;
809         Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
810         Group3Spin->SpinBox_DZ->setValue( myY );
811       }
812     }
813   }
814   else if ( myConstructorId == 1 ) {  // ARC
815     if ( myConstructorDirId == 2 ) {  // Angle
816       if ( constructorId == 2 ) {  // Length
817         mySketchType = DIR_ANGLE_LENGTH;
818         initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
819         initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
820         initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
821         Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
822         Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
823         Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
824         Group3Spin->SpinBox_DX->setValue( myAngle );
825         myRadius = 100.0;
826         Group3Spin->SpinBox_DY->setValue( myRadius );
827         myLength = 30.0;
828         Group3Spin->SpinBox_DZ->setValue( myLength );
829         Group3Spin->show();
830         Group3Spin->buttonApply->setFocus();
831       }
832     }
833     else if ( myConstructorDirId == 0 ) {  // Perpendicular
834       if ( constructorId == 2 ) {  // Length
835         mySketchType = DIR_PER_LENGTH;
836         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
837         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
838         Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
839         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
840         myRadius = 100.0;
841         Group2Spin->SpinBox_DX->setValue( myRadius );
842         myLength = 30.0;
843         Group2Spin->SpinBox_DY->setValue( myLength );
844         Group2Spin->show();
845         Group2Spin->buttonApply->setFocus();
846       }
847     }
848     else if ( myConstructorDirId == 1 ) {  // Tangent
849       if ( constructorId == 2 ) {  // Length
850         mySketchType = DIR_TAN_LENGTH;
851         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
852         initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
853         Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
854         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
855         myRadius = 100.0;
856         Group2Spin->SpinBox_DX->setValue( myRadius );
857         myLength = 30.0;
858         Group2Spin->SpinBox_DY->setValue( myLength );
859         Group2Spin->show();
860         Group2Spin->buttonApply->setFocus();
861       }
862     }
863     else if ( myConstructorDirId == 3 ) {  // DXDY
864       if ( constructorId == 2 ) {  // Length
865         mySketchType = DIR_DXDY_LENGTH;
866         Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
867         Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
868         Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
869         Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
870         initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
871         initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
872         initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
873         initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
874         myDX = 0.0;
875         Group4Spin->SpinBox_DX->setValue( myDX );
876         myDY = 0.0;
877         Group4Spin->SpinBox_DY->setValue( myDY );
878         myRadius = 100.0;
879         Group4Spin->SpinBox_DZ->setValue( myRadius );
880         myLength = 30.0;
881         Group4Spin->SpinBox_DS->setValue( myLength );
882         Group4Spin->show();
883         Group4Spin->buttonApply->setFocus();
884       }
885     }
886   }
887
888   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
889 }
890
891 //=================================================================================
892 // function : CheckBoxClicked()
893 // purpose  : CheckBox  management
894 //=================================================================================
895 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
896 {
897   myCheckFlag = State;
898
899   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
900 }
901
902
903 //=================================================================================
904 // function : ClickOnCancel()
905 // purpose  :
906 //=================================================================================
907 void EntityGUI_SketcherDlg::ClickOnCancel()
908 {
909   close();
910 }
911
912
913 //=================================================================================
914 // function : ClickOnEnd()
915 // purpose  : connected to buttonEnd AND buttonClose
916 //=================================================================================
917 void EntityGUI_SketcherDlg::ClickOnEnd()
918 {
919   if ( sender() == MainWidget->buttonClose ) {
920     // Verify validity of commands
921     if ( myCommand.count() <= 2 ) {
922       SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
923                                  tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
924       return;
925     }
926
927     QString Parameters;
928     QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
929     Sketcher_Profile aProfile( Command.toAscii() );
930
931     Command = myCommand.join( "" );
932     aProfile = Sketcher_Profile( Command.toAscii() );
933     TopoDS_Shape myShape;
934     if ( aProfile.IsDone() )
935       myShape = aProfile.GetShape();
936
937     if ( myShape.ShapeType() != TopAbs_VERTEX )
938       myCommand.append( ":WW" );
939   }
940   else {
941     // PAL16008 (Sketcher Validation should be equal to Apply&Close)
942     if ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ||
943          Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ||
944          Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ||
945          Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ||
946          Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible()  ||
947          Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible()  ||
948          Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() )  {     
949       ClickOnApply();
950     }
951     myIsAllAdded = true;
952   }
953
954   if ( myCommand.size() > 2 )
955     if ( !onAccept() )
956       return;
957
958   close();
959 }
960
961 //=================================================================================
962 // function : ClickOnApply()
963 // purpose  :
964 //=================================================================================
965 bool EntityGUI_SketcherDlg::ClickOnApply()
966 {
967   if ( sender() && sender()->inherits( "QPushButton" ) )
968     ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
969
970   QString aParameters;
971   myCommand.append( GetNewCommand( aParameters ) );
972   mySketchState = NEXT_POINT;
973
974   myUndoCommand.clear();
975   myUndoCommand.append( "Sketcher" );
976
977   myParameters.append( aParameters );
978   myUndoParameters.clear();
979
980   MainWidget->GroupConstructors->setEnabled( true );
981   MainWidget->GroupDest1->setEnabled( true );
982   setEnabledUndo( true );
983   setEnabledRedo( false );
984
985   myIsApply = true;
986   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
987   myIsApply = false;
988
989   // Set focus to SpinBox_DX
990   if ( sender() == Group1Spin->buttonApply ) {
991     (Group1Spin->SpinBox_DX)->setFocus();
992     (Group1Spin->SpinBox_DX)->selectAll();
993   }
994   else if ( sender() == Group1Sel1Spin->buttonApply ) {
995     (Group1Sel1Spin->SpinBox_DX)->setFocus();
996     (Group1Sel1Spin->SpinBox_DX)->selectAll();
997   }
998   else if ( sender() == Group2Spin->buttonApply ) {
999     (Group2Spin->SpinBox_DX)->setFocus();
1000     (Group2Spin->SpinBox_DX)->selectAll();
1001   }
1002   else if ( sender() == Group3Spin->buttonApply ) {
1003     (Group3Spin->SpinBox_DX)->setFocus();
1004     (Group3Spin->SpinBox_DX)->selectAll();
1005   }
1006   else if ( sender() == Group4Spin->buttonApply ) {
1007     (Group4Spin->SpinBox_DX)->setFocus();
1008     (Group4Spin->SpinBox_DX)->selectAll();
1009   }
1010
1011   return true;
1012 }
1013
1014 //=================================================================================
1015 // function : ClickOnHelp()
1016 // purpose  :
1017 //=================================================================================
1018 void EntityGUI_SketcherDlg::ClickOnHelp()
1019 {
1020   LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1021   if ( app )
1022     app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1023   else {
1024     QString platform;
1025 #ifdef WIN32
1026     platform = "winapplication";
1027 #else
1028     platform = "application";
1029 #endif
1030
1031     SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1032                               QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1033                               arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1034                               QObject::tr( "BUT_OK" ) );
1035   }
1036 }
1037
1038 //=================================================================================
1039 // function : ClickOnUndo()
1040 // purpose  :
1041 //=================================================================================
1042 void EntityGUI_SketcherDlg::ClickOnUndo()
1043 {
1044   myUndoCommand.append( myCommand.last() );
1045   myCommand.pop_back();
1046
1047   myUndoParameters.append( myParameters.last() );
1048   myParameters.pop_back();
1049
1050   if ( myCommand.count() == 1 ) {
1051     mySketchState = FIRST_POINT;
1052
1053     MainWidget->RadioButton1->setChecked( true );
1054     TypeClicked( 0 );
1055
1056     connect( myGeometryGUI->getApp()->selectionMgr(),
1057              SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1058
1059     MainWidget->GroupConstructors->setEnabled( false );
1060     MainWidget->GroupDest1->setEnabled( false );
1061     setEnabledUndo( false );
1062   }
1063
1064   setEnabledRedo( true );
1065
1066   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1067 }
1068
1069 //=================================================================================
1070 // function : ClickOnRedo()
1071 // purpose  :
1072 //=================================================================================
1073 void EntityGUI_SketcherDlg::ClickOnRedo()
1074 {
1075   myCommand.append( myUndoCommand.last() );
1076   myUndoCommand.pop_back();
1077
1078   myParameters.append( myUndoParameters.last() );
1079   myUndoParameters.pop_back();
1080
1081   mySketchState = NEXT_POINT;
1082
1083   MainWidget->GroupConstructors->setEnabled( true );
1084   MainWidget->GroupDest1->setEnabled( true );
1085   setEnabledUndo( true );
1086
1087   if ( myUndoCommand.count() == 1 )
1088     setEnabledRedo( false );
1089
1090   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1091 }
1092
1093 //=================================================================================
1094 // function : setEnabledUndo()
1095 // purpose  :
1096 //=================================================================================
1097 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1098 {
1099   Group1Sel->buttonUndo->setEnabled( value );
1100   Group2Sel->buttonUndo->setEnabled( value );
1101   Group1Sel1Spin->buttonUndo->setEnabled( value );
1102   Group1Spin->buttonUndo->setEnabled( value );
1103   Group2Spin->buttonUndo->setEnabled( value );
1104   Group3Spin->buttonUndo->setEnabled( value );
1105   Group4Spin->buttonUndo->setEnabled( value );
1106 }
1107
1108 //=================================================================================
1109 // function : setEnabledRedo()
1110 // purpose  :
1111 //=================================================================================
1112 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1113 {
1114   Group1Sel->buttonRedo->setEnabled( value );
1115   Group2Sel->buttonRedo->setEnabled( value );
1116   Group1Sel1Spin->buttonRedo->setEnabled( value );
1117   Group1Spin->buttonRedo->setEnabled( value );
1118   Group2Spin->buttonRedo->setEnabled( value );
1119   Group3Spin->buttonRedo->setEnabled( value );
1120   Group4Spin->buttonRedo->setEnabled( value );
1121 }
1122
1123 //=================================================================================
1124 // function : SelectionIntoArgument()
1125 // purpose  : Called when selection as changed
1126 //=================================================================================
1127 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1128 {
1129   myEditCurrentArgument->setText( "" );
1130   double tmpX = myX;
1131   double tmpY = myY;
1132   myX = myLastX1;
1133   myY = myLastY1;
1134   //  printf ("\nmyX = %f         myY = %f", myX, myY);
1135   //  printf ("\nmyLastX1 = %f    myLastY1 = %f", myLastX1, myLastY1);
1136   //  printf ("\nmyLastX2 = %f    myLastY2 = %f", myLastX2, myLastY2);
1137
1138   if ( sender() == ComboBox1 )
1139       ActivateLocalCS();
1140
1141   LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1142   SALOME_ListIO aSelList;
1143   aSelMgr->selectedObjects(aSelList);
1144
1145   int nbSel = aSelList.Extent();
1146   if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1147     Standard_Boolean aRes = Standard_False;
1148     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
1149     if (!CORBA::is_nil(aSelectedObject) && aRes) {
1150       TopoDS_Shape aShape;
1151       if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1152         gp_Trsf aTrans;
1153         gp_Ax3 aWPlane = GetActiveLocalCS();
1154
1155         aTrans.SetTransformation(aWPlane);
1156         BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1157         aShape = aTransformation.Shape();
1158
1159         gp_Pnt aPnt;
1160         if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1161           myX = aPnt.X();
1162           myY = aPnt.Y();
1163           Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1164           if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1165             disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1166             disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1167             Group2Spin->SpinBox_DX->setValue(myX);
1168             Group2Spin->SpinBox_DY->setValue(myY);
1169             connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1170             connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1171           } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1172             if ( myLastX1 && myLastY1 ) {
1173               Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1174               Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1175             } else {
1176               if ( mySketchState != FIRST_POINT ) {
1177                 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1178                 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1179               } else {
1180                 Group2Spin->SpinBox_DX->setValue(myX);
1181                 Group2Spin->SpinBox_DY->setValue(myY);
1182               }
1183             }
1184           }
1185         }
1186       }
1187     }
1188   }
1189
1190   if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1191     Standard_Boolean aRes = Standard_False;
1192     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
1193     if (!CORBA::is_nil(aSelectedObject) && aRes) {
1194       TopoDS_Shape aShape;
1195       if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1196         gp_Trsf aTrans;
1197         gp_Ax3 aWPlane = GetActiveLocalCS();
1198
1199         aTrans.SetTransformation(aWPlane);
1200         BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1201         aShape = aTransformation.Shape();
1202
1203         gp_Pnt aPnt;
1204         if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1205           myX = aPnt.X();
1206           myY = aPnt.Y();
1207           Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1208           if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1209             disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1210             disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1211             Group3Spin->SpinBox_DX->setValue(myX);
1212             Group3Spin->SpinBox_DY->setValue(myY);
1213             connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1214             connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1215           } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1216             if ( myLastX1 && myLastY1 ) {
1217               Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1218               Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1219             } else {
1220               if ( mySketchState != FIRST_POINT ) {
1221                 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1222                 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1223               } else {
1224                 Group3Spin->SpinBox_DX->setValue(myX);
1225                 Group3Spin->SpinBox_DY->setValue(myY);
1226               }
1227             }
1228           }
1229         }
1230       }
1231     }
1232   }
1233
1234   if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1235     Standard_Boolean aRes = Standard_False;
1236     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
1237     if (!CORBA::is_nil(aSelectedObject) && aRes) {
1238       TopoDS_Shape aShape;
1239       if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1240         gp_Trsf aTrans;
1241         gp_Ax3 aWPlane = GetActiveLocalCS();
1242
1243         aTrans.SetTransformation(aWPlane);
1244         BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1245         aShape = aTransformation.Shape();
1246
1247         gp_Pnt aPnt;
1248         if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1249           myX = aPnt.X();
1250           myY = aPnt.Y();
1251           Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1252           if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1253             disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1254             disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1255             Group4Spin->SpinBox_DX->setValue(myX);
1256             Group4Spin->SpinBox_DY->setValue(myY);
1257             connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1258             connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1259           } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1260             if ( myLastX1 && myLastY1 ) {
1261               Group4Spin->SpinBox_DX->setValue(myX - myLastX1);
1262               Group4Spin->SpinBox_DY->setValue(myY - myLastY1);
1263             } else {
1264               if ( mySketchState != FIRST_POINT ) {
1265                 Group4Spin->SpinBox_DX->setValue(myX - tmpX);
1266                 Group4Spin->SpinBox_DY->setValue(myY - tmpY);
1267               } else {
1268                 Group4Spin->SpinBox_DX->setValue(myX);
1269                 Group4Spin->SpinBox_DY->setValue(myY);
1270               }
1271             }
1272           }
1273         }
1274       }
1275     }
1276   }
1277
1278   if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1279     if (!Group2Sel->LineEdit1->text().isEmpty()){    //Check wether or not Linedit2 has been modified
1280       myX=tmpX;                                      // If yes keep the old values of X and Y  
1281       myY=tmpY;
1282     }
1283     Standard_Boolean aRes = Standard_False;
1284     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
1285     if (!CORBA::is_nil(aSelectedObject) && aRes) {
1286       TopoDS_Shape aShape;
1287       if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1288         gp_Trsf aTrans;
1289         gp_Ax3 aWPlane = GetActiveLocalCS();
1290
1291         aTrans.SetTransformation(aWPlane);
1292         BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1293         aShape = aTransformation.Shape();
1294
1295         gp_Pnt aPnt;
1296         if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1297           myXc = aPnt.X();
1298           myYc = aPnt.Y();
1299           Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1300           if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1301             disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1302             disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1303             Group4Spin->SpinBox_DZ->setValue(myXc);
1304             Group4Spin->SpinBox_DS->setValue(myYc);
1305             connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1306             connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1307           } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1308             if ( myLastX1 && myLastY1 ) {
1309               Group4Spin->SpinBox_DZ->setValue(myXc - myLastX1);
1310               Group4Spin->SpinBox_DS->setValue(myYc - myLastY1);
1311             } else {
1312               if ( mySketchState != FIRST_POINT ) {
1313                 Group4Spin->SpinBox_DZ->setValue(myXc - tmpX);
1314                 Group4Spin->SpinBox_DS->setValue(myYc - tmpY);
1315               } else {
1316                 Group4Spin->SpinBox_DZ->setValue(myXc);
1317                 Group4Spin->SpinBox_DS->setValue(myYc);
1318               }
1319             }
1320           }
1321         }
1322       }
1323     }
1324   }
1325
1326
1327
1328   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1329 }
1330
1331
1332 //=================================================================================
1333 // function : SetEditCurrentArgument()
1334 // purpose  :
1335 //=================================================================================
1336 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1337 {
1338   if ( sender() == Group1Sel->PushButton1 ) {
1339     myEditCurrentArgument = Group1Sel->LineEdit1;
1340     myEditCurrentArgument->setFocus();
1341   }
1342   else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1343     myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1344     myEditCurrentArgument->setFocus();
1345   }
1346   else if ( sender() == Group2Sel->PushButton1 ) {
1347     myEditCurrentArgument = Group2Sel->LineEdit1;
1348     Group2Sel->PushButton2->setDown(false);
1349     Group2Sel->PushButton1->setDown(true);
1350     Group2Sel->LineEdit2->setEnabled(false);
1351     Group2Sel->LineEdit1->setEnabled(true);
1352    // myEditCurrentArgument->setFocus();
1353   }
1354    else if ( sender() == Group2Sel->PushButton2 ) {
1355     myEditCurrentArgument = Group2Sel->LineEdit2;
1356     Group2Sel->PushButton1->setDown(false);
1357     Group2Sel->PushButton2->setDown(true);
1358     Group2Sel->LineEdit1->setEnabled(false);
1359     Group2Sel->LineEdit2->setEnabled(true);
1360    // myEditCurrentArgument->setFocus();
1361   }
1362   SelectionIntoArgument();
1363 }
1364
1365
1366 //=================================================================================
1367 // function : LineEditReturnPressed()
1368 // purpose  :
1369 //=================================================================================
1370 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1371 {
1372   if ( sender() == Group1Sel->LineEdit1 ) 
1373     myEditCurrentArgument = Group1Sel->LineEdit1;
1374   else if ( sender() == Group1Sel1Spin->LineEdit1 ) 
1375      myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1376   else if ( sender() == Group2Sel->LineEdit1 ) 
1377      myEditCurrentArgument = Group2Sel->LineEdit1;
1378   else if ( sender() == Group2Sel->LineEdit2 )
1379      myEditCurrentArgument = Group2Sel->LineEdit2;
1380
1381   /* User name of object input management                          */
1382   /* If successfull the selection is changed and signal emitted... */
1383   /* so SelectionIntoArgument() is automatically called.           */
1384   const QString objectUserName = myEditCurrentArgument->text();
1385   QWidget* thisWidget = (QWidget*)this;
1386
1387   LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1388   SALOME_ListIO aSelList;
1389   aSelMgr->selectedObjects(aSelList);
1390
1391   if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1392     myEditCurrentArgument->setText( objectUserName );
1393 }
1394
1395
1396 //=================================================================================
1397 // function : DeactivateActiveDialog()
1398 // purpose  :
1399 //=================================================================================
1400 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1401 {
1402   //myGeometryGUI->SetState( -1 );
1403
1404   setEnabled( false );
1405   globalSelection();
1406   disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1407   myGeometryGUI->SetActiveDialogBox( 0 );
1408 }
1409
1410
1411 //=================================================================================
1412 // function : ActivateThisDialog()
1413 // purpose  :
1414 //=================================================================================
1415 void EntityGUI_SketcherDlg::ActivateThisDialog()
1416 {
1417   myGeometryGUI->EmitSignalDeactivateDialog();
1418   setEnabled( true );
1419   myGeometryGUI->SetActiveDialogBox( this );
1420
1421   connect( myGeometryGUI->getApp()->selectionMgr(),
1422           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1423
1424   //myGeometryGUI->SetState( 0 );
1425   globalSelection( GEOM_POINT );
1426   
1427   myEditCurrentArgument = Group1Sel->LineEdit1;
1428   myEditCurrentArgument->setFocus();
1429   
1430    if ( sender() == Group1Sel->LineEdit1 ) {
1431      myEditCurrentArgument = Group1Sel->LineEdit1;
1432      myEditCurrentArgument->setFocus();
1433    }
1434    else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1435      myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1436      myEditCurrentArgument->setFocus();
1437    }
1438    else if ( sender() == Group2Sel->LineEdit1 ) {
1439      myEditCurrentArgument = Group2Sel->LineEdit1;
1440      myEditCurrentArgument->setFocus();
1441    }
1442     else if ( sender() == Group2Sel->LineEdit2 ) {
1443      myEditCurrentArgument = Group2Sel->LineEdit2;
1444      myEditCurrentArgument->setFocus();
1445    }
1446
1447   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1448 }
1449
1450
1451 //=================================================================================
1452 // function : enterEvent [REDEFINED]
1453 // purpose  :
1454 //=================================================================================
1455 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1456 {
1457   if ( !isEnabled() )
1458     ActivateThisDialog();
1459 }
1460
1461
1462 //=================================================================================
1463 // function : closeEvent()
1464 // purpose  :
1465 //=================================================================================
1466 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1467 {
1468   //myGeometryGUI->SetState( -1 );
1469   disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1470   myGeometryGUI->getApp()->updateActions();
1471   QDialog::closeEvent( e );
1472 }
1473
1474
1475 //=================================================================================
1476 // function : ValueChangedInSpinBox()
1477 // purpose  :
1478 //=================================================================================
1479 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1480 {
1481   QObject* send = (QObject*)sender();
1482   Standard_Real vx, vy, vz, vs, minRad;
1483   vx = vy = vz = vs = minRad =0.0;
1484
1485   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1486   int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1487   double LastDecimal = 0.0;
1488
1489   QString vxStr, vyStr, vzStr, vsStr;
1490
1491   QString newValueStr;
1492   if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1493     newValueStr = aDoubleSpinBox->text();
1494
1495   if ( send == Group1Spin->SpinBox_DX ) {
1496     vx = newValue;                        vxStr = newValueStr;
1497   }
1498   else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1499     vx = newValue;                        vxStr = newValueStr;
1500   }
1501   else if ( send == Group2Spin->SpinBox_DX ) {
1502     vx = newValue;                        vxStr = newValueStr;
1503     vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1504   }
1505   else if ( send == Group2Spin->SpinBox_DY ) {
1506     vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1507     vy = newValue;                        vyStr = newValueStr;
1508   }
1509   else if ( send == Group3Spin->SpinBox_DX ) {
1510     vx = newValue;                        vxStr = newValueStr;
1511     vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1512     vz = Group3Spin->SpinBox_DZ->value();
1513     if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {  
1514       minRad = 0.5 * Sqrt(vx * vx + vy * vy);                             //Computation of the minimum acceptable radius for the arc calculation
1515       if (aPrecision >= 0)    // 'f' format in the QString             
1516         LastDecimal = aPrecision;
1517       else                    // 'g' format in the Qstring
1518         LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) ); 
1519       minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal);  // Rounded up at the last allowed decimal place
1520       if ( Abs(vz) < minRad){
1521         if (vz < 0.0)
1522           Group3Spin->SpinBox_DZ->setValue( - minRad );
1523         else 
1524            Group3Spin->SpinBox_DZ->setValue( minRad );
1525       }
1526     }
1527     vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1528   }
1529   else if ( send == Group3Spin->SpinBox_DY ) {
1530     vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1531     vy = newValue;                        vyStr = newValueStr;
1532     vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1533     if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){  
1534       minRad = 0.5 * Sqrt(vx * vx + vy * vy);                            //Computation of the minimum acceptable radius for the arc calculation
1535       if (aPrecision >= 0)    // 'f' format in the QString 
1536         LastDecimal = aPrecision;
1537       else                    // 'g' format in the QString 
1538         LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) ); 
1539       minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1540       if ( Abs(vz) < minRad){
1541         if (vz < 0.0)
1542           Group3Spin->SpinBox_DZ->setValue( - minRad );
1543         else 
1544            Group3Spin->SpinBox_DZ->setValue( minRad );
1545       }
1546     }
1547     vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1548   }
1549   else if ( send == Group3Spin->SpinBox_DZ ) {
1550     vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1551     vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1552     vz = newValue;                        vzStr = newValueStr;
1553   }
1554   else if ( send == Group4Spin->SpinBox_DX ) {
1555     vx = newValue;                        vxStr = newValueStr;
1556     vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1557     vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1558     vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1559   }
1560   else if ( send == Group4Spin->SpinBox_DY ) {
1561     vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1562     vy = newValue;                        vyStr = newValueStr;
1563     vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1564     vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1565   }
1566   else if ( send == Group4Spin->SpinBox_DZ ) {
1567     vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1568     vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1569     vz = newValue;                        vzStr = newValueStr;
1570     vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1571   }
1572   else if ( send == Group4Spin->SpinBox_DS ) {
1573     vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1574     vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1575     vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1576     vs = newValue;                        vsStr = newValueStr;
1577   }
1578   // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1579
1580   if ( myConstructorId == 0 ) {  // SEGMENT
1581     if ( mySketchType == PT_ABS ) {
1582       myX = vx;
1583       myY = vy;
1584       myXStr = vxStr;
1585       myYStr = vyStr;
1586     }
1587     else if ( mySketchType == PT_RELATIVE ) {
1588       myDX = vx;
1589       myDY = vy;
1590       myDXStr = vxStr;
1591       myDYStr = vyStr;
1592     }
1593     else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1594       myAngle = vx;
1595       myLength = vy;
1596       myAngleStr = vxStr;
1597       myLengthStr = vyStr;
1598     }
1599     else if ( mySketchType == DIR_ANGLE_X ) {
1600       myAngle = vx;
1601       myX = vy;
1602       myAngleStr = vxStr;
1603       myXStr = vyStr;
1604     }
1605     else if ( mySketchType == DIR_ANGLE_Y ) {
1606       myAngle = vx;
1607       myY = vy;
1608       myAngleStr = vxStr;
1609       myYStr = vyStr;
1610     }
1611     else if ( mySketchType == DIR_PER_LENGTH ) {
1612       myLength = vx;
1613       myLengthStr = vxStr;
1614     }
1615     else if ( mySketchType == DIR_PER_X ) {
1616       myX = vx;
1617       myXStr = vxStr;
1618     }
1619     else if ( mySketchType == DIR_PER_Y ) {
1620       myY = vx;
1621       myYStr = vxStr;
1622     }
1623     else if ( mySketchType == DIR_TAN_LENGTH ) {
1624       myLength = vx;
1625       myLengthStr = vxStr;
1626     }
1627     else if ( mySketchType == DIR_TAN_X ) {
1628       myX = vx;
1629       myXStr = vxStr;
1630     }
1631     else if ( mySketchType == DIR_TAN_Y ) {
1632       myY = vx;
1633       myYStr = vxStr;
1634     }
1635     else if ( mySketchType == DIR_DXDY_LENGTH ) {
1636       myDX = vx;
1637       myDY = vy;
1638       myLength = vz;
1639       myDXStr = vxStr;
1640       myDYStr = vyStr;
1641       myLengthStr = vzStr;
1642     }
1643     else if ( mySketchType == DIR_DXDY_X ) {
1644       myDX = vx;
1645       myDY = vy;
1646       myX = vz;
1647       myDXStr = vxStr;
1648       myDYStr = vyStr;
1649       myXStr = vzStr;
1650     }
1651     else if ( mySketchType == DIR_DXDY_Y ) {
1652       myDX = vx;
1653       myDY = vy;
1654       myY = vz;
1655       myDXStr = vxStr;
1656       myDYStr = vyStr;
1657       myYStr = vzStr;
1658     }
1659   }
1660   else if ( myConstructorId == 1 ) {  // ARC
1661     if ( mySketchType == PT_ABS ) {  
1662       myX = vx;
1663       myY = vy;
1664       myXStr = vxStr;
1665       myYStr = vyStr;
1666     }
1667     else if ( mySketchType == PT_RELATIVE ) {
1668       myDX = vx;
1669       myDY = vy;
1670       myDXStr = vxStr;
1671       myDYStr = vyStr;
1672     }
1673     if ( mySketchType == PT_ABS_RADIUS ) {  
1674       myX = vx;
1675       myY = vy;
1676       myRadius=vz;
1677       myXStr = vxStr;
1678       myYStr = vyStr;
1679       myRadiusStr = vzStr;
1680     }
1681     else if ( mySketchType == PT_REL_RADIUS ) {
1682       myDX = vx;
1683       myDY = vy;
1684       myRadius=vz;
1685       myDXStr = vxStr;
1686       myDYStr = vyStr;
1687       myRadiusStr = vzStr;
1688     }
1689     else if ( mySketchType == PT_SEL_RADIUS ) {
1690       myRadius = vx;
1691       myRadiusStr = vxStr;
1692     }
1693     if ( mySketchType == PT_ABS_CENTER ) {  
1694       myX = vx;
1695       myY = vy;
1696       myXc = vz;
1697       myYc = vs;
1698       myXStr = vxStr;
1699       myYStr = vyStr;
1700       myXcStr = vzStr;
1701       myYcStr = vsStr;
1702     }
1703     else if ( mySketchType == PT_REL_CENTER ) {
1704       myDX = vx;
1705       myDY = vy;
1706       myDXc = vz;
1707       myDYc = vs;
1708       myDXStr = vxStr;
1709       myDYStr = vyStr;
1710       myDXcStr = vzStr;
1711       myDYcStr = vsStr;
1712     }
1713     if ( mySketchType == DIR_ANGLE_LENGTH ) {
1714       myAngle = vx;
1715       myRadius = vy;
1716       myLength = vz;
1717       myAngleStr = vxStr;
1718       myRadiusStr = vyStr;
1719       myLengthStr = vzStr;
1720     }
1721     else if ( mySketchType == DIR_PER_LENGTH ) {
1722       myRadius = vx;
1723       myLength = vy;
1724       myRadiusStr = vxStr;
1725       myLengthStr = vyStr;
1726     }
1727     else if ( mySketchType == DIR_TAN_LENGTH ) {
1728       myRadius = vx;
1729       myLength = vy;
1730       myRadiusStr = vxStr;
1731       myLengthStr = vyStr;
1732     }
1733     else if ( mySketchType == DIR_DXDY_LENGTH ) {
1734       myDX = vx;
1735       myDY = vy;
1736       myRadius = vz;
1737       myLength = vs;
1738       myDXStr = vxStr;
1739       myDYStr = vyStr;
1740       myRadiusStr = vzStr;
1741       myLengthStr = vsStr;
1742     }
1743   }
1744
1745   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1746 }
1747
1748
1749 //=================================================================================
1750 // function : GetNewCommand()
1751 // purpose  : Build the new command with context
1752 //=================================================================================
1753 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1754 {
1755   theParameters.clear();
1756   QString myNewCommand = ":";
1757   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1758   int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1759   int DigNum = qAbs(aPrecision);                   // options for the format of numbers in  myNewCommand
1760   char Format = 'f';
1761   if ( aPrecision < 0 )                            // f --> DigNum is the number of digits after the decimal point
1762     Format = 'g';                                  // g --> DigNum is the maximum number of significant digits 
1763
1764   if ( mySketchState == FIRST_POINT ) {
1765     if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1766       myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1767       theParameters = myXStr + ":" + myYStr;
1768     }
1769     if ( mySketchType == PT_RELATIVE) {
1770       myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1771       theParameters = myDXStr + ":" + myDYStr;
1772     }
1773     return myNewCommand;
1774   }
1775
1776   if ( myConstructorId == 0  ) {  // SEGMENT
1777     if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1778       myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1779       theParameters = myXStr + ":" + myYStr;
1780     }
1781     if ( mySketchType == PT_RELATIVE) {
1782       myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1783       theParameters = myDXStr + ":" + myDYStr;
1784     }
1785     if ( mySketchType == DIR_ANGLE_LENGTH ) {
1786       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1787       myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1788       theParameters = myAngleStr + ":" + myLengthStr;
1789     }
1790     if ( mySketchType == DIR_ANGLE_X ) {
1791       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1792       myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1793       theParameters = myAngleStr + ":" + myXStr;
1794     }
1795     if ( mySketchType == DIR_ANGLE_Y ) {
1796       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1797       myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1798       theParameters = myAngleStr + ":" + myYStr;
1799     }
1800     if ( mySketchType == DIR_PER_LENGTH ) {
1801       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1802       myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1803       theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1804     }
1805     if ( mySketchType == DIR_PER_X ) {
1806       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1807       myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1808       theParameters = QString::number( 90.0 ) + ":" + myXStr;
1809     }
1810     if ( mySketchType == DIR_PER_Y ) {
1811       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1812       myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1813       theParameters = QString::number( 90.0 ) + ":" + myYStr;
1814     }
1815     if ( mySketchType == DIR_TAN_LENGTH ) {
1816       myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1817       theParameters = myLengthStr;
1818     }
1819     if ( mySketchType == DIR_TAN_X ) {
1820       myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1821       theParameters = myXStr;
1822     }
1823     if ( mySketchType == DIR_TAN_Y) {
1824       myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1825       theParameters = myYStr;
1826     }
1827     if ( mySketchType == DIR_DXDY_LENGTH ) {
1828       myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1829       myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1830       theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1831     }
1832     if ( mySketchType == DIR_DXDY_X ) {
1833       myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1834       myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1835       theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1836     }
1837     if ( mySketchType == DIR_DXDY_Y ) {
1838       myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1839       myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1840       theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1841     }
1842   }
1843   else if ( myConstructorId == 1 ) {  // ARC
1844     if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1845       myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1846       theParameters = myXStr + ":" + myYStr;
1847     }
1848     if ( mySketchType == PT_RELATIVE) {
1849       myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1850       theParameters = myDXStr + ":" + myDYStr;
1851     }
1852     if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1853       myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format,  DigNum)+ " " + QString::number( myCheckFlag );
1854       theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr; 
1855     }
1856     if ( mySketchType == PT_REL_RADIUS) {
1857       myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1858       theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;  
1859     }
1860     if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
1861       myNewCommand = myNewCommand + "EE " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myXc , Format,  DigNum) + " " + QString::number( myYc , Format,  DigNum)+ " " + QString::number( myCheckFlag ) + " " + QString::number( 0 );
1862       theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr; 
1863     }
1864     if ( mySketchType == PT_REL_CENTER) {
1865       myNewCommand = myNewCommand + "E " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myDXc, Format, DigNum )+ " " + QString::number( myDYc, Format, DigNum )+ " " + QString::number( myCheckFlag )+ " " + QString::number( 0 );
1866       theParameters = myDXStr + ":" + myDYStr + ":" +  myDXcStr + ":" + myDYcStr ;  
1867     }
1868     if ( mySketchType == DIR_ANGLE_LENGTH ) {
1869       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1870       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1871       theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1872     }
1873     if ( mySketchType == DIR_PER_LENGTH ) {
1874       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1875       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1876       theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
1877     }
1878     if ( mySketchType == DIR_TAN_LENGTH ) {
1879       myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1880       theParameters = myRadiusStr + ":" + myLengthStr;
1881     }
1882     if ( mySketchType == DIR_DXDY_LENGTH ) {
1883       myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1884       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1885       theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
1886     }
1887   }
1888   return myNewCommand;
1889 }
1890
1891 //=================================================================================
1892 // function : createOperation
1893 // purpose  :
1894 //=================================================================================
1895 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1896 {
1897   return getGeomEngine()->GetICurvesOperations( getStudyId() );
1898 }
1899
1900 //=================================================================================
1901 // function : isValid
1902 // purpose  :
1903 //=================================================================================
1904 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1905 {
1906   bool ok = true;
1907   bool toCorrect = !IsPreview() || myIsApply;
1908
1909   if( Group1Spin->isVisible() ) {
1910     ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1911   }
1912   else if( Group1Sel1Spin->isVisible() ) {
1913     ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1914   }
1915   else if( Group2Spin->isVisible() ) {
1916     ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1917     ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1918   }
1919   else if( Group3Spin->isVisible() ) {
1920     ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1921     ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1922     ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1923   }
1924   else if( Group4Spin->isVisible() ) {
1925     ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1926     ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1927     ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1928     ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
1929   }
1930
1931   if( myIsApply && !ok )
1932     showError( msg );
1933
1934   return ok;
1935 }
1936
1937 //=================================================================================
1938 // function : execute
1939 // purpose  :
1940 //=================================================================================
1941 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1942 {
1943   QString aParameters;
1944
1945   if ( mySketchState == FIRST_POINT ) {
1946     myLastX2 = myX;
1947     myLastY2 = myY;
1948   }
1949   else {
1950     //Test if the current point is the same as the last one
1951     TopoDS_Shape myShape1, myShape2;
1952
1953     // Set "C" numeric locale
1954     Kernel_Utils::Localizer loc;
1955
1956     //Last Shape
1957     QString Command1 = myCommand.join( "" );
1958     Sketcher_Profile aProfile1( Command1.toAscii() );
1959     if ( aProfile1.IsDone() )
1960       myShape1 = aProfile1.GetShape();
1961
1962     //Current Shape
1963     QString Command2 = Command1 + GetNewCommand( aParameters );
1964     Sketcher_Profile aProfile2( Command2.toAscii() );
1965
1966     //Error Message
1967     if ( mySketchType == PT_ABS_CENTER || 
1968          mySketchType == PT_REL_CENTER  ){
1969       Group4Spin->label->show();
1970       Group4Spin->label->setText(QString(aProfile2.ErrMsg().c_str()));
1971     }
1972     else 
1973       Group4Spin->label->hide();
1974     if ( mySketchType == PT_SEL_CENTER ){
1975       Group2Sel->label->show();
1976       Group2Sel->label->setText(QString(aProfile2.ErrMsg().c_str()));   
1977     }
1978     else 
1979       Group2Sel->label->hide();
1980
1981     if ( aProfile2.IsDone() )
1982       myShape2 = aProfile2.GetShape();
1983
1984     if ( myShape2.IsNull() ) {
1985       //the current point is the same as the last one
1986       myLastX2 = myLastX1;
1987       myLastY2 = myLastY1;
1988     }
1989     else {
1990       TopoDS_Vertex V1, V2;
1991       gp_Pnt pt;
1992       if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
1993         //the last shape is the first point
1994         pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
1995         myLastX1 = pt.X();
1996         myLastY1 = pt.Y();
1997       }
1998       else {
1999         TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2000         pt = BRep_Tool::Pnt( V2 );
2001         myLastX1 = pt.X();
2002         myLastY1 = pt.Y();
2003       }
2004       TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2005       pt = BRep_Tool::Pnt( V2 );
2006       myLastX2 = pt.X();
2007       myLastY2 = pt.Y();
2008     }
2009   }
2010
2011   QString cmd;
2012   if ( ( mySketchState != FIRST_POINT &&
2013          myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2014     cmd = myCommand.join( "" );
2015     if ( Group1Sel->isVisible() ) {
2016       Group1Sel->buttonApply->setEnabled( false );
2017       //Group1Sel->buttonApply->setFocus();
2018     }
2019     if ( Group2Sel->isVisible() ) {
2020       Group2Sel->buttonApply->setEnabled( false );
2021       //Group2Sel->buttonApply->setFocus();
2022     }
2023     if ( Group1Sel1Spin->isVisible() ) {
2024       Group1Sel1Spin->buttonApply->setEnabled( false );
2025       //Group1Sel1Spin->buttonApply->setFocus();
2026     }
2027     if ( Group1Spin->isVisible() ) {
2028       Group1Spin->buttonApply->setEnabled( false );
2029       //Group1Spin->buttonApply->setFocus();
2030     }
2031     if ( Group2Spin->isVisible() ) {
2032       Group2Spin->buttonApply->setEnabled( false );
2033       //Group2Spin->buttonApply->setFocus();
2034     }
2035     if ( Group3Spin->isVisible() ) {
2036       Group3Spin->buttonApply->setEnabled( false );
2037       //Group3Spin->buttonApply->setFocus();
2038     }
2039     if ( Group4Spin->isVisible() ) {
2040       Group4Spin->buttonApply->setEnabled( false );
2041       //Group4Spin->buttonApply->setFocus();
2042     }
2043   }
2044   else {
2045     cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2046
2047     if ( Group1Sel->isVisible() ) {
2048       Group1Sel->buttonApply->setEnabled( true );
2049       //Group1Sel->buttonApply->setFocus();
2050     }
2051     if ( Group2Sel->isVisible() ) {
2052       Group2Sel->buttonApply->setEnabled( true );
2053       //Group2Sel->buttonApply->setFocus();
2054     }
2055     if ( Group1Sel1Spin->isVisible() ) {
2056       Group1Sel1Spin->buttonApply->setEnabled( true );
2057       //Group1Sel1Spin->buttonApply->setFocus();
2058     }
2059     if ( Group1Spin->isVisible() ) {
2060       Group1Spin->buttonApply->setEnabled( true );
2061       //Group1Spin->buttonApply->setFocus();
2062     }
2063     if ( Group2Spin->isVisible() ) {
2064       Group2Spin->buttonApply->setEnabled( true );
2065       //Group2Spin->buttonApply->setFocus();
2066     }
2067     if ( Group3Spin->isVisible() ) {
2068       Group3Spin->buttonApply->setEnabled( true );
2069       //Group3Spin->buttonApply->setFocus();
2070     }
2071     if ( Group4Spin->isVisible() ) {
2072       Group4Spin->buttonApply->setEnabled( true );
2073       //Group4Spin->buttonApply->setFocus();
2074     }
2075   }
2076
2077   gp_Ax3 myWPlane = GetActiveLocalCS();
2078   GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2079   WPlane->length( 9 );
2080   WPlane[0] = myWPlane.Location().X();
2081   WPlane[1] = myWPlane.Location().Y();
2082   WPlane[2] = myWPlane.Location().Z();
2083
2084   WPlane[3] = myWPlane.Direction().X();
2085   WPlane[4] = myWPlane.Direction().Y();
2086   WPlane[5] = myWPlane.Direction().Z();
2087
2088   WPlane[6] = myWPlane.XDirection().X();
2089   WPlane[7] = myWPlane.XDirection().Y();
2090   WPlane[8] = myWPlane.XDirection().Z();
2091
2092   GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2093   GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2094
2095   if ( !anObj->_is_nil() )
2096   {
2097     if( !IsPreview() ) {
2098       QStringList aCurrentParameters = myParameters;
2099       aCurrentParameters << aParameters;
2100       anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2101     }
2102
2103     objects.push_back( anObj._retn() );
2104   }
2105
2106   return true;
2107 }
2108
2109 //================================================================
2110 // Function : displayPreview
2111 // Purpose  : Method for displaying preview of resulting shape
2112 //            Redefined from GEOMBase_Helper.
2113 //================================================================
2114 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2115                                             const bool            append,
2116                                             const bool            activate,
2117                                             const bool            update,
2118                                             const double          lineWidth,
2119                                             const int             displayMode,
2120                                             const int             color )
2121 {
2122   // Set color for preview shape
2123   getDisplayer()->SetColor( Quantity_NOC_RED );
2124
2125   // set width of displayed shape
2126   getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2127
2128   // Disable activation of selection
2129   getDisplayer()->SetToActivate( activate );
2130
2131   // Make a reference to GEOM_Object
2132   CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2133   getDisplayer()->SetName( objStr.in() );
2134
2135   // Create wire from applayed object
2136   TopoDS_Shape anApplyedWire, aLastSegment;
2137   if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2138     return;
2139
2140   // Build prs
2141   SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2142   if ( aPrs != 0 && !aPrs->IsNull() )
2143     GEOMBase_Helper::displayPreview( aPrs, append, update );
2144
2145   getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2146   aPrs = getDisplayer()->BuildPrs( aLastSegment );
2147   if ( aPrs != 0 && !aPrs->IsNull() )
2148     GEOMBase_Helper::displayPreview( aPrs, append, update );
2149
2150   getDisplayer()->UnsetName();
2151
2152   // Enable activation of displayed objects
2153   getDisplayer()->SetToActivate( true );
2154 }
2155
2156 //================================================================
2157 // Function : createShapes
2158 // Purpose  : Create applyed wire, and last segment from entry object
2159 //================================================================
2160 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2161                                           TopoDS_Shape&         theApplyedWire,
2162                                           TopoDS_Shape&         theLastSegment )
2163 {
2164   TopoDS_Shape aShape;
2165   if ( !GEOMBase::GetShape( theObject, aShape ) ||
2166        aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
2167     return false;
2168
2169   if ( Group1Sel->isVisible()  && !Group1Sel->buttonApply->isEnabled()  ||
2170        Group2Sel->isVisible()  && !Group2Sel->buttonApply->isEnabled()  ||
2171        Group1Sel1Spin->isVisible()  && !Group1Sel1Spin->buttonApply->isEnabled()  ||
2172        Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
2173        Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
2174        Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
2175        Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) {
2176      theApplyedWire = aShape;
2177      return true;
2178   }
2179
2180   BRepBuilderAPI_MakeWire aBuilder;
2181   TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2182   while ( 1 ) {
2183     TopoDS_Shape anEdge = anExp.Current();
2184     anExp.Next();
2185     if ( anExp.More() ) // i.e. non-last edge
2186       aBuilder.Add( TopoDS::Edge( anEdge ) );
2187     else {
2188       theLastSegment = anEdge;
2189       break;
2190     }
2191   }
2192
2193   if ( aBuilder.IsDone() )
2194     theApplyedWire = aBuilder.Shape();
2195
2196   return true;
2197 }
2198
2199 //=================================================================================
2200 // function : keyPressEvent()
2201 // purpose  :
2202 //=================================================================================
2203 void  EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2204 {
2205   QDialog::keyPressEvent( e );
2206   if ( e->isAccepted() )
2207     return;
2208
2209   if ( e->key() == Qt::Key_F1 ) {
2210     e->accept();
2211     ClickOnHelp();
2212   }
2213 }
2214
2215 //=================================================================================
2216 // function : initSpinBox()
2217 // purpose  :
2218 //=================================================================================
2219 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2220                                          double min,  double max,
2221                                          double step, const char* quantity )
2222 {
2223   // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2224   // TODO: Think how to keep the single piece of code...
2225
2226   // Obtain precision from preferences
2227   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2228   int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2229   
2230   spinBox->setPrecision( aPrecision );
2231   spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2232                                               // by default Qt rounds boundaries to 2 decimals at setRange
2233   spinBox->setRange( min, max );
2234   spinBox->setSingleStep( step );
2235   
2236   // Add a hint for the user saying how to tune precision
2237   QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2238   spinBox->setProperty( "validity_tune_hint", 
2239                         QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2240 }
2241
2242 //=================================================================================
2243 // function : SetDoubleSpinBoxStep()
2244 // purpose  : Double spin box management
2245 //=================================================================================
2246 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2247 {
2248   Group1Spin->SpinBox_DX->setSingleStep(step);
2249   Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2250   Group2Spin->SpinBox_DX->setSingleStep(step);
2251   Group2Spin->SpinBox_DY->setSingleStep(step);
2252   Group3Spin->SpinBox_DX->setSingleStep(step);
2253   Group3Spin->SpinBox_DY->setSingleStep(step);
2254   Group3Spin->SpinBox_DZ->setSingleStep(step);
2255   Group4Spin->SpinBox_DZ->setSingleStep(step);
2256
2257   // san: Do NOT override the step when a speicifc step value is used
2258   // in some input fields!
2259   //Group4Spin->SpinBox_DX->setSingleStep(step);
2260   //Group4Spin->SpinBox_DY->setSingleStep(step);
2261   //Group4Spin->SpinBox_DS->setSingleStep(step);
2262 }
2263
2264 //=================================================================================
2265 // function : FindLocalCS()
2266 // purpose  : Find All Coordinates systems in study
2267 //=================================================================================
2268 void EntityGUI_SketcherDlg::FindLocalCS()
2269 {
2270   ComboBox1->clear();
2271   myLCSList.clear();
2272   SalomeApp_Application* app =
2273     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2274   if ( !app )
2275     return;
2276
2277   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2278   if ( !appStudy )
2279     return;
2280
2281   _PTR(Study) aStudy = appStudy->studyDS();
2282
2283   //add Global CS
2284   ComboBox1->addItem(tr("GEOM_GCS"));
2285   gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2286   gp_Dir aDirZ = gp_Dir(0, 0, 1);
2287   gp_Dir aDirX = gp_Dir(1, 0, 0);
2288   gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2289   myLCSList.push_back(globalCS);
2290
2291   // get GEOM component
2292   CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2293   _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2294   if (!obj)
2295     return;
2296   _PTR(SComponent) fc = obj->GetFatherComponent();
2297   QString geomComp = fc->GetID().c_str();
2298   _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2299   if ( !comp )
2300     return;
2301
2302   // browse through all GEOM data tree
2303   _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2304   for ( it->InitEx( true ); it->More(); it->Next() ) {
2305     _PTR(SObject) child( it->Value() );
2306     CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2307     GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2308     if( CORBA::is_nil( geomObj ) ) 
2309       continue;
2310     if (geomObj->GetType() == GEOM_MARKER) {
2311       ComboBox1->addItem(geomObj->GetName());
2312       TopoDS_Shape aShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2313       
2314       gp_Ax3 aLCS;
2315       aLCS.Transform(aShape.Location().Transformation());
2316       if (aShape.ShapeType() == TopAbs_FACE) {
2317         Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2318         if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2319           Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2320           gp_Pln aPln = aGPlane->Pln();
2321           aLCS = aPln.Position();
2322         }
2323       }
2324       myLCSList.push_back(aLCS);
2325     }
2326   }
2327 }
2328
2329 //=================================================================================
2330 // function : GetActiveLocalCS()
2331 // purpose  : Get Working plane
2332 //=================================================================================
2333 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2334 {
2335   int ind = ComboBox1->currentIndex();
2336   if (ind == -1)
2337     return myGeometryGUI->GetWorkingPlane();
2338
2339   gp_Ax3 aLCS = myLCSList.at(ind);
2340
2341   return aLCS;
2342 }
2343
2344 //=================================================================================
2345 // function : ActivateLocalCS()
2346 // purpose  : Activate & Fit Working plane
2347 //=================================================================================
2348 void EntityGUI_SketcherDlg::ActivateLocalCS()
2349 {
2350     myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2351     myGeometryGUI->ActiveWorkingPlane();
2352 }