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