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
29 #include "EntityGUI_SketcherDlg.h"
30 #include "Sketcher_Profile.hxx"
31 #include "GEOM_Displayer.h"
33 #include "SUIT_Desktop.h"
34 #include "SUIT_Session.h"
35 #include "SUIT_MessageBox.h"
36 #include "SUIT_ResourceMgr.h"
37 #include "SalomeApp_Application.h"
38 #include "SalomeApp_SelectionMgr.h"
40 #include <qpushbutton.h>
43 #include <BRep_Tool.hxx>
45 #include <TopExp_Explorer.hxx>
46 #include <TopoDS_Vertex.hxx>
48 #include <BRepBuilderAPI_Transform.hxx>
49 #include <BRepBuilderAPI_MakeWire.hxx>
51 #include "GEOMImpl_Types.hxx"
53 #include "utilities.h"
57 //=================================================================================
58 // class : EntityGUI_SketcherDlg()
59 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
60 // name 'name' and widget flags set to 'f'.
61 // The dialog will by default be modeless, unless you set 'modal' to
62 // TRUE to construct a modal dialog.
63 //=================================================================================
64 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(GeometryGUI* GUI, QWidget* parent, const char* name, bool modal, WFlags fl)
65 :EntityGUI_Skeleton_QTD(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), GEOMBase_Helper(), myIsAllAdded( false ),
68 myGeometryGUI->SetActiveDialogBox(this);
70 if ( !name ) setName("EntityGUI_SketcherDlg");
72 buttonCancel->setText(tr("GEOM_BUT_CANCEL"));
73 buttonEnd->setText(tr("GEOM_BUT_END_SKETCH"));
74 buttonClose->setText(tr("GEOM_BUT_CLOSE_SKETCH"));
76 GroupVal->close(TRUE);
77 GroupDest2->close(TRUE);
78 GroupDest3->close(TRUE);
80 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
81 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_UNDO")));
82 QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_REDO")));
84 setCaption(tr("GEOM_SKETCHER_TITLE"));
86 GroupConstructors->setTitle(tr("GEOM_SKETCHER_EL"));
87 RadioButton1->setText(tr("GEOM_SKETCHER_SEGMENT"));
88 RadioButton2->setText(tr("GEOM_SKETCHER_ARC"));
89 GroupDest->setTitle(tr("GEOM_SKETCHER_DEST"));
90 GroupDest1->setTitle(tr("GEOM_SKETCHER_TYPE"));
91 RB_Dest1->setText(tr("GEOM_SKETCHER_POINT"));
92 RB_Dest2->setText(tr("GEOM_SKETCHER_DIR"));
94 /***************************************************************/
95 GroupPt = new EntityGUI_Point_QTD(GroupDest, "GroupPt");
96 GroupPt->GroupPoint->setTitle(tr("GEOM_SKETCHER_POINT"));
97 GroupPt->RB_Point1->setText(tr("GEOM_SKETCHER_ABS"));
98 GroupPt->RB_Point2->setText(tr("GEOM_SKETCHER_REL"));
99 GroupPt->RB_Point3->setText(tr("GEOM_SKETCHER_SEL"));
101 GroupD1 = new EntityGUI_Dir1_QTD(GroupDest, "GroupD1");
102 GroupD1->GroupDir1->setTitle(tr("GEOM_SKETCHER_DIR"));
103 GroupD1->RB_Dir11->setText(tr("GEOM_SKETCHER_ANGLE"));
104 GroupD1->RB_Dir12->setText(tr("GEOM_SKETCHER_PER"));
105 GroupD1->RB_Dir13->setText(tr("GEOM_SKETCHER_TAN"));
106 GroupD1->RB_Dir14->setText(tr("GEOM_SKETCHER_VXVY"));
108 GroupD2 = new EntityGUI_Dir2_QTD(GroupDest, "GroupD2");
109 GroupD2->GroupDir2->setTitle(tr("GEOM_SKETCHER_DIR"));
110 GroupD2->RB_Dir21->setText(tr("GEOM_SKETCHER_LENGTH"));
111 GroupD2->RB_Dir22->setText(tr("GEOM_SKETCHER_X"));
112 GroupD2->RB_Dir23->setText(tr("GEOM_SKETCHER_Y"));
114 Group1Sel = new EntityGUI_1Sel_QTD(this, "Group1Sel");
115 Group1Sel->TextLabel1->setText(tr("GEOM_SKETCHER_POINT2"));
116 Group1Sel->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
117 Group1Sel->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
118 Group1Sel->PushButton1->setPixmap(image0);
119 Group1Sel->buttonUndo->setPixmap(image1);
120 Group1Sel->buttonRedo->setPixmap(image2);
121 Group1Sel->LineEdit1->setReadOnly( true );
123 Group1Spin = new EntityGUI_1Spin(this, "Group1Spin");
124 Group1Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
125 Group1Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
126 Group1Spin->buttonUndo->setPixmap(image1);
127 Group1Spin->buttonRedo->setPixmap(image2);
129 Group2Spin = new EntityGUI_2Spin(this, "Group2Spin");
130 Group2Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
131 Group2Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
132 Group2Spin->buttonUndo->setPixmap(image1);
133 Group2Spin->buttonRedo->setPixmap(image2);
135 Group3Spin = new EntityGUI_3Spin(this, "Group3Spin");
136 Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
137 Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
138 Group3Spin->buttonUndo->setPixmap(image1);
139 Group3Spin->buttonRedo->setPixmap(image2);
141 Group4Spin = new EntityGUI_4Spin(this, "Group4Spin");
142 Group4Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
143 Group4Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
144 Group4Spin->buttonUndo->setPixmap(image1);
145 Group4Spin->buttonRedo->setPixmap(image2);
147 Layout5->addMultiCellWidget(GroupPt, 1, 1, 0, 1);
148 Layout5->addWidget(GroupD1, 1, 0);
149 Layout5->addWidget(GroupD2, 1, 1);
151 Layout1->addWidget(Group1Sel, 2, 0);
152 Layout1->addWidget(Group1Spin, 2, 0);
153 Layout1->addWidget(Group2Spin, 2, 0);
154 Layout1->addWidget(Group3Spin, 2, 0);
155 Layout1->addWidget(Group4Spin, 2, 0);
156 /***************************************************************/
158 /* signals and slots connections */
159 connect(buttonEnd, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
160 connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
161 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
163 connect(Group1Sel->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
164 connect(Group1Sel->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
165 connect(Group1Sel->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
166 connect(Group1Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
167 connect(Group1Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
168 connect(Group1Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
169 connect(Group2Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
170 connect(Group2Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
171 connect(Group2Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
172 connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
173 connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
174 connect(Group3Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
175 connect(Group4Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
176 connect(Group4Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
177 connect(Group4Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
179 connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(TypeClicked(int)));
180 connect(GroupDest1, SIGNAL(clicked(int)), this, SLOT(DestClicked(int)));
181 connect(GroupPt->GroupPoint, SIGNAL(clicked(int)), this, SLOT(PointClicked(int)));
182 connect(GroupD1->GroupDir1, SIGNAL(clicked(int)), this, SLOT(Dir1Clicked(int)));
183 connect(GroupD2->GroupDir2, SIGNAL(clicked(int)), this, SLOT(Dir2Clicked(int)));
185 connect(Group1Sel->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
186 connect(Group1Sel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
188 connect(Group1Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
189 connect(Group2Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
190 connect(Group2Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
191 connect(Group3Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
192 connect(Group3Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
193 connect(Group3Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
194 connect(Group4Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
195 connect(Group4Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
196 connect(Group4Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
197 connect(Group4Spin->SpinBox_DS, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
199 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1Spin->SpinBox_DX, SLOT(SetStep(double)));
200 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DX, SLOT(SetStep(double)));
201 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DY, SLOT(SetStep(double)));
202 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DX, SLOT(SetStep(double)));
203 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DY, SLOT(SetStep(double)));
204 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DZ, SLOT(SetStep(double)));
205 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DX, SLOT(SetStep(double)));
206 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DY, SLOT(SetStep(double)));
207 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DZ, SLOT(SetStep(double)));
208 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DS, SLOT(SetStep(double)));
210 connect(myGeometryGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
211 connect(myGeometryGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
217 //=================================================================================
218 // function : ~EntityGUI_SketcherDlg()
219 // purpose : Destroys the object and frees any allocated resources
220 //=================================================================================
221 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
223 myGeometryGUI->SetActiveDialogBox( 0 );
227 //=================================================================================
230 //=================================================================================
231 void EntityGUI_SketcherDlg::Init()
234 myEditCurrentArgument = Group1Sel->LineEdit1;
235 myCommand.append( "Sketcher" );
236 myUndoCommand.append( "Sketcher" );
238 mySketchState = FIRST_POINT;
239 globalSelection( GEOM_POINT );
246 /* Get setting of step value from file configuration */
247 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
249 /* min, max, step and decimals for spin boxes */
250 Group1Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
251 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
252 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
253 Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
254 Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
255 Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
256 Group4Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
257 Group4Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
258 Group4Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
259 Group4Spin->SpinBox_DS->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
261 /* displays Dialog */
262 GroupConstructors->setEnabled(false);
263 GroupDest1->setEnabled(false);
264 setEnabledUndo(false);
265 setEnabledRedo(false);
267 RadioButton1->setChecked(true);
272 GEOMBase_Helper::displayPreview();
276 //=================================================================================
277 // function : InitClick()
279 //=================================================================================
280 void EntityGUI_SketcherDlg::InitClick()
282 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
294 //=================================================================================
295 // function : TypeClicked()
296 // purpose : Radio button management
297 //=================================================================================
298 void EntityGUI_SketcherDlg::TypeClicked(int constructorId)
300 myConstructorId = constructorId;
301 if ( myConstructorId == 0 ) // SEGMENT
303 GroupD2->setEnabled(true);
304 RB_Dest1->setEnabled(true);
305 RB_Dest1->setChecked(true);
308 else if ( myConstructorId == 1 ) // ARC
310 GroupD2->setEnabled(false);
311 RB_Dest1->setEnabled(false);
312 RB_Dest2->setChecked(true);
318 //=================================================================================
319 // function : DestClicked()
320 // purpose : Radio button management
321 //=================================================================================
322 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
328 if ( constructorId == 1 )
330 GroupPt->RB_Point1->setChecked(true);
332 PointClicked(1); // XY
334 else if ( constructorId == 0 )
336 GroupD1->RB_Dir11->setChecked(true);
339 Dir1Clicked(2); // Angle
344 //=================================================================================
345 // function : PointClicked()
346 // purpose : Radio button management
347 //=================================================================================
348 void EntityGUI_SketcherDlg::PointClicked(int constructorId)
352 if ( myConstructorId == 0 )
354 if ( constructorId == 1 )
356 mySketchType = PT_ABS;
357 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
358 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
359 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
360 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
362 Group2Spin->SpinBox_DX->SetValue(myX);
364 Group2Spin->SpinBox_DY->SetValue(myY);
366 Group2Spin->buttonApply->setFocus();
368 GEOMBase_Helper::displayPreview();
370 else if ( constructorId == 0 )
372 mySketchType = PT_RELATIVE;
373 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
374 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
375 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2"));
376 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2"));
378 Group2Spin->SpinBox_DX->SetValue(myDX);
380 Group2Spin->SpinBox_DY->SetValue(myDY);
382 Group2Spin->buttonApply->setFocus();
384 GEOMBase_Helper::displayPreview();
386 else if ( constructorId == 2 )
388 mySketchType = PT_SEL;
389 myEditCurrentArgument = Group1Sel->LineEdit1;
390 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
391 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
393 Group1Sel->buttonApply->setFocus();
394 SelectionIntoArgument();
400 //=================================================================================
401 // function : Dir1Clicked()
402 // purpose : Radio button management
403 //=================================================================================
404 void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId)
406 myConstructorDirId = constructorId;
407 GroupD2->RB_Dir21->setChecked(true);
412 //=================================================================================
413 // function : Dir2Clicked()
414 // purpose : Radio button management
415 //=================================================================================
416 void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId)
421 if ( myConstructorId == 0 )
426 if ( myConstructorDirId == 2 )
428 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
429 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
430 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
431 Group2Spin->SpinBox_DX->SetValue(myAngle);
432 Group2Spin->buttonApply->setFocus();
435 if ( constructorId == 2 )
437 mySketchType = DIR_ANGLE_LENGTH;
438 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2"));
439 Group2Spin->SpinBox_DY->SetValue(myLength);
441 else if ( constructorId == 0 )
443 mySketchType = DIR_ANGLE_X;
444 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_X3"));
445 Group2Spin->SpinBox_DY->SetValue(myX);
447 else if ( constructorId == 1 )
449 mySketchType = DIR_ANGLE_Y;
450 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y3"));
451 Group2Spin->SpinBox_DY->SetValue(myY);
454 else if ( myConstructorDirId == 0 )
457 Group1Spin->buttonApply->setFocus();
459 if ( constructorId == 2 )
461 mySketchType = DIR_PER_LENGTH;
462 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
463 Group1Spin->SpinBox_DX->SetValue(myLength);
465 else if ( constructorId == 0 )
467 mySketchType = DIR_PER_X;
468 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
469 Group1Spin->SpinBox_DX->SetValue(myX);
471 else if ( constructorId == 1 )
473 mySketchType = DIR_PER_Y;
474 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
475 Group1Spin->SpinBox_DX->SetValue(myY);
478 else if ( myConstructorDirId == 1 )
481 Group1Spin->buttonApply->setFocus();
483 if ( constructorId == 2 )
485 mySketchType = DIR_TAN_LENGTH;
486 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
487 Group1Spin->SpinBox_DX->SetValue(myLength);
489 else if ( constructorId == 0 )
491 mySketchType = DIR_TAN_X;
492 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
493 Group1Spin->SpinBox_DX->SetValue(myX);
495 else if ( constructorId == 1 )
497 mySketchType = DIR_TAN_Y;
498 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
499 Group1Spin->SpinBox_DX->SetValue(myY);
502 else if ( myConstructorDirId == 3 )
504 Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
505 Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
506 Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
507 Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
508 Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
510 Group3Spin->SpinBox_DX->SetValue(myDX);
512 Group3Spin->SpinBox_DY->SetValue(myDY);
514 Group3Spin->buttonApply->setFocus();
516 if ( constructorId == 2 )
518 mySketchType = DIR_DXDY_LENGTH;
519 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2"));
520 Group3Spin->SpinBox_DZ->SetValue(myLength);
522 else if ( constructorId == 0 )
524 mySketchType = DIR_DXDY_X;
525 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_X3"));
526 Group3Spin->SpinBox_DZ->SetValue(myX);
528 else if ( constructorId == 1 )
530 mySketchType = DIR_DXDY_Y;
531 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Y3"));
532 Group3Spin->SpinBox_DZ->SetValue(myY);
536 else if ( myConstructorId == 1 )
538 if ( myConstructorDirId == 2 )
540 if ( constructorId == 2 )
542 mySketchType = DIR_ANGLE_LENGTH;
543 Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
544 Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
545 Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
546 Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
547 Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_RADIUS2"));
548 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_ANGLE2"));
549 Group3Spin->SpinBox_DX->SetValue(myAngle);
551 Group3Spin->SpinBox_DY->SetValue(myRadius);
553 Group3Spin->SpinBox_DZ->SetValue(myLength);
555 Group3Spin->buttonApply->setFocus();
558 else if ( myConstructorDirId == 0 )
560 if ( constructorId == 2 )
562 mySketchType = DIR_PER_LENGTH;
563 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
564 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
565 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
566 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
568 Group2Spin->SpinBox_DX->SetValue(myRadius);
570 Group2Spin->SpinBox_DY->SetValue(myLength);
572 Group2Spin->buttonApply->setFocus();
575 else if ( myConstructorDirId == 1 )
577 if ( constructorId == 2 )
579 mySketchType = DIR_TAN_LENGTH;
580 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
581 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
582 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
583 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
585 Group2Spin->SpinBox_DX->SetValue(myRadius);
587 Group2Spin->SpinBox_DY->SetValue(myLength);
589 Group2Spin->buttonApply->setFocus();
592 else if ( myConstructorDirId == 3 )
594 if ( constructorId == 2 )
596 mySketchType = DIR_DXDY_LENGTH;
597 Group4Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
598 Group4Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
599 Group4Spin->TextLabel3->setText(tr("GEOM_SKETCHER_RADIUS2"));
600 Group4Spin->TextLabel4->setText(tr("GEOM_SKETCHER_ANGLE2"));
602 Group4Spin->SpinBox_DX->SetValue(myDX);
604 Group4Spin->SpinBox_DY->SetValue(myDY);
606 Group4Spin->SpinBox_DZ->SetValue(myRadius);
608 Group4Spin->SpinBox_DS->SetValue(myLength);
610 Group4Spin->buttonApply->setFocus();
615 GEOMBase_Helper::displayPreview();
619 //=================================================================================
620 // function : ClickOnCancel()
622 //=================================================================================
623 void EntityGUI_SketcherDlg::ClickOnCancel()
629 //=================================================================================
630 // function : ClickOnEnd()
631 // purpose : connected to buttonEnd AND buttonClose
632 //=================================================================================
633 void EntityGUI_SketcherDlg::ClickOnEnd()
635 if ( sender() == buttonClose )
637 // Verify validity of commands
638 if ( myCommand.count() <= 2 )
640 SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(),
641 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
645 QString Command = myCommand.join( "" ) + GetNewCommand();
646 Sketcher_Profile aProfile (Command.ascii());
648 Command = myCommand.join( "" );
649 aProfile = Sketcher_Profile(Command.ascii());
650 TopoDS_Shape myShape;
651 if ( aProfile.IsDone() )
652 myShape = aProfile.GetShape();
654 if(myShape.ShapeType() != TopAbs_VERTEX)
655 myCommand.append( ":WW" );
660 if( myCommand.size() > 2 )
667 //=================================================================================
668 // function : ClickOnApply()
670 //=================================================================================
671 bool EntityGUI_SketcherDlg::ClickOnApply()
673 myCommand.append( GetNewCommand() );
674 mySketchState = NEXT_POINT;
676 myUndoCommand.clear();
677 myUndoCommand.append( "Sketcher" );
679 GroupConstructors->setEnabled(true);
680 GroupDest1->setEnabled(true);
681 setEnabledUndo(true);
682 setEnabledRedo(false);
684 GEOMBase_Helper::displayPreview();
689 //=================================================================================
690 // function : ClickOnUndo()
692 //=================================================================================
693 void EntityGUI_SketcherDlg::ClickOnUndo()
695 myUndoCommand.append( myCommand.last() );
696 myCommand.pop_back();
698 if(myCommand.count() == 1) {
699 mySketchState = FIRST_POINT;
701 RadioButton1->setChecked(true);
704 GroupConstructors->setEnabled(false);
705 GroupDest1->setEnabled(false);
706 setEnabledUndo(false);
709 setEnabledRedo(true);
711 GEOMBase_Helper::displayPreview();
714 //=================================================================================
715 // function : ClickOnRedo()
717 //=================================================================================
718 void EntityGUI_SketcherDlg::ClickOnRedo()
720 myCommand.append( myUndoCommand.last() );
721 myUndoCommand.pop_back();
723 mySketchState = NEXT_POINT;
725 GroupConstructors->setEnabled(true);
726 GroupDest1->setEnabled(true);
727 setEnabledUndo(true);
729 if(myUndoCommand.count() == 1)
730 setEnabledRedo(false);
732 GEOMBase_Helper::displayPreview();
735 //=================================================================================
736 // function : setEnabledUndo()
738 //=================================================================================
739 void EntityGUI_SketcherDlg::setEnabledUndo(bool value)
741 Group1Sel->buttonUndo->setEnabled(value);
742 Group1Spin->buttonUndo->setEnabled(value);
743 Group2Spin->buttonUndo->setEnabled(value);
744 Group3Spin->buttonUndo->setEnabled(value);
745 Group4Spin->buttonUndo->setEnabled(value);
748 //=================================================================================
749 // function : setEnabledRedo()
751 //=================================================================================
752 void EntityGUI_SketcherDlg::setEnabledRedo(bool value)
754 Group1Sel->buttonRedo->setEnabled(value);
755 Group1Spin->buttonRedo->setEnabled(value);
756 Group2Spin->buttonRedo->setEnabled(value);
757 Group3Spin->buttonRedo->setEnabled(value);
758 Group4Spin->buttonRedo->setEnabled(value);
761 //=================================================================================
762 // function : SelectionIntoArgument()
763 // purpose : Called when selection as changed
764 //=================================================================================
765 void EntityGUI_SketcherDlg::SelectionIntoArgument()
767 myEditCurrentArgument->setText("");
771 int nbSel = IObjectCount();
772 if ( nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1 )
774 Standard_Boolean aRes = Standard_False;
775 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes );
776 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
778 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_VERTEX ) ) {
780 gp_Ax3 aWPlane = myGeometryGUI->GetWorkingPlane();
782 aTrans.SetTransformation(aWPlane);
783 BRepBuilderAPI_Transform aTransformation(aShape, aTrans, Standard_False);
784 aShape = aTransformation.Shape();
787 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
790 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
796 GEOMBase_Helper::displayPreview();
800 //=================================================================================
801 // function : SetEditCurrentArgument()
803 //=================================================================================
804 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
806 if ( sender() == Group1Sel->PushButton1 )
808 myEditCurrentArgument = Group1Sel->LineEdit1;
809 myEditCurrentArgument->setFocus();
811 SelectionIntoArgument();
815 //=================================================================================
816 // function : LineEditReturnPressed()
818 //=================================================================================
819 void EntityGUI_SketcherDlg::LineEditReturnPressed()
821 if ( sender() == Group1Sel->LineEdit1 )
823 myEditCurrentArgument = Group1Sel->LineEdit1;
825 /* User name of object input management */
826 /* If successfull the selection is changed and signal emitted... */
827 /* so SelectionIntoArgument() is automatically called. */
828 const QString objectUserName = myEditCurrentArgument->text();
829 QWidget* thisWidget = (QWidget*)this;
830 if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO()))
831 myEditCurrentArgument->setText(objectUserName);
836 //=================================================================================
837 // function : DeactivateActiveDialog()
839 //=================================================================================
840 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
842 //myGeometryGUI->SetState( -1 );
846 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
847 myGeometryGUI->SetActiveDialogBox(0);
851 //=================================================================================
852 // function : ActivateThisDialog()
854 //=================================================================================
855 void EntityGUI_SketcherDlg::ActivateThisDialog()
857 myGeometryGUI->EmitSignalDeactivateDialog();
859 myGeometryGUI->SetActiveDialogBox((QDialog*)this);
861 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
862 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
864 //myGeometryGUI->SetState( 0 );
865 globalSelection( GEOM_POINT );
867 myEditCurrentArgument = Group1Sel->LineEdit1;
868 myEditCurrentArgument->setFocus();
870 GEOMBase_Helper::displayPreview();
874 //=================================================================================
875 // function : enterEvent [REDEFINED]
877 //=================================================================================
878 void EntityGUI_SketcherDlg::enterEvent(QEvent* e)
880 if ( !GroupConstructors->isEnabled())
881 ActivateThisDialog();
885 //=================================================================================
886 // function : closeEvent()
888 //=================================================================================
889 void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e)
891 //myGeometryGUI->SetState( -1 );
892 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
893 QDialog::closeEvent( e );
897 //=================================================================================
898 // function : ValueChangedInSpinBox()
900 //=================================================================================
901 void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue)
903 QObject* send = (QObject*)sender();
904 Standard_Real vx, vy, vz, vs;
905 vx = vy = vz = vs = 0.0;
907 if ( send == Group1Spin->SpinBox_DX)
911 else if ( send == Group2Spin->SpinBox_DX )
914 vy = Group2Spin->SpinBox_DY->GetValue();
916 else if ( send == Group2Spin->SpinBox_DY)
918 vx = Group2Spin->SpinBox_DX->GetValue();
921 else if ( send == Group3Spin->SpinBox_DX)
924 vy = Group3Spin->SpinBox_DY->GetValue();
925 vz = Group3Spin->SpinBox_DZ->GetValue();
927 else if ( send == Group3Spin->SpinBox_DY)
929 vx = Group3Spin->SpinBox_DX->GetValue();
931 vz = Group3Spin->SpinBox_DZ->GetValue();
933 else if ( send == Group3Spin->SpinBox_DZ)
935 vx = Group3Spin->SpinBox_DX->GetValue();
936 vy = Group3Spin->SpinBox_DY->GetValue();
939 else if ( send == Group4Spin->SpinBox_DX)
942 vy = Group4Spin->SpinBox_DY->GetValue();
943 vz = Group4Spin->SpinBox_DZ->GetValue();
944 vs = Group4Spin->SpinBox_DS->GetValue();
946 else if ( send == Group4Spin->SpinBox_DY)
948 vx = Group4Spin->SpinBox_DX->GetValue();
950 vz = Group4Spin->SpinBox_DZ->GetValue();
951 vs = Group4Spin->SpinBox_DS->GetValue();
953 else if ( send == Group4Spin->SpinBox_DZ)
955 vx = Group4Spin->SpinBox_DX->GetValue();
956 vy = Group4Spin->SpinBox_DY->GetValue();
958 vs = Group4Spin->SpinBox_DS->GetValue();
960 else if ( send == Group4Spin->SpinBox_DS)
962 vx = Group4Spin->SpinBox_DX->GetValue();
963 vy = Group4Spin->SpinBox_DY->GetValue();
964 vz = Group4Spin->SpinBox_DZ->GetValue();
968 if ( myConstructorId == 0 )
970 if ( mySketchType == PT_ABS)
975 else if ( mySketchType == PT_RELATIVE)
980 else if ( mySketchType == DIR_ANGLE_LENGTH)
985 else if ( mySketchType == DIR_ANGLE_X)
990 else if ( mySketchType == DIR_ANGLE_Y)
995 else if ( mySketchType == DIR_PER_LENGTH)
999 else if ( mySketchType == DIR_PER_X)
1003 else if ( mySketchType == DIR_PER_Y)
1007 else if ( mySketchType == DIR_TAN_LENGTH)
1011 else if ( mySketchType == DIR_TAN_X)
1015 else if ( mySketchType == DIR_TAN_Y)
1019 else if ( mySketchType == DIR_DXDY_LENGTH)
1025 else if ( mySketchType == DIR_DXDY_X)
1031 else if ( mySketchType == DIR_DXDY_Y)
1038 else if ( myConstructorId == 1 )
1040 if ( mySketchType == DIR_ANGLE_LENGTH)
1046 else if ( mySketchType == DIR_PER_LENGTH)
1051 else if ( mySketchType == DIR_TAN_LENGTH)
1056 else if ( mySketchType == DIR_DXDY_LENGTH)
1065 GEOMBase_Helper::displayPreview();
1069 //=================================================================================
1070 // function : GetNewCommand()
1071 // purpose : Build the new command with context
1072 //=================================================================================
1073 QString EntityGUI_SketcherDlg::GetNewCommand()
1075 QString myNewCommand = ":";
1076 if ( mySketchState == FIRST_POINT ) {
1077 if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
1078 myNewCommand = myNewCommand + "F " + QString::number(myX) + " " + QString::number(myY);
1079 if ( mySketchType == PT_RELATIVE)
1080 myNewCommand = myNewCommand + "F " + QString::number(myDX) + " " + QString::number(myDY);
1081 return myNewCommand;
1084 if ( myConstructorId == 0 )
1086 if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
1087 myNewCommand = myNewCommand + "TT " + QString::number(myX) + " " + QString::number(myY);
1088 if ( mySketchType == PT_RELATIVE)
1089 myNewCommand = myNewCommand + "T " + QString::number(myDX) + " " + QString::number(myDY);
1090 if ( mySketchType == DIR_ANGLE_LENGTH)
1092 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1093 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1095 if ( mySketchType == DIR_ANGLE_X)
1097 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1098 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1100 if ( mySketchType == DIR_ANGLE_Y)
1102 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1103 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1105 if ( mySketchType == DIR_PER_LENGTH)
1107 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1108 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1110 if ( mySketchType == DIR_PER_X)
1112 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1113 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1115 if ( mySketchType == DIR_PER_Y)
1117 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1118 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1120 if ( mySketchType == DIR_TAN_LENGTH)
1121 myNewCommand = myNewCommand + "L " + QString::number(myLength);
1122 if ( mySketchType == DIR_TAN_X)
1123 myNewCommand = myNewCommand + "IX " + QString::number(myX);
1124 if ( mySketchType == DIR_TAN_Y)
1125 myNewCommand = myNewCommand + "IY " + QString::number(myY);
1126 if ( mySketchType == DIR_DXDY_LENGTH)
1128 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1129 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1131 if ( mySketchType == DIR_DXDY_X)
1133 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1134 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1136 if ( mySketchType == DIR_DXDY_Y)
1138 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1139 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1142 else if ( myConstructorId == 1 )
1144 if ( mySketchType == DIR_ANGLE_LENGTH)
1146 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1147 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1149 if ( mySketchType == DIR_PER_LENGTH)
1151 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1152 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1154 if ( mySketchType == DIR_TAN_LENGTH)
1156 myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1158 if ( mySketchType == DIR_DXDY_LENGTH)
1160 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1161 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1164 return myNewCommand;
1167 //=================================================================================
1168 // function : createOperation
1170 //=================================================================================
1171 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1173 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1176 //=================================================================================
1177 // function : isValid
1179 //=================================================================================
1180 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1185 //=================================================================================
1186 // function : execute
1188 //=================================================================================
1189 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1191 if(mySketchState == FIRST_POINT) {
1196 //Test if the current point is the same as the last one
1197 TopoDS_Shape myShape1, myShape2;
1200 QString Command1 = myCommand.join( "" );
1201 Sketcher_Profile aProfile1 (Command1.ascii());
1202 if(aProfile1.IsDone())
1203 myShape1 = aProfile1.GetShape();
1206 QString Command2 = Command1 + GetNewCommand();
1207 Sketcher_Profile aProfile2 (Command2.ascii());
1208 if(aProfile2.IsDone())
1209 myShape2 = aProfile2.GetShape();
1211 if(myShape2.IsNull()) {
1212 //the current point is the same as the last one
1213 myLastX2 = myLastX1;
1214 myLastY2 = myLastY1;
1217 TopoDS_Vertex V1, V2;
1219 if(myShape1.ShapeType() == TopAbs_VERTEX) {
1220 //the last shape is the first point
1221 pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape1));
1226 TopExp::Vertices(TopoDS::Wire(myShape1), V1, V2);
1227 pt = BRep_Tool::Pnt(V2);
1231 TopExp::Vertices(TopoDS::Wire(myShape2), V1, V2);
1232 pt = BRep_Tool::Pnt(V2);
1239 if( ( mySketchState != FIRST_POINT && myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
1240 cmd = myCommand.join( "" );
1242 if ( Group1Sel->isVisible() ) {
1243 Group1Sel->buttonApply->setEnabled(false);
1244 Group1Sel->buttonApply->setFocus();
1246 if ( Group1Spin->isVisible() ) {
1247 Group1Spin->buttonApply->setEnabled(false);
1248 Group1Spin->buttonApply->setFocus();
1250 if ( Group2Spin->isVisible() ) {
1251 Group2Spin->buttonApply->setEnabled(false);
1252 Group2Spin->buttonApply->setFocus();
1254 if ( Group3Spin->isVisible() ) {
1255 Group3Spin->buttonApply->setEnabled(false);
1256 Group3Spin->buttonApply->setFocus();
1258 if ( Group4Spin->isVisible() ) {
1259 Group4Spin->buttonApply->setEnabled(false);
1260 Group4Spin->buttonApply->setFocus();
1264 cmd = myCommand.join( "" ) + GetNewCommand();
1266 if ( Group1Sel->isVisible() ) {
1267 Group1Sel->buttonApply->setEnabled(true);
1268 Group1Sel->buttonApply->setFocus();
1270 if ( Group1Spin->isVisible() ) {
1271 Group1Spin->buttonApply->setEnabled(true);
1272 Group1Spin->buttonApply->setFocus();
1274 if ( Group2Spin->isVisible() ) {
1275 Group2Spin->buttonApply->setEnabled(true);
1276 Group2Spin->buttonApply->setFocus();
1278 if ( Group3Spin->isVisible() ) {
1279 Group3Spin->buttonApply->setEnabled(true);
1280 Group3Spin->buttonApply->setFocus();
1282 if ( Group4Spin->isVisible() ) {
1283 Group4Spin->buttonApply->setEnabled(true);
1284 Group4Spin->buttonApply->setFocus();
1288 gp_Ax3 myWPlane = myGeometryGUI->GetWorkingPlane();
1289 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
1291 WPlane[0] = myWPlane.Location().X();
1292 WPlane[1] = myWPlane.Location().Y();
1293 WPlane[2] = myWPlane.Location().Z();
1295 WPlane[3] = myWPlane.Direction().X();
1296 WPlane[4] = myWPlane.Direction().Y();
1297 WPlane[5] = myWPlane.Direction().Z();
1299 WPlane[6] = myWPlane.XDirection().X();
1300 WPlane[7] = myWPlane.XDirection().Y();
1301 WPlane[8] = myWPlane.XDirection().Z();
1303 GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeSketcher( cmd.latin1(), WPlane );
1305 if ( !anObj->_is_nil() )
1306 objects.push_back( anObj._retn() );
1311 //================================================================
1312 // Function : displayPreview
1313 // Purpose : Method for displaying preview of resulting shape
1314 // Redefined from GEOMBase_Helper.
1315 //================================================================
1316 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
1318 const bool activate,
1320 const double lineWidth )
1322 // Set color for preview shape
1323 getDisplayer()->SetColor( Quantity_NOC_RED );
1325 // set width of displayed shape
1326 getDisplayer()->SetWidth( lineWidth );
1328 // Disable activation of selection
1329 getDisplayer()->SetToActivate( activate );
1331 // Make a reference to GEOM_Object
1332 getDisplayer()->SetName( myGeometryGUI->getApp()->orb()->object_to_string( object ) );
1334 // Create wire from applayed object
1335 TopoDS_Shape anApplyedWire, aLastSegment;
1336 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
1340 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
1341 if ( aPrs != 0 && !aPrs->IsNull() )
1342 GEOMBase_Helper::displayPreview( aPrs, append, update );
1344 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
1345 aPrs = getDisplayer()->BuildPrs( aLastSegment );
1346 if ( aPrs != 0 && !aPrs->IsNull() )
1347 GEOMBase_Helper::displayPreview( aPrs, append, update );
1349 getDisplayer()->UnsetName();
1351 // Enable activation of displayed objects
1352 getDisplayer()->SetToActivate( true );
1355 //================================================================
1356 // Function : createShapes
1357 // Purpose : Create applyed wire, and last segment from entry object
1358 //================================================================
1359 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
1360 TopoDS_Shape& theApplyedWire,
1361 TopoDS_Shape& theLastSegment )
1363 TopoDS_Shape aShape;
1364 if ( !GEOMBase::GetShape( theObject, aShape ) ||
1365 aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
1368 if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() ||
1369 Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
1370 Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
1371 Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
1372 Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() )
1374 theApplyedWire = aShape;
1378 BRepBuilderAPI_MakeWire aBuilder;
1379 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
1382 TopoDS_Shape anEdge = anExp.Current();
1384 if ( anExp.More() ) // i.e. non-last edge
1385 aBuilder.Add( TopoDS::Edge( anEdge ) );
1388 theLastSegment = anEdge;
1393 if ( aBuilder.IsDone() )
1394 theApplyedWire = aBuilder.Shape();
1399 //=================================================================================
1400 // function : getDesktop()
1402 //=================================================================================
1403 SUIT_Desktop* EntityGUI_SketcherDlg::getDesktop() const
1405 return dynamic_cast<SUIT_Desktop*>( parentWidget() );