]> SALOME platform Git repositories - modules/geom.git/blob - src/EntityGUI/EntityGUI_SketcherDlg.cxx
Salome HOME
DCQ : new Sketcher
[modules/geom.git] / src / EntityGUI / EntityGUI_SketcherDlg.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : EntityGUI_SketcherDlg.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27 //  $Header: 
28
29 using namespace std;
30 #include "EntityGUI_SketcherDlg.h"
31 #include "Sketcher_Profile.hxx"
32 #include "utilities.h"
33
34 #include <BRep_Tool.hxx>
35 #include <TopExp.hxx>
36 #include <TopoDS_Vertex.hxx>
37
38 #include <qpushbutton.h>
39
40 //=================================================================================
41 // class    : EntityGUI_SketcherDlg()
42 // purpose  : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the 
43 //            name 'name' and widget flags set to 'f'.
44 //            The dialog will by default be modeless, unless you set 'modal' to
45 //            TRUE to construct a modal dialog.
46 //=================================================================================
47 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, EntityGUI* theEntityGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
48   :EntityGUI_Skeleton_QTD(parent, name, modal, fl)
49 {
50   if (!name)
51     setName("EntityGUI_SketcherDlg");
52
53   buttonCancel->setText(tr("GEOM_BUT_CANCEL"));
54   buttonEnd->setText(tr("GEOM_BUT_END_SKETCH"));
55   buttonClose->setText(tr("GEOM_BUT_CLOSE_SKETCH"));
56   GroupVal->close(TRUE);
57   GroupDest2->close(TRUE);
58   GroupDest3->close(TRUE);
59   resize(0, 0);
60
61   QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
62
63   setCaption(tr("GEOM_SKETCHER_TITLE"));
64
65   GroupConstructors->setTitle(tr("GEOM_SKETCHER_EL"));
66   RadioButton1->setText(tr("GEOM_SKETCHER_SEGMENT"));
67   RadioButton2->setText(tr("GEOM_SKETCHER_ARC"));
68   GroupDest->setTitle(tr("GEOM_SKETCHER_DEST"));
69   GroupDest1->setTitle(tr("GEOM_SKETCHER_TYPE"));
70   RB_Dest1->setText(tr("GEOM_SKETCHER_POINT"));
71   RB_Dest2->setText(tr("GEOM_SKETCHER_DIR"));
72
73   /***************************************************************/
74   GroupPt = new EntityGUI_Point_QTD(GroupDest, "GroupPt");
75   GroupPt->GroupPoint->setTitle(tr("GEOM_SKETCHER_POINT"));
76   GroupPt->RB_Point1->setText(tr("GEOM_SKETCHER_ABS"));
77   GroupPt->RB_Point2->setText(tr("GEOM_SKETCHER_REL"));
78   GroupPt->RB_Point3->setText(tr("GEOM_SKETCHER_SEL"));
79
80   GroupD1 = new EntityGUI_Dir1_QTD(GroupDest, "GroupD1");
81   GroupD1->GroupDir1->setTitle(tr("GEOM_SKETCHER_DIR"));
82   GroupD1->RB_Dir11->setText(tr("GEOM_SKETCHER_ANGLE"));
83   GroupD1->RB_Dir12->setText(tr("GEOM_SKETCHER_PER"));
84   GroupD1->RB_Dir13->setText(tr("GEOM_SKETCHER_TAN"));
85   GroupD1->RB_Dir14->setText(tr("GEOM_SKETCHER_VXVY"));
86
87   GroupD2 = new EntityGUI_Dir2_QTD(GroupDest, "GroupD2");
88   GroupD2->GroupDir2->setTitle(tr("GEOM_SKETCHER_DIR"));
89   GroupD2->RB_Dir21->setText(tr("GEOM_SKETCHER_LENGTH"));
90   GroupD2->RB_Dir22->setText(tr("GEOM_SKETCHER_X"));
91   GroupD2->RB_Dir23->setText(tr("GEOM_SKETCHER_Y"));
92
93   Group1Sel = new EntityGUI_1Sel_QTD(this, "Group1Sel");
94   Group1Sel->TextLabel1->setText(tr("GEOM_SKETCHER_POINT2"));
95   Group1Sel->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
96   Group1Sel->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO"));
97   Group1Sel->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
98   Group1Sel->PushButton1->setPixmap(image0);
99
100   Group1Spin = new EntityGUI_1Spin(this, "Group1Spin");
101   Group1Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
102   Group1Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO"));
103   Group1Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
104
105   Group2Spin = new EntityGUI_2Spin(this, "Group2Spin");
106   Group2Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
107   Group2Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO"));
108   Group2Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
109
110   Group3Spin = new EntityGUI_3Spin(this, "Group3Spin");
111   Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
112   Group3Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO"));
113   Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
114
115   Group4Spin = new EntityGUI_4Spin(this, "Group4Spin");
116   Group4Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
117   Group4Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO"));
118   Group4Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
119
120   Layout5->addMultiCellWidget(GroupPt, 1, 1, 0, 1);
121   Layout5->addWidget(GroupD1, 1, 0);
122   Layout5->addWidget(GroupD2, 1, 1);
123
124   Layout1->addWidget(Group1Sel, 2, 0);
125   Layout1->addWidget(Group1Spin, 2, 0);
126   Layout1->addWidget(Group2Spin, 2, 0);
127   Layout1->addWidget(Group3Spin, 2, 0);
128   Layout1->addWidget(Group4Spin, 2, 0);
129   /***************************************************************/
130
131   mySelection = Sel;
132   mySimulationTopoDs1.Nullify();
133   mySimulationTopoDs2.Nullify();
134   myEntityGUI = theEntityGUI;
135
136   /* Get setting of step value from file configuration */
137   QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
138   step = St.toDouble();
139
140   myGeomBase = new GEOMBase();
141   myGeomGUI = GEOMContext::GetGeomGUI();
142   myGeomGUI->SetActiveDialogBox((QDialog*)this);
143   myGeom = myGeomGUI->myComponentGeom;
144
145   myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom);
146   mySelection->AddFilter(myVertexFilter);
147
148   /* signals and slots connections */
149   connect(buttonEnd, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
150   connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnClose()));
151   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
152
153   connect(Group1Sel->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
154   connect(Group1Sel->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
155   connect(Group1Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
156   connect(Group1Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
157   connect(Group2Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
158   connect(Group2Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
159   connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
160   connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
161   connect(Group4Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
162   connect(Group4Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
163
164   connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(TypeClicked(int)));
165   connect(GroupDest1, SIGNAL(clicked(int)), this, SLOT(DestClicked(int)));
166   connect(GroupPt->GroupPoint, SIGNAL(clicked(int)), this, SLOT(PointClicked(int)));
167   connect(GroupD1->GroupDir1, SIGNAL(clicked(int)), this, SLOT(Dir1Clicked(int)));
168   connect(GroupD2->GroupDir2, SIGNAL(clicked(int)), this, SLOT(Dir2Clicked(int)));
169
170   connect(Group1Sel->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
171   connect(Group1Sel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
172
173   connect(Group1Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
174   connect(Group2Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
175   connect(Group2Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
176   connect(Group3Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
177   connect(Group3Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
178   connect(Group3Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
179   connect(Group4Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
180   connect(Group4Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
181   connect(Group4Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
182   connect(Group4Spin->SpinBox_DS, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
183
184   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1Spin->SpinBox_DX, SLOT(SetStep(double)));
185   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DX, SLOT(SetStep(double)));
186   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DY, SLOT(SetStep(double)));
187   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DX, SLOT(SetStep(double)));
188   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DY, SLOT(SetStep(double)));
189   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DZ, SLOT(SetStep(double)));
190   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DX, SLOT(SetStep(double)));
191   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DY, SLOT(SetStep(double)));
192   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DZ, SLOT(SetStep(double)));
193   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DS, SLOT(SetStep(double)));
194
195   connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
196   connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
197
198   /* Move widget on the botton right corner of main widget */
199 //   int x, y;
200 //   myGeomBase->DefineDlgPosition( this, x, y );
201
202   myEntityGUI = theEntityGUI;
203   this->Init();
204   this->show();
205 }
206
207
208 //=================================================================================
209 // function : ~EntityGUI_SketcherDlg()
210 // purpose  : Destroys the object and frees any allocated resources
211 //=================================================================================
212 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
213 {
214   // no need to delete child widgets, Qt does it all for us
215   this->destroy(TRUE, TRUE);
216 }
217
218
219 //=================================================================================
220 // function : Init()
221 // purpose  :
222 //=================================================================================
223 void EntityGUI_SketcherDlg::Init()
224 {
225   /* init variables */
226   myEditCurrentArgument = Group1Sel->LineEdit1;
227
228   /* min, max, step and decimals for spin boxes */
229   Group1Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3);
230   Group2Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3);
231   Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3);
232   Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3);
233   Group3Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3);
234   Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3);
235   Group4Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 0.1, 3);
236   Group4Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 0.1, 3);
237   Group4Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3);
238   Group4Spin->SpinBox_DS->RangeStepAndValidator(-999.999, 999.999, 5., 3);
239
240   Group1Spin->SpinBox_DX->SetValue(0.0);
241   Group2Spin->SpinBox_DX->SetValue(0.0);
242   Group2Spin->SpinBox_DY->SetValue(0.0);
243   Group3Spin->SpinBox_DX->SetValue(0.0);
244   Group3Spin->SpinBox_DY->SetValue(0.0);
245   Group3Spin->SpinBox_DZ->SetValue(0.0);
246   Group4Spin->SpinBox_DX->SetValue(0.0);
247   Group4Spin->SpinBox_DY->SetValue(0.0);
248   Group4Spin->SpinBox_DZ->SetValue(0.0);
249   Group4Spin->SpinBox_DS->SetValue(0.0);
250
251   /* displays Dialog */
252   Group1Sel->buttonUndo->setEnabled(false);
253   Group1Spin->buttonUndo->setEnabled(false);
254   Group2Spin->buttonUndo->setEnabled(false);
255   Group3Spin->buttonUndo->setEnabled(false);
256   Group4Spin->buttonUndo->setEnabled(false);
257
258   RadioButton1->setChecked(true);
259
260   myLastOp = 0;
261   myLastX1 = 0.0;
262   myLastY1 = 0.0;
263   myLastX2 = 0.0;
264   myLastY2 = 0.0;
265
266   mySketchState = FIRST_POINT;
267   this->TypeClicked(0);
268
269   return;
270 }
271
272
273 //=================================================================================
274 // function : InitClick()
275 // purpose  : 
276 //=================================================================================
277 void EntityGUI_SketcherDlg::InitClick()
278 {
279   disconnect(mySelection, 0, this, 0);
280
281   Group2Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3);
282   Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3);
283   Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3);
284   Group3Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3);
285   Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3);
286
287   Group1Sel->hide();
288   Group1Spin->hide();
289   Group2Spin->hide();
290   Group3Spin->hide();
291   Group4Spin->hide();
292
293   resize(0, 0);
294
295   return;
296 }
297
298
299 //=================================================================================
300 // function : TypeClicked()
301 // purpose  : Radio button management
302 //=================================================================================
303 void EntityGUI_SketcherDlg::TypeClicked(int constructorId)
304 {
305   myConstructorId = constructorId;
306   if(myConstructorId == 0) {  // SEGMENT
307     GroupD2->setEnabled(true);
308     RB_Dest1->setEnabled(true);
309     RB_Dest1->setChecked(true);
310     this->DestClicked(1);
311   }
312   else if(myConstructorId == 1) {  // ARC
313     GroupD2->setEnabled(false);
314     RB_Dest1->setEnabled(false);
315     RB_Dest2->setChecked(true);
316     this->DestClicked(0);
317   }
318   return;
319 }
320
321
322 //=================================================================================
323 // function : DestClicked()
324 // purpose  : Radio button management
325 //=================================================================================
326 void EntityGUI_SketcherDlg::DestClicked(int constructorId)
327 {
328   GroupPt->hide();
329   GroupD1->hide();
330   GroupD2->hide();
331
332   if(constructorId == 1) {  // Point
333     GroupPt->RB_Point1->setChecked(true);
334     GroupPt->show();
335     this->PointClicked(1);  // XY
336   }
337   else if(constructorId == 0) {  // Direction
338     GroupD1->RB_Dir11->setChecked(true);
339     GroupD1->show();
340     GroupD2->show();
341     this->Dir1Clicked(2);  // Angle
342   }
343   return;
344 }
345
346
347 //=================================================================================
348 // function : PointClicked()
349 // purpose  : Radio button management
350 //=================================================================================
351 void EntityGUI_SketcherDlg::PointClicked(int constructorId)
352 {
353   this->InitClick();
354
355   if(myConstructorId == 0) {  // SEGMENT
356     if(constructorId == 1) {  // XY
357       mySketchType = PT_ABS;
358       Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
359       Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
360       myX = 0.0;
361       Group2Spin->SpinBox_DX->SetValue(myX);
362       myY = 0.0;
363       Group2Spin->SpinBox_DY->SetValue(myY);
364       Group2Spin->show();
365       Group2Spin->buttonApply->setFocus();
366       this->MakeSimulationAndDisplay();
367     }
368     else if(constructorId == 0) {  // DXDY
369       mySketchType = PT_RELATIVE;
370       Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2"));
371       Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2"));
372       myDX = 0.0;
373       Group2Spin->SpinBox_DX->SetValue(myDX);
374       myDY = 0.0;
375       Group2Spin->SpinBox_DY->SetValue(myDY);
376       Group2Spin->show();
377       Group2Spin->buttonApply->setFocus();
378       this->MakeSimulationAndDisplay();
379     }
380     else if(constructorId == 2) {  // Selection
381       mySketchType = PT_SEL;
382       myEditCurrentArgument = Group1Sel->LineEdit1;
383       connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
384       Group1Sel->show();
385       Group1Sel->buttonApply->setFocus();
386       this->SelectionIntoArgument();
387     }
388   }
389
390   return;
391 }
392
393
394 //=================================================================================
395 // function : Dir1Clicked()
396 // purpose  : Radio button management
397 //=================================================================================
398 void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId)
399 {
400   myConstructorDirId = constructorId;
401   GroupD2->RB_Dir21->setChecked(true);
402   this->Dir2Clicked(2);
403   return;
404 }
405
406
407 //=================================================================================
408 // function : Dir2Clicked()
409 // purpose  : Radio button management
410 //=================================================================================
411 void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId)
412 {
413   this->InitClick();
414   myAngle = 0.0;
415
416   if(myConstructorId == 0) {  // SEGMENT
417     myX = 0.0;
418     myY = 0.0;
419     myLength = 100.0;
420     if(myConstructorDirId == 2) {  // Angle
421       Group2Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 5., 3);
422       Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
423       Group2Spin->SpinBox_DX->SetValue(myAngle);
424       Group2Spin->buttonApply->setFocus();
425       Group2Spin->show();
426
427       if(constructorId == 2) {  // Length
428         mySketchType = DIR_ANGLE_LENGTH;
429         Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2"));
430         Group2Spin->SpinBox_DY->SetValue(myLength);
431       }
432       else if(constructorId == 0) {  // X
433         mySketchType = DIR_ANGLE_X;
434         Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_X3"));
435         Group2Spin->SpinBox_DY->SetValue(myX);
436       }
437       else if(constructorId == 1) {  // Y
438         mySketchType = DIR_ANGLE_Y;
439         Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y3"));
440         Group2Spin->SpinBox_DY->SetValue(myY);
441       }
442     }
443     else if(myConstructorDirId == 0) {  // Perpendicular
444       Group1Spin->show();
445       Group1Spin->buttonApply->setFocus();
446
447       if(constructorId == 2) {  // Length
448         mySketchType = DIR_PER_LENGTH;
449         Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
450         Group1Spin->SpinBox_DX->SetValue(myLength);
451       }
452       else if(constructorId == 0) {  // X
453         mySketchType = DIR_PER_X;
454         Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
455         Group1Spin->SpinBox_DX->SetValue(myX);
456       }
457       else if(constructorId == 1) {  // Y
458         mySketchType = DIR_PER_Y;
459         Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
460         Group1Spin->SpinBox_DX->SetValue(myY);
461       }
462     }
463     else if(myConstructorDirId == 1) {  // Tangent
464       Group1Spin->show();
465       Group1Spin->buttonApply->setFocus();
466
467       if(constructorId == 2) {  // Length
468         mySketchType = DIR_TAN_LENGTH;
469         Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
470         Group1Spin->SpinBox_DX->SetValue(myLength);
471       }
472       else if(constructorId == 0) {  // X
473         mySketchType = DIR_TAN_X;
474         Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
475         Group1Spin->SpinBox_DX->SetValue(myX);
476       }
477       else if(constructorId == 1) {  // Y
478         mySketchType = DIR_TAN_Y;
479         Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
480         Group1Spin->SpinBox_DX->SetValue(myY);
481       }
482     }
483     else if(myConstructorDirId == 3) {  // DXDY
484       Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 0.1, 3);
485       Group3Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 0.1, 3);
486       Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
487       Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
488       myDX = 0.0;
489       Group3Spin->SpinBox_DX->SetValue(myDX);
490       myDY = 0.0;
491       Group3Spin->SpinBox_DY->SetValue(myDY);
492       Group3Spin->show();
493       Group3Spin->buttonApply->setFocus();
494
495       if(constructorId == 2) {  // Length
496         mySketchType = DIR_DXDY_LENGTH;
497         Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2"));
498         Group3Spin->SpinBox_DZ->SetValue(myLength);
499       }
500       else if(constructorId == 0) {  // X
501         mySketchType = DIR_DXDY_X;
502         Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_X3"));
503         Group3Spin->SpinBox_DZ->SetValue(myX);
504       }
505       else if(constructorId == 1) {  // Y
506         mySketchType = DIR_DXDY_Y;
507         Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Y3"));
508         Group3Spin->SpinBox_DZ->SetValue(myY);
509       }
510     }
511   }
512   else if(myConstructorId == 1) {  // ARC
513     if(myConstructorDirId == 2) {  // Angle
514       if(constructorId == 2) {  // Length
515         mySketchType = DIR_ANGLE_LENGTH;
516         Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 5., 3);
517         Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, 5., 3);
518         Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
519         Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_RADIUS2"));
520         Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_ANGLE2"));
521         Group3Spin->SpinBox_DX->SetValue(myAngle);
522         myRadius = 100.0;
523         Group3Spin->SpinBox_DY->SetValue(myRadius);
524         myLength = 30.0;
525         Group3Spin->SpinBox_DZ->SetValue(myLength);
526         Group3Spin->show();
527         Group3Spin->buttonApply->setFocus();
528       }
529     }
530     else if(myConstructorDirId == 0) {  // Perpendicular
531       if(constructorId == 2) {  // Length
532         mySketchType = DIR_PER_LENGTH;
533         Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 5., 3);
534         Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
535         Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
536         myRadius = 100.0;
537         Group2Spin->SpinBox_DX->SetValue(myRadius);
538         myLength = 30.0;
539         Group2Spin->SpinBox_DY->SetValue(myLength);
540         Group2Spin->show();
541         Group2Spin->buttonApply->setFocus();
542       }
543     }
544     else if(myConstructorDirId == 1) {  // Tangent
545       if(constructorId == 2) {  // Length
546         mySketchType = DIR_TAN_LENGTH;
547         Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 5., 3);
548         Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
549         Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
550         myRadius = 100.0;
551         Group2Spin->SpinBox_DX->SetValue(myRadius);
552         myLength = 30.0;
553         Group2Spin->SpinBox_DY->SetValue(myLength);
554         Group2Spin->show();
555         Group2Spin->buttonApply->setFocus();
556       }
557     }
558     else if(myConstructorDirId == 3) {  // DXDY
559       if(constructorId == 2) {  // Length
560         mySketchType = DIR_DXDY_LENGTH;
561         Group4Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
562         Group4Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
563         Group4Spin->TextLabel3->setText(tr("GEOM_SKETCHER_RADIUS2"));
564         Group4Spin->TextLabel4->setText(tr("GEOM_SKETCHER_ANGLE2"));
565         myDX = 0.0;
566         Group4Spin->SpinBox_DX->SetValue(myDX);
567         myDY = 0.0;
568         Group4Spin->SpinBox_DY->SetValue(myDY);
569         myRadius = 100.0;
570         Group4Spin->SpinBox_DZ->SetValue(myRadius);
571         myLength = 30.0;
572         Group4Spin->SpinBox_DS->SetValue(myLength);
573         Group4Spin->show();
574         Group4Spin->buttonApply->setFocus();
575       }
576     }
577   }
578
579   this->MakeSimulationAndDisplay();
580   return;
581 }
582
583
584 //=================================================================================
585 // function : ClickOnCancel()
586 // purpose  :
587 //=================================================================================
588 void EntityGUI_SketcherDlg::ClickOnCancel()
589 {
590   QAD_Application::getDesktop()->putInfo(tr(""));
591   myEntityGUI->EraseSimulationShape();
592   mySimulationTopoDs1.Nullify();
593   mySimulationTopoDs2.Nullify();
594
595   mySelection->ClearFilters();
596   disconnect(mySelection, 0, this, 0);
597
598   reject();
599   return;
600 }
601
602
603 //=================================================================================
604 // function : ClickOnEnd()
605 // purpose  :
606 //=================================================================================
607 void EntityGUI_SketcherDlg::ClickOnEnd()
608 {
609   if(mySketchState != FIRST_POINT && mySketchState != SECOND_POINT)
610     myEntityGUI->OnSketchEnd(myCommand.ascii());
611
612   this->ClickOnCancel();
613   return;
614 }
615
616
617 //=================================================================================
618 // function : ClickOnClose()
619 // purpose  :
620 //=================================================================================
621 void EntityGUI_SketcherDlg::ClickOnClose()
622 {
623   if(mySketchState != FIRST_POINT && mySketchState != SECOND_POINT) {
624     myCommand = myCommand + ":WW";
625     myEntityGUI->OnSketchEnd(myCommand.ascii());
626   }
627
628   this->ClickOnCancel();
629   return;
630 }
631
632
633 //=================================================================================
634 // function : ClickOnApply()
635 // purpose  :
636 //=================================================================================
637 void EntityGUI_SketcherDlg::ClickOnApply()
638 {
639   if(mySketchState == FIRST_POINT) {
640     mySketchState = SECOND_POINT;
641     myLastX2 = myLastX1;
642     myLastY2 = myLastY1;
643   }
644   else {
645     if(mySketchState != SECOND_POINT) {
646       Group1Sel->buttonUndo->setEnabled(true);
647       Group1Spin->buttonUndo->setEnabled(true);
648       Group2Spin->buttonUndo->setEnabled(true);
649       Group3Spin->buttonUndo->setEnabled(true);
650       Group4Spin->buttonUndo->setEnabled(true);
651     }
652
653     QString myNewCommand = this->GetNewCommand();
654     QString myCommandTemp = myCommand + myNewCommand;
655
656     Sketcher_Profile aProfile (myCommandTemp.ascii());
657
658     if(aProfile.IsDone()) {
659       myLastCommand = myCommand;
660       myCommand = myCommandTemp;
661       myLastX2 = myLastX1;
662       myLastY2 = myLastY1;
663       mySketchState = NEXT_POINT;
664     }
665   }
666
667   myLastOp = myConstructorId;
668   this->MakeSimulationAndDisplay();
669   return;
670 }
671
672
673 //=================================================================================
674 // function : ClickOnUndo()
675 // purpose  :
676 //=================================================================================
677 void EntityGUI_SketcherDlg::ClickOnUndo()
678 {
679   Group1Sel->buttonUndo->setEnabled(false);
680   Group1Spin->buttonUndo->setEnabled(false);
681   Group2Spin->buttonUndo->setEnabled(false);
682   Group3Spin->buttonUndo->setEnabled(false);
683   Group4Spin->buttonUndo->setEnabled(false);
684
685   myCommand = myLastCommand;
686   this->MakeSimulationAndDisplay();
687   return;
688 }
689
690
691 //=================================================================================
692 // function : SelectionIntoArgument()
693 // purpose  : Called when selection as changed
694 //=================================================================================
695 void EntityGUI_SketcherDlg::SelectionIntoArgument()
696 {
697   myEntityGUI->EraseSimulationShape();
698
699   Group1Sel->buttonApply->setEnabled(false);
700   Group1Sel->buttonApply->setFocus();
701
702   myEditCurrentArgument->setText("");
703   QString aString = "";
704
705   myX = 0.0;
706   myY = 0.0;
707
708   int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
709   if(nbSel != 1) {
710     return;
711   }
712
713   /*  nbSel == 1  */
714   TopoDS_Shape S;
715   gp_Pnt myPoint1;
716   Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
717
718   if(!myGeomBase->GetTopoFromSelection(mySelection, S)) {
719     //    this->MakeSimulationAndDisplay();
720     return;
721   }
722
723   if(myEditCurrentArgument == Group1Sel->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) {
724     myX = myPoint1.X();
725     myY = myPoint1.Y();
726     Group1Sel->LineEdit1->setText(aString);
727
728     Group1Sel->buttonApply->setEnabled(true);
729     Group1Sel->buttonApply->setFocus();
730     this->MakeSimulationAndDisplay();
731   }
732
733
734   return;
735 }
736
737
738 //=================================================================================
739 // function : SetEditCurrentArgument()
740 // purpose  :
741 //=================================================================================
742 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
743 {
744   QPushButton* send = (QPushButton*)sender();
745
746   mySelection->ClearFilters();
747   if(send == Group1Sel->PushButton1) {
748     //Group1Sel->LineEdit1->setFocus();
749     myEditCurrentArgument = Group1Sel->LineEdit1;
750   }
751   mySelection->AddFilter(myVertexFilter);
752   this->SelectionIntoArgument();
753   return;
754 }
755
756
757 //=================================================================================
758 // function : LineEditReturnPressed()
759 // purpose  :
760 //=================================================================================
761 void EntityGUI_SketcherDlg::LineEditReturnPressed()
762 {
763   /* User name of object input management                          */
764   /* If successfull the selection is changed and signal emitted... */
765   /* so SelectionIntoArgument() is automatically called.           */
766   const QString objectUserName = myEditCurrentArgument->text();
767   QWidget* thisWidget = (QWidget*)this;
768   if(myGeomBase->SelectionByNameInDialogs(thisWidget, objectUserName, mySelection))
769     myEditCurrentArgument->setText(objectUserName);
770
771   return;
772 }
773
774
775 //=================================================================================
776 // function : DeactivateActiveDialog()
777 // purpose  :
778 //=================================================================================
779 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
780 {
781   this->setEnabled(false);
782   mySelection->ClearFilters();
783   disconnect(mySelection, 0, this, 0);
784   myEntityGUI->EraseSimulationShape();
785   myGeomGUI->SetActiveDialogBox(0);
786   return;
787 }
788
789
790 //=================================================================================
791 // function : ActivateThisDialog()
792 // purpose  :
793 //=================================================================================
794 void EntityGUI_SketcherDlg::ActivateThisDialog()
795 {
796   /* Emit a signal to deactivate the active dialog */
797   myGeomGUI->EmitSignalDeactivateDialog();
798   this->setEnabled(true);
799   myGeomGUI->SetActiveDialogBox((QDialog*)this);
800   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
801   mySelection->AddFilter(myVertexFilter);
802   myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2);
803
804   return;
805 }
806
807
808 //=================================================================================
809 // function : enterEvent [REDEFINED]
810 // purpose  :
811 //=================================================================================
812 void EntityGUI_SketcherDlg::enterEvent(QEvent* e)
813 {
814   if(GroupConstructors->isEnabled())
815     return;
816   this->ActivateThisDialog();
817   return;
818 }
819
820
821 //=================================================================================
822 // function : closeEvent()
823 // purpose  :
824 //=================================================================================
825 void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e)
826 {
827   /* same than click on cancel button */
828   this->ClickOnCancel();
829   return;
830 }
831
832
833 //=================================================================================
834 // function : ValueChangedInSpinBox()
835 // purpose  :
836 //=================================================================================
837 void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue)
838 {
839   QObject* send = (QObject*)sender();
840   Standard_Real vx, vy, vz, vs;
841   vx = vy = vz = vs = 0.0;
842
843   if(send == Group1Spin->SpinBox_DX) {
844     vx = newValue;
845     Group1Spin->buttonApply->setFocus();
846   }
847   else if(send == Group2Spin->SpinBox_DX) {
848     vx = newValue;
849     vy = Group2Spin->SpinBox_DY->GetValue();
850     Group2Spin->buttonApply->setFocus();
851   }
852   else if(send == Group2Spin->SpinBox_DY) {
853     vx = Group2Spin->SpinBox_DX->GetValue();
854     vy = newValue;
855     Group2Spin->buttonApply->setFocus();
856   }
857   else if(send == Group3Spin->SpinBox_DX) {
858     vx = newValue;
859     vy = Group3Spin->SpinBox_DY->GetValue();
860     vz = Group3Spin->SpinBox_DZ->GetValue();
861     Group3Spin->buttonApply->setFocus();
862   }
863   else if(send == Group3Spin->SpinBox_DY) {
864     vx = Group3Spin->SpinBox_DX->GetValue();
865     vy = newValue;
866     vz = Group3Spin->SpinBox_DZ->GetValue();
867     Group3Spin->buttonApply->setFocus();
868   }
869   else if(send == Group3Spin->SpinBox_DZ) {
870     vx = Group3Spin->SpinBox_DX->GetValue();
871     vy = Group3Spin->SpinBox_DY->GetValue();
872     vz = newValue;
873     Group3Spin->buttonApply->setFocus();
874   }
875   else if(send == Group4Spin->SpinBox_DX) {
876     vx = newValue;
877     vy = Group4Spin->SpinBox_DY->GetValue();
878     vz = Group4Spin->SpinBox_DZ->GetValue();
879     vs = Group4Spin->SpinBox_DS->GetValue();
880     Group4Spin->buttonApply->setFocus();
881   }
882   else if(send == Group4Spin->SpinBox_DY) {
883     vx = Group4Spin->SpinBox_DX->GetValue();
884     vy = newValue;
885     vz = Group4Spin->SpinBox_DZ->GetValue();
886     vs = Group4Spin->SpinBox_DS->GetValue();
887     Group4Spin->buttonApply->setFocus();
888   }
889   else if(send == Group4Spin->SpinBox_DZ) {
890     vx = Group4Spin->SpinBox_DX->GetValue();
891     vy = Group4Spin->SpinBox_DY->GetValue();
892     vz = newValue;
893     vs = Group4Spin->SpinBox_DS->GetValue();
894     Group4Spin->buttonApply->setFocus();
895   }
896   else if(send == Group4Spin->SpinBox_DS) {
897     vx = Group4Spin->SpinBox_DX->GetValue();
898     vy = Group4Spin->SpinBox_DY->GetValue();
899     vz = Group4Spin->SpinBox_DZ->GetValue();
900     vs = newValue;
901     Group4Spin->buttonApply->setFocus();
902   }
903
904   if(myConstructorId == 0) {  // SEGMENT
905     if(mySketchType == PT_ABS) {
906       myX = vx;
907       myY = vy;
908     }
909     else if(mySketchType == PT_RELATIVE) {
910       myDX = vx;
911       myDY = vy;
912     }
913     else if(mySketchType == DIR_ANGLE_LENGTH) {
914       myAngle = vx;
915       myLength = vy;
916     }
917     else if(mySketchType == DIR_ANGLE_X) {
918       myAngle = vx;
919       myX = vy;
920     }
921     else if(mySketchType == DIR_ANGLE_Y) {
922       myAngle = vx;
923       myY = vy;
924     }
925     else if(mySketchType == DIR_PER_LENGTH) {
926       myLength = vx;
927     }
928     else if(mySketchType == DIR_PER_X) {
929       myX = vx;
930     }
931     else if(mySketchType == DIR_PER_Y) {
932       myY = vx;
933     }
934     else if(mySketchType == DIR_TAN_LENGTH) {
935       myLength = vx;
936     }
937     else if(mySketchType == DIR_TAN_X) {
938       myX = vx;
939     }
940     else if(mySketchType == DIR_TAN_Y) {
941       myY = vx;
942     }
943     else if(mySketchType == DIR_DXDY_LENGTH) {
944       myDX = vx;
945       myDY = vy;
946       myLength = vz;
947     }
948     else if(mySketchType == DIR_DXDY_X) {
949       myDX = vx;
950       myDY = vy;
951       myX = vz;
952     }
953     else if(mySketchType == DIR_DXDY_Y) {
954       myDX = vx;
955       myDY = vy;
956       myY = vz;
957     }
958   }
959   else if(myConstructorId == 1) {  // ARC
960     if(mySketchType == DIR_ANGLE_LENGTH) {
961       myAngle = vx;
962       myRadius = vy;
963       myLength = vz;
964     }
965     else if(mySketchType == DIR_PER_LENGTH) {
966       myRadius = vx;
967       myLength = vy;
968     }
969     else if(mySketchType == DIR_TAN_LENGTH) {
970       myRadius = vx;
971       myLength = vy;
972     }
973     else if(mySketchType == DIR_DXDY_LENGTH) {
974       myDX = vx;
975       myDY = vy;
976       myRadius = vz;
977       myLength = vs;
978     }
979   }
980
981   this->MakeSimulationAndDisplay();
982   return;
983 }
984
985
986 //=================================================================================
987 // function : GetNewCommand()
988 // purpose  :
989 //=================================================================================
990 QString EntityGUI_SketcherDlg::GetNewCommand()
991 {
992   QString myNewCommand = "";
993   if(mySketchState == FIRST_POINT)
994     return myNewCommand;
995
996   myNewCommand = ":";
997   if(myConstructorId == 0) {  // SEGMENT
998     if(mySketchType == PT_ABS || mySketchType == PT_SEL)
999       myNewCommand = myNewCommand + "TT " + QString::number(myX) + " " + QString::number(myY);
1000     if(mySketchType == PT_RELATIVE)
1001       myNewCommand = myNewCommand + "T " + QString::number(myDX) + " " + QString::number(myDY);
1002     if(mySketchType == DIR_ANGLE_LENGTH) {
1003       myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1004       myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1005     }
1006     if(mySketchType == DIR_ANGLE_X) {
1007       myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1008       myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1009     }
1010     if(mySketchType == DIR_ANGLE_Y) {
1011       myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1012       myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1013     }
1014     if(mySketchType == DIR_PER_LENGTH) {
1015       myNewCommand = myNewCommand + "R " + QString::number(90.0);
1016       myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1017     }
1018     if(mySketchType == DIR_PER_X) {
1019       myNewCommand = myNewCommand + "R " + QString::number(90.0);
1020       myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1021     }
1022     if(mySketchType == DIR_PER_Y) {
1023       myNewCommand = myNewCommand + "R " + QString::number(90.0);
1024       myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1025     }
1026     if(mySketchType == DIR_TAN_LENGTH)
1027       myNewCommand = myNewCommand + "L " + QString::number(myLength);
1028     if(mySketchType == DIR_TAN_X)
1029       myNewCommand = myNewCommand + "IX " + QString::number(myX);
1030     if(mySketchType == DIR_TAN_Y)
1031       myNewCommand = myNewCommand + "IY " + QString::number(myY);
1032     if(mySketchType == DIR_DXDY_LENGTH) {
1033       myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1034       myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1035     }
1036     if(mySketchType == DIR_DXDY_X) {
1037       myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1038       myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1039     }
1040     if(mySketchType == DIR_DXDY_Y) {
1041       myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1042       myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1043     }
1044   }
1045   else if(myConstructorId == 1) {  // ARC
1046     if(mySketchType == DIR_ANGLE_LENGTH) {
1047       myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1048       myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1049     }
1050     if(mySketchType == DIR_PER_LENGTH) {
1051       myNewCommand = myNewCommand + "R " + QString::number(90.0);
1052       myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1053     }
1054     if(mySketchType == DIR_TAN_LENGTH) {
1055       myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1056     }
1057     if(mySketchType == DIR_DXDY_LENGTH) {
1058       myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1059       myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1060     }
1061   }
1062   return myNewCommand;
1063 }
1064
1065
1066 //=================================================================================
1067 // function : MakeSimulationAndDisplay()
1068 // purpose  :
1069 //=================================================================================
1070 void EntityGUI_SketcherDlg::MakeSimulationAndDisplay()
1071 {
1072   myEntityGUI->EraseSimulationShape();
1073   mySimulationTopoDs1.Nullify();
1074   mySimulationTopoDs2.Nullify();
1075   
1076   try {
1077     if(mySketchState == FIRST_POINT) {
1078       myCommand = "Sketch ";
1079       myCommand = myCommand + ":" + "F " + QString::number(myX) + " " + QString::number(myY);
1080
1081       myLastX1 = myX;
1082       myLastY1 = myY;
1083
1084     }
1085
1086     Sketcher_Profile aProfile1 (myCommand.ascii());
1087
1088     if(aProfile1.IsDone()) {
1089       myShape = aProfile1.GetShape();
1090       mySimulationTopoDs1 = myShape;
1091     }
1092
1093     if(mySketchState != FIRST_POINT) {
1094       if(mySketchState == SECOND_POINT) {
1095         gp_Pnt pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape));
1096         myLastX1 = pt.X();
1097         myLastY1 = pt.Y();
1098       }
1099       else {
1100         TopoDS_Vertex V1, V2;
1101         TopExp::Vertices(TopoDS::Wire(myShape), V1, V2);
1102         gp_Pnt pt = BRep_Tool::Pnt(V2);
1103         myLastX1 = pt.X();
1104         myLastY1 = pt.Y();
1105         if(myLastOp == 1) {   // ARC
1106           myLastDir = aProfile1.GetLastDir();
1107           myLastX2 = myLastX1 - myLastDir.X();
1108           myLastY2 = myLastY1 - myLastDir.Y();
1109         }
1110       }
1111       QString myNewCommand = "Sketch ";
1112       myNewCommand = myNewCommand + ":" + "F " + QString::number(myLastX1) + " " + QString::number(myLastY1);
1113       if(mySketchState != SECOND_POINT && !((myLastX1 - myLastX2) == 0 && (myLastY1 - myLastY2) == 0))
1114         myNewCommand = myNewCommand + ":" + "D " + QString::number(myLastX1 - myLastX2) + " " + QString::number(myLastY1 - myLastY2);
1115       myNewCommand = myNewCommand + this->GetNewCommand();
1116       Sketcher_Profile aProfile2 (myNewCommand.ascii());
1117       if(aProfile2.IsDone())
1118         mySimulationTopoDs2 = aProfile2.GetShape();
1119
1120       if ( mySimulationTopoDs2.IsNull() ) {
1121         if ( Group1Sel->isVisible() ) {
1122           Group1Sel->buttonApply->setEnabled(false);
1123           Group1Sel->buttonApply->setFocus();
1124         }
1125         if ( Group1Spin->isVisible() ) {
1126           Group1Spin->buttonApply->setEnabled(false);
1127           Group1Spin->buttonApply->setFocus();
1128         }
1129         if ( Group2Spin->isVisible() ) {
1130           Group2Spin->buttonApply->setEnabled(false);
1131           Group2Spin->buttonApply->setFocus();
1132         }
1133         if ( Group3Spin->isVisible() ) {
1134           Group3Spin->buttonApply->setEnabled(false);
1135           Group3Spin->buttonApply->setFocus();
1136         }
1137         if ( Group4Spin->isVisible() ) {
1138           Group4Spin->buttonApply->setEnabled(false);
1139           Group4Spin->buttonApply->setFocus();
1140         }
1141       } else {
1142         if ( Group1Sel->isVisible() ) {
1143           Group1Sel->buttonApply->setEnabled(true);
1144           Group1Sel->buttonApply->setFocus();
1145         }
1146         if ( Group1Spin->isVisible() ) {
1147           Group1Spin->buttonApply->setEnabled(true);
1148           Group1Spin->buttonApply->setFocus();
1149         }
1150         if ( Group2Spin->isVisible() ) {
1151           Group2Spin->buttonApply->setEnabled(true);
1152           Group2Spin->buttonApply->setFocus();
1153         }
1154         if ( Group3Spin->isVisible() ) {
1155           Group3Spin->buttonApply->setEnabled(true);
1156           Group3Spin->buttonApply->setFocus();
1157         }
1158         if ( Group4Spin->isVisible() ) {
1159           Group4Spin->buttonApply->setEnabled(true);
1160           Group4Spin->buttonApply->setFocus();
1161         }
1162       }
1163     }
1164
1165     myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2);
1166   }
1167   catch(Standard_Failure) {
1168     MESSAGE("Exception catched in MakeSimulationAndDisplay");
1169     return;
1170   }
1171   return;
1172 }