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"
32 #include "QAD_Config.h"
33 #include "QAD_Desktop.h"
34 #include "QAD_MessageBox.h"
36 #include <qpushbutton.h>
38 #include <BRep_Tool.hxx>
40 #include <TopExp_Explorer.hxx>
41 #include <TopoDS_Vertex.hxx>
43 #include <BRepBuilderAPI_Transform.hxx>
44 #include <BRepBuilderAPI_MakeWire.hxx>
46 #include "GEOMImpl_Types.hxx"
48 #include "utilities.h"
52 //=================================================================================
53 // class : EntityGUI_SketcherDlg()
54 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
55 // name 'name' and widget flags set to 'f'.
56 // The dialog will by default be modeless, unless you set 'modal' to
57 // TRUE to construct a modal dialog.
58 //=================================================================================
59 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
60 :EntityGUI_Skeleton_QTD(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), GEOMBase_Helper(), myIsAllAdded( false )
63 GeometryGUI::GetGeomGUI()->SetActiveDialogBox(this);
65 if ( !name ) setName("EntityGUI_SketcherDlg");
67 buttonCancel->setText(tr("GEOM_BUT_CANCEL"));
68 buttonEnd->setText(tr("GEOM_BUT_END_SKETCH"));
69 buttonClose->setText(tr("GEOM_BUT_CLOSE_SKETCH"));
71 GroupVal->close(TRUE);
72 GroupDest2->close(TRUE);
73 GroupDest3->close(TRUE);
75 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
76 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_UNDO")));
77 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_REDO")));
79 setCaption(tr("GEOM_SKETCHER_TITLE"));
81 GroupConstructors->setTitle(tr("GEOM_SKETCHER_EL"));
82 RadioButton1->setText(tr("GEOM_SKETCHER_SEGMENT"));
83 RadioButton2->setText(tr("GEOM_SKETCHER_ARC"));
84 GroupDest->setTitle(tr("GEOM_SKETCHER_DEST"));
85 GroupDest1->setTitle(tr("GEOM_SKETCHER_TYPE"));
86 RB_Dest1->setText(tr("GEOM_SKETCHER_POINT"));
87 RB_Dest2->setText(tr("GEOM_SKETCHER_DIR"));
89 /***************************************************************/
90 GroupPt = new EntityGUI_Point_QTD(GroupDest, "GroupPt");
91 GroupPt->GroupPoint->setTitle(tr("GEOM_SKETCHER_POINT"));
92 GroupPt->RB_Point1->setText(tr("GEOM_SKETCHER_ABS"));
93 GroupPt->RB_Point2->setText(tr("GEOM_SKETCHER_REL"));
94 GroupPt->RB_Point3->setText(tr("GEOM_SKETCHER_SEL"));
96 GroupD1 = new EntityGUI_Dir1_QTD(GroupDest, "GroupD1");
97 GroupD1->GroupDir1->setTitle(tr("GEOM_SKETCHER_DIR"));
98 GroupD1->RB_Dir11->setText(tr("GEOM_SKETCHER_ANGLE"));
99 GroupD1->RB_Dir12->setText(tr("GEOM_SKETCHER_PER"));
100 GroupD1->RB_Dir13->setText(tr("GEOM_SKETCHER_TAN"));
101 GroupD1->RB_Dir14->setText(tr("GEOM_SKETCHER_VXVY"));
103 GroupD2 = new EntityGUI_Dir2_QTD(GroupDest, "GroupD2");
104 GroupD2->GroupDir2->setTitle(tr("GEOM_SKETCHER_DIR"));
105 GroupD2->RB_Dir21->setText(tr("GEOM_SKETCHER_LENGTH"));
106 GroupD2->RB_Dir22->setText(tr("GEOM_SKETCHER_X"));
107 GroupD2->RB_Dir23->setText(tr("GEOM_SKETCHER_Y"));
109 Group1Sel = new EntityGUI_1Sel_QTD(this, "Group1Sel");
110 Group1Sel->TextLabel1->setText(tr("GEOM_SKETCHER_POINT2"));
111 Group1Sel->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
112 Group1Sel->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
113 Group1Sel->PushButton1->setPixmap(image0);
114 Group1Sel->buttonUndo->setPixmap(image1);
115 Group1Sel->buttonRedo->setPixmap(image2);
116 Group1Sel->LineEdit1->setReadOnly( true );
118 Group1Spin = new EntityGUI_1Spin(this, "Group1Spin");
119 Group1Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
120 Group1Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
121 Group1Spin->buttonUndo->setPixmap(image1);
122 Group1Spin->buttonRedo->setPixmap(image2);
124 Group2Spin = new EntityGUI_2Spin(this, "Group2Spin");
125 Group2Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
126 Group2Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
127 Group2Spin->buttonUndo->setPixmap(image1);
128 Group2Spin->buttonRedo->setPixmap(image2);
130 Group3Spin = new EntityGUI_3Spin(this, "Group3Spin");
131 Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
132 Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
133 Group3Spin->buttonUndo->setPixmap(image1);
134 Group3Spin->buttonRedo->setPixmap(image2);
136 Group4Spin = new EntityGUI_4Spin(this, "Group4Spin");
137 Group4Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
138 Group4Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
139 Group4Spin->buttonUndo->setPixmap(image1);
140 Group4Spin->buttonRedo->setPixmap(image2);
142 Layout5->addMultiCellWidget(GroupPt, 1, 1, 0, 1);
143 Layout5->addWidget(GroupD1, 1, 0);
144 Layout5->addWidget(GroupD2, 1, 1);
146 Layout1->addWidget(Group1Sel, 2, 0);
147 Layout1->addWidget(Group1Spin, 2, 0);
148 Layout1->addWidget(Group2Spin, 2, 0);
149 Layout1->addWidget(Group3Spin, 2, 0);
150 Layout1->addWidget(Group4Spin, 2, 0);
151 /***************************************************************/
153 /* signals and slots connections */
154 connect(buttonEnd, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
155 connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
156 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
158 connect(Group1Sel->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
159 connect(Group1Sel->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
160 connect(Group1Sel->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
161 connect(Group1Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
162 connect(Group1Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
163 connect(Group1Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
164 connect(Group2Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
165 connect(Group2Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
166 connect(Group2Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
167 connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
168 connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
169 connect(Group3Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
170 connect(Group4Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
171 connect(Group4Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
172 connect(Group4Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
174 connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(TypeClicked(int)));
175 connect(GroupDest1, SIGNAL(clicked(int)), this, SLOT(DestClicked(int)));
176 connect(GroupPt->GroupPoint, SIGNAL(clicked(int)), this, SLOT(PointClicked(int)));
177 connect(GroupD1->GroupDir1, SIGNAL(clicked(int)), this, SLOT(Dir1Clicked(int)));
178 connect(GroupD2->GroupDir2, SIGNAL(clicked(int)), this, SLOT(Dir2Clicked(int)));
180 connect(Group1Sel->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
181 connect(Group1Sel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
183 connect(Group1Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
184 connect(Group2Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
185 connect(Group2Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
186 connect(Group3Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
187 connect(Group3Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
188 connect(Group3Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
189 connect(Group4Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
190 connect(Group4Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
191 connect(Group4Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
192 connect(Group4Spin->SpinBox_DS, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
194 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group1Spin->SpinBox_DX, SLOT(SetStep(double)));
195 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DX, SLOT(SetStep(double)));
196 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DY, SLOT(SetStep(double)));
197 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DX, SLOT(SetStep(double)));
198 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DY, SLOT(SetStep(double)));
199 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DZ, SLOT(SetStep(double)));
200 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DX, SLOT(SetStep(double)));
201 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DY, SLOT(SetStep(double)));
202 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DZ, SLOT(SetStep(double)));
203 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DS, SLOT(SetStep(double)));
205 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
206 connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
212 //=================================================================================
213 // function : ~EntityGUI_SketcherDlg()
214 // purpose : Destroys the object and frees any allocated resources
215 //=================================================================================
216 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
218 GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 );
222 //=================================================================================
225 //=================================================================================
226 void EntityGUI_SketcherDlg::Init()
229 myEditCurrentArgument = Group1Sel->LineEdit1;
230 myCommand.append( "Sketcher" );
231 myUndoCommand.append( "Sketcher" );
233 mySketchState = FIRST_POINT;
234 globalSelection( GEOM_POINT );
241 /* Get setting of step value from file configuration */
242 QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
243 double step = St.toDouble();
245 /* min, max, step and decimals for spin boxes */
246 Group1Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
247 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
248 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
249 Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
250 Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
251 Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
252 Group4Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
253 Group4Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
254 Group4Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, step, 3);
255 Group4Spin->SpinBox_DS->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
257 /* displays Dialog */
258 GroupConstructors->setEnabled(false);
259 GroupDest1->setEnabled(false);
260 setEnabledUndo(false);
261 setEnabledRedo(false);
263 RadioButton1->setChecked(true);
268 GEOMBase_Helper::displayPreview();
272 //=================================================================================
273 // function : InitClick()
275 //=================================================================================
276 void EntityGUI_SketcherDlg::InitClick()
278 disconnect(mySelection, 0, this, 0);
290 //=================================================================================
291 // function : TypeClicked()
292 // purpose : Radio button management
293 //=================================================================================
294 void EntityGUI_SketcherDlg::TypeClicked(int constructorId)
296 myConstructorId = constructorId;
297 if ( myConstructorId == 0 ) // SEGMENT
299 GroupD2->setEnabled(true);
300 RB_Dest1->setEnabled(true);
301 RB_Dest1->setChecked(true);
304 else if ( myConstructorId == 1 ) // ARC
306 GroupD2->setEnabled(false);
307 RB_Dest1->setEnabled(false);
308 RB_Dest2->setChecked(true);
314 //=================================================================================
315 // function : DestClicked()
316 // purpose : Radio button management
317 //=================================================================================
318 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
324 if ( constructorId == 1 )
326 GroupPt->RB_Point1->setChecked(true);
328 PointClicked(1); // XY
330 else if ( constructorId == 0 )
332 GroupD1->RB_Dir11->setChecked(true);
335 Dir1Clicked(2); // Angle
340 //=================================================================================
341 // function : PointClicked()
342 // purpose : Radio button management
343 //=================================================================================
344 void EntityGUI_SketcherDlg::PointClicked(int constructorId)
348 if ( myConstructorId == 0 )
350 if ( constructorId == 1 )
352 mySketchType = PT_ABS;
353 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
354 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
355 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
356 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
358 Group2Spin->SpinBox_DX->SetValue(myX);
360 Group2Spin->SpinBox_DY->SetValue(myY);
362 Group2Spin->buttonApply->setFocus();
364 GEOMBase_Helper::displayPreview();
366 else if ( constructorId == 0 )
368 mySketchType = PT_RELATIVE;
369 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
370 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
371 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2"));
372 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2"));
374 Group2Spin->SpinBox_DX->SetValue(myDX);
376 Group2Spin->SpinBox_DY->SetValue(myDY);
378 Group2Spin->buttonApply->setFocus();
380 GEOMBase_Helper::displayPreview();
382 else if ( constructorId == 2 )
384 mySketchType = PT_SEL;
385 myEditCurrentArgument = Group1Sel->LineEdit1;
386 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
388 Group1Sel->buttonApply->setFocus();
389 SelectionIntoArgument();
395 //=================================================================================
396 // function : Dir1Clicked()
397 // purpose : Radio button management
398 //=================================================================================
399 void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId)
401 myConstructorDirId = constructorId;
402 GroupD2->RB_Dir21->setChecked(true);
407 //=================================================================================
408 // function : Dir2Clicked()
409 // purpose : Radio button management
410 //=================================================================================
411 void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId)
416 if ( myConstructorId == 0 )
421 if ( myConstructorDirId == 2 )
423 Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
424 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
425 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
426 Group2Spin->SpinBox_DX->SetValue(myAngle);
427 Group2Spin->buttonApply->setFocus();
430 if ( constructorId == 2 )
432 mySketchType = DIR_ANGLE_LENGTH;
433 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2"));
434 Group2Spin->SpinBox_DY->SetValue(myLength);
436 else if ( constructorId == 0 )
438 mySketchType = DIR_ANGLE_X;
439 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_X3"));
440 Group2Spin->SpinBox_DY->SetValue(myX);
442 else if ( constructorId == 1 )
444 mySketchType = DIR_ANGLE_Y;
445 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y3"));
446 Group2Spin->SpinBox_DY->SetValue(myY);
449 else if ( myConstructorDirId == 0 )
452 Group1Spin->buttonApply->setFocus();
454 if ( constructorId == 2 )
456 mySketchType = DIR_PER_LENGTH;
457 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
458 Group1Spin->SpinBox_DX->SetValue(myLength);
460 else if ( constructorId == 0 )
462 mySketchType = DIR_PER_X;
463 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
464 Group1Spin->SpinBox_DX->SetValue(myX);
466 else if ( constructorId == 1 )
468 mySketchType = DIR_PER_Y;
469 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
470 Group1Spin->SpinBox_DX->SetValue(myY);
473 else if ( myConstructorDirId == 1 )
476 Group1Spin->buttonApply->setFocus();
478 if ( constructorId == 2 )
480 mySketchType = DIR_TAN_LENGTH;
481 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
482 Group1Spin->SpinBox_DX->SetValue(myLength);
484 else if ( constructorId == 0 )
486 mySketchType = DIR_TAN_X;
487 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
488 Group1Spin->SpinBox_DX->SetValue(myX);
490 else if ( constructorId == 1 )
492 mySketchType = DIR_TAN_Y;
493 Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
494 Group1Spin->SpinBox_DX->SetValue(myY);
497 else if ( myConstructorDirId == 3 )
499 Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
500 Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3);
501 Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
502 Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
503 Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
505 Group3Spin->SpinBox_DX->SetValue(myDX);
507 Group3Spin->SpinBox_DY->SetValue(myDY);
509 Group3Spin->buttonApply->setFocus();
511 if ( constructorId == 2 )
513 mySketchType = DIR_DXDY_LENGTH;
514 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2"));
515 Group3Spin->SpinBox_DZ->SetValue(myLength);
517 else if ( constructorId == 0 )
519 mySketchType = DIR_DXDY_X;
520 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_X3"));
521 Group3Spin->SpinBox_DZ->SetValue(myX);
523 else if ( constructorId == 1 )
525 mySketchType = DIR_DXDY_Y;
526 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Y3"));
527 Group3Spin->SpinBox_DZ->SetValue(myY);
531 else if ( myConstructorId == 1 )
533 if ( myConstructorDirId == 2 )
535 if ( constructorId == 2 )
537 mySketchType = DIR_ANGLE_LENGTH;
538 Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
539 Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
540 Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
541 Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
542 Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_RADIUS2"));
543 Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_ANGLE2"));
544 Group3Spin->SpinBox_DX->SetValue(myAngle);
546 Group3Spin->SpinBox_DY->SetValue(myRadius);
548 Group3Spin->SpinBox_DZ->SetValue(myLength);
550 Group3Spin->buttonApply->setFocus();
553 else if ( myConstructorDirId == 0 )
555 if ( constructorId == 2 )
557 mySketchType = DIR_PER_LENGTH;
558 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
559 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
560 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
561 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
563 Group2Spin->SpinBox_DX->SetValue(myRadius);
565 Group2Spin->SpinBox_DY->SetValue(myLength);
567 Group2Spin->buttonApply->setFocus();
570 else if ( myConstructorDirId == 1 )
572 if ( constructorId == 2 )
574 mySketchType = DIR_TAN_LENGTH;
575 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3);
576 Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 5., 3);
577 Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
578 Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
580 Group2Spin->SpinBox_DX->SetValue(myRadius);
582 Group2Spin->SpinBox_DY->SetValue(myLength);
584 Group2Spin->buttonApply->setFocus();
587 else if ( myConstructorDirId == 3 )
589 if ( constructorId == 2 )
591 mySketchType = DIR_DXDY_LENGTH;
592 Group4Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
593 Group4Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
594 Group4Spin->TextLabel3->setText(tr("GEOM_SKETCHER_RADIUS2"));
595 Group4Spin->TextLabel4->setText(tr("GEOM_SKETCHER_ANGLE2"));
597 Group4Spin->SpinBox_DX->SetValue(myDX);
599 Group4Spin->SpinBox_DY->SetValue(myDY);
601 Group4Spin->SpinBox_DZ->SetValue(myRadius);
603 Group4Spin->SpinBox_DS->SetValue(myLength);
605 Group4Spin->buttonApply->setFocus();
610 GEOMBase_Helper::displayPreview();
614 //=================================================================================
615 // function : ClickOnCancel()
617 //=================================================================================
618 void EntityGUI_SketcherDlg::ClickOnCancel()
624 //=================================================================================
625 // function : ClickOnEnd()
626 // purpose : connected to buttonEnd AND buttonClose
627 //=================================================================================
628 void EntityGUI_SketcherDlg::ClickOnEnd()
630 if ( sender() == buttonClose )
632 // Verify validity of commands
633 if ( myCommand.count() <= 2 )
635 QAD_MessageBox::error1( QAD_Application::getDesktop(),
636 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
640 QString Command = myCommand.join( "" ) + GetNewCommand();
641 Sketcher_Profile aProfile (Command.ascii());
643 Command = myCommand.join( "" );
644 aProfile = Sketcher_Profile(Command.ascii());
645 TopoDS_Shape myShape;
646 if ( aProfile.IsDone() )
647 myShape = aProfile.GetShape();
649 if(myShape.ShapeType() != TopAbs_VERTEX)
650 myCommand.append( ":WW" );
655 if( myCommand.size() > 2 )
662 //=================================================================================
663 // function : ClickOnApply()
665 //=================================================================================
666 bool EntityGUI_SketcherDlg::ClickOnApply()
668 myCommand.append( GetNewCommand() );
669 mySketchState = NEXT_POINT;
671 myUndoCommand.clear();
672 myUndoCommand.append( "Sketcher" );
674 GroupConstructors->setEnabled(true);
675 GroupDest1->setEnabled(true);
676 setEnabledUndo(true);
677 setEnabledRedo(false);
679 GEOMBase_Helper::displayPreview();
684 //=================================================================================
685 // function : ClickOnUndo()
687 //=================================================================================
688 void EntityGUI_SketcherDlg::ClickOnUndo()
690 myUndoCommand.append( myCommand.last() );
691 myCommand.pop_back();
693 if(myCommand.count() == 1) {
694 mySketchState = FIRST_POINT;
696 RadioButton1->setChecked(true);
699 GroupConstructors->setEnabled(false);
700 GroupDest1->setEnabled(false);
701 setEnabledUndo(false);
704 setEnabledRedo(true);
706 GEOMBase_Helper::displayPreview();
709 //=================================================================================
710 // function : ClickOnRedo()
712 //=================================================================================
713 void EntityGUI_SketcherDlg::ClickOnRedo()
715 myCommand.append( myUndoCommand.last() );
716 myUndoCommand.pop_back();
718 mySketchState = NEXT_POINT;
720 GroupConstructors->setEnabled(true);
721 GroupDest1->setEnabled(true);
722 setEnabledUndo(true);
724 if(myUndoCommand.count() == 1)
725 setEnabledRedo(false);
727 GEOMBase_Helper::displayPreview();
730 //=================================================================================
731 // function : setEnabledUndo()
733 //=================================================================================
734 void EntityGUI_SketcherDlg::setEnabledUndo(bool value)
736 Group1Sel->buttonUndo->setEnabled(value);
737 Group1Spin->buttonUndo->setEnabled(value);
738 Group2Spin->buttonUndo->setEnabled(value);
739 Group3Spin->buttonUndo->setEnabled(value);
740 Group4Spin->buttonUndo->setEnabled(value);
743 //=================================================================================
744 // function : setEnabledRedo()
746 //=================================================================================
747 void EntityGUI_SketcherDlg::setEnabledRedo(bool value)
749 Group1Sel->buttonRedo->setEnabled(value);
750 Group1Spin->buttonRedo->setEnabled(value);
751 Group2Spin->buttonRedo->setEnabled(value);
752 Group3Spin->buttonRedo->setEnabled(value);
753 Group4Spin->buttonRedo->setEnabled(value);
756 //=================================================================================
757 // function : SelectionIntoArgument()
758 // purpose : Called when selection as changed
759 //=================================================================================
760 void EntityGUI_SketcherDlg::SelectionIntoArgument()
762 myEditCurrentArgument->setText("");
766 int nbSel = mySelection->IObjectCount();
767 if ( nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1 )
769 Standard_Boolean aRes = Standard_False;
770 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes );
771 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
773 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_VERTEX ) ) {
775 gp_Ax3 aWPlane = GeometryGUI::GetGeomGUI()->GetWorkingPlane();
777 aTrans.SetTransformation(aWPlane);
778 BRepBuilderAPI_Transform aTransformation(aShape, aTrans, Standard_False);
779 aShape = aTransformation.Shape();
782 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
785 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
791 GEOMBase_Helper::displayPreview();
795 //=================================================================================
796 // function : SetEditCurrentArgument()
798 //=================================================================================
799 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
801 if ( sender() == Group1Sel->PushButton1 )
803 myEditCurrentArgument = Group1Sel->LineEdit1;
804 myEditCurrentArgument->setFocus();
806 SelectionIntoArgument();
810 //=================================================================================
811 // function : LineEditReturnPressed()
813 //=================================================================================
814 void EntityGUI_SketcherDlg::LineEditReturnPressed()
816 if ( sender() == Group1Sel->LineEdit1 )
818 myEditCurrentArgument = Group1Sel->LineEdit1;
820 /* User name of object input management */
821 /* If successfull the selection is changed and signal emitted... */
822 /* so SelectionIntoArgument() is automatically called. */
823 const QString objectUserName = myEditCurrentArgument->text();
824 QWidget* thisWidget = (QWidget*)this;
825 if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, mySelection))
826 myEditCurrentArgument->setText(objectUserName);
831 //=================================================================================
832 // function : DeactivateActiveDialog()
834 //=================================================================================
835 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
837 GeometryGUI::GetGeomGUI()->SetState( -1 );
841 disconnect(mySelection, 0, this, 0);
842 GeometryGUI::GetGeomGUI()->SetActiveDialogBox(0);
846 //=================================================================================
847 // function : ActivateThisDialog()
849 //=================================================================================
850 void EntityGUI_SketcherDlg::ActivateThisDialog()
852 GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog();
854 GeometryGUI::GetGeomGUI()->SetActiveDialogBox((QDialog*)this);
856 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
858 GeometryGUI::GetGeomGUI()->SetState( 0 );
859 globalSelection( GEOM_POINT );
861 myEditCurrentArgument = Group1Sel->LineEdit1;
862 myEditCurrentArgument->setFocus();
864 GEOMBase_Helper::displayPreview();
868 //=================================================================================
869 // function : enterEvent [REDEFINED]
871 //=================================================================================
872 void EntityGUI_SketcherDlg::enterEvent(QEvent* e)
874 if ( !GroupConstructors->isEnabled())
875 ActivateThisDialog();
879 //=================================================================================
880 // function : closeEvent()
882 //=================================================================================
883 void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e)
885 GeometryGUI::GetGeomGUI()->SetState( -1 );
886 disconnect(mySelection, 0, this, 0);
887 QDialog::closeEvent( e );
891 //=================================================================================
892 // function : ValueChangedInSpinBox()
894 //=================================================================================
895 void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue)
897 QObject* send = (QObject*)sender();
898 Standard_Real vx, vy, vz, vs;
899 vx = vy = vz = vs = 0.0;
901 if ( send == Group1Spin->SpinBox_DX)
905 else if ( send == Group2Spin->SpinBox_DX )
908 vy = Group2Spin->SpinBox_DY->GetValue();
910 else if ( send == Group2Spin->SpinBox_DY)
912 vx = Group2Spin->SpinBox_DX->GetValue();
915 else if ( send == Group3Spin->SpinBox_DX)
918 vy = Group3Spin->SpinBox_DY->GetValue();
919 vz = Group3Spin->SpinBox_DZ->GetValue();
921 else if ( send == Group3Spin->SpinBox_DY)
923 vx = Group3Spin->SpinBox_DX->GetValue();
925 vz = Group3Spin->SpinBox_DZ->GetValue();
927 else if ( send == Group3Spin->SpinBox_DZ)
929 vx = Group3Spin->SpinBox_DX->GetValue();
930 vy = Group3Spin->SpinBox_DY->GetValue();
933 else if ( send == Group4Spin->SpinBox_DX)
936 vy = Group4Spin->SpinBox_DY->GetValue();
937 vz = Group4Spin->SpinBox_DZ->GetValue();
938 vs = Group4Spin->SpinBox_DS->GetValue();
940 else if ( send == Group4Spin->SpinBox_DY)
942 vx = Group4Spin->SpinBox_DX->GetValue();
944 vz = Group4Spin->SpinBox_DZ->GetValue();
945 vs = Group4Spin->SpinBox_DS->GetValue();
947 else if ( send == Group4Spin->SpinBox_DZ)
949 vx = Group4Spin->SpinBox_DX->GetValue();
950 vy = Group4Spin->SpinBox_DY->GetValue();
952 vs = Group4Spin->SpinBox_DS->GetValue();
954 else if ( send == Group4Spin->SpinBox_DS)
956 vx = Group4Spin->SpinBox_DX->GetValue();
957 vy = Group4Spin->SpinBox_DY->GetValue();
958 vz = Group4Spin->SpinBox_DZ->GetValue();
962 if ( myConstructorId == 0 )
964 if ( mySketchType == PT_ABS)
969 else if ( mySketchType == PT_RELATIVE)
974 else if ( mySketchType == DIR_ANGLE_LENGTH)
979 else if ( mySketchType == DIR_ANGLE_X)
984 else if ( mySketchType == DIR_ANGLE_Y)
989 else if ( mySketchType == DIR_PER_LENGTH)
993 else if ( mySketchType == DIR_PER_X)
997 else if ( mySketchType == DIR_PER_Y)
1001 else if ( mySketchType == DIR_TAN_LENGTH)
1005 else if ( mySketchType == DIR_TAN_X)
1009 else if ( mySketchType == DIR_TAN_Y)
1013 else if ( mySketchType == DIR_DXDY_LENGTH)
1019 else if ( mySketchType == DIR_DXDY_X)
1025 else if ( mySketchType == DIR_DXDY_Y)
1032 else if ( myConstructorId == 1 )
1034 if ( mySketchType == DIR_ANGLE_LENGTH)
1040 else if ( mySketchType == DIR_PER_LENGTH)
1045 else if ( mySketchType == DIR_TAN_LENGTH)
1050 else if ( mySketchType == DIR_DXDY_LENGTH)
1059 GEOMBase_Helper::displayPreview();
1063 //=================================================================================
1064 // function : GetNewCommand()
1065 // purpose : Build the new command with context
1066 //=================================================================================
1067 QString EntityGUI_SketcherDlg::GetNewCommand()
1069 QString myNewCommand = ":";
1070 if ( mySketchState == FIRST_POINT ) {
1071 if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
1072 myNewCommand = myNewCommand + "F " + QString::number(myX) + " " + QString::number(myY);
1073 if ( mySketchType == PT_RELATIVE)
1074 myNewCommand = myNewCommand + "F " + QString::number(myDX) + " " + QString::number(myDY);
1075 return myNewCommand;
1078 if ( myConstructorId == 0 )
1080 if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
1081 myNewCommand = myNewCommand + "TT " + QString::number(myX) + " " + QString::number(myY);
1082 if ( mySketchType == PT_RELATIVE)
1083 myNewCommand = myNewCommand + "T " + QString::number(myDX) + " " + QString::number(myDY);
1084 if ( mySketchType == DIR_ANGLE_LENGTH)
1086 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1087 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1089 if ( mySketchType == DIR_ANGLE_X)
1091 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1092 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1094 if ( mySketchType == DIR_ANGLE_Y)
1096 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1097 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1099 if ( mySketchType == DIR_PER_LENGTH)
1101 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1102 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1104 if ( mySketchType == DIR_PER_X)
1106 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1107 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1109 if ( mySketchType == DIR_PER_Y)
1111 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1112 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1114 if ( mySketchType == DIR_TAN_LENGTH)
1115 myNewCommand = myNewCommand + "L " + QString::number(myLength);
1116 if ( mySketchType == DIR_TAN_X)
1117 myNewCommand = myNewCommand + "IX " + QString::number(myX);
1118 if ( mySketchType == DIR_TAN_Y)
1119 myNewCommand = myNewCommand + "IY " + QString::number(myY);
1120 if ( mySketchType == DIR_DXDY_LENGTH)
1122 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1123 myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
1125 if ( mySketchType == DIR_DXDY_X)
1127 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1128 myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
1130 if ( mySketchType == DIR_DXDY_Y)
1132 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1133 myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
1136 else if ( myConstructorId == 1 )
1138 if ( mySketchType == DIR_ANGLE_LENGTH)
1140 myNewCommand = myNewCommand + "R " + QString::number(myAngle);
1141 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1143 if ( mySketchType == DIR_PER_LENGTH)
1145 myNewCommand = myNewCommand + "R " + QString::number(90.0);
1146 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1148 if ( mySketchType == DIR_TAN_LENGTH)
1150 myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1152 if ( mySketchType == DIR_DXDY_LENGTH)
1154 myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
1155 myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
1158 return myNewCommand;
1161 //=================================================================================
1162 // function : createOperation
1164 //=================================================================================
1165 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1167 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1170 //=================================================================================
1171 // function : isValid
1173 //=================================================================================
1174 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1179 //=================================================================================
1180 // function : execute
1182 //=================================================================================
1183 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1185 if(mySketchState == FIRST_POINT) {
1190 //Test if the current point is the same as the last one
1191 TopoDS_Shape myShape1, myShape2;
1194 QString Command1 = myCommand.join( "" );
1195 Sketcher_Profile aProfile1 (Command1.ascii());
1196 if(aProfile1.IsDone())
1197 myShape1 = aProfile1.GetShape();
1200 QString Command2 = Command1 + GetNewCommand();
1201 Sketcher_Profile aProfile2 (Command2.ascii());
1202 if(aProfile2.IsDone())
1203 myShape2 = aProfile2.GetShape();
1205 if(myShape2.IsNull()) {
1206 //the current point is the same as the last one
1207 myLastX2 = myLastX1;
1208 myLastY2 = myLastY1;
1211 TopoDS_Vertex V1, V2;
1213 if(myShape1.ShapeType() == TopAbs_VERTEX) {
1214 //the last shape is the first point
1215 pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape1));
1220 TopExp::Vertices(TopoDS::Wire(myShape1), V1, V2);
1221 pt = BRep_Tool::Pnt(V2);
1225 TopExp::Vertices(TopoDS::Wire(myShape2), V1, V2);
1226 pt = BRep_Tool::Pnt(V2);
1233 if( ( mySketchState != FIRST_POINT && myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
1234 cmd = myCommand.join( "" );
1236 if ( Group1Sel->isVisible() ) {
1237 Group1Sel->buttonApply->setEnabled(false);
1238 Group1Sel->buttonApply->setFocus();
1240 if ( Group1Spin->isVisible() ) {
1241 Group1Spin->buttonApply->setEnabled(false);
1242 Group1Spin->buttonApply->setFocus();
1244 if ( Group2Spin->isVisible() ) {
1245 Group2Spin->buttonApply->setEnabled(false);
1246 Group2Spin->buttonApply->setFocus();
1248 if ( Group3Spin->isVisible() ) {
1249 Group3Spin->buttonApply->setEnabled(false);
1250 Group3Spin->buttonApply->setFocus();
1252 if ( Group4Spin->isVisible() ) {
1253 Group4Spin->buttonApply->setEnabled(false);
1254 Group4Spin->buttonApply->setFocus();
1258 cmd = myCommand.join( "" ) + GetNewCommand();
1260 if ( Group1Sel->isVisible() ) {
1261 Group1Sel->buttonApply->setEnabled(true);
1262 Group1Sel->buttonApply->setFocus();
1264 if ( Group1Spin->isVisible() ) {
1265 Group1Spin->buttonApply->setEnabled(true);
1266 Group1Spin->buttonApply->setFocus();
1268 if ( Group2Spin->isVisible() ) {
1269 Group2Spin->buttonApply->setEnabled(true);
1270 Group2Spin->buttonApply->setFocus();
1272 if ( Group3Spin->isVisible() ) {
1273 Group3Spin->buttonApply->setEnabled(true);
1274 Group3Spin->buttonApply->setFocus();
1276 if ( Group4Spin->isVisible() ) {
1277 Group4Spin->buttonApply->setEnabled(true);
1278 Group4Spin->buttonApply->setFocus();
1282 gp_Ax3 myWPlane = GeometryGUI::GetGeomGUI()->GetWorkingPlane();
1283 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
1285 WPlane[0] = myWPlane.Location().X();
1286 WPlane[1] = myWPlane.Location().Y();
1287 WPlane[2] = myWPlane.Location().Z();
1289 WPlane[3] = myWPlane.Direction().X();
1290 WPlane[4] = myWPlane.Direction().Y();
1291 WPlane[5] = myWPlane.Direction().Z();
1293 WPlane[6] = myWPlane.XDirection().X();
1294 WPlane[7] = myWPlane.XDirection().Y();
1295 WPlane[8] = myWPlane.XDirection().Z();
1297 GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeSketcher( cmd.latin1(), WPlane );
1299 if ( !anObj->_is_nil() )
1300 objects.push_back( anObj._retn() );
1305 //================================================================
1306 // Function : displayPreview
1307 // Purpose : Method for displaying preview of resulting shape
1308 // Redefined from GEOMBase_Helper.
1309 //================================================================
1310 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
1312 const bool activate,
1314 const double lineWidth )
1316 // Set color for preview shape
1317 getDisplayer()->SetColor( Quantity_NOC_RED );
1319 // set width of displayed shape
1320 getDisplayer()->SetWidth( lineWidth );
1322 // Disable activation of selection
1323 getDisplayer()->SetToActivate( activate );
1325 // Make a reference to GEOM_Object
1326 getDisplayer()->SetName( GeometryGUI::GetORB()->object_to_string( object ) );
1328 // Create wire from applayed object
1329 TopoDS_Shape anApplyedWire, aLastSegment;
1330 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
1334 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
1335 if ( aPrs != 0 && !aPrs->IsNull() )
1336 GEOMBase_Helper::displayPreview( aPrs, append, update );
1338 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
1339 aPrs = getDisplayer()->BuildPrs( aLastSegment );
1340 if ( aPrs != 0 && !aPrs->IsNull() )
1341 GEOMBase_Helper::displayPreview( aPrs, append, update );
1343 getDisplayer()->UnsetName();
1345 // Enable activation of displayed objects
1346 getDisplayer()->SetToActivate( true );
1349 //================================================================
1350 // Function : createShapes
1351 // Purpose : Create applyed wire, and last segment from entry object
1352 //================================================================
1353 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
1354 TopoDS_Shape& theApplyedWire,
1355 TopoDS_Shape& theLastSegment )
1357 TopoDS_Shape aShape;
1358 if ( !GEOMBase::GetShape( theObject, aShape ) ||
1359 aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
1362 if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() ||
1363 Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
1364 Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
1365 Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
1366 Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() )
1368 theApplyedWire = aShape;
1372 BRepBuilderAPI_MakeWire aBuilder;
1373 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
1376 TopoDS_Shape anEdge = anExp.Current();
1378 if ( anExp.More() ) // i.e. non-last edge
1379 aBuilder.Add( TopoDS::Edge( anEdge ) );
1382 theLastSegment = anEdge;
1387 if ( aBuilder.IsDone() )
1388 theApplyedWire = aBuilder.Shape();