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