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 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1148 if ( !CORBA::is_nil(aSelectedObject) ) {
1149 TopoDS_Shape aShape;
1150 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1152 gp_Ax3 aWPlane = GetActiveLocalCS();
1154 aTrans.SetTransformation(aWPlane);
1155 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1156 aShape = aTransformation.Shape();
1159 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1162 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1163 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1164 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1165 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1166 Group2Spin->SpinBox_DX->setValue(myX);
1167 Group2Spin->SpinBox_DY->setValue(myY);
1168 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1169 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1170 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1171 if ( myLastX1 && myLastY1 ) {
1172 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1173 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1175 if ( mySketchState != FIRST_POINT ) {
1176 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1177 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1179 Group2Spin->SpinBox_DX->setValue(myX);
1180 Group2Spin->SpinBox_DY->setValue(myY);
1189 if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1190 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1191 if ( !CORBA::is_nil(aSelectedObject) ) {
1192 TopoDS_Shape aShape;
1193 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1195 gp_Ax3 aWPlane = GetActiveLocalCS();
1197 aTrans.SetTransformation(aWPlane);
1198 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1199 aShape = aTransformation.Shape();
1202 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1205 Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1206 if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1207 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1208 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1209 Group3Spin->SpinBox_DX->setValue(myX);
1210 Group3Spin->SpinBox_DY->setValue(myY);
1211 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1212 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1213 } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1214 if ( myLastX1 && myLastY1 ) {
1215 Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1216 Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1218 if ( mySketchState != FIRST_POINT ) {
1219 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1220 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1222 Group3Spin->SpinBox_DX->setValue(myX);
1223 Group3Spin->SpinBox_DY->setValue(myY);
1232 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1233 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1234 if ( !CORBA::is_nil(aSelectedObject) ) {
1235 TopoDS_Shape aShape;
1236 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1238 gp_Ax3 aWPlane = GetActiveLocalCS();
1240 aTrans.SetTransformation(aWPlane);
1241 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1242 aShape = aTransformation.Shape();
1245 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1248 Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1249 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1250 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1251 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1252 Group4Spin->SpinBox_DX->setValue(myX);
1253 Group4Spin->SpinBox_DY->setValue(myY);
1254 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1255 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1256 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1257 if ( myLastX1 && myLastY1 ) {
1258 Group4Spin->SpinBox_DX->setValue(myX - myLastX1);
1259 Group4Spin->SpinBox_DY->setValue(myY - myLastY1);
1261 if ( mySketchState != FIRST_POINT ) {
1262 Group4Spin->SpinBox_DX->setValue(myX - tmpX);
1263 Group4Spin->SpinBox_DY->setValue(myY - tmpY);
1265 Group4Spin->SpinBox_DX->setValue(myX);
1266 Group4Spin->SpinBox_DY->setValue(myY);
1275 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1276 if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
1277 myX=tmpX; // If yes keep the old values of X and Y
1280 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1281 if ( !CORBA::is_nil(aSelectedObject) ) {
1282 TopoDS_Shape aShape;
1283 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1285 gp_Ax3 aWPlane = GetActiveLocalCS();
1287 aTrans.SetTransformation(aWPlane);
1288 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1289 aShape = aTransformation.Shape();
1292 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1295 Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1296 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1297 disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1298 disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1299 Group4Spin->SpinBox_DZ->setValue(myXc);
1300 Group4Spin->SpinBox_DS->setValue(myYc);
1301 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1302 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1303 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1304 if ( myLastX1 && myLastY1 ) {
1305 Group4Spin->SpinBox_DZ->setValue(myXc - myLastX1);
1306 Group4Spin->SpinBox_DS->setValue(myYc - myLastY1);
1308 if ( mySketchState != FIRST_POINT ) {
1309 Group4Spin->SpinBox_DZ->setValue(myXc - tmpX);
1310 Group4Spin->SpinBox_DS->setValue(myYc - tmpY);
1312 Group4Spin->SpinBox_DZ->setValue(myXc);
1313 Group4Spin->SpinBox_DS->setValue(myYc);
1324 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1328 //=================================================================================
1329 // function : SetEditCurrentArgument()
1331 //=================================================================================
1332 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1334 if ( sender() == Group1Sel->PushButton1 ) {
1335 myEditCurrentArgument = Group1Sel->LineEdit1;
1336 myEditCurrentArgument->setFocus();
1338 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1339 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1340 myEditCurrentArgument->setFocus();
1342 else if ( sender() == Group2Sel->PushButton1 ) {
1343 myEditCurrentArgument = Group2Sel->LineEdit1;
1344 Group2Sel->PushButton2->setDown(false);
1345 Group2Sel->PushButton1->setDown(true);
1346 Group2Sel->LineEdit2->setEnabled(false);
1347 Group2Sel->LineEdit1->setEnabled(true);
1348 // myEditCurrentArgument->setFocus();
1350 else if ( sender() == Group2Sel->PushButton2 ) {
1351 myEditCurrentArgument = Group2Sel->LineEdit2;
1352 Group2Sel->PushButton1->setDown(false);
1353 Group2Sel->PushButton2->setDown(true);
1354 Group2Sel->LineEdit1->setEnabled(false);
1355 Group2Sel->LineEdit2->setEnabled(true);
1356 // myEditCurrentArgument->setFocus();
1358 SelectionIntoArgument();
1362 //=================================================================================
1363 // function : LineEditReturnPressed()
1365 //=================================================================================
1366 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1368 if ( sender() == Group1Sel->LineEdit1 )
1369 myEditCurrentArgument = Group1Sel->LineEdit1;
1370 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1371 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1372 else if ( sender() == Group2Sel->LineEdit1 )
1373 myEditCurrentArgument = Group2Sel->LineEdit1;
1374 else if ( sender() == Group2Sel->LineEdit2 )
1375 myEditCurrentArgument = Group2Sel->LineEdit2;
1377 /* User name of object input management */
1378 /* If successfull the selection is changed and signal emitted... */
1379 /* so SelectionIntoArgument() is automatically called. */
1380 const QString objectUserName = myEditCurrentArgument->text();
1381 QWidget* thisWidget = (QWidget*)this;
1383 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1384 SALOME_ListIO aSelList;
1385 aSelMgr->selectedObjects(aSelList);
1387 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1388 myEditCurrentArgument->setText( objectUserName );
1392 //=================================================================================
1393 // function : DeactivateActiveDialog()
1395 //=================================================================================
1396 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1398 //myGeometryGUI->SetState( -1 );
1400 setEnabled( false );
1402 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1403 myGeometryGUI->SetActiveDialogBox( 0 );
1407 //=================================================================================
1408 // function : ActivateThisDialog()
1410 //=================================================================================
1411 void EntityGUI_SketcherDlg::ActivateThisDialog()
1413 myGeometryGUI->EmitSignalDeactivateDialog();
1415 myGeometryGUI->SetActiveDialogBox( this );
1417 connect( myGeometryGUI->getApp()->selectionMgr(),
1418 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1420 //myGeometryGUI->SetState( 0 );
1421 globalSelection( GEOM_POINT );
1423 myEditCurrentArgument = Group1Sel->LineEdit1;
1424 myEditCurrentArgument->setFocus();
1426 if ( sender() == Group1Sel->LineEdit1 ) {
1427 myEditCurrentArgument = Group1Sel->LineEdit1;
1428 myEditCurrentArgument->setFocus();
1430 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1431 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1432 myEditCurrentArgument->setFocus();
1434 else if ( sender() == Group2Sel->LineEdit1 ) {
1435 myEditCurrentArgument = Group2Sel->LineEdit1;
1436 myEditCurrentArgument->setFocus();
1438 else if ( sender() == Group2Sel->LineEdit2 ) {
1439 myEditCurrentArgument = Group2Sel->LineEdit2;
1440 myEditCurrentArgument->setFocus();
1443 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1447 //=================================================================================
1448 // function : enterEvent [REDEFINED]
1450 //=================================================================================
1451 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1454 ActivateThisDialog();
1458 //=================================================================================
1459 // function : closeEvent()
1461 //=================================================================================
1462 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1464 //myGeometryGUI->SetState( -1 );
1465 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1466 myGeometryGUI->getApp()->updateActions();
1467 QDialog::closeEvent( e );
1471 //=================================================================================
1472 // function : ValueChangedInSpinBox()
1474 //=================================================================================
1475 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1477 QObject* send = (QObject*)sender();
1478 Standard_Real vx, vy, vz, vs, minRad;
1479 vx = vy = vz = vs = minRad =0.0;
1481 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1482 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1483 double LastDecimal = 0.0;
1485 QString vxStr, vyStr, vzStr, vsStr;
1487 QString newValueStr;
1488 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1489 newValueStr = aDoubleSpinBox->text();
1491 if ( send == Group1Spin->SpinBox_DX ) {
1492 vx = newValue; vxStr = newValueStr;
1494 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1495 vx = newValue; vxStr = newValueStr;
1497 else if ( send == Group2Spin->SpinBox_DX ) {
1498 vx = newValue; vxStr = newValueStr;
1499 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1501 else if ( send == Group2Spin->SpinBox_DY ) {
1502 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1503 vy = newValue; vyStr = newValueStr;
1505 else if ( send == Group3Spin->SpinBox_DX ) {
1506 vx = newValue; vxStr = newValueStr;
1507 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1508 vz = Group3Spin->SpinBox_DZ->value();
1509 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1510 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1511 if (aPrecision >= 0) // 'f' format in the QString
1512 LastDecimal = aPrecision;
1513 else // 'g' format in the Qstring
1514 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1515 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1516 if ( Abs(vz) < minRad){
1518 Group3Spin->SpinBox_DZ->setValue( - minRad );
1520 Group3Spin->SpinBox_DZ->setValue( minRad );
1523 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1525 else if ( send == Group3Spin->SpinBox_DY ) {
1526 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1527 vy = newValue; vyStr = newValueStr;
1528 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1529 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1530 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1531 if (aPrecision >= 0) // 'f' format in the QString
1532 LastDecimal = aPrecision;
1533 else // 'g' format in the QString
1534 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1535 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1536 if ( Abs(vz) < minRad){
1538 Group3Spin->SpinBox_DZ->setValue( - minRad );
1540 Group3Spin->SpinBox_DZ->setValue( minRad );
1543 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1545 else if ( send == Group3Spin->SpinBox_DZ ) {
1546 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1547 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1548 vz = newValue; vzStr = newValueStr;
1550 else if ( send == Group4Spin->SpinBox_DX ) {
1551 vx = newValue; vxStr = newValueStr;
1552 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1553 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1554 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1556 else if ( send == Group4Spin->SpinBox_DY ) {
1557 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1558 vy = newValue; vyStr = newValueStr;
1559 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1560 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1562 else if ( send == Group4Spin->SpinBox_DZ ) {
1563 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1564 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1565 vz = newValue; vzStr = newValueStr;
1566 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1568 else if ( send == Group4Spin->SpinBox_DS ) {
1569 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1570 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1571 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1572 vs = newValue; vsStr = newValueStr;
1574 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1576 if ( myConstructorId == 0 ) { // SEGMENT
1577 if ( mySketchType == PT_ABS ) {
1583 else if ( mySketchType == PT_RELATIVE ) {
1589 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1593 myLengthStr = vyStr;
1595 else if ( mySketchType == DIR_ANGLE_X ) {
1601 else if ( mySketchType == DIR_ANGLE_Y ) {
1607 else if ( mySketchType == DIR_PER_LENGTH ) {
1609 myLengthStr = vxStr;
1611 else if ( mySketchType == DIR_PER_X ) {
1615 else if ( mySketchType == DIR_PER_Y ) {
1619 else if ( mySketchType == DIR_TAN_LENGTH ) {
1621 myLengthStr = vxStr;
1623 else if ( mySketchType == DIR_TAN_X ) {
1627 else if ( mySketchType == DIR_TAN_Y ) {
1631 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1637 myLengthStr = vzStr;
1639 else if ( mySketchType == DIR_DXDY_X ) {
1647 else if ( mySketchType == DIR_DXDY_Y ) {
1656 else if ( myConstructorId == 1 ) { // ARC
1657 if ( mySketchType == PT_ABS ) {
1663 else if ( mySketchType == PT_RELATIVE ) {
1669 if ( mySketchType == PT_ABS_RADIUS ) {
1675 myRadiusStr = vzStr;
1677 else if ( mySketchType == PT_REL_RADIUS ) {
1683 myRadiusStr = vzStr;
1685 else if ( mySketchType == PT_SEL_RADIUS ) {
1687 myRadiusStr = vxStr;
1689 if ( mySketchType == PT_ABS_CENTER ) {
1699 else if ( mySketchType == PT_REL_CENTER ) {
1709 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1714 myRadiusStr = vyStr;
1715 myLengthStr = vzStr;
1717 else if ( mySketchType == DIR_PER_LENGTH ) {
1720 myRadiusStr = vxStr;
1721 myLengthStr = vyStr;
1723 else if ( mySketchType == DIR_TAN_LENGTH ) {
1726 myRadiusStr = vxStr;
1727 myLengthStr = vyStr;
1729 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1736 myRadiusStr = vzStr;
1737 myLengthStr = vsStr;
1741 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1745 //=================================================================================
1746 // function : GetNewCommand()
1747 // purpose : Build the new command with context
1748 //=================================================================================
1749 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1751 theParameters.clear();
1752 QString myNewCommand = ":";
1753 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1754 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1755 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1757 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1758 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1760 if ( mySketchState == FIRST_POINT ) {
1761 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1762 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1763 theParameters = myXStr + ":" + myYStr;
1765 if ( mySketchType == PT_RELATIVE) {
1766 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1767 theParameters = myDXStr + ":" + myDYStr;
1769 return myNewCommand;
1772 if ( myConstructorId == 0 ) { // SEGMENT
1773 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1774 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1775 theParameters = myXStr + ":" + myYStr;
1777 if ( mySketchType == PT_RELATIVE) {
1778 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1779 theParameters = myDXStr + ":" + myDYStr;
1781 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1782 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1783 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1784 theParameters = myAngleStr + ":" + myLengthStr;
1786 if ( mySketchType == DIR_ANGLE_X ) {
1787 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1788 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1789 theParameters = myAngleStr + ":" + myXStr;
1791 if ( mySketchType == DIR_ANGLE_Y ) {
1792 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1793 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1794 theParameters = myAngleStr + ":" + myYStr;
1796 if ( mySketchType == DIR_PER_LENGTH ) {
1797 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1798 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1799 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1801 if ( mySketchType == DIR_PER_X ) {
1802 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1803 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1804 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1806 if ( mySketchType == DIR_PER_Y ) {
1807 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1808 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1809 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1811 if ( mySketchType == DIR_TAN_LENGTH ) {
1812 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1813 theParameters = myLengthStr;
1815 if ( mySketchType == DIR_TAN_X ) {
1816 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1817 theParameters = myXStr;
1819 if ( mySketchType == DIR_TAN_Y) {
1820 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1821 theParameters = myYStr;
1823 if ( mySketchType == DIR_DXDY_LENGTH ) {
1824 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1825 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1826 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1828 if ( mySketchType == DIR_DXDY_X ) {
1829 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1830 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1831 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1833 if ( mySketchType == DIR_DXDY_Y ) {
1834 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1835 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1836 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1839 else if ( myConstructorId == 1 ) { // ARC
1840 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1841 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1842 theParameters = myXStr + ":" + myYStr;
1844 if ( mySketchType == PT_RELATIVE) {
1845 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1846 theParameters = myDXStr + ":" + myDYStr;
1848 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1849 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1850 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
1852 if ( mySketchType == PT_REL_RADIUS) {
1853 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1854 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
1856 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
1857 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 );
1858 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
1860 if ( mySketchType == PT_REL_CENTER) {
1861 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 );
1862 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
1864 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1865 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1866 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1867 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1869 if ( mySketchType == DIR_PER_LENGTH ) {
1870 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1871 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1872 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
1874 if ( mySketchType == DIR_TAN_LENGTH ) {
1875 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1876 theParameters = myRadiusStr + ":" + myLengthStr;
1878 if ( mySketchType == DIR_DXDY_LENGTH ) {
1879 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1880 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1881 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
1884 return myNewCommand;
1887 //=================================================================================
1888 // function : createOperation
1890 //=================================================================================
1891 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1893 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1896 //=================================================================================
1897 // function : isValid
1899 //=================================================================================
1900 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1903 bool toCorrect = !IsPreview() || myIsApply;
1905 if( Group1Spin->isVisible() ) {
1906 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1908 else if( Group1Sel1Spin->isVisible() ) {
1909 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1911 else if( Group2Spin->isVisible() ) {
1912 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1913 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1915 else if( Group3Spin->isVisible() ) {
1916 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1917 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1918 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1920 else if( Group4Spin->isVisible() ) {
1921 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1922 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1923 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1924 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
1927 if( myIsApply && !ok )
1933 //=================================================================================
1934 // function : execute
1936 //=================================================================================
1937 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1939 QString aParameters;
1941 if ( mySketchState == FIRST_POINT ) {
1946 //Test if the current point is the same as the last one
1947 TopoDS_Shape myShape1, myShape2;
1949 // Set "C" numeric locale
1950 Kernel_Utils::Localizer loc;
1953 QString Command1 = myCommand.join( "" );
1954 Sketcher_Profile aProfile1( Command1.toAscii() );
1955 if ( aProfile1.IsDone() )
1956 myShape1 = aProfile1.GetShape();
1959 QString Command2 = Command1 + GetNewCommand( aParameters );
1960 Sketcher_Profile aProfile2( Command2.toAscii() );
1963 if ( mySketchType == PT_ABS_CENTER ||
1964 mySketchType == PT_REL_CENTER ){
1965 Group4Spin->label->show();
1966 Group4Spin->label->setText(QString(aProfile2.ErrMsg().c_str()));
1969 Group4Spin->label->hide();
1970 if ( mySketchType == PT_SEL_CENTER ){
1971 Group2Sel->label->show();
1972 Group2Sel->label->setText(QString(aProfile2.ErrMsg().c_str()));
1975 Group2Sel->label->hide();
1977 if ( aProfile2.IsDone() )
1978 myShape2 = aProfile2.GetShape();
1980 if ( myShape2.IsNull() ) {
1981 //the current point is the same as the last one
1982 myLastX2 = myLastX1;
1983 myLastY2 = myLastY1;
1986 TopoDS_Vertex V1, V2;
1988 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
1989 //the last shape is the first point
1990 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
1995 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
1996 pt = BRep_Tool::Pnt( V2 );
2000 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2001 pt = BRep_Tool::Pnt( V2 );
2008 if ( ( mySketchState != FIRST_POINT &&
2009 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2010 cmd = myCommand.join( "" );
2011 if ( Group1Sel->isVisible() ) {
2012 Group1Sel->buttonApply->setEnabled( false );
2013 //Group1Sel->buttonApply->setFocus();
2015 if ( Group2Sel->isVisible() ) {
2016 Group2Sel->buttonApply->setEnabled( false );
2017 //Group2Sel->buttonApply->setFocus();
2019 if ( Group1Sel1Spin->isVisible() ) {
2020 Group1Sel1Spin->buttonApply->setEnabled( false );
2021 //Group1Sel1Spin->buttonApply->setFocus();
2023 if ( Group1Spin->isVisible() ) {
2024 Group1Spin->buttonApply->setEnabled( false );
2025 //Group1Spin->buttonApply->setFocus();
2027 if ( Group2Spin->isVisible() ) {
2028 Group2Spin->buttonApply->setEnabled( false );
2029 //Group2Spin->buttonApply->setFocus();
2031 if ( Group3Spin->isVisible() ) {
2032 Group3Spin->buttonApply->setEnabled( false );
2033 //Group3Spin->buttonApply->setFocus();
2035 if ( Group4Spin->isVisible() ) {
2036 Group4Spin->buttonApply->setEnabled( false );
2037 //Group4Spin->buttonApply->setFocus();
2041 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2043 if ( Group1Sel->isVisible() ) {
2044 Group1Sel->buttonApply->setEnabled( true );
2045 //Group1Sel->buttonApply->setFocus();
2047 if ( Group2Sel->isVisible() ) {
2048 Group2Sel->buttonApply->setEnabled( true );
2049 //Group2Sel->buttonApply->setFocus();
2051 if ( Group1Sel1Spin->isVisible() ) {
2052 Group1Sel1Spin->buttonApply->setEnabled( true );
2053 //Group1Sel1Spin->buttonApply->setFocus();
2055 if ( Group1Spin->isVisible() ) {
2056 Group1Spin->buttonApply->setEnabled( true );
2057 //Group1Spin->buttonApply->setFocus();
2059 if ( Group2Spin->isVisible() ) {
2060 Group2Spin->buttonApply->setEnabled( true );
2061 //Group2Spin->buttonApply->setFocus();
2063 if ( Group3Spin->isVisible() ) {
2064 Group3Spin->buttonApply->setEnabled( true );
2065 //Group3Spin->buttonApply->setFocus();
2067 if ( Group4Spin->isVisible() ) {
2068 Group4Spin->buttonApply->setEnabled( true );
2069 //Group4Spin->buttonApply->setFocus();
2073 gp_Ax3 myWPlane = GetActiveLocalCS();
2074 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2075 WPlane->length( 9 );
2076 WPlane[0] = myWPlane.Location().X();
2077 WPlane[1] = myWPlane.Location().Y();
2078 WPlane[2] = myWPlane.Location().Z();
2080 WPlane[3] = myWPlane.Direction().X();
2081 WPlane[4] = myWPlane.Direction().Y();
2082 WPlane[5] = myWPlane.Direction().Z();
2084 WPlane[6] = myWPlane.XDirection().X();
2085 WPlane[7] = myWPlane.XDirection().Y();
2086 WPlane[8] = myWPlane.XDirection().Z();
2088 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2089 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2091 if ( !anObj->_is_nil() )
2093 if( !IsPreview() ) {
2094 QStringList aCurrentParameters = myParameters;
2095 aCurrentParameters << aParameters;
2096 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2099 objects.push_back( anObj._retn() );
2105 //================================================================
2106 // Function : displayPreview
2107 // Purpose : Method for displaying preview of resulting shape
2108 // Redefined from GEOMBase_Helper.
2109 //================================================================
2110 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2112 const bool activate,
2114 const double lineWidth,
2115 const int displayMode,
2118 // Set color for preview shape
2119 getDisplayer()->SetColor( Quantity_NOC_RED );
2121 // set width of displayed shape
2122 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2124 // Disable activation of selection
2125 getDisplayer()->SetToActivate( activate );
2127 // Make a reference to GEOM_Object
2128 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2129 getDisplayer()->SetName( objStr.in() );
2131 // Create wire from applayed object
2132 TopoDS_Shape anApplyedWire, aLastSegment;
2133 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2137 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2138 if ( aPrs != 0 && !aPrs->IsNull() )
2139 GEOMBase_Helper::displayPreview( aPrs, append, update );
2141 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2142 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2143 if ( aPrs != 0 && !aPrs->IsNull() )
2144 GEOMBase_Helper::displayPreview( aPrs, append, update );
2146 getDisplayer()->UnsetName();
2148 // Enable activation of displayed objects
2149 getDisplayer()->SetToActivate( true );
2152 //================================================================
2153 // Function : createShapes
2154 // Purpose : Create applyed wire, and last segment from entry object
2155 //================================================================
2156 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2157 TopoDS_Shape& theApplyedWire,
2158 TopoDS_Shape& theLastSegment )
2160 TopoDS_Shape aShape;
2161 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2162 aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
2165 if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() ||
2166 Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ||
2167 Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ||
2168 Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
2169 Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
2170 Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
2171 Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) {
2172 theApplyedWire = aShape;
2176 BRepBuilderAPI_MakeWire aBuilder;
2177 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2179 TopoDS_Shape anEdge = anExp.Current();
2181 if ( anExp.More() ) // i.e. non-last edge
2182 aBuilder.Add( TopoDS::Edge( anEdge ) );
2184 theLastSegment = anEdge;
2189 if ( aBuilder.IsDone() )
2190 theApplyedWire = aBuilder.Shape();
2195 //=================================================================================
2196 // function : keyPressEvent()
2198 //=================================================================================
2199 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2201 QDialog::keyPressEvent( e );
2202 if ( e->isAccepted() )
2205 if ( e->key() == Qt::Key_F1 ) {
2211 //=================================================================================
2212 // function : initSpinBox()
2214 //=================================================================================
2215 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2216 double min, double max,
2217 double step, const char* quantity )
2219 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2220 // TODO: Think how to keep the single piece of code...
2222 // Obtain precision from preferences
2223 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2224 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2226 spinBox->setPrecision( aPrecision );
2227 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2228 // by default Qt rounds boundaries to 2 decimals at setRange
2229 spinBox->setRange( min, max );
2230 spinBox->setSingleStep( step );
2232 // Add a hint for the user saying how to tune precision
2233 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2234 spinBox->setProperty( "validity_tune_hint",
2235 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2238 //=================================================================================
2239 // function : SetDoubleSpinBoxStep()
2240 // purpose : Double spin box management
2241 //=================================================================================
2242 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2244 Group1Spin->SpinBox_DX->setSingleStep(step);
2245 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2246 Group2Spin->SpinBox_DX->setSingleStep(step);
2247 Group2Spin->SpinBox_DY->setSingleStep(step);
2248 Group3Spin->SpinBox_DX->setSingleStep(step);
2249 Group3Spin->SpinBox_DY->setSingleStep(step);
2250 Group3Spin->SpinBox_DZ->setSingleStep(step);
2251 Group4Spin->SpinBox_DZ->setSingleStep(step);
2253 // san: Do NOT override the step when a speicifc step value is used
2254 // in some input fields!
2255 //Group4Spin->SpinBox_DX->setSingleStep(step);
2256 //Group4Spin->SpinBox_DY->setSingleStep(step);
2257 //Group4Spin->SpinBox_DS->setSingleStep(step);
2260 //=================================================================================
2261 // function : FindLocalCS()
2262 // purpose : Find All Coordinates systems in study
2263 //=================================================================================
2264 void EntityGUI_SketcherDlg::FindLocalCS()
2268 SalomeApp_Application* app =
2269 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2273 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2277 _PTR(Study) aStudy = appStudy->studyDS();
2280 ComboBox1->addItem(tr("GEOM_GCS"));
2281 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2282 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2283 gp_Dir aDirX = gp_Dir(1, 0, 0);
2284 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2285 myLCSList.push_back(globalCS);
2287 // get GEOM component
2288 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2289 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2292 _PTR(SComponent) fc = obj->GetFatherComponent();
2293 QString geomComp = fc->GetID().c_str();
2294 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2298 // browse through all GEOM data tree
2299 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2300 for ( it->InitEx( true ); it->More(); it->Next() ) {
2301 _PTR(SObject) child( it->Value() );
2302 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2303 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2304 if( CORBA::is_nil( geomObj ) )
2306 if (geomObj->GetType() == GEOM_MARKER) {
2307 ComboBox1->addItem(geomObj->GetName());
2308 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2311 aLCS.Transform(aShape.Location().Transformation());
2312 if (aShape.ShapeType() == TopAbs_FACE) {
2313 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2314 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2315 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2316 gp_Pln aPln = aGPlane->Pln();
2317 aLCS = aPln.Position();
2320 myLCSList.push_back(aLCS);
2325 //=================================================================================
2326 // function : GetActiveLocalCS()
2327 // purpose : Get Working plane
2328 //=================================================================================
2329 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2331 int ind = ComboBox1->currentIndex();
2333 return myGeometryGUI->GetWorkingPlane();
2335 gp_Ax3 aLCS = myLCSList.at(ind);
2340 //=================================================================================
2341 // function : ActivateLocalCS()
2342 // purpose : Activate & Fit Working plane
2343 //=================================================================================
2344 void EntityGUI_SketcherDlg::ActivateLocalCS()
2346 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2347 myGeometryGUI->ActiveWorkingPlane();