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>
31 #include <OCCViewer_ViewPort3d.h>
32 #include <OCCViewer_ViewWindow.h>
35 #include <GeometryGUI.h>
36 #include <GEOMImpl_Types.hxx>
37 #include <Geom_Surface.hxx>
38 #include <Geom_Plane.hxx>
40 #include <SUIT_Desktop.h>
41 #include <SUIT_Session.h>
42 #include <SUIT_MessageBox.h>
43 #include <SUIT_ResourceMgr.h>
44 #include <SalomeApp_Application.h>
45 #include <LightApp_Application.h>
46 #include <LightApp_SelectionMgr.h>
50 #include <BRep_Tool.hxx>
52 #include <TopExp_Explorer.hxx>
53 #include <TopoDS_Vertex.hxx>
55 #include <BRepBuilderAPI_Transform.hxx>
56 #include <BRepBuilderAPI_MakeWire.hxx>
57 #include <BRepBuilderAPI_MakeVertex.hxx>
58 #include <Sketcher_Profile.hxx>
60 #include <SalomeApp_Study.h>
64 #include <Basics_Utils.hxx>
66 //=================================================================================
67 // class : EntityGUI_SketcherDlg()
68 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
69 // name 'name' and widget flags set to 'f'.
70 // The dialog will by default be modeless, unless you set 'modal' to
71 // TRUE to construct a modal dialog.
72 //=================================================================================
73 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
74 bool modal, Qt::WindowFlags fl,
75 const double lineWidth )
76 : QDialog( parent, fl ),
77 myIsAllAdded( false ),
79 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
81 myLineWidth( lineWidth )
83 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
85 setAttribute( Qt::WA_DeleteOnClose );
87 myGeometryGUI->SetActiveDialogBox(this);
89 MainWidget = new EntityGUI_Skeleton( this );
90 QVBoxLayout* topLayout = new QVBoxLayout( this );
91 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
93 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
94 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_CLOSE" ) );
95 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
96 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
98 QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
99 QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
100 QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
101 QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
102 QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) );
104 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
106 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
107 MainWidget->RadioButton1->setText( "" );
108 MainWidget->RadioButton1->setIcon( image3 );
109 MainWidget->RadioButton2->setText( "" );
110 MainWidget->RadioButton2->setIcon( image4 );
111 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
112 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
113 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
114 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
116 /***************************************************************/
118 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
119 QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
120 planeLayout->setSpacing(6);
121 planeLayout->setMargin(11);
123 ComboBox1 = new QComboBox(GroupBox1);
124 ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
125 planeLayout->addWidget(ComboBox1);
127 planeButton = new QPushButton (GroupBox1);
128 planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
129 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
130 planeLayout->addWidget(planeButton);
132 topLayout->addWidget(GroupBox1);
133 topLayout->addWidget( MainWidget );
134 topLayout->setStretch( 1, 1);
136 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
138 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
139 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
140 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
141 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
143 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
145 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
146 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
147 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
148 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
150 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
152 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
153 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
154 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
155 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
156 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
158 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
160 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIST" ) );
161 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
162 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
163 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
165 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
166 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
167 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
168 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
169 Group1Sel->PushButton1->setIcon( image0 );
170 Group1Sel->buttonUndo->setIcon( image1 );
171 Group1Sel->buttonRedo->setIcon( image2 );
172 Group1Sel->LineEdit1->setReadOnly( true );
174 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
175 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
176 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
177 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
178 Group2Sel->PushButton1->setIcon( image0 );
179 Group2Sel->PushButton2->setIcon( image0 );
180 Group2Sel->buttonUndo->setIcon( image1 );
181 Group2Sel->buttonRedo->setIcon( image2 );
182 Group2Sel->LineEdit1->setReadOnly( true );
183 Group2Sel->LineEdit2->setReadOnly( true );
185 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
186 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
187 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
188 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
189 Group1Sel1Spin->PushButton1->setIcon( image0 );
190 Group1Sel1Spin->buttonUndo->setIcon( image1 );
191 Group1Sel1Spin->buttonRedo->setIcon( image2 );
192 Group1Sel1Spin->LineEdit1->setReadOnly( true );
194 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
195 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
196 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
197 Group1Spin->buttonUndo->setIcon( image1 );
198 Group1Spin->buttonRedo->setIcon( image2 );
200 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
201 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
202 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
203 Group2Spin->buttonUndo->setIcon( image1 );
204 Group2Spin->buttonRedo->setIcon( image2 );
206 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
207 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
208 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
209 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
210 Group3Spin->buttonUndo->setIcon( image1 );
211 Group3Spin->buttonRedo->setIcon( image2 );
213 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
214 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
215 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
216 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
217 Group4Spin->buttonUndo->setIcon( image1 );
218 Group4Spin->buttonRedo->setIcon( image2 );
220 // Defines a palette for the error message on Group4Spin and Group2Sel
223 palette.setColor(Group4Spin->label->foregroundRole(), color);
224 Group4Spin->label->setPalette(palette);
225 palette.setColor(Group2Sel->label->foregroundRole(), color);
226 Group2Sel->label->setPalette(palette);
228 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
229 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
230 DestCntLayout->addWidget( GroupPt, 0, 0 );
231 DestCntLayout->addWidget( GroupPt2, 0, 1 );
232 DestCntLayout->addWidget( GroupD1, 0, 0 );
233 DestCntLayout->addWidget( GroupD2, 0, 1 );
235 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
236 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
237 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
238 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
239 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
240 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
241 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
242 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
243 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
244 //SkeletonCntlayout->setStretch( 0, 1);
245 /***************************************************************/
247 QButtonGroup* ButtonGroup = new QButtonGroup( this );
248 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
249 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
251 /* signals and slots connections */
252 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
253 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
254 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
255 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
257 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
258 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
259 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
260 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
261 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
262 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
263 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
264 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
265 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
266 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
267 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
268 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
269 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
270 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
271 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
272 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
273 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
274 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
275 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
276 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
277 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
279 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
280 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
281 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
282 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
283 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
284 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
286 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
287 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
289 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
290 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
291 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
292 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
294 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
295 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
296 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
298 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
299 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
300 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
301 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
302 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
303 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
304 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
305 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
306 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
307 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
309 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
310 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
311 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
312 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
314 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
315 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
317 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
319 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
320 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
322 // install event filter on spin-boxes to provide Apply action on Return pressed
323 Group1Spin->SpinBox_DX->installEventFilter(this);
324 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
325 Group2Spin->SpinBox_DX->installEventFilter(this);
326 Group2Spin->SpinBox_DY->installEventFilter(this);
327 Group3Spin->SpinBox_DX->installEventFilter(this);
328 Group3Spin->SpinBox_DY->installEventFilter(this);
329 Group3Spin->SpinBox_DZ->installEventFilter(this);
330 Group4Spin->SpinBox_DX->installEventFilter(this);
331 Group4Spin->SpinBox_DY->installEventFilter(this);
332 Group4Spin->SpinBox_DZ->installEventFilter(this);
333 Group4Spin->SpinBox_DS->installEventFilter(this);
339 //=================================================================================
340 // function : ~EntityGUI_SketcherDlg()
341 // purpose : Destroys the object and frees any allocated resources
342 //=================================================================================
343 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
345 myGeometryGUI->SetActiveDialogBox( 0 );
349 //=================================================================================
350 // function : eventFilter()
351 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
352 //=================================================================================
353 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
355 if (event->type() == QEvent::KeyPress) {
356 QKeyEvent* ke = (QKeyEvent*)event;
357 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
358 if (object == Group1Spin->SpinBox_DX) {
359 Group1Spin->buttonApply->click();
361 } else if (object == Group1Sel1Spin->SpinBox_DX) {
362 Group1Sel1Spin->buttonApply->click();
364 } else if (object == Group2Spin->SpinBox_DX ||
365 object == Group2Spin->SpinBox_DY) {
366 Group2Spin->buttonApply->click();
368 } else if (object == Group3Spin->SpinBox_DX ||
369 object == Group3Spin->SpinBox_DY ||
370 object == Group3Spin->SpinBox_DZ) {
371 Group3Spin->buttonApply->click();
373 } else if (object == Group4Spin->SpinBox_DX ||
374 object == Group4Spin->SpinBox_DY ||
375 object == Group4Spin->SpinBox_DZ ||
376 object == Group4Spin->SpinBox_DS) {
377 Group4Spin->buttonApply->click();
383 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
385 return QDialog::eventFilter(object, event);
389 //=================================================================================
392 //=================================================================================
393 void EntityGUI_SketcherDlg::Init()
397 myEditCurrentArgument = Group1Sel->LineEdit1;
398 myCommand.append( "Sketcher" );
399 myUndoCommand.append( "Sketcher" );
401 mySketchState = FIRST_POINT;
402 globalSelection( GEOM_POINT );
411 myHelpFileName = "create_sketcher_page.html";
413 /* Get setting of step value from file configuration */
414 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
416 /* min, max, step and decimals for spin boxes */
417 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
418 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
419 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
420 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
421 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
422 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
423 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
424 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
425 // san: Note specific step values below!
426 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
427 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
428 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
430 /* displays Dialog */
431 MainWidget->GroupConstructors->setEnabled( false );
432 MainWidget->GroupDest1->setEnabled( false );
433 setEnabledUndo( false );
434 setEnabledRedo( false );
436 MainWidget->RadioButton1->setChecked( true );
444 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
448 //=================================================================================
449 // function : InitClick()
451 //=================================================================================
452 void EntityGUI_SketcherDlg::InitClick()
454 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
459 Group1Sel1Spin->hide();
464 globalSelection(); // close local selection to clear it
465 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
469 //=================================================================================
470 // function : TypeClicked()
471 // purpose : Radio button management
472 //=================================================================================
473 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
475 myConstructorId = constructorId;
476 if ( myConstructorId == 0 ) { // SEGMENT
477 GroupPt2->RB_Point1->setChecked( true );
478 GroupPt2->setEnabled( false );
479 GroupD2->setEnabled( true );
480 MainWidget->RB_Dest1->setEnabled( true );
481 MainWidget->RB_Dest1->setChecked( true );
484 else if ( myConstructorId == 1 ) { // ARC
485 GroupPt2->setEnabled( true );
486 GroupD2->RB_Dir21->setChecked( true );
487 GroupD2->setEnabled( false );
488 MainWidget->RB_Dest1->setEnabled( true );
489 MainWidget->RB_Dest1->setChecked( true );
495 //=================================================================================
496 // function : DestClicked()
497 // purpose : Radio button management
498 //=================================================================================
499 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
506 if ( constructorId == 1 ) {
508 GroupPt->RB_Point1->setChecked( true );
511 Group3Spin->checkBox->show();
512 Group4Spin->checkBox->show();
513 PointClicked( 1 ); // XY
515 else if ( constructorId == 0 ) {
517 GroupD1->RB_Dir11->setChecked( true );
520 Group3Spin->checkBox->hide();
521 Group4Spin->checkBox->hide();
522 Dir1Clicked( 2 ); // Angle
524 resize( minimumSizeHint() );
527 //=================================================================================
528 // function : PointClicked()
529 // purpose : Radio button management
530 //=================================================================================
531 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
533 MESSAGE("PointClicked")
534 myConstructorPntId = constructorId;
535 GroupPt->RB_Point3->setEnabled( true );
536 int buttonId = GroupPt2->ButtonGroup->checkedId();
537 MESSAGE("checkedId ="<< buttonId)
538 if (buttonId >= 0){ // = If a button is checked
539 Point2Clicked(buttonId);
542 GroupPt2->RB_Point1->setChecked( true );
547 //=================================================================================
548 // function : Point2Clicked()
549 // purpose : Radio button management
550 //=================================================================================
551 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
553 MESSAGE("Point2Clicked")
556 // Get setting of step value from file configuration
557 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
559 if ( myConstructorPntId == 1 ) { // XY
560 if ( constructorId == 1 ){ // No additional parameter
561 mySketchType = PT_ABS;
562 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
563 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
564 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
565 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
567 Group2Spin->SpinBox_DX->setValue( myX );
569 Group2Spin->SpinBox_DY->setValue( myY );
571 Group2Spin->buttonApply->setFocus();
573 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
575 else if ( constructorId == 0 ){ // Point + radius
576 mySketchType = PT_ABS_RADIUS;
577 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
578 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
579 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
580 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
581 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
582 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
584 Group3Spin->SpinBox_DX->setValue( myX );
586 Group3Spin->SpinBox_DY->setValue( myY );
588 Group3Spin->SpinBox_DZ->setValue( myRadius );
590 Group3Spin->buttonApply->setFocus();
592 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
594 else if ( constructorId == 2 ){ // Point + center
595 mySketchType = PT_ABS_CENTER;
596 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
597 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
598 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
599 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
600 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
601 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
602 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
603 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
605 Group4Spin->SpinBox_DX->setValue( myXc );
607 Group4Spin->SpinBox_DY->setValue( myYc );
609 Group4Spin->SpinBox_DZ->setValue( myX );
611 Group4Spin->SpinBox_DS->setValue( myY );
613 Group4Spin->buttonApply->setFocus();
615 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
619 else if ( myConstructorPntId == 0 ) { // DXDY
620 if ( constructorId == 1 ){ // No additional parameter
621 mySketchType = PT_RELATIVE;
622 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
623 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
624 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
625 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
627 Group2Spin->SpinBox_DX->setValue( myDX );
629 Group2Spin->SpinBox_DY->setValue( myDY );
631 Group2Spin->buttonApply->setFocus();
633 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
635 else if ( constructorId == 0 ){ // Point + radius
636 mySketchType = PT_REL_RADIUS;
637 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
638 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
639 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
640 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
641 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
642 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
644 Group3Spin->SpinBox_DX->setValue( myDX );
646 Group3Spin->SpinBox_DY->setValue( myDY );
648 Group3Spin->SpinBox_DZ->setValue( myRadius );
650 Group3Spin->buttonApply->setFocus();
652 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
654 else if ( constructorId == 2 ){ // Point + center
655 mySketchType = PT_REL_CENTER;
656 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
657 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
658 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
659 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
660 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
661 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
662 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
663 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
665 Group4Spin->SpinBox_DX->setValue( myDXc );
667 Group4Spin->SpinBox_DY->setValue( myDYc );
669 Group4Spin->SpinBox_DZ->setValue( myDX );
671 Group4Spin->SpinBox_DS->setValue( myDY );
673 Group4Spin->buttonApply->setFocus();
675 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
679 else if ( myConstructorPntId == 2 ) { // Selection
680 if ( constructorId == 1 ){ // No additional parameter
681 mySketchType = PT_SEL;
682 myEditCurrentArgument = Group1Sel->LineEdit1;
683 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
685 Group1Sel->buttonApply->setFocus();
686 SelectionIntoArgument();
688 else if ( constructorId == 0 ){ // Point + radius
689 mySketchType = PT_SEL_RADIUS;
690 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
691 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
692 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
693 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
695 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
697 Group1Sel1Spin->show();
698 Group1Sel1Spin->buttonApply->setFocus();
699 SelectionIntoArgument();
701 else if ( constructorId == 2 ){ // Point + center
702 mySketchType = PT_SEL_CENTER;
703 myEditCurrentArgument = Group2Sel->LineEdit1;
704 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
705 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
706 Group2Sel->LineEdit1->setEnabled(true);
707 Group2Sel->PushButton1->setDown(true);
708 Group2Sel->LineEdit2->setEnabled(false);
709 Group2Sel->PushButton2->setDown(false);
711 Group2Sel->buttonApply->setFocus();
712 SelectionIntoArgument();
716 resize( minimumSizeHint() );
717 connect( myGeometryGUI->getApp()->selectionMgr(),
718 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
723 //=================================================================================
724 // function : Dir1Clicked()
725 // purpose : Radio button management
726 //=================================================================================
727 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
729 myConstructorDirId = constructorId;
730 int dirButtonId = GroupD2->ButtonGroup->checkedId();
731 MESSAGE("checkedId ="<< dirButtonId)
732 if (dirButtonId >= 0){ // = If a button is checked
733 Dir2Clicked(dirButtonId);
736 GroupD2->RB_Dir21->setChecked( true );
742 //=================================================================================
743 // function : Dir2Clicked()
744 // purpose : Radio button management
745 //=================================================================================
746 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
751 // Get setting of step value from file configuration
752 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
754 if ( myConstructorId == 0 ) { // SEGMENT
758 if ( myConstructorDirId == 2 ) { // Angle
759 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
760 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
761 Group2Spin->SpinBox_DX->setValue( myAngle );
762 Group2Spin->buttonApply->setFocus();
765 if ( constructorId == 2 ) { // Length
766 mySketchType = DIR_ANGLE_LENGTH;
767 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
768 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
769 Group2Spin->SpinBox_DY->setValue( myLength );
771 else if ( constructorId == 0 ) { // X
772 mySketchType = DIR_ANGLE_X;
773 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
774 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
775 Group2Spin->SpinBox_DY->setValue( myX );
777 else if ( constructorId == 1 ) { // Y
778 mySketchType = DIR_ANGLE_Y;
779 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
780 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
781 Group2Spin->SpinBox_DY->setValue( myY );
784 else if ( myConstructorDirId == 0 ) { // Perpendicular
786 Group1Spin->buttonApply->setFocus();
788 if ( constructorId == 2 ) { // Length
789 mySketchType = DIR_PER_LENGTH;
790 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
791 Group1Spin->SpinBox_DX->setValue( myLength );
793 else if ( constructorId == 0 ) { // X
794 mySketchType = DIR_PER_X;
795 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
796 Group1Spin->SpinBox_DX->setValue( myX );
798 else if ( constructorId == 1 ) { // Y
799 mySketchType = DIR_PER_Y;
800 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
801 Group1Spin->SpinBox_DX->setValue( myY );
804 else if ( myConstructorDirId == 1 ) { // Tangent
806 Group1Spin->buttonApply->setFocus();
808 if ( constructorId == 2 ) { // Length
809 mySketchType = DIR_TAN_LENGTH;
810 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
811 Group1Spin->SpinBox_DX->setValue( myLength );
813 else if ( constructorId == 0 ) { // X
814 mySketchType = DIR_TAN_X;
815 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
816 Group1Spin->SpinBox_DX->setValue( myX );
818 else if ( constructorId == 1 ) { // Y
819 mySketchType = DIR_TAN_Y;
820 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
821 Group1Spin->SpinBox_DX->setValue( myY );
824 else if ( myConstructorDirId == 3 ) { // DXDY
825 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
826 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
827 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
828 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
829 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
831 Group3Spin->SpinBox_DX->setValue( myDX );
833 Group3Spin->SpinBox_DY->setValue( myDY );
835 Group3Spin->buttonApply->setFocus();
837 if ( constructorId == 2 ) { // Length
838 mySketchType = DIR_DXDY_LENGTH;
839 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
840 Group3Spin->SpinBox_DZ->setValue( myLength );
842 else if ( constructorId == 0 ) { // X
843 mySketchType = DIR_DXDY_X;
844 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
845 Group3Spin->SpinBox_DZ->setValue( myX );
847 else if ( constructorId == 1 ) { // Y
848 mySketchType = DIR_DXDY_Y;
849 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
850 Group3Spin->SpinBox_DZ->setValue( myY );
854 else if ( myConstructorId == 1 ) { // ARC
855 if ( myConstructorDirId == 2 ) { // Angle
856 if ( constructorId == 2 ) { // Length
857 mySketchType = DIR_ANGLE_LENGTH;
858 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
859 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
860 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
861 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
862 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
863 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
864 Group3Spin->SpinBox_DX->setValue( myAngle );
866 Group3Spin->SpinBox_DY->setValue( myRadius );
868 Group3Spin->SpinBox_DZ->setValue( myLength );
870 Group3Spin->buttonApply->setFocus();
873 else if ( myConstructorDirId == 0 ) { // Perpendicular
874 if ( constructorId == 2 ) { // Length
875 mySketchType = DIR_PER_LENGTH;
876 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
877 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
878 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
879 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
881 Group2Spin->SpinBox_DX->setValue( myRadius );
883 Group2Spin->SpinBox_DY->setValue( myLength );
885 Group2Spin->buttonApply->setFocus();
888 else if ( myConstructorDirId == 1 ) { // Tangent
889 if ( constructorId == 2 ) { // Length
890 mySketchType = DIR_TAN_LENGTH;
891 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
892 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
893 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
894 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
896 Group2Spin->SpinBox_DX->setValue( myRadius );
898 Group2Spin->SpinBox_DY->setValue( myLength );
900 Group2Spin->buttonApply->setFocus();
903 else if ( myConstructorDirId == 3 ) { // DXDY
904 if ( constructorId == 2 ) { // Length
905 mySketchType = DIR_DXDY_LENGTH;
906 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
907 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
908 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
909 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
910 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
911 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
912 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
913 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
915 Group4Spin->SpinBox_DX->setValue( myDX );
917 Group4Spin->SpinBox_DY->setValue( myDY );
919 Group4Spin->SpinBox_DZ->setValue( myRadius );
921 Group4Spin->SpinBox_DS->setValue( myLength );
923 Group4Spin->buttonApply->setFocus();
927 resize( minimumSizeHint() );
928 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
931 //=================================================================================
932 // function : CheckBoxClicked()
933 // purpose : CheckBox management
934 //=================================================================================
935 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
939 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
943 //=================================================================================
944 // function : ClickOnCancel()
946 //=================================================================================
947 void EntityGUI_SketcherDlg::ClickOnCancel()
953 //=================================================================================
954 // function : ClickOnEnd()
955 // purpose : connected to buttonEnd AND buttonClose
956 //=================================================================================
957 void EntityGUI_SketcherDlg::ClickOnEnd()
959 if ( sender() == MainWidget->buttonClose ) {
960 // Verify validity of commands
961 if ( myCommand.count() <= 2 ) {
962 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
963 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
968 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
969 Sketcher_Profile aProfile( Command.toAscii() );
971 Command = myCommand.join( "" );
972 aProfile = Sketcher_Profile( Command.toAscii() );
973 TopoDS_Shape myShape;
974 if ( aProfile.IsDone() )
975 myShape = aProfile.GetShape();
977 if ( myShape.ShapeType() != TopAbs_VERTEX )
978 myCommand.append( ":WW" );
981 /*// PAL16008 (Sketcher Validation should be equal to Apply&Close)
982 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
983 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
984 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
985 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
986 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
987 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
988 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
994 if ( myCommand.size() > 2 )
1001 //=================================================================================
1002 // function : ClickOnApply()
1004 //=================================================================================
1005 bool EntityGUI_SketcherDlg::ClickOnApply()
1007 if ( sender() && sender()->inherits( "QPushButton" ) )
1008 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1010 QString aParameters;
1011 myCommand.append( GetNewCommand( aParameters ) );
1012 mySketchState = NEXT_POINT;
1014 myUndoCommand.clear();
1015 myUndoCommand.append( "Sketcher" );
1017 myParameters.append( aParameters );
1018 myUndoParameters.clear();
1020 MainWidget->GroupConstructors->setEnabled( true );
1021 MainWidget->GroupDest1->setEnabled( true );
1022 setEnabledUndo( true );
1023 setEnabledRedo( false );
1026 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1029 // Set focus to SpinBox_DX
1030 if ( sender() == Group1Spin->buttonApply ) {
1031 (Group1Spin->SpinBox_DX)->setFocus();
1032 (Group1Spin->SpinBox_DX)->selectAll();
1034 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1035 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1036 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1038 else if ( sender() == Group2Spin->buttonApply ) {
1039 (Group2Spin->SpinBox_DX)->setFocus();
1040 (Group2Spin->SpinBox_DX)->selectAll();
1042 else if ( sender() == Group3Spin->buttonApply ) {
1043 (Group3Spin->SpinBox_DX)->setFocus();
1044 (Group3Spin->SpinBox_DX)->selectAll();
1046 else if ( sender() == Group4Spin->buttonApply ) {
1047 (Group4Spin->SpinBox_DX)->setFocus();
1048 (Group4Spin->SpinBox_DX)->selectAll();
1054 //=================================================================================
1055 // function : ClickOnHelp()
1057 //=================================================================================
1058 void EntityGUI_SketcherDlg::ClickOnHelp()
1060 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1062 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1066 platform = "winapplication";
1068 platform = "application";
1071 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1072 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1073 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1074 QObject::tr( "BUT_OK" ) );
1078 //=================================================================================
1079 // function : ClickOnUndo()
1081 //=================================================================================
1082 void EntityGUI_SketcherDlg::ClickOnUndo()
1084 myUndoCommand.append( myCommand.last() );
1085 myCommand.pop_back();
1087 myUndoParameters.append( myParameters.last() );
1088 myParameters.pop_back();
1090 if ( myCommand.count() == 1 ) {
1091 mySketchState = FIRST_POINT;
1093 MainWidget->RadioButton1->setChecked( true );
1096 connect( myGeometryGUI->getApp()->selectionMgr(),
1097 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1099 MainWidget->GroupConstructors->setEnabled( false );
1100 MainWidget->GroupDest1->setEnabled( false );
1101 setEnabledUndo( false );
1104 setEnabledRedo( true );
1106 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1109 //=================================================================================
1110 // function : ClickOnRedo()
1112 //=================================================================================
1113 void EntityGUI_SketcherDlg::ClickOnRedo()
1115 myCommand.append( myUndoCommand.last() );
1116 myUndoCommand.pop_back();
1118 myParameters.append( myUndoParameters.last() );
1119 myUndoParameters.pop_back();
1121 mySketchState = NEXT_POINT;
1123 MainWidget->GroupConstructors->setEnabled( true );
1124 MainWidget->GroupDest1->setEnabled( true );
1125 setEnabledUndo( true );
1127 if ( myUndoCommand.count() == 1 )
1128 setEnabledRedo( false );
1130 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1133 //=================================================================================
1134 // function : setEnabledUndo()
1136 //=================================================================================
1137 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1139 Group1Sel->buttonUndo->setEnabled( value );
1140 Group2Sel->buttonUndo->setEnabled( value );
1141 Group1Sel1Spin->buttonUndo->setEnabled( value );
1142 Group1Spin->buttonUndo->setEnabled( value );
1143 Group2Spin->buttonUndo->setEnabled( value );
1144 Group3Spin->buttonUndo->setEnabled( value );
1145 Group4Spin->buttonUndo->setEnabled( value );
1148 //=================================================================================
1149 // function : setEnabledRedo()
1151 //=================================================================================
1152 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1154 Group1Sel->buttonRedo->setEnabled( value );
1155 Group2Sel->buttonRedo->setEnabled( value );
1156 Group1Sel1Spin->buttonRedo->setEnabled( value );
1157 Group1Spin->buttonRedo->setEnabled( value );
1158 Group2Spin->buttonRedo->setEnabled( value );
1159 Group3Spin->buttonRedo->setEnabled( value );
1160 Group4Spin->buttonRedo->setEnabled( value );
1163 //=================================================================================
1164 // function : SelectionIntoArgument()
1165 // purpose : Called when selection as changed
1166 //=================================================================================
1167 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1169 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1170 myEditCurrentArgument->setText( "" );
1175 // printf ("\nmyX = %f myY = %f", myX, myY);
1176 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
1177 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
1179 if ( sender() == ComboBox1 )
1182 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1183 SALOME_ListIO aSelList;
1184 aSelMgr->selectedObjects(aSelList);
1186 int nbSel = aSelList.Extent();
1187 MESSAGE("NbSel = "<<nbSel)
1188 if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1189 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1190 if ( !CORBA::is_nil(aSelectedObject) ) {
1191 TopoDS_Shape aShape;
1192 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1194 gp_Ax3 aWPlane = GetActiveLocalCS();
1196 aTrans.SetTransformation(aWPlane);
1197 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1198 aShape = aTransformation.Shape();
1201 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1204 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1205 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1206 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1207 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1208 Group2Spin->SpinBox_DX->setValue(myX);
1209 Group2Spin->SpinBox_DY->setValue(myY);
1210 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1211 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1212 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1213 if ( myLastX1 && myLastY1 ) {
1214 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1215 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1217 if ( mySketchState != FIRST_POINT ) {
1218 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1219 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1221 Group2Spin->SpinBox_DX->setValue(myX);
1222 Group2Spin->SpinBox_DY->setValue(myY);
1231 if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1232 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1233 if ( !CORBA::is_nil(aSelectedObject) ) {
1234 TopoDS_Shape aShape;
1235 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1237 gp_Ax3 aWPlane = GetActiveLocalCS();
1239 aTrans.SetTransformation(aWPlane);
1240 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1241 aShape = aTransformation.Shape();
1244 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1247 Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1248 if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1249 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1250 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1251 Group3Spin->SpinBox_DX->setValue(myX);
1252 Group3Spin->SpinBox_DY->setValue(myY);
1253 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1254 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1255 } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1256 if ( myLastX1 && myLastY1 ) {
1257 Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1258 Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1260 if ( mySketchState != FIRST_POINT ) {
1261 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1262 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1264 Group3Spin->SpinBox_DX->setValue(myX);
1265 Group3Spin->SpinBox_DY->setValue(myY);
1274 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1275 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1276 if ( !CORBA::is_nil(aSelectedObject) ) {
1277 TopoDS_Shape aShape;
1278 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1280 gp_Ax3 aWPlane = GetActiveLocalCS();
1282 aTrans.SetTransformation(aWPlane);
1283 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1284 aShape = aTransformation.Shape();
1287 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1290 Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1291 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1292 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1293 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1294 Group4Spin->SpinBox_DX->setValue(myXc);
1295 Group4Spin->SpinBox_DY->setValue(myYc);
1296 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1297 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1298 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1299 if ( myLastX1 && myLastY1 ) {
1300 Group4Spin->SpinBox_DX->setValue(myXc - myLastX1);
1301 Group4Spin->SpinBox_DY->setValue(myYc - myLastY1);
1303 if ( mySketchState != FIRST_POINT ) {
1304 Group4Spin->SpinBox_DX->setValue(myXc - tmpX);
1305 Group4Spin->SpinBox_DY->setValue(myYc - tmpY);
1307 Group4Spin->SpinBox_DX->setValue(myXc);
1308 Group4Spin->SpinBox_DY->setValue(myYc);
1317 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1318 if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
1319 myX=tmpX; // If yes keep the old values of X and Y
1322 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1323 if ( !CORBA::is_nil(aSelectedObject) ) {
1324 TopoDS_Shape aShape;
1325 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1327 gp_Ax3 aWPlane = GetActiveLocalCS();
1329 aTrans.SetTransformation(aWPlane);
1330 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1331 aShape = aTransformation.Shape();
1334 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1337 Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1338 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1339 disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1340 disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1341 Group4Spin->SpinBox_DZ->setValue(myX);
1342 Group4Spin->SpinBox_DS->setValue(myY);
1343 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1344 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1345 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1346 if ( myLastX1 && myLastY1 ) {
1347 Group4Spin->SpinBox_DZ->setValue(myX - myLastX1);
1348 Group4Spin->SpinBox_DS->setValue(myY - myLastY1);
1350 if ( mySketchState != FIRST_POINT ) {
1351 Group4Spin->SpinBox_DZ->setValue(myX - tmpX);
1352 Group4Spin->SpinBox_DS->setValue(myY - tmpY);
1354 Group4Spin->SpinBox_DZ->setValue(myX);
1355 Group4Spin->SpinBox_DS->setValue(myY);
1363 if (nbSel == 0){ // If no object selected
1364 myX=tmpX; // Don't change the point coordinates
1365 myY=tmpY; // and don't redisplay the preview
1367 else if(!autoApply){
1368 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1374 this->activateWindow();
1379 //=================================================================================
1380 // function : SetEditCurrentArgument()
1382 //=================================================================================
1383 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1385 if ( sender() == Group1Sel->PushButton1 ) {
1386 myEditCurrentArgument = Group1Sel->LineEdit1;
1387 myEditCurrentArgument->setFocus();
1389 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1390 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1391 myEditCurrentArgument->setFocus();
1393 else if ( sender() == Group2Sel->PushButton1 ) {
1394 myEditCurrentArgument = Group2Sel->LineEdit1;
1395 Group2Sel->PushButton2->setDown(false);
1396 Group2Sel->PushButton1->setDown(true);
1397 Group2Sel->LineEdit2->setEnabled(false);
1398 Group2Sel->LineEdit1->setEnabled(true);
1399 // myEditCurrentArgument->setFocus();
1401 else if ( sender() == Group2Sel->PushButton2 ) {
1402 myEditCurrentArgument = Group2Sel->LineEdit2;
1403 Group2Sel->PushButton1->setDown(false);
1404 Group2Sel->PushButton2->setDown(true);
1405 Group2Sel->LineEdit1->setEnabled(false);
1406 Group2Sel->LineEdit2->setEnabled(true);
1407 // myEditCurrentArgument->setFocus();
1409 SelectionIntoArgument();
1413 //=================================================================================
1414 // function : LineEditReturnPressed()
1416 //=================================================================================
1417 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1419 if ( sender() == Group1Sel->LineEdit1 )
1420 myEditCurrentArgument = Group1Sel->LineEdit1;
1421 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1422 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1423 else if ( sender() == Group2Sel->LineEdit1 )
1424 myEditCurrentArgument = Group2Sel->LineEdit1;
1425 else if ( sender() == Group2Sel->LineEdit2 )
1426 myEditCurrentArgument = Group2Sel->LineEdit2;
1428 /* User name of object input management */
1429 /* If successfull the selection is changed and signal emitted... */
1430 /* so SelectionIntoArgument() is automatically called. */
1431 const QString objectUserName = myEditCurrentArgument->text();
1432 QWidget* thisWidget = (QWidget*)this;
1434 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1435 SALOME_ListIO aSelList;
1436 aSelMgr->selectedObjects(aSelList);
1438 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1439 myEditCurrentArgument->setText( objectUserName );
1443 //=================================================================================
1444 // function : DeactivateActiveDialog()
1446 //=================================================================================
1447 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1449 //myGeometryGUI->SetState( -1 );
1451 setEnabled( false );
1453 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1454 myGeometryGUI->SetActiveDialogBox( 0 );
1458 //=================================================================================
1459 // function : ActivateThisDialog()
1461 //=================================================================================
1462 void EntityGUI_SketcherDlg::ActivateThisDialog()
1464 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1465 myGeometryGUI->EmitSignalDeactivateDialog();
1467 myGeometryGUI->SetActiveDialogBox( this );
1469 connect( myGeometryGUI->getApp()->selectionMgr(),
1470 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1472 //myGeometryGUI->SetState( 0 );
1473 globalSelection( GEOM_POINT );
1475 myEditCurrentArgument = Group1Sel->LineEdit1;
1476 myEditCurrentArgument->setFocus();
1478 if ( sender() == Group1Sel->LineEdit1 ) {
1479 myEditCurrentArgument = Group1Sel->LineEdit1;
1480 myEditCurrentArgument->setFocus();
1482 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1483 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1484 myEditCurrentArgument->setFocus();
1486 else if ( sender() == Group2Sel->LineEdit1 ) {
1487 myEditCurrentArgument = Group2Sel->LineEdit1;
1488 myEditCurrentArgument->setFocus();
1490 else if ( sender() == Group2Sel->LineEdit2 ) {
1491 myEditCurrentArgument = Group2Sel->LineEdit2;
1492 myEditCurrentArgument->setFocus();
1495 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1499 //=================================================================================
1500 // function : enterEvent [REDEFINED]
1502 //=================================================================================
1503 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1506 ActivateThisDialog();
1510 //=================================================================================
1511 // function : closeEvent()
1513 //=================================================================================
1514 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1516 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1517 //myGeometryGUI->SetState( -1 );
1518 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1519 myGeometryGUI->getApp()->updateActions();
1520 QDialog::closeEvent( e );
1523 //=================================================================================
1524 // function : OnPointSelected
1526 //=================================================================================
1527 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt)
1529 MESSAGE("EntityGUI_SketcherDlg::OnPointSelected")
1531 SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
1532 OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
1533 QString theImgFileName;
1534 vp->background().texture( theImgFileName ); ////////////// VSR: temporarily
1539 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1540 TopoDS_Shape aShape = mkVertex.Shape();
1542 // Taking into account LocalCS
1543 gp_Ax3 aWPlane = GetActiveLocalCS();
1546 aTrans.SetTransformation(aWPlane);
1547 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1548 aShape = aTransformation.Shape();
1551 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1553 autoApply = ( (getPnt2ConstructorId() == 1) && (!theImgFileName.isEmpty()) ); // If no additional argument needed after selection and there is a backgroundimage
1554 // -> apply automatically
1556 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1557 x = aTrsfPnt.X() - myLastX1;
1558 y = aTrsfPnt.Y() - myLastY1;
1564 switch (getPnt2ConstructorId()){
1566 Group2Spin->SpinBox_DX->setValue( x );
1567 Group2Spin->SpinBox_DY->setValue( y );
1568 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1571 Group3Spin->SpinBox_DX->setValue( x );
1572 Group3Spin->SpinBox_DY->setValue( y );
1573 Group3Spin->buttonApply->setFocus();
1576 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1577 Group4Spin->SpinBox_DX->setValue( x );
1578 Group4Spin->SpinBox_DY->setValue( y );
1580 else{ // Select end point
1581 Group4Spin->SpinBox_DZ->setValue( x );
1582 Group4Spin->SpinBox_DS->setValue( y );
1584 Group4Spin->buttonApply->setFocus();
1589 //=================================================================================
1590 // function : ValueChangedInSpinBox()
1592 //=================================================================================
1593 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1595 MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
1596 QObject* send = (QObject*)sender();
1597 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1598 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1600 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1601 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1602 double LastDecimal = 0.0;
1604 QString vxStr, vyStr, vzStr, vsStr;
1606 QString newValueStr;
1607 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1608 newValueStr = aDoubleSpinBox->text();
1610 if ( send == Group1Spin->SpinBox_DX ) {
1611 vx = newValue; vxStr = newValueStr;
1613 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1614 vx = newValue; vxStr = newValueStr;
1616 else if ( send == Group2Spin->SpinBox_DX ) {
1617 vx = newValue; vxStr = newValueStr;
1618 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1620 else if ( send == Group2Spin->SpinBox_DY ) {
1621 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1622 vy = newValue; vyStr = newValueStr;
1624 else if ( send == Group3Spin->SpinBox_DX ) {
1625 vx = newValue; vxStr = newValueStr;
1626 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1627 vz = Group3Spin->SpinBox_DZ->value();
1628 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1629 if (mySketchType == PT_ABS_RADIUS){
1637 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1638 if (aPrecision >= 0) // 'f' format in the QString
1639 LastDecimal = aPrecision;
1640 else // 'g' format in the Qstring
1641 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1642 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1643 if ( Abs(vz) < minRad){
1645 Group3Spin->SpinBox_DZ->setValue( - minRad );
1647 Group3Spin->SpinBox_DZ->setValue( minRad );
1650 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1652 else if ( send == Group3Spin->SpinBox_DY ) {
1653 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1654 vy = newValue; vyStr = newValueStr;
1655 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1656 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1657 if (mySketchType == PT_ABS_RADIUS){
1665 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1666 if (aPrecision >= 0) // 'f' format in the QString
1667 LastDecimal = aPrecision;
1668 else // 'g' format in the QString
1669 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1670 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1671 if ( Abs(vz) < minRad){
1673 Group3Spin->SpinBox_DZ->setValue( - minRad );
1675 Group3Spin->SpinBox_DZ->setValue( minRad );
1678 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1680 else if ( send == Group3Spin->SpinBox_DZ ) {
1681 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1682 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1683 vz = newValue; vzStr = newValueStr;
1685 else if ( send == Group4Spin->SpinBox_DX ) {
1686 vx = newValue; vxStr = newValueStr;
1687 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1688 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1689 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1691 else if ( send == Group4Spin->SpinBox_DY ) {
1692 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1693 vy = newValue; vyStr = newValueStr;
1694 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1695 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1697 else if ( send == Group4Spin->SpinBox_DZ ) {
1698 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1699 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1700 vz = newValue; vzStr = newValueStr;
1701 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1703 else if ( send == Group4Spin->SpinBox_DS ) {
1704 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1705 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1706 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1707 vs = newValue; vsStr = newValueStr;
1709 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1711 if ( myConstructorId == 0 ) { // SEGMENT
1712 if ( mySketchType == PT_ABS ) {
1718 else if ( mySketchType == PT_RELATIVE ) {
1724 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1728 myLengthStr = vyStr;
1730 else if ( mySketchType == DIR_ANGLE_X ) {
1736 else if ( mySketchType == DIR_ANGLE_Y ) {
1742 else if ( mySketchType == DIR_PER_LENGTH ) {
1744 myLengthStr = vxStr;
1746 else if ( mySketchType == DIR_PER_X ) {
1750 else if ( mySketchType == DIR_PER_Y ) {
1754 else if ( mySketchType == DIR_TAN_LENGTH ) {
1756 myLengthStr = vxStr;
1758 else if ( mySketchType == DIR_TAN_X ) {
1762 else if ( mySketchType == DIR_TAN_Y ) {
1766 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1772 myLengthStr = vzStr;
1774 else if ( mySketchType == DIR_DXDY_X ) {
1782 else if ( mySketchType == DIR_DXDY_Y ) {
1791 else if ( myConstructorId == 1 ) { // ARC
1792 if ( mySketchType == PT_ABS ) {
1798 else if ( mySketchType == PT_RELATIVE ) {
1804 if ( mySketchType == PT_ABS_RADIUS ) {
1810 myRadiusStr = vzStr;
1812 else if ( mySketchType == PT_REL_RADIUS ) {
1818 myRadiusStr = vzStr;
1820 else if ( mySketchType == PT_SEL_RADIUS ) {
1822 myRadiusStr = vxStr;
1824 if ( mySketchType == PT_ABS_CENTER ) {
1834 else if ( mySketchType == PT_REL_CENTER ) {
1844 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1849 myRadiusStr = vyStr;
1850 myLengthStr = vzStr;
1852 else if ( mySketchType == DIR_PER_LENGTH ) {
1855 myRadiusStr = vxStr;
1856 myLengthStr = vyStr;
1858 else if ( mySketchType == DIR_TAN_LENGTH ) {
1861 myRadiusStr = vxStr;
1862 myLengthStr = vyStr;
1864 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1871 myRadiusStr = vzStr;
1872 myLengthStr = vsStr;
1877 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1879 double x, y, xc, yc;
1880 x = y = xc = yc = 0.0;
1881 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
1883 if ( mySketchType == PT_REL_CENTER ){
1884 x = myDX + myLastX1;
1885 y = myDY + myLastY1;
1886 xc = myDXc + myLastX1;
1887 yc = myDYc + myLastY1;
1895 displayPntPreview(xc,yc);
1896 displayPntPreview(x,y);
1901 //=================================================================================
1902 // function : GetNewCommand()
1903 // purpose : Build the new command with context
1904 //=================================================================================
1905 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1907 theParameters.clear();
1908 QString myNewCommand = ":";
1909 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1910 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1911 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1913 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1914 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1916 if ( mySketchState == FIRST_POINT ) {
1917 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1918 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1919 theParameters = myXStr + ":" + myYStr;
1921 if ( mySketchType == PT_RELATIVE) {
1922 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1923 theParameters = myDXStr + ":" + myDYStr;
1925 return myNewCommand;
1928 if ( myConstructorId == 0 ) { // SEGMENT
1929 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1930 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1931 theParameters = myXStr + ":" + myYStr;
1933 if ( mySketchType == PT_RELATIVE) {
1934 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1935 theParameters = myDXStr + ":" + myDYStr;
1937 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1938 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1939 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1940 theParameters = myAngleStr + ":" + myLengthStr;
1942 if ( mySketchType == DIR_ANGLE_X ) {
1943 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1944 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1945 theParameters = myAngleStr + ":" + myXStr;
1947 if ( mySketchType == DIR_ANGLE_Y ) {
1948 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1949 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1950 theParameters = myAngleStr + ":" + myYStr;
1952 if ( mySketchType == DIR_PER_LENGTH ) {
1953 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1954 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1955 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1957 if ( mySketchType == DIR_PER_X ) {
1958 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1959 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1960 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1962 if ( mySketchType == DIR_PER_Y ) {
1963 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1964 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1965 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1967 if ( mySketchType == DIR_TAN_LENGTH ) {
1968 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1969 theParameters = myLengthStr;
1971 if ( mySketchType == DIR_TAN_X ) {
1972 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1973 theParameters = myXStr;
1975 if ( mySketchType == DIR_TAN_Y) {
1976 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1977 theParameters = myYStr;
1979 if ( mySketchType == DIR_DXDY_LENGTH ) {
1980 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1981 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1982 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1984 if ( mySketchType == DIR_DXDY_X ) {
1985 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1986 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1987 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1989 if ( mySketchType == DIR_DXDY_Y ) {
1990 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1991 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1992 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1995 else if ( myConstructorId == 1 ) { // ARC
1996 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1997 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1998 theParameters = myXStr + ":" + myYStr;
2000 if ( mySketchType == PT_RELATIVE) {
2001 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2002 theParameters = myDXStr + ":" + myDYStr;
2004 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
2005 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
2006 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
2008 if ( mySketchType == PT_REL_RADIUS) {
2009 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
2010 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
2012 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2013 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 );
2014 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2016 if ( mySketchType == PT_REL_CENTER) {
2017 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 );
2018 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2020 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2021 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2022 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2023 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2025 if ( mySketchType == DIR_PER_LENGTH ) {
2026 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2027 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2028 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2030 if ( mySketchType == DIR_TAN_LENGTH ) {
2031 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2032 theParameters = myRadiusStr + ":" + myLengthStr;
2034 if ( mySketchType == DIR_DXDY_LENGTH ) {
2035 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2036 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2037 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2040 return myNewCommand;
2043 //=================================================================================
2044 // function : createOperation
2046 //=================================================================================
2047 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2049 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2052 //=================================================================================
2053 // function : isValid
2055 //=================================================================================
2056 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2059 bool toCorrect = !IsPreview() || myIsApply;
2061 if( Group1Spin->isVisible() ) {
2062 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2064 else if( Group1Sel1Spin->isVisible() ) {
2065 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2067 else if( Group2Spin->isVisible() ) {
2068 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2069 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2071 else if( Group3Spin->isVisible() ) {
2072 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2073 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2074 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2076 else if( Group4Spin->isVisible() ) {
2077 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2078 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2079 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2080 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2083 if( myIsApply && !ok )
2089 //=================================================================================
2090 // function : execute
2092 //=================================================================================
2093 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2095 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2096 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2097 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2099 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2100 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2102 QString aParameters;
2104 if ( mySketchState == FIRST_POINT ) {
2109 //Test if the current point is the same as the last one
2110 TopoDS_Shape myShape1, myShape2;
2112 // Set "C" numeric locale
2113 Kernel_Utils::Localizer loc;
2116 QString Command1 = myCommand.join( "" );
2117 Sketcher_Profile aProfile1( Command1.toAscii() );
2118 if ( aProfile1.IsDone() )
2119 myShape1 = aProfile1.GetShape();
2122 QString Command2 = Command1 + GetNewCommand( aParameters );
2123 Sketcher_Profile aProfile2( Command2.toAscii() );
2126 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2127 if (aProfile2.Error() > Precision::Confusion()){
2128 Group4Spin->label->show();
2129 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2132 Group4Spin->label->hide();
2136 Group4Spin->label->hide();
2137 if ( mySketchType == PT_SEL_CENTER ){
2138 if (aProfile2.Error() > Precision::Confusion()){
2139 Group2Sel->label->show();
2140 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2143 Group2Sel->label->hide();
2147 Group2Sel->label->hide();
2149 if ( aProfile2.IsDone() )
2150 myShape2 = aProfile2.GetShape();
2152 if ( myShape2.IsNull() ) {
2153 //the current point is the same as the last one
2154 myLastX2 = myLastX1;
2155 myLastY2 = myLastY1;
2158 TopoDS_Vertex V1, V2;
2160 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2161 //the last shape is the first point
2162 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2167 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2168 pt = BRep_Tool::Pnt( V2 );
2172 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2173 pt = BRep_Tool::Pnt( V2 );
2180 if ( ( mySketchState != FIRST_POINT &&
2181 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2182 cmd = myCommand.join( "" );
2183 if ( Group1Sel->isVisible() ) {
2184 Group1Sel->buttonApply->setEnabled( false );
2185 //Group1Sel->buttonApply->setFocus();
2187 if ( Group2Sel->isVisible() ) {
2188 Group2Sel->buttonApply->setEnabled( false );
2189 //Group2Sel->buttonApply->setFocus();
2191 if ( Group1Sel1Spin->isVisible() ) {
2192 Group1Sel1Spin->buttonApply->setEnabled( false );
2193 //Group1Sel1Spin->buttonApply->setFocus();
2195 if ( Group1Spin->isVisible() ) {
2196 Group1Spin->buttonApply->setEnabled( false );
2197 //Group1Spin->buttonApply->setFocus();
2199 if ( Group2Spin->isVisible() ) {
2200 Group2Spin->buttonApply->setEnabled( false );
2201 //Group2Spin->buttonApply->setFocus();
2203 if ( Group3Spin->isVisible() ) {
2204 Group3Spin->buttonApply->setEnabled( false );
2205 //Group3Spin->buttonApply->setFocus();
2207 if ( Group4Spin->isVisible() ) {
2208 Group4Spin->buttonApply->setEnabled( false );
2209 //Group4Spin->buttonApply->setFocus();
2213 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2215 if ( Group1Sel->isVisible() ) {
2216 Group1Sel->buttonApply->setEnabled( true );
2218 if ( Group2Sel->isVisible() ) {
2219 Group2Sel->buttonApply->setEnabled( true );
2221 if ( Group1Sel1Spin->isVisible() ) {
2222 Group1Sel1Spin->buttonApply->setEnabled( true );;
2224 if ( Group1Spin->isVisible() ) {
2225 Group1Spin->buttonApply->setEnabled( true );
2227 if ( Group2Spin->isVisible() ) {
2228 Group2Spin->buttonApply->setEnabled( true );
2230 if ( Group3Spin->isVisible() ) {
2231 Group3Spin->buttonApply->setEnabled( true );
2233 if ( Group4Spin->isVisible() ) {
2234 Group4Spin->buttonApply->setEnabled( true );
2238 gp_Ax3 myWPlane = GetActiveLocalCS();
2239 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2240 WPlane->length( 9 );
2241 WPlane[0] = myWPlane.Location().X();
2242 WPlane[1] = myWPlane.Location().Y();
2243 WPlane[2] = myWPlane.Location().Z();
2245 WPlane[3] = myWPlane.Direction().X();
2246 WPlane[4] = myWPlane.Direction().Y();
2247 WPlane[5] = myWPlane.Direction().Z();
2249 WPlane[6] = myWPlane.XDirection().X();
2250 WPlane[7] = myWPlane.XDirection().Y();
2251 WPlane[8] = myWPlane.XDirection().Z();
2253 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2254 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2256 if ( !anObj->_is_nil() )
2258 if( !IsPreview() ) {
2259 QStringList aCurrentParameters = myParameters;
2260 aCurrentParameters << aParameters;
2261 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2264 objects.push_back( anObj._retn() );
2270 //================================================================
2271 // Function : displayPreview
2272 // Purpose : Method for displaying preview of resulting shape
2273 // Redefined from GEOMBase_Helper.
2274 //================================================================
2275 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2277 const bool activate,
2279 const double lineWidth,
2280 const int displayMode,
2283 // Set color for preview shape
2284 getDisplayer()->SetColor( Quantity_NOC_RED );
2286 // set width of displayed shape
2287 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2289 // Disable activation of selection
2290 getDisplayer()->SetToActivate( activate );
2292 // Make a reference to GEOM_Object
2293 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2294 getDisplayer()->SetName( objStr.in() );
2296 // Create wire from applayed object
2297 TopoDS_Shape anApplyedWire, aLastSegment;
2298 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2302 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2303 if ( aPrs != 0 && !aPrs->IsNull() )
2304 GEOMBase_Helper::displayPreview( aPrs, append, update );
2306 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2307 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2308 if ( aPrs != 0 && !aPrs->IsNull() )
2309 GEOMBase_Helper::displayPreview( aPrs, append, update );
2311 getDisplayer()->UnsetName();
2313 // Enable activation of displayed objects
2314 getDisplayer()->SetToActivate( true );
2317 //================================================================
2318 // Function : displayPntPreview
2319 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2320 //================================================================
2321 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2327 // Get globalCS and working plane
2328 gp_Ax3 globalCS = myLCSList.first(); //gp_Ax3(aOrigin, aDirZ, aDirX);
2329 gp_Ax3 aWPlane = GetActiveLocalCS();
2331 // Build point in localCS
2332 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2334 // Get transfomation from local to global CS
2336 aTrans.SetTransformation(aWPlane, globalCS);
2338 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2339 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2341 // Perform transformation
2342 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2343 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2345 // Build prs with vertex in globalCS
2346 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2347 if ( aPrs != 0 && !aPrs->IsNull() )
2348 GEOMBase_Helper::displayPreview( aPrs, append, update );
2352 //================================================================
2353 // Function : createShapes
2354 // Purpose : Create applyed wire, and last segment from entry object
2355 //================================================================
2356 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2357 TopoDS_Shape& theApplyedWire,
2358 TopoDS_Shape& theLastSegment )
2360 TopoDS_Shape aShape;
2361 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2362 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2365 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2366 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2367 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2368 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2369 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2370 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2371 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2372 theApplyedWire = aShape;
2376 BRepBuilderAPI_MakeWire aBuilder;
2377 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2379 TopoDS_Shape anEdge = anExp.Current();
2381 if ( anExp.More() ) // i.e. non-last edge
2382 aBuilder.Add( TopoDS::Edge( anEdge ) );
2384 theLastSegment = anEdge;
2389 if ( aBuilder.IsDone() )
2390 theApplyedWire = aBuilder.Shape();
2395 //=================================================================================
2396 // function : keyPressEvent()
2398 //=================================================================================
2399 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2401 QDialog::keyPressEvent( e );
2402 if ( e->isAccepted() )
2405 if ( e->key() == Qt::Key_F1 ) {
2411 //=================================================================================
2412 // function : initSpinBox()
2414 //=================================================================================
2415 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2416 double min, double max,
2417 double step, const char* quantity )
2419 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2420 // TODO: Think how to keep the single piece of code...
2422 // Obtain precision from preferences
2423 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2424 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2426 spinBox->setPrecision( aPrecision );
2427 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2428 // by default Qt rounds boundaries to 2 decimals at setRange
2429 spinBox->setRange( min, max );
2430 spinBox->setSingleStep( step );
2432 // Add a hint for the user saying how to tune precision
2433 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2434 spinBox->setProperty( "validity_tune_hint",
2435 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2438 //=================================================================================
2439 // function : SetDoubleSpinBoxStep()
2440 // purpose : Double spin box management
2441 //=================================================================================
2442 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2444 Group1Spin->SpinBox_DX->setSingleStep(step);
2445 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2446 Group2Spin->SpinBox_DX->setSingleStep(step);
2447 Group2Spin->SpinBox_DY->setSingleStep(step);
2448 Group3Spin->SpinBox_DX->setSingleStep(step);
2449 Group3Spin->SpinBox_DY->setSingleStep(step);
2450 Group3Spin->SpinBox_DZ->setSingleStep(step);
2451 Group4Spin->SpinBox_DZ->setSingleStep(step);
2453 // san: Do NOT override the step when a speicifc step value is used
2454 // in some input fields!
2455 //Group4Spin->SpinBox_DX->setSingleStep(step);
2456 //Group4Spin->SpinBox_DY->setSingleStep(step);
2457 //Group4Spin->SpinBox_DS->setSingleStep(step);
2460 //=================================================================================
2461 // function : FindLocalCS()
2462 // purpose : Find All Coordinates systems in study
2463 //=================================================================================
2464 void EntityGUI_SketcherDlg::FindLocalCS()
2468 SalomeApp_Application* app =
2469 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2473 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2477 _PTR(Study) aStudy = appStudy->studyDS();
2480 ComboBox1->addItem(tr("GEOM_GCS"));
2481 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2482 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2483 gp_Dir aDirX = gp_Dir(1, 0, 0);
2484 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2485 myLCSList.push_back(globalCS);
2487 // get GEOM component
2488 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2489 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2492 _PTR(SComponent) fc = obj->GetFatherComponent();
2493 QString geomComp = fc->GetID().c_str();
2494 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2498 // browse through all GEOM data tree
2499 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2500 for ( it->InitEx( true ); it->More(); it->Next() ) {
2501 _PTR(SObject) child( it->Value() );
2502 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2503 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2504 if( CORBA::is_nil( geomObj ) )
2506 if (geomObj->GetType() == GEOM_MARKER) {
2507 ComboBox1->addItem(geomObj->GetName());
2508 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2511 aLCS.Transform(aShape.Location().Transformation());
2512 if (aShape.ShapeType() == TopAbs_FACE) {
2513 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2514 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2515 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2516 gp_Pln aPln = aGPlane->Pln();
2517 aLCS = aPln.Position();
2520 myLCSList.push_back(aLCS);
2525 //=================================================================================
2526 // function : getPnt1ConstructorId()
2528 //=================================================================================
2529 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2531 int buttonId = GroupPt->ButtonGroup->checkedId();
2532 // MESSAGE("buttonId = "<<buttonId)
2536 //=================================================================================
2537 // function : getPnt2ConstructorId()
2539 //=================================================================================
2540 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2542 int buttonId = GroupPt2->ButtonGroup->checkedId();
2543 // MESSAGE("buttonId = "<<buttonId)
2547 //=================================================================================
2548 // function : GetActiveLocalCS()
2549 // purpose : Get Working plane
2550 //=================================================================================
2551 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2553 int ind = ComboBox1->currentIndex();
2555 return myGeometryGUI->GetWorkingPlane();
2557 gp_Ax3 aLCS = myLCSList.at(ind);
2562 //=================================================================================
2563 // function : ActivateLocalCS()
2564 // purpose : Activate & Fit Working plane
2565 //=================================================================================
2566 void EntityGUI_SketcherDlg::ActivateLocalCS()
2568 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2569 myGeometryGUI->ActiveWorkingPlane();