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(1); //Juste Shape2!!
699 Group1Sel->buttonApply->setEnabled(false);
700 Group1Sel->buttonApply->setFocus();
702 myEditCurrentArgument->setText("");
703 QString aString = "";
708 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
715 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
717 if(!myGeomBase->GetTopoFromSelection(mySelection, S))
720 if(myEditCurrentArgument == Group1Sel->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) {
723 Group1Sel->LineEdit1->setText(aString);
725 Group1Sel->buttonApply->setEnabled(true);
726 Group1Sel->buttonApply->setFocus();
727 this->MakeSimulationAndDisplay();
734 //=================================================================================
735 // function : SetEditCurrentArgument()
737 //=================================================================================
738 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
740 QPushButton* send = (QPushButton*)sender();
742 mySelection->ClearFilters();
743 if(send == Group1Sel->PushButton1) {
744 //Group1Sel->LineEdit1->setFocus();
745 myEditCurrentArgument = Group1Sel->LineEdit1;
747 mySelection->AddFilter(myVertexFilter);
748 this->SelectionIntoArgument();
753 //=================================================================================
754 // function : LineEditReturnPressed()
756 //=================================================================================
757 void EntityGUI_SketcherDlg::LineEditReturnPressed()
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);
771 //=================================================================================
772 // function : DeactivateActiveDialog()
774 //=================================================================================
775 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
777 this->setEnabled(false);
778 mySelection->ClearFilters();
779 disconnect(mySelection, 0, this, 0);
780 myEntityGUI->EraseSimulationShape();
781 myGeomGUI->SetActiveDialogBox(0);
786 //=================================================================================
787 // function : ActivateThisDialog()
789 //=================================================================================
790 void EntityGUI_SketcherDlg::ActivateThisDialog()
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);
804 //=================================================================================
805 // function : enterEvent [REDEFINED]
807 //=================================================================================
808 void EntityGUI_SketcherDlg::enterEvent(QEvent* e)
810 if(GroupConstructors->isEnabled())
812 this->ActivateThisDialog();
817 //=================================================================================
818 // function : closeEvent()
820 //=================================================================================
821 void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e)
823 /* same than click on cancel button */
824 this->ClickOnCancel();
829 //=================================================================================
830 // function : ValueChangedInSpinBox()
832 //=================================================================================
833 void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue)
835 QObject* send = (QObject*)sender();
836 Standard_Real vx, vy, vz, vs;
837 vx = vy = vz = vs = 0.0;
839 if(send == Group1Spin->SpinBox_DX) {
841 Group1Spin->buttonApply->setFocus();
843 else if(send == Group2Spin->SpinBox_DX) {
845 vy = Group2Spin->SpinBox_DY->GetValue();
846 Group2Spin->buttonApply->setFocus();
848 else if(send == Group2Spin->SpinBox_DY) {
849 vx = Group2Spin->SpinBox_DX->GetValue();
851 Group2Spin->buttonApply->setFocus();
853 else if(send == Group3Spin->SpinBox_DX) {
855 vy = Group3Spin->SpinBox_DY->GetValue();
856 vz = Group3Spin->SpinBox_DZ->GetValue();
857 Group3Spin->buttonApply->setFocus();
859 else if(send == Group3Spin->SpinBox_DY) {
860 vx = Group3Spin->SpinBox_DX->GetValue();
862 vz = Group3Spin->SpinBox_DZ->GetValue();
863 Group3Spin->buttonApply->setFocus();
865 else if(send == Group3Spin->SpinBox_DZ) {
866 vx = Group3Spin->SpinBox_DX->GetValue();
867 vy = Group3Spin->SpinBox_DY->GetValue();
869 Group3Spin->buttonApply->setFocus();
871 else if(send == Group4Spin->SpinBox_DX) {
873 vy = Group4Spin->SpinBox_DY->GetValue();
874 vz = Group4Spin->SpinBox_DZ->GetValue();
875 vs = Group4Spin->SpinBox_DS->GetValue();
876 Group4Spin->buttonApply->setFocus();
878 else if(send == Group4Spin->SpinBox_DY) {
879 vx = Group4Spin->SpinBox_DX->GetValue();
881 vz = Group4Spin->SpinBox_DZ->GetValue();
882 vs = Group4Spin->SpinBox_DS->GetValue();
883 Group4Spin->buttonApply->setFocus();
885 else if(send == Group4Spin->SpinBox_DZ) {
886 vx = Group4Spin->SpinBox_DX->GetValue();
887 vy = Group4Spin->SpinBox_DY->GetValue();
889 vs = Group4Spin->SpinBox_DS->GetValue();
890 Group4Spin->buttonApply->setFocus();
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();
897 Group4Spin->buttonApply->setFocus();
900 if(myConstructorId == 0) { // SEGMENT
901 if(mySketchType == PT_ABS) {
905 else if(mySketchType == PT_RELATIVE) {
909 else if(mySketchType == DIR_ANGLE_LENGTH) {
913 else if(mySketchType == DIR_ANGLE_X) {
917 else if(mySketchType == DIR_ANGLE_Y) {
921 else if(mySketchType == DIR_PER_LENGTH) {
924 else if(mySketchType == DIR_PER_X) {
927 else if(mySketchType == DIR_PER_Y) {
930 else if(mySketchType == DIR_TAN_LENGTH) {
933 else if(mySketchType == DIR_TAN_X) {
936 else if(mySketchType == DIR_TAN_Y) {
939 else if(mySketchType == DIR_DXDY_LENGTH) {
944 else if(mySketchType == DIR_DXDY_X) {
949 else if(mySketchType == DIR_DXDY_Y) {
955 else if(myConstructorId == 1) { // ARC
956 if(mySketchType == DIR_ANGLE_LENGTH) {
961 else if(mySketchType == DIR_PER_LENGTH) {
965 else if(mySketchType == DIR_TAN_LENGTH) {
969 else if(mySketchType == DIR_DXDY_LENGTH) {
977 this->MakeSimulationAndDisplay();
982 //=================================================================================
983 // function : GetNewCommand()
985 //=================================================================================
986 QString EntityGUI_SketcherDlg::GetNewCommand()
988 QString myNewCommand = "";
989 if(mySketchState == FIRST_POINT)
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);
1002 if(mySketchType == DIR_ANGLE_X) {
1003 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1004 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1006 if(mySketchType == DIR_ANGLE_Y) {
1007 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1008 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1010 if(mySketchType == DIR_PER_LENGTH) {
1011 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1012 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1014 if(mySketchType == DIR_PER_X) {
1015 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1016 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1018 if(mySketchType == DIR_PER_Y) {
1019 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1020 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
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);
1032 if(mySketchType == DIR_DXDY_X) {
1033 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1034 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1036 if(mySketchType == DIR_DXDY_Y) {
1037 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1038 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
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);
1046 if(mySketchType == DIR_PER_LENGTH) {
1047 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1048 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1050 if(mySketchType == DIR_TAN_LENGTH) {
1051 myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength);
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);
1058 return myNewCommand;
1062 //=================================================================================
1063 // function : MakeSimulationAndDisplay()
1065 //=================================================================================
1066 void EntityGUI_SketcherDlg::MakeSimulationAndDisplay()
1068 myEntityGUI->EraseSimulationShape();
1069 mySimulationTopoDs1.Nullify();
1070 mySimulationTopoDs2.Nullify();
1073 if(mySketchState == FIRST_POINT) {
1074 myCommand = "Sketch ";
1075 myCommand = myCommand + ":" + "F " + QString::number(myX) + " " + QString::number(myY);
1082 Sketcher_Profile aProfile1 (myCommand.ascii());
1084 if(aProfile1.IsDone()) {
1085 myShape = aProfile1.GetShape();
1086 mySimulationTopoDs1 = myShape;
1089 if(mySketchState != FIRST_POINT) {
1090 if(mySketchState == SECOND_POINT) {
1091 gp_Pnt pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape));
1096 TopoDS_Vertex V1, V2;
1097 TopExp::Vertices(TopoDS::Wire(myShape), V1, V2);
1098 gp_Pnt pt = BRep_Tool::Pnt(V2);
1101 if(myLastOp == 1) { // ARC
1102 myLastDir = aProfile1.GetLastDir();
1103 myLastX2 = myLastX1 - myLastDir.X();
1104 myLastY2 = myLastY1 - myLastDir.Y();
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();
1116 if ( mySimulationTopoDs2.IsNull() ) {
1117 if ( Group1Sel->isVisible() ) {
1118 Group1Sel->buttonApply->setEnabled(false);
1119 Group1Sel->buttonApply->setFocus();
1121 if ( Group1Spin->isVisible() ) {
1122 Group1Spin->buttonApply->setEnabled(false);
1123 Group1Spin->buttonApply->setFocus();
1125 if ( Group2Spin->isVisible() ) {
1126 Group2Spin->buttonApply->setEnabled(false);
1127 Group2Spin->buttonApply->setFocus();
1129 if ( Group3Spin->isVisible() ) {
1130 Group3Spin->buttonApply->setEnabled(false);
1131 Group3Spin->buttonApply->setFocus();
1133 if ( Group4Spin->isVisible() ) {
1134 Group4Spin->buttonApply->setEnabled(false);
1135 Group4Spin->buttonApply->setFocus();
1138 if ( Group1Sel->isVisible() ) {
1139 Group1Sel->buttonApply->setEnabled(true);
1140 Group1Sel->buttonApply->setFocus();
1142 if ( Group1Spin->isVisible() ) {
1143 Group1Spin->buttonApply->setEnabled(true);
1144 Group1Spin->buttonApply->setFocus();
1146 if ( Group2Spin->isVisible() ) {
1147 Group2Spin->buttonApply->setEnabled(true);
1148 Group2Spin->buttonApply->setFocus();
1150 if ( Group3Spin->isVisible() ) {
1151 Group3Spin->buttonApply->setEnabled(true);
1152 Group3Spin->buttonApply->setFocus();
1154 if ( Group4Spin->isVisible() ) {
1155 Group4Spin->buttonApply->setEnabled(true);
1156 Group4Spin->buttonApply->setFocus();
1161 myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2);
1163 catch(Standard_Failure) {
1164 MESSAGE("Exception catched in MakeSimulationAndDisplay");