1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
27 #include "EntityGUI_SketcherDlg.h"
28 #include "EntityGUI_Widgets.h"
29 #include <SalomeApp_DoubleSpinBox.h>
32 #include <GeometryGUI.h>
33 #include <GEOMImpl_Types.hxx>
34 #include <Geom_Surface.hxx>
35 #include <Geom_Plane.hxx>
37 #include <SUIT_Desktop.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Application.h>
42 #include <LightApp_Application.h>
43 #include <LightApp_SelectionMgr.h>
47 #include <BRep_Tool.hxx>
49 #include <TopExp_Explorer.hxx>
50 #include <TopoDS_Vertex.hxx>
52 #include <BRepBuilderAPI_Transform.hxx>
53 #include <BRepBuilderAPI_MakeWire.hxx>
54 #include <Sketcher_Profile.hxx>
56 #include <SalomeApp_Study.h>
60 #include <Basics_Utils.hxx>
62 //=================================================================================
63 // class : EntityGUI_SketcherDlg()
64 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
65 // name 'name' and widget flags set to 'f'.
66 // The dialog will by default be modeless, unless you set 'modal' to
67 // TRUE to construct a modal dialog.
68 //=================================================================================
69 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
70 bool modal, Qt::WindowFlags fl,
71 const double lineWidth )
72 : QDialog( parent, fl ),
73 myIsAllAdded( false ),
75 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
77 myLineWidth( lineWidth )
80 setAttribute( Qt::WA_DeleteOnClose );
82 myGeometryGUI->SetActiveDialogBox(this);
84 MainWidget = new EntityGUI_Skeleton( this );
85 QVBoxLayout* topLayout = new QVBoxLayout( this );
86 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
88 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
89 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
90 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
91 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
93 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
94 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
95 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
97 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
99 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
100 MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) );
101 MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) );
102 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
103 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
104 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
105 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
107 /***************************************************************/
109 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
110 QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
111 planeLayout->setSpacing(6);
112 planeLayout->setMargin(11);
114 ComboBox1 = new QComboBox(GroupBox1);
115 ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
116 planeLayout->addWidget(ComboBox1);
118 planeButton = new QPushButton (GroupBox1);
119 planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
120 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
121 planeLayout->addWidget(planeButton);
123 topLayout->addWidget(GroupBox1);
124 topLayout->addWidget( MainWidget );
126 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
128 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
129 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
130 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
131 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
133 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
135 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
136 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
137 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
138 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
140 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
142 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
143 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
144 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
145 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
146 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
148 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
150 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
151 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
152 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
153 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
155 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
156 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
157 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
158 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
159 Group1Sel->PushButton1->setIcon( image0 );
160 Group1Sel->buttonUndo->setIcon( image1 );
161 Group1Sel->buttonRedo->setIcon( image2 );
162 Group1Sel->LineEdit1->setReadOnly( true );
164 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
165 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
166 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
167 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
168 Group2Sel->PushButton1->setIcon( image0 );
169 Group2Sel->PushButton2->setIcon( image0 );
170 Group2Sel->buttonUndo->setIcon( image1 );
171 Group2Sel->buttonRedo->setIcon( image2 );
172 Group2Sel->LineEdit1->setReadOnly( true );
173 Group2Sel->LineEdit2->setReadOnly( true );
175 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
176 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
177 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
178 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
179 Group1Sel1Spin->PushButton1->setIcon( image0 );
180 Group1Sel1Spin->buttonUndo->setIcon( image1 );
181 Group1Sel1Spin->buttonRedo->setIcon( image2 );
182 Group1Sel1Spin->LineEdit1->setReadOnly( true );
184 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
185 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
186 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
187 Group1Spin->buttonUndo->setIcon( image1 );
188 Group1Spin->buttonRedo->setIcon( image2 );
190 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
191 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
192 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
193 Group2Spin->buttonUndo->setIcon( image1 );
194 Group2Spin->buttonRedo->setIcon( image2 );
196 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
197 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
198 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
199 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
200 Group3Spin->buttonUndo->setIcon( image1 );
201 Group3Spin->buttonRedo->setIcon( image2 );
203 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
204 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
205 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
206 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
207 Group4Spin->buttonUndo->setIcon( image1 );
208 Group4Spin->buttonRedo->setIcon( image2 );
210 //myErrLabel = new QLabel( MainWidget->DestCnt );
212 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
213 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
214 DestCntLayout->addWidget( GroupPt, 0, 0 );
215 DestCntLayout->addWidget( GroupPt2, 0, 1 );
216 DestCntLayout->addWidget( GroupD1, 0, 0 );
217 DestCntLayout->addWidget( GroupD2, 0, 1 );
219 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
220 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
221 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
222 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
223 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
224 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
225 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
226 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
227 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
228 /***************************************************************/
230 QButtonGroup* ButtonGroup = new QButtonGroup( this );
231 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
232 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
234 /* signals and slots connections */
235 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
236 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
237 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
238 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
240 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
241 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
242 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
243 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
244 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
245 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
246 connect( Group1Sel1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
247 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
248 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
249 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
250 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
251 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
252 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
253 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
254 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
255 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
256 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
257 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
258 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
259 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
260 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
262 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
263 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
264 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
265 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
266 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
267 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
269 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
270 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
272 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
273 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
274 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
275 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
277 connect( Group1Sel1Spin->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
278 connect( Group1Sel1Spin->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
279 connect( Group1Sel1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
281 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
282 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
283 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
284 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
285 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
286 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
287 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
288 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
289 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
290 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
292 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
293 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
294 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
295 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
297 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
298 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
300 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
302 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
303 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
305 // install event filter on spin-boxes to provide Apply action on Return pressed
306 Group1Spin->SpinBox_DX->installEventFilter(this);
307 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
308 Group2Spin->SpinBox_DX->installEventFilter(this);
309 Group2Spin->SpinBox_DY->installEventFilter(this);
310 Group3Spin->SpinBox_DX->installEventFilter(this);
311 Group3Spin->SpinBox_DY->installEventFilter(this);
312 Group3Spin->SpinBox_DZ->installEventFilter(this);
313 Group4Spin->SpinBox_DX->installEventFilter(this);
314 Group4Spin->SpinBox_DY->installEventFilter(this);
315 Group4Spin->SpinBox_DZ->installEventFilter(this);
316 Group4Spin->SpinBox_DS->installEventFilter(this);
322 //=================================================================================
323 // function : ~EntityGUI_SketcherDlg()
324 // purpose : Destroys the object and frees any allocated resources
325 //=================================================================================
326 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
328 myGeometryGUI->SetActiveDialogBox( 0 );
332 //=================================================================================
333 // function : eventFilter()
334 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
335 //=================================================================================
336 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
338 if (event->type() == QEvent::KeyPress) {
339 QKeyEvent* ke = (QKeyEvent*)event;
340 if (ke->key() == Qt::Key_Return) {
341 if (object == Group1Spin->SpinBox_DX) {
342 Group1Spin->buttonApply->animateClick();
344 } else if (object == Group1Sel1Spin->SpinBox_DX) {
345 Group1Sel1Spin->buttonApply->animateClick();
347 } else if (object == Group2Spin->SpinBox_DX ||
348 object == Group2Spin->SpinBox_DY) {
349 Group2Spin->buttonApply->animateClick();
351 } else if (object == Group3Spin->SpinBox_DX ||
352 object == Group3Spin->SpinBox_DY ||
353 object == Group3Spin->SpinBox_DZ) {
354 Group3Spin->buttonApply->animateClick();
356 } else if (object == Group4Spin->SpinBox_DX ||
357 object == Group4Spin->SpinBox_DY ||
358 object == Group4Spin->SpinBox_DZ ||
359 object == Group4Spin->SpinBox_DS) {
360 Group4Spin->buttonApply->animateClick();
366 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
368 return QDialog::eventFilter(object, event);
372 //=================================================================================
375 //=================================================================================
376 void EntityGUI_SketcherDlg::Init()
379 myEditCurrentArgument = Group1Sel->LineEdit1;
380 myCommand.append( "Sketcher" );
381 myUndoCommand.append( "Sketcher" );
383 mySketchState = FIRST_POINT;
384 globalSelection( GEOM_POINT );
393 myHelpFileName = "create_sketcher_page.html";
395 /* Get setting of step value from file configuration */
396 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
398 /* min, max, step and decimals for spin boxes */
399 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
400 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
401 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
402 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
403 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
404 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
405 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
406 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
407 // san: Note specific step values below!
408 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
409 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
410 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
412 /* displays Dialog */
413 MainWidget->GroupConstructors->setEnabled( false );
414 MainWidget->GroupDest1->setEnabled( false );
415 setEnabledUndo( false );
416 setEnabledRedo( false );
418 MainWidget->RadioButton1->setChecked( true );
426 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
430 //=================================================================================
431 // function : InitClick()
433 //=================================================================================
434 void EntityGUI_SketcherDlg::InitClick()
436 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
441 Group1Sel1Spin->hide();
449 //=================================================================================
450 // function : TypeClicked()
451 // purpose : Radio button management
452 //=================================================================================
453 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
455 myConstructorId = constructorId;
456 if ( myConstructorId == 0 ) { // SEGMENT
457 GroupPt2->setEnabled( false );
458 GroupD2->setEnabled( true );
459 MainWidget->RB_Dest1->setEnabled( true );
460 MainWidget->RB_Dest1->setChecked( true );
463 else if ( myConstructorId == 1 ) { // ARC
464 GroupPt2->setEnabled( true );
465 GroupD2->setEnabled( false );
466 MainWidget->RB_Dest1->setEnabled( true );
467 MainWidget->RB_Dest1->setChecked( true );
473 //=================================================================================
474 // function : DestClicked()
475 // purpose : Radio button management
476 //=================================================================================
477 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
484 if ( constructorId == 1 ) {
486 GroupPt->RB_Point1->setChecked( true );
489 Group3Spin->checkBox->show();
490 Group4Spin->checkBox->show();
491 PointClicked( 1 ); // XY
493 else if ( constructorId == 0 ) {
495 GroupD1->RB_Dir11->setChecked( true );
498 Group3Spin->checkBox->hide();
499 Group4Spin->checkBox->hide();
500 Dir1Clicked( 2 ); // Angle
504 //=================================================================================
505 // function : PointClicked()
506 // purpose : Radio button management
507 //=================================================================================
508 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
510 myConstructorPntId = constructorId;
511 GroupPt2->RB_Point1->setChecked( true );
512 GroupPt->RB_Point3->setEnabled( true );
516 //=================================================================================
517 // function : Point2Clicked()
518 // purpose : Radio button management
519 //=================================================================================
520 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
524 // Get setting of step value from file configuration
525 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
527 if ( myConstructorPntId == 1 ) { // XY
528 if ( constructorId == 1 ){ // No additional parameter
529 mySketchType = PT_ABS;
530 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
531 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
532 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
533 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
535 Group2Spin->SpinBox_DX->setValue( myX );
537 Group2Spin->SpinBox_DY->setValue( myY );
539 Group2Spin->buttonApply->setFocus();
541 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
543 else if ( constructorId == 0 ){ // Point + radius
544 mySketchType = PT_ABS_RADIUS;
545 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
546 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
547 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
548 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
549 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
550 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
552 Group3Spin->SpinBox_DX->setValue( myDX );
554 Group3Spin->SpinBox_DY->setValue( myDY );
556 Group3Spin->SpinBox_DZ->setValue( myRadius );
558 Group3Spin->buttonApply->setFocus();
560 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
562 else if ( constructorId == 2 ){ // Point + center
563 mySketchType = PT_ABS_CENTER;
564 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
565 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
566 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
567 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
568 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
569 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
570 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
571 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
573 Group4Spin->SpinBox_DX->setValue( myDX );
575 Group4Spin->SpinBox_DY->setValue( myDY );
577 Group4Spin->SpinBox_DZ->setValue( myXc );
579 Group4Spin->SpinBox_DS->setValue( myYc );
581 Group4Spin->buttonApply->setFocus();
583 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
587 else if ( myConstructorPntId == 0 ) { // DXDY
588 if ( constructorId == 1 ){ // No additional parameter
589 mySketchType = PT_RELATIVE;
590 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
591 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
592 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
593 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
595 Group2Spin->SpinBox_DX->setValue( myDX );
597 Group2Spin->SpinBox_DY->setValue( myDY );
599 Group2Spin->buttonApply->setFocus();
601 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
603 else if ( constructorId == 0 ){ // Point + radius
604 mySketchType = PT_REL_RADIUS;
605 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
606 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
607 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
608 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
609 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
610 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
612 Group3Spin->SpinBox_DX->setValue( myDX );
614 Group3Spin->SpinBox_DY->setValue( myDY );
616 Group3Spin->SpinBox_DZ->setValue( myRadius );
618 Group3Spin->buttonApply->setFocus();
620 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
622 else if ( constructorId == 2 ){ // Point + center
623 mySketchType = PT_REL_CENTER;
624 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
625 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
626 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
627 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
628 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
629 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
630 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
631 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
633 Group4Spin->SpinBox_DX->setValue( myDX );
635 Group4Spin->SpinBox_DY->setValue( myDY );
637 Group4Spin->SpinBox_DZ->setValue( myDXc );
639 Group4Spin->SpinBox_DS->setValue( myDYc );
641 Group4Spin->buttonApply->setFocus();
643 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
647 else if ( myConstructorPntId == 2 ) { // Selection
648 if ( constructorId == 1 ){ // No additional parameter
649 mySketchType = PT_SEL;
650 myEditCurrentArgument = Group1Sel->LineEdit1;
651 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
653 Group1Sel->buttonApply->setFocus();
654 SelectionIntoArgument();
656 else if ( constructorId == 0 ){ // Point + radius
657 mySketchType = PT_SEL_RADIUS;
658 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
659 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
660 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
661 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
663 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
665 Group1Sel1Spin->show();
666 Group1Sel1Spin->buttonApply->setFocus();
667 SelectionIntoArgument();
669 else if ( constructorId == 2 ){ // Point + center
670 mySketchType = PT_SEL_CENTER;
671 myEditCurrentArgument = Group2Sel->LineEdit1;
672 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
673 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
674 Group2Sel->LineEdit1->setEnabled(true);
675 Group2Sel->PushButton1->setDown(true);
676 Group2Sel->LineEdit2->setEnabled(false);
677 Group2Sel->PushButton2->setDown(false);
679 Group2Sel->buttonApply->setFocus();
680 SelectionIntoArgument();
684 connect( myGeometryGUI->getApp()->selectionMgr(),
685 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
690 //=================================================================================
691 // function : Dir1Clicked()
692 // purpose : Radio button management
693 //=================================================================================
694 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
696 myConstructorDirId = constructorId;
697 GroupD2->RB_Dir21->setChecked( true );
702 //=================================================================================
703 // function : Dir2Clicked()
704 // purpose : Radio button management
705 //=================================================================================
706 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
711 // Get setting of step value from file configuration
712 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
714 if ( myConstructorId == 0 ) { // SEGMENT
718 if ( myConstructorDirId == 2 ) { // Angle
719 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
720 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
721 Group2Spin->SpinBox_DX->setValue( myAngle );
722 Group2Spin->buttonApply->setFocus();
725 if ( constructorId == 2 ) { // Length
726 mySketchType = DIR_ANGLE_LENGTH;
727 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
728 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
729 Group2Spin->SpinBox_DY->setValue( myLength );
731 else if ( constructorId == 0 ) { // X
732 mySketchType = DIR_ANGLE_X;
733 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
734 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
735 Group2Spin->SpinBox_DY->setValue( myX );
737 else if ( constructorId == 1 ) { // Y
738 mySketchType = DIR_ANGLE_Y;
739 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
740 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
741 Group2Spin->SpinBox_DY->setValue( myY );
744 else if ( myConstructorDirId == 0 ) { // Perpendicular
746 Group1Spin->buttonApply->setFocus();
748 if ( constructorId == 2 ) { // Length
749 mySketchType = DIR_PER_LENGTH;
750 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
751 Group1Spin->SpinBox_DX->setValue( myLength );
753 else if ( constructorId == 0 ) { // X
754 mySketchType = DIR_PER_X;
755 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
756 Group1Spin->SpinBox_DX->setValue( myX );
758 else if ( constructorId == 1 ) { // Y
759 mySketchType = DIR_PER_Y;
760 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
761 Group1Spin->SpinBox_DX->setValue( myY );
764 else if ( myConstructorDirId == 1 ) { // Tangent
766 Group1Spin->buttonApply->setFocus();
768 if ( constructorId == 2 ) { // Length
769 mySketchType = DIR_TAN_LENGTH;
770 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
771 Group1Spin->SpinBox_DX->setValue( myLength );
773 else if ( constructorId == 0 ) { // X
774 mySketchType = DIR_TAN_X;
775 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
776 Group1Spin->SpinBox_DX->setValue( myX );
778 else if ( constructorId == 1 ) { // Y
779 mySketchType = DIR_TAN_Y;
780 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
781 Group1Spin->SpinBox_DX->setValue( myY );
784 else if ( myConstructorDirId == 3 ) { // DXDY
785 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
786 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
787 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
788 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
789 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
791 Group3Spin->SpinBox_DX->setValue( myDX );
793 Group3Spin->SpinBox_DY->setValue( myDY );
795 Group3Spin->buttonApply->setFocus();
797 if ( constructorId == 2 ) { // Length
798 mySketchType = DIR_DXDY_LENGTH;
799 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
800 Group3Spin->SpinBox_DZ->setValue( myLength );
802 else if ( constructorId == 0 ) { // X
803 mySketchType = DIR_DXDY_X;
804 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
805 Group3Spin->SpinBox_DZ->setValue( myX );
807 else if ( constructorId == 1 ) { // Y
808 mySketchType = DIR_DXDY_Y;
809 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
810 Group3Spin->SpinBox_DZ->setValue( myY );
814 else if ( myConstructorId == 1 ) { // ARC
815 if ( myConstructorDirId == 2 ) { // Angle
816 if ( constructorId == 2 ) { // Length
817 mySketchType = DIR_ANGLE_LENGTH;
818 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
819 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
820 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
821 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
822 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
823 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
824 Group3Spin->SpinBox_DX->setValue( myAngle );
826 Group3Spin->SpinBox_DY->setValue( myRadius );
828 Group3Spin->SpinBox_DZ->setValue( myLength );
830 Group3Spin->buttonApply->setFocus();
833 else if ( myConstructorDirId == 0 ) { // Perpendicular
834 if ( constructorId == 2 ) { // Length
835 mySketchType = DIR_PER_LENGTH;
836 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
837 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
838 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
839 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
841 Group2Spin->SpinBox_DX->setValue( myRadius );
843 Group2Spin->SpinBox_DY->setValue( myLength );
845 Group2Spin->buttonApply->setFocus();
848 else if ( myConstructorDirId == 1 ) { // Tangent
849 if ( constructorId == 2 ) { // Length
850 mySketchType = DIR_TAN_LENGTH;
851 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
852 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
853 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
854 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
856 Group2Spin->SpinBox_DX->setValue( myRadius );
858 Group2Spin->SpinBox_DY->setValue( myLength );
860 Group2Spin->buttonApply->setFocus();
863 else if ( myConstructorDirId == 3 ) { // DXDY
864 if ( constructorId == 2 ) { // Length
865 mySketchType = DIR_DXDY_LENGTH;
866 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
867 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
868 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
869 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
870 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
871 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
872 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
873 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
875 Group4Spin->SpinBox_DX->setValue( myDX );
877 Group4Spin->SpinBox_DY->setValue( myDY );
879 Group4Spin->SpinBox_DZ->setValue( myRadius );
881 Group4Spin->SpinBox_DS->setValue( myLength );
883 Group4Spin->buttonApply->setFocus();
888 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
891 //=================================================================================
892 // function : CheckBoxClicked()
893 // purpose : CheckBox management
894 //=================================================================================
895 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
899 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
903 //=================================================================================
904 // function : ClickOnCancel()
906 //=================================================================================
907 void EntityGUI_SketcherDlg::ClickOnCancel()
913 //=================================================================================
914 // function : ClickOnEnd()
915 // purpose : connected to buttonEnd AND buttonClose
916 //=================================================================================
917 void EntityGUI_SketcherDlg::ClickOnEnd()
919 if ( sender() == MainWidget->buttonClose ) {
920 // Verify validity of commands
921 if ( myCommand.count() <= 2 ) {
922 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
923 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
928 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
929 Sketcher_Profile aProfile( Command.toAscii() );
931 Command = myCommand.join( "" );
932 aProfile = Sketcher_Profile( Command.toAscii() );
933 TopoDS_Shape myShape;
934 if ( aProfile.IsDone() )
935 myShape = aProfile.GetShape();
937 if ( myShape.ShapeType() != TopAbs_VERTEX )
938 myCommand.append( ":WW" );
941 // PAL16008 (Sketcher Validation should be equal to Apply&Close)
942 if ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ||
943 Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ||
944 Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ||
945 Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ||
946 Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ||
947 Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ||
948 Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) {
954 if ( myCommand.size() > 2 )
961 //=================================================================================
962 // function : ClickOnApply()
964 //=================================================================================
965 bool EntityGUI_SketcherDlg::ClickOnApply()
967 if ( sender() && sender()->inherits( "QPushButton" ) )
968 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
971 myCommand.append( GetNewCommand( aParameters ) );
972 mySketchState = NEXT_POINT;
974 myUndoCommand.clear();
975 myUndoCommand.append( "Sketcher" );
977 myParameters.append( aParameters );
978 myUndoParameters.clear();
980 MainWidget->GroupConstructors->setEnabled( true );
981 MainWidget->GroupDest1->setEnabled( true );
982 setEnabledUndo( true );
983 setEnabledRedo( false );
986 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
989 // Set focus to SpinBox_DX
990 if ( sender() == Group1Spin->buttonApply ) {
991 (Group1Spin->SpinBox_DX)->setFocus();
992 (Group1Spin->SpinBox_DX)->selectAll();
994 else if ( sender() == Group1Sel1Spin->buttonApply ) {
995 (Group1Sel1Spin->SpinBox_DX)->setFocus();
996 (Group1Sel1Spin->SpinBox_DX)->selectAll();
998 else if ( sender() == Group2Spin->buttonApply ) {
999 (Group2Spin->SpinBox_DX)->setFocus();
1000 (Group2Spin->SpinBox_DX)->selectAll();
1002 else if ( sender() == Group3Spin->buttonApply ) {
1003 (Group3Spin->SpinBox_DX)->setFocus();
1004 (Group3Spin->SpinBox_DX)->selectAll();
1006 else if ( sender() == Group4Spin->buttonApply ) {
1007 (Group4Spin->SpinBox_DX)->setFocus();
1008 (Group4Spin->SpinBox_DX)->selectAll();
1014 //=================================================================================
1015 // function : ClickOnHelp()
1017 //=================================================================================
1018 void EntityGUI_SketcherDlg::ClickOnHelp()
1020 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1022 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1026 platform = "winapplication";
1028 platform = "application";
1031 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1032 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1033 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1034 QObject::tr( "BUT_OK" ) );
1038 //=================================================================================
1039 // function : ClickOnUndo()
1041 //=================================================================================
1042 void EntityGUI_SketcherDlg::ClickOnUndo()
1044 myUndoCommand.append( myCommand.last() );
1045 myCommand.pop_back();
1047 myUndoParameters.append( myParameters.last() );
1048 myParameters.pop_back();
1050 if ( myCommand.count() == 1 ) {
1051 mySketchState = FIRST_POINT;
1053 MainWidget->RadioButton1->setChecked( true );
1056 connect( myGeometryGUI->getApp()->selectionMgr(),
1057 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1059 MainWidget->GroupConstructors->setEnabled( false );
1060 MainWidget->GroupDest1->setEnabled( false );
1061 setEnabledUndo( false );
1064 setEnabledRedo( true );
1066 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1069 //=================================================================================
1070 // function : ClickOnRedo()
1072 //=================================================================================
1073 void EntityGUI_SketcherDlg::ClickOnRedo()
1075 myCommand.append( myUndoCommand.last() );
1076 myUndoCommand.pop_back();
1078 myParameters.append( myUndoParameters.last() );
1079 myUndoParameters.pop_back();
1081 mySketchState = NEXT_POINT;
1083 MainWidget->GroupConstructors->setEnabled( true );
1084 MainWidget->GroupDest1->setEnabled( true );
1085 setEnabledUndo( true );
1087 if ( myUndoCommand.count() == 1 )
1088 setEnabledRedo( false );
1090 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1093 //=================================================================================
1094 // function : setEnabledUndo()
1096 //=================================================================================
1097 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1099 Group1Sel->buttonUndo->setEnabled( value );
1100 Group2Sel->buttonUndo->setEnabled( value );
1101 Group1Sel1Spin->buttonUndo->setEnabled( value );
1102 Group1Spin->buttonUndo->setEnabled( value );
1103 Group2Spin->buttonUndo->setEnabled( value );
1104 Group3Spin->buttonUndo->setEnabled( value );
1105 Group4Spin->buttonUndo->setEnabled( value );
1108 //=================================================================================
1109 // function : setEnabledRedo()
1111 //=================================================================================
1112 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1114 Group1Sel->buttonRedo->setEnabled( value );
1115 Group2Sel->buttonRedo->setEnabled( value );
1116 Group1Sel1Spin->buttonRedo->setEnabled( value );
1117 Group1Spin->buttonRedo->setEnabled( value );
1118 Group2Spin->buttonRedo->setEnabled( value );
1119 Group3Spin->buttonRedo->setEnabled( value );
1120 Group4Spin->buttonRedo->setEnabled( value );
1123 //=================================================================================
1124 // function : SelectionIntoArgument()
1125 // purpose : Called when selection as changed
1126 //=================================================================================
1127 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1129 myEditCurrentArgument->setText( "" );
1134 // printf ("\nmyX = %f myY = %f", myX, myY);
1135 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
1136 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
1138 if ( sender() == ComboBox1 )
1141 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1142 SALOME_ListIO aSelList;
1143 aSelMgr->selectedObjects(aSelList);
1145 int nbSel = aSelList.Extent();
1146 if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1147 Standard_Boolean aRes = Standard_False;
1148 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
1149 if (!CORBA::is_nil(aSelectedObject) && aRes) {
1150 TopoDS_Shape aShape;
1151 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1153 gp_Ax3 aWPlane = GetActiveLocalCS();
1155 aTrans.SetTransformation(aWPlane);
1156 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1157 aShape = aTransformation.Shape();
1160 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1163 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1164 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1165 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1166 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1167 Group2Spin->SpinBox_DX->setValue(myX);
1168 Group2Spin->SpinBox_DY->setValue(myY);
1169 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1170 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1171 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1172 if ( myLastX1 && myLastY1 ) {
1173 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1174 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1176 if ( mySketchState != FIRST_POINT ) {
1177 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1178 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1180 Group2Spin->SpinBox_DX->setValue(myX);
1181 Group2Spin->SpinBox_DY->setValue(myY);
1190 if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1191 Standard_Boolean aRes = Standard_False;
1192 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
1193 if (!CORBA::is_nil(aSelectedObject) && aRes) {
1194 TopoDS_Shape aShape;
1195 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1197 gp_Ax3 aWPlane = GetActiveLocalCS();
1199 aTrans.SetTransformation(aWPlane);
1200 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1201 aShape = aTransformation.Shape();
1204 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1207 Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1208 if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1209 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1210 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1211 Group3Spin->SpinBox_DX->setValue(myX);
1212 Group3Spin->SpinBox_DY->setValue(myY);
1213 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1214 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1215 } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1216 if ( myLastX1 && myLastY1 ) {
1217 Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1218 Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1220 if ( mySketchState != FIRST_POINT ) {
1221 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1222 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1224 Group3Spin->SpinBox_DX->setValue(myX);
1225 Group3Spin->SpinBox_DY->setValue(myY);
1234 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1235 Standard_Boolean aRes = Standard_False;
1236 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
1237 if (!CORBA::is_nil(aSelectedObject) && aRes) {
1238 TopoDS_Shape aShape;
1239 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1241 gp_Ax3 aWPlane = GetActiveLocalCS();
1243 aTrans.SetTransformation(aWPlane);
1244 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1245 aShape = aTransformation.Shape();
1248 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1251 Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1252 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1253 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1254 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1255 Group4Spin->SpinBox_DX->setValue(myX);
1256 Group4Spin->SpinBox_DY->setValue(myY);
1257 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1258 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1259 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1260 if ( myLastX1 && myLastY1 ) {
1261 Group4Spin->SpinBox_DX->setValue(myX - myLastX1);
1262 Group4Spin->SpinBox_DY->setValue(myY - myLastY1);
1264 if ( mySketchState != FIRST_POINT ) {
1265 Group4Spin->SpinBox_DX->setValue(myX - tmpX);
1266 Group4Spin->SpinBox_DY->setValue(myY - tmpY);
1268 Group4Spin->SpinBox_DX->setValue(myX);
1269 Group4Spin->SpinBox_DY->setValue(myY);
1278 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1279 if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
1280 myX=tmpX; // If yes keep the old values of X and Y
1283 Standard_Boolean aRes = Standard_False;
1284 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
1285 if (!CORBA::is_nil(aSelectedObject) && aRes) {
1286 TopoDS_Shape aShape;
1287 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1289 gp_Ax3 aWPlane = GetActiveLocalCS();
1291 aTrans.SetTransformation(aWPlane);
1292 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1293 aShape = aTransformation.Shape();
1296 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1299 Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1300 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1301 disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1302 disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1303 Group4Spin->SpinBox_DZ->setValue(myXc);
1304 Group4Spin->SpinBox_DS->setValue(myYc);
1305 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1306 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1307 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1308 if ( myLastX1 && myLastY1 ) {
1309 Group4Spin->SpinBox_DZ->setValue(myXc - myLastX1);
1310 Group4Spin->SpinBox_DS->setValue(myYc - myLastY1);
1312 if ( mySketchState != FIRST_POINT ) {
1313 Group4Spin->SpinBox_DZ->setValue(myXc - tmpX);
1314 Group4Spin->SpinBox_DS->setValue(myYc - tmpY);
1316 Group4Spin->SpinBox_DZ->setValue(myXc);
1317 Group4Spin->SpinBox_DS->setValue(myYc);
1328 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1332 //=================================================================================
1333 // function : SetEditCurrentArgument()
1335 //=================================================================================
1336 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1338 if ( sender() == Group1Sel->PushButton1 ) {
1339 myEditCurrentArgument = Group1Sel->LineEdit1;
1340 myEditCurrentArgument->setFocus();
1342 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1343 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1344 myEditCurrentArgument->setFocus();
1346 else if ( sender() == Group2Sel->PushButton1 ) {
1347 myEditCurrentArgument = Group2Sel->LineEdit1;
1348 Group2Sel->PushButton2->setDown(false);
1349 Group2Sel->PushButton1->setDown(true);
1350 Group2Sel->LineEdit2->setEnabled(false);
1351 Group2Sel->LineEdit1->setEnabled(true);
1352 // myEditCurrentArgument->setFocus();
1354 else if ( sender() == Group2Sel->PushButton2 ) {
1355 myEditCurrentArgument = Group2Sel->LineEdit2;
1356 Group2Sel->PushButton1->setDown(false);
1357 Group2Sel->PushButton2->setDown(true);
1358 Group2Sel->LineEdit1->setEnabled(false);
1359 Group2Sel->LineEdit2->setEnabled(true);
1360 // myEditCurrentArgument->setFocus();
1362 SelectionIntoArgument();
1366 //=================================================================================
1367 // function : LineEditReturnPressed()
1369 //=================================================================================
1370 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1372 if ( sender() == Group1Sel->LineEdit1 )
1373 myEditCurrentArgument = Group1Sel->LineEdit1;
1374 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1375 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1376 else if ( sender() == Group2Sel->LineEdit1 )
1377 myEditCurrentArgument = Group2Sel->LineEdit1;
1378 else if ( sender() == Group2Sel->LineEdit2 )
1379 myEditCurrentArgument = Group2Sel->LineEdit2;
1381 /* User name of object input management */
1382 /* If successfull the selection is changed and signal emitted... */
1383 /* so SelectionIntoArgument() is automatically called. */
1384 const QString objectUserName = myEditCurrentArgument->text();
1385 QWidget* thisWidget = (QWidget*)this;
1387 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1388 SALOME_ListIO aSelList;
1389 aSelMgr->selectedObjects(aSelList);
1391 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1392 myEditCurrentArgument->setText( objectUserName );
1396 //=================================================================================
1397 // function : DeactivateActiveDialog()
1399 //=================================================================================
1400 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1402 //myGeometryGUI->SetState( -1 );
1404 setEnabled( false );
1406 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1407 myGeometryGUI->SetActiveDialogBox( 0 );
1411 //=================================================================================
1412 // function : ActivateThisDialog()
1414 //=================================================================================
1415 void EntityGUI_SketcherDlg::ActivateThisDialog()
1417 myGeometryGUI->EmitSignalDeactivateDialog();
1419 myGeometryGUI->SetActiveDialogBox( this );
1421 connect( myGeometryGUI->getApp()->selectionMgr(),
1422 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1424 //myGeometryGUI->SetState( 0 );
1425 globalSelection( GEOM_POINT );
1427 myEditCurrentArgument = Group1Sel->LineEdit1;
1428 myEditCurrentArgument->setFocus();
1430 if ( sender() == Group1Sel->LineEdit1 ) {
1431 myEditCurrentArgument = Group1Sel->LineEdit1;
1432 myEditCurrentArgument->setFocus();
1434 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1435 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1436 myEditCurrentArgument->setFocus();
1438 else if ( sender() == Group2Sel->LineEdit1 ) {
1439 myEditCurrentArgument = Group2Sel->LineEdit1;
1440 myEditCurrentArgument->setFocus();
1442 else if ( sender() == Group2Sel->LineEdit2 ) {
1443 myEditCurrentArgument = Group2Sel->LineEdit2;
1444 myEditCurrentArgument->setFocus();
1447 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1451 //=================================================================================
1452 // function : enterEvent [REDEFINED]
1454 //=================================================================================
1455 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1457 if ( !MainWidget->GroupConstructors->isEnabled() )
1458 ActivateThisDialog();
1462 //=================================================================================
1463 // function : closeEvent()
1465 //=================================================================================
1466 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1468 //myGeometryGUI->SetState( -1 );
1469 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1470 myGeometryGUI->getApp()->updateActions();
1471 QDialog::closeEvent( e );
1475 //=================================================================================
1476 // function : ValueChangedInSpinBox()
1478 //=================================================================================
1479 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1481 QObject* send = (QObject*)sender();
1482 Standard_Real vx, vy, vz, vs, minRad;
1483 vx = vy = vz = vs = minRad =0.0;
1485 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1486 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1487 double LastDecimal = 0.0;
1489 QString vxStr, vyStr, vzStr, vsStr;
1491 QString newValueStr;
1492 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1493 newValueStr = aDoubleSpinBox->text();
1495 if ( send == Group1Spin->SpinBox_DX ) {
1496 vx = newValue; vxStr = newValueStr;
1498 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1499 vx = newValue; vxStr = newValueStr;
1501 else if ( send == Group2Spin->SpinBox_DX ) {
1502 vx = newValue; vxStr = newValueStr;
1503 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1505 else if ( send == Group2Spin->SpinBox_DY ) {
1506 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1507 vy = newValue; vyStr = newValueStr;
1509 else if ( send == Group3Spin->SpinBox_DX ) {
1510 vx = newValue; vxStr = newValueStr;
1511 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1512 vz = Group3Spin->SpinBox_DZ->value();
1513 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1514 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1515 if (aPrecision >= 0) // 'f' format in the QString
1516 LastDecimal = aPrecision;
1517 else // 'g' format in the Qstring
1518 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1519 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1520 if ( Abs(vz) < minRad){
1522 Group3Spin->SpinBox_DZ->setValue( - minRad );
1524 Group3Spin->SpinBox_DZ->setValue( minRad );
1527 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1529 else if ( send == Group3Spin->SpinBox_DY ) {
1530 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1531 vy = newValue; vyStr = newValueStr;
1532 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1533 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1534 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1535 if (aPrecision >= 0) // 'f' format in the QString
1536 LastDecimal = aPrecision;
1537 else // 'g' format in the QString
1538 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1539 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1540 if ( Abs(vz) < minRad){
1542 Group3Spin->SpinBox_DZ->setValue( - minRad );
1544 Group3Spin->SpinBox_DZ->setValue( minRad );
1547 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1549 else if ( send == Group3Spin->SpinBox_DZ ) {
1550 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1551 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1552 vz = newValue; vzStr = newValueStr;
1554 else if ( send == Group4Spin->SpinBox_DX ) {
1555 vx = newValue; vxStr = newValueStr;
1556 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1557 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1558 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1560 else if ( send == Group4Spin->SpinBox_DY ) {
1561 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1562 vy = newValue; vyStr = newValueStr;
1563 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1564 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1566 else if ( send == Group4Spin->SpinBox_DZ ) {
1567 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1568 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1569 vz = newValue; vzStr = newValueStr;
1570 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1572 else if ( send == Group4Spin->SpinBox_DS ) {
1573 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1574 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1575 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1576 vs = newValue; vsStr = newValueStr;
1578 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1580 if ( myConstructorId == 0 ) { // SEGMENT
1581 if ( mySketchType == PT_ABS ) {
1587 else if ( mySketchType == PT_RELATIVE ) {
1593 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1597 myLengthStr = vyStr;
1599 else if ( mySketchType == DIR_ANGLE_X ) {
1605 else if ( mySketchType == DIR_ANGLE_Y ) {
1611 else if ( mySketchType == DIR_PER_LENGTH ) {
1613 myLengthStr = vxStr;
1615 else if ( mySketchType == DIR_PER_X ) {
1619 else if ( mySketchType == DIR_PER_Y ) {
1623 else if ( mySketchType == DIR_TAN_LENGTH ) {
1625 myLengthStr = vxStr;
1627 else if ( mySketchType == DIR_TAN_X ) {
1631 else if ( mySketchType == DIR_TAN_Y ) {
1635 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1641 myLengthStr = vzStr;
1643 else if ( mySketchType == DIR_DXDY_X ) {
1651 else if ( mySketchType == DIR_DXDY_Y ) {
1660 else if ( myConstructorId == 1 ) { // ARC
1661 if ( mySketchType == PT_ABS ) {
1667 else if ( mySketchType == PT_RELATIVE ) {
1673 if ( mySketchType == PT_ABS_RADIUS ) {
1679 myRadiusStr = vzStr;
1681 else if ( mySketchType == PT_REL_RADIUS ) {
1687 myRadiusStr = vzStr;
1689 else if ( mySketchType == PT_SEL_RADIUS ) {
1691 myRadiusStr = vxStr;
1693 if ( mySketchType == PT_ABS_CENTER ) {
1703 else if ( mySketchType == PT_REL_CENTER ) {
1713 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1718 myRadiusStr = vyStr;
1719 myLengthStr = vzStr;
1721 else if ( mySketchType == DIR_PER_LENGTH ) {
1724 myRadiusStr = vxStr;
1725 myLengthStr = vyStr;
1727 else if ( mySketchType == DIR_TAN_LENGTH ) {
1730 myRadiusStr = vxStr;
1731 myLengthStr = vyStr;
1733 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1740 myRadiusStr = vzStr;
1741 myLengthStr = vsStr;
1745 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1749 //=================================================================================
1750 // function : GetNewCommand()
1751 // purpose : Build the new command with context
1752 //=================================================================================
1753 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1755 theParameters.clear();
1756 QString myNewCommand = ":";
1757 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1758 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1759 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1761 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1762 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1764 if ( mySketchState == FIRST_POINT ) {
1765 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1766 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1767 theParameters = myXStr + ":" + myYStr;
1769 if ( mySketchType == PT_RELATIVE) {
1770 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1771 theParameters = myDXStr + ":" + myDYStr;
1773 return myNewCommand;
1776 if ( myConstructorId == 0 ) { // SEGMENT
1777 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1778 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1779 theParameters = myXStr + ":" + myYStr;
1781 if ( mySketchType == PT_RELATIVE) {
1782 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1783 theParameters = myDXStr + ":" + myDYStr;
1785 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1786 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1787 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1788 theParameters = myAngleStr + ":" + myLengthStr;
1790 if ( mySketchType == DIR_ANGLE_X ) {
1791 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1792 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1793 theParameters = myAngleStr + ":" + myXStr;
1795 if ( mySketchType == DIR_ANGLE_Y ) {
1796 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1797 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1798 theParameters = myAngleStr + ":" + myYStr;
1800 if ( mySketchType == DIR_PER_LENGTH ) {
1801 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1802 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1803 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1805 if ( mySketchType == DIR_PER_X ) {
1806 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1807 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1808 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1810 if ( mySketchType == DIR_PER_Y ) {
1811 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1812 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1813 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1815 if ( mySketchType == DIR_TAN_LENGTH ) {
1816 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1817 theParameters = myLengthStr;
1819 if ( mySketchType == DIR_TAN_X ) {
1820 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1821 theParameters = myXStr;
1823 if ( mySketchType == DIR_TAN_Y) {
1824 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1825 theParameters = myYStr;
1827 if ( mySketchType == DIR_DXDY_LENGTH ) {
1828 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1829 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1830 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1832 if ( mySketchType == DIR_DXDY_X ) {
1833 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1834 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1835 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1837 if ( mySketchType == DIR_DXDY_Y ) {
1838 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1839 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1840 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1843 else if ( myConstructorId == 1 ) { // ARC
1844 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1845 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1846 theParameters = myXStr + ":" + myYStr;
1848 if ( mySketchType == PT_RELATIVE) {
1849 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1850 theParameters = myDXStr + ":" + myDYStr;
1852 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1853 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1854 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
1856 if ( mySketchType == PT_REL_RADIUS) {
1857 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1858 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
1860 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
1861 myNewCommand = myNewCommand + "EE " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myXc , Format, DigNum) + " " + QString::number( myYc , Format, DigNum)+ " " + QString::number( myCheckFlag ) + " " + QString::number( 0 );
1862 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
1864 if ( mySketchType == PT_REL_CENTER) {
1865 myNewCommand = myNewCommand + "E " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myDXc, Format, DigNum )+ " " + QString::number( myDYc, Format, DigNum )+ " " + QString::number( myCheckFlag )+ " " + QString::number( 0 );
1866 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
1868 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1869 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1870 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1871 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1873 if ( mySketchType == DIR_PER_LENGTH ) {
1874 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1875 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1876 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
1878 if ( mySketchType == DIR_TAN_LENGTH ) {
1879 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1880 theParameters = myRadiusStr + ":" + myLengthStr;
1882 if ( mySketchType == DIR_DXDY_LENGTH ) {
1883 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1884 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1885 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
1888 return myNewCommand;
1891 //=================================================================================
1892 // function : createOperation
1894 //=================================================================================
1895 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1897 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1900 //=================================================================================
1901 // function : isValid
1903 //=================================================================================
1904 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1907 bool toCorrect = !IsPreview() || myIsApply;
1909 if( Group1Spin->isVisible() ) {
1910 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1912 else if( Group1Sel1Spin->isVisible() ) {
1913 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1915 else if( Group2Spin->isVisible() ) {
1916 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1917 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1919 else if( Group3Spin->isVisible() ) {
1920 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1921 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1922 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1924 else if( Group4Spin->isVisible() ) {
1925 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1926 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1927 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1928 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
1931 if( myIsApply && !ok )
1937 //=================================================================================
1938 // function : execute
1940 //=================================================================================
1941 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1943 QString aParameters;
1945 if ( mySketchState == FIRST_POINT ) {
1950 //Test if the current point is the same as the last one
1951 TopoDS_Shape myShape1, myShape2;
1953 // Set "C" numeric locale
1954 Kernel_Utils::Localizer loc;
1957 QString Command1 = myCommand.join( "" );
1958 Sketcher_Profile aProfile1( Command1.toAscii() );
1959 if ( aProfile1.IsDone() )
1960 myShape1 = aProfile1.GetShape();
1963 QString Command2 = Command1 + GetNewCommand( aParameters );
1964 Sketcher_Profile aProfile2( Command2.toAscii() );
1967 if ( mySketchType == PT_ABS_CENTER ||
1968 mySketchType == PT_REL_CENTER ){
1969 Group4Spin->label->show();
1970 Group4Spin->label->setText(QString(aProfile2.ErrMsg().c_str()));
1973 Group4Spin->label->hide();
1974 if ( mySketchType == PT_SEL_CENTER ){
1975 Group2Sel->label->show();
1976 Group2Sel->label->setText(QString(aProfile2.ErrMsg().c_str()));
1979 Group2Sel->label->hide();
1981 if ( aProfile2.IsDone() )
1982 myShape2 = aProfile2.GetShape();
1984 if ( myShape2.IsNull() ) {
1985 //the current point is the same as the last one
1986 myLastX2 = myLastX1;
1987 myLastY2 = myLastY1;
1990 TopoDS_Vertex V1, V2;
1992 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
1993 //the last shape is the first point
1994 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
1999 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2000 pt = BRep_Tool::Pnt( V2 );
2004 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2005 pt = BRep_Tool::Pnt( V2 );
2012 if ( ( mySketchState != FIRST_POINT &&
2013 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2014 cmd = myCommand.join( "" );
2015 if ( Group1Sel->isVisible() ) {
2016 Group1Sel->buttonApply->setEnabled( false );
2017 //Group1Sel->buttonApply->setFocus();
2019 if ( Group2Sel->isVisible() ) {
2020 Group2Sel->buttonApply->setEnabled( false );
2021 //Group2Sel->buttonApply->setFocus();
2023 if ( Group1Sel1Spin->isVisible() ) {
2024 Group1Sel1Spin->buttonApply->setEnabled( false );
2025 //Group1Sel1Spin->buttonApply->setFocus();
2027 if ( Group1Spin->isVisible() ) {
2028 Group1Spin->buttonApply->setEnabled( false );
2029 //Group1Spin->buttonApply->setFocus();
2031 if ( Group2Spin->isVisible() ) {
2032 Group2Spin->buttonApply->setEnabled( false );
2033 //Group2Spin->buttonApply->setFocus();
2035 if ( Group3Spin->isVisible() ) {
2036 Group3Spin->buttonApply->setEnabled( false );
2037 //Group3Spin->buttonApply->setFocus();
2039 if ( Group4Spin->isVisible() ) {
2040 Group4Spin->buttonApply->setEnabled( false );
2041 //Group4Spin->buttonApply->setFocus();
2045 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2047 if ( Group1Sel->isVisible() ) {
2048 Group1Sel->buttonApply->setEnabled( true );
2049 //Group1Sel->buttonApply->setFocus();
2051 if ( Group2Sel->isVisible() ) {
2052 Group2Sel->buttonApply->setEnabled( true );
2053 //Group2Sel->buttonApply->setFocus();
2055 if ( Group1Sel1Spin->isVisible() ) {
2056 Group1Sel1Spin->buttonApply->setEnabled( true );
2057 //Group1Sel1Spin->buttonApply->setFocus();
2059 if ( Group1Spin->isVisible() ) {
2060 Group1Spin->buttonApply->setEnabled( true );
2061 //Group1Spin->buttonApply->setFocus();
2063 if ( Group2Spin->isVisible() ) {
2064 Group2Spin->buttonApply->setEnabled( true );
2065 //Group2Spin->buttonApply->setFocus();
2067 if ( Group3Spin->isVisible() ) {
2068 Group3Spin->buttonApply->setEnabled( true );
2069 //Group3Spin->buttonApply->setFocus();
2071 if ( Group4Spin->isVisible() ) {
2072 Group4Spin->buttonApply->setEnabled( true );
2073 //Group4Spin->buttonApply->setFocus();
2077 gp_Ax3 myWPlane = GetActiveLocalCS();
2078 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2079 WPlane->length( 9 );
2080 WPlane[0] = myWPlane.Location().X();
2081 WPlane[1] = myWPlane.Location().Y();
2082 WPlane[2] = myWPlane.Location().Z();
2084 WPlane[3] = myWPlane.Direction().X();
2085 WPlane[4] = myWPlane.Direction().Y();
2086 WPlane[5] = myWPlane.Direction().Z();
2088 WPlane[6] = myWPlane.XDirection().X();
2089 WPlane[7] = myWPlane.XDirection().Y();
2090 WPlane[8] = myWPlane.XDirection().Z();
2092 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2093 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2095 if ( !anObj->_is_nil() )
2097 if( !IsPreview() ) {
2098 QStringList aCurrentParameters = myParameters;
2099 aCurrentParameters << aParameters;
2100 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2103 objects.push_back( anObj._retn() );
2109 //================================================================
2110 // Function : displayPreview
2111 // Purpose : Method for displaying preview of resulting shape
2112 // Redefined from GEOMBase_Helper.
2113 //================================================================
2114 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2116 const bool activate,
2118 const double lineWidth,
2119 const int displayMode,
2122 // Set color for preview shape
2123 getDisplayer()->SetColor( Quantity_NOC_RED );
2125 // set width of displayed shape
2126 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2128 // Disable activation of selection
2129 getDisplayer()->SetToActivate( activate );
2131 // Make a reference to GEOM_Object
2132 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2133 getDisplayer()->SetName( objStr.in() );
2135 // Create wire from applayed object
2136 TopoDS_Shape anApplyedWire, aLastSegment;
2137 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2141 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2142 if ( aPrs != 0 && !aPrs->IsNull() )
2143 GEOMBase_Helper::displayPreview( aPrs, append, update );
2145 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2146 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2147 if ( aPrs != 0 && !aPrs->IsNull() )
2148 GEOMBase_Helper::displayPreview( aPrs, append, update );
2150 getDisplayer()->UnsetName();
2152 // Enable activation of displayed objects
2153 getDisplayer()->SetToActivate( true );
2156 //================================================================
2157 // Function : createShapes
2158 // Purpose : Create applyed wire, and last segment from entry object
2159 //================================================================
2160 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2161 TopoDS_Shape& theApplyedWire,
2162 TopoDS_Shape& theLastSegment )
2164 TopoDS_Shape aShape;
2165 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2166 aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
2169 if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() ||
2170 Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ||
2171 Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ||
2172 Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
2173 Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
2174 Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
2175 Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) {
2176 theApplyedWire = aShape;
2180 BRepBuilderAPI_MakeWire aBuilder;
2181 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2183 TopoDS_Shape anEdge = anExp.Current();
2185 if ( anExp.More() ) // i.e. non-last edge
2186 aBuilder.Add( TopoDS::Edge( anEdge ) );
2188 theLastSegment = anEdge;
2193 if ( aBuilder.IsDone() )
2194 theApplyedWire = aBuilder.Shape();
2199 //=================================================================================
2200 // function : keyPressEvent()
2202 //=================================================================================
2203 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2205 QDialog::keyPressEvent( e );
2206 if ( e->isAccepted() )
2209 if ( e->key() == Qt::Key_F1 ) {
2215 //=================================================================================
2216 // function : initSpinBox()
2218 //=================================================================================
2219 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2220 double min, double max,
2221 double step, const char* quantity )
2223 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2224 // TODO: Think how to keep the single piece of code...
2226 // Obtain precision from preferences
2227 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2228 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2230 spinBox->setPrecision( aPrecision );
2231 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2232 // by default Qt rounds boundaries to 2 decimals at setRange
2233 spinBox->setRange( min, max );
2234 spinBox->setSingleStep( step );
2236 // Add a hint for the user saying how to tune precision
2237 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2238 spinBox->setProperty( "validity_tune_hint",
2239 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2242 //=================================================================================
2243 // function : SetDoubleSpinBoxStep()
2244 // purpose : Double spin box management
2245 //=================================================================================
2246 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2248 Group1Spin->SpinBox_DX->setSingleStep(step);
2249 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2250 Group2Spin->SpinBox_DX->setSingleStep(step);
2251 Group2Spin->SpinBox_DY->setSingleStep(step);
2252 Group3Spin->SpinBox_DX->setSingleStep(step);
2253 Group3Spin->SpinBox_DY->setSingleStep(step);
2254 Group3Spin->SpinBox_DZ->setSingleStep(step);
2255 Group4Spin->SpinBox_DZ->setSingleStep(step);
2257 // san: Do NOT override the step when a speicifc step value is used
2258 // in some input fields!
2259 //Group4Spin->SpinBox_DX->setSingleStep(step);
2260 //Group4Spin->SpinBox_DY->setSingleStep(step);
2261 //Group4Spin->SpinBox_DS->setSingleStep(step);
2264 //=================================================================================
2265 // function : FindLocalCS()
2266 // purpose : Find All Coordinates systems in study
2267 //=================================================================================
2268 void EntityGUI_SketcherDlg::FindLocalCS()
2272 SalomeApp_Application* app =
2273 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2277 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2281 _PTR(Study) aStudy = appStudy->studyDS();
2284 ComboBox1->addItem(tr("GEOM_GCS"));
2285 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2286 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2287 gp_Dir aDirX = gp_Dir(1, 0, 0);
2288 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2289 myLCSList.push_back(globalCS);
2291 // get GEOM component
2292 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2293 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2296 _PTR(SComponent) fc = obj->GetFatherComponent();
2297 QString geomComp = fc->GetID().c_str();
2298 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2302 // browse through all GEOM data tree
2303 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2304 for ( it->InitEx( true ); it->More(); it->Next() ) {
2305 _PTR(SObject) child( it->Value() );
2306 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2307 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2308 if( CORBA::is_nil( geomObj ) )
2310 if (geomObj->GetType() == GEOM_MARKER) {
2311 ComboBox1->addItem(geomObj->GetName());
2312 TopoDS_Shape aShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2315 aLCS.Transform(aShape.Location().Transformation());
2316 if (aShape.ShapeType() == TopAbs_FACE) {
2317 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2318 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2319 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2320 gp_Pln aPln = aGPlane->Pln();
2321 aLCS = aPln.Position();
2324 myLCSList.push_back(aLCS);
2329 //=================================================================================
2330 // function : GetActiveLocalCS()
2331 // purpose : Get Working plane
2332 //=================================================================================
2333 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2335 int ind = ComboBox1->currentIndex();
2337 return myGeometryGUI->GetWorkingPlane();
2339 gp_Ax3 aLCS = myLCSList.at(ind);
2344 //=================================================================================
2345 // function : ActivateLocalCS()
2346 // purpose : Activate & Fit Working plane
2347 //=================================================================================
2348 void EntityGUI_SketcherDlg::ActivateLocalCS()
2350 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2351 myGeometryGUI->ActiveWorkingPlane();