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 if (event->type() == QEvent::KeyPress) {
348 QKeyEvent* ke = (QKeyEvent*)event;
349 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
350 if (object == Group1Spin->SpinBox_DX) {
351 Group1Spin->buttonApply->click();
353 } else if (object == Group1Sel1Spin->SpinBox_DX) {
354 Group1Sel1Spin->buttonApply->click();
356 } else if (object == Group2Spin->SpinBox_DX ||
357 object == Group2Spin->SpinBox_DY) {
358 Group2Spin->buttonApply->click();
360 } else if (object == Group3Spin->SpinBox_DX ||
361 object == Group3Spin->SpinBox_DY ||
362 object == Group3Spin->SpinBox_DZ) {
363 Group3Spin->buttonApply->click();
365 } else if (object == Group4Spin->SpinBox_DX ||
366 object == Group4Spin->SpinBox_DY ||
367 object == Group4Spin->SpinBox_DZ ||
368 object == Group4Spin->SpinBox_DS) {
369 Group4Spin->buttonApply->click();
375 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
377 return QDialog::eventFilter(object, event);
381 //=================================================================================
384 //=================================================================================
385 void EntityGUI_SketcherDlg::Init()
389 myEditCurrentArgument = Group1Sel->LineEdit1;
390 myCommand.append( "Sketcher" );
391 myUndoCommand.append( "Sketcher" );
393 mySketchState = FIRST_POINT;
394 globalSelection( GEOM_POINT );
403 myHelpFileName = "create_sketcher_page.html";
405 /* Get setting of step value from file configuration */
406 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
408 /* min, max, step and decimals for spin boxes */
409 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
410 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
411 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
412 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
413 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
414 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
415 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
416 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
417 // san: Note specific step values below!
418 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
419 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
420 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
422 /* displays Dialog */
423 MainWidget->GroupConstructors->setEnabled( false );
424 MainWidget->GroupDest1->setEnabled( false );
425 setEnabledUndo( false );
426 setEnabledRedo( false );
428 MainWidget->RadioButton1->setChecked( true );
436 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
440 //=================================================================================
441 // function : InitClick()
443 //=================================================================================
444 void EntityGUI_SketcherDlg::InitClick()
446 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
451 Group1Sel1Spin->hide();
456 globalSelection(); // close local selection to clear it
457 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
461 //=================================================================================
462 // function : TypeClicked()
463 // purpose : Radio button management
464 //=================================================================================
465 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
467 myConstructorId = constructorId;
468 if ( myConstructorId == 0 ) { // SEGMENT
469 GroupPt2->RB_Point1->setChecked( true );
470 GroupPt2->setEnabled( false );
471 GroupD2->setEnabled( true );
472 MainWidget->RB_Dest1->setEnabled( true );
473 MainWidget->RB_Dest1->setChecked( true );
476 else if ( myConstructorId == 1 ) { // ARC
477 GroupPt2->setEnabled( true );
478 GroupD2->RB_Dir21->setChecked( true );
479 GroupD2->setEnabled( false );
480 MainWidget->RB_Dest1->setEnabled( true );
481 MainWidget->RB_Dest1->setChecked( true );
487 //=================================================================================
488 // function : DestClicked()
489 // purpose : Radio button management
490 //=================================================================================
491 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
498 if ( constructorId == 1 ) {
500 GroupPt->RB_Point1->setChecked( true );
503 Group3Spin->checkBox->show();
504 Group4Spin->checkBox->show();
505 PointClicked( 1 ); // XY
507 else if ( constructorId == 0 ) {
509 GroupD1->RB_Dir11->setChecked( true );
512 Group3Spin->checkBox->hide();
513 Group4Spin->checkBox->hide();
514 Dir1Clicked( 2 ); // Angle
516 resize( minimumSizeHint() );
519 //=================================================================================
520 // function : PointClicked()
521 // purpose : Radio button management
522 //=================================================================================
523 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
525 MESSAGE("PointClicked")
526 myConstructorPntId = constructorId;
527 GroupPt->RB_Point3->setEnabled( true );
528 int buttonId = GroupPt2->ButtonGroup->checkedId();
529 MESSAGE("checkedId ="<< buttonId)
530 if (buttonId >= 0){ // = If a button is checked
531 Point2Clicked(buttonId);
534 GroupPt2->RB_Point1->setChecked( true );
539 //=================================================================================
540 // function : Point2Clicked()
541 // purpose : Radio button management
542 //=================================================================================
543 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
545 MESSAGE("Point2Clicked")
548 // Get setting of step value from file configuration
549 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
551 if ( myConstructorPntId == 1 ) { // XY
552 if ( constructorId == 1 ){ // No additional parameter
553 mySketchType = PT_ABS;
554 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
555 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
556 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
557 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
559 Group2Spin->SpinBox_DX->setValue( myX );
561 Group2Spin->SpinBox_DY->setValue( myY );
563 Group2Spin->buttonApply->setFocus();
565 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
567 else if ( constructorId == 0 ){ // Point + radius
568 mySketchType = PT_ABS_RADIUS;
569 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
570 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
571 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
572 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
573 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
574 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
576 Group3Spin->SpinBox_DX->setValue( myX );
578 Group3Spin->SpinBox_DY->setValue( myY );
580 Group3Spin->SpinBox_DZ->setValue( myRadius );
582 Group3Spin->buttonApply->setFocus();
584 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
586 else if ( constructorId == 2 ){ // Point + center
587 mySketchType = PT_ABS_CENTER;
588 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
589 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
590 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
591 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
592 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
593 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
594 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
595 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
597 Group4Spin->SpinBox_DX->setValue( myXc );
599 Group4Spin->SpinBox_DY->setValue( myYc );
601 Group4Spin->SpinBox_DZ->setValue( myX );
603 Group4Spin->SpinBox_DS->setValue( myY );
605 Group4Spin->buttonApply->setFocus();
607 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
611 else if ( myConstructorPntId == 0 ) { // DXDY
612 if ( constructorId == 1 ){ // No additional parameter
613 mySketchType = PT_RELATIVE;
614 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
615 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
616 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
617 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
619 Group2Spin->SpinBox_DX->setValue( myDX );
621 Group2Spin->SpinBox_DY->setValue( myDY );
623 Group2Spin->buttonApply->setFocus();
625 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
627 else if ( constructorId == 0 ){ // Point + radius
628 mySketchType = PT_REL_RADIUS;
629 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
630 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
631 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
632 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
633 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
634 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
636 Group3Spin->SpinBox_DX->setValue( myDX );
638 Group3Spin->SpinBox_DY->setValue( myDY );
640 Group3Spin->SpinBox_DZ->setValue( myRadius );
642 Group3Spin->buttonApply->setFocus();
644 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
646 else if ( constructorId == 2 ){ // Point + center
647 mySketchType = PT_REL_CENTER;
648 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
649 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
650 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
651 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
652 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
653 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
654 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
655 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
657 Group4Spin->SpinBox_DX->setValue( myDXc );
659 Group4Spin->SpinBox_DY->setValue( myDYc );
661 Group4Spin->SpinBox_DZ->setValue( myDX );
663 Group4Spin->SpinBox_DS->setValue( myDY );
665 Group4Spin->buttonApply->setFocus();
667 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
671 else if ( myConstructorPntId == 2 ) { // Selection
672 if ( constructorId == 1 ){ // No additional parameter
673 mySketchType = PT_SEL;
674 myEditCurrentArgument = Group1Sel->LineEdit1;
675 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
677 Group1Sel->buttonApply->setFocus();
678 SelectionIntoArgument();
680 else if ( constructorId == 0 ){ // Point + radius
681 mySketchType = PT_SEL_RADIUS;
682 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
683 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
684 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
685 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
687 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
689 Group1Sel1Spin->show();
690 Group1Sel1Spin->buttonApply->setFocus();
691 SelectionIntoArgument();
693 else if ( constructorId == 2 ){ // Point + center
694 mySketchType = PT_SEL_CENTER;
695 myEditCurrentArgument = Group2Sel->LineEdit1;
696 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
697 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
698 Group2Sel->LineEdit1->setEnabled(true);
699 Group2Sel->PushButton1->setDown(true);
700 Group2Sel->LineEdit2->setEnabled(false);
701 Group2Sel->PushButton2->setDown(false);
703 Group2Sel->buttonApply->setFocus();
704 SelectionIntoArgument();
708 resize( minimumSizeHint() );
709 connect( myGeometryGUI->getApp()->selectionMgr(),
710 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
715 //=================================================================================
716 // function : Dir1Clicked()
717 // purpose : Radio button management
718 //=================================================================================
719 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
721 myConstructorDirId = constructorId;
722 int dirButtonId = GroupD2->ButtonGroup->checkedId();
723 MESSAGE("checkedId ="<< dirButtonId)
724 if (dirButtonId >= 0){ // = If a button is checked
725 Dir2Clicked(dirButtonId);
728 GroupD2->RB_Dir21->setChecked( true );
734 //=================================================================================
735 // function : Dir2Clicked()
736 // purpose : Radio button management
737 //=================================================================================
738 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
743 // Get setting of step value from file configuration
744 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
746 if ( myConstructorId == 0 ) { // SEGMENT
750 if ( myConstructorDirId == 2 ) { // Angle
751 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
752 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
753 Group2Spin->SpinBox_DX->setValue( myAngle );
754 Group2Spin->buttonApply->setFocus();
757 if ( constructorId == 2 ) { // Length
758 mySketchType = DIR_ANGLE_LENGTH;
759 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
760 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
761 Group2Spin->SpinBox_DY->setValue( myLength );
763 else if ( constructorId == 0 ) { // X
764 mySketchType = DIR_ANGLE_X;
765 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
766 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
767 Group2Spin->SpinBox_DY->setValue( myX );
769 else if ( constructorId == 1 ) { // Y
770 mySketchType = DIR_ANGLE_Y;
771 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
772 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
773 Group2Spin->SpinBox_DY->setValue( myY );
776 else if ( myConstructorDirId == 0 ) { // Perpendicular
778 Group1Spin->buttonApply->setFocus();
780 if ( constructorId == 2 ) { // Length
781 mySketchType = DIR_PER_LENGTH;
782 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
783 Group1Spin->SpinBox_DX->setValue( myLength );
785 else if ( constructorId == 0 ) { // X
786 mySketchType = DIR_PER_X;
787 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
788 Group1Spin->SpinBox_DX->setValue( myX );
790 else if ( constructorId == 1 ) { // Y
791 mySketchType = DIR_PER_Y;
792 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
793 Group1Spin->SpinBox_DX->setValue( myY );
796 else if ( myConstructorDirId == 1 ) { // Tangent
798 Group1Spin->buttonApply->setFocus();
800 if ( constructorId == 2 ) { // Length
801 mySketchType = DIR_TAN_LENGTH;
802 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
803 Group1Spin->SpinBox_DX->setValue( myLength );
805 else if ( constructorId == 0 ) { // X
806 mySketchType = DIR_TAN_X;
807 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
808 Group1Spin->SpinBox_DX->setValue( myX );
810 else if ( constructorId == 1 ) { // Y
811 mySketchType = DIR_TAN_Y;
812 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
813 Group1Spin->SpinBox_DX->setValue( myY );
816 else if ( myConstructorDirId == 3 ) { // DXDY
817 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
818 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
819 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
820 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
821 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
823 Group3Spin->SpinBox_DX->setValue( myDX );
825 Group3Spin->SpinBox_DY->setValue( myDY );
827 Group3Spin->buttonApply->setFocus();
829 if ( constructorId == 2 ) { // Length
830 mySketchType = DIR_DXDY_LENGTH;
831 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
832 Group3Spin->SpinBox_DZ->setValue( myLength );
834 else if ( constructorId == 0 ) { // X
835 mySketchType = DIR_DXDY_X;
836 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
837 Group3Spin->SpinBox_DZ->setValue( myX );
839 else if ( constructorId == 1 ) { // Y
840 mySketchType = DIR_DXDY_Y;
841 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
842 Group3Spin->SpinBox_DZ->setValue( myY );
846 else if ( myConstructorId == 1 ) { // ARC
847 if ( myConstructorDirId == 2 ) { // Angle
848 if ( constructorId == 2 ) { // Length
849 mySketchType = DIR_ANGLE_LENGTH;
850 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
851 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
852 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
853 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
854 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
855 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
856 Group3Spin->SpinBox_DX->setValue( myAngle );
858 Group3Spin->SpinBox_DY->setValue( myRadius );
860 Group3Spin->SpinBox_DZ->setValue( myLength );
862 Group3Spin->buttonApply->setFocus();
865 else if ( myConstructorDirId == 0 ) { // Perpendicular
866 if ( constructorId == 2 ) { // Length
867 mySketchType = DIR_PER_LENGTH;
868 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
869 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
870 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
871 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
873 Group2Spin->SpinBox_DX->setValue( myRadius );
875 Group2Spin->SpinBox_DY->setValue( myLength );
877 Group2Spin->buttonApply->setFocus();
880 else if ( myConstructorDirId == 1 ) { // Tangent
881 if ( constructorId == 2 ) { // Length
882 mySketchType = DIR_TAN_LENGTH;
883 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
884 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
885 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
886 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
888 Group2Spin->SpinBox_DX->setValue( myRadius );
890 Group2Spin->SpinBox_DY->setValue( myLength );
892 Group2Spin->buttonApply->setFocus();
895 else if ( myConstructorDirId == 3 ) { // DXDY
896 if ( constructorId == 2 ) { // Length
897 mySketchType = DIR_DXDY_LENGTH;
898 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
899 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
900 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
901 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
902 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
903 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
904 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
905 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
907 Group4Spin->SpinBox_DX->setValue( myDX );
909 Group4Spin->SpinBox_DY->setValue( myDY );
911 Group4Spin->SpinBox_DZ->setValue( myRadius );
913 Group4Spin->SpinBox_DS->setValue( myLength );
915 Group4Spin->buttonApply->setFocus();
919 resize( minimumSizeHint() );
920 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
923 //=================================================================================
924 // function : CheckBoxClicked()
925 // purpose : CheckBox management
926 //=================================================================================
927 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
931 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
935 //=================================================================================
936 // function : ClickOnCancel()
938 //=================================================================================
939 void EntityGUI_SketcherDlg::ClickOnCancel()
945 //=================================================================================
946 // function : ClickOnEnd()
947 // purpose : connected to buttonEnd AND buttonClose
948 //=================================================================================
949 void EntityGUI_SketcherDlg::ClickOnEnd()
951 if ( sender() == MainWidget->buttonClose ) {
952 // Verify validity of commands
953 if ( myCommand.count() <= 2 ) {
954 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
955 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
960 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
961 Sketcher_Profile aProfile( Command.toAscii() );
963 Command = myCommand.join( "" );
964 aProfile = Sketcher_Profile( Command.toAscii() );
965 TopoDS_Shape myShape;
966 if ( aProfile.IsDone() )
967 myShape = aProfile.GetShape();
969 if ( myShape.ShapeType() != TopAbs_VERTEX )
970 myCommand.append( ":WW" );
973 // PAL16008 (Sketcher Validation should be equal to Apply&Close)
974 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
975 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
976 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
977 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
978 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
979 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
980 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
986 if ( myCommand.size() > 2 )
993 //=================================================================================
994 // function : ClickOnApply()
996 //=================================================================================
997 bool EntityGUI_SketcherDlg::ClickOnApply()
999 if ( sender() && sender()->inherits( "QPushButton" ) )
1000 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1002 QString aParameters;
1003 myCommand.append( GetNewCommand( aParameters ) );
1004 mySketchState = NEXT_POINT;
1006 myUndoCommand.clear();
1007 myUndoCommand.append( "Sketcher" );
1009 myParameters.append( aParameters );
1010 myUndoParameters.clear();
1012 MainWidget->GroupConstructors->setEnabled( true );
1013 MainWidget->GroupDest1->setEnabled( true );
1014 setEnabledUndo( true );
1015 setEnabledRedo( false );
1018 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1021 // Set focus to SpinBox_DX
1022 if ( sender() == Group1Spin->buttonApply ) {
1023 (Group1Spin->SpinBox_DX)->setFocus();
1024 (Group1Spin->SpinBox_DX)->selectAll();
1026 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1027 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1028 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1030 else if ( sender() == Group2Spin->buttonApply ) {
1031 (Group2Spin->SpinBox_DX)->setFocus();
1032 (Group2Spin->SpinBox_DX)->selectAll();
1034 else if ( sender() == Group3Spin->buttonApply ) {
1035 (Group3Spin->SpinBox_DX)->setFocus();
1036 (Group3Spin->SpinBox_DX)->selectAll();
1038 else if ( sender() == Group4Spin->buttonApply ) {
1039 (Group4Spin->SpinBox_DX)->setFocus();
1040 (Group4Spin->SpinBox_DX)->selectAll();
1046 //=================================================================================
1047 // function : ClickOnHelp()
1049 //=================================================================================
1050 void EntityGUI_SketcherDlg::ClickOnHelp()
1052 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1054 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1058 platform = "winapplication";
1060 platform = "application";
1063 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1064 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1065 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1066 QObject::tr( "BUT_OK" ) );
1070 //=================================================================================
1071 // function : ClickOnUndo()
1073 //=================================================================================
1074 void EntityGUI_SketcherDlg::ClickOnUndo()
1076 myUndoCommand.append( myCommand.last() );
1077 myCommand.pop_back();
1079 myUndoParameters.append( myParameters.last() );
1080 myParameters.pop_back();
1082 if ( myCommand.count() == 1 ) {
1083 mySketchState = FIRST_POINT;
1085 MainWidget->RadioButton1->setChecked( true );
1088 connect( myGeometryGUI->getApp()->selectionMgr(),
1089 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1091 MainWidget->GroupConstructors->setEnabled( false );
1092 MainWidget->GroupDest1->setEnabled( false );
1093 setEnabledUndo( false );
1096 setEnabledRedo( true );
1098 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1101 //=================================================================================
1102 // function : ClickOnRedo()
1104 //=================================================================================
1105 void EntityGUI_SketcherDlg::ClickOnRedo()
1107 myCommand.append( myUndoCommand.last() );
1108 myUndoCommand.pop_back();
1110 myParameters.append( myUndoParameters.last() );
1111 myUndoParameters.pop_back();
1113 mySketchState = NEXT_POINT;
1115 MainWidget->GroupConstructors->setEnabled( true );
1116 MainWidget->GroupDest1->setEnabled( true );
1117 setEnabledUndo( true );
1119 if ( myUndoCommand.count() == 1 )
1120 setEnabledRedo( false );
1122 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1125 //=================================================================================
1126 // function : setEnabledUndo()
1128 //=================================================================================
1129 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1131 Group1Sel->buttonUndo->setEnabled( value );
1132 Group2Sel->buttonUndo->setEnabled( value );
1133 Group1Sel1Spin->buttonUndo->setEnabled( value );
1134 Group1Spin->buttonUndo->setEnabled( value );
1135 Group2Spin->buttonUndo->setEnabled( value );
1136 Group3Spin->buttonUndo->setEnabled( value );
1137 Group4Spin->buttonUndo->setEnabled( value );
1140 //=================================================================================
1141 // function : setEnabledRedo()
1143 //=================================================================================
1144 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1146 Group1Sel->buttonRedo->setEnabled( value );
1147 Group2Sel->buttonRedo->setEnabled( value );
1148 Group1Sel1Spin->buttonRedo->setEnabled( value );
1149 Group1Spin->buttonRedo->setEnabled( value );
1150 Group2Spin->buttonRedo->setEnabled( value );
1151 Group3Spin->buttonRedo->setEnabled( value );
1152 Group4Spin->buttonRedo->setEnabled( value );
1155 //=================================================================================
1156 // function : SelectionIntoArgument()
1157 // purpose : Called when selection as changed
1158 //=================================================================================
1159 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1161 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1162 myEditCurrentArgument->setText( "" );
1167 // printf ("\nmyX = %f myY = %f", myX, myY);
1168 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
1169 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
1171 if ( sender() == ComboBox1 )
1174 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1175 SALOME_ListIO aSelList;
1176 aSelMgr->selectedObjects(aSelList);
1178 int nbSel = aSelList.Extent();
1179 MESSAGE("NbSel = "<<nbSel)
1180 if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1181 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1182 if ( !CORBA::is_nil(aSelectedObject) ) {
1183 TopoDS_Shape aShape;
1184 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1186 gp_Ax3 aWPlane = GetActiveLocalCS();
1188 aTrans.SetTransformation(aWPlane);
1189 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1190 aShape = aTransformation.Shape();
1193 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1196 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1197 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1198 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1199 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1200 Group2Spin->SpinBox_DX->setValue(myX);
1201 Group2Spin->SpinBox_DY->setValue(myY);
1202 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1203 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1204 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1205 if ( myLastX1 && myLastY1 ) {
1206 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1207 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1209 if ( mySketchState != FIRST_POINT ) {
1210 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1211 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1213 Group2Spin->SpinBox_DX->setValue(myX);
1214 Group2Spin->SpinBox_DY->setValue(myY);
1223 if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1224 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1225 if ( !CORBA::is_nil(aSelectedObject) ) {
1226 TopoDS_Shape aShape;
1227 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1229 gp_Ax3 aWPlane = GetActiveLocalCS();
1231 aTrans.SetTransformation(aWPlane);
1232 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1233 aShape = aTransformation.Shape();
1236 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1239 Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1240 if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1241 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1242 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1243 Group3Spin->SpinBox_DX->setValue(myX);
1244 Group3Spin->SpinBox_DY->setValue(myY);
1245 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1246 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1247 } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1248 if ( myLastX1 && myLastY1 ) {
1249 Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1250 Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1252 if ( mySketchState != FIRST_POINT ) {
1253 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1254 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1256 Group3Spin->SpinBox_DX->setValue(myX);
1257 Group3Spin->SpinBox_DY->setValue(myY);
1266 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1267 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1268 if ( !CORBA::is_nil(aSelectedObject) ) {
1269 TopoDS_Shape aShape;
1270 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1272 gp_Ax3 aWPlane = GetActiveLocalCS();
1274 aTrans.SetTransformation(aWPlane);
1275 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1276 aShape = aTransformation.Shape();
1279 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1282 Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1283 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1284 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1285 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1286 Group4Spin->SpinBox_DX->setValue(myXc);
1287 Group4Spin->SpinBox_DY->setValue(myYc);
1288 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1289 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1290 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1291 if ( myLastX1 && myLastY1 ) {
1292 Group4Spin->SpinBox_DX->setValue(myXc - myLastX1);
1293 Group4Spin->SpinBox_DY->setValue(myYc - myLastY1);
1295 if ( mySketchState != FIRST_POINT ) {
1296 Group4Spin->SpinBox_DX->setValue(myXc - tmpX);
1297 Group4Spin->SpinBox_DY->setValue(myYc - tmpY);
1299 Group4Spin->SpinBox_DX->setValue(myXc);
1300 Group4Spin->SpinBox_DY->setValue(myYc);
1309 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1310 if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
1311 myX=tmpX; // If yes keep the old values of X and Y
1314 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1315 if ( !CORBA::is_nil(aSelectedObject) ) {
1316 TopoDS_Shape aShape;
1317 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1319 gp_Ax3 aWPlane = GetActiveLocalCS();
1321 aTrans.SetTransformation(aWPlane);
1322 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1323 aShape = aTransformation.Shape();
1326 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1329 Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1330 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1331 disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1332 disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1333 Group4Spin->SpinBox_DZ->setValue(myX);
1334 Group4Spin->SpinBox_DS->setValue(myY);
1335 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1336 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1337 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1338 if ( myLastX1 && myLastY1 ) {
1339 Group4Spin->SpinBox_DZ->setValue(myX - myLastX1);
1340 Group4Spin->SpinBox_DS->setValue(myY - myLastY1);
1342 if ( mySketchState != FIRST_POINT ) {
1343 Group4Spin->SpinBox_DZ->setValue(myX - tmpX);
1344 Group4Spin->SpinBox_DS->setValue(myY - tmpY);
1346 Group4Spin->SpinBox_DZ->setValue(myX);
1347 Group4Spin->SpinBox_DS->setValue(myY);
1355 if (nbSel == 0){ // If no object selected
1356 myX=tmpX; // Don't change the point coordinates
1357 myY=tmpY; // and don't redisplay the preview
1359 else if(!autoApply){
1360 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1366 this->activateWindow();
1371 //=================================================================================
1372 // function : SetEditCurrentArgument()
1374 //=================================================================================
1375 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1377 if ( sender() == Group1Sel->PushButton1 ) {
1378 myEditCurrentArgument = Group1Sel->LineEdit1;
1379 myEditCurrentArgument->setFocus();
1381 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1382 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1383 myEditCurrentArgument->setFocus();
1385 else if ( sender() == Group2Sel->PushButton1 ) {
1386 myEditCurrentArgument = Group2Sel->LineEdit1;
1387 Group2Sel->PushButton2->setDown(false);
1388 Group2Sel->PushButton1->setDown(true);
1389 Group2Sel->LineEdit2->setEnabled(false);
1390 Group2Sel->LineEdit1->setEnabled(true);
1391 // myEditCurrentArgument->setFocus();
1393 else if ( sender() == Group2Sel->PushButton2 ) {
1394 myEditCurrentArgument = Group2Sel->LineEdit2;
1395 Group2Sel->PushButton1->setDown(false);
1396 Group2Sel->PushButton2->setDown(true);
1397 Group2Sel->LineEdit1->setEnabled(false);
1398 Group2Sel->LineEdit2->setEnabled(true);
1399 // myEditCurrentArgument->setFocus();
1401 SelectionIntoArgument();
1405 //=================================================================================
1406 // function : LineEditReturnPressed()
1408 //=================================================================================
1409 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1411 if ( sender() == Group1Sel->LineEdit1 )
1412 myEditCurrentArgument = Group1Sel->LineEdit1;
1413 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1414 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1415 else if ( sender() == Group2Sel->LineEdit1 )
1416 myEditCurrentArgument = Group2Sel->LineEdit1;
1417 else if ( sender() == Group2Sel->LineEdit2 )
1418 myEditCurrentArgument = Group2Sel->LineEdit2;
1420 /* User name of object input management */
1421 /* If successfull the selection is changed and signal emitted... */
1422 /* so SelectionIntoArgument() is automatically called. */
1423 const QString objectUserName = myEditCurrentArgument->text();
1424 QWidget* thisWidget = (QWidget*)this;
1426 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1427 SALOME_ListIO aSelList;
1428 aSelMgr->selectedObjects(aSelList);
1430 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1431 myEditCurrentArgument->setText( objectUserName );
1435 //=================================================================================
1436 // function : DeactivateActiveDialog()
1438 //=================================================================================
1439 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1441 //myGeometryGUI->SetState( -1 );
1443 setEnabled( false );
1445 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1446 myGeometryGUI->SetActiveDialogBox( 0 );
1450 //=================================================================================
1451 // function : ActivateThisDialog()
1453 //=================================================================================
1454 void EntityGUI_SketcherDlg::ActivateThisDialog()
1456 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1457 myGeometryGUI->EmitSignalDeactivateDialog();
1459 myGeometryGUI->SetActiveDialogBox( this );
1461 connect( myGeometryGUI->getApp()->selectionMgr(),
1462 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1464 //myGeometryGUI->SetState( 0 );
1465 globalSelection( GEOM_POINT );
1467 myEditCurrentArgument = Group1Sel->LineEdit1;
1468 myEditCurrentArgument->setFocus();
1470 if ( sender() == Group1Sel->LineEdit1 ) {
1471 myEditCurrentArgument = Group1Sel->LineEdit1;
1472 myEditCurrentArgument->setFocus();
1474 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1475 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1476 myEditCurrentArgument->setFocus();
1478 else if ( sender() == Group2Sel->LineEdit1 ) {
1479 myEditCurrentArgument = Group2Sel->LineEdit1;
1480 myEditCurrentArgument->setFocus();
1482 else if ( sender() == Group2Sel->LineEdit2 ) {
1483 myEditCurrentArgument = Group2Sel->LineEdit2;
1484 myEditCurrentArgument->setFocus();
1487 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1491 //=================================================================================
1492 // function : enterEvent [REDEFINED]
1494 //=================================================================================
1495 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1498 ActivateThisDialog();
1502 //=================================================================================
1503 // function : closeEvent()
1505 //=================================================================================
1506 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1508 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1509 //myGeometryGUI->SetState( -1 );
1510 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1511 myGeometryGUI->getApp()->updateActions();
1512 QDialog::closeEvent( e );
1515 //=================================================================================
1516 // function : OnPointSelected
1518 //=================================================================================
1519 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt)
1521 MESSAGE("EntityGUI_SketcherDlg::OnPointSelected")
1526 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1527 TopoDS_Shape aShape = mkVertex.Shape();
1529 // Taking into account LocalCS
1530 gp_Ax3 aWPlane = GetActiveLocalCS();
1533 aTrans.SetTransformation(aWPlane);
1534 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1535 aShape = aTransformation.Shape();
1538 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1540 autoApply = ( getPnt2ConstructorId() == 1 && false ); // If no additional argument needed after selection
1541 // -> apply automatically --> disabled for now
1543 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1544 x = aTrsfPnt.X() - myLastX1;
1545 y = aTrsfPnt.Y() - myLastY1;
1551 switch (getPnt2ConstructorId()){
1553 Group2Spin->SpinBox_DX->setValue( x );
1554 Group2Spin->SpinBox_DY->setValue( y );
1555 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1558 Group3Spin->SpinBox_DX->setValue( x );
1559 Group3Spin->SpinBox_DY->setValue( y );
1560 Group3Spin->buttonApply->setFocus();
1563 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1564 Group4Spin->SpinBox_DX->setValue( x );
1565 Group4Spin->SpinBox_DY->setValue( y );
1567 else{ // Select end point
1568 Group4Spin->SpinBox_DZ->setValue( x );
1569 Group4Spin->SpinBox_DS->setValue( y );
1571 Group4Spin->buttonApply->setFocus();
1576 //=================================================================================
1577 // function : ValueChangedInSpinBox()
1579 //=================================================================================
1580 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1582 MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
1583 QObject* send = (QObject*)sender();
1584 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1585 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1587 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1588 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1589 double LastDecimal = 0.0;
1591 QString vxStr, vyStr, vzStr, vsStr;
1593 QString newValueStr;
1594 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1595 newValueStr = aDoubleSpinBox->text();
1597 if ( send == Group1Spin->SpinBox_DX ) {
1598 vx = newValue; vxStr = newValueStr;
1600 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1601 vx = newValue; vxStr = newValueStr;
1603 else if ( send == Group2Spin->SpinBox_DX ) {
1604 vx = newValue; vxStr = newValueStr;
1605 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1607 else if ( send == Group2Spin->SpinBox_DY ) {
1608 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1609 vy = newValue; vyStr = newValueStr;
1611 else if ( send == Group3Spin->SpinBox_DX ) {
1612 vx = newValue; vxStr = newValueStr;
1613 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1614 vz = Group3Spin->SpinBox_DZ->value();
1615 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1616 if (mySketchType == PT_ABS_RADIUS){
1624 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1625 if (aPrecision >= 0) // 'f' format in the QString
1626 LastDecimal = aPrecision;
1627 else // 'g' format in the Qstring
1628 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1629 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1630 if ( Abs(vz) < minRad){
1632 Group3Spin->SpinBox_DZ->setValue( - minRad );
1634 Group3Spin->SpinBox_DZ->setValue( minRad );
1637 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1639 else if ( send == Group3Spin->SpinBox_DY ) {
1640 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1641 vy = newValue; vyStr = newValueStr;
1642 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1643 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1644 if (mySketchType == PT_ABS_RADIUS){
1652 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1653 if (aPrecision >= 0) // 'f' format in the QString
1654 LastDecimal = aPrecision;
1655 else // 'g' format in the QString
1656 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1657 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1658 if ( Abs(vz) < minRad){
1660 Group3Spin->SpinBox_DZ->setValue( - minRad );
1662 Group3Spin->SpinBox_DZ->setValue( minRad );
1665 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1667 else if ( send == Group3Spin->SpinBox_DZ ) {
1668 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1669 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1670 vz = newValue; vzStr = newValueStr;
1672 else if ( send == Group4Spin->SpinBox_DX ) {
1673 vx = newValue; vxStr = newValueStr;
1674 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1675 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1676 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1678 else if ( send == Group4Spin->SpinBox_DY ) {
1679 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1680 vy = newValue; vyStr = newValueStr;
1681 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1682 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1684 else if ( send == Group4Spin->SpinBox_DZ ) {
1685 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1686 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1687 vz = newValue; vzStr = newValueStr;
1688 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1690 else if ( send == Group4Spin->SpinBox_DS ) {
1691 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1692 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1693 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1694 vs = newValue; vsStr = newValueStr;
1696 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1698 if ( myConstructorId == 0 ) { // SEGMENT
1699 if ( mySketchType == PT_ABS ) {
1705 else if ( mySketchType == PT_RELATIVE ) {
1711 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1715 myLengthStr = vyStr;
1717 else if ( mySketchType == DIR_ANGLE_X ) {
1723 else if ( mySketchType == DIR_ANGLE_Y ) {
1729 else if ( mySketchType == DIR_PER_LENGTH ) {
1731 myLengthStr = vxStr;
1733 else if ( mySketchType == DIR_PER_X ) {
1737 else if ( mySketchType == DIR_PER_Y ) {
1741 else if ( mySketchType == DIR_TAN_LENGTH ) {
1743 myLengthStr = vxStr;
1745 else if ( mySketchType == DIR_TAN_X ) {
1749 else if ( mySketchType == DIR_TAN_Y ) {
1753 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1759 myLengthStr = vzStr;
1761 else if ( mySketchType == DIR_DXDY_X ) {
1769 else if ( mySketchType == DIR_DXDY_Y ) {
1778 else if ( myConstructorId == 1 ) { // ARC
1779 if ( mySketchType == PT_ABS ) {
1785 else if ( mySketchType == PT_RELATIVE ) {
1791 if ( mySketchType == PT_ABS_RADIUS ) {
1797 myRadiusStr = vzStr;
1799 else if ( mySketchType == PT_REL_RADIUS ) {
1805 myRadiusStr = vzStr;
1807 else if ( mySketchType == PT_SEL_RADIUS ) {
1809 myRadiusStr = vxStr;
1811 if ( mySketchType == PT_ABS_CENTER ) {
1821 else if ( mySketchType == PT_REL_CENTER ) {
1831 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1836 myRadiusStr = vyStr;
1837 myLengthStr = vzStr;
1839 else if ( mySketchType == DIR_PER_LENGTH ) {
1842 myRadiusStr = vxStr;
1843 myLengthStr = vyStr;
1845 else if ( mySketchType == DIR_TAN_LENGTH ) {
1848 myRadiusStr = vxStr;
1849 myLengthStr = vyStr;
1851 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1858 myRadiusStr = vzStr;
1859 myLengthStr = vsStr;
1864 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1866 double x, y, xc, yc;
1867 x = y = xc = yc = 0.0;
1868 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
1870 if ( mySketchType == PT_REL_CENTER ){
1871 x = myDX + myLastX1;
1872 y = myDY + myLastY1;
1873 xc = myDXc + myLastX1;
1874 yc = myDYc + myLastY1;
1882 displayPntPreview(xc,yc);
1883 displayPntPreview(x,y);
1888 //=================================================================================
1889 // function : GetNewCommand()
1890 // purpose : Build the new command with context
1891 //=================================================================================
1892 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1894 theParameters.clear();
1895 QString myNewCommand = ":";
1896 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1897 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1898 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1900 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1901 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1903 if ( mySketchState == FIRST_POINT ) {
1904 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1905 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1906 theParameters = myXStr + ":" + myYStr;
1908 if ( mySketchType == PT_RELATIVE) {
1909 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1910 theParameters = myDXStr + ":" + myDYStr;
1912 return myNewCommand;
1915 if ( myConstructorId == 0 ) { // SEGMENT
1916 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1917 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1918 theParameters = myXStr + ":" + myYStr;
1920 if ( mySketchType == PT_RELATIVE) {
1921 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1922 theParameters = myDXStr + ":" + myDYStr;
1924 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1925 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1926 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1927 theParameters = myAngleStr + ":" + myLengthStr;
1929 if ( mySketchType == DIR_ANGLE_X ) {
1930 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1931 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1932 theParameters = myAngleStr + ":" + myXStr;
1934 if ( mySketchType == DIR_ANGLE_Y ) {
1935 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1936 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1937 theParameters = myAngleStr + ":" + myYStr;
1939 if ( mySketchType == DIR_PER_LENGTH ) {
1940 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1941 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1942 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1944 if ( mySketchType == DIR_PER_X ) {
1945 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1946 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1947 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1949 if ( mySketchType == DIR_PER_Y ) {
1950 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1951 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1952 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1954 if ( mySketchType == DIR_TAN_LENGTH ) {
1955 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1956 theParameters = myLengthStr;
1958 if ( mySketchType == DIR_TAN_X ) {
1959 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1960 theParameters = myXStr;
1962 if ( mySketchType == DIR_TAN_Y) {
1963 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1964 theParameters = myYStr;
1966 if ( mySketchType == DIR_DXDY_LENGTH ) {
1967 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1968 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1969 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1971 if ( mySketchType == DIR_DXDY_X ) {
1972 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1973 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1974 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1976 if ( mySketchType == DIR_DXDY_Y ) {
1977 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1978 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1979 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1982 else if ( myConstructorId == 1 ) { // ARC
1983 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1984 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1985 theParameters = myXStr + ":" + myYStr;
1987 if ( mySketchType == PT_RELATIVE) {
1988 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1989 theParameters = myDXStr + ":" + myDYStr;
1991 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1992 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1993 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
1995 if ( mySketchType == PT_REL_RADIUS) {
1996 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1997 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
1999 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2000 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 );
2001 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2003 if ( mySketchType == PT_REL_CENTER) {
2004 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 );
2005 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2007 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2008 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2009 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2010 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2012 if ( mySketchType == DIR_PER_LENGTH ) {
2013 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2014 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2015 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2017 if ( mySketchType == DIR_TAN_LENGTH ) {
2018 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2019 theParameters = myRadiusStr + ":" + myLengthStr;
2021 if ( mySketchType == DIR_DXDY_LENGTH ) {
2022 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2023 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2024 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2027 return myNewCommand;
2030 //=================================================================================
2031 // function : createOperation
2033 //=================================================================================
2034 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2036 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2039 //=================================================================================
2040 // function : isValid
2042 //=================================================================================
2043 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2046 bool toCorrect = !IsPreview() || myIsApply;
2048 if( Group1Spin->isVisible() ) {
2049 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2051 else if( Group1Sel1Spin->isVisible() ) {
2052 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2054 else if( Group2Spin->isVisible() ) {
2055 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2056 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2058 else if( Group3Spin->isVisible() ) {
2059 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2060 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2061 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2063 else if( Group4Spin->isVisible() ) {
2064 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2065 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2066 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2067 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2070 if( myIsApply && !ok )
2076 //=================================================================================
2077 // function : execute
2079 //=================================================================================
2080 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2082 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2083 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2084 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2086 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2087 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2089 QString aParameters;
2091 if ( mySketchState == FIRST_POINT ) {
2096 //Test if the current point is the same as the last one
2097 TopoDS_Shape myShape1, myShape2;
2099 // Set "C" numeric locale
2100 Kernel_Utils::Localizer loc;
2103 QString Command1 = myCommand.join( "" );
2104 Sketcher_Profile aProfile1( Command1.toAscii() );
2105 if ( aProfile1.IsDone() )
2106 myShape1 = aProfile1.GetShape();
2109 QString Command2 = Command1 + GetNewCommand( aParameters );
2110 Sketcher_Profile aProfile2( Command2.toAscii() );
2113 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2114 if (aProfile2.Error() > Precision::Confusion()){
2115 Group4Spin->label->show();
2116 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2119 Group4Spin->label->hide();
2123 Group4Spin->label->hide();
2124 if ( mySketchType == PT_SEL_CENTER ){
2125 if (aProfile2.Error() > Precision::Confusion()){
2126 Group2Sel->label->show();
2127 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2130 Group2Sel->label->hide();
2134 Group2Sel->label->hide();
2136 if ( aProfile2.IsDone() )
2137 myShape2 = aProfile2.GetShape();
2139 if ( myShape2.IsNull() ) {
2140 //the current point is the same as the last one
2141 myLastX2 = myLastX1;
2142 myLastY2 = myLastY1;
2145 TopoDS_Vertex V1, V2;
2147 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2148 //the last shape is the first point
2149 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2154 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2155 pt = BRep_Tool::Pnt( V2 );
2159 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2160 pt = BRep_Tool::Pnt( V2 );
2167 if ( ( mySketchState != FIRST_POINT &&
2168 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2169 cmd = myCommand.join( "" );
2170 if ( Group1Sel->isVisible() ) {
2171 Group1Sel->buttonApply->setEnabled( false );
2172 //Group1Sel->buttonApply->setFocus();
2174 if ( Group2Sel->isVisible() ) {
2175 Group2Sel->buttonApply->setEnabled( false );
2176 //Group2Sel->buttonApply->setFocus();
2178 if ( Group1Sel1Spin->isVisible() ) {
2179 Group1Sel1Spin->buttonApply->setEnabled( false );
2180 //Group1Sel1Spin->buttonApply->setFocus();
2182 if ( Group1Spin->isVisible() ) {
2183 Group1Spin->buttonApply->setEnabled( false );
2184 //Group1Spin->buttonApply->setFocus();
2186 if ( Group2Spin->isVisible() ) {
2187 Group2Spin->buttonApply->setEnabled( false );
2188 //Group2Spin->buttonApply->setFocus();
2190 if ( Group3Spin->isVisible() ) {
2191 Group3Spin->buttonApply->setEnabled( false );
2192 //Group3Spin->buttonApply->setFocus();
2194 if ( Group4Spin->isVisible() ) {
2195 Group4Spin->buttonApply->setEnabled( false );
2196 //Group4Spin->buttonApply->setFocus();
2200 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2202 if ( Group1Sel->isVisible() ) {
2203 Group1Sel->buttonApply->setEnabled( true );
2205 if ( Group2Sel->isVisible() ) {
2206 Group2Sel->buttonApply->setEnabled( true );
2208 if ( Group1Sel1Spin->isVisible() ) {
2209 Group1Sel1Spin->buttonApply->setEnabled( true );;
2211 if ( Group1Spin->isVisible() ) {
2212 Group1Spin->buttonApply->setEnabled( true );
2214 if ( Group2Spin->isVisible() ) {
2215 Group2Spin->buttonApply->setEnabled( true );
2217 if ( Group3Spin->isVisible() ) {
2218 Group3Spin->buttonApply->setEnabled( true );
2220 if ( Group4Spin->isVisible() ) {
2221 Group4Spin->buttonApply->setEnabled( true );
2225 gp_Ax3 myWPlane = GetActiveLocalCS();
2226 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2227 WPlane->length( 9 );
2228 WPlane[0] = myWPlane.Location().X();
2229 WPlane[1] = myWPlane.Location().Y();
2230 WPlane[2] = myWPlane.Location().Z();
2232 WPlane[3] = myWPlane.Direction().X();
2233 WPlane[4] = myWPlane.Direction().Y();
2234 WPlane[5] = myWPlane.Direction().Z();
2236 WPlane[6] = myWPlane.XDirection().X();
2237 WPlane[7] = myWPlane.XDirection().Y();
2238 WPlane[8] = myWPlane.XDirection().Z();
2240 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2241 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2243 if ( !anObj->_is_nil() )
2245 if( !IsPreview() ) {
2246 QStringList aCurrentParameters = myParameters;
2247 aCurrentParameters << aParameters;
2248 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2251 objects.push_back( anObj._retn() );
2257 //================================================================
2258 // Function : displayPreview
2259 // Purpose : Method for displaying preview of resulting shape
2260 // Redefined from GEOMBase_Helper.
2261 //================================================================
2262 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2264 const bool activate,
2266 const double lineWidth,
2267 const int displayMode,
2270 // Set color for preview shape
2271 getDisplayer()->SetColor( Quantity_NOC_RED );
2273 // set width of displayed shape
2274 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2276 // Disable activation of selection
2277 getDisplayer()->SetToActivate( activate );
2279 // Make a reference to GEOM_Object
2280 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2281 getDisplayer()->SetName( objStr.in() );
2283 // Create wire from applayed object
2284 TopoDS_Shape anApplyedWire, aLastSegment;
2285 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2289 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2290 if ( aPrs != 0 && !aPrs->IsNull() )
2291 GEOMBase_Helper::displayPreview( aPrs, append, update );
2293 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2294 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2295 if ( aPrs != 0 && !aPrs->IsNull() )
2296 GEOMBase_Helper::displayPreview( aPrs, append, update );
2298 getDisplayer()->UnsetName();
2300 // Enable activation of displayed objects
2301 getDisplayer()->SetToActivate( true );
2304 //================================================================
2305 // Function : displayPntPreview
2306 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2307 //================================================================
2308 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2314 // Get globalCS and working plane
2315 gp_Ax3 globalCS = myLCSList.first(); //gp_Ax3(aOrigin, aDirZ, aDirX);
2316 gp_Ax3 aWPlane = GetActiveLocalCS();
2318 // Build point in localCS
2319 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2321 // Get transfomation from local to global CS
2323 aTrans.SetTransformation(aWPlane, globalCS);
2325 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2326 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2328 // Perform transformation
2329 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2330 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2332 // Build prs with vertex in globalCS
2333 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2334 if ( aPrs != 0 && !aPrs->IsNull() )
2335 GEOMBase_Helper::displayPreview( aPrs, append, update );
2339 //================================================================
2340 // Function : createShapes
2341 // Purpose : Create applyed wire, and last segment from entry object
2342 //================================================================
2343 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2344 TopoDS_Shape& theApplyedWire,
2345 TopoDS_Shape& theLastSegment )
2347 TopoDS_Shape aShape;
2348 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2349 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2352 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2353 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2354 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2355 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2356 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2357 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2358 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2359 theApplyedWire = aShape;
2363 BRepBuilderAPI_MakeWire aBuilder;
2364 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2366 TopoDS_Shape anEdge = anExp.Current();
2368 if ( anExp.More() ) // i.e. non-last edge
2369 aBuilder.Add( TopoDS::Edge( anEdge ) );
2371 theLastSegment = anEdge;
2376 if ( aBuilder.IsDone() )
2377 theApplyedWire = aBuilder.Shape();
2382 //=================================================================================
2383 // function : keyPressEvent()
2385 //=================================================================================
2386 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2388 QDialog::keyPressEvent( e );
2389 if ( e->isAccepted() )
2392 if ( e->key() == Qt::Key_F1 ) {
2398 //=================================================================================
2399 // function : initSpinBox()
2401 //=================================================================================
2402 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2403 double min, double max,
2404 double step, const char* quantity )
2406 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2407 // TODO: Think how to keep the single piece of code...
2409 // Obtain precision from preferences
2410 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2411 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2413 spinBox->setPrecision( aPrecision );
2414 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2415 // by default Qt rounds boundaries to 2 decimals at setRange
2416 spinBox->setRange( min, max );
2417 spinBox->setSingleStep( step );
2419 // Add a hint for the user saying how to tune precision
2420 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2421 spinBox->setProperty( "validity_tune_hint",
2422 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2425 //=================================================================================
2426 // function : SetDoubleSpinBoxStep()
2427 // purpose : Double spin box management
2428 //=================================================================================
2429 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2431 Group1Spin->SpinBox_DX->setSingleStep(step);
2432 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2433 Group2Spin->SpinBox_DX->setSingleStep(step);
2434 Group2Spin->SpinBox_DY->setSingleStep(step);
2435 Group3Spin->SpinBox_DX->setSingleStep(step);
2436 Group3Spin->SpinBox_DY->setSingleStep(step);
2437 Group3Spin->SpinBox_DZ->setSingleStep(step);
2438 Group4Spin->SpinBox_DZ->setSingleStep(step);
2440 // san: Do NOT override the step when a speicifc step value is used
2441 // in some input fields!
2442 //Group4Spin->SpinBox_DX->setSingleStep(step);
2443 //Group4Spin->SpinBox_DY->setSingleStep(step);
2444 //Group4Spin->SpinBox_DS->setSingleStep(step);
2447 //=================================================================================
2448 // function : FindLocalCS()
2449 // purpose : Find All Coordinates systems in study
2450 //=================================================================================
2451 void EntityGUI_SketcherDlg::FindLocalCS()
2455 SalomeApp_Application* app =
2456 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2460 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2464 _PTR(Study) aStudy = appStudy->studyDS();
2467 ComboBox1->addItem(tr("GEOM_GCS"));
2468 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2469 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2470 gp_Dir aDirX = gp_Dir(1, 0, 0);
2471 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2472 myLCSList.push_back(globalCS);
2474 // get GEOM component
2475 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2476 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2479 _PTR(SComponent) fc = obj->GetFatherComponent();
2480 QString geomComp = fc->GetID().c_str();
2481 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2485 // browse through all GEOM data tree
2486 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2487 for ( it->InitEx( true ); it->More(); it->Next() ) {
2488 _PTR(SObject) child( it->Value() );
2489 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2490 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2491 if( CORBA::is_nil( geomObj ) )
2493 if (geomObj->GetType() == GEOM_MARKER) {
2494 ComboBox1->addItem(geomObj->GetName());
2495 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2498 aLCS.Transform(aShape.Location().Transformation());
2499 if (aShape.ShapeType() == TopAbs_FACE) {
2500 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2501 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2502 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2503 gp_Pln aPln = aGPlane->Pln();
2504 aLCS = aPln.Position();
2507 myLCSList.push_back(aLCS);
2512 //=================================================================================
2513 // function : getPnt1ConstructorId()
2515 //=================================================================================
2516 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2518 int buttonId = GroupPt->ButtonGroup->checkedId();
2519 // MESSAGE("buttonId = "<<buttonId)
2523 //=================================================================================
2524 // function : getPnt2ConstructorId()
2526 //=================================================================================
2527 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2529 int buttonId = GroupPt2->ButtonGroup->checkedId();
2530 // MESSAGE("buttonId = "<<buttonId)
2534 //=================================================================================
2535 // function : GetActiveLocalCS()
2536 // purpose : Get Working plane
2537 //=================================================================================
2538 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2540 int ind = ComboBox1->currentIndex();
2542 return myGeometryGUI->GetWorkingPlane();
2544 gp_Ax3 aLCS = myLCSList.at(ind);
2549 //=================================================================================
2550 // function : ActivateLocalCS()
2551 // purpose : Activate & Fit Working plane
2552 //=================================================================================
2553 void EntityGUI_SketcherDlg::ActivateLocalCS()
2555 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2556 myGeometryGUI->ActiveWorkingPlane();