]> SALOME platform Git repositories - modules/geom.git/blob - src/EntityGUI/EntityGUI_SketcherDlg.cxx
Salome HOME
rnc: In the frame of the feature EDF 1900, made possible to define a point by clickin...
[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   MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1158   myEditCurrentArgument->setText( "" );
1159   double tmpX = myX;
1160   double tmpY = myY;
1161   myX = myLastX1;
1162   myY = myLastY1;
1163   //  printf ("\nmyX = %f         myY = %f", myX, myY);
1164   //  printf ("\nmyLastX1 = %f    myLastY1 = %f", myLastX1, myLastY1);
1165   //  printf ("\nmyLastX2 = %f    myLastY2 = %f", myLastX2, myLastY2);
1166
1167   if ( sender() == ComboBox1 )
1168       ActivateLocalCS();
1169
1170   LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1171   SALOME_ListIO aSelList;
1172   aSelMgr->selectedObjects(aSelList);
1173
1174   int nbSel = aSelList.Extent();
1175   MESSAGE("NbSel = "<<nbSel)
1176   if (nbSel == 0){
1177     myX=tmpX;
1178     myY=tmpY;
1179   }
1180   if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1181     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1182     if ( !CORBA::is_nil(aSelectedObject) ) {
1183       TopoDS_Shape aShape;
1184       if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1185         gp_Trsf aTrans;
1186         gp_Ax3 aWPlane = GetActiveLocalCS();
1187
1188         aTrans.SetTransformation(aWPlane);
1189         BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1190         aShape = aTransformation.Shape();
1191
1192         gp_Pnt aPnt;
1193         if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1194           myX = aPnt.X();
1195           myY = aPnt.Y();
1196           Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1197           if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1198             disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1199             disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1200             Group2Spin->SpinBox_DX->setValue(myX);
1201             Group2Spin->SpinBox_DY->setValue(myY);
1202             connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1203             connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1204           } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1205             if ( myLastX1 && myLastY1 ) {
1206               Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1207               Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1208             } else {
1209               if ( mySketchState != FIRST_POINT ) {
1210                 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1211                 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1212               } else {
1213                 Group2Spin->SpinBox_DX->setValue(myX);
1214                 Group2Spin->SpinBox_DY->setValue(myY);
1215               }
1216             }
1217           }
1218         }
1219       }
1220     }
1221   }
1222
1223   if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1224     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1225     if ( !CORBA::is_nil(aSelectedObject) ) {
1226       TopoDS_Shape aShape;
1227       if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1228         gp_Trsf aTrans;
1229         gp_Ax3 aWPlane = GetActiveLocalCS();
1230
1231         aTrans.SetTransformation(aWPlane);
1232         BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1233         aShape = aTransformation.Shape();
1234
1235         gp_Pnt aPnt;
1236         if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1237           myX = aPnt.X();
1238           myY = aPnt.Y();
1239           Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1240           if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1241             disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1242             disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1243             Group3Spin->SpinBox_DX->setValue(myX);
1244             Group3Spin->SpinBox_DY->setValue(myY);
1245             connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1246             connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1247           } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1248             if ( myLastX1 && myLastY1 ) {
1249               Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1250               Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1251             } else {
1252               if ( mySketchState != FIRST_POINT ) {
1253                 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1254                 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1255               } else {
1256                 Group3Spin->SpinBox_DX->setValue(myX);
1257                 Group3Spin->SpinBox_DY->setValue(myY);
1258               }
1259             }
1260           }
1261         }
1262       }
1263     }
1264   }
1265
1266   if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1267     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1268     if ( !CORBA::is_nil(aSelectedObject) ) {
1269       TopoDS_Shape aShape;
1270       if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1271         gp_Trsf aTrans;
1272         gp_Ax3 aWPlane = GetActiveLocalCS();
1273
1274         aTrans.SetTransformation(aWPlane);
1275         BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1276         aShape = aTransformation.Shape();
1277
1278         gp_Pnt aPnt;
1279         if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1280           myXc = aPnt.X();
1281           myYc = aPnt.Y();
1282           Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1283           if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1284             disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1285             disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1286             Group4Spin->SpinBox_DX->setValue(myXc);
1287             Group4Spin->SpinBox_DY->setValue(myYc);
1288             connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1289             connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1290           } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1291             if ( myLastX1 && myLastY1 ) {
1292               Group4Spin->SpinBox_DX->setValue(myXc - myLastX1);
1293               Group4Spin->SpinBox_DY->setValue(myYc - myLastY1);
1294             } else {
1295               if ( mySketchState != FIRST_POINT ) {
1296                 Group4Spin->SpinBox_DX->setValue(myXc - tmpX);
1297                 Group4Spin->SpinBox_DY->setValue(myYc - tmpY);
1298               } else {
1299                 Group4Spin->SpinBox_DX->setValue(myXc);
1300                 Group4Spin->SpinBox_DY->setValue(myYc);
1301               }
1302             }
1303           }
1304         }
1305       }
1306     }
1307   }
1308
1309   if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1310     if (!Group2Sel->LineEdit1->text().isEmpty()){    //Check wether or not Linedit2 has been modified
1311       myX=tmpX;                                      // If yes keep the old values of X and Y  
1312       myY=tmpY;
1313     }
1314     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1315     if ( !CORBA::is_nil(aSelectedObject) ) {
1316       TopoDS_Shape aShape;
1317       if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1318         gp_Trsf aTrans;
1319         gp_Ax3 aWPlane = GetActiveLocalCS();
1320
1321         aTrans.SetTransformation(aWPlane);
1322         BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1323         aShape = aTransformation.Shape();
1324
1325         gp_Pnt aPnt;
1326         if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1327           myX = aPnt.X();
1328           myY = aPnt.Y();
1329           Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1330           if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1331             disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1332             disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1333             Group4Spin->SpinBox_DZ->setValue(myX);
1334             Group4Spin->SpinBox_DS->setValue(myY);
1335             connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1336             connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1337           } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1338             if ( myLastX1 && myLastY1 ) {
1339               Group4Spin->SpinBox_DZ->setValue(myX - myLastX1);
1340               Group4Spin->SpinBox_DS->setValue(myY - myLastY1);
1341             } else {
1342               if ( mySketchState != FIRST_POINT ) {
1343                 Group4Spin->SpinBox_DZ->setValue(myX - tmpX);
1344                 Group4Spin->SpinBox_DS->setValue(myY - tmpY);
1345               } else {
1346                 Group4Spin->SpinBox_DZ->setValue(myX);
1347                 Group4Spin->SpinBox_DS->setValue(myY);
1348               }
1349             }
1350           }
1351         }
1352       }
1353     }
1354   }
1355
1356
1357
1358   GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1359 }
1360
1361
1362 //=================================================================================
1363 // function : SetEditCurrentArgument()
1364 // purpose  :
1365 //=================================================================================
1366 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1367 {
1368   if ( sender() == Group1Sel->PushButton1 ) {
1369     myEditCurrentArgument = Group1Sel->LineEdit1;
1370     myEditCurrentArgument->setFocus();
1371   }
1372   else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1373     myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1374     myEditCurrentArgument->setFocus();
1375   }
1376   else if ( sender() == Group2Sel->PushButton1 ) {
1377     myEditCurrentArgument = Group2Sel->LineEdit1;
1378     Group2Sel->PushButton2->setDown(false);
1379     Group2Sel->PushButton1->setDown(true);
1380     Group2Sel->LineEdit2->setEnabled(false);
1381     Group2Sel->LineEdit1->setEnabled(true);
1382    // myEditCurrentArgument->setFocus();
1383   }
1384    else if ( sender() == Group2Sel->PushButton2 ) {
1385     myEditCurrentArgument = Group2Sel->LineEdit2;
1386     Group2Sel->PushButton1->setDown(false);
1387     Group2Sel->PushButton2->setDown(true);
1388     Group2Sel->LineEdit1->setEnabled(false);
1389     Group2Sel->LineEdit2->setEnabled(true);
1390    // myEditCurrentArgument->setFocus();
1391   }
1392   SelectionIntoArgument();
1393 }
1394
1395
1396 //=================================================================================
1397 // function : LineEditReturnPressed()
1398 // purpose  :
1399 //=================================================================================
1400 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1401 {
1402   if ( sender() == Group1Sel->LineEdit1 ) 
1403     myEditCurrentArgument = Group1Sel->LineEdit1;
1404   else if ( sender() == Group1Sel1Spin->LineEdit1 ) 
1405      myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1406   else if ( sender() == Group2Sel->LineEdit1 ) 
1407      myEditCurrentArgument = Group2Sel->LineEdit1;
1408   else if ( sender() == Group2Sel->LineEdit2 )
1409      myEditCurrentArgument = Group2Sel->LineEdit2;
1410
1411   /* User name of object input management                          */
1412   /* If successfull the selection is changed and signal emitted... */
1413   /* so SelectionIntoArgument() is automatically called.           */
1414   const QString objectUserName = myEditCurrentArgument->text();
1415   QWidget* thisWidget = (QWidget*)this;
1416
1417   LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1418   SALOME_ListIO aSelList;
1419   aSelMgr->selectedObjects(aSelList);
1420
1421   if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1422     myEditCurrentArgument->setText( objectUserName );
1423 }
1424
1425
1426 //=================================================================================
1427 // function : DeactivateActiveDialog()
1428 // purpose  :
1429 //=================================================================================
1430 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1431 {
1432   //myGeometryGUI->SetState( -1 );
1433
1434   setEnabled( false );
1435   globalSelection();
1436   disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1437   myGeometryGUI->SetActiveDialogBox( 0 );
1438 }
1439
1440
1441 //=================================================================================
1442 // function : ActivateThisDialog()
1443 // purpose  :
1444 //=================================================================================
1445 void EntityGUI_SketcherDlg::ActivateThisDialog()
1446 {
1447   myGeometryGUI->EmitSignalDeactivateDialog();
1448   setEnabled( true );
1449   myGeometryGUI->SetActiveDialogBox( this );
1450
1451   connect( myGeometryGUI->getApp()->selectionMgr(),
1452           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1453
1454   //myGeometryGUI->SetState( 0 );
1455   globalSelection( GEOM_POINT );
1456   
1457   myEditCurrentArgument = Group1Sel->LineEdit1;
1458   myEditCurrentArgument->setFocus();
1459   
1460    if ( sender() == Group1Sel->LineEdit1 ) {
1461      myEditCurrentArgument = Group1Sel->LineEdit1;
1462      myEditCurrentArgument->setFocus();
1463    }
1464    else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1465      myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1466      myEditCurrentArgument->setFocus();
1467    }
1468    else if ( sender() == Group2Sel->LineEdit1 ) {
1469      myEditCurrentArgument = Group2Sel->LineEdit1;
1470      myEditCurrentArgument->setFocus();
1471    }
1472     else if ( sender() == Group2Sel->LineEdit2 ) {
1473      myEditCurrentArgument = Group2Sel->LineEdit2;
1474      myEditCurrentArgument->setFocus();
1475    }
1476
1477   GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1478 }
1479
1480
1481 //=================================================================================
1482 // function : enterEvent [REDEFINED]
1483 // purpose  :
1484 //=================================================================================
1485 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1486 {
1487   if ( !isEnabled() )
1488     ActivateThisDialog();
1489 }
1490
1491
1492 //=================================================================================
1493 // function : closeEvent()
1494 // purpose  :
1495 //=================================================================================
1496 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1497 {
1498   MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1499   //myGeometryGUI->SetState( -1 );
1500   disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1501   myGeometryGUI->getApp()->updateActions();
1502   QDialog::closeEvent( e );
1503 }
1504
1505 //rnc TODO
1506 //=================================================================================
1507 // function : OnPointSelected
1508 // purpose  :
1509 //=================================================================================
1510 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt)
1511 {
1512   MESSAGE("EntityGUI_SketcherDlg::OnPointSelected")
1513   switch (getPnt2ConstructorId()){
1514     case 1:
1515       Group2Spin->SpinBox_DX->setValue( thePnt.X() );
1516       Group2Spin->SpinBox_DY->setValue( thePnt.Y() ); 
1517       break;
1518     case 0:
1519       Group3Spin->SpinBox_DX->setValue( thePnt.X() );
1520       Group3Spin->SpinBox_DY->setValue( thePnt.Y() );
1521       break;
1522     case 2:
1523       if (modifiers == Qt::MetaModifier){                // Select center with Meta key
1524         Group4Spin->SpinBox_DX->setValue( thePnt.X() );
1525         Group4Spin->SpinBox_DY->setValue( thePnt.Y() );
1526       }
1527       else{                                              // The select end point
1528         Group4Spin->SpinBox_DZ->setValue( thePnt.X() );
1529         Group4Spin->SpinBox_DS->setValue( thePnt.Y() );
1530       }
1531       break;
1532   }
1533 }
1534
1535 //=================================================================================
1536 // function : ValueChangedInSpinBox()
1537 // purpose  :
1538 //=================================================================================
1539 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1540 {
1541   MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
1542   QObject* send = (QObject*)sender();
1543   Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1544   vx = vy = vz = vs = minRad = dx = dy = 0.0;
1545
1546   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1547   int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1548   double LastDecimal = 0.0;
1549
1550   QString vxStr, vyStr, vzStr, vsStr;
1551
1552   QString newValueStr;
1553   if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1554     newValueStr = aDoubleSpinBox->text();
1555
1556   if ( send == Group1Spin->SpinBox_DX ) {
1557     vx = newValue;                        vxStr = newValueStr;
1558   }
1559   else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1560     vx = newValue;                        vxStr = newValueStr;
1561   }
1562   else if ( send == Group2Spin->SpinBox_DX ) {
1563     vx = newValue;                        vxStr = newValueStr;
1564     vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1565   }
1566   else if ( send == Group2Spin->SpinBox_DY ) {
1567     vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1568     vy = newValue;                        vyStr = newValueStr;
1569   }
1570   else if ( send == Group3Spin->SpinBox_DX ) {
1571     vx = newValue;                        vxStr = newValueStr;
1572     vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1573     vz = Group3Spin->SpinBox_DZ->value();
1574     if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {  
1575       if (mySketchType == PT_ABS_RADIUS){
1576         dx = vx - myLastX1;
1577         dy = vy - myLastY1;
1578       }
1579       else{
1580         dx = vx;
1581         dy = vy;
1582       }
1583       minRad = 0.5 * Sqrt(dx * dx + dy * dy);                             //Computation of the minimum acceptable radius for the arc calculation
1584       if (aPrecision >= 0)    // 'f' format in the QString             
1585         LastDecimal = aPrecision;
1586       else                    // 'g' format in the Qstring
1587         LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) ); 
1588       minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal);  // Rounded up at the last allowed decimal place
1589       if ( Abs(vz) < minRad){
1590         if (vz < 0.0)
1591           Group3Spin->SpinBox_DZ->setValue( - minRad );
1592         else 
1593           Group3Spin->SpinBox_DZ->setValue( minRad );
1594       }
1595     }
1596     vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1597   }
1598   else if ( send == Group3Spin->SpinBox_DY ) {
1599     vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1600     vy = newValue;                        vyStr = newValueStr;
1601     vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1602     if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1603       if (mySketchType == PT_ABS_RADIUS){
1604         dx = vx - myLastX1;
1605         dy = vy - myLastY1;
1606       }
1607       else{
1608         dx = vx;
1609         dy = vy;
1610       }    
1611       minRad = 0.5 * Sqrt(dx * dx + dy * dy);                            //Computation of the minimum acceptable radius for the arc calculation
1612       if (aPrecision >= 0)    // 'f' format in the QString 
1613         LastDecimal = aPrecision;
1614       else                    // 'g' format in the QString 
1615         LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) ); 
1616         minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1617       if ( Abs(vz) < minRad){
1618         if (vz < 0.0)
1619           Group3Spin->SpinBox_DZ->setValue( - minRad );
1620         else 
1621           Group3Spin->SpinBox_DZ->setValue( minRad );
1622       }
1623     }
1624     vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1625   }
1626   else if ( send == Group3Spin->SpinBox_DZ ) {
1627     vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1628     vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1629     vz = newValue;                        vzStr = newValueStr;
1630   }
1631   else if ( send == Group4Spin->SpinBox_DX ) {
1632     vx = newValue;                        vxStr = newValueStr;
1633     vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1634     vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1635     vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1636   }
1637   else if ( send == Group4Spin->SpinBox_DY ) {
1638     vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1639     vy = newValue;                        vyStr = newValueStr;
1640     vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1641     vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1642   }
1643   else if ( send == Group4Spin->SpinBox_DZ ) {
1644     vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1645     vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1646     vz = newValue;                        vzStr = newValueStr;
1647     vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1648   }
1649   else if ( send == Group4Spin->SpinBox_DS ) {
1650     vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1651     vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1652     vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1653     vs = newValue;                        vsStr = newValueStr;
1654   }
1655   // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1656
1657   if ( myConstructorId == 0 ) {  // SEGMENT
1658     if ( mySketchType == PT_ABS ) {
1659       myX = vx;
1660       myY = vy;
1661       myXStr = vxStr;
1662       myYStr = vyStr;
1663     }
1664     else if ( mySketchType == PT_RELATIVE ) {
1665       myDX = vx;
1666       myDY = vy;
1667       myDXStr = vxStr;
1668       myDYStr = vyStr;
1669     }
1670     else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1671       myAngle = vx;
1672       myLength = vy;
1673       myAngleStr = vxStr;
1674       myLengthStr = vyStr;
1675     }
1676     else if ( mySketchType == DIR_ANGLE_X ) {
1677       myAngle = vx;
1678       myX = vy;
1679       myAngleStr = vxStr;
1680       myXStr = vyStr;
1681     }
1682     else if ( mySketchType == DIR_ANGLE_Y ) {
1683       myAngle = vx;
1684       myY = vy;
1685       myAngleStr = vxStr;
1686       myYStr = vyStr;
1687     }
1688     else if ( mySketchType == DIR_PER_LENGTH ) {
1689       myLength = vx;
1690       myLengthStr = vxStr;
1691     }
1692     else if ( mySketchType == DIR_PER_X ) {
1693       myX = vx;
1694       myXStr = vxStr;
1695     }
1696     else if ( mySketchType == DIR_PER_Y ) {
1697       myY = vx;
1698       myYStr = vxStr;
1699     }
1700     else if ( mySketchType == DIR_TAN_LENGTH ) {
1701       myLength = vx;
1702       myLengthStr = vxStr;
1703     }
1704     else if ( mySketchType == DIR_TAN_X ) {
1705       myX = vx;
1706       myXStr = vxStr;
1707     }
1708     else if ( mySketchType == DIR_TAN_Y ) {
1709       myY = vx;
1710       myYStr = vxStr;
1711     }
1712     else if ( mySketchType == DIR_DXDY_LENGTH ) {
1713       myDX = vx;
1714       myDY = vy;
1715       myLength = vz;
1716       myDXStr = vxStr;
1717       myDYStr = vyStr;
1718       myLengthStr = vzStr;
1719     }
1720     else if ( mySketchType == DIR_DXDY_X ) {
1721       myDX = vx;
1722       myDY = vy;
1723       myX = vz;
1724       myDXStr = vxStr;
1725       myDYStr = vyStr;
1726       myXStr = vzStr;
1727     }
1728     else if ( mySketchType == DIR_DXDY_Y ) {
1729       myDX = vx;
1730       myDY = vy;
1731       myY = vz;
1732       myDXStr = vxStr;
1733       myDYStr = vyStr;
1734       myYStr = vzStr;
1735     }
1736   }
1737   else if ( myConstructorId == 1 ) {  // ARC
1738     if ( mySketchType == PT_ABS ) {  
1739       myX = vx;
1740       myY = vy;
1741       myXStr = vxStr;
1742       myYStr = vyStr;
1743     }
1744     else if ( mySketchType == PT_RELATIVE ) {
1745       myDX = vx;
1746       myDY = vy;
1747       myDXStr = vxStr;
1748       myDYStr = vyStr;
1749     }
1750     if ( mySketchType == PT_ABS_RADIUS ) {  
1751       myX = vx;
1752       myY = vy;
1753       myRadius=vz;
1754       myXStr = vxStr;
1755       myYStr = vyStr;
1756       myRadiusStr = vzStr;
1757     }
1758     else if ( mySketchType == PT_REL_RADIUS ) {
1759       myDX = vx;
1760       myDY = vy;
1761       myRadius=vz;
1762       myDXStr = vxStr;
1763       myDYStr = vyStr;
1764       myRadiusStr = vzStr;
1765     }
1766     else if ( mySketchType == PT_SEL_RADIUS ) {
1767       myRadius = vx;
1768       myRadiusStr = vxStr;
1769     }
1770     if ( mySketchType == PT_ABS_CENTER ) {  
1771       myXc = vx;
1772       myYc = vy;
1773       myX = vz;
1774       myY = vs;
1775       myXcStr = vxStr;
1776       myYcStr = vyStr;
1777       myXStr = vzStr;
1778       myYStr = vsStr;
1779     }
1780     else if ( mySketchType == PT_REL_CENTER ) {
1781       myDXc = vx;
1782       myDYc = vy;
1783       myDX = vz;
1784       myDY = vs;
1785       myDXcStr = vxStr;
1786       myDYcStr = vyStr;
1787       myDXStr = vzStr;
1788       myDYStr = vsStr;
1789     }
1790     if ( mySketchType == DIR_ANGLE_LENGTH ) {
1791       myAngle = vx;
1792       myRadius = vy;
1793       myLength = vz;
1794       myAngleStr = vxStr;
1795       myRadiusStr = vyStr;
1796       myLengthStr = vzStr;
1797     }
1798     else if ( mySketchType == DIR_PER_LENGTH ) {
1799       myRadius = vx;
1800       myLength = vy;
1801       myRadiusStr = vxStr;
1802       myLengthStr = vyStr;
1803     }
1804     else if ( mySketchType == DIR_TAN_LENGTH ) {
1805       myRadius = vx;
1806       myLength = vy;
1807       myRadiusStr = vxStr;
1808       myLengthStr = vyStr;
1809     }
1810     else if ( mySketchType == DIR_DXDY_LENGTH ) {
1811       myDX = vx;
1812       myDY = vy;
1813       myRadius = vz;
1814       myLength = vs;
1815       myDXStr = vxStr;
1816       myDYStr = vyStr;
1817       myRadiusStr = vzStr;
1818       myLengthStr = vsStr;
1819     }
1820   }
1821
1822   GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1823 }
1824
1825
1826 //=================================================================================
1827 // function : GetNewCommand()
1828 // purpose  : Build the new command with context
1829 //=================================================================================
1830 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1831 {
1832   theParameters.clear();
1833   QString myNewCommand = ":";
1834   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1835   int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1836   int DigNum = qAbs(aPrecision);                   // options for the format of numbers in  myNewCommand
1837   char Format = 'f';
1838   if ( aPrecision < 0 )                            // f --> DigNum is the number of digits after the decimal point
1839     Format = 'g';                                  // g --> DigNum is the maximum number of significant digits 
1840
1841   if ( mySketchState == FIRST_POINT ) {
1842     if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1843       myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1844       theParameters = myXStr + ":" + myYStr;
1845     }
1846     if ( mySketchType == PT_RELATIVE) {
1847       myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1848       theParameters = myDXStr + ":" + myDYStr;
1849     }
1850     return myNewCommand;
1851   }
1852
1853   if ( myConstructorId == 0  ) {  // SEGMENT
1854     if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1855       myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1856       theParameters = myXStr + ":" + myYStr;
1857     }
1858     if ( mySketchType == PT_RELATIVE) {
1859       myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1860       theParameters = myDXStr + ":" + myDYStr;
1861     }
1862     if ( mySketchType == DIR_ANGLE_LENGTH ) {
1863       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1864       myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1865       theParameters = myAngleStr + ":" + myLengthStr;
1866     }
1867     if ( mySketchType == DIR_ANGLE_X ) {
1868       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1869       myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1870       theParameters = myAngleStr + ":" + myXStr;
1871     }
1872     if ( mySketchType == DIR_ANGLE_Y ) {
1873       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1874       myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1875       theParameters = myAngleStr + ":" + myYStr;
1876     }
1877     if ( mySketchType == DIR_PER_LENGTH ) {
1878       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1879       myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1880       theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1881     }
1882     if ( mySketchType == DIR_PER_X ) {
1883       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1884       myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1885       theParameters = QString::number( 90.0 ) + ":" + myXStr;
1886     }
1887     if ( mySketchType == DIR_PER_Y ) {
1888       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1889       myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1890       theParameters = QString::number( 90.0 ) + ":" + myYStr;
1891     }
1892     if ( mySketchType == DIR_TAN_LENGTH ) {
1893       myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1894       theParameters = myLengthStr;
1895     }
1896     if ( mySketchType == DIR_TAN_X ) {
1897       myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1898       theParameters = myXStr;
1899     }
1900     if ( mySketchType == DIR_TAN_Y) {
1901       myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1902       theParameters = myYStr;
1903     }
1904     if ( mySketchType == DIR_DXDY_LENGTH ) {
1905       myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1906       myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1907       theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1908     }
1909     if ( mySketchType == DIR_DXDY_X ) {
1910       myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1911       myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1912       theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1913     }
1914     if ( mySketchType == DIR_DXDY_Y ) {
1915       myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1916       myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1917       theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1918     }
1919   }
1920   else if ( myConstructorId == 1 ) {  // ARC
1921     if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1922       myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1923       theParameters = myXStr + ":" + myYStr;
1924     }
1925     if ( mySketchType == PT_RELATIVE) {
1926       myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1927       theParameters = myDXStr + ":" + myDYStr;
1928     }
1929     if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1930       myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format,  DigNum)+ " " + QString::number( myCheckFlag );
1931       theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr; 
1932     }
1933     if ( mySketchType == PT_REL_RADIUS) {
1934       myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1935       theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;  
1936     }
1937     if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
1938       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 );
1939       theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr; 
1940     }
1941     if ( mySketchType == PT_REL_CENTER) {
1942       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 );
1943       theParameters = myDXStr + ":" + myDYStr + ":" +  myDXcStr + ":" + myDYcStr ;  
1944     }
1945     if ( mySketchType == DIR_ANGLE_LENGTH ) {
1946       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1947       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1948       theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1949     }
1950     if ( mySketchType == DIR_PER_LENGTH ) {
1951       myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1952       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1953       theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
1954     }
1955     if ( mySketchType == DIR_TAN_LENGTH ) {
1956       myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1957       theParameters = myRadiusStr + ":" + myLengthStr;
1958     }
1959     if ( mySketchType == DIR_DXDY_LENGTH ) {
1960       myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1961       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1962       theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
1963     }
1964   }
1965   return myNewCommand;
1966 }
1967
1968 //=================================================================================
1969 // function : createOperation
1970 // purpose  :
1971 //=================================================================================
1972 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1973 {
1974   return getGeomEngine()->GetICurvesOperations( getStudyId() );
1975 }
1976
1977 //=================================================================================
1978 // function : isValid
1979 // purpose  :
1980 //=================================================================================
1981 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1982 {
1983   bool ok = true;
1984   bool toCorrect = !IsPreview() || myIsApply;
1985
1986   if( Group1Spin->isVisible() ) {
1987     ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1988   }
1989   else if( Group1Sel1Spin->isVisible() ) {
1990     ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1991   }
1992   else if( Group2Spin->isVisible() ) {
1993     ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1994     ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1995   }
1996   else if( Group3Spin->isVisible() ) {
1997     ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1998     ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1999     ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2000   }
2001   else if( Group4Spin->isVisible() ) {
2002     ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2003     ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2004     ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2005     ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2006   }
2007
2008   if( myIsApply && !ok )
2009     showError( msg );
2010
2011   return ok;
2012 }
2013
2014 //=================================================================================
2015 // function : execute
2016 // purpose  :
2017 //=================================================================================
2018 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2019 {
2020   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2021   int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2022   int DigNum = qAbs(aPrecision);                   // options for the format of numbers in  myNewCommand
2023   char Format = 'f';
2024   if ( aPrecision < 0 )                            // f --> DigNum is the number of digits after the decimal point
2025     Format = 'g';                                  // g --> DigNum is the maximum number of significant digits 
2026     
2027   QString aParameters;
2028
2029   if ( mySketchState == FIRST_POINT ) {
2030     myLastX2 = myX;
2031     myLastY2 = myY;
2032   }
2033   else {
2034     //Test if the current point is the same as the last one
2035     TopoDS_Shape myShape1, myShape2;
2036
2037     // Set "C" numeric locale
2038     Kernel_Utils::Localizer loc;
2039
2040     //Last Shape
2041     QString Command1 = myCommand.join( "" );
2042     Sketcher_Profile aProfile1( Command1.toAscii() );
2043     if ( aProfile1.IsDone() )
2044       myShape1 = aProfile1.GetShape();
2045
2046     //Current Shape
2047     QString Command2 = Command1 + GetNewCommand( aParameters );
2048     Sketcher_Profile aProfile2( Command2.toAscii() );
2049
2050     //Error Message
2051     if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER  ){
2052       if (aProfile2.Error() > Precision::Confusion()){
2053         Group4Spin->label->show();
2054         Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2055       }
2056       else{
2057         Group4Spin->label->hide();
2058       } 
2059     }
2060     else 
2061       Group4Spin->label->hide();
2062     if ( mySketchType == PT_SEL_CENTER ){
2063       if (aProfile2.Error() > Precision::Confusion()){
2064         Group2Sel->label->show();
2065         Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2066       }
2067       else{
2068         Group2Sel->label->hide();
2069       } 
2070     }
2071     else 
2072       Group2Sel->label->hide();
2073
2074     if ( aProfile2.IsDone() )
2075       myShape2 = aProfile2.GetShape();
2076
2077     if ( myShape2.IsNull() ) {
2078       //the current point is the same as the last one
2079       myLastX2 = myLastX1;
2080       myLastY2 = myLastY1;
2081     }
2082     else {
2083       TopoDS_Vertex V1, V2;
2084       gp_Pnt pt;
2085       if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2086         //the last shape is the first point
2087         pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2088         myLastX1 = pt.X();
2089         myLastY1 = pt.Y();
2090       }
2091       else {
2092         TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2093         pt = BRep_Tool::Pnt( V2 );
2094         myLastX1 = pt.X();
2095         myLastY1 = pt.Y();
2096       }
2097       TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2098       pt = BRep_Tool::Pnt( V2 );
2099       myLastX2 = pt.X();
2100       myLastY2 = pt.Y();
2101     }
2102   }
2103
2104   QString cmd;
2105   if ( ( mySketchState != FIRST_POINT &&
2106          myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2107     cmd = myCommand.join( "" );
2108     if ( Group1Sel->isVisible() ) {
2109       Group1Sel->buttonApply->setEnabled( false );
2110       //Group1Sel->buttonApply->setFocus();
2111     }
2112     if ( Group2Sel->isVisible() ) {
2113       Group2Sel->buttonApply->setEnabled( false );
2114       //Group2Sel->buttonApply->setFocus();
2115     }
2116     if ( Group1Sel1Spin->isVisible() ) {
2117       Group1Sel1Spin->buttonApply->setEnabled( false );
2118       //Group1Sel1Spin->buttonApply->setFocus();
2119     }
2120     if ( Group1Spin->isVisible() ) {
2121       Group1Spin->buttonApply->setEnabled( false );
2122       //Group1Spin->buttonApply->setFocus();
2123     }
2124     if ( Group2Spin->isVisible() ) {
2125       Group2Spin->buttonApply->setEnabled( false );
2126       //Group2Spin->buttonApply->setFocus();
2127     }
2128     if ( Group3Spin->isVisible() ) {
2129       Group3Spin->buttonApply->setEnabled( false );
2130       //Group3Spin->buttonApply->setFocus();
2131     }
2132     if ( Group4Spin->isVisible() ) {
2133       Group4Spin->buttonApply->setEnabled( false );
2134       //Group4Spin->buttonApply->setFocus();
2135     }
2136   }
2137   else {
2138     cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2139
2140     if ( Group1Sel->isVisible() ) {
2141       Group1Sel->buttonApply->setEnabled( true );
2142       //Group1Sel->buttonApply->setFocus();
2143     }
2144     if ( Group2Sel->isVisible() ) {
2145       Group2Sel->buttonApply->setEnabled( true );
2146       //Group2Sel->buttonApply->setFocus();
2147     }
2148     if ( Group1Sel1Spin->isVisible() ) {
2149       Group1Sel1Spin->buttonApply->setEnabled( true );
2150       //Group1Sel1Spin->buttonApply->setFocus();
2151     }
2152     if ( Group1Spin->isVisible() ) {
2153       Group1Spin->buttonApply->setEnabled( true );
2154       //Group1Spin->buttonApply->setFocus();
2155     }
2156     if ( Group2Spin->isVisible() ) {
2157       Group2Spin->buttonApply->setEnabled( true );
2158       //Group2Spin->buttonApply->setFocus();
2159     }
2160     if ( Group3Spin->isVisible() ) {
2161       Group3Spin->buttonApply->setEnabled( true );
2162       //Group3Spin->buttonApply->setFocus();
2163     }
2164     if ( Group4Spin->isVisible() ) {
2165       Group4Spin->buttonApply->setEnabled( true );
2166       //Group4Spin->buttonApply->setFocus();
2167     }
2168   }
2169
2170   gp_Ax3 myWPlane = GetActiveLocalCS();
2171   GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2172   WPlane->length( 9 );
2173   WPlane[0] = myWPlane.Location().X();
2174   WPlane[1] = myWPlane.Location().Y();
2175   WPlane[2] = myWPlane.Location().Z();
2176
2177   WPlane[3] = myWPlane.Direction().X();
2178   WPlane[4] = myWPlane.Direction().Y();
2179   WPlane[5] = myWPlane.Direction().Z();
2180
2181   WPlane[6] = myWPlane.XDirection().X();
2182   WPlane[7] = myWPlane.XDirection().Y();
2183   WPlane[8] = myWPlane.XDirection().Z();
2184
2185   GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2186   GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2187
2188   if ( !anObj->_is_nil() )
2189   {
2190     if( !IsPreview() ) {
2191       QStringList aCurrentParameters = myParameters;
2192       aCurrentParameters << aParameters;
2193       anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2194     }
2195
2196     objects.push_back( anObj._retn() );
2197   }
2198
2199   return true;
2200 }
2201
2202 //================================================================
2203 // Function : displayPreview
2204 // Purpose  : Method for displaying preview of resulting shape
2205 //            Redefined from GEOMBase_Helper.
2206 //================================================================
2207 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2208                                             const bool            append,
2209                                             const bool            activate,
2210                                             const bool            update,
2211                                             const double          lineWidth,
2212                                             const int             displayMode,
2213                                             const int             color )
2214
2215   // Set color for preview shape
2216   getDisplayer()->SetColor( Quantity_NOC_RED );
2217
2218   // set width of displayed shape
2219   getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2220
2221   // Disable activation of selection
2222   getDisplayer()->SetToActivate( activate );
2223
2224   // Make a reference to GEOM_Object
2225   CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2226   getDisplayer()->SetName( objStr.in() );
2227
2228   // Create wire from applayed object
2229   TopoDS_Shape anApplyedWire, aLastSegment;
2230   if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2231     return;
2232
2233   // Build prs
2234   SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2235   if ( aPrs != 0 && !aPrs->IsNull() )
2236     GEOMBase_Helper::displayPreview( aPrs, append, update );
2237
2238   getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2239   aPrs = getDisplayer()->BuildPrs( aLastSegment );
2240   if ( aPrs != 0 && !aPrs->IsNull() )
2241     GEOMBase_Helper::displayPreview( aPrs, append, update );
2242
2243   getDisplayer()->UnsetName();
2244
2245   // Enable activation of displayed objects
2246   getDisplayer()->SetToActivate( true );
2247 }
2248
2249 //================================================================
2250 // Function : createShapes
2251 // Purpose  : Create applyed wire, and last segment from entry object
2252 //================================================================
2253 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2254                                           TopoDS_Shape&         theApplyedWire,
2255                                           TopoDS_Shape&         theLastSegment )
2256 {
2257   TopoDS_Shape aShape;
2258   if (  !GEOMBase::GetShape( theObject, aShape ) ||
2259        ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2260     return false;
2261
2262   if ( ( Group1Sel->isVisible()  && !Group1Sel->buttonApply->isEnabled() )||
2263        ( Group2Sel->isVisible()  && !Group2Sel->buttonApply->isEnabled() ) ||
2264        ( Group1Sel1Spin->isVisible()  && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2265        ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2266        ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2267        ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2268        ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2269      theApplyedWire = aShape;
2270      return true;
2271   }
2272
2273   BRepBuilderAPI_MakeWire aBuilder;
2274   TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2275   while ( 1 ) {
2276     TopoDS_Shape anEdge = anExp.Current();
2277     anExp.Next();
2278     if ( anExp.More() ) // i.e. non-last edge
2279       aBuilder.Add( TopoDS::Edge( anEdge ) );
2280     else {
2281       theLastSegment = anEdge;
2282       break;
2283     }
2284   }
2285
2286   if ( aBuilder.IsDone() )
2287     theApplyedWire = aBuilder.Shape();
2288
2289   return true;
2290 }
2291
2292 //=================================================================================
2293 // function : keyPressEvent()
2294 // purpose  :
2295 //=================================================================================
2296 void  EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2297 {
2298   QDialog::keyPressEvent( e );
2299   if ( e->isAccepted() )
2300     return;
2301
2302   if ( e->key() == Qt::Key_F1 ) {
2303     e->accept();
2304     ClickOnHelp();
2305   }
2306 }
2307
2308 //=================================================================================
2309 // function : initSpinBox()
2310 // purpose  :
2311 //=================================================================================
2312 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2313                                          double min,  double max,
2314                                          double step, const char* quantity )
2315 {
2316   // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2317   // TODO: Think how to keep the single piece of code...
2318
2319   // Obtain precision from preferences
2320   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2321   int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2322   
2323   spinBox->setPrecision( aPrecision );
2324   spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2325                                               // by default Qt rounds boundaries to 2 decimals at setRange
2326   spinBox->setRange( min, max );
2327   spinBox->setSingleStep( step );
2328   
2329   // Add a hint for the user saying how to tune precision
2330   QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2331   spinBox->setProperty( "validity_tune_hint", 
2332                         QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2333 }
2334
2335 //=================================================================================
2336 // function : SetDoubleSpinBoxStep()
2337 // purpose  : Double spin box management
2338 //=================================================================================
2339 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2340 {
2341   Group1Spin->SpinBox_DX->setSingleStep(step);
2342   Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2343   Group2Spin->SpinBox_DX->setSingleStep(step);
2344   Group2Spin->SpinBox_DY->setSingleStep(step);
2345   Group3Spin->SpinBox_DX->setSingleStep(step);
2346   Group3Spin->SpinBox_DY->setSingleStep(step);
2347   Group3Spin->SpinBox_DZ->setSingleStep(step);
2348   Group4Spin->SpinBox_DZ->setSingleStep(step);
2349
2350   // san: Do NOT override the step when a speicifc step value is used
2351   // in some input fields!
2352   //Group4Spin->SpinBox_DX->setSingleStep(step);
2353   //Group4Spin->SpinBox_DY->setSingleStep(step);
2354   //Group4Spin->SpinBox_DS->setSingleStep(step);
2355 }
2356
2357 //=================================================================================
2358 // function : FindLocalCS()
2359 // purpose  : Find All Coordinates systems in study
2360 //=================================================================================
2361 void EntityGUI_SketcherDlg::FindLocalCS()
2362 {
2363   ComboBox1->clear();
2364   myLCSList.clear();
2365   SalomeApp_Application* app =
2366     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2367   if ( !app )
2368     return;
2369
2370   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2371   if ( !appStudy )
2372     return;
2373
2374   _PTR(Study) aStudy = appStudy->studyDS();
2375
2376   //add Global CS
2377   ComboBox1->addItem(tr("GEOM_GCS"));
2378   gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2379   gp_Dir aDirZ = gp_Dir(0, 0, 1);
2380   gp_Dir aDirX = gp_Dir(1, 0, 0);
2381   gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2382   myLCSList.push_back(globalCS);
2383
2384   // get GEOM component
2385   CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2386   _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2387   if (!obj)
2388     return;
2389   _PTR(SComponent) fc = obj->GetFatherComponent();
2390   QString geomComp = fc->GetID().c_str();
2391   _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2392   if ( !comp )
2393     return;
2394
2395   // browse through all GEOM data tree
2396   _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2397   for ( it->InitEx( true ); it->More(); it->Next() ) {
2398     _PTR(SObject) child( it->Value() );
2399     CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2400     GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2401     if( CORBA::is_nil( geomObj ) ) 
2402       continue;
2403     if (geomObj->GetType() == GEOM_MARKER) {
2404       ComboBox1->addItem(geomObj->GetName());
2405       TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2406       
2407       gp_Ax3 aLCS;
2408       aLCS.Transform(aShape.Location().Transformation());
2409       if (aShape.ShapeType() == TopAbs_FACE) {
2410         Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2411         if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2412           Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2413           gp_Pln aPln = aGPlane->Pln();
2414           aLCS = aPln.Position();
2415         }
2416       }
2417       myLCSList.push_back(aLCS);
2418     }
2419   }
2420 }
2421
2422 //rnc TODO
2423 //=================================================================================
2424 // function : getPnt1ConstructorId()
2425 // purpose  :
2426 //=================================================================================
2427 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2428
2429   int buttonId = GroupPt->ButtonGroup->checkedId(); 
2430   MESSAGE("buttonId = "<<buttonId)
2431   return buttonId;
2432 }
2433
2434 //=================================================================================
2435 // function : getPnt2ConstructorId()
2436 // purpose  :
2437 //=================================================================================
2438 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2439
2440   int buttonId = GroupPt2->ButtonGroup->checkedId(); 
2441   MESSAGE("buttonId = "<<buttonId)
2442   return buttonId;
2443 }
2444
2445 //=================================================================================
2446 // function : GetActiveLocalCS()
2447 // purpose  : Get Working plane
2448 //=================================================================================
2449 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2450 {
2451   int ind = ComboBox1->currentIndex();
2452   if (ind == -1)
2453     return myGeometryGUI->GetWorkingPlane();
2454
2455   gp_Ax3 aLCS = myLCSList.at(ind);
2456
2457   return aLCS;
2458 }
2459
2460 //=================================================================================
2461 // function : ActivateLocalCS()
2462 // purpose  : Activate & Fit Working plane
2463 //=================================================================================
2464 void EntityGUI_SketcherDlg::ActivateLocalCS()
2465 {
2466     myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2467     myGeometryGUI->ActiveWorkingPlane();
2468 }