1 // Copyright (C) 2007-2011 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 <BRepBuilderAPI_MakeVertex.hxx>
55 #include <Sketcher_Profile.hxx>
57 #include <SalomeApp_Study.h>
61 #include <Basics_Utils.hxx>
63 //=================================================================================
64 // class : EntityGUI_SketcherDlg()
65 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
66 // name 'name' and widget flags set to 'f'.
67 // The dialog will by default be modeless, unless you set 'modal' to
68 // TRUE to construct a modal dialog.
69 //=================================================================================
70 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
71 bool modal, Qt::WindowFlags fl,
72 const double lineWidth )
73 : QDialog( parent, fl ),
74 myIsAllAdded( false ),
76 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
78 myLineWidth( lineWidth )
81 setAttribute( Qt::WA_DeleteOnClose );
83 myGeometryGUI->SetActiveDialogBox(this);
85 MainWidget = new EntityGUI_Skeleton( this );
86 QVBoxLayout* topLayout = new QVBoxLayout( this );
87 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
89 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
90 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
91 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
92 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
94 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
95 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
96 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
98 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
100 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
101 MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) );
102 MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) );
103 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
104 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
105 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
106 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
108 /***************************************************************/
110 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
111 QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
112 planeLayout->setSpacing(6);
113 planeLayout->setMargin(11);
115 ComboBox1 = new QComboBox(GroupBox1);
116 ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
117 planeLayout->addWidget(ComboBox1);
119 planeButton = new QPushButton (GroupBox1);
120 planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
121 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
122 planeLayout->addWidget(planeButton);
124 topLayout->addWidget(GroupBox1);
125 topLayout->addWidget( MainWidget );
126 topLayout->setStretch( 1, 1);
128 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
130 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
131 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
132 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
133 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
135 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
137 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
138 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
139 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
140 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
142 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
144 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
145 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
146 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
147 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
148 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
150 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
152 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
153 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
154 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
155 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
157 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
158 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
159 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
160 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
161 Group1Sel->PushButton1->setIcon( image0 );
162 Group1Sel->buttonUndo->setIcon( image1 );
163 Group1Sel->buttonRedo->setIcon( image2 );
164 Group1Sel->LineEdit1->setReadOnly( true );
166 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
167 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
168 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
169 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
170 Group2Sel->PushButton1->setIcon( image0 );
171 Group2Sel->PushButton2->setIcon( image0 );
172 Group2Sel->buttonUndo->setIcon( image1 );
173 Group2Sel->buttonRedo->setIcon( image2 );
174 Group2Sel->LineEdit1->setReadOnly( true );
175 Group2Sel->LineEdit2->setReadOnly( true );
177 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
178 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
179 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
180 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
181 Group1Sel1Spin->PushButton1->setIcon( image0 );
182 Group1Sel1Spin->buttonUndo->setIcon( image1 );
183 Group1Sel1Spin->buttonRedo->setIcon( image2 );
184 Group1Sel1Spin->LineEdit1->setReadOnly( true );
186 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
187 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
188 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
189 Group1Spin->buttonUndo->setIcon( image1 );
190 Group1Spin->buttonRedo->setIcon( image2 );
192 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
193 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
194 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
195 Group2Spin->buttonUndo->setIcon( image1 );
196 Group2Spin->buttonRedo->setIcon( image2 );
198 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
199 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
200 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
201 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
202 Group3Spin->buttonUndo->setIcon( image1 );
203 Group3Spin->buttonRedo->setIcon( image2 );
205 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
206 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
207 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
208 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
209 Group4Spin->buttonUndo->setIcon( image1 );
210 Group4Spin->buttonRedo->setIcon( image2 );
212 // Defines a palette for the error message on Group4Spin and Group2Sel
215 palette.setColor(Group4Spin->label->foregroundRole(), color);
216 Group4Spin->label->setPalette(palette);
217 palette.setColor(Group2Sel->label->foregroundRole(), color);
218 Group2Sel->label->setPalette(palette);
220 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
221 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
222 DestCntLayout->addWidget( GroupPt, 0, 0 );
223 DestCntLayout->addWidget( GroupPt2, 0, 1 );
224 DestCntLayout->addWidget( GroupD1, 0, 0 );
225 DestCntLayout->addWidget( GroupD2, 0, 1 );
227 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
228 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
229 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
230 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
231 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
232 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
233 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
234 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
235 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
236 //SkeletonCntlayout->setStretch( 0, 1);
237 /***************************************************************/
239 QButtonGroup* ButtonGroup = new QButtonGroup( this );
240 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
241 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
243 /* signals and slots connections */
244 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
245 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
246 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
247 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
249 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
250 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
251 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
252 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
253 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
254 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
255 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
256 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
257 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
258 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
259 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
260 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
261 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
262 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
263 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
264 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
265 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
266 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
267 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
268 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
269 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
271 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
272 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
273 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
274 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
275 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
276 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
278 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
279 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
281 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
282 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
283 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
284 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
286 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
287 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
288 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
290 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
291 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
292 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
293 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
294 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
295 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
296 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
297 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
298 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
299 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
301 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
302 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
303 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
304 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
306 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
307 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
309 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
311 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
312 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
314 // install event filter on spin-boxes to provide Apply action on Return pressed
315 Group1Spin->SpinBox_DX->installEventFilter(this);
316 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
317 Group2Spin->SpinBox_DX->installEventFilter(this);
318 Group2Spin->SpinBox_DY->installEventFilter(this);
319 Group3Spin->SpinBox_DX->installEventFilter(this);
320 Group3Spin->SpinBox_DY->installEventFilter(this);
321 Group3Spin->SpinBox_DZ->installEventFilter(this);
322 Group4Spin->SpinBox_DX->installEventFilter(this);
323 Group4Spin->SpinBox_DY->installEventFilter(this);
324 Group4Spin->SpinBox_DZ->installEventFilter(this);
325 Group4Spin->SpinBox_DS->installEventFilter(this);
331 //=================================================================================
332 // function : ~EntityGUI_SketcherDlg()
333 // purpose : Destroys the object and frees any allocated resources
334 //=================================================================================
335 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
337 myGeometryGUI->SetActiveDialogBox( 0 );
341 //=================================================================================
342 // function : eventFilter()
343 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
344 //=================================================================================
345 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
347 MESSAGE("EntityGUI_SketcherDlg::eventFilter")
348 if (event->type() == QEvent::KeyPress) {
349 QKeyEvent* ke = (QKeyEvent*)event;
350 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
351 if (object == Group1Spin->SpinBox_DX) {
352 Group1Spin->buttonApply->click();
354 } else if (object == Group1Sel1Spin->SpinBox_DX) {
355 Group1Sel1Spin->buttonApply->click();
357 } else if (object == Group2Spin->SpinBox_DX ||
358 object == Group2Spin->SpinBox_DY) {
359 Group2Spin->buttonApply->click();
361 } else if (object == Group3Spin->SpinBox_DX ||
362 object == Group3Spin->SpinBox_DY ||
363 object == Group3Spin->SpinBox_DZ) {
364 Group3Spin->buttonApply->click();
366 } else if (object == Group4Spin->SpinBox_DX ||
367 object == Group4Spin->SpinBox_DY ||
368 object == Group4Spin->SpinBox_DZ ||
369 object == Group4Spin->SpinBox_DS) {
370 Group4Spin->buttonApply->click();
376 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
378 return QDialog::eventFilter(object, event);
382 //=================================================================================
385 //=================================================================================
386 void EntityGUI_SketcherDlg::Init()
390 myEditCurrentArgument = Group1Sel->LineEdit1;
391 myCommand.append( "Sketcher" );
392 myUndoCommand.append( "Sketcher" );
394 mySketchState = FIRST_POINT;
395 globalSelection( GEOM_POINT );
404 myHelpFileName = "create_sketcher_page.html";
406 /* Get setting of step value from file configuration */
407 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
409 /* min, max, step and decimals for spin boxes */
410 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
411 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
412 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
413 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
414 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
415 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
416 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
417 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
418 // san: Note specific step values below!
419 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
420 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
421 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
423 /* displays Dialog */
424 MainWidget->GroupConstructors->setEnabled( false );
425 MainWidget->GroupDest1->setEnabled( false );
426 setEnabledUndo( false );
427 setEnabledRedo( false );
429 MainWidget->RadioButton1->setChecked( true );
437 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
441 //=================================================================================
442 // function : InitClick()
444 //=================================================================================
445 void EntityGUI_SketcherDlg::InitClick()
447 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
452 Group1Sel1Spin->hide();
460 //=================================================================================
461 // function : TypeClicked()
462 // purpose : Radio button management
463 //=================================================================================
464 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
466 myConstructorId = constructorId;
467 if ( myConstructorId == 0 ) { // SEGMENT
468 GroupPt2->RB_Point1->setChecked( true );
469 GroupPt2->setEnabled( false );
470 GroupD2->setEnabled( true );
471 MainWidget->RB_Dest1->setEnabled( true );
472 MainWidget->RB_Dest1->setChecked( true );
475 else if ( myConstructorId == 1 ) { // ARC
476 GroupPt2->setEnabled( true );
477 GroupD2->RB_Dir21->setChecked( true );
478 GroupD2->setEnabled( false );
479 MainWidget->RB_Dest1->setEnabled( true );
480 MainWidget->RB_Dest1->setChecked( true );
486 //=================================================================================
487 // function : DestClicked()
488 // purpose : Radio button management
489 //=================================================================================
490 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
497 if ( constructorId == 1 ) {
499 GroupPt->RB_Point1->setChecked( true );
502 Group3Spin->checkBox->show();
503 Group4Spin->checkBox->show();
504 PointClicked( 1 ); // XY
506 else if ( constructorId == 0 ) {
508 GroupD1->RB_Dir11->setChecked( true );
511 Group3Spin->checkBox->hide();
512 Group4Spin->checkBox->hide();
513 Dir1Clicked( 2 ); // Angle
515 resize( minimumSizeHint() );
518 //=================================================================================
519 // function : PointClicked()
520 // purpose : Radio button management
521 //=================================================================================
522 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
524 MESSAGE("PointClicked")
525 myConstructorPntId = constructorId;
526 GroupPt->RB_Point3->setEnabled( true );
527 int buttonId = GroupPt2->ButtonGroup->checkedId();
528 MESSAGE("checkedId ="<< buttonId)
529 if (buttonId >= 0){ // = If a button is checked
530 Point2Clicked(buttonId);
533 GroupPt2->RB_Point1->setChecked( true );
538 //=================================================================================
539 // function : Point2Clicked()
540 // purpose : Radio button management
541 //=================================================================================
542 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
544 MESSAGE("Point2Clicked")
547 // Get setting of step value from file configuration
548 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
550 if ( myConstructorPntId == 1 ) { // XY
551 if ( constructorId == 1 ){ // No additional parameter
552 mySketchType = PT_ABS;
553 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
554 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
555 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
556 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
558 Group2Spin->SpinBox_DX->setValue( myX );
560 Group2Spin->SpinBox_DY->setValue( myY );
562 Group2Spin->buttonApply->setFocus();
564 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
566 else if ( constructorId == 0 ){ // Point + radius
567 mySketchType = PT_ABS_RADIUS;
568 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
569 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
570 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
571 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
572 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
573 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
575 Group3Spin->SpinBox_DX->setValue( myX );
577 Group3Spin->SpinBox_DY->setValue( myY );
579 Group3Spin->SpinBox_DZ->setValue( myRadius );
581 Group3Spin->buttonApply->setFocus();
583 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
585 else if ( constructorId == 2 ){ // Point + center
586 mySketchType = PT_ABS_CENTER;
587 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
588 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
589 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
590 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
591 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
592 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
593 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
594 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
596 Group4Spin->SpinBox_DX->setValue( myXc );
598 Group4Spin->SpinBox_DY->setValue( myYc );
600 Group4Spin->SpinBox_DZ->setValue( myX );
602 Group4Spin->SpinBox_DS->setValue( myY );
604 Group4Spin->buttonApply->setFocus();
606 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
610 else if ( myConstructorPntId == 0 ) { // DXDY
611 if ( constructorId == 1 ){ // No additional parameter
612 mySketchType = PT_RELATIVE;
613 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
614 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
615 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
616 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
618 Group2Spin->SpinBox_DX->setValue( myDX );
620 Group2Spin->SpinBox_DY->setValue( myDY );
622 Group2Spin->buttonApply->setFocus();
624 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
626 else if ( constructorId == 0 ){ // Point + radius
627 mySketchType = PT_REL_RADIUS;
628 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
629 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
630 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
631 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
632 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
633 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
635 Group3Spin->SpinBox_DX->setValue( myDX );
637 Group3Spin->SpinBox_DY->setValue( myDY );
639 Group3Spin->SpinBox_DZ->setValue( myRadius );
641 Group3Spin->buttonApply->setFocus();
643 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
645 else if ( constructorId == 2 ){ // Point + center
646 mySketchType = PT_REL_CENTER;
647 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
648 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
649 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
650 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
651 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
652 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
653 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
654 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
656 Group4Spin->SpinBox_DX->setValue( myDXc );
658 Group4Spin->SpinBox_DY->setValue( myDYc );
660 Group4Spin->SpinBox_DZ->setValue( myDX );
662 Group4Spin->SpinBox_DS->setValue( myDY );
664 Group4Spin->buttonApply->setFocus();
666 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
670 else if ( myConstructorPntId == 2 ) { // Selection
671 if ( constructorId == 1 ){ // No additional parameter
672 mySketchType = PT_SEL;
673 myEditCurrentArgument = Group1Sel->LineEdit1;
674 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
676 Group1Sel->buttonApply->setFocus();
677 SelectionIntoArgument();
679 else if ( constructorId == 0 ){ // Point + radius
680 mySketchType = PT_SEL_RADIUS;
681 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
682 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
683 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
684 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
686 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
688 Group1Sel1Spin->show();
689 Group1Sel1Spin->buttonApply->setFocus();
690 SelectionIntoArgument();
692 else if ( constructorId == 2 ){ // Point + center
693 mySketchType = PT_SEL_CENTER;
694 myEditCurrentArgument = Group2Sel->LineEdit1;
695 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
696 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
697 Group2Sel->LineEdit1->setEnabled(true);
698 Group2Sel->PushButton1->setDown(true);
699 Group2Sel->LineEdit2->setEnabled(false);
700 Group2Sel->PushButton2->setDown(false);
702 Group2Sel->buttonApply->setFocus();
703 SelectionIntoArgument();
707 resize( minimumSizeHint() );
708 connect( myGeometryGUI->getApp()->selectionMgr(),
709 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
714 //=================================================================================
715 // function : Dir1Clicked()
716 // purpose : Radio button management
717 //=================================================================================
718 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
720 myConstructorDirId = constructorId;
721 int dirButtonId = GroupD2->ButtonGroup->checkedId();
722 MESSAGE("checkedId ="<< dirButtonId)
723 if (dirButtonId >= 0){ // = If a button is checked
724 Dir2Clicked(dirButtonId);
727 GroupD2->RB_Dir21->setChecked( true );
733 //=================================================================================
734 // function : Dir2Clicked()
735 // purpose : Radio button management
736 //=================================================================================
737 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
742 // Get setting of step value from file configuration
743 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
745 if ( myConstructorId == 0 ) { // SEGMENT
749 if ( myConstructorDirId == 2 ) { // Angle
750 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
751 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
752 Group2Spin->SpinBox_DX->setValue( myAngle );
753 Group2Spin->buttonApply->setFocus();
756 if ( constructorId == 2 ) { // Length
757 mySketchType = DIR_ANGLE_LENGTH;
758 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
759 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
760 Group2Spin->SpinBox_DY->setValue( myLength );
762 else if ( constructorId == 0 ) { // X
763 mySketchType = DIR_ANGLE_X;
764 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
765 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
766 Group2Spin->SpinBox_DY->setValue( myX );
768 else if ( constructorId == 1 ) { // Y
769 mySketchType = DIR_ANGLE_Y;
770 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
771 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
772 Group2Spin->SpinBox_DY->setValue( myY );
775 else if ( myConstructorDirId == 0 ) { // Perpendicular
777 Group1Spin->buttonApply->setFocus();
779 if ( constructorId == 2 ) { // Length
780 mySketchType = DIR_PER_LENGTH;
781 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
782 Group1Spin->SpinBox_DX->setValue( myLength );
784 else if ( constructorId == 0 ) { // X
785 mySketchType = DIR_PER_X;
786 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
787 Group1Spin->SpinBox_DX->setValue( myX );
789 else if ( constructorId == 1 ) { // Y
790 mySketchType = DIR_PER_Y;
791 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
792 Group1Spin->SpinBox_DX->setValue( myY );
795 else if ( myConstructorDirId == 1 ) { // Tangent
797 Group1Spin->buttonApply->setFocus();
799 if ( constructorId == 2 ) { // Length
800 mySketchType = DIR_TAN_LENGTH;
801 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
802 Group1Spin->SpinBox_DX->setValue( myLength );
804 else if ( constructorId == 0 ) { // X
805 mySketchType = DIR_TAN_X;
806 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
807 Group1Spin->SpinBox_DX->setValue( myX );
809 else if ( constructorId == 1 ) { // Y
810 mySketchType = DIR_TAN_Y;
811 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
812 Group1Spin->SpinBox_DX->setValue( myY );
815 else if ( myConstructorDirId == 3 ) { // DXDY
816 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
817 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
818 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
819 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
820 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
822 Group3Spin->SpinBox_DX->setValue( myDX );
824 Group3Spin->SpinBox_DY->setValue( myDY );
826 Group3Spin->buttonApply->setFocus();
828 if ( constructorId == 2 ) { // Length
829 mySketchType = DIR_DXDY_LENGTH;
830 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
831 Group3Spin->SpinBox_DZ->setValue( myLength );
833 else if ( constructorId == 0 ) { // X
834 mySketchType = DIR_DXDY_X;
835 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
836 Group3Spin->SpinBox_DZ->setValue( myX );
838 else if ( constructorId == 1 ) { // Y
839 mySketchType = DIR_DXDY_Y;
840 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
841 Group3Spin->SpinBox_DZ->setValue( myY );
845 else if ( myConstructorId == 1 ) { // ARC
846 if ( myConstructorDirId == 2 ) { // Angle
847 if ( constructorId == 2 ) { // Length
848 mySketchType = DIR_ANGLE_LENGTH;
849 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
850 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
851 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
852 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
853 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
854 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
855 Group3Spin->SpinBox_DX->setValue( myAngle );
857 Group3Spin->SpinBox_DY->setValue( myRadius );
859 Group3Spin->SpinBox_DZ->setValue( myLength );
861 Group3Spin->buttonApply->setFocus();
864 else if ( myConstructorDirId == 0 ) { // Perpendicular
865 if ( constructorId == 2 ) { // Length
866 mySketchType = DIR_PER_LENGTH;
867 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
868 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
869 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
870 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
872 Group2Spin->SpinBox_DX->setValue( myRadius );
874 Group2Spin->SpinBox_DY->setValue( myLength );
876 Group2Spin->buttonApply->setFocus();
879 else if ( myConstructorDirId == 1 ) { // Tangent
880 if ( constructorId == 2 ) { // Length
881 mySketchType = DIR_TAN_LENGTH;
882 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
883 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
884 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
885 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
887 Group2Spin->SpinBox_DX->setValue( myRadius );
889 Group2Spin->SpinBox_DY->setValue( myLength );
891 Group2Spin->buttonApply->setFocus();
894 else if ( myConstructorDirId == 3 ) { // DXDY
895 if ( constructorId == 2 ) { // Length
896 mySketchType = DIR_DXDY_LENGTH;
897 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
898 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
899 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
900 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
901 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
902 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
903 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
904 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
906 Group4Spin->SpinBox_DX->setValue( myDX );
908 Group4Spin->SpinBox_DY->setValue( myDY );
910 Group4Spin->SpinBox_DZ->setValue( myRadius );
912 Group4Spin->SpinBox_DS->setValue( myLength );
914 Group4Spin->buttonApply->setFocus();
918 resize( minimumSizeHint() );
919 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
922 //=================================================================================
923 // function : CheckBoxClicked()
924 // purpose : CheckBox management
925 //=================================================================================
926 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
930 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
934 //=================================================================================
935 // function : ClickOnCancel()
937 //=================================================================================
938 void EntityGUI_SketcherDlg::ClickOnCancel()
944 //=================================================================================
945 // function : ClickOnEnd()
946 // purpose : connected to buttonEnd AND buttonClose
947 //=================================================================================
948 void EntityGUI_SketcherDlg::ClickOnEnd()
950 if ( sender() == MainWidget->buttonClose ) {
951 // Verify validity of commands
952 if ( myCommand.count() <= 2 ) {
953 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
954 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
959 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
960 Sketcher_Profile aProfile( Command.toAscii() );
962 Command = myCommand.join( "" );
963 aProfile = Sketcher_Profile( Command.toAscii() );
964 TopoDS_Shape myShape;
965 if ( aProfile.IsDone() )
966 myShape = aProfile.GetShape();
968 if ( myShape.ShapeType() != TopAbs_VERTEX )
969 myCommand.append( ":WW" );
972 // PAL16008 (Sketcher Validation should be equal to Apply&Close)
973 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
974 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
975 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
976 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
977 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
978 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
979 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
985 if ( myCommand.size() > 2 )
992 //=================================================================================
993 // function : ClickOnApply()
995 //=================================================================================
996 bool EntityGUI_SketcherDlg::ClickOnApply()
998 if ( sender() && sender()->inherits( "QPushButton" ) )
999 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1001 QString aParameters;
1002 myCommand.append( GetNewCommand( aParameters ) );
1003 mySketchState = NEXT_POINT;
1005 myUndoCommand.clear();
1006 myUndoCommand.append( "Sketcher" );
1008 myParameters.append( aParameters );
1009 myUndoParameters.clear();
1011 MainWidget->GroupConstructors->setEnabled( true );
1012 MainWidget->GroupDest1->setEnabled( true );
1013 setEnabledUndo( true );
1014 setEnabledRedo( false );
1017 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1020 // Set focus to SpinBox_DX
1021 if ( sender() == Group1Spin->buttonApply ) {
1022 (Group1Spin->SpinBox_DX)->setFocus();
1023 (Group1Spin->SpinBox_DX)->selectAll();
1025 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1026 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1027 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1029 else if ( sender() == Group2Spin->buttonApply ) {
1030 (Group2Spin->SpinBox_DX)->setFocus();
1031 (Group2Spin->SpinBox_DX)->selectAll();
1033 else if ( sender() == Group3Spin->buttonApply ) {
1034 (Group3Spin->SpinBox_DX)->setFocus();
1035 (Group3Spin->SpinBox_DX)->selectAll();
1037 else if ( sender() == Group4Spin->buttonApply ) {
1038 (Group4Spin->SpinBox_DX)->setFocus();
1039 (Group4Spin->SpinBox_DX)->selectAll();
1045 //=================================================================================
1046 // function : ClickOnHelp()
1048 //=================================================================================
1049 void EntityGUI_SketcherDlg::ClickOnHelp()
1051 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1053 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1057 platform = "winapplication";
1059 platform = "application";
1062 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1063 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1064 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1065 QObject::tr( "BUT_OK" ) );
1069 //=================================================================================
1070 // function : ClickOnUndo()
1072 //=================================================================================
1073 void EntityGUI_SketcherDlg::ClickOnUndo()
1075 myUndoCommand.append( myCommand.last() );
1076 myCommand.pop_back();
1078 myUndoParameters.append( myParameters.last() );
1079 myParameters.pop_back();
1081 if ( myCommand.count() == 1 ) {
1082 mySketchState = FIRST_POINT;
1084 MainWidget->RadioButton1->setChecked( true );
1087 connect( myGeometryGUI->getApp()->selectionMgr(),
1088 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1090 MainWidget->GroupConstructors->setEnabled( false );
1091 MainWidget->GroupDest1->setEnabled( false );
1092 setEnabledUndo( false );
1095 setEnabledRedo( true );
1097 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1100 //=================================================================================
1101 // function : ClickOnRedo()
1103 //=================================================================================
1104 void EntityGUI_SketcherDlg::ClickOnRedo()
1106 myCommand.append( myUndoCommand.last() );
1107 myUndoCommand.pop_back();
1109 myParameters.append( myUndoParameters.last() );
1110 myUndoParameters.pop_back();
1112 mySketchState = NEXT_POINT;
1114 MainWidget->GroupConstructors->setEnabled( true );
1115 MainWidget->GroupDest1->setEnabled( true );
1116 setEnabledUndo( true );
1118 if ( myUndoCommand.count() == 1 )
1119 setEnabledRedo( false );
1121 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1124 //=================================================================================
1125 // function : setEnabledUndo()
1127 //=================================================================================
1128 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1130 Group1Sel->buttonUndo->setEnabled( value );
1131 Group2Sel->buttonUndo->setEnabled( value );
1132 Group1Sel1Spin->buttonUndo->setEnabled( value );
1133 Group1Spin->buttonUndo->setEnabled( value );
1134 Group2Spin->buttonUndo->setEnabled( value );
1135 Group3Spin->buttonUndo->setEnabled( value );
1136 Group4Spin->buttonUndo->setEnabled( value );
1139 //=================================================================================
1140 // function : setEnabledRedo()
1142 //=================================================================================
1143 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1145 Group1Sel->buttonRedo->setEnabled( value );
1146 Group2Sel->buttonRedo->setEnabled( value );
1147 Group1Sel1Spin->buttonRedo->setEnabled( value );
1148 Group1Spin->buttonRedo->setEnabled( value );
1149 Group2Spin->buttonRedo->setEnabled( value );
1150 Group3Spin->buttonRedo->setEnabled( value );
1151 Group4Spin->buttonRedo->setEnabled( value );
1154 //=================================================================================
1155 // function : SelectionIntoArgument()
1156 // purpose : Called when selection as changed
1157 //=================================================================================
1158 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1160 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1161 myEditCurrentArgument->setText( "" );
1166 // printf ("\nmyX = %f myY = %f", myX, myY);
1167 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
1168 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
1170 if ( sender() == ComboBox1 )
1173 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1174 SALOME_ListIO aSelList;
1175 aSelMgr->selectedObjects(aSelList);
1177 int nbSel = aSelList.Extent();
1178 MESSAGE("NbSel = "<<nbSel)
1179 if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1180 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1181 if ( !CORBA::is_nil(aSelectedObject) ) {
1182 TopoDS_Shape aShape;
1183 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1185 gp_Ax3 aWPlane = GetActiveLocalCS();
1187 aTrans.SetTransformation(aWPlane);
1188 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1189 aShape = aTransformation.Shape();
1192 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1195 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1196 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1197 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1198 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1199 Group2Spin->SpinBox_DX->setValue(myX);
1200 Group2Spin->SpinBox_DY->setValue(myY);
1201 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1202 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1203 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1204 if ( myLastX1 && myLastY1 ) {
1205 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1206 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1208 if ( mySketchState != FIRST_POINT ) {
1209 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1210 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1212 Group2Spin->SpinBox_DX->setValue(myX);
1213 Group2Spin->SpinBox_DY->setValue(myY);
1222 if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1223 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1224 if ( !CORBA::is_nil(aSelectedObject) ) {
1225 TopoDS_Shape aShape;
1226 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1228 gp_Ax3 aWPlane = GetActiveLocalCS();
1230 aTrans.SetTransformation(aWPlane);
1231 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1232 aShape = aTransformation.Shape();
1235 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1238 Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1239 if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1240 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1241 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1242 Group3Spin->SpinBox_DX->setValue(myX);
1243 Group3Spin->SpinBox_DY->setValue(myY);
1244 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1245 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1246 } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1247 if ( myLastX1 && myLastY1 ) {
1248 Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1249 Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1251 if ( mySketchState != FIRST_POINT ) {
1252 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1253 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1255 Group3Spin->SpinBox_DX->setValue(myX);
1256 Group3Spin->SpinBox_DY->setValue(myY);
1265 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1266 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1267 if ( !CORBA::is_nil(aSelectedObject) ) {
1268 TopoDS_Shape aShape;
1269 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1271 gp_Ax3 aWPlane = GetActiveLocalCS();
1273 aTrans.SetTransformation(aWPlane);
1274 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1275 aShape = aTransformation.Shape();
1278 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1281 Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1282 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1283 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1284 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1285 Group4Spin->SpinBox_DX->setValue(myXc);
1286 Group4Spin->SpinBox_DY->setValue(myYc);
1287 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1288 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1289 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1290 if ( myLastX1 && myLastY1 ) {
1291 Group4Spin->SpinBox_DX->setValue(myXc - myLastX1);
1292 Group4Spin->SpinBox_DY->setValue(myYc - myLastY1);
1294 if ( mySketchState != FIRST_POINT ) {
1295 Group4Spin->SpinBox_DX->setValue(myXc - tmpX);
1296 Group4Spin->SpinBox_DY->setValue(myYc - tmpY);
1298 Group4Spin->SpinBox_DX->setValue(myXc);
1299 Group4Spin->SpinBox_DY->setValue(myYc);
1308 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1309 if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
1310 myX=tmpX; // If yes keep the old values of X and Y
1313 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1314 if ( !CORBA::is_nil(aSelectedObject) ) {
1315 TopoDS_Shape aShape;
1316 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1318 gp_Ax3 aWPlane = GetActiveLocalCS();
1320 aTrans.SetTransformation(aWPlane);
1321 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1322 aShape = aTransformation.Shape();
1325 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1328 Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1329 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1330 disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1331 disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1332 Group4Spin->SpinBox_DZ->setValue(myX);
1333 Group4Spin->SpinBox_DS->setValue(myY);
1334 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1335 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1336 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1337 if ( myLastX1 && myLastY1 ) {
1338 Group4Spin->SpinBox_DZ->setValue(myX - myLastX1);
1339 Group4Spin->SpinBox_DS->setValue(myY - myLastY1);
1341 if ( mySketchState != FIRST_POINT ) {
1342 Group4Spin->SpinBox_DZ->setValue(myX - tmpX);
1343 Group4Spin->SpinBox_DS->setValue(myY - tmpY);
1345 Group4Spin->SpinBox_DZ->setValue(myX);
1346 Group4Spin->SpinBox_DS->setValue(myY);
1354 if (nbSel == 0){ // If no object selected
1355 myX=tmpX; // Don't change the point coordinates
1356 myY=tmpY; // and don't redisplay the preview
1358 else if(!autoApply){
1359 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1365 this->activateWindow();
1370 //=================================================================================
1371 // function : SetEditCurrentArgument()
1373 //=================================================================================
1374 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1376 if ( sender() == Group1Sel->PushButton1 ) {
1377 myEditCurrentArgument = Group1Sel->LineEdit1;
1378 myEditCurrentArgument->setFocus();
1380 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1381 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1382 myEditCurrentArgument->setFocus();
1384 else if ( sender() == Group2Sel->PushButton1 ) {
1385 myEditCurrentArgument = Group2Sel->LineEdit1;
1386 Group2Sel->PushButton2->setDown(false);
1387 Group2Sel->PushButton1->setDown(true);
1388 Group2Sel->LineEdit2->setEnabled(false);
1389 Group2Sel->LineEdit1->setEnabled(true);
1390 // myEditCurrentArgument->setFocus();
1392 else if ( sender() == Group2Sel->PushButton2 ) {
1393 myEditCurrentArgument = Group2Sel->LineEdit2;
1394 Group2Sel->PushButton1->setDown(false);
1395 Group2Sel->PushButton2->setDown(true);
1396 Group2Sel->LineEdit1->setEnabled(false);
1397 Group2Sel->LineEdit2->setEnabled(true);
1398 // myEditCurrentArgument->setFocus();
1400 SelectionIntoArgument();
1404 //=================================================================================
1405 // function : LineEditReturnPressed()
1407 //=================================================================================
1408 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1410 if ( sender() == Group1Sel->LineEdit1 )
1411 myEditCurrentArgument = Group1Sel->LineEdit1;
1412 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1413 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1414 else if ( sender() == Group2Sel->LineEdit1 )
1415 myEditCurrentArgument = Group2Sel->LineEdit1;
1416 else if ( sender() == Group2Sel->LineEdit2 )
1417 myEditCurrentArgument = Group2Sel->LineEdit2;
1419 /* User name of object input management */
1420 /* If successfull the selection is changed and signal emitted... */
1421 /* so SelectionIntoArgument() is automatically called. */
1422 const QString objectUserName = myEditCurrentArgument->text();
1423 QWidget* thisWidget = (QWidget*)this;
1425 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1426 SALOME_ListIO aSelList;
1427 aSelMgr->selectedObjects(aSelList);
1429 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1430 myEditCurrentArgument->setText( objectUserName );
1434 //=================================================================================
1435 // function : DeactivateActiveDialog()
1437 //=================================================================================
1438 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1440 //myGeometryGUI->SetState( -1 );
1442 setEnabled( false );
1444 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1445 myGeometryGUI->SetActiveDialogBox( 0 );
1449 //=================================================================================
1450 // function : ActivateThisDialog()
1452 //=================================================================================
1453 void EntityGUI_SketcherDlg::ActivateThisDialog()
1455 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1456 myGeometryGUI->EmitSignalDeactivateDialog();
1458 myGeometryGUI->SetActiveDialogBox( this );
1460 connect( myGeometryGUI->getApp()->selectionMgr(),
1461 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1463 //myGeometryGUI->SetState( 0 );
1464 globalSelection( GEOM_POINT );
1466 myEditCurrentArgument = Group1Sel->LineEdit1;
1467 myEditCurrentArgument->setFocus();
1469 if ( sender() == Group1Sel->LineEdit1 ) {
1470 myEditCurrentArgument = Group1Sel->LineEdit1;
1471 myEditCurrentArgument->setFocus();
1473 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1474 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1475 myEditCurrentArgument->setFocus();
1477 else if ( sender() == Group2Sel->LineEdit1 ) {
1478 myEditCurrentArgument = Group2Sel->LineEdit1;
1479 myEditCurrentArgument->setFocus();
1481 else if ( sender() == Group2Sel->LineEdit2 ) {
1482 myEditCurrentArgument = Group2Sel->LineEdit2;
1483 myEditCurrentArgument->setFocus();
1486 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1490 //=================================================================================
1491 // function : enterEvent [REDEFINED]
1493 //=================================================================================
1494 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1497 ActivateThisDialog();
1501 //=================================================================================
1502 // function : closeEvent()
1504 //=================================================================================
1505 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1507 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1508 //myGeometryGUI->SetState( -1 );
1509 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1510 myGeometryGUI->getApp()->updateActions();
1511 QDialog::closeEvent( e );
1514 //=================================================================================
1515 // function : OnPointSelected
1517 //=================================================================================
1518 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt)
1520 MESSAGE("EntityGUI_SketcherDlg::OnPointSelected")
1525 autoApply = ( getPnt2ConstructorId() == 1 && false ); // If no additional argument needed after selection
1526 // -> apply automatically --> disabled for now
1528 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1529 x = thePnt.X() - myLastX1;
1530 y = thePnt.Y() - myLastY1;
1536 switch (getPnt2ConstructorId()){
1538 Group2Spin->SpinBox_DX->setValue( x );
1539 Group2Spin->SpinBox_DY->setValue( y );
1540 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1543 Group3Spin->SpinBox_DX->setValue( x );
1544 Group3Spin->SpinBox_DY->setValue( y );
1545 Group3Spin->buttonApply->setFocus();
1548 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1549 Group4Spin->SpinBox_DX->setValue( x );
1550 Group4Spin->SpinBox_DY->setValue( y );
1552 else{ // Select end point
1553 Group4Spin->SpinBox_DZ->setValue( x );
1554 Group4Spin->SpinBox_DS->setValue( y );
1556 Group4Spin->buttonApply->setFocus();
1561 //=================================================================================
1562 // function : ValueChangedInSpinBox()
1564 //=================================================================================
1565 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1567 MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
1568 QObject* send = (QObject*)sender();
1569 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1570 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1572 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1573 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1574 double LastDecimal = 0.0;
1576 QString vxStr, vyStr, vzStr, vsStr;
1578 QString newValueStr;
1579 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1580 newValueStr = aDoubleSpinBox->text();
1582 if ( send == Group1Spin->SpinBox_DX ) {
1583 vx = newValue; vxStr = newValueStr;
1585 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1586 vx = newValue; vxStr = newValueStr;
1588 else if ( send == Group2Spin->SpinBox_DX ) {
1589 vx = newValue; vxStr = newValueStr;
1590 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1592 else if ( send == Group2Spin->SpinBox_DY ) {
1593 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1594 vy = newValue; vyStr = newValueStr;
1596 else if ( send == Group3Spin->SpinBox_DX ) {
1597 vx = newValue; vxStr = newValueStr;
1598 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1599 vz = Group3Spin->SpinBox_DZ->value();
1600 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1601 if (mySketchType == PT_ABS_RADIUS){
1609 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1610 if (aPrecision >= 0) // 'f' format in the QString
1611 LastDecimal = aPrecision;
1612 else // 'g' format in the Qstring
1613 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1614 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1615 if ( Abs(vz) < minRad){
1617 Group3Spin->SpinBox_DZ->setValue( - minRad );
1619 Group3Spin->SpinBox_DZ->setValue( minRad );
1622 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1624 else if ( send == Group3Spin->SpinBox_DY ) {
1625 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1626 vy = newValue; vyStr = newValueStr;
1627 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1628 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1629 if (mySketchType == PT_ABS_RADIUS){
1637 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1638 if (aPrecision >= 0) // 'f' format in the QString
1639 LastDecimal = aPrecision;
1640 else // 'g' format in the QString
1641 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1642 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1643 if ( Abs(vz) < minRad){
1645 Group3Spin->SpinBox_DZ->setValue( - minRad );
1647 Group3Spin->SpinBox_DZ->setValue( minRad );
1650 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1652 else if ( send == Group3Spin->SpinBox_DZ ) {
1653 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1654 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1655 vz = newValue; vzStr = newValueStr;
1657 else if ( send == Group4Spin->SpinBox_DX ) {
1658 vx = newValue; vxStr = newValueStr;
1659 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1660 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1661 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1663 else if ( send == Group4Spin->SpinBox_DY ) {
1664 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1665 vy = newValue; vyStr = newValueStr;
1666 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1667 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1669 else if ( send == Group4Spin->SpinBox_DZ ) {
1670 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1671 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1672 vz = newValue; vzStr = newValueStr;
1673 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1675 else if ( send == Group4Spin->SpinBox_DS ) {
1676 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1677 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1678 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1679 vs = newValue; vsStr = newValueStr;
1681 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1683 if ( myConstructorId == 0 ) { // SEGMENT
1684 if ( mySketchType == PT_ABS ) {
1690 else if ( mySketchType == PT_RELATIVE ) {
1696 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1700 myLengthStr = vyStr;
1702 else if ( mySketchType == DIR_ANGLE_X ) {
1708 else if ( mySketchType == DIR_ANGLE_Y ) {
1714 else if ( mySketchType == DIR_PER_LENGTH ) {
1716 myLengthStr = vxStr;
1718 else if ( mySketchType == DIR_PER_X ) {
1722 else if ( mySketchType == DIR_PER_Y ) {
1726 else if ( mySketchType == DIR_TAN_LENGTH ) {
1728 myLengthStr = vxStr;
1730 else if ( mySketchType == DIR_TAN_X ) {
1734 else if ( mySketchType == DIR_TAN_Y ) {
1738 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1744 myLengthStr = vzStr;
1746 else if ( mySketchType == DIR_DXDY_X ) {
1754 else if ( mySketchType == DIR_DXDY_Y ) {
1763 else if ( myConstructorId == 1 ) { // ARC
1764 if ( mySketchType == PT_ABS ) {
1770 else if ( mySketchType == PT_RELATIVE ) {
1776 if ( mySketchType == PT_ABS_RADIUS ) {
1782 myRadiusStr = vzStr;
1784 else if ( mySketchType == PT_REL_RADIUS ) {
1790 myRadiusStr = vzStr;
1792 else if ( mySketchType == PT_SEL_RADIUS ) {
1794 myRadiusStr = vxStr;
1796 if ( mySketchType == PT_ABS_CENTER ) {
1806 else if ( mySketchType == PT_REL_CENTER ) {
1816 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1821 myRadiusStr = vyStr;
1822 myLengthStr = vzStr;
1824 else if ( mySketchType == DIR_PER_LENGTH ) {
1827 myRadiusStr = vxStr;
1828 myLengthStr = vyStr;
1830 else if ( mySketchType == DIR_TAN_LENGTH ) {
1833 myRadiusStr = vxStr;
1834 myLengthStr = vyStr;
1836 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1843 myRadiusStr = vzStr;
1844 myLengthStr = vsStr;
1849 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1851 double x, y, xc, yc;
1852 x = y = xc = yc = 0.0;
1853 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
1855 if ( mySketchType == PT_REL_CENTER ){
1856 x = myDX + myLastX1;
1857 y = myDY + myLastY1;
1858 xc = myDXc + myLastX1;
1859 yc = myDYc + myLastY1;
1867 displayPntPreview(xc,yc);
1868 displayPntPreview(x,y);
1873 //=================================================================================
1874 // function : GetNewCommand()
1875 // purpose : Build the new command with context
1876 //=================================================================================
1877 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1879 theParameters.clear();
1880 QString myNewCommand = ":";
1881 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1882 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1883 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1885 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1886 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1888 if ( mySketchState == FIRST_POINT ) {
1889 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1890 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1891 theParameters = myXStr + ":" + myYStr;
1893 if ( mySketchType == PT_RELATIVE) {
1894 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1895 theParameters = myDXStr + ":" + myDYStr;
1897 return myNewCommand;
1900 if ( myConstructorId == 0 ) { // SEGMENT
1901 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1902 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1903 theParameters = myXStr + ":" + myYStr;
1905 if ( mySketchType == PT_RELATIVE) {
1906 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1907 theParameters = myDXStr + ":" + myDYStr;
1909 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1910 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1911 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1912 theParameters = myAngleStr + ":" + myLengthStr;
1914 if ( mySketchType == DIR_ANGLE_X ) {
1915 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1916 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1917 theParameters = myAngleStr + ":" + myXStr;
1919 if ( mySketchType == DIR_ANGLE_Y ) {
1920 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1921 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1922 theParameters = myAngleStr + ":" + myYStr;
1924 if ( mySketchType == DIR_PER_LENGTH ) {
1925 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1926 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1927 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1929 if ( mySketchType == DIR_PER_X ) {
1930 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1931 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1932 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1934 if ( mySketchType == DIR_PER_Y ) {
1935 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1936 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1937 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1939 if ( mySketchType == DIR_TAN_LENGTH ) {
1940 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1941 theParameters = myLengthStr;
1943 if ( mySketchType == DIR_TAN_X ) {
1944 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1945 theParameters = myXStr;
1947 if ( mySketchType == DIR_TAN_Y) {
1948 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1949 theParameters = myYStr;
1951 if ( mySketchType == DIR_DXDY_LENGTH ) {
1952 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1953 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1954 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1956 if ( mySketchType == DIR_DXDY_X ) {
1957 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1958 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1959 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1961 if ( mySketchType == DIR_DXDY_Y ) {
1962 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1963 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1964 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1967 else if ( myConstructorId == 1 ) { // ARC
1968 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1969 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1970 theParameters = myXStr + ":" + myYStr;
1972 if ( mySketchType == PT_RELATIVE) {
1973 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1974 theParameters = myDXStr + ":" + myDYStr;
1976 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1977 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1978 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
1980 if ( mySketchType == PT_REL_RADIUS) {
1981 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1982 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
1984 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
1985 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 );
1986 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
1988 if ( mySketchType == PT_REL_CENTER) {
1989 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 );
1990 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
1992 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1993 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1994 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1995 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1997 if ( mySketchType == DIR_PER_LENGTH ) {
1998 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1999 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2000 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2002 if ( mySketchType == DIR_TAN_LENGTH ) {
2003 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2004 theParameters = myRadiusStr + ":" + myLengthStr;
2006 if ( mySketchType == DIR_DXDY_LENGTH ) {
2007 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2008 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2009 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2012 return myNewCommand;
2015 //=================================================================================
2016 // function : createOperation
2018 //=================================================================================
2019 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2021 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2024 //=================================================================================
2025 // function : isValid
2027 //=================================================================================
2028 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2031 bool toCorrect = !IsPreview() || myIsApply;
2033 if( Group1Spin->isVisible() ) {
2034 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2036 else if( Group1Sel1Spin->isVisible() ) {
2037 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2039 else if( Group2Spin->isVisible() ) {
2040 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2041 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2043 else if( Group3Spin->isVisible() ) {
2044 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2045 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2046 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2048 else if( Group4Spin->isVisible() ) {
2049 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2050 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2051 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2052 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2055 if( myIsApply && !ok )
2061 //=================================================================================
2062 // function : execute
2064 //=================================================================================
2065 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2067 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2068 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2069 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2071 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2072 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2074 QString aParameters;
2076 if ( mySketchState == FIRST_POINT ) {
2081 //Test if the current point is the same as the last one
2082 TopoDS_Shape myShape1, myShape2;
2084 // Set "C" numeric locale
2085 Kernel_Utils::Localizer loc;
2088 QString Command1 = myCommand.join( "" );
2089 Sketcher_Profile aProfile1( Command1.toAscii() );
2090 if ( aProfile1.IsDone() )
2091 myShape1 = aProfile1.GetShape();
2094 QString Command2 = Command1 + GetNewCommand( aParameters );
2095 Sketcher_Profile aProfile2( Command2.toAscii() );
2098 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2099 if (aProfile2.Error() > Precision::Confusion()){
2100 Group4Spin->label->show();
2101 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2104 Group4Spin->label->hide();
2108 Group4Spin->label->hide();
2109 if ( mySketchType == PT_SEL_CENTER ){
2110 if (aProfile2.Error() > Precision::Confusion()){
2111 Group2Sel->label->show();
2112 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2115 Group2Sel->label->hide();
2119 Group2Sel->label->hide();
2121 if ( aProfile2.IsDone() )
2122 myShape2 = aProfile2.GetShape();
2124 if ( myShape2.IsNull() ) {
2125 //the current point is the same as the last one
2126 myLastX2 = myLastX1;
2127 myLastY2 = myLastY1;
2130 TopoDS_Vertex V1, V2;
2132 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2133 //the last shape is the first point
2134 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2139 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2140 pt = BRep_Tool::Pnt( V2 );
2144 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2145 pt = BRep_Tool::Pnt( V2 );
2152 if ( ( mySketchState != FIRST_POINT &&
2153 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2154 cmd = myCommand.join( "" );
2155 if ( Group1Sel->isVisible() ) {
2156 Group1Sel->buttonApply->setEnabled( false );
2157 //Group1Sel->buttonApply->setFocus();
2159 if ( Group2Sel->isVisible() ) {
2160 Group2Sel->buttonApply->setEnabled( false );
2161 //Group2Sel->buttonApply->setFocus();
2163 if ( Group1Sel1Spin->isVisible() ) {
2164 Group1Sel1Spin->buttonApply->setEnabled( false );
2165 //Group1Sel1Spin->buttonApply->setFocus();
2167 if ( Group1Spin->isVisible() ) {
2168 Group1Spin->buttonApply->setEnabled( false );
2169 //Group1Spin->buttonApply->setFocus();
2171 if ( Group2Spin->isVisible() ) {
2172 Group2Spin->buttonApply->setEnabled( false );
2173 //Group2Spin->buttonApply->setFocus();
2175 if ( Group3Spin->isVisible() ) {
2176 Group3Spin->buttonApply->setEnabled( false );
2177 //Group3Spin->buttonApply->setFocus();
2179 if ( Group4Spin->isVisible() ) {
2180 Group4Spin->buttonApply->setEnabled( false );
2181 //Group4Spin->buttonApply->setFocus();
2185 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2187 if ( Group1Sel->isVisible() ) {
2188 Group1Sel->buttonApply->setEnabled( true );
2190 if ( Group2Sel->isVisible() ) {
2191 Group2Sel->buttonApply->setEnabled( true );
2193 if ( Group1Sel1Spin->isVisible() ) {
2194 Group1Sel1Spin->buttonApply->setEnabled( true );;
2196 if ( Group1Spin->isVisible() ) {
2197 Group1Spin->buttonApply->setEnabled( true );
2199 if ( Group2Spin->isVisible() ) {
2200 Group2Spin->buttonApply->setEnabled( true );
2202 if ( Group3Spin->isVisible() ) {
2203 Group3Spin->buttonApply->setEnabled( true );
2205 if ( Group4Spin->isVisible() ) {
2206 Group4Spin->buttonApply->setEnabled( true );
2210 gp_Ax3 myWPlane = GetActiveLocalCS();
2211 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2212 WPlane->length( 9 );
2213 WPlane[0] = myWPlane.Location().X();
2214 WPlane[1] = myWPlane.Location().Y();
2215 WPlane[2] = myWPlane.Location().Z();
2217 WPlane[3] = myWPlane.Direction().X();
2218 WPlane[4] = myWPlane.Direction().Y();
2219 WPlane[5] = myWPlane.Direction().Z();
2221 WPlane[6] = myWPlane.XDirection().X();
2222 WPlane[7] = myWPlane.XDirection().Y();
2223 WPlane[8] = myWPlane.XDirection().Z();
2225 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2226 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2228 if ( !anObj->_is_nil() )
2230 if( !IsPreview() ) {
2231 QStringList aCurrentParameters = myParameters;
2232 aCurrentParameters << aParameters;
2233 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2236 objects.push_back( anObj._retn() );
2242 //================================================================
2243 // Function : displayPreview
2244 // Purpose : Method for displaying preview of resulting shape
2245 // Redefined from GEOMBase_Helper.
2246 //================================================================
2247 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2249 const bool activate,
2251 const double lineWidth,
2252 const int displayMode,
2255 // Set color for preview shape
2256 getDisplayer()->SetColor( Quantity_NOC_RED );
2258 // set width of displayed shape
2259 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2261 // Disable activation of selection
2262 getDisplayer()->SetToActivate( activate );
2264 // Make a reference to GEOM_Object
2265 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2266 getDisplayer()->SetName( objStr.in() );
2268 // Create wire from applayed object
2269 TopoDS_Shape anApplyedWire, aLastSegment;
2270 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2274 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2275 if ( aPrs != 0 && !aPrs->IsNull() )
2276 GEOMBase_Helper::displayPreview( aPrs, append, update );
2278 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2279 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2280 if ( aPrs != 0 && !aPrs->IsNull() )
2281 GEOMBase_Helper::displayPreview( aPrs, append, update );
2283 getDisplayer()->UnsetName();
2285 // Enable activation of displayed objects
2286 getDisplayer()->SetToActivate( true );
2289 //================================================================
2290 // Function : displayPntPreview
2291 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2292 //================================================================
2293 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2299 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2300 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2301 TopoDS_Shape aVertex = mkVertex.Shape();
2303 // Disable activation of selection
2304 getDisplayer()->SetToActivate( false );
2307 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aVertex );
2308 if ( aPrs != 0 && !aPrs->IsNull() )
2309 GEOMBase_Helper::displayPreview( aPrs, append, update );
2311 // Enable back activation of selection
2312 getDisplayer()->SetToActivate( true );
2315 //================================================================
2316 // Function : createShapes
2317 // Purpose : Create applyed wire, and last segment from entry object
2318 //================================================================
2319 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2320 TopoDS_Shape& theApplyedWire,
2321 TopoDS_Shape& theLastSegment )
2323 TopoDS_Shape aShape;
2324 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2325 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2328 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2329 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2330 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2331 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2332 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2333 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2334 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2335 theApplyedWire = aShape;
2339 BRepBuilderAPI_MakeWire aBuilder;
2340 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2342 TopoDS_Shape anEdge = anExp.Current();
2344 if ( anExp.More() ) // i.e. non-last edge
2345 aBuilder.Add( TopoDS::Edge( anEdge ) );
2347 theLastSegment = anEdge;
2352 if ( aBuilder.IsDone() )
2353 theApplyedWire = aBuilder.Shape();
2358 //=================================================================================
2359 // function : keyPressEvent()
2361 //=================================================================================
2362 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2364 QDialog::keyPressEvent( e );
2365 if ( e->isAccepted() )
2368 if ( e->key() == Qt::Key_F1 ) {
2374 //=================================================================================
2375 // function : initSpinBox()
2377 //=================================================================================
2378 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2379 double min, double max,
2380 double step, const char* quantity )
2382 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2383 // TODO: Think how to keep the single piece of code...
2385 // Obtain precision from preferences
2386 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2387 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2389 spinBox->setPrecision( aPrecision );
2390 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2391 // by default Qt rounds boundaries to 2 decimals at setRange
2392 spinBox->setRange( min, max );
2393 spinBox->setSingleStep( step );
2395 // Add a hint for the user saying how to tune precision
2396 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2397 spinBox->setProperty( "validity_tune_hint",
2398 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2401 //=================================================================================
2402 // function : SetDoubleSpinBoxStep()
2403 // purpose : Double spin box management
2404 //=================================================================================
2405 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2407 Group1Spin->SpinBox_DX->setSingleStep(step);
2408 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2409 Group2Spin->SpinBox_DX->setSingleStep(step);
2410 Group2Spin->SpinBox_DY->setSingleStep(step);
2411 Group3Spin->SpinBox_DX->setSingleStep(step);
2412 Group3Spin->SpinBox_DY->setSingleStep(step);
2413 Group3Spin->SpinBox_DZ->setSingleStep(step);
2414 Group4Spin->SpinBox_DZ->setSingleStep(step);
2416 // san: Do NOT override the step when a speicifc step value is used
2417 // in some input fields!
2418 //Group4Spin->SpinBox_DX->setSingleStep(step);
2419 //Group4Spin->SpinBox_DY->setSingleStep(step);
2420 //Group4Spin->SpinBox_DS->setSingleStep(step);
2423 //=================================================================================
2424 // function : FindLocalCS()
2425 // purpose : Find All Coordinates systems in study
2426 //=================================================================================
2427 void EntityGUI_SketcherDlg::FindLocalCS()
2431 SalomeApp_Application* app =
2432 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2436 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2440 _PTR(Study) aStudy = appStudy->studyDS();
2443 ComboBox1->addItem(tr("GEOM_GCS"));
2444 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2445 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2446 gp_Dir aDirX = gp_Dir(1, 0, 0);
2447 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2448 myLCSList.push_back(globalCS);
2450 // get GEOM component
2451 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2452 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2455 _PTR(SComponent) fc = obj->GetFatherComponent();
2456 QString geomComp = fc->GetID().c_str();
2457 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2461 // browse through all GEOM data tree
2462 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2463 for ( it->InitEx( true ); it->More(); it->Next() ) {
2464 _PTR(SObject) child( it->Value() );
2465 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2466 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2467 if( CORBA::is_nil( geomObj ) )
2469 if (geomObj->GetType() == GEOM_MARKER) {
2470 ComboBox1->addItem(geomObj->GetName());
2471 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2474 aLCS.Transform(aShape.Location().Transformation());
2475 if (aShape.ShapeType() == TopAbs_FACE) {
2476 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2477 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2478 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2479 gp_Pln aPln = aGPlane->Pln();
2480 aLCS = aPln.Position();
2483 myLCSList.push_back(aLCS);
2488 //=================================================================================
2489 // function : getPnt1ConstructorId()
2491 //=================================================================================
2492 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2494 int buttonId = GroupPt->ButtonGroup->checkedId();
2495 // MESSAGE("buttonId = "<<buttonId)
2499 //=================================================================================
2500 // function : getPnt2ConstructorId()
2502 //=================================================================================
2503 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2505 int buttonId = GroupPt2->ButtonGroup->checkedId();
2506 // MESSAGE("buttonId = "<<buttonId)
2510 //=================================================================================
2511 // function : GetActiveLocalCS()
2512 // purpose : Get Working plane
2513 //=================================================================================
2514 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2516 int ind = ComboBox1->currentIndex();
2518 return myGeometryGUI->GetWorkingPlane();
2520 gp_Ax3 aLCS = myLCSList.at(ind);
2525 //=================================================================================
2526 // function : ActivateLocalCS()
2527 // purpose : Activate & Fit Working plane
2528 //=================================================================================
2529 void EntityGUI_SketcherDlg::ActivateLocalCS()
2531 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2532 myGeometryGUI->ActiveWorkingPlane();