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 <Sketcher_Profile.hxx>
56 #include <SalomeApp_Study.h>
60 #include <Basics_Utils.hxx>
62 //=================================================================================
63 // class : EntityGUI_SketcherDlg()
64 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
65 // name 'name' and widget flags set to 'f'.
66 // The dialog will by default be modeless, unless you set 'modal' to
67 // TRUE to construct a modal dialog.
68 //=================================================================================
69 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
70 bool modal, Qt::WindowFlags fl,
71 const double lineWidth )
72 : QDialog( parent, fl ),
73 myIsAllAdded( false ),
75 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
77 myLineWidth( lineWidth )
80 setAttribute( Qt::WA_DeleteOnClose );
82 myGeometryGUI->SetActiveDialogBox(this);
84 MainWidget = new EntityGUI_Skeleton( this );
85 QVBoxLayout* topLayout = new QVBoxLayout( this );
86 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
88 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
89 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
90 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
91 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
93 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
94 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
95 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
97 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
99 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
100 MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) );
101 MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) );
102 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
103 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
104 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
105 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
107 /***************************************************************/
109 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
110 QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
111 planeLayout->setSpacing(6);
112 planeLayout->setMargin(11);
114 ComboBox1 = new QComboBox(GroupBox1);
115 ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
116 planeLayout->addWidget(ComboBox1);
118 planeButton = new QPushButton (GroupBox1);
119 planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
120 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
121 planeLayout->addWidget(planeButton);
123 topLayout->addWidget(GroupBox1);
124 topLayout->addWidget( MainWidget );
125 topLayout->setStretch( 1, 1);
127 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
129 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
130 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
131 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
132 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
134 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
136 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
137 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
138 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
139 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
141 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
143 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
144 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
145 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
146 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
147 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
149 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
151 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
152 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
153 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
154 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
156 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
157 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
158 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
159 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
160 Group1Sel->PushButton1->setIcon( image0 );
161 Group1Sel->buttonUndo->setIcon( image1 );
162 Group1Sel->buttonRedo->setIcon( image2 );
163 Group1Sel->LineEdit1->setReadOnly( true );
165 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
166 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
167 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
168 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
169 Group2Sel->PushButton1->setIcon( image0 );
170 Group2Sel->PushButton2->setIcon( image0 );
171 Group2Sel->buttonUndo->setIcon( image1 );
172 Group2Sel->buttonRedo->setIcon( image2 );
173 Group2Sel->LineEdit1->setReadOnly( true );
174 Group2Sel->LineEdit2->setReadOnly( true );
176 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
177 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
178 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
179 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
180 Group1Sel1Spin->PushButton1->setIcon( image0 );
181 Group1Sel1Spin->buttonUndo->setIcon( image1 );
182 Group1Sel1Spin->buttonRedo->setIcon( image2 );
183 Group1Sel1Spin->LineEdit1->setReadOnly( true );
185 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
186 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
187 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
188 Group1Spin->buttonUndo->setIcon( image1 );
189 Group1Spin->buttonRedo->setIcon( image2 );
191 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
192 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
193 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
194 Group2Spin->buttonUndo->setIcon( image1 );
195 Group2Spin->buttonRedo->setIcon( image2 );
197 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
198 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
199 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
200 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
201 Group3Spin->buttonUndo->setIcon( image1 );
202 Group3Spin->buttonRedo->setIcon( image2 );
204 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
205 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
206 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
207 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
208 Group4Spin->buttonUndo->setIcon( image1 );
209 Group4Spin->buttonRedo->setIcon( image2 );
211 // Defines a palette for the error message on Group4Spin and Group2Sel
214 palette.setColor(Group4Spin->label->foregroundRole(), color);
215 Group4Spin->label->setPalette(palette);
216 palette.setColor(Group2Sel->label->foregroundRole(), color);
217 Group2Sel->label->setPalette(palette);
219 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
220 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
221 DestCntLayout->addWidget( GroupPt, 0, 0 );
222 DestCntLayout->addWidget( GroupPt2, 0, 1 );
223 DestCntLayout->addWidget( GroupD1, 0, 0 );
224 DestCntLayout->addWidget( GroupD2, 0, 1 );
226 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
227 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
228 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
229 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
230 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
231 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
232 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
233 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
234 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
235 //SkeletonCntlayout->setStretch( 0, 1);
236 /***************************************************************/
238 QButtonGroup* ButtonGroup = new QButtonGroup( this );
239 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
240 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
242 /* signals and slots connections */
243 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
244 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
245 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
246 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
248 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
249 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
250 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
251 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
252 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
253 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
254 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
255 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
256 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
257 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
258 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
259 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
260 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
261 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
262 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
263 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
264 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
265 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
266 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
267 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
268 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
270 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
271 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
272 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
273 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
274 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
275 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
277 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
278 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
280 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
281 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
282 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
283 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
285 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
286 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
287 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
289 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
290 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
291 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
292 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
293 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
294 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
295 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
296 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
297 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
298 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
300 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
301 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
302 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
303 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
305 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
306 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
308 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
310 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
311 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
313 // install event filter on spin-boxes to provide Apply action on Return pressed
314 Group1Spin->SpinBox_DX->installEventFilter(this);
315 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
316 Group2Spin->SpinBox_DX->installEventFilter(this);
317 Group2Spin->SpinBox_DY->installEventFilter(this);
318 Group3Spin->SpinBox_DX->installEventFilter(this);
319 Group3Spin->SpinBox_DY->installEventFilter(this);
320 Group3Spin->SpinBox_DZ->installEventFilter(this);
321 Group4Spin->SpinBox_DX->installEventFilter(this);
322 Group4Spin->SpinBox_DY->installEventFilter(this);
323 Group4Spin->SpinBox_DZ->installEventFilter(this);
324 Group4Spin->SpinBox_DS->installEventFilter(this);
330 //=================================================================================
331 // function : ~EntityGUI_SketcherDlg()
332 // purpose : Destroys the object and frees any allocated resources
333 //=================================================================================
334 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
336 myGeometryGUI->SetActiveDialogBox( 0 );
340 //=================================================================================
341 // function : eventFilter()
342 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
343 //=================================================================================
344 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
346 if (event->type() == QEvent::KeyPress) {
347 QKeyEvent* ke = (QKeyEvent*)event;
348 if (ke->key() == Qt::Key_Return) {
349 if (object == Group1Spin->SpinBox_DX) {
350 Group1Spin->buttonApply->animateClick();
352 } else if (object == Group1Sel1Spin->SpinBox_DX) {
353 Group1Sel1Spin->buttonApply->animateClick();
355 } else if (object == Group2Spin->SpinBox_DX ||
356 object == Group2Spin->SpinBox_DY) {
357 Group2Spin->buttonApply->animateClick();
359 } else if (object == Group3Spin->SpinBox_DX ||
360 object == Group3Spin->SpinBox_DY ||
361 object == Group3Spin->SpinBox_DZ) {
362 Group3Spin->buttonApply->animateClick();
364 } else if (object == Group4Spin->SpinBox_DX ||
365 object == Group4Spin->SpinBox_DY ||
366 object == Group4Spin->SpinBox_DZ ||
367 object == Group4Spin->SpinBox_DS) {
368 Group4Spin->buttonApply->animateClick();
374 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
376 return QDialog::eventFilter(object, event);
380 //=================================================================================
383 //=================================================================================
384 void EntityGUI_SketcherDlg::Init()
387 myEditCurrentArgument = Group1Sel->LineEdit1;
388 myCommand.append( "Sketcher" );
389 myUndoCommand.append( "Sketcher" );
391 mySketchState = FIRST_POINT;
392 globalSelection( GEOM_POINT );
401 myHelpFileName = "create_sketcher_page.html";
403 /* Get setting of step value from file configuration */
404 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
406 /* min, max, step and decimals for spin boxes */
407 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
408 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
409 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
410 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
411 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
412 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
413 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
414 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
415 // san: Note specific step values below!
416 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
417 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
418 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
420 /* displays Dialog */
421 MainWidget->GroupConstructors->setEnabled( false );
422 MainWidget->GroupDest1->setEnabled( false );
423 setEnabledUndo( false );
424 setEnabledRedo( false );
426 MainWidget->RadioButton1->setChecked( true );
434 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
438 //=================================================================================
439 // function : InitClick()
441 //=================================================================================
442 void EntityGUI_SketcherDlg::InitClick()
444 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
449 Group1Sel1Spin->hide();
457 //=================================================================================
458 // function : TypeClicked()
459 // purpose : Radio button management
460 //=================================================================================
461 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
463 myConstructorId = constructorId;
464 if ( myConstructorId == 0 ) { // SEGMENT
465 GroupPt2->RB_Point1->setChecked( true );
466 GroupPt2->setEnabled( false );
467 GroupD2->setEnabled( true );
468 MainWidget->RB_Dest1->setEnabled( true );
469 MainWidget->RB_Dest1->setChecked( true );
472 else if ( myConstructorId == 1 ) { // ARC
473 GroupPt2->setEnabled( true );
474 GroupD2->RB_Dir21->setChecked( true );
475 GroupD2->setEnabled( false );
476 MainWidget->RB_Dest1->setEnabled( true );
477 MainWidget->RB_Dest1->setChecked( true );
483 //=================================================================================
484 // function : DestClicked()
485 // purpose : Radio button management
486 //=================================================================================
487 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
494 if ( constructorId == 1 ) {
496 GroupPt->RB_Point1->setChecked( true );
499 Group3Spin->checkBox->show();
500 Group4Spin->checkBox->show();
501 PointClicked( 1 ); // XY
503 else if ( constructorId == 0 ) {
505 GroupD1->RB_Dir11->setChecked( true );
508 Group3Spin->checkBox->hide();
509 Group4Spin->checkBox->hide();
510 Dir1Clicked( 2 ); // Angle
512 resize( minimumSizeHint() );
515 //=================================================================================
516 // function : PointClicked()
517 // purpose : Radio button management
518 //=================================================================================
519 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
521 MESSAGE("PointClicked")
522 myConstructorPntId = constructorId;
523 GroupPt->RB_Point3->setEnabled( true );
524 int buttonId = GroupPt2->ButtonGroup->checkedId();
525 MESSAGE("checkedId ="<< buttonId)
526 if (buttonId >= 0){ // = If a button is checked
527 Point2Clicked(buttonId);
530 GroupPt2->RB_Point1->setChecked( true );
535 //=================================================================================
536 // function : Point2Clicked()
537 // purpose : Radio button management
538 //=================================================================================
539 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
541 MESSAGE("Point2Clicked")
544 // Get setting of step value from file configuration
545 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
547 if ( myConstructorPntId == 1 ) { // XY
548 if ( constructorId == 1 ){ // No additional parameter
549 mySketchType = PT_ABS;
550 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
551 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
552 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
553 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
555 Group2Spin->SpinBox_DX->setValue( myX );
557 Group2Spin->SpinBox_DY->setValue( myY );
559 Group2Spin->buttonApply->setFocus();
561 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
563 else if ( constructorId == 0 ){ // Point + radius
564 mySketchType = PT_ABS_RADIUS;
565 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
566 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
567 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
568 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
569 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
570 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
572 Group3Spin->SpinBox_DX->setValue( myX );
574 Group3Spin->SpinBox_DY->setValue( myY );
576 Group3Spin->SpinBox_DZ->setValue( myRadius );
578 Group3Spin->buttonApply->setFocus();
580 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
582 else if ( constructorId == 2 ){ // Point + center
583 mySketchType = PT_ABS_CENTER;
584 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
585 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
586 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
587 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
588 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
589 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
590 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
591 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
593 Group4Spin->SpinBox_DX->setValue( myXc );
595 Group4Spin->SpinBox_DY->setValue( myYc );
597 Group4Spin->SpinBox_DZ->setValue( myX );
599 Group4Spin->SpinBox_DS->setValue( myY );
601 Group4Spin->buttonApply->setFocus();
603 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
607 else if ( myConstructorPntId == 0 ) { // DXDY
608 if ( constructorId == 1 ){ // No additional parameter
609 mySketchType = PT_RELATIVE;
610 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
611 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
612 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
613 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
615 Group2Spin->SpinBox_DX->setValue( myDX );
617 Group2Spin->SpinBox_DY->setValue( myDY );
619 Group2Spin->buttonApply->setFocus();
621 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
623 else if ( constructorId == 0 ){ // Point + radius
624 mySketchType = PT_REL_RADIUS;
625 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
626 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
627 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
628 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
629 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
630 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
632 Group3Spin->SpinBox_DX->setValue( myDX );
634 Group3Spin->SpinBox_DY->setValue( myDY );
636 Group3Spin->SpinBox_DZ->setValue( myRadius );
638 Group3Spin->buttonApply->setFocus();
640 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
642 else if ( constructorId == 2 ){ // Point + center
643 mySketchType = PT_REL_CENTER;
644 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
645 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
646 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
647 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
648 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
649 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
650 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
651 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
653 Group4Spin->SpinBox_DX->setValue( myDXc );
655 Group4Spin->SpinBox_DY->setValue( myDYc );
657 Group4Spin->SpinBox_DZ->setValue( myDX );
659 Group4Spin->SpinBox_DS->setValue( myDY );
661 Group4Spin->buttonApply->setFocus();
663 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
667 else if ( myConstructorPntId == 2 ) { // Selection
668 if ( constructorId == 1 ){ // No additional parameter
669 mySketchType = PT_SEL;
670 myEditCurrentArgument = Group1Sel->LineEdit1;
671 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
673 Group1Sel->buttonApply->setFocus();
674 SelectionIntoArgument();
676 else if ( constructorId == 0 ){ // Point + radius
677 mySketchType = PT_SEL_RADIUS;
678 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
679 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
680 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
681 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
683 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
685 Group1Sel1Spin->show();
686 Group1Sel1Spin->buttonApply->setFocus();
687 SelectionIntoArgument();
689 else if ( constructorId == 2 ){ // Point + center
690 mySketchType = PT_SEL_CENTER;
691 myEditCurrentArgument = Group2Sel->LineEdit1;
692 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
693 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
694 Group2Sel->LineEdit1->setEnabled(true);
695 Group2Sel->PushButton1->setDown(true);
696 Group2Sel->LineEdit2->setEnabled(false);
697 Group2Sel->PushButton2->setDown(false);
699 Group2Sel->buttonApply->setFocus();
700 SelectionIntoArgument();
704 resize( minimumSizeHint() );
705 connect( myGeometryGUI->getApp()->selectionMgr(),
706 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
711 //=================================================================================
712 // function : Dir1Clicked()
713 // purpose : Radio button management
714 //=================================================================================
715 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
717 myConstructorDirId = constructorId;
718 int dirButtonId = GroupD2->ButtonGroup->checkedId();
719 MESSAGE("checkedId ="<< dirButtonId)
720 if (dirButtonId >= 0){ // = If a button is checked
721 Dir2Clicked(dirButtonId);
724 GroupD2->RB_Dir21->setChecked( true );
730 //=================================================================================
731 // function : Dir2Clicked()
732 // purpose : Radio button management
733 //=================================================================================
734 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
739 // Get setting of step value from file configuration
740 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
742 if ( myConstructorId == 0 ) { // SEGMENT
746 if ( myConstructorDirId == 2 ) { // Angle
747 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
748 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
749 Group2Spin->SpinBox_DX->setValue( myAngle );
750 Group2Spin->buttonApply->setFocus();
753 if ( constructorId == 2 ) { // Length
754 mySketchType = DIR_ANGLE_LENGTH;
755 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
756 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
757 Group2Spin->SpinBox_DY->setValue( myLength );
759 else if ( constructorId == 0 ) { // X
760 mySketchType = DIR_ANGLE_X;
761 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
762 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
763 Group2Spin->SpinBox_DY->setValue( myX );
765 else if ( constructorId == 1 ) { // Y
766 mySketchType = DIR_ANGLE_Y;
767 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
768 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
769 Group2Spin->SpinBox_DY->setValue( myY );
772 else if ( myConstructorDirId == 0 ) { // Perpendicular
774 Group1Spin->buttonApply->setFocus();
776 if ( constructorId == 2 ) { // Length
777 mySketchType = DIR_PER_LENGTH;
778 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
779 Group1Spin->SpinBox_DX->setValue( myLength );
781 else if ( constructorId == 0 ) { // X
782 mySketchType = DIR_PER_X;
783 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
784 Group1Spin->SpinBox_DX->setValue( myX );
786 else if ( constructorId == 1 ) { // Y
787 mySketchType = DIR_PER_Y;
788 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
789 Group1Spin->SpinBox_DX->setValue( myY );
792 else if ( myConstructorDirId == 1 ) { // Tangent
794 Group1Spin->buttonApply->setFocus();
796 if ( constructorId == 2 ) { // Length
797 mySketchType = DIR_TAN_LENGTH;
798 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
799 Group1Spin->SpinBox_DX->setValue( myLength );
801 else if ( constructorId == 0 ) { // X
802 mySketchType = DIR_TAN_X;
803 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
804 Group1Spin->SpinBox_DX->setValue( myX );
806 else if ( constructorId == 1 ) { // Y
807 mySketchType = DIR_TAN_Y;
808 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
809 Group1Spin->SpinBox_DX->setValue( myY );
812 else if ( myConstructorDirId == 3 ) { // DXDY
813 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
814 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
815 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
816 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
817 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
819 Group3Spin->SpinBox_DX->setValue( myDX );
821 Group3Spin->SpinBox_DY->setValue( myDY );
823 Group3Spin->buttonApply->setFocus();
825 if ( constructorId == 2 ) { // Length
826 mySketchType = DIR_DXDY_LENGTH;
827 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
828 Group3Spin->SpinBox_DZ->setValue( myLength );
830 else if ( constructorId == 0 ) { // X
831 mySketchType = DIR_DXDY_X;
832 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
833 Group3Spin->SpinBox_DZ->setValue( myX );
835 else if ( constructorId == 1 ) { // Y
836 mySketchType = DIR_DXDY_Y;
837 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
838 Group3Spin->SpinBox_DZ->setValue( myY );
842 else if ( myConstructorId == 1 ) { // ARC
843 if ( myConstructorDirId == 2 ) { // Angle
844 if ( constructorId == 2 ) { // Length
845 mySketchType = DIR_ANGLE_LENGTH;
846 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
847 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
848 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
849 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
850 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
851 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
852 Group3Spin->SpinBox_DX->setValue( myAngle );
854 Group3Spin->SpinBox_DY->setValue( myRadius );
856 Group3Spin->SpinBox_DZ->setValue( myLength );
858 Group3Spin->buttonApply->setFocus();
861 else if ( myConstructorDirId == 0 ) { // Perpendicular
862 if ( constructorId == 2 ) { // Length
863 mySketchType = DIR_PER_LENGTH;
864 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
865 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
866 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
867 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
869 Group2Spin->SpinBox_DX->setValue( myRadius );
871 Group2Spin->SpinBox_DY->setValue( myLength );
873 Group2Spin->buttonApply->setFocus();
876 else if ( myConstructorDirId == 1 ) { // Tangent
877 if ( constructorId == 2 ) { // Length
878 mySketchType = DIR_TAN_LENGTH;
879 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
880 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
881 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
882 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
884 Group2Spin->SpinBox_DX->setValue( myRadius );
886 Group2Spin->SpinBox_DY->setValue( myLength );
888 Group2Spin->buttonApply->setFocus();
891 else if ( myConstructorDirId == 3 ) { // DXDY
892 if ( constructorId == 2 ) { // Length
893 mySketchType = DIR_DXDY_LENGTH;
894 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
895 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
896 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
897 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
898 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
899 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
900 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
901 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
903 Group4Spin->SpinBox_DX->setValue( myDX );
905 Group4Spin->SpinBox_DY->setValue( myDY );
907 Group4Spin->SpinBox_DZ->setValue( myRadius );
909 Group4Spin->SpinBox_DS->setValue( myLength );
911 Group4Spin->buttonApply->setFocus();
915 resize( minimumSizeHint() );
916 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
919 //=================================================================================
920 // function : CheckBoxClicked()
921 // purpose : CheckBox management
922 //=================================================================================
923 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
927 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
931 //=================================================================================
932 // function : ClickOnCancel()
934 //=================================================================================
935 void EntityGUI_SketcherDlg::ClickOnCancel()
941 //=================================================================================
942 // function : ClickOnEnd()
943 // purpose : connected to buttonEnd AND buttonClose
944 //=================================================================================
945 void EntityGUI_SketcherDlg::ClickOnEnd()
947 if ( sender() == MainWidget->buttonClose ) {
948 // Verify validity of commands
949 if ( myCommand.count() <= 2 ) {
950 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
951 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
956 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
957 Sketcher_Profile aProfile( Command.toAscii() );
959 Command = myCommand.join( "" );
960 aProfile = Sketcher_Profile( Command.toAscii() );
961 TopoDS_Shape myShape;
962 if ( aProfile.IsDone() )
963 myShape = aProfile.GetShape();
965 if ( myShape.ShapeType() != TopAbs_VERTEX )
966 myCommand.append( ":WW" );
969 // PAL16008 (Sketcher Validation should be equal to Apply&Close)
970 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
971 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
972 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
973 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
974 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
975 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
976 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
982 if ( myCommand.size() > 2 )
989 //=================================================================================
990 // function : ClickOnApply()
992 //=================================================================================
993 bool EntityGUI_SketcherDlg::ClickOnApply()
995 if ( sender() && sender()->inherits( "QPushButton" ) )
996 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
999 myCommand.append( GetNewCommand( aParameters ) );
1000 mySketchState = NEXT_POINT;
1002 myUndoCommand.clear();
1003 myUndoCommand.append( "Sketcher" );
1005 myParameters.append( aParameters );
1006 myUndoParameters.clear();
1008 MainWidget->GroupConstructors->setEnabled( true );
1009 MainWidget->GroupDest1->setEnabled( true );
1010 setEnabledUndo( true );
1011 setEnabledRedo( false );
1014 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1017 // Set focus to SpinBox_DX
1018 if ( sender() == Group1Spin->buttonApply ) {
1019 (Group1Spin->SpinBox_DX)->setFocus();
1020 (Group1Spin->SpinBox_DX)->selectAll();
1022 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1023 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1024 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1026 else if ( sender() == Group2Spin->buttonApply ) {
1027 (Group2Spin->SpinBox_DX)->setFocus();
1028 (Group2Spin->SpinBox_DX)->selectAll();
1030 else if ( sender() == Group3Spin->buttonApply ) {
1031 (Group3Spin->SpinBox_DX)->setFocus();
1032 (Group3Spin->SpinBox_DX)->selectAll();
1034 else if ( sender() == Group4Spin->buttonApply ) {
1035 (Group4Spin->SpinBox_DX)->setFocus();
1036 (Group4Spin->SpinBox_DX)->selectAll();
1042 //=================================================================================
1043 // function : ClickOnHelp()
1045 //=================================================================================
1046 void EntityGUI_SketcherDlg::ClickOnHelp()
1048 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1050 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1054 platform = "winapplication";
1056 platform = "application";
1059 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1060 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1061 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1062 QObject::tr( "BUT_OK" ) );
1066 //=================================================================================
1067 // function : ClickOnUndo()
1069 //=================================================================================
1070 void EntityGUI_SketcherDlg::ClickOnUndo()
1072 myUndoCommand.append( myCommand.last() );
1073 myCommand.pop_back();
1075 myUndoParameters.append( myParameters.last() );
1076 myParameters.pop_back();
1078 if ( myCommand.count() == 1 ) {
1079 mySketchState = FIRST_POINT;
1081 MainWidget->RadioButton1->setChecked( true );
1084 connect( myGeometryGUI->getApp()->selectionMgr(),
1085 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1087 MainWidget->GroupConstructors->setEnabled( false );
1088 MainWidget->GroupDest1->setEnabled( false );
1089 setEnabledUndo( false );
1092 setEnabledRedo( true );
1094 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1097 //=================================================================================
1098 // function : ClickOnRedo()
1100 //=================================================================================
1101 void EntityGUI_SketcherDlg::ClickOnRedo()
1103 myCommand.append( myUndoCommand.last() );
1104 myUndoCommand.pop_back();
1106 myParameters.append( myUndoParameters.last() );
1107 myUndoParameters.pop_back();
1109 mySketchState = NEXT_POINT;
1111 MainWidget->GroupConstructors->setEnabled( true );
1112 MainWidget->GroupDest1->setEnabled( true );
1113 setEnabledUndo( true );
1115 if ( myUndoCommand.count() == 1 )
1116 setEnabledRedo( false );
1118 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1121 //=================================================================================
1122 // function : setEnabledUndo()
1124 //=================================================================================
1125 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1127 Group1Sel->buttonUndo->setEnabled( value );
1128 Group2Sel->buttonUndo->setEnabled( value );
1129 Group1Sel1Spin->buttonUndo->setEnabled( value );
1130 Group1Spin->buttonUndo->setEnabled( value );
1131 Group2Spin->buttonUndo->setEnabled( value );
1132 Group3Spin->buttonUndo->setEnabled( value );
1133 Group4Spin->buttonUndo->setEnabled( value );
1136 //=================================================================================
1137 // function : setEnabledRedo()
1139 //=================================================================================
1140 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1142 Group1Sel->buttonRedo->setEnabled( value );
1143 Group2Sel->buttonRedo->setEnabled( value );
1144 Group1Sel1Spin->buttonRedo->setEnabled( value );
1145 Group1Spin->buttonRedo->setEnabled( value );
1146 Group2Spin->buttonRedo->setEnabled( value );
1147 Group3Spin->buttonRedo->setEnabled( value );
1148 Group4Spin->buttonRedo->setEnabled( value );
1151 //=================================================================================
1152 // function : SelectionIntoArgument()
1153 // purpose : Called when selection as changed
1154 //=================================================================================
1155 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1157 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1158 myEditCurrentArgument->setText( "" );
1163 // printf ("\nmyX = %f myY = %f", myX, myY);
1164 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
1165 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
1167 if ( sender() == ComboBox1 )
1170 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1171 SALOME_ListIO aSelList;
1172 aSelMgr->selectedObjects(aSelList);
1174 int nbSel = aSelList.Extent();
1175 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);
1358 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1362 //=================================================================================
1363 // function : SetEditCurrentArgument()
1365 //=================================================================================
1366 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1368 if ( sender() == Group1Sel->PushButton1 ) {
1369 myEditCurrentArgument = Group1Sel->LineEdit1;
1370 myEditCurrentArgument->setFocus();
1372 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1373 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1374 myEditCurrentArgument->setFocus();
1376 else if ( sender() == Group2Sel->PushButton1 ) {
1377 myEditCurrentArgument = Group2Sel->LineEdit1;
1378 Group2Sel->PushButton2->setDown(false);
1379 Group2Sel->PushButton1->setDown(true);
1380 Group2Sel->LineEdit2->setEnabled(false);
1381 Group2Sel->LineEdit1->setEnabled(true);
1382 // myEditCurrentArgument->setFocus();
1384 else if ( sender() == Group2Sel->PushButton2 ) {
1385 myEditCurrentArgument = Group2Sel->LineEdit2;
1386 Group2Sel->PushButton1->setDown(false);
1387 Group2Sel->PushButton2->setDown(true);
1388 Group2Sel->LineEdit1->setEnabled(false);
1389 Group2Sel->LineEdit2->setEnabled(true);
1390 // myEditCurrentArgument->setFocus();
1392 SelectionIntoArgument();
1396 //=================================================================================
1397 // function : LineEditReturnPressed()
1399 //=================================================================================
1400 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1402 if ( sender() == Group1Sel->LineEdit1 )
1403 myEditCurrentArgument = Group1Sel->LineEdit1;
1404 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1405 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1406 else if ( sender() == Group2Sel->LineEdit1 )
1407 myEditCurrentArgument = Group2Sel->LineEdit1;
1408 else if ( sender() == Group2Sel->LineEdit2 )
1409 myEditCurrentArgument = Group2Sel->LineEdit2;
1411 /* User name of object input management */
1412 /* If successfull the selection is changed and signal emitted... */
1413 /* so SelectionIntoArgument() is automatically called. */
1414 const QString objectUserName = myEditCurrentArgument->text();
1415 QWidget* thisWidget = (QWidget*)this;
1417 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1418 SALOME_ListIO aSelList;
1419 aSelMgr->selectedObjects(aSelList);
1421 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1422 myEditCurrentArgument->setText( objectUserName );
1426 //=================================================================================
1427 // function : DeactivateActiveDialog()
1429 //=================================================================================
1430 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1432 //myGeometryGUI->SetState( -1 );
1434 setEnabled( false );
1436 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1437 myGeometryGUI->SetActiveDialogBox( 0 );
1441 //=================================================================================
1442 // function : ActivateThisDialog()
1444 //=================================================================================
1445 void EntityGUI_SketcherDlg::ActivateThisDialog()
1447 myGeometryGUI->EmitSignalDeactivateDialog();
1449 myGeometryGUI->SetActiveDialogBox( this );
1451 connect( myGeometryGUI->getApp()->selectionMgr(),
1452 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1454 //myGeometryGUI->SetState( 0 );
1455 globalSelection( GEOM_POINT );
1457 myEditCurrentArgument = Group1Sel->LineEdit1;
1458 myEditCurrentArgument->setFocus();
1460 if ( sender() == Group1Sel->LineEdit1 ) {
1461 myEditCurrentArgument = Group1Sel->LineEdit1;
1462 myEditCurrentArgument->setFocus();
1464 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1465 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1466 myEditCurrentArgument->setFocus();
1468 else if ( sender() == Group2Sel->LineEdit1 ) {
1469 myEditCurrentArgument = Group2Sel->LineEdit1;
1470 myEditCurrentArgument->setFocus();
1472 else if ( sender() == Group2Sel->LineEdit2 ) {
1473 myEditCurrentArgument = Group2Sel->LineEdit2;
1474 myEditCurrentArgument->setFocus();
1477 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1481 //=================================================================================
1482 // function : enterEvent [REDEFINED]
1484 //=================================================================================
1485 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1488 ActivateThisDialog();
1492 //=================================================================================
1493 // function : closeEvent()
1495 //=================================================================================
1496 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1498 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1499 //myGeometryGUI->SetState( -1 );
1500 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1501 myGeometryGUI->getApp()->updateActions();
1502 QDialog::closeEvent( e );
1506 //=================================================================================
1507 // function : OnPointSelected
1509 //=================================================================================
1510 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt)
1512 MESSAGE("EntityGUI_SketcherDlg::OnPointSelected")
1513 switch (getPnt2ConstructorId()){
1515 Group2Spin->SpinBox_DX->setValue( thePnt.X() );
1516 Group2Spin->SpinBox_DY->setValue( thePnt.Y() );
1519 Group3Spin->SpinBox_DX->setValue( thePnt.X() );
1520 Group3Spin->SpinBox_DY->setValue( thePnt.Y() );
1523 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1524 Group4Spin->SpinBox_DX->setValue( thePnt.X() );
1525 Group4Spin->SpinBox_DY->setValue( thePnt.Y() );
1527 else{ // The select end point
1528 Group4Spin->SpinBox_DZ->setValue( thePnt.X() );
1529 Group4Spin->SpinBox_DS->setValue( thePnt.Y() );
1535 //=================================================================================
1536 // function : ValueChangedInSpinBox()
1538 //=================================================================================
1539 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1541 MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
1542 QObject* send = (QObject*)sender();
1543 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1544 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1546 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1547 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1548 double LastDecimal = 0.0;
1550 QString vxStr, vyStr, vzStr, vsStr;
1552 QString newValueStr;
1553 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1554 newValueStr = aDoubleSpinBox->text();
1556 if ( send == Group1Spin->SpinBox_DX ) {
1557 vx = newValue; vxStr = newValueStr;
1559 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1560 vx = newValue; vxStr = newValueStr;
1562 else if ( send == Group2Spin->SpinBox_DX ) {
1563 vx = newValue; vxStr = newValueStr;
1564 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1566 else if ( send == Group2Spin->SpinBox_DY ) {
1567 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1568 vy = newValue; vyStr = newValueStr;
1570 else if ( send == Group3Spin->SpinBox_DX ) {
1571 vx = newValue; vxStr = newValueStr;
1572 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1573 vz = Group3Spin->SpinBox_DZ->value();
1574 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1575 if (mySketchType == PT_ABS_RADIUS){
1583 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1584 if (aPrecision >= 0) // 'f' format in the QString
1585 LastDecimal = aPrecision;
1586 else // 'g' format in the Qstring
1587 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1588 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1589 if ( Abs(vz) < minRad){
1591 Group3Spin->SpinBox_DZ->setValue( - minRad );
1593 Group3Spin->SpinBox_DZ->setValue( minRad );
1596 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1598 else if ( send == Group3Spin->SpinBox_DY ) {
1599 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1600 vy = newValue; vyStr = newValueStr;
1601 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1602 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1603 if (mySketchType == PT_ABS_RADIUS){
1611 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1612 if (aPrecision >= 0) // 'f' format in the QString
1613 LastDecimal = aPrecision;
1614 else // 'g' format in the QString
1615 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1616 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1617 if ( Abs(vz) < minRad){
1619 Group3Spin->SpinBox_DZ->setValue( - minRad );
1621 Group3Spin->SpinBox_DZ->setValue( minRad );
1624 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1626 else if ( send == Group3Spin->SpinBox_DZ ) {
1627 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1628 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1629 vz = newValue; vzStr = newValueStr;
1631 else if ( send == Group4Spin->SpinBox_DX ) {
1632 vx = newValue; vxStr = newValueStr;
1633 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1634 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1635 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1637 else if ( send == Group4Spin->SpinBox_DY ) {
1638 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1639 vy = newValue; vyStr = newValueStr;
1640 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1641 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1643 else if ( send == Group4Spin->SpinBox_DZ ) {
1644 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1645 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1646 vz = newValue; vzStr = newValueStr;
1647 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1649 else if ( send == Group4Spin->SpinBox_DS ) {
1650 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1651 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1652 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1653 vs = newValue; vsStr = newValueStr;
1655 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1657 if ( myConstructorId == 0 ) { // SEGMENT
1658 if ( mySketchType == PT_ABS ) {
1664 else if ( mySketchType == PT_RELATIVE ) {
1670 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1674 myLengthStr = vyStr;
1676 else if ( mySketchType == DIR_ANGLE_X ) {
1682 else if ( mySketchType == DIR_ANGLE_Y ) {
1688 else if ( mySketchType == DIR_PER_LENGTH ) {
1690 myLengthStr = vxStr;
1692 else if ( mySketchType == DIR_PER_X ) {
1696 else if ( mySketchType == DIR_PER_Y ) {
1700 else if ( mySketchType == DIR_TAN_LENGTH ) {
1702 myLengthStr = vxStr;
1704 else if ( mySketchType == DIR_TAN_X ) {
1708 else if ( mySketchType == DIR_TAN_Y ) {
1712 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1718 myLengthStr = vzStr;
1720 else if ( mySketchType == DIR_DXDY_X ) {
1728 else if ( mySketchType == DIR_DXDY_Y ) {
1737 else if ( myConstructorId == 1 ) { // ARC
1738 if ( mySketchType == PT_ABS ) {
1744 else if ( mySketchType == PT_RELATIVE ) {
1750 if ( mySketchType == PT_ABS_RADIUS ) {
1756 myRadiusStr = vzStr;
1758 else if ( mySketchType == PT_REL_RADIUS ) {
1764 myRadiusStr = vzStr;
1766 else if ( mySketchType == PT_SEL_RADIUS ) {
1768 myRadiusStr = vxStr;
1770 if ( mySketchType == PT_ABS_CENTER ) {
1780 else if ( mySketchType == PT_REL_CENTER ) {
1790 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1795 myRadiusStr = vyStr;
1796 myLengthStr = vzStr;
1798 else if ( mySketchType == DIR_PER_LENGTH ) {
1801 myRadiusStr = vxStr;
1802 myLengthStr = vyStr;
1804 else if ( mySketchType == DIR_TAN_LENGTH ) {
1807 myRadiusStr = vxStr;
1808 myLengthStr = vyStr;
1810 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1817 myRadiusStr = vzStr;
1818 myLengthStr = vsStr;
1822 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1826 //=================================================================================
1827 // function : GetNewCommand()
1828 // purpose : Build the new command with context
1829 //=================================================================================
1830 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1832 theParameters.clear();
1833 QString myNewCommand = ":";
1834 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1835 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1836 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1838 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1839 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1841 if ( mySketchState == FIRST_POINT ) {
1842 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1843 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1844 theParameters = myXStr + ":" + myYStr;
1846 if ( mySketchType == PT_RELATIVE) {
1847 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1848 theParameters = myDXStr + ":" + myDYStr;
1850 return myNewCommand;
1853 if ( myConstructorId == 0 ) { // SEGMENT
1854 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1855 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1856 theParameters = myXStr + ":" + myYStr;
1858 if ( mySketchType == PT_RELATIVE) {
1859 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1860 theParameters = myDXStr + ":" + myDYStr;
1862 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1863 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1864 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1865 theParameters = myAngleStr + ":" + myLengthStr;
1867 if ( mySketchType == DIR_ANGLE_X ) {
1868 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1869 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1870 theParameters = myAngleStr + ":" + myXStr;
1872 if ( mySketchType == DIR_ANGLE_Y ) {
1873 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1874 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1875 theParameters = myAngleStr + ":" + myYStr;
1877 if ( mySketchType == DIR_PER_LENGTH ) {
1878 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1879 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1880 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1882 if ( mySketchType == DIR_PER_X ) {
1883 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1884 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1885 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1887 if ( mySketchType == DIR_PER_Y ) {
1888 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1889 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1890 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1892 if ( mySketchType == DIR_TAN_LENGTH ) {
1893 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1894 theParameters = myLengthStr;
1896 if ( mySketchType == DIR_TAN_X ) {
1897 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1898 theParameters = myXStr;
1900 if ( mySketchType == DIR_TAN_Y) {
1901 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1902 theParameters = myYStr;
1904 if ( mySketchType == DIR_DXDY_LENGTH ) {
1905 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1906 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1907 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1909 if ( mySketchType == DIR_DXDY_X ) {
1910 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1911 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1912 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1914 if ( mySketchType == DIR_DXDY_Y ) {
1915 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1916 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1917 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1920 else if ( myConstructorId == 1 ) { // ARC
1921 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1922 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1923 theParameters = myXStr + ":" + myYStr;
1925 if ( mySketchType == PT_RELATIVE) {
1926 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1927 theParameters = myDXStr + ":" + myDYStr;
1929 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1930 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1931 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
1933 if ( mySketchType == PT_REL_RADIUS) {
1934 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1935 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
1937 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
1938 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 );
1939 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
1941 if ( mySketchType == PT_REL_CENTER) {
1942 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 );
1943 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
1945 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1946 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1947 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1948 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1950 if ( mySketchType == DIR_PER_LENGTH ) {
1951 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1952 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1953 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
1955 if ( mySketchType == DIR_TAN_LENGTH ) {
1956 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1957 theParameters = myRadiusStr + ":" + myLengthStr;
1959 if ( mySketchType == DIR_DXDY_LENGTH ) {
1960 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1961 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1962 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
1965 return myNewCommand;
1968 //=================================================================================
1969 // function : createOperation
1971 //=================================================================================
1972 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1974 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1977 //=================================================================================
1978 // function : isValid
1980 //=================================================================================
1981 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1984 bool toCorrect = !IsPreview() || myIsApply;
1986 if( Group1Spin->isVisible() ) {
1987 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1989 else if( Group1Sel1Spin->isVisible() ) {
1990 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1992 else if( Group2Spin->isVisible() ) {
1993 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1994 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1996 else if( Group3Spin->isVisible() ) {
1997 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1998 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1999 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2001 else if( Group4Spin->isVisible() ) {
2002 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2003 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2004 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2005 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2008 if( myIsApply && !ok )
2014 //=================================================================================
2015 // function : execute
2017 //=================================================================================
2018 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2020 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2021 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2022 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2024 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2025 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2027 QString aParameters;
2029 if ( mySketchState == FIRST_POINT ) {
2034 //Test if the current point is the same as the last one
2035 TopoDS_Shape myShape1, myShape2;
2037 // Set "C" numeric locale
2038 Kernel_Utils::Localizer loc;
2041 QString Command1 = myCommand.join( "" );
2042 Sketcher_Profile aProfile1( Command1.toAscii() );
2043 if ( aProfile1.IsDone() )
2044 myShape1 = aProfile1.GetShape();
2047 QString Command2 = Command1 + GetNewCommand( aParameters );
2048 Sketcher_Profile aProfile2( Command2.toAscii() );
2051 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2052 if (aProfile2.Error() > Precision::Confusion()){
2053 Group4Spin->label->show();
2054 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2057 Group4Spin->label->hide();
2061 Group4Spin->label->hide();
2062 if ( mySketchType == PT_SEL_CENTER ){
2063 if (aProfile2.Error() > Precision::Confusion()){
2064 Group2Sel->label->show();
2065 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2068 Group2Sel->label->hide();
2072 Group2Sel->label->hide();
2074 if ( aProfile2.IsDone() )
2075 myShape2 = aProfile2.GetShape();
2077 if ( myShape2.IsNull() ) {
2078 //the current point is the same as the last one
2079 myLastX2 = myLastX1;
2080 myLastY2 = myLastY1;
2083 TopoDS_Vertex V1, V2;
2085 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2086 //the last shape is the first point
2087 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2092 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2093 pt = BRep_Tool::Pnt( V2 );
2097 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2098 pt = BRep_Tool::Pnt( V2 );
2105 if ( ( mySketchState != FIRST_POINT &&
2106 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2107 cmd = myCommand.join( "" );
2108 if ( Group1Sel->isVisible() ) {
2109 Group1Sel->buttonApply->setEnabled( false );
2110 //Group1Sel->buttonApply->setFocus();
2112 if ( Group2Sel->isVisible() ) {
2113 Group2Sel->buttonApply->setEnabled( false );
2114 //Group2Sel->buttonApply->setFocus();
2116 if ( Group1Sel1Spin->isVisible() ) {
2117 Group1Sel1Spin->buttonApply->setEnabled( false );
2118 //Group1Sel1Spin->buttonApply->setFocus();
2120 if ( Group1Spin->isVisible() ) {
2121 Group1Spin->buttonApply->setEnabled( false );
2122 //Group1Spin->buttonApply->setFocus();
2124 if ( Group2Spin->isVisible() ) {
2125 Group2Spin->buttonApply->setEnabled( false );
2126 //Group2Spin->buttonApply->setFocus();
2128 if ( Group3Spin->isVisible() ) {
2129 Group3Spin->buttonApply->setEnabled( false );
2130 //Group3Spin->buttonApply->setFocus();
2132 if ( Group4Spin->isVisible() ) {
2133 Group4Spin->buttonApply->setEnabled( false );
2134 //Group4Spin->buttonApply->setFocus();
2138 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2140 if ( Group1Sel->isVisible() ) {
2141 Group1Sel->buttonApply->setEnabled( true );
2142 //Group1Sel->buttonApply->setFocus();
2144 if ( Group2Sel->isVisible() ) {
2145 Group2Sel->buttonApply->setEnabled( true );
2146 //Group2Sel->buttonApply->setFocus();
2148 if ( Group1Sel1Spin->isVisible() ) {
2149 Group1Sel1Spin->buttonApply->setEnabled( true );
2150 //Group1Sel1Spin->buttonApply->setFocus();
2152 if ( Group1Spin->isVisible() ) {
2153 Group1Spin->buttonApply->setEnabled( true );
2154 //Group1Spin->buttonApply->setFocus();
2156 if ( Group2Spin->isVisible() ) {
2157 Group2Spin->buttonApply->setEnabled( true );
2158 //Group2Spin->buttonApply->setFocus();
2160 if ( Group3Spin->isVisible() ) {
2161 Group3Spin->buttonApply->setEnabled( true );
2162 //Group3Spin->buttonApply->setFocus();
2164 if ( Group4Spin->isVisible() ) {
2165 Group4Spin->buttonApply->setEnabled( true );
2166 //Group4Spin->buttonApply->setFocus();
2170 gp_Ax3 myWPlane = GetActiveLocalCS();
2171 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2172 WPlane->length( 9 );
2173 WPlane[0] = myWPlane.Location().X();
2174 WPlane[1] = myWPlane.Location().Y();
2175 WPlane[2] = myWPlane.Location().Z();
2177 WPlane[3] = myWPlane.Direction().X();
2178 WPlane[4] = myWPlane.Direction().Y();
2179 WPlane[5] = myWPlane.Direction().Z();
2181 WPlane[6] = myWPlane.XDirection().X();
2182 WPlane[7] = myWPlane.XDirection().Y();
2183 WPlane[8] = myWPlane.XDirection().Z();
2185 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2186 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2188 if ( !anObj->_is_nil() )
2190 if( !IsPreview() ) {
2191 QStringList aCurrentParameters = myParameters;
2192 aCurrentParameters << aParameters;
2193 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2196 objects.push_back( anObj._retn() );
2202 //================================================================
2203 // Function : displayPreview
2204 // Purpose : Method for displaying preview of resulting shape
2205 // Redefined from GEOMBase_Helper.
2206 //================================================================
2207 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2209 const bool activate,
2211 const double lineWidth,
2212 const int displayMode,
2215 // Set color for preview shape
2216 getDisplayer()->SetColor( Quantity_NOC_RED );
2218 // set width of displayed shape
2219 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2221 // Disable activation of selection
2222 getDisplayer()->SetToActivate( activate );
2224 // Make a reference to GEOM_Object
2225 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2226 getDisplayer()->SetName( objStr.in() );
2228 // Create wire from applayed object
2229 TopoDS_Shape anApplyedWire, aLastSegment;
2230 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2234 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2235 if ( aPrs != 0 && !aPrs->IsNull() )
2236 GEOMBase_Helper::displayPreview( aPrs, append, update );
2238 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2239 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2240 if ( aPrs != 0 && !aPrs->IsNull() )
2241 GEOMBase_Helper::displayPreview( aPrs, append, update );
2243 getDisplayer()->UnsetName();
2245 // Enable activation of displayed objects
2246 getDisplayer()->SetToActivate( true );
2249 //================================================================
2250 // Function : createShapes
2251 // Purpose : Create applyed wire, and last segment from entry object
2252 //================================================================
2253 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2254 TopoDS_Shape& theApplyedWire,
2255 TopoDS_Shape& theLastSegment )
2257 TopoDS_Shape aShape;
2258 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2259 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2262 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2263 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2264 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2265 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2266 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2267 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2268 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2269 theApplyedWire = aShape;
2273 BRepBuilderAPI_MakeWire aBuilder;
2274 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2276 TopoDS_Shape anEdge = anExp.Current();
2278 if ( anExp.More() ) // i.e. non-last edge
2279 aBuilder.Add( TopoDS::Edge( anEdge ) );
2281 theLastSegment = anEdge;
2286 if ( aBuilder.IsDone() )
2287 theApplyedWire = aBuilder.Shape();
2292 //=================================================================================
2293 // function : keyPressEvent()
2295 //=================================================================================
2296 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2298 QDialog::keyPressEvent( e );
2299 if ( e->isAccepted() )
2302 if ( e->key() == Qt::Key_F1 ) {
2308 //=================================================================================
2309 // function : initSpinBox()
2311 //=================================================================================
2312 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2313 double min, double max,
2314 double step, const char* quantity )
2316 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2317 // TODO: Think how to keep the single piece of code...
2319 // Obtain precision from preferences
2320 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2321 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2323 spinBox->setPrecision( aPrecision );
2324 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2325 // by default Qt rounds boundaries to 2 decimals at setRange
2326 spinBox->setRange( min, max );
2327 spinBox->setSingleStep( step );
2329 // Add a hint for the user saying how to tune precision
2330 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2331 spinBox->setProperty( "validity_tune_hint",
2332 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2335 //=================================================================================
2336 // function : SetDoubleSpinBoxStep()
2337 // purpose : Double spin box management
2338 //=================================================================================
2339 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2341 Group1Spin->SpinBox_DX->setSingleStep(step);
2342 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2343 Group2Spin->SpinBox_DX->setSingleStep(step);
2344 Group2Spin->SpinBox_DY->setSingleStep(step);
2345 Group3Spin->SpinBox_DX->setSingleStep(step);
2346 Group3Spin->SpinBox_DY->setSingleStep(step);
2347 Group3Spin->SpinBox_DZ->setSingleStep(step);
2348 Group4Spin->SpinBox_DZ->setSingleStep(step);
2350 // san: Do NOT override the step when a speicifc step value is used
2351 // in some input fields!
2352 //Group4Spin->SpinBox_DX->setSingleStep(step);
2353 //Group4Spin->SpinBox_DY->setSingleStep(step);
2354 //Group4Spin->SpinBox_DS->setSingleStep(step);
2357 //=================================================================================
2358 // function : FindLocalCS()
2359 // purpose : Find All Coordinates systems in study
2360 //=================================================================================
2361 void EntityGUI_SketcherDlg::FindLocalCS()
2365 SalomeApp_Application* app =
2366 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2370 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2374 _PTR(Study) aStudy = appStudy->studyDS();
2377 ComboBox1->addItem(tr("GEOM_GCS"));
2378 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2379 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2380 gp_Dir aDirX = gp_Dir(1, 0, 0);
2381 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2382 myLCSList.push_back(globalCS);
2384 // get GEOM component
2385 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2386 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2389 _PTR(SComponent) fc = obj->GetFatherComponent();
2390 QString geomComp = fc->GetID().c_str();
2391 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2395 // browse through all GEOM data tree
2396 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2397 for ( it->InitEx( true ); it->More(); it->Next() ) {
2398 _PTR(SObject) child( it->Value() );
2399 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2400 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2401 if( CORBA::is_nil( geomObj ) )
2403 if (geomObj->GetType() == GEOM_MARKER) {
2404 ComboBox1->addItem(geomObj->GetName());
2405 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2408 aLCS.Transform(aShape.Location().Transformation());
2409 if (aShape.ShapeType() == TopAbs_FACE) {
2410 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2411 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2412 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2413 gp_Pln aPln = aGPlane->Pln();
2414 aLCS = aPln.Position();
2417 myLCSList.push_back(aLCS);
2423 //=================================================================================
2424 // function : getPnt1ConstructorId()
2426 //=================================================================================
2427 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2429 int buttonId = GroupPt->ButtonGroup->checkedId();
2430 MESSAGE("buttonId = "<<buttonId)
2434 //=================================================================================
2435 // function : getPnt2ConstructorId()
2437 //=================================================================================
2438 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2440 int buttonId = GroupPt2->ButtonGroup->checkedId();
2441 MESSAGE("buttonId = "<<buttonId)
2445 //=================================================================================
2446 // function : GetActiveLocalCS()
2447 // purpose : Get Working plane
2448 //=================================================================================
2449 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2451 int ind = ComboBox1->currentIndex();
2453 return myGeometryGUI->GetWorkingPlane();
2455 gp_Ax3 aLCS = myLCSList.at(ind);
2460 //=================================================================================
2461 // function : ActivateLocalCS()
2462 // purpose : Activate & Fit Working plane
2463 //=================================================================================
2464 void EntityGUI_SketcherDlg::ActivateLocalCS()
2466 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2467 myGeometryGUI->ActiveWorkingPlane();