1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET
30 #include "EntityGUI_SketcherDlg.h"
31 #include "Sketcher_Profile.hxx"
32 #include "utilities.h"
34 #include <BRep_Tool.hxx>
36 #include <TopoDS_Vertex.hxx>
38 #include <qpushbutton.h>
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)
51 setName("EntityGUI_SketcherDlg");
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);
61 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
63 setCaption(tr("GEOM_SKETCHER_TITLE"));
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"));
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"));
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"));
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"));
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);
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"));
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"));
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"));
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"));
120 Layout5->addMultiCellWidget(GroupPt, 1, 1, 0, 1);
121 Layout5->addWidget(GroupD1, 1, 0);
122 Layout5->addWidget(GroupD2, 1, 1);
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 /***************************************************************/
132 mySimulationTopoDs1.Nullify();
133 mySimulationTopoDs2.Nullify();
134 myEntityGUI = theEntityGUI;
136 /* Get setting of step value from file configuration */
137 QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
138 step = St.toDouble();
140 myGeomBase = new GEOMBase();
141 myGeomGUI = GEOMContext::GetGeomGUI();
142 myGeomGUI->SetActiveDialogBox((QDialog*)this);
143 myGeom = myGeomGUI->myComponentGeom;
145 myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom);
146 mySelection->AddFilter(myVertexFilter);
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()));
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()));
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)));
170 connect(Group1Sel->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
171 connect(Group1Sel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
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)));
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)));
195 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
196 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
198 /* Move widget on the botton right corner of main widget */
200 // myGeomBase->DefineDlgPosition( this, x, y );
202 myEntityGUI = theEntityGUI;
208 //=================================================================================
209 // function : ~EntityGUI_SketcherDlg()
210 // purpose : Destroys the object and frees any allocated resources
211 //=================================================================================
212 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
214 // no need to delete child widgets, Qt does it all for us
215 this->destroy(TRUE, TRUE);
219 //=================================================================================
222 //=================================================================================
223 void EntityGUI_SketcherDlg::Init()
226 myEditCurrentArgument = Group1Sel->LineEdit1;
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);
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);
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);
258 RadioButton1->setChecked(true);
266 mySketchState = FIRST_POINT;
267 this->TypeClicked(0);
273 //=================================================================================
274 // function : InitClick()
276 //=================================================================================
277 void EntityGUI_SketcherDlg::InitClick()
279 disconnect(mySelection, 0, this, 0);
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);
299 //=================================================================================
300 // function : TypeClicked()
301 // purpose : Radio button management
302 //=================================================================================
303 void EntityGUI_SketcherDlg::TypeClicked(int constructorId)
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);
312 else if(myConstructorId == 1) { // ARC
313 GroupD2->setEnabled(false);
314 RB_Dest1->setEnabled(false);
315 RB_Dest2->setChecked(true);
316 this->DestClicked(0);
322 //=================================================================================
323 // function : DestClicked()
324 // purpose : Radio button management
325 //=================================================================================
326 void EntityGUI_SketcherDlg::DestClicked(int constructorId)
332 if(constructorId == 1) { // Point
333 GroupPt->RB_Point1->setChecked(true);
335 this->PointClicked(1); // XY
337 else if(constructorId == 0) { // Direction
338 GroupD1->RB_Dir11->setChecked(true);
341 this->Dir1Clicked(2); // Angle
347 //=================================================================================
348 // function : PointClicked()
349 // purpose : Radio button management
350 //=================================================================================
351 void EntityGUI_SketcherDlg::PointClicked(int constructorId)
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"));
361 Group2Spin->SpinBox_DX->SetValue(myX);
363 Group2Spin->SpinBox_DY->SetValue(myY);
365 Group2Spin->buttonApply->setFocus();
366 this->MakeSimulationAndDisplay();
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"));
373 Group2Spin->SpinBox_DX->SetValue(myDX);
375 Group2Spin->SpinBox_DY->SetValue(myDY);
377 Group2Spin->buttonApply->setFocus();
378 this->MakeSimulationAndDisplay();
380 else if(constructorId == 2) { // Selection
381 mySketchType = PT_SEL;
382 myEditCurrentArgument = Group1Sel->LineEdit1;
383 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
385 Group1Sel->buttonApply->setFocus();
386 this->SelectionIntoArgument();
394 //=================================================================================
395 // function : Dir1Clicked()
396 // purpose : Radio button management
397 //=================================================================================
398 void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId)
400 myConstructorDirId = constructorId;
401 GroupD2->RB_Dir21->setChecked(true);
402 this->Dir2Clicked(2);
407 //=================================================================================
408 // function : Dir2Clicked()
409 // purpose : Radio button management
410 //=================================================================================
411 void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId)
416 if(myConstructorId == 0) { // SEGMENT
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();
427 if(constructorId == 2) { // Length
428 mySketchType = DIR_ANGLE_LENGTH;
429 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2"));
430 Group2Spin->SpinBox_DY->SetValue(myLength);
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);
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);
443 else if(myConstructorDirId == 0) { // Perpendicular
445 Group1Spin->buttonApply->setFocus();
447 if(constructorId == 2) { // Length
448 mySketchType = DIR_PER_LENGTH;
449 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
450 Group1Spin->SpinBox_DX->SetValue(myLength);
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);
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);
463 else if(myConstructorDirId == 1) { // Tangent
465 Group1Spin->buttonApply->setFocus();
467 if(constructorId == 2) { // Length
468 mySketchType = DIR_TAN_LENGTH;
469 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
470 Group1Spin->SpinBox_DX->SetValue(myLength);
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);
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);
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"));
489 Group3Spin->SpinBox_DX->SetValue(myDX);
491 Group3Spin->SpinBox_DY->SetValue(myDY);
493 Group3Spin->buttonApply->setFocus();
495 if(constructorId == 2) { // Length
496 mySketchType = DIR_DXDY_LENGTH;
497 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2"));
498 Group3Spin->SpinBox_DZ->SetValue(myLength);
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);
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);
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);
523 Group3Spin->SpinBox_DY->SetValue(myRadius);
525 Group3Spin->SpinBox_DZ->SetValue(myLength);
527 Group3Spin->buttonApply->setFocus();
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"));
537 Group2Spin->SpinBox_DX->SetValue(myRadius);
539 Group2Spin->SpinBox_DY->SetValue(myLength);
541 Group2Spin->buttonApply->setFocus();
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"));
551 Group2Spin->SpinBox_DX->SetValue(myRadius);
553 Group2Spin->SpinBox_DY->SetValue(myLength);
555 Group2Spin->buttonApply->setFocus();
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"));
566 Group4Spin->SpinBox_DX->SetValue(myDX);
568 Group4Spin->SpinBox_DY->SetValue(myDY);
570 Group4Spin->SpinBox_DZ->SetValue(myRadius);
572 Group4Spin->SpinBox_DS->SetValue(myLength);
574 Group4Spin->buttonApply->setFocus();
579 this->MakeSimulationAndDisplay();
584 //=================================================================================
585 // function : ClickOnCancel()
587 //=================================================================================
588 void EntityGUI_SketcherDlg::ClickOnCancel()
590 QAD_Application::getDesktop()->putInfo(tr(""));
591 myEntityGUI->EraseSimulationShape();
592 mySimulationTopoDs1.Nullify();
593 mySimulationTopoDs2.Nullify();
595 mySelection->ClearFilters();
596 disconnect(mySelection, 0, this, 0);
603 //=================================================================================
604 // function : ClickOnEnd()
606 //=================================================================================
607 void EntityGUI_SketcherDlg::ClickOnEnd()
609 if(mySketchState != FIRST_POINT && mySketchState != SECOND_POINT)
610 myEntityGUI->OnSketchEnd(myCommand.ascii());
612 this->ClickOnCancel();
617 //=================================================================================
618 // function : ClickOnClose()
620 //=================================================================================
621 void EntityGUI_SketcherDlg::ClickOnClose()
623 if(mySketchState != FIRST_POINT && mySketchState != SECOND_POINT) {
624 myCommand = myCommand + ":WW";
625 myEntityGUI->OnSketchEnd(myCommand.ascii());
628 this->ClickOnCancel();
633 //=================================================================================
634 // function : ClickOnApply()
636 //=================================================================================
637 void EntityGUI_SketcherDlg::ClickOnApply()
639 if(mySketchState == FIRST_POINT) {
640 mySketchState = SECOND_POINT;
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);
653 QString myNewCommand = this->GetNewCommand();
654 QString myCommandTemp = myCommand + myNewCommand;
656 Sketcher_Profile aProfile (myCommandTemp.ascii());
658 if(aProfile.IsDone()) {
659 myLastCommand = myCommand;
660 myCommand = myCommandTemp;
663 mySketchState = NEXT_POINT;
667 myLastOp = myConstructorId;
668 this->MakeSimulationAndDisplay();
673 //=================================================================================
674 // function : ClickOnUndo()
676 //=================================================================================
677 void EntityGUI_SketcherDlg::ClickOnUndo()
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);
685 myCommand = myLastCommand;
686 this->MakeSimulationAndDisplay();
691 //=================================================================================
692 // function : SelectionIntoArgument()
693 // purpose : Called when selection as changed
694 //=================================================================================
695 void EntityGUI_SketcherDlg::SelectionIntoArgument()
697 myEntityGUI->EraseSimulationShape();
699 Group1Sel->buttonApply->setEnabled(false);
700 Group1Sel->buttonApply->setFocus();
702 myEditCurrentArgument->setText("");
703 QString aString = "";
708 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
716 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
718 if(!myGeomBase->GetTopoFromSelection(mySelection, S)) {
719 // this->MakeSimulationAndDisplay();
723 if(myEditCurrentArgument == Group1Sel->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) {
726 Group1Sel->LineEdit1->setText(aString);
728 Group1Sel->buttonApply->setEnabled(true);
729 Group1Sel->buttonApply->setFocus();
730 this->MakeSimulationAndDisplay();
738 //=================================================================================
739 // function : SetEditCurrentArgument()
741 //=================================================================================
742 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
744 QPushButton* send = (QPushButton*)sender();
746 mySelection->ClearFilters();
747 if(send == Group1Sel->PushButton1) {
748 //Group1Sel->LineEdit1->setFocus();
749 myEditCurrentArgument = Group1Sel->LineEdit1;
751 mySelection->AddFilter(myVertexFilter);
752 this->SelectionIntoArgument();
757 //=================================================================================
758 // function : LineEditReturnPressed()
760 //=================================================================================
761 void EntityGUI_SketcherDlg::LineEditReturnPressed()
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);
775 //=================================================================================
776 // function : DeactivateActiveDialog()
778 //=================================================================================
779 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
781 this->setEnabled(false);
782 mySelection->ClearFilters();
783 disconnect(mySelection, 0, this, 0);
784 myEntityGUI->EraseSimulationShape();
785 myGeomGUI->SetActiveDialogBox(0);
790 //=================================================================================
791 // function : ActivateThisDialog()
793 //=================================================================================
794 void EntityGUI_SketcherDlg::ActivateThisDialog()
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);
808 //=================================================================================
809 // function : enterEvent [REDEFINED]
811 //=================================================================================
812 void EntityGUI_SketcherDlg::enterEvent(QEvent* e)
814 if(GroupConstructors->isEnabled())
816 this->ActivateThisDialog();
821 //=================================================================================
822 // function : closeEvent()
824 //=================================================================================
825 void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e)
827 /* same than click on cancel button */
828 this->ClickOnCancel();
833 //=================================================================================
834 // function : ValueChangedInSpinBox()
836 //=================================================================================
837 void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue)
839 QObject* send = (QObject*)sender();
840 Standard_Real vx, vy, vz, vs;
841 vx = vy = vz = vs = 0.0;
843 if(send == Group1Spin->SpinBox_DX) {
845 Group1Spin->buttonApply->setFocus();
847 else if(send == Group2Spin->SpinBox_DX) {
849 vy = Group2Spin->SpinBox_DY->GetValue();
850 Group2Spin->buttonApply->setFocus();
852 else if(send == Group2Spin->SpinBox_DY) {
853 vx = Group2Spin->SpinBox_DX->GetValue();
855 Group2Spin->buttonApply->setFocus();
857 else if(send == Group3Spin->SpinBox_DX) {
859 vy = Group3Spin->SpinBox_DY->GetValue();
860 vz = Group3Spin->SpinBox_DZ->GetValue();
861 Group3Spin->buttonApply->setFocus();
863 else if(send == Group3Spin->SpinBox_DY) {
864 vx = Group3Spin->SpinBox_DX->GetValue();
866 vz = Group3Spin->SpinBox_DZ->GetValue();
867 Group3Spin->buttonApply->setFocus();
869 else if(send == Group3Spin->SpinBox_DZ) {
870 vx = Group3Spin->SpinBox_DX->GetValue();
871 vy = Group3Spin->SpinBox_DY->GetValue();
873 Group3Spin->buttonApply->setFocus();
875 else if(send == Group4Spin->SpinBox_DX) {
877 vy = Group4Spin->SpinBox_DY->GetValue();
878 vz = Group4Spin->SpinBox_DZ->GetValue();
879 vs = Group4Spin->SpinBox_DS->GetValue();
880 Group4Spin->buttonApply->setFocus();
882 else if(send == Group4Spin->SpinBox_DY) {
883 vx = Group4Spin->SpinBox_DX->GetValue();
885 vz = Group4Spin->SpinBox_DZ->GetValue();
886 vs = Group4Spin->SpinBox_DS->GetValue();
887 Group4Spin->buttonApply->setFocus();
889 else if(send == Group4Spin->SpinBox_DZ) {
890 vx = Group4Spin->SpinBox_DX->GetValue();
891 vy = Group4Spin->SpinBox_DY->GetValue();
893 vs = Group4Spin->SpinBox_DS->GetValue();
894 Group4Spin->buttonApply->setFocus();
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();
901 Group4Spin->buttonApply->setFocus();
904 if(myConstructorId == 0) { // SEGMENT
905 if(mySketchType == PT_ABS) {
909 else if(mySketchType == PT_RELATIVE) {
913 else if(mySketchType == DIR_ANGLE_LENGTH) {
917 else if(mySketchType == DIR_ANGLE_X) {
921 else if(mySketchType == DIR_ANGLE_Y) {
925 else if(mySketchType == DIR_PER_LENGTH) {
928 else if(mySketchType == DIR_PER_X) {
931 else if(mySketchType == DIR_PER_Y) {
934 else if(mySketchType == DIR_TAN_LENGTH) {
937 else if(mySketchType == DIR_TAN_X) {
940 else if(mySketchType == DIR_TAN_Y) {
943 else if(mySketchType == DIR_DXDY_LENGTH) {
948 else if(mySketchType == DIR_DXDY_X) {
953 else if(mySketchType == DIR_DXDY_Y) {
959 else if(myConstructorId == 1) { // ARC
960 if(mySketchType == DIR_ANGLE_LENGTH) {
965 else if(mySketchType == DIR_PER_LENGTH) {
969 else if(mySketchType == DIR_TAN_LENGTH) {
973 else if(mySketchType == DIR_DXDY_LENGTH) {
981 this->MakeSimulationAndDisplay();
986 //=================================================================================
987 // function : GetNewCommand()
989 //=================================================================================
990 QString EntityGUI_SketcherDlg::GetNewCommand()
992 QString myNewCommand = "";
993 if(mySketchState == FIRST_POINT)
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);
1006 if(mySketchType == DIR_ANGLE_X) {
1007 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1008 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1010 if(mySketchType == DIR_ANGLE_Y) {
1011 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1012 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1014 if(mySketchType == DIR_PER_LENGTH) {
1015 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1016 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1018 if(mySketchType == DIR_PER_X) {
1019 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1020 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1022 if(mySketchType == DIR_PER_Y) {
1023 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1024 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
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);
1036 if(mySketchType == DIR_DXDY_X) {
1037 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1038 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1040 if(mySketchType == DIR_DXDY_Y) {
1041 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1042 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
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);
1050 if(mySketchType == DIR_PER_LENGTH) {
1051 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1052 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1054 if(mySketchType == DIR_TAN_LENGTH) {
1055 myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength);
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);
1062 return myNewCommand;
1066 //=================================================================================
1067 // function : MakeSimulationAndDisplay()
1069 //=================================================================================
1070 void EntityGUI_SketcherDlg::MakeSimulationAndDisplay()
1072 myEntityGUI->EraseSimulationShape();
1073 mySimulationTopoDs1.Nullify();
1074 mySimulationTopoDs2.Nullify();
1077 if(mySketchState == FIRST_POINT) {
1078 myCommand = "Sketch ";
1079 myCommand = myCommand + ":" + "F " + QString::number(myX) + " " + QString::number(myY);
1086 Sketcher_Profile aProfile1 (myCommand.ascii());
1088 if(aProfile1.IsDone()) {
1089 myShape = aProfile1.GetShape();
1090 mySimulationTopoDs1 = myShape;
1093 if(mySketchState != FIRST_POINT) {
1094 if(mySketchState == SECOND_POINT) {
1095 gp_Pnt pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape));
1100 TopoDS_Vertex V1, V2;
1101 TopExp::Vertices(TopoDS::Wire(myShape), V1, V2);
1102 gp_Pnt pt = BRep_Tool::Pnt(V2);
1105 if(myLastOp == 1) { // ARC
1106 myLastDir = aProfile1.GetLastDir();
1107 myLastX2 = myLastX1 - myLastDir.X();
1108 myLastY2 = myLastY1 - myLastDir.Y();
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();
1120 if ( mySimulationTopoDs2.IsNull() ) {
1121 if ( Group1Sel->isVisible() ) {
1122 Group1Sel->buttonApply->setEnabled(false);
1123 Group1Sel->buttonApply->setFocus();
1125 if ( Group1Spin->isVisible() ) {
1126 Group1Spin->buttonApply->setEnabled(false);
1127 Group1Spin->buttonApply->setFocus();
1129 if ( Group2Spin->isVisible() ) {
1130 Group2Spin->buttonApply->setEnabled(false);
1131 Group2Spin->buttonApply->setFocus();
1133 if ( Group3Spin->isVisible() ) {
1134 Group3Spin->buttonApply->setEnabled(false);
1135 Group3Spin->buttonApply->setFocus();
1137 if ( Group4Spin->isVisible() ) {
1138 Group4Spin->buttonApply->setEnabled(false);
1139 Group4Spin->buttonApply->setFocus();
1142 if ( Group1Sel->isVisible() ) {
1143 Group1Sel->buttonApply->setEnabled(true);
1144 Group1Sel->buttonApply->setFocus();
1146 if ( Group1Spin->isVisible() ) {
1147 Group1Spin->buttonApply->setEnabled(true);
1148 Group1Spin->buttonApply->setFocus();
1150 if ( Group2Spin->isVisible() ) {
1151 Group2Spin->buttonApply->setEnabled(true);
1152 Group2Spin->buttonApply->setFocus();
1154 if ( Group3Spin->isVisible() ) {
1155 Group3Spin->buttonApply->setEnabled(true);
1156 Group3Spin->buttonApply->setFocus();
1158 if ( Group4Spin->isVisible() ) {
1159 Group4Spin->buttonApply->setEnabled(true);
1160 Group4Spin->buttonApply->setFocus();
1165 myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2);
1167 catch(Standard_Failure) {
1168 MESSAGE("Exception catched in MakeSimulationAndDisplay");