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