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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET
29 #include "EntityGUI_SketcherDlg.h"
30 #include "Sketcher_Profile.hxx"
31 #include "GEOM_Displayer.h"
34 #include "SUIT_Desktop.h"
35 #include "SUIT_Session.h"
36 #include "SUIT_MessageBox.h"
37 #include "SUIT_ResourceMgr.h"
38 #include "SalomeApp_Application.h"
39 #include "LightApp_Application.h"
40 #include "LightApp_SelectionMgr.h"
42 #include <qpushbutton.h>
45 #include <BRep_Tool.hxx>
47 #include <TopExp_Explorer.hxx>
48 #include <TopoDS_Vertex.hxx>
50 #include <BRepBuilderAPI_Transform.hxx>
51 #include <BRepBuilderAPI_MakeWire.hxx>
53 #include "GEOMImpl_Types.hxx"
55 #include "utilities.h"
59 //=================================================================================
60 // class : EntityGUI_SketcherDlg()
61 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
62 // name 'name' and widget flags set to 'f'.
63 // The dialog will by default be modeless, unless you set 'modal' to
64 // TRUE to construct a modal dialog.
65 //=================================================================================
66 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(GeometryGUI* GUI, QWidget* parent,
67 const char* name, bool modal, WFlags fl)
68 :EntityGUI_Skeleton_QTD(parent, name, modal, WStyle_Customize |
69 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
70 myIsAllAdded( false ),
71 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
74 myGeometryGUI->SetActiveDialogBox(this);
76 if ( !name ) setName("EntityGUI_SketcherDlg");
78 buttonCancel->setText(tr("GEOM_BUT_CANCEL"));
79 buttonEnd->setText(tr("GEOM_BUT_END_SKETCH"));
80 buttonClose->setText(tr("GEOM_BUT_CLOSE_SKETCH"));
81 buttonHelp->setText(tr("GEOM_BUT_HELP"));
83 GroupVal->close(TRUE);
84 GroupDest2->close(TRUE);
85 GroupDest3->close(TRUE);
87 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
88 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_UNDO")));
89 QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_REDO")));
91 setCaption(tr("GEOM_SKETCHER_TITLE"));
93 GroupConstructors->setTitle(tr("GEOM_SKETCHER_EL"));
94 RadioButton1->setText(tr("GEOM_SKETCHER_SEGMENT"));
95 RadioButton2->setText(tr("GEOM_SKETCHER_ARC"));
96 GroupDest->setTitle(tr("GEOM_SKETCHER_DEST"));
97 GroupDest1->setTitle(tr("GEOM_SKETCHER_TYPE"));
98 RB_Dest1->setText(tr("GEOM_SKETCHER_POINT"));
99 RB_Dest2->setText(tr("GEOM_SKETCHER_DIR"));
101 /***************************************************************/
102 GroupPt = new EntityGUI_Point_QTD(GroupDest, "GroupPt");
103 GroupPt->GroupPoint->setTitle(tr("GEOM_SKETCHER_POINT"));
104 GroupPt->RB_Point1->setText(tr("GEOM_SKETCHER_ABS"));
105 GroupPt->RB_Point2->setText(tr("GEOM_SKETCHER_REL"));
106 GroupPt->RB_Point3->setText(tr("GEOM_SKETCHER_SEL"));
108 GroupD1 = new EntityGUI_Dir1_QTD(GroupDest, "GroupD1");
109 GroupD1->GroupDir1->setTitle(tr("GEOM_SKETCHER_DIR"));
110 GroupD1->RB_Dir11->setText(tr("GEOM_SKETCHER_ANGLE"));
111 GroupD1->RB_Dir12->setText(tr("GEOM_SKETCHER_PER"));
112 GroupD1->RB_Dir13->setText(tr("GEOM_SKETCHER_TAN"));
113 GroupD1->RB_Dir14->setText(tr("GEOM_SKETCHER_VXVY"));
115 GroupD2 = new EntityGUI_Dir2_QTD(GroupDest, "GroupD2");
116 GroupD2->GroupDir2->setTitle(tr("GEOM_SKETCHER_DIR"));
117 GroupD2->RB_Dir21->setText(tr("GEOM_SKETCHER_LENGTH"));
118 GroupD2->RB_Dir22->setText(tr("GEOM_SKETCHER_X"));
119 GroupD2->RB_Dir23->setText(tr("GEOM_SKETCHER_Y"));
121 Group1Sel = new EntityGUI_1Sel_QTD(this, "Group1Sel");
122 Group1Sel->TextLabel1->setText(tr("GEOM_SKETCHER_POINT2"));
123 Group1Sel->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
124 Group1Sel->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
125 Group1Sel->PushButton1->setPixmap(image0);
126 Group1Sel->buttonUndo->setPixmap(image1);
127 Group1Sel->buttonRedo->setPixmap(image2);
128 Group1Sel->LineEdit1->setReadOnly( true );
130 Group1Spin = new EntityGUI_1Spin(this, "Group1Spin");
131 Group1Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
132 Group1Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
133 Group1Spin->buttonUndo->setPixmap(image1);
134 Group1Spin->buttonRedo->setPixmap(image2);
136 Group2Spin = new EntityGUI_2Spin(this, "Group2Spin");
137 Group2Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
138 Group2Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
139 Group2Spin->buttonUndo->setPixmap(image1);
140 Group2Spin->buttonRedo->setPixmap(image2);
142 Group3Spin = new EntityGUI_3Spin(this, "Group3Spin");
143 Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
144 Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
145 Group3Spin->buttonUndo->setPixmap(image1);
146 Group3Spin->buttonRedo->setPixmap(image2);
148 Group4Spin = new EntityGUI_4Spin(this, "Group4Spin");
149 Group4Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
150 Group4Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
151 Group4Spin->buttonUndo->setPixmap(image1);
152 Group4Spin->buttonRedo->setPixmap(image2);
154 Layout5->addMultiCellWidget(GroupPt, 1, 1, 0, 1);
155 Layout5->addWidget(GroupD1, 1, 0);
156 Layout5->addWidget(GroupD2, 1, 1);
158 Layout1->addWidget(Group1Sel, 2, 0);
159 Layout1->addWidget(Group1Spin, 2, 0);
160 Layout1->addWidget(Group2Spin, 2, 0);
161 Layout1->addWidget(Group3Spin, 2, 0);
162 Layout1->addWidget(Group4Spin, 2, 0);
163 /***************************************************************/
165 /* signals and slots connections */
166 connect(buttonEnd, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
167 connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
168 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
169 connect(buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp()));
171 connect(Group1Sel->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
172 connect(Group1Sel->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
173 connect(Group1Sel->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
174 connect(Group1Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
175 connect(Group1Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
176 connect(Group1Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
177 connect(Group2Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
178 connect(Group2Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
179 connect(Group2Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
180 connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
181 connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
182 connect(Group3Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
183 connect(Group4Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
184 connect(Group4Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
185 connect(Group4Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
187 connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(TypeClicked(int)));
188 connect(GroupDest1, SIGNAL(clicked(int)), this, SLOT(DestClicked(int)));
189 connect(GroupPt->GroupPoint, SIGNAL(clicked(int)), this, SLOT(PointClicked(int)));
190 connect(GroupD1->GroupDir1, SIGNAL(clicked(int)), this, SLOT(Dir1Clicked(int)));
191 connect(GroupD2->GroupDir2, SIGNAL(clicked(int)), this, SLOT(Dir2Clicked(int)));
193 connect(Group1Sel->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
194 connect(Group1Sel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
196 connect(Group1Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
197 connect(Group2Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
198 connect(Group2Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
199 connect(Group3Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
200 connect(Group3Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
201 connect(Group3Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
202 connect(Group4Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
203 connect(Group4Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
204 connect(Group4Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
205 connect(Group4Spin->SpinBox_DS, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
207 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1Spin->SpinBox_DX, SLOT(SetStep(double)));
208 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DX, SLOT(SetStep(double)));
209 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DY, SLOT(SetStep(double)));
210 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DX, SLOT(SetStep(double)));
211 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DY, SLOT(SetStep(double)));
212 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DZ, SLOT(SetStep(double)));
213 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DX, SLOT(SetStep(double)));
214 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DY, SLOT(SetStep(double)));
215 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DZ, SLOT(SetStep(double)));
216 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DS, SLOT(SetStep(double)));
218 connect(myGeometryGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
219 connect(myGeometryGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
225 //=================================================================================
226 // function : ~EntityGUI_SketcherDlg()
227 // purpose : Destroys the object and frees any allocated resources
228 //=================================================================================
229 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
231 myGeometryGUI->SetActiveDialogBox( 0 );
235 //=================================================================================
238 //=================================================================================
239 void EntityGUI_SketcherDlg::Init()
242 myEditCurrentArgument = Group1Sel->LineEdit1;
243 myCommand.append( "Sketcher" );
244 myUndoCommand.append( "Sketcher" );
246 mySketchState = FIRST_POINT;
247 globalSelection( GEOM_POINT );
254 myHelpFileName = "sketcher.htm";
256 /* Get setting of step value from file configuration */
257 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
259 /* min, max, step and decimals for spin boxes */
260 Group1Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
261 Group2Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
262 Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
263 Group3Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
264 Group3Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
265 Group3Spin->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
266 Group4Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.1, 3);
267 Group4Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.1, 3);
268 Group4Spin->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
269 Group4Spin->SpinBox_DS->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., 3);
271 /* displays Dialog */
272 GroupConstructors->setEnabled(false);
273 GroupDest1->setEnabled(false);
274 setEnabledUndo(false);
275 setEnabledRedo(false);
277 RadioButton1->setChecked(true);
282 GEOMBase_Helper::displayPreview();
286 //=================================================================================
287 // function : InitClick()
289 //=================================================================================
290 void EntityGUI_SketcherDlg::InitClick()
292 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
304 //=================================================================================
305 // function : TypeClicked()
306 // purpose : Radio button management
307 //=================================================================================
308 void EntityGUI_SketcherDlg::TypeClicked(int constructorId)
310 myConstructorId = constructorId;
311 if ( myConstructorId == 0 ) // SEGMENT
313 GroupD2->setEnabled(true);
314 RB_Dest1->setEnabled(true);
315 RB_Dest1->setChecked(true);
318 else if ( myConstructorId == 1 ) // ARC
320 GroupD2->setEnabled(false);
321 RB_Dest1->setEnabled(false);
322 RB_Dest2->setChecked(true);
328 //=================================================================================
329 // function : DestClicked()
330 // purpose : Radio button management
331 //=================================================================================
332 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
338 if ( constructorId == 1 )
340 GroupPt->RB_Point1->setChecked(true);
342 PointClicked(1); // XY
344 else if ( constructorId == 0 )
346 GroupD1->RB_Dir11->setChecked(true);
349 Dir1Clicked(2); // Angle
354 //=================================================================================
355 // function : PointClicked()
356 // purpose : Radio button management
357 //=================================================================================
358 void EntityGUI_SketcherDlg::PointClicked(int constructorId)
362 if ( myConstructorId == 0 )
364 if ( constructorId == 1 )
366 mySketchType = PT_ABS;
367 Group2Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 100., 3);
368 Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 100., 3);
369 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
370 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
372 Group2Spin->SpinBox_DX->SetValue(myX);
374 Group2Spin->SpinBox_DY->SetValue(myY);
376 Group2Spin->buttonApply->setFocus();
378 GEOMBase_Helper::displayPreview();
380 else if ( constructorId == 0 )
382 mySketchType = PT_RELATIVE;
383 Group2Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 100., 3);
384 Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 100., 3);
385 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2"));
386 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2"));
388 Group2Spin->SpinBox_DX->SetValue(myDX);
390 Group2Spin->SpinBox_DY->SetValue(myDY);
392 Group2Spin->buttonApply->setFocus();
394 GEOMBase_Helper::displayPreview();
396 else if ( constructorId == 2 )
398 mySketchType = PT_SEL;
399 myEditCurrentArgument = Group1Sel->LineEdit1;
400 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
401 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
403 Group1Sel->buttonApply->setFocus();
404 SelectionIntoArgument();
410 //=================================================================================
411 // function : Dir1Clicked()
412 // purpose : Radio button management
413 //=================================================================================
414 void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId)
416 myConstructorDirId = constructorId;
417 GroupD2->RB_Dir21->setChecked(true);
422 //=================================================================================
423 // function : Dir2Clicked()
424 // purpose : Radio button management
425 //=================================================================================
426 void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId)
431 if ( myConstructorId == 0 )
436 if ( myConstructorDirId == 2 )
438 Group2Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., 3);
439 Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 100., 3);
440 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
441 Group2Spin->SpinBox_DX->SetValue(myAngle);
442 Group2Spin->buttonApply->setFocus();
445 if ( constructorId == 2 )
447 mySketchType = DIR_ANGLE_LENGTH;
448 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2"));
449 Group2Spin->SpinBox_DY->SetValue(myLength);
451 else if ( constructorId == 0 )
453 mySketchType = DIR_ANGLE_X;
454 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_X3"));
455 Group2Spin->SpinBox_DY->SetValue(myX);
457 else if ( constructorId == 1 )
459 mySketchType = DIR_ANGLE_Y;
460 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y3"));
461 Group2Spin->SpinBox_DY->SetValue(myY);
464 else if ( myConstructorDirId == 0 )
467 Group1Spin->buttonApply->setFocus();
469 if ( constructorId == 2 )
471 mySketchType = DIR_PER_LENGTH;
472 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
473 Group1Spin->SpinBox_DX->SetValue(myLength);
475 else if ( constructorId == 0 )
477 mySketchType = DIR_PER_X;
478 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
479 Group1Spin->SpinBox_DX->SetValue(myX);
481 else if ( constructorId == 1 )
483 mySketchType = DIR_PER_Y;
484 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
485 Group1Spin->SpinBox_DX->SetValue(myY);
488 else if ( myConstructorDirId == 1 )
491 Group1Spin->buttonApply->setFocus();
493 if ( constructorId == 2 )
495 mySketchType = DIR_TAN_LENGTH;
496 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
497 Group1Spin->SpinBox_DX->SetValue(myLength);
499 else if ( constructorId == 0 )
501 mySketchType = DIR_TAN_X;
502 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
503 Group1Spin->SpinBox_DX->SetValue(myX);
505 else if ( constructorId == 1 )
507 mySketchType = DIR_TAN_Y;
508 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
509 Group1Spin->SpinBox_DX->SetValue(myY);
512 else if ( myConstructorDirId == 3 )
514 Group3Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.1, 3);
515 Group3Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.1, 3);
516 Group3Spin->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 100., 3);
517 Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
518 Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
520 Group3Spin->SpinBox_DX->SetValue(myDX);
522 Group3Spin->SpinBox_DY->SetValue(myDY);
524 Group3Spin->buttonApply->setFocus();
526 if ( constructorId == 2 )
528 mySketchType = DIR_DXDY_LENGTH;
529 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2"));
530 Group3Spin->SpinBox_DZ->SetValue(myLength);
532 else if ( constructorId == 0 )
534 mySketchType = DIR_DXDY_X;
535 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_X3"));
536 Group3Spin->SpinBox_DZ->SetValue(myX);
538 else if ( constructorId == 1 )
540 mySketchType = DIR_DXDY_Y;
541 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Y3"));
542 Group3Spin->SpinBox_DZ->SetValue(myY);
546 else if ( myConstructorId == 1 )
548 if ( myConstructorDirId == 2 )
550 if ( constructorId == 2 )
552 mySketchType = DIR_ANGLE_LENGTH;
553 Group3Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., 3);
554 Group3Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 100., 3);
555 Group3Spin->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., 3);
556 Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
557 Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_RADIUS2"));
558 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_ANGLE2"));
559 Group3Spin->SpinBox_DX->SetValue(myAngle);
561 Group3Spin->SpinBox_DY->SetValue(myRadius);
563 Group3Spin->SpinBox_DZ->SetValue(myLength);
565 Group3Spin->buttonApply->setFocus();
568 else if ( myConstructorDirId == 0 )
570 if ( constructorId == 2 )
572 mySketchType = DIR_PER_LENGTH;
573 Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 100., 3);
574 Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., 3);
575 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
576 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
578 Group2Spin->SpinBox_DX->SetValue(myRadius);
580 Group2Spin->SpinBox_DY->SetValue(myLength);
582 Group2Spin->buttonApply->setFocus();
585 else if ( myConstructorDirId == 1 )
587 if ( constructorId == 2 )
589 mySketchType = DIR_TAN_LENGTH;
590 Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 100., 3);
591 Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., 3);
592 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
593 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
595 Group2Spin->SpinBox_DX->SetValue(myRadius);
597 Group2Spin->SpinBox_DY->SetValue(myLength);
599 Group2Spin->buttonApply->setFocus();
602 else if ( myConstructorDirId == 3 )
604 if ( constructorId == 2 )
606 mySketchType = DIR_DXDY_LENGTH;
607 Group4Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
608 Group4Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
609 Group4Spin->TextLabel3->setText(tr("GEOM_SKETCHER_RADIUS2"));
610 Group4Spin->TextLabel4->setText(tr("GEOM_SKETCHER_ANGLE2"));
612 Group4Spin->SpinBox_DX->SetValue(myDX);
614 Group4Spin->SpinBox_DY->SetValue(myDY);
616 Group4Spin->SpinBox_DZ->SetValue(myRadius);
618 Group4Spin->SpinBox_DS->SetValue(myLength);
620 Group4Spin->buttonApply->setFocus();
625 GEOMBase_Helper::displayPreview();
629 //=================================================================================
630 // function : ClickOnCancel()
632 //=================================================================================
633 void EntityGUI_SketcherDlg::ClickOnCancel()
639 //=================================================================================
640 // function : ClickOnEnd()
641 // purpose : connected to buttonEnd AND buttonClose
642 //=================================================================================
643 void EntityGUI_SketcherDlg::ClickOnEnd()
645 if ( sender() == buttonClose )
647 // Verify validity of commands
648 if ( myCommand.count() <= 2 )
650 SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(),
651 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
655 QString Command = myCommand.join( "" ) + GetNewCommand();
656 Sketcher_Profile aProfile (Command.ascii());
658 Command = myCommand.join( "" );
659 aProfile = Sketcher_Profile(Command.ascii());
660 TopoDS_Shape myShape;
661 if ( aProfile.IsDone() )
662 myShape = aProfile.GetShape();
664 if(myShape.ShapeType() != TopAbs_VERTEX)
665 myCommand.append( ":WW" );
670 if( myCommand.size() > 2 )
677 //=================================================================================
678 // function : ClickOnApply()
680 //=================================================================================
681 bool EntityGUI_SketcherDlg::ClickOnApply()
683 ((QPushButton*)sender())->setFocus();
685 myCommand.append( GetNewCommand() );
686 mySketchState = NEXT_POINT;
688 myUndoCommand.clear();
689 myUndoCommand.append( "Sketcher" );
691 GroupConstructors->setEnabled(true);
692 GroupDest1->setEnabled(true);
693 setEnabledUndo(true);
694 setEnabledRedo(false);
696 GEOMBase_Helper::displayPreview();
701 //=================================================================================
702 // function : ClickOnHelp()
704 //=================================================================================
705 void EntityGUI_SketcherDlg::ClickOnHelp()
707 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
709 app->onHelpContextModule(myGeometryGUI ? app->moduleName(myGeometryGUI->moduleName()) : QString(""), myHelpFileName);
711 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
712 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
713 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
714 QObject::tr("BUT_OK"));
718 //=================================================================================
719 // function : ClickOnUndo()
721 //=================================================================================
722 void EntityGUI_SketcherDlg::ClickOnUndo()
724 myUndoCommand.append( myCommand.last() );
725 myCommand.pop_back();
727 if(myCommand.count() == 1) {
728 mySketchState = FIRST_POINT;
730 RadioButton1->setChecked(true);
733 GroupConstructors->setEnabled(false);
734 GroupDest1->setEnabled(false);
735 setEnabledUndo(false);
738 setEnabledRedo(true);
740 GEOMBase_Helper::displayPreview();
743 //=================================================================================
744 // function : ClickOnRedo()
746 //=================================================================================
747 void EntityGUI_SketcherDlg::ClickOnRedo()
749 myCommand.append( myUndoCommand.last() );
750 myUndoCommand.pop_back();
752 mySketchState = NEXT_POINT;
754 GroupConstructors->setEnabled(true);
755 GroupDest1->setEnabled(true);
756 setEnabledUndo(true);
758 if(myUndoCommand.count() == 1)
759 setEnabledRedo(false);
761 GEOMBase_Helper::displayPreview();
764 //=================================================================================
765 // function : setEnabledUndo()
767 //=================================================================================
768 void EntityGUI_SketcherDlg::setEnabledUndo(bool value)
770 Group1Sel->buttonUndo->setEnabled(value);
771 Group1Spin->buttonUndo->setEnabled(value);
772 Group2Spin->buttonUndo->setEnabled(value);
773 Group3Spin->buttonUndo->setEnabled(value);
774 Group4Spin->buttonUndo->setEnabled(value);
777 //=================================================================================
778 // function : setEnabledRedo()
780 //=================================================================================
781 void EntityGUI_SketcherDlg::setEnabledRedo(bool value)
783 Group1Sel->buttonRedo->setEnabled(value);
784 Group1Spin->buttonRedo->setEnabled(value);
785 Group2Spin->buttonRedo->setEnabled(value);
786 Group3Spin->buttonRedo->setEnabled(value);
787 Group4Spin->buttonRedo->setEnabled(value);
790 //=================================================================================
791 // function : SelectionIntoArgument()
792 // purpose : Called when selection as changed
793 //=================================================================================
794 void EntityGUI_SketcherDlg::SelectionIntoArgument()
796 myEditCurrentArgument->setText("");
800 int nbSel = IObjectCount();
801 if ( nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1 )
803 Standard_Boolean aRes = Standard_False;
804 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes );
805 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
807 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_VERTEX ) ) {
809 gp_Ax3 aWPlane = myGeometryGUI->GetWorkingPlane();
811 aTrans.SetTransformation(aWPlane);
812 BRepBuilderAPI_Transform aTransformation(aShape, aTrans, Standard_False);
813 aShape = aTransformation.Shape();
816 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
819 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
825 GEOMBase_Helper::displayPreview();
829 //=================================================================================
830 // function : SetEditCurrentArgument()
832 //=================================================================================
833 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
835 if ( sender() == Group1Sel->PushButton1 )
837 myEditCurrentArgument = Group1Sel->LineEdit1;
838 myEditCurrentArgument->setFocus();
840 SelectionIntoArgument();
844 //=================================================================================
845 // function : LineEditReturnPressed()
847 //=================================================================================
848 void EntityGUI_SketcherDlg::LineEditReturnPressed()
850 if ( sender() == Group1Sel->LineEdit1 )
852 myEditCurrentArgument = Group1Sel->LineEdit1;
854 /* User name of object input management */
855 /* If successfull the selection is changed and signal emitted... */
856 /* so SelectionIntoArgument() is automatically called. */
857 const QString objectUserName = myEditCurrentArgument->text();
858 QWidget* thisWidget = (QWidget*)this;
859 if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO()))
860 myEditCurrentArgument->setText(objectUserName);
865 //=================================================================================
866 // function : DeactivateActiveDialog()
868 //=================================================================================
869 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
871 //myGeometryGUI->SetState( -1 );
875 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
876 myGeometryGUI->SetActiveDialogBox(0);
880 //=================================================================================
881 // function : ActivateThisDialog()
883 //=================================================================================
884 void EntityGUI_SketcherDlg::ActivateThisDialog()
886 myGeometryGUI->EmitSignalDeactivateDialog();
888 myGeometryGUI->SetActiveDialogBox((QDialog*)this);
890 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
891 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
893 //myGeometryGUI->SetState( 0 );
894 globalSelection( GEOM_POINT );
896 myEditCurrentArgument = Group1Sel->LineEdit1;
897 myEditCurrentArgument->setFocus();
899 GEOMBase_Helper::displayPreview();
903 //=================================================================================
904 // function : enterEvent [REDEFINED]
906 //=================================================================================
907 void EntityGUI_SketcherDlg::enterEvent(QEvent* e)
909 if ( !GroupConstructors->isEnabled())
910 ActivateThisDialog();
914 //=================================================================================
915 // function : closeEvent()
917 //=================================================================================
918 void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e)
920 //myGeometryGUI->SetState( -1 );
921 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
922 QDialog::closeEvent( e );
926 //=================================================================================
927 // function : ValueChangedInSpinBox()
929 //=================================================================================
930 void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue)
932 QObject* send = (QObject*)sender();
933 Standard_Real vx, vy, vz, vs;
934 vx = vy = vz = vs = 0.0;
936 if ( send == Group1Spin->SpinBox_DX)
940 else if ( send == Group2Spin->SpinBox_DX )
943 vy = Group2Spin->SpinBox_DY->GetValue();
945 else if ( send == Group2Spin->SpinBox_DY)
947 vx = Group2Spin->SpinBox_DX->GetValue();
950 else if ( send == Group3Spin->SpinBox_DX)
953 vy = Group3Spin->SpinBox_DY->GetValue();
954 vz = Group3Spin->SpinBox_DZ->GetValue();
956 else if ( send == Group3Spin->SpinBox_DY)
958 vx = Group3Spin->SpinBox_DX->GetValue();
960 vz = Group3Spin->SpinBox_DZ->GetValue();
962 else if ( send == Group3Spin->SpinBox_DZ)
964 vx = Group3Spin->SpinBox_DX->GetValue();
965 vy = Group3Spin->SpinBox_DY->GetValue();
968 else if ( send == Group4Spin->SpinBox_DX)
971 vy = Group4Spin->SpinBox_DY->GetValue();
972 vz = Group4Spin->SpinBox_DZ->GetValue();
973 vs = Group4Spin->SpinBox_DS->GetValue();
975 else if ( send == Group4Spin->SpinBox_DY)
977 vx = Group4Spin->SpinBox_DX->GetValue();
979 vz = Group4Spin->SpinBox_DZ->GetValue();
980 vs = Group4Spin->SpinBox_DS->GetValue();
982 else if ( send == Group4Spin->SpinBox_DZ)
984 vx = Group4Spin->SpinBox_DX->GetValue();
985 vy = Group4Spin->SpinBox_DY->GetValue();
987 vs = Group4Spin->SpinBox_DS->GetValue();
989 else if ( send == Group4Spin->SpinBox_DS)
991 vx = Group4Spin->SpinBox_DX->GetValue();
992 vy = Group4Spin->SpinBox_DY->GetValue();
993 vz = Group4Spin->SpinBox_DZ->GetValue();
997 if ( myConstructorId == 0 )
999 if ( mySketchType == PT_ABS)
1004 else if ( mySketchType == PT_RELATIVE)
1009 else if ( mySketchType == DIR_ANGLE_LENGTH)
1014 else if ( mySketchType == DIR_ANGLE_X)
1019 else if ( mySketchType == DIR_ANGLE_Y)
1024 else if ( mySketchType == DIR_PER_LENGTH)
1028 else if ( mySketchType == DIR_PER_X)
1032 else if ( mySketchType == DIR_PER_Y)
1036 else if ( mySketchType == DIR_TAN_LENGTH)
1040 else if ( mySketchType == DIR_TAN_X)
1044 else if ( mySketchType == DIR_TAN_Y)
1048 else if ( mySketchType == DIR_DXDY_LENGTH)
1054 else if ( mySketchType == DIR_DXDY_X)
1060 else if ( mySketchType == DIR_DXDY_Y)
1067 else if ( myConstructorId == 1 )
1069 if ( mySketchType == DIR_ANGLE_LENGTH)
1075 else if ( mySketchType == DIR_PER_LENGTH)
1080 else if ( mySketchType == DIR_TAN_LENGTH)
1085 else if ( mySketchType == DIR_DXDY_LENGTH)
1094 GEOMBase_Helper::displayPreview();
1098 //=================================================================================
1099 // function : GetNewCommand()
1100 // purpose : Build the new command with context
1101 //=================================================================================
1102 QString EntityGUI_SketcherDlg::GetNewCommand()
1104 QString myNewCommand = ":";
1105 if ( mySketchState == FIRST_POINT ) {
1106 if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
1107 myNewCommand = myNewCommand + "F " + QString::number(myX) + " " + QString::number(myY);
1108 if ( mySketchType == PT_RELATIVE)
1109 myNewCommand = myNewCommand + "F " + QString::number(myDX) + " " + QString::number(myDY);
1110 return myNewCommand;
1113 if ( myConstructorId == 0 )
1115 if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
1116 myNewCommand = myNewCommand + "TT " + QString::number(myX) + " " + QString::number(myY);
1117 if ( mySketchType == PT_RELATIVE)
1118 myNewCommand = myNewCommand + "T " + QString::number(myDX) + " " + QString::number(myDY);
1119 if ( mySketchType == DIR_ANGLE_LENGTH)
1121 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1122 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1124 if ( mySketchType == DIR_ANGLE_X)
1126 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1127 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1129 if ( mySketchType == DIR_ANGLE_Y)
1131 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1132 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1134 if ( mySketchType == DIR_PER_LENGTH)
1136 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1137 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1139 if ( mySketchType == DIR_PER_X)
1141 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1142 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1144 if ( mySketchType == DIR_PER_Y)
1146 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1147 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1149 if ( mySketchType == DIR_TAN_LENGTH)
1150 myNewCommand = myNewCommand + "L " + QString::number(myLength);
1151 if ( mySketchType == DIR_TAN_X)
1152 myNewCommand = myNewCommand + "IX " + QString::number(myX);
1153 if ( mySketchType == DIR_TAN_Y)
1154 myNewCommand = myNewCommand + "IY " + QString::number(myY);
1155 if ( mySketchType == DIR_DXDY_LENGTH)
1157 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1158 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1160 if ( mySketchType == DIR_DXDY_X)
1162 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1163 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1165 if ( mySketchType == DIR_DXDY_Y)
1167 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1168 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1171 else if ( myConstructorId == 1 )
1173 if ( mySketchType == DIR_ANGLE_LENGTH)
1175 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1176 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1178 if ( mySketchType == DIR_PER_LENGTH)
1180 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1181 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1183 if ( mySketchType == DIR_TAN_LENGTH)
1185 myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1187 if ( mySketchType == DIR_DXDY_LENGTH)
1189 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1190 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1193 return myNewCommand;
1196 //=================================================================================
1197 // function : createOperation
1199 //=================================================================================
1200 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1202 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1205 //=================================================================================
1206 // function : isValid
1208 //=================================================================================
1209 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1214 //=================================================================================
1215 // function : execute
1217 //=================================================================================
1218 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1220 if(mySketchState == FIRST_POINT) {
1225 //Test if the current point is the same as the last one
1226 TopoDS_Shape myShape1, myShape2;
1229 QString Command1 = myCommand.join( "" );
1230 Sketcher_Profile aProfile1 (Command1.ascii());
1231 if(aProfile1.IsDone())
1232 myShape1 = aProfile1.GetShape();
1235 QString Command2 = Command1 + GetNewCommand();
1236 Sketcher_Profile aProfile2 (Command2.ascii());
1237 if(aProfile2.IsDone())
1238 myShape2 = aProfile2.GetShape();
1240 if(myShape2.IsNull()) {
1241 //the current point is the same as the last one
1242 myLastX2 = myLastX1;
1243 myLastY2 = myLastY1;
1246 TopoDS_Vertex V1, V2;
1248 if(myShape1.ShapeType() == TopAbs_VERTEX) {
1249 //the last shape is the first point
1250 pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape1));
1255 TopExp::Vertices(TopoDS::Wire(myShape1), V1, V2);
1256 pt = BRep_Tool::Pnt(V2);
1260 TopExp::Vertices(TopoDS::Wire(myShape2), V1, V2);
1261 pt = BRep_Tool::Pnt(V2);
1268 if( ( mySketchState != FIRST_POINT && myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
1269 cmd = myCommand.join( "" );
1271 if ( Group1Sel->isVisible() ) {
1272 Group1Sel->buttonApply->setEnabled(false);
1273 Group1Sel->buttonApply->setFocus();
1275 if ( Group1Spin->isVisible() ) {
1276 Group1Spin->buttonApply->setEnabled(false);
1277 Group1Spin->buttonApply->setFocus();
1279 if ( Group2Spin->isVisible() ) {
1280 Group2Spin->buttonApply->setEnabled(false);
1281 Group2Spin->buttonApply->setFocus();
1283 if ( Group3Spin->isVisible() ) {
1284 Group3Spin->buttonApply->setEnabled(false);
1285 Group3Spin->buttonApply->setFocus();
1287 if ( Group4Spin->isVisible() ) {
1288 Group4Spin->buttonApply->setEnabled(false);
1289 Group4Spin->buttonApply->setFocus();
1293 cmd = myCommand.join( "" ) + GetNewCommand();
1295 if ( Group1Sel->isVisible() ) {
1296 Group1Sel->buttonApply->setEnabled(true);
1297 Group1Sel->buttonApply->setFocus();
1299 if ( Group1Spin->isVisible() ) {
1300 Group1Spin->buttonApply->setEnabled(true);
1301 Group1Spin->buttonApply->setFocus();
1303 if ( Group2Spin->isVisible() ) {
1304 Group2Spin->buttonApply->setEnabled(true);
1305 Group2Spin->buttonApply->setFocus();
1307 if ( Group3Spin->isVisible() ) {
1308 Group3Spin->buttonApply->setEnabled(true);
1309 Group3Spin->buttonApply->setFocus();
1311 if ( Group4Spin->isVisible() ) {
1312 Group4Spin->buttonApply->setEnabled(true);
1313 Group4Spin->buttonApply->setFocus();
1317 gp_Ax3 myWPlane = myGeometryGUI->GetWorkingPlane();
1318 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
1320 WPlane[0] = myWPlane.Location().X();
1321 WPlane[1] = myWPlane.Location().Y();
1322 WPlane[2] = myWPlane.Location().Z();
1324 WPlane[3] = myWPlane.Direction().X();
1325 WPlane[4] = myWPlane.Direction().Y();
1326 WPlane[5] = myWPlane.Direction().Z();
1328 WPlane[6] = myWPlane.XDirection().X();
1329 WPlane[7] = myWPlane.XDirection().Y();
1330 WPlane[8] = myWPlane.XDirection().Z();
1332 GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeSketcher( cmd.latin1(), WPlane );
1334 if ( !anObj->_is_nil() )
1335 objects.push_back( anObj._retn() );
1340 //================================================================
1341 // Function : displayPreview
1342 // Purpose : Method for displaying preview of resulting shape
1343 // Redefined from GEOMBase_Helper.
1344 //================================================================
1345 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
1347 const bool activate,
1349 const double lineWidth )
1351 // Set color for preview shape
1352 getDisplayer()->SetColor( Quantity_NOC_RED );
1354 // set width of displayed shape
1355 getDisplayer()->SetWidth( lineWidth );
1357 // Disable activation of selection
1358 getDisplayer()->SetToActivate( activate );
1360 // Make a reference to GEOM_Object
1361 getDisplayer()->SetName( myGeometryGUI->getApp()->orb()->object_to_string( object ) );
1363 // Create wire from applayed object
1364 TopoDS_Shape anApplyedWire, aLastSegment;
1365 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
1369 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
1370 if ( aPrs != 0 && !aPrs->IsNull() )
1371 GEOMBase_Helper::displayPreview( aPrs, append, update );
1373 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
1374 aPrs = getDisplayer()->BuildPrs( aLastSegment );
1375 if ( aPrs != 0 && !aPrs->IsNull() )
1376 GEOMBase_Helper::displayPreview( aPrs, append, update );
1378 getDisplayer()->UnsetName();
1380 // Enable activation of displayed objects
1381 getDisplayer()->SetToActivate( true );
1384 //================================================================
1385 // Function : createShapes
1386 // Purpose : Create applyed wire, and last segment from entry object
1387 //================================================================
1388 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
1389 TopoDS_Shape& theApplyedWire,
1390 TopoDS_Shape& theLastSegment )
1392 TopoDS_Shape aShape;
1393 if ( !GEOMBase::GetShape( theObject, aShape ) ||
1394 aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
1397 if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() ||
1398 Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
1399 Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
1400 Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
1401 Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() )
1403 theApplyedWire = aShape;
1407 BRepBuilderAPI_MakeWire aBuilder;
1408 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
1411 TopoDS_Shape anEdge = anExp.Current();
1413 if ( anExp.More() ) // i.e. non-last edge
1414 aBuilder.Add( TopoDS::Edge( anEdge ) );
1417 theLastSegment = anEdge;
1422 if ( aBuilder.IsDone() )
1423 theApplyedWire = aBuilder.Shape();
1428 //=================================================================================
1429 // function : keyPressEvent()
1431 //=================================================================================
1432 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
1434 QDialog::keyPressEvent( e );
1435 if ( e->isAccepted() )
1438 if ( e->key() == Key_F1 )