Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[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(1); //Juste Shape2!!
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   /*  nbSel == 1  */
713   TopoDS_Shape S;
714   gp_Pnt myPoint1;
715   Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
716
717   if(!myGeomBase->GetTopoFromSelection(mySelection, S))
718     return;
719
720   if(myEditCurrentArgument == Group1Sel->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) {
721     myX = myPoint1.X();
722     myY = myPoint1.Y();
723     Group1Sel->LineEdit1->setText(aString);
724
725     Group1Sel->buttonApply->setEnabled(true);
726     Group1Sel->buttonApply->setFocus();
727     this->MakeSimulationAndDisplay();
728   }
729
730   return;
731 }
732
733
734 //=================================================================================
735 // function : SetEditCurrentArgument()
736 // purpose  :
737 //=================================================================================
738 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
739 {
740   QPushButton* send = (QPushButton*)sender();
741
742   mySelection->ClearFilters();
743   if(send == Group1Sel->PushButton1) {
744     //Group1Sel->LineEdit1->setFocus();
745     myEditCurrentArgument = Group1Sel->LineEdit1;
746   }
747   mySelection->AddFilter(myVertexFilter);
748   this->SelectionIntoArgument();
749   return;
750 }
751
752
753 //=================================================================================
754 // function : LineEditReturnPressed()
755 // purpose  :
756 //=================================================================================
757 void EntityGUI_SketcherDlg::LineEditReturnPressed()
758 {
759   /* User name of object input management                          */
760   /* If successfull the selection is changed and signal emitted... */
761   /* so SelectionIntoArgument() is automatically called.           */
762   const QString objectUserName = myEditCurrentArgument->text();
763   QWidget* thisWidget = (QWidget*)this;
764   if(myGeomBase->SelectionByNameInDialogs(thisWidget, objectUserName, mySelection))
765     myEditCurrentArgument->setText(objectUserName);
766
767   return;
768 }
769
770
771 //=================================================================================
772 // function : DeactivateActiveDialog()
773 // purpose  :
774 //=================================================================================
775 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
776 {
777   this->setEnabled(false);
778   mySelection->ClearFilters();
779   disconnect(mySelection, 0, this, 0);
780   myEntityGUI->EraseSimulationShape();
781   myGeomGUI->SetActiveDialogBox(0);
782   return;
783 }
784
785
786 //=================================================================================
787 // function : ActivateThisDialog()
788 // purpose  :
789 //=================================================================================
790 void EntityGUI_SketcherDlg::ActivateThisDialog()
791 {
792   /* Emit a signal to deactivate the active dialog */
793   myGeomGUI->EmitSignalDeactivateDialog();
794   this->setEnabled(true);
795   myGeomGUI->SetActiveDialogBox((QDialog*)this);
796   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
797   mySelection->AddFilter(myVertexFilter);
798   myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2);
799
800   return;
801 }
802
803
804 //=================================================================================
805 // function : enterEvent [REDEFINED]
806 // purpose  :
807 //=================================================================================
808 void EntityGUI_SketcherDlg::enterEvent(QEvent* e)
809 {
810   if(GroupConstructors->isEnabled())
811     return;
812   this->ActivateThisDialog();
813   return;
814 }
815
816
817 //=================================================================================
818 // function : closeEvent()
819 // purpose  :
820 //=================================================================================
821 void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e)
822 {
823   /* same than click on cancel button */
824   this->ClickOnCancel();
825   return;
826 }
827
828
829 //=================================================================================
830 // function : ValueChangedInSpinBox()
831 // purpose  :
832 //=================================================================================
833 void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue)
834 {
835   QObject* send = (QObject*)sender();
836   Standard_Real vx, vy, vz, vs;
837   vx = vy = vz = vs = 0.0;
838
839   if(send == Group1Spin->SpinBox_DX) {
840     vx = newValue;
841     Group1Spin->buttonApply->setFocus();
842   }
843   else if(send == Group2Spin->SpinBox_DX) {
844     vx = newValue;
845     vy = Group2Spin->SpinBox_DY->GetValue();
846     Group2Spin->buttonApply->setFocus();
847   }
848   else if(send == Group2Spin->SpinBox_DY) {
849     vx = Group2Spin->SpinBox_DX->GetValue();
850     vy = newValue;
851     Group2Spin->buttonApply->setFocus();
852   }
853   else if(send == Group3Spin->SpinBox_DX) {
854     vx = newValue;
855     vy = Group3Spin->SpinBox_DY->GetValue();
856     vz = Group3Spin->SpinBox_DZ->GetValue();
857     Group3Spin->buttonApply->setFocus();
858   }
859   else if(send == Group3Spin->SpinBox_DY) {
860     vx = Group3Spin->SpinBox_DX->GetValue();
861     vy = newValue;
862     vz = Group3Spin->SpinBox_DZ->GetValue();
863     Group3Spin->buttonApply->setFocus();
864   }
865   else if(send == Group3Spin->SpinBox_DZ) {
866     vx = Group3Spin->SpinBox_DX->GetValue();
867     vy = Group3Spin->SpinBox_DY->GetValue();
868     vz = newValue;
869     Group3Spin->buttonApply->setFocus();
870   }
871   else if(send == Group4Spin->SpinBox_DX) {
872     vx = newValue;
873     vy = Group4Spin->SpinBox_DY->GetValue();
874     vz = Group4Spin->SpinBox_DZ->GetValue();
875     vs = Group4Spin->SpinBox_DS->GetValue();
876     Group4Spin->buttonApply->setFocus();
877   }
878   else if(send == Group4Spin->SpinBox_DY) {
879     vx = Group4Spin->SpinBox_DX->GetValue();
880     vy = newValue;
881     vz = Group4Spin->SpinBox_DZ->GetValue();
882     vs = Group4Spin->SpinBox_DS->GetValue();
883     Group4Spin->buttonApply->setFocus();
884   }
885   else if(send == Group4Spin->SpinBox_DZ) {
886     vx = Group4Spin->SpinBox_DX->GetValue();
887     vy = Group4Spin->SpinBox_DY->GetValue();
888     vz = newValue;
889     vs = Group4Spin->SpinBox_DS->GetValue();
890     Group4Spin->buttonApply->setFocus();
891   }
892   else if(send == Group4Spin->SpinBox_DS) {
893     vx = Group4Spin->SpinBox_DX->GetValue();
894     vy = Group4Spin->SpinBox_DY->GetValue();
895     vz = Group4Spin->SpinBox_DZ->GetValue();
896     vs = newValue;
897     Group4Spin->buttonApply->setFocus();
898   }
899
900   if(myConstructorId == 0) {  // SEGMENT
901     if(mySketchType == PT_ABS) {
902       myX = vx;
903       myY = vy;
904     }
905     else if(mySketchType == PT_RELATIVE) {
906       myDX = vx;
907       myDY = vy;
908     }
909     else if(mySketchType == DIR_ANGLE_LENGTH) {
910       myAngle = vx;
911       myLength = vy;
912     }
913     else if(mySketchType == DIR_ANGLE_X) {
914       myAngle = vx;
915       myX = vy;
916     }
917     else if(mySketchType == DIR_ANGLE_Y) {
918       myAngle = vx;
919       myY = vy;
920     }
921     else if(mySketchType == DIR_PER_LENGTH) {
922       myLength = vx;
923     }
924     else if(mySketchType == DIR_PER_X) {
925       myX = vx;
926     }
927     else if(mySketchType == DIR_PER_Y) {
928       myY = vx;
929     }
930     else if(mySketchType == DIR_TAN_LENGTH) {
931       myLength = vx;
932     }
933     else if(mySketchType == DIR_TAN_X) {
934       myX = vx;
935     }
936     else if(mySketchType == DIR_TAN_Y) {
937       myY = vx;
938     }
939     else if(mySketchType == DIR_DXDY_LENGTH) {
940       myDX = vx;
941       myDY = vy;
942       myLength = vz;
943     }
944     else if(mySketchType == DIR_DXDY_X) {
945       myDX = vx;
946       myDY = vy;
947       myX = vz;
948     }
949     else if(mySketchType == DIR_DXDY_Y) {
950       myDX = vx;
951       myDY = vy;
952       myY = vz;
953     }
954   }
955   else if(myConstructorId == 1) {  // ARC
956     if(mySketchType == DIR_ANGLE_LENGTH) {
957       myAngle = vx;
958       myRadius = vy;
959       myLength = vz;
960     }
961     else if(mySketchType == DIR_PER_LENGTH) {
962       myRadius = vx;
963       myLength = vy;
964     }
965     else if(mySketchType == DIR_TAN_LENGTH) {
966       myRadius = vx;
967       myLength = vy;
968     }
969     else if(mySketchType == DIR_DXDY_LENGTH) {
970       myDX = vx;
971       myDY = vy;
972       myRadius = vz;
973       myLength = vs;
974     }
975   }
976
977   this->MakeSimulationAndDisplay();
978   return;
979 }
980
981
982 //=================================================================================
983 // function : GetNewCommand()
984 // purpose  :
985 //=================================================================================
986 QString EntityGUI_SketcherDlg::GetNewCommand()
987 {
988   QString myNewCommand = "";
989   if(mySketchState == FIRST_POINT)
990     return myNewCommand;
991
992   myNewCommand = ":";
993   if(myConstructorId == 0) {  // SEGMENT
994     if(mySketchType == PT_ABS || mySketchType == PT_SEL)
995       myNewCommand = myNewCommand + "TT " + QString::number(myX) + " " + QString::number(myY);
996     if(mySketchType == PT_RELATIVE)
997       myNewCommand = myNewCommand + "T " + QString::number(myDX) + " " + QString::number(myDY);
998     if(mySketchType == DIR_ANGLE_LENGTH) {
999       myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1000       myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1001     }
1002     if(mySketchType == DIR_ANGLE_X) {
1003       myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1004       myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1005     }
1006     if(mySketchType == DIR_ANGLE_Y) {
1007       myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1008       myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1009     }
1010     if(mySketchType == DIR_PER_LENGTH) {
1011       myNewCommand = myNewCommand + "R " + QString::number(90.0);
1012       myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1013     }
1014     if(mySketchType == DIR_PER_X) {
1015       myNewCommand = myNewCommand + "R " + QString::number(90.0);
1016       myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1017     }
1018     if(mySketchType == DIR_PER_Y) {
1019       myNewCommand = myNewCommand + "R " + QString::number(90.0);
1020       myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1021     }
1022     if(mySketchType == DIR_TAN_LENGTH)
1023       myNewCommand = myNewCommand + "L " + QString::number(myLength);
1024     if(mySketchType == DIR_TAN_X)
1025       myNewCommand = myNewCommand + "IX " + QString::number(myX);
1026     if(mySketchType == DIR_TAN_Y)
1027       myNewCommand = myNewCommand + "IY " + QString::number(myY);
1028     if(mySketchType == DIR_DXDY_LENGTH) {
1029       myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1030       myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1031     }
1032     if(mySketchType == DIR_DXDY_X) {
1033       myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1034       myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1035     }
1036     if(mySketchType == DIR_DXDY_Y) {
1037       myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1038       myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1039     }
1040   }
1041   else if(myConstructorId == 1) {  // ARC
1042     if(mySketchType == DIR_ANGLE_LENGTH) {
1043       myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1044       myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1045     }
1046     if(mySketchType == DIR_PER_LENGTH) {
1047       myNewCommand = myNewCommand + "R " + QString::number(90.0);
1048       myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1049     }
1050     if(mySketchType == DIR_TAN_LENGTH) {
1051       myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1052     }
1053     if(mySketchType == DIR_DXDY_LENGTH) {
1054       myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1055       myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1056     }
1057   }
1058   return myNewCommand;
1059 }
1060
1061
1062 //=================================================================================
1063 // function : MakeSimulationAndDisplay()
1064 // purpose  :
1065 //=================================================================================
1066 void EntityGUI_SketcherDlg::MakeSimulationAndDisplay()
1067 {
1068   myEntityGUI->EraseSimulationShape();
1069   mySimulationTopoDs1.Nullify();
1070   mySimulationTopoDs2.Nullify();
1071   
1072   try {
1073     if(mySketchState == FIRST_POINT) {
1074       myCommand = "Sketch ";
1075       myCommand = myCommand + ":" + "F " + QString::number(myX) + " " + QString::number(myY);
1076
1077       myLastX1 = myX;
1078       myLastY1 = myY;
1079
1080     }
1081
1082     Sketcher_Profile aProfile1 (myCommand.ascii());
1083
1084     if(aProfile1.IsDone()) {
1085       myShape = aProfile1.GetShape();
1086       mySimulationTopoDs1 = myShape;
1087     }
1088
1089     if(mySketchState != FIRST_POINT) {
1090       if(mySketchState == SECOND_POINT) {
1091         gp_Pnt pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape));
1092         myLastX1 = pt.X();
1093         myLastY1 = pt.Y();
1094       }
1095       else {
1096         TopoDS_Vertex V1, V2;
1097         TopExp::Vertices(TopoDS::Wire(myShape), V1, V2);
1098         gp_Pnt pt = BRep_Tool::Pnt(V2);
1099         myLastX1 = pt.X();
1100         myLastY1 = pt.Y();
1101         if(myLastOp == 1) {   // ARC
1102           myLastDir = aProfile1.GetLastDir();
1103           myLastX2 = myLastX1 - myLastDir.X();
1104           myLastY2 = myLastY1 - myLastDir.Y();
1105         }
1106       }
1107       QString myNewCommand = "Sketch ";
1108       myNewCommand = myNewCommand + ":" + "F " + QString::number(myLastX1) + " " + QString::number(myLastY1);
1109       if(mySketchState != SECOND_POINT && !((myLastX1 - myLastX2) == 0 && (myLastY1 - myLastY2) == 0))
1110         myNewCommand = myNewCommand + ":" + "D " + QString::number(myLastX1 - myLastX2) + " " + QString::number(myLastY1 - myLastY2);
1111       myNewCommand = myNewCommand + this->GetNewCommand();
1112       Sketcher_Profile aProfile2 (myNewCommand.ascii());
1113       if(aProfile2.IsDone())
1114         mySimulationTopoDs2 = aProfile2.GetShape();
1115
1116       if ( mySimulationTopoDs2.IsNull() ) {
1117         if ( Group1Sel->isVisible() ) {
1118           Group1Sel->buttonApply->setEnabled(false);
1119           Group1Sel->buttonApply->setFocus();
1120         }
1121         if ( Group1Spin->isVisible() ) {
1122           Group1Spin->buttonApply->setEnabled(false);
1123           Group1Spin->buttonApply->setFocus();
1124         }
1125         if ( Group2Spin->isVisible() ) {
1126           Group2Spin->buttonApply->setEnabled(false);
1127           Group2Spin->buttonApply->setFocus();
1128         }
1129         if ( Group3Spin->isVisible() ) {
1130           Group3Spin->buttonApply->setEnabled(false);
1131           Group3Spin->buttonApply->setFocus();
1132         }
1133         if ( Group4Spin->isVisible() ) {
1134           Group4Spin->buttonApply->setEnabled(false);
1135           Group4Spin->buttonApply->setFocus();
1136         }
1137       } else {
1138         if ( Group1Sel->isVisible() ) {
1139           Group1Sel->buttonApply->setEnabled(true);
1140           Group1Sel->buttonApply->setFocus();
1141         }
1142         if ( Group1Spin->isVisible() ) {
1143           Group1Spin->buttonApply->setEnabled(true);
1144           Group1Spin->buttonApply->setFocus();
1145         }
1146         if ( Group2Spin->isVisible() ) {
1147           Group2Spin->buttonApply->setEnabled(true);
1148           Group2Spin->buttonApply->setFocus();
1149         }
1150         if ( Group3Spin->isVisible() ) {
1151           Group3Spin->buttonApply->setEnabled(true);
1152           Group3Spin->buttonApply->setFocus();
1153         }
1154         if ( Group4Spin->isVisible() ) {
1155           Group4Spin->buttonApply->setEnabled(true);
1156           Group4Spin->buttonApply->setFocus();
1157         }
1158       }
1159     }
1160
1161     myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2);
1162   }
1163   catch(Standard_Failure) {
1164     MESSAGE("Exception catched in MakeSimulationAndDisplay");
1165     return;
1166   }
1167   return;
1168 }