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), myIsAllAdded( false ),
66 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
69 myGeometryGUI->SetActiveDialogBox(this);
71 if ( !name ) setName("EntityGUI_SketcherDlg");
73 buttonCancel->setText(tr("GEOM_BUT_CANCEL"));
74 buttonEnd->setText(tr("GEOM_BUT_END_SKETCH"));
75 buttonClose->setText(tr("GEOM_BUT_CLOSE_SKETCH"));
77 GroupVal->close(TRUE);
78 GroupDest2->close(TRUE);
79 GroupDest3->close(TRUE);
81 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
82 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_UNDO")));
83 QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_REDO")));
85 setCaption(tr("GEOM_SKETCHER_TITLE"));
87 GroupConstructors->setTitle(tr("GEOM_SKETCHER_EL"));
88 RadioButton1->setText(tr("GEOM_SKETCHER_SEGMENT"));
89 RadioButton2->setText(tr("GEOM_SKETCHER_ARC"));
90 GroupDest->setTitle(tr("GEOM_SKETCHER_DEST"));
91 GroupDest1->setTitle(tr("GEOM_SKETCHER_TYPE"));
92 RB_Dest1->setText(tr("GEOM_SKETCHER_POINT"));
93 RB_Dest2->setText(tr("GEOM_SKETCHER_DIR"));
95 /***************************************************************/
96 GroupPt = new EntityGUI_Point_QTD(GroupDest, "GroupPt");
97 GroupPt->GroupPoint->setTitle(tr("GEOM_SKETCHER_POINT"));
98 GroupPt->RB_Point1->setText(tr("GEOM_SKETCHER_ABS"));
99 GroupPt->RB_Point2->setText(tr("GEOM_SKETCHER_REL"));
100 GroupPt->RB_Point3->setText(tr("GEOM_SKETCHER_SEL"));
102 GroupD1 = new EntityGUI_Dir1_QTD(GroupDest, "GroupD1");
103 GroupD1->GroupDir1->setTitle(tr("GEOM_SKETCHER_DIR"));
104 GroupD1->RB_Dir11->setText(tr("GEOM_SKETCHER_ANGLE"));
105 GroupD1->RB_Dir12->setText(tr("GEOM_SKETCHER_PER"));
106 GroupD1->RB_Dir13->setText(tr("GEOM_SKETCHER_TAN"));
107 GroupD1->RB_Dir14->setText(tr("GEOM_SKETCHER_VXVY"));
109 GroupD2 = new EntityGUI_Dir2_QTD(GroupDest, "GroupD2");
110 GroupD2->GroupDir2->setTitle(tr("GEOM_SKETCHER_DIR"));
111 GroupD2->RB_Dir21->setText(tr("GEOM_SKETCHER_LENGTH"));
112 GroupD2->RB_Dir22->setText(tr("GEOM_SKETCHER_X"));
113 GroupD2->RB_Dir23->setText(tr("GEOM_SKETCHER_Y"));
115 Group1Sel = new EntityGUI_1Sel_QTD(this, "Group1Sel");
116 Group1Sel->TextLabel1->setText(tr("GEOM_SKETCHER_POINT2"));
117 Group1Sel->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
118 Group1Sel->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
119 Group1Sel->PushButton1->setPixmap(image0);
120 Group1Sel->buttonUndo->setPixmap(image1);
121 Group1Sel->buttonRedo->setPixmap(image2);
122 Group1Sel->LineEdit1->setReadOnly( true );
124 Group1Spin = new EntityGUI_1Spin(this, "Group1Spin");
125 Group1Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
126 Group1Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
127 Group1Spin->buttonUndo->setPixmap(image1);
128 Group1Spin->buttonRedo->setPixmap(image2);
130 Group2Spin = new EntityGUI_2Spin(this, "Group2Spin");
131 Group2Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
132 Group2Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
133 Group2Spin->buttonUndo->setPixmap(image1);
134 Group2Spin->buttonRedo->setPixmap(image2);
136 Group3Spin = new EntityGUI_3Spin(this, "Group3Spin");
137 Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
138 Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
139 Group3Spin->buttonUndo->setPixmap(image1);
140 Group3Spin->buttonRedo->setPixmap(image2);
142 Group4Spin = new EntityGUI_4Spin(this, "Group4Spin");
143 Group4Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
144 Group4Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
145 Group4Spin->buttonUndo->setPixmap(image1);
146 Group4Spin->buttonRedo->setPixmap(image2);
148 Layout5->addMultiCellWidget(GroupPt, 1, 1, 0, 1);
149 Layout5->addWidget(GroupD1, 1, 0);
150 Layout5->addWidget(GroupD2, 1, 1);
152 Layout1->addWidget(Group1Sel, 2, 0);
153 Layout1->addWidget(Group1Spin, 2, 0);
154 Layout1->addWidget(Group2Spin, 2, 0);
155 Layout1->addWidget(Group3Spin, 2, 0);
156 Layout1->addWidget(Group4Spin, 2, 0);
157 /***************************************************************/
159 /* signals and slots connections */
160 connect(buttonEnd, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
161 connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
162 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
164 connect(Group1Sel->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
165 connect(Group1Sel->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
166 connect(Group1Sel->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
167 connect(Group1Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
168 connect(Group1Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
169 connect(Group1Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
170 connect(Group2Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
171 connect(Group2Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
172 connect(Group2Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
173 connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
174 connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
175 connect(Group3Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
176 connect(Group4Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
177 connect(Group4Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
178 connect(Group4Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
180 connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(TypeClicked(int)));
181 connect(GroupDest1, SIGNAL(clicked(int)), this, SLOT(DestClicked(int)));
182 connect(GroupPt->GroupPoint, SIGNAL(clicked(int)), this, SLOT(PointClicked(int)));
183 connect(GroupD1->GroupDir1, SIGNAL(clicked(int)), this, SLOT(Dir1Clicked(int)));
184 connect(GroupD2->GroupDir2, SIGNAL(clicked(int)), this, SLOT(Dir2Clicked(int)));
186 connect(Group1Sel->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
187 connect(Group1Sel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
189 connect(Group1Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
190 connect(Group2Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
191 connect(Group2Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
192 connect(Group3Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
193 connect(Group3Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
194 connect(Group3Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
195 connect(Group4Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
196 connect(Group4Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
197 connect(Group4Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
198 connect(Group4Spin->SpinBox_DS, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
200 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1Spin->SpinBox_DX, SLOT(SetStep(double)));
201 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DX, SLOT(SetStep(double)));
202 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DY, SLOT(SetStep(double)));
203 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DX, SLOT(SetStep(double)));
204 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DY, SLOT(SetStep(double)));
205 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DZ, SLOT(SetStep(double)));
206 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DX, SLOT(SetStep(double)));
207 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DY, SLOT(SetStep(double)));
208 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DZ, SLOT(SetStep(double)));
209 connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DS, SLOT(SetStep(double)));
211 connect(myGeometryGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
212 connect(myGeometryGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
218 //=================================================================================
219 // function : ~EntityGUI_SketcherDlg()
220 // purpose : Destroys the object and frees any allocated resources
221 //=================================================================================
222 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
224 myGeometryGUI->SetActiveDialogBox( 0 );
228 //=================================================================================
231 //=================================================================================
232 void EntityGUI_SketcherDlg::Init()
235 myEditCurrentArgument = Group1Sel->LineEdit1;
236 myCommand.append( "Sketcher" );
237 myUndoCommand.append( "Sketcher" );
239 mySketchState = FIRST_POINT;
240 globalSelection( GEOM_POINT );
247 /* Get setting of step value from file configuration */
248 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
250 /* min, max, step and decimals for spin boxes */
251 Group1Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
252 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
253 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
254 Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
255 Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
256 Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
257 Group4Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
258 Group4Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
259 Group4Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
260 Group4Spin->SpinBox_DS->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
262 /* displays Dialog */
263 GroupConstructors->setEnabled(false);
264 GroupDest1->setEnabled(false);
265 setEnabledUndo(false);
266 setEnabledRedo(false);
268 RadioButton1->setChecked(true);
273 GEOMBase_Helper::displayPreview();
277 //=================================================================================
278 // function : InitClick()
280 //=================================================================================
281 void EntityGUI_SketcherDlg::InitClick()
283 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
295 //=================================================================================
296 // function : TypeClicked()
297 // purpose : Radio button management
298 //=================================================================================
299 void EntityGUI_SketcherDlg::TypeClicked(int constructorId)
301 myConstructorId = constructorId;
302 if ( myConstructorId == 0 ) // SEGMENT
304 GroupD2->setEnabled(true);
305 RB_Dest1->setEnabled(true);
306 RB_Dest1->setChecked(true);
309 else if ( myConstructorId == 1 ) // ARC
311 GroupD2->setEnabled(false);
312 RB_Dest1->setEnabled(false);
313 RB_Dest2->setChecked(true);
319 //=================================================================================
320 // function : DestClicked()
321 // purpose : Radio button management
322 //=================================================================================
323 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
329 if ( constructorId == 1 )
331 GroupPt->RB_Point1->setChecked(true);
333 PointClicked(1); // XY
335 else if ( constructorId == 0 )
337 GroupD1->RB_Dir11->setChecked(true);
340 Dir1Clicked(2); // Angle
345 //=================================================================================
346 // function : PointClicked()
347 // purpose : Radio button management
348 //=================================================================================
349 void EntityGUI_SketcherDlg::PointClicked(int constructorId)
353 if ( myConstructorId == 0 )
355 if ( constructorId == 1 )
357 mySketchType = PT_ABS;
358 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
359 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
360 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
361 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
363 Group2Spin->SpinBox_DX->SetValue(myX);
365 Group2Spin->SpinBox_DY->SetValue(myY);
367 Group2Spin->buttonApply->setFocus();
369 GEOMBase_Helper::displayPreview();
371 else if ( constructorId == 0 )
373 mySketchType = PT_RELATIVE;
374 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
375 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
376 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2"));
377 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2"));
379 Group2Spin->SpinBox_DX->SetValue(myDX);
381 Group2Spin->SpinBox_DY->SetValue(myDY);
383 Group2Spin->buttonApply->setFocus();
385 GEOMBase_Helper::displayPreview();
387 else if ( constructorId == 2 )
389 mySketchType = PT_SEL;
390 myEditCurrentArgument = Group1Sel->LineEdit1;
391 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
392 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
394 Group1Sel->buttonApply->setFocus();
395 SelectionIntoArgument();
401 //=================================================================================
402 // function : Dir1Clicked()
403 // purpose : Radio button management
404 //=================================================================================
405 void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId)
407 myConstructorDirId = constructorId;
408 GroupD2->RB_Dir21->setChecked(true);
413 //=================================================================================
414 // function : Dir2Clicked()
415 // purpose : Radio button management
416 //=================================================================================
417 void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId)
422 if ( myConstructorId == 0 )
427 if ( myConstructorDirId == 2 )
429 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
430 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
431 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
432 Group2Spin->SpinBox_DX->SetValue(myAngle);
433 Group2Spin->buttonApply->setFocus();
436 if ( constructorId == 2 )
438 mySketchType = DIR_ANGLE_LENGTH;
439 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2"));
440 Group2Spin->SpinBox_DY->SetValue(myLength);
442 else if ( constructorId == 0 )
444 mySketchType = DIR_ANGLE_X;
445 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_X3"));
446 Group2Spin->SpinBox_DY->SetValue(myX);
448 else if ( constructorId == 1 )
450 mySketchType = DIR_ANGLE_Y;
451 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y3"));
452 Group2Spin->SpinBox_DY->SetValue(myY);
455 else if ( myConstructorDirId == 0 )
458 Group1Spin->buttonApply->setFocus();
460 if ( constructorId == 2 )
462 mySketchType = DIR_PER_LENGTH;
463 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
464 Group1Spin->SpinBox_DX->SetValue(myLength);
466 else if ( constructorId == 0 )
468 mySketchType = DIR_PER_X;
469 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
470 Group1Spin->SpinBox_DX->SetValue(myX);
472 else if ( constructorId == 1 )
474 mySketchType = DIR_PER_Y;
475 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
476 Group1Spin->SpinBox_DX->SetValue(myY);
479 else if ( myConstructorDirId == 1 )
482 Group1Spin->buttonApply->setFocus();
484 if ( constructorId == 2 )
486 mySketchType = DIR_TAN_LENGTH;
487 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
488 Group1Spin->SpinBox_DX->SetValue(myLength);
490 else if ( constructorId == 0 )
492 mySketchType = DIR_TAN_X;
493 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
494 Group1Spin->SpinBox_DX->SetValue(myX);
496 else if ( constructorId == 1 )
498 mySketchType = DIR_TAN_Y;
499 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
500 Group1Spin->SpinBox_DX->SetValue(myY);
503 else if ( myConstructorDirId == 3 )
505 Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
506 Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
507 Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
508 Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
509 Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
511 Group3Spin->SpinBox_DX->SetValue(myDX);
513 Group3Spin->SpinBox_DY->SetValue(myDY);
515 Group3Spin->buttonApply->setFocus();
517 if ( constructorId == 2 )
519 mySketchType = DIR_DXDY_LENGTH;
520 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2"));
521 Group3Spin->SpinBox_DZ->SetValue(myLength);
523 else if ( constructorId == 0 )
525 mySketchType = DIR_DXDY_X;
526 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_X3"));
527 Group3Spin->SpinBox_DZ->SetValue(myX);
529 else if ( constructorId == 1 )
531 mySketchType = DIR_DXDY_Y;
532 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Y3"));
533 Group3Spin->SpinBox_DZ->SetValue(myY);
537 else if ( myConstructorId == 1 )
539 if ( myConstructorDirId == 2 )
541 if ( constructorId == 2 )
543 mySketchType = DIR_ANGLE_LENGTH;
544 Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
545 Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
546 Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
547 Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
548 Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_RADIUS2"));
549 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_ANGLE2"));
550 Group3Spin->SpinBox_DX->SetValue(myAngle);
552 Group3Spin->SpinBox_DY->SetValue(myRadius);
554 Group3Spin->SpinBox_DZ->SetValue(myLength);
556 Group3Spin->buttonApply->setFocus();
559 else if ( myConstructorDirId == 0 )
561 if ( constructorId == 2 )
563 mySketchType = DIR_PER_LENGTH;
564 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
565 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
566 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
567 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
569 Group2Spin->SpinBox_DX->SetValue(myRadius);
571 Group2Spin->SpinBox_DY->SetValue(myLength);
573 Group2Spin->buttonApply->setFocus();
576 else if ( myConstructorDirId == 1 )
578 if ( constructorId == 2 )
580 mySketchType = DIR_TAN_LENGTH;
581 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
582 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
583 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
584 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
586 Group2Spin->SpinBox_DX->SetValue(myRadius);
588 Group2Spin->SpinBox_DY->SetValue(myLength);
590 Group2Spin->buttonApply->setFocus();
593 else if ( myConstructorDirId == 3 )
595 if ( constructorId == 2 )
597 mySketchType = DIR_DXDY_LENGTH;
598 Group4Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
599 Group4Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
600 Group4Spin->TextLabel3->setText(tr("GEOM_SKETCHER_RADIUS2"));
601 Group4Spin->TextLabel4->setText(tr("GEOM_SKETCHER_ANGLE2"));
603 Group4Spin->SpinBox_DX->SetValue(myDX);
605 Group4Spin->SpinBox_DY->SetValue(myDY);
607 Group4Spin->SpinBox_DZ->SetValue(myRadius);
609 Group4Spin->SpinBox_DS->SetValue(myLength);
611 Group4Spin->buttonApply->setFocus();
616 GEOMBase_Helper::displayPreview();
620 //=================================================================================
621 // function : ClickOnCancel()
623 //=================================================================================
624 void EntityGUI_SketcherDlg::ClickOnCancel()
630 //=================================================================================
631 // function : ClickOnEnd()
632 // purpose : connected to buttonEnd AND buttonClose
633 //=================================================================================
634 void EntityGUI_SketcherDlg::ClickOnEnd()
636 if ( sender() == buttonClose )
638 // Verify validity of commands
639 if ( myCommand.count() <= 2 )
641 SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(),
642 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
646 QString Command = myCommand.join( "" ) + GetNewCommand();
647 Sketcher_Profile aProfile (Command.ascii());
649 Command = myCommand.join( "" );
650 aProfile = Sketcher_Profile(Command.ascii());
651 TopoDS_Shape myShape;
652 if ( aProfile.IsDone() )
653 myShape = aProfile.GetShape();
655 if(myShape.ShapeType() != TopAbs_VERTEX)
656 myCommand.append( ":WW" );
661 if( myCommand.size() > 2 )
668 //=================================================================================
669 // function : ClickOnApply()
671 //=================================================================================
672 bool EntityGUI_SketcherDlg::ClickOnApply()
674 myCommand.append( GetNewCommand() );
675 mySketchState = NEXT_POINT;
677 myUndoCommand.clear();
678 myUndoCommand.append( "Sketcher" );
680 GroupConstructors->setEnabled(true);
681 GroupDest1->setEnabled(true);
682 setEnabledUndo(true);
683 setEnabledRedo(false);
685 GEOMBase_Helper::displayPreview();
690 //=================================================================================
691 // function : ClickOnUndo()
693 //=================================================================================
694 void EntityGUI_SketcherDlg::ClickOnUndo()
696 myUndoCommand.append( myCommand.last() );
697 myCommand.pop_back();
699 if(myCommand.count() == 1) {
700 mySketchState = FIRST_POINT;
702 RadioButton1->setChecked(true);
705 GroupConstructors->setEnabled(false);
706 GroupDest1->setEnabled(false);
707 setEnabledUndo(false);
710 setEnabledRedo(true);
712 GEOMBase_Helper::displayPreview();
715 //=================================================================================
716 // function : ClickOnRedo()
718 //=================================================================================
719 void EntityGUI_SketcherDlg::ClickOnRedo()
721 myCommand.append( myUndoCommand.last() );
722 myUndoCommand.pop_back();
724 mySketchState = NEXT_POINT;
726 GroupConstructors->setEnabled(true);
727 GroupDest1->setEnabled(true);
728 setEnabledUndo(true);
730 if(myUndoCommand.count() == 1)
731 setEnabledRedo(false);
733 GEOMBase_Helper::displayPreview();
736 //=================================================================================
737 // function : setEnabledUndo()
739 //=================================================================================
740 void EntityGUI_SketcherDlg::setEnabledUndo(bool value)
742 Group1Sel->buttonUndo->setEnabled(value);
743 Group1Spin->buttonUndo->setEnabled(value);
744 Group2Spin->buttonUndo->setEnabled(value);
745 Group3Spin->buttonUndo->setEnabled(value);
746 Group4Spin->buttonUndo->setEnabled(value);
749 //=================================================================================
750 // function : setEnabledRedo()
752 //=================================================================================
753 void EntityGUI_SketcherDlg::setEnabledRedo(bool value)
755 Group1Sel->buttonRedo->setEnabled(value);
756 Group1Spin->buttonRedo->setEnabled(value);
757 Group2Spin->buttonRedo->setEnabled(value);
758 Group3Spin->buttonRedo->setEnabled(value);
759 Group4Spin->buttonRedo->setEnabled(value);
762 //=================================================================================
763 // function : SelectionIntoArgument()
764 // purpose : Called when selection as changed
765 //=================================================================================
766 void EntityGUI_SketcherDlg::SelectionIntoArgument()
768 myEditCurrentArgument->setText("");
772 int nbSel = IObjectCount();
773 if ( nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1 )
775 Standard_Boolean aRes = Standard_False;
776 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes );
777 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
779 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_VERTEX ) ) {
781 gp_Ax3 aWPlane = myGeometryGUI->GetWorkingPlane();
783 aTrans.SetTransformation(aWPlane);
784 BRepBuilderAPI_Transform aTransformation(aShape, aTrans, Standard_False);
785 aShape = aTransformation.Shape();
788 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
791 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
797 GEOMBase_Helper::displayPreview();
801 //=================================================================================
802 // function : SetEditCurrentArgument()
804 //=================================================================================
805 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
807 if ( sender() == Group1Sel->PushButton1 )
809 myEditCurrentArgument = Group1Sel->LineEdit1;
810 myEditCurrentArgument->setFocus();
812 SelectionIntoArgument();
816 //=================================================================================
817 // function : LineEditReturnPressed()
819 //=================================================================================
820 void EntityGUI_SketcherDlg::LineEditReturnPressed()
822 if ( sender() == Group1Sel->LineEdit1 )
824 myEditCurrentArgument = Group1Sel->LineEdit1;
826 /* User name of object input management */
827 /* If successfull the selection is changed and signal emitted... */
828 /* so SelectionIntoArgument() is automatically called. */
829 const QString objectUserName = myEditCurrentArgument->text();
830 QWidget* thisWidget = (QWidget*)this;
831 if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO()))
832 myEditCurrentArgument->setText(objectUserName);
837 //=================================================================================
838 // function : DeactivateActiveDialog()
840 //=================================================================================
841 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
843 //myGeometryGUI->SetState( -1 );
847 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
848 myGeometryGUI->SetActiveDialogBox(0);
852 //=================================================================================
853 // function : ActivateThisDialog()
855 //=================================================================================
856 void EntityGUI_SketcherDlg::ActivateThisDialog()
858 myGeometryGUI->EmitSignalDeactivateDialog();
860 myGeometryGUI->SetActiveDialogBox((QDialog*)this);
862 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
863 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
865 //myGeometryGUI->SetState( 0 );
866 globalSelection( GEOM_POINT );
868 myEditCurrentArgument = Group1Sel->LineEdit1;
869 myEditCurrentArgument->setFocus();
871 GEOMBase_Helper::displayPreview();
875 //=================================================================================
876 // function : enterEvent [REDEFINED]
878 //=================================================================================
879 void EntityGUI_SketcherDlg::enterEvent(QEvent* e)
881 if ( !GroupConstructors->isEnabled())
882 ActivateThisDialog();
886 //=================================================================================
887 // function : closeEvent()
889 //=================================================================================
890 void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e)
892 //myGeometryGUI->SetState( -1 );
893 disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
894 QDialog::closeEvent( e );
898 //=================================================================================
899 // function : ValueChangedInSpinBox()
901 //=================================================================================
902 void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue)
904 QObject* send = (QObject*)sender();
905 Standard_Real vx, vy, vz, vs;
906 vx = vy = vz = vs = 0.0;
908 if ( send == Group1Spin->SpinBox_DX)
912 else if ( send == Group2Spin->SpinBox_DX )
915 vy = Group2Spin->SpinBox_DY->GetValue();
917 else if ( send == Group2Spin->SpinBox_DY)
919 vx = Group2Spin->SpinBox_DX->GetValue();
922 else if ( send == Group3Spin->SpinBox_DX)
925 vy = Group3Spin->SpinBox_DY->GetValue();
926 vz = Group3Spin->SpinBox_DZ->GetValue();
928 else if ( send == Group3Spin->SpinBox_DY)
930 vx = Group3Spin->SpinBox_DX->GetValue();
932 vz = Group3Spin->SpinBox_DZ->GetValue();
934 else if ( send == Group3Spin->SpinBox_DZ)
936 vx = Group3Spin->SpinBox_DX->GetValue();
937 vy = Group3Spin->SpinBox_DY->GetValue();
940 else if ( send == Group4Spin->SpinBox_DX)
943 vy = Group4Spin->SpinBox_DY->GetValue();
944 vz = Group4Spin->SpinBox_DZ->GetValue();
945 vs = Group4Spin->SpinBox_DS->GetValue();
947 else if ( send == Group4Spin->SpinBox_DY)
949 vx = Group4Spin->SpinBox_DX->GetValue();
951 vz = Group4Spin->SpinBox_DZ->GetValue();
952 vs = Group4Spin->SpinBox_DS->GetValue();
954 else if ( send == Group4Spin->SpinBox_DZ)
956 vx = Group4Spin->SpinBox_DX->GetValue();
957 vy = Group4Spin->SpinBox_DY->GetValue();
959 vs = Group4Spin->SpinBox_DS->GetValue();
961 else if ( send == Group4Spin->SpinBox_DS)
963 vx = Group4Spin->SpinBox_DX->GetValue();
964 vy = Group4Spin->SpinBox_DY->GetValue();
965 vz = Group4Spin->SpinBox_DZ->GetValue();
969 if ( myConstructorId == 0 )
971 if ( mySketchType == PT_ABS)
976 else if ( mySketchType == PT_RELATIVE)
981 else if ( mySketchType == DIR_ANGLE_LENGTH)
986 else if ( mySketchType == DIR_ANGLE_X)
991 else if ( mySketchType == DIR_ANGLE_Y)
996 else if ( mySketchType == DIR_PER_LENGTH)
1000 else if ( mySketchType == DIR_PER_X)
1004 else if ( mySketchType == DIR_PER_Y)
1008 else if ( mySketchType == DIR_TAN_LENGTH)
1012 else if ( mySketchType == DIR_TAN_X)
1016 else if ( mySketchType == DIR_TAN_Y)
1020 else if ( mySketchType == DIR_DXDY_LENGTH)
1026 else if ( mySketchType == DIR_DXDY_X)
1032 else if ( mySketchType == DIR_DXDY_Y)
1039 else if ( myConstructorId == 1 )
1041 if ( mySketchType == DIR_ANGLE_LENGTH)
1047 else if ( mySketchType == DIR_PER_LENGTH)
1052 else if ( mySketchType == DIR_TAN_LENGTH)
1057 else if ( mySketchType == DIR_DXDY_LENGTH)
1066 GEOMBase_Helper::displayPreview();
1070 //=================================================================================
1071 // function : GetNewCommand()
1072 // purpose : Build the new command with context
1073 //=================================================================================
1074 QString EntityGUI_SketcherDlg::GetNewCommand()
1076 QString myNewCommand = ":";
1077 if ( mySketchState == FIRST_POINT ) {
1078 if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
1079 myNewCommand = myNewCommand + "F " + QString::number(myX) + " " + QString::number(myY);
1080 if ( mySketchType == PT_RELATIVE)
1081 myNewCommand = myNewCommand + "F " + QString::number(myDX) + " " + QString::number(myDY);
1082 return myNewCommand;
1085 if ( myConstructorId == 0 )
1087 if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
1088 myNewCommand = myNewCommand + "TT " + QString::number(myX) + " " + QString::number(myY);
1089 if ( mySketchType == PT_RELATIVE)
1090 myNewCommand = myNewCommand + "T " + QString::number(myDX) + " " + QString::number(myDY);
1091 if ( mySketchType == DIR_ANGLE_LENGTH)
1093 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1094 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1096 if ( mySketchType == DIR_ANGLE_X)
1098 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1099 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1101 if ( mySketchType == DIR_ANGLE_Y)
1103 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1104 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1106 if ( mySketchType == DIR_PER_LENGTH)
1108 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1109 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1111 if ( mySketchType == DIR_PER_X)
1113 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1114 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1116 if ( mySketchType == DIR_PER_Y)
1118 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1119 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1121 if ( mySketchType == DIR_TAN_LENGTH)
1122 myNewCommand = myNewCommand + "L " + QString::number(myLength);
1123 if ( mySketchType == DIR_TAN_X)
1124 myNewCommand = myNewCommand + "IX " + QString::number(myX);
1125 if ( mySketchType == DIR_TAN_Y)
1126 myNewCommand = myNewCommand + "IY " + QString::number(myY);
1127 if ( mySketchType == DIR_DXDY_LENGTH)
1129 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1130 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1132 if ( mySketchType == DIR_DXDY_X)
1134 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1135 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1137 if ( mySketchType == DIR_DXDY_Y)
1139 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1140 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1143 else if ( myConstructorId == 1 )
1145 if ( mySketchType == DIR_ANGLE_LENGTH)
1147 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1148 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1150 if ( mySketchType == DIR_PER_LENGTH)
1152 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1153 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1155 if ( mySketchType == DIR_TAN_LENGTH)
1157 myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1159 if ( mySketchType == DIR_DXDY_LENGTH)
1161 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1162 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1165 return myNewCommand;
1168 //=================================================================================
1169 // function : createOperation
1171 //=================================================================================
1172 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1174 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1177 //=================================================================================
1178 // function : isValid
1180 //=================================================================================
1181 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1186 //=================================================================================
1187 // function : execute
1189 //=================================================================================
1190 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1192 if(mySketchState == FIRST_POINT) {
1197 //Test if the current point is the same as the last one
1198 TopoDS_Shape myShape1, myShape2;
1201 QString Command1 = myCommand.join( "" );
1202 Sketcher_Profile aProfile1 (Command1.ascii());
1203 if(aProfile1.IsDone())
1204 myShape1 = aProfile1.GetShape();
1207 QString Command2 = Command1 + GetNewCommand();
1208 Sketcher_Profile aProfile2 (Command2.ascii());
1209 if(aProfile2.IsDone())
1210 myShape2 = aProfile2.GetShape();
1212 if(myShape2.IsNull()) {
1213 //the current point is the same as the last one
1214 myLastX2 = myLastX1;
1215 myLastY2 = myLastY1;
1218 TopoDS_Vertex V1, V2;
1220 if(myShape1.ShapeType() == TopAbs_VERTEX) {
1221 //the last shape is the first point
1222 pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape1));
1227 TopExp::Vertices(TopoDS::Wire(myShape1), V1, V2);
1228 pt = BRep_Tool::Pnt(V2);
1232 TopExp::Vertices(TopoDS::Wire(myShape2), V1, V2);
1233 pt = BRep_Tool::Pnt(V2);
1240 if( ( mySketchState != FIRST_POINT && myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
1241 cmd = myCommand.join( "" );
1243 if ( Group1Sel->isVisible() ) {
1244 Group1Sel->buttonApply->setEnabled(false);
1245 Group1Sel->buttonApply->setFocus();
1247 if ( Group1Spin->isVisible() ) {
1248 Group1Spin->buttonApply->setEnabled(false);
1249 Group1Spin->buttonApply->setFocus();
1251 if ( Group2Spin->isVisible() ) {
1252 Group2Spin->buttonApply->setEnabled(false);
1253 Group2Spin->buttonApply->setFocus();
1255 if ( Group3Spin->isVisible() ) {
1256 Group3Spin->buttonApply->setEnabled(false);
1257 Group3Spin->buttonApply->setFocus();
1259 if ( Group4Spin->isVisible() ) {
1260 Group4Spin->buttonApply->setEnabled(false);
1261 Group4Spin->buttonApply->setFocus();
1265 cmd = myCommand.join( "" ) + GetNewCommand();
1267 if ( Group1Sel->isVisible() ) {
1268 Group1Sel->buttonApply->setEnabled(true);
1269 Group1Sel->buttonApply->setFocus();
1271 if ( Group1Spin->isVisible() ) {
1272 Group1Spin->buttonApply->setEnabled(true);
1273 Group1Spin->buttonApply->setFocus();
1275 if ( Group2Spin->isVisible() ) {
1276 Group2Spin->buttonApply->setEnabled(true);
1277 Group2Spin->buttonApply->setFocus();
1279 if ( Group3Spin->isVisible() ) {
1280 Group3Spin->buttonApply->setEnabled(true);
1281 Group3Spin->buttonApply->setFocus();
1283 if ( Group4Spin->isVisible() ) {
1284 Group4Spin->buttonApply->setEnabled(true);
1285 Group4Spin->buttonApply->setFocus();
1289 gp_Ax3 myWPlane = myGeometryGUI->GetWorkingPlane();
1290 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
1292 WPlane[0] = myWPlane.Location().X();
1293 WPlane[1] = myWPlane.Location().Y();
1294 WPlane[2] = myWPlane.Location().Z();
1296 WPlane[3] = myWPlane.Direction().X();
1297 WPlane[4] = myWPlane.Direction().Y();
1298 WPlane[5] = myWPlane.Direction().Z();
1300 WPlane[6] = myWPlane.XDirection().X();
1301 WPlane[7] = myWPlane.XDirection().Y();
1302 WPlane[8] = myWPlane.XDirection().Z();
1304 GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeSketcher( cmd.latin1(), WPlane );
1306 if ( !anObj->_is_nil() )
1307 objects.push_back( anObj._retn() );
1312 //================================================================
1313 // Function : displayPreview
1314 // Purpose : Method for displaying preview of resulting shape
1315 // Redefined from GEOMBase_Helper.
1316 //================================================================
1317 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
1319 const bool activate,
1321 const double lineWidth )
1323 // Set color for preview shape
1324 getDisplayer()->SetColor( Quantity_NOC_RED );
1326 // set width of displayed shape
1327 getDisplayer()->SetWidth( lineWidth );
1329 // Disable activation of selection
1330 getDisplayer()->SetToActivate( activate );
1332 // Make a reference to GEOM_Object
1333 getDisplayer()->SetName( myGeometryGUI->getApp()->orb()->object_to_string( object ) );
1335 // Create wire from applayed object
1336 TopoDS_Shape anApplyedWire, aLastSegment;
1337 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
1341 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
1342 if ( aPrs != 0 && !aPrs->IsNull() )
1343 GEOMBase_Helper::displayPreview( aPrs, append, update );
1345 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
1346 aPrs = getDisplayer()->BuildPrs( aLastSegment );
1347 if ( aPrs != 0 && !aPrs->IsNull() )
1348 GEOMBase_Helper::displayPreview( aPrs, append, update );
1350 getDisplayer()->UnsetName();
1352 // Enable activation of displayed objects
1353 getDisplayer()->SetToActivate( true );
1356 //================================================================
1357 // Function : createShapes
1358 // Purpose : Create applyed wire, and last segment from entry object
1359 //================================================================
1360 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
1361 TopoDS_Shape& theApplyedWire,
1362 TopoDS_Shape& theLastSegment )
1364 TopoDS_Shape aShape;
1365 if ( !GEOMBase::GetShape( theObject, aShape ) ||
1366 aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
1369 if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() ||
1370 Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
1371 Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
1372 Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
1373 Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() )
1375 theApplyedWire = aShape;
1379 BRepBuilderAPI_MakeWire aBuilder;
1380 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
1383 TopoDS_Shape anEdge = anExp.Current();
1385 if ( anExp.More() ) // i.e. non-last edge
1386 aBuilder.Add( TopoDS::Edge( anEdge ) );
1389 theLastSegment = anEdge;
1394 if ( aBuilder.IsDone() )
1395 theApplyedWire = aBuilder.Shape();