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_DIR" ) );
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 = vp->backgroundImageFilename();
1538 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1539 TopoDS_Shape aShape = mkVertex.Shape();
1541 // Taking into account LocalCS
1542 gp_Ax3 aWPlane = GetActiveLocalCS();
1545 aTrans.SetTransformation(aWPlane);
1546 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1547 aShape = aTransformation.Shape();
1550 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1552 autoApply = ( (getPnt2ConstructorId() == 1) && (!theImgFileName.isEmpty()) ); // If no additional argument needed after selection and there is a backgroundimage
1553 // -> apply automatically
1555 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1556 x = aTrsfPnt.X() - myLastX1;
1557 y = aTrsfPnt.Y() - myLastY1;
1563 switch (getPnt2ConstructorId()){
1565 Group2Spin->SpinBox_DX->setValue( x );
1566 Group2Spin->SpinBox_DY->setValue( y );
1567 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1570 Group3Spin->SpinBox_DX->setValue( x );
1571 Group3Spin->SpinBox_DY->setValue( y );
1572 Group3Spin->buttonApply->setFocus();
1575 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1576 Group4Spin->SpinBox_DX->setValue( x );
1577 Group4Spin->SpinBox_DY->setValue( y );
1579 else{ // Select end point
1580 Group4Spin->SpinBox_DZ->setValue( x );
1581 Group4Spin->SpinBox_DS->setValue( y );
1583 Group4Spin->buttonApply->setFocus();
1588 //=================================================================================
1589 // function : ValueChangedInSpinBox()
1591 //=================================================================================
1592 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1594 MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
1595 QObject* send = (QObject*)sender();
1596 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1597 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1599 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1600 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1601 double LastDecimal = 0.0;
1603 QString vxStr, vyStr, vzStr, vsStr;
1605 QString newValueStr;
1606 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1607 newValueStr = aDoubleSpinBox->text();
1609 if ( send == Group1Spin->SpinBox_DX ) {
1610 vx = newValue; vxStr = newValueStr;
1612 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1613 vx = newValue; vxStr = newValueStr;
1615 else if ( send == Group2Spin->SpinBox_DX ) {
1616 vx = newValue; vxStr = newValueStr;
1617 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1619 else if ( send == Group2Spin->SpinBox_DY ) {
1620 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1621 vy = newValue; vyStr = newValueStr;
1623 else if ( send == Group3Spin->SpinBox_DX ) {
1624 vx = newValue; vxStr = newValueStr;
1625 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1626 vz = Group3Spin->SpinBox_DZ->value();
1627 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1628 if (mySketchType == PT_ABS_RADIUS){
1636 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1637 if (aPrecision >= 0) // 'f' format in the QString
1638 LastDecimal = aPrecision;
1639 else // 'g' format in the Qstring
1640 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1641 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1642 if ( Abs(vz) < minRad){
1644 Group3Spin->SpinBox_DZ->setValue( - minRad );
1646 Group3Spin->SpinBox_DZ->setValue( minRad );
1649 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1651 else if ( send == Group3Spin->SpinBox_DY ) {
1652 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1653 vy = newValue; vyStr = newValueStr;
1654 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1655 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1656 if (mySketchType == PT_ABS_RADIUS){
1664 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1665 if (aPrecision >= 0) // 'f' format in the QString
1666 LastDecimal = aPrecision;
1667 else // 'g' format in the QString
1668 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1669 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1670 if ( Abs(vz) < minRad){
1672 Group3Spin->SpinBox_DZ->setValue( - minRad );
1674 Group3Spin->SpinBox_DZ->setValue( minRad );
1677 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1679 else if ( send == Group3Spin->SpinBox_DZ ) {
1680 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1681 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1682 vz = newValue; vzStr = newValueStr;
1684 else if ( send == Group4Spin->SpinBox_DX ) {
1685 vx = newValue; vxStr = newValueStr;
1686 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1687 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1688 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1690 else if ( send == Group4Spin->SpinBox_DY ) {
1691 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1692 vy = newValue; vyStr = newValueStr;
1693 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1694 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1696 else if ( send == Group4Spin->SpinBox_DZ ) {
1697 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1698 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1699 vz = newValue; vzStr = newValueStr;
1700 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1702 else if ( send == Group4Spin->SpinBox_DS ) {
1703 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1704 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1705 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1706 vs = newValue; vsStr = newValueStr;
1708 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1710 if ( myConstructorId == 0 ) { // SEGMENT
1711 if ( mySketchType == PT_ABS ) {
1717 else if ( mySketchType == PT_RELATIVE ) {
1723 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1727 myLengthStr = vyStr;
1729 else if ( mySketchType == DIR_ANGLE_X ) {
1735 else if ( mySketchType == DIR_ANGLE_Y ) {
1741 else if ( mySketchType == DIR_PER_LENGTH ) {
1743 myLengthStr = vxStr;
1745 else if ( mySketchType == DIR_PER_X ) {
1749 else if ( mySketchType == DIR_PER_Y ) {
1753 else if ( mySketchType == DIR_TAN_LENGTH ) {
1755 myLengthStr = vxStr;
1757 else if ( mySketchType == DIR_TAN_X ) {
1761 else if ( mySketchType == DIR_TAN_Y ) {
1765 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1771 myLengthStr = vzStr;
1773 else if ( mySketchType == DIR_DXDY_X ) {
1781 else if ( mySketchType == DIR_DXDY_Y ) {
1790 else if ( myConstructorId == 1 ) { // ARC
1791 if ( mySketchType == PT_ABS ) {
1797 else if ( mySketchType == PT_RELATIVE ) {
1803 if ( mySketchType == PT_ABS_RADIUS ) {
1809 myRadiusStr = vzStr;
1811 else if ( mySketchType == PT_REL_RADIUS ) {
1817 myRadiusStr = vzStr;
1819 else if ( mySketchType == PT_SEL_RADIUS ) {
1821 myRadiusStr = vxStr;
1823 if ( mySketchType == PT_ABS_CENTER ) {
1833 else if ( mySketchType == PT_REL_CENTER ) {
1843 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1848 myRadiusStr = vyStr;
1849 myLengthStr = vzStr;
1851 else if ( mySketchType == DIR_PER_LENGTH ) {
1854 myRadiusStr = vxStr;
1855 myLengthStr = vyStr;
1857 else if ( mySketchType == DIR_TAN_LENGTH ) {
1860 myRadiusStr = vxStr;
1861 myLengthStr = vyStr;
1863 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1870 myRadiusStr = vzStr;
1871 myLengthStr = vsStr;
1876 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1878 double x, y, xc, yc;
1879 x = y = xc = yc = 0.0;
1880 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
1882 if ( mySketchType == PT_REL_CENTER ){
1883 x = myDX + myLastX1;
1884 y = myDY + myLastY1;
1885 xc = myDXc + myLastX1;
1886 yc = myDYc + myLastY1;
1894 displayPntPreview(xc,yc);
1895 displayPntPreview(x,y);
1900 //=================================================================================
1901 // function : GetNewCommand()
1902 // purpose : Build the new command with context
1903 //=================================================================================
1904 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1906 theParameters.clear();
1907 QString myNewCommand = ":";
1908 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1909 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1910 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1912 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1913 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1915 if ( mySketchState == FIRST_POINT ) {
1916 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1917 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1918 theParameters = myXStr + ":" + myYStr;
1920 if ( mySketchType == PT_RELATIVE) {
1921 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1922 theParameters = myDXStr + ":" + myDYStr;
1924 return myNewCommand;
1927 if ( myConstructorId == 0 ) { // SEGMENT
1928 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1929 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1930 theParameters = myXStr + ":" + myYStr;
1932 if ( mySketchType == PT_RELATIVE) {
1933 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1934 theParameters = myDXStr + ":" + myDYStr;
1936 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1937 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1938 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1939 theParameters = myAngleStr + ":" + myLengthStr;
1941 if ( mySketchType == DIR_ANGLE_X ) {
1942 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1943 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1944 theParameters = myAngleStr + ":" + myXStr;
1946 if ( mySketchType == DIR_ANGLE_Y ) {
1947 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1948 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1949 theParameters = myAngleStr + ":" + myYStr;
1951 if ( mySketchType == DIR_PER_LENGTH ) {
1952 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1953 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1954 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1956 if ( mySketchType == DIR_PER_X ) {
1957 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1958 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1959 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1961 if ( mySketchType == DIR_PER_Y ) {
1962 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1963 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1964 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1966 if ( mySketchType == DIR_TAN_LENGTH ) {
1967 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1968 theParameters = myLengthStr;
1970 if ( mySketchType == DIR_TAN_X ) {
1971 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1972 theParameters = myXStr;
1974 if ( mySketchType == DIR_TAN_Y) {
1975 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1976 theParameters = myYStr;
1978 if ( mySketchType == DIR_DXDY_LENGTH ) {
1979 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1980 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1981 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1983 if ( mySketchType == DIR_DXDY_X ) {
1984 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1985 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1986 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1988 if ( mySketchType == DIR_DXDY_Y ) {
1989 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1990 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1991 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1994 else if ( myConstructorId == 1 ) { // ARC
1995 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1996 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1997 theParameters = myXStr + ":" + myYStr;
1999 if ( mySketchType == PT_RELATIVE) {
2000 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2001 theParameters = myDXStr + ":" + myDYStr;
2003 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
2004 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
2005 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
2007 if ( mySketchType == PT_REL_RADIUS) {
2008 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
2009 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
2011 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2012 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 );
2013 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2015 if ( mySketchType == PT_REL_CENTER) {
2016 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 );
2017 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2019 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2020 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2021 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2022 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2024 if ( mySketchType == DIR_PER_LENGTH ) {
2025 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2026 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2027 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2029 if ( mySketchType == DIR_TAN_LENGTH ) {
2030 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2031 theParameters = myRadiusStr + ":" + myLengthStr;
2033 if ( mySketchType == DIR_DXDY_LENGTH ) {
2034 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2035 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2036 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2039 return myNewCommand;
2042 //=================================================================================
2043 // function : createOperation
2045 //=================================================================================
2046 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2048 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2051 //=================================================================================
2052 // function : isValid
2054 //=================================================================================
2055 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2058 bool toCorrect = !IsPreview() || myIsApply;
2060 if( Group1Spin->isVisible() ) {
2061 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2063 else if( Group1Sel1Spin->isVisible() ) {
2064 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2066 else if( Group2Spin->isVisible() ) {
2067 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2068 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2070 else if( Group3Spin->isVisible() ) {
2071 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2072 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2073 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2075 else if( Group4Spin->isVisible() ) {
2076 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2077 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2078 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2079 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2082 if( myIsApply && !ok )
2088 //=================================================================================
2089 // function : execute
2091 //=================================================================================
2092 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2094 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2095 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2096 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2098 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2099 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2101 QString aParameters;
2103 if ( mySketchState == FIRST_POINT ) {
2108 //Test if the current point is the same as the last one
2109 TopoDS_Shape myShape1, myShape2;
2111 // Set "C" numeric locale
2112 Kernel_Utils::Localizer loc;
2115 QString Command1 = myCommand.join( "" );
2116 Sketcher_Profile aProfile1( Command1.toAscii() );
2117 if ( aProfile1.IsDone() )
2118 myShape1 = aProfile1.GetShape();
2121 QString Command2 = Command1 + GetNewCommand( aParameters );
2122 Sketcher_Profile aProfile2( Command2.toAscii() );
2125 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2126 if (aProfile2.Error() > Precision::Confusion()){
2127 Group4Spin->label->show();
2128 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2131 Group4Spin->label->hide();
2135 Group4Spin->label->hide();
2136 if ( mySketchType == PT_SEL_CENTER ){
2137 if (aProfile2.Error() > Precision::Confusion()){
2138 Group2Sel->label->show();
2139 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2142 Group2Sel->label->hide();
2146 Group2Sel->label->hide();
2148 if ( aProfile2.IsDone() )
2149 myShape2 = aProfile2.GetShape();
2151 if ( myShape2.IsNull() ) {
2152 //the current point is the same as the last one
2153 myLastX2 = myLastX1;
2154 myLastY2 = myLastY1;
2157 TopoDS_Vertex V1, V2;
2159 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2160 //the last shape is the first point
2161 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2166 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2167 pt = BRep_Tool::Pnt( V2 );
2171 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2172 pt = BRep_Tool::Pnt( V2 );
2179 if ( ( mySketchState != FIRST_POINT &&
2180 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2181 cmd = myCommand.join( "" );
2182 if ( Group1Sel->isVisible() ) {
2183 Group1Sel->buttonApply->setEnabled( false );
2184 //Group1Sel->buttonApply->setFocus();
2186 if ( Group2Sel->isVisible() ) {
2187 Group2Sel->buttonApply->setEnabled( false );
2188 //Group2Sel->buttonApply->setFocus();
2190 if ( Group1Sel1Spin->isVisible() ) {
2191 Group1Sel1Spin->buttonApply->setEnabled( false );
2192 //Group1Sel1Spin->buttonApply->setFocus();
2194 if ( Group1Spin->isVisible() ) {
2195 Group1Spin->buttonApply->setEnabled( false );
2196 //Group1Spin->buttonApply->setFocus();
2198 if ( Group2Spin->isVisible() ) {
2199 Group2Spin->buttonApply->setEnabled( false );
2200 //Group2Spin->buttonApply->setFocus();
2202 if ( Group3Spin->isVisible() ) {
2203 Group3Spin->buttonApply->setEnabled( false );
2204 //Group3Spin->buttonApply->setFocus();
2206 if ( Group4Spin->isVisible() ) {
2207 Group4Spin->buttonApply->setEnabled( false );
2208 //Group4Spin->buttonApply->setFocus();
2212 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2214 if ( Group1Sel->isVisible() ) {
2215 Group1Sel->buttonApply->setEnabled( true );
2217 if ( Group2Sel->isVisible() ) {
2218 Group2Sel->buttonApply->setEnabled( true );
2220 if ( Group1Sel1Spin->isVisible() ) {
2221 Group1Sel1Spin->buttonApply->setEnabled( true );;
2223 if ( Group1Spin->isVisible() ) {
2224 Group1Spin->buttonApply->setEnabled( true );
2226 if ( Group2Spin->isVisible() ) {
2227 Group2Spin->buttonApply->setEnabled( true );
2229 if ( Group3Spin->isVisible() ) {
2230 Group3Spin->buttonApply->setEnabled( true );
2232 if ( Group4Spin->isVisible() ) {
2233 Group4Spin->buttonApply->setEnabled( true );
2237 gp_Ax3 myWPlane = GetActiveLocalCS();
2238 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2239 WPlane->length( 9 );
2240 WPlane[0] = myWPlane.Location().X();
2241 WPlane[1] = myWPlane.Location().Y();
2242 WPlane[2] = myWPlane.Location().Z();
2244 WPlane[3] = myWPlane.Direction().X();
2245 WPlane[4] = myWPlane.Direction().Y();
2246 WPlane[5] = myWPlane.Direction().Z();
2248 WPlane[6] = myWPlane.XDirection().X();
2249 WPlane[7] = myWPlane.XDirection().Y();
2250 WPlane[8] = myWPlane.XDirection().Z();
2252 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2253 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2255 if ( !anObj->_is_nil() )
2257 if( !IsPreview() ) {
2258 QStringList aCurrentParameters = myParameters;
2259 aCurrentParameters << aParameters;
2260 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2263 objects.push_back( anObj._retn() );
2269 //================================================================
2270 // Function : displayPreview
2271 // Purpose : Method for displaying preview of resulting shape
2272 // Redefined from GEOMBase_Helper.
2273 //================================================================
2274 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2276 const bool activate,
2278 const double lineWidth,
2279 const int displayMode,
2282 // Set color for preview shape
2283 getDisplayer()->SetColor( Quantity_NOC_RED );
2285 // set width of displayed shape
2286 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2288 // Disable activation of selection
2289 getDisplayer()->SetToActivate( activate );
2291 // Make a reference to GEOM_Object
2292 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2293 getDisplayer()->SetName( objStr.in() );
2295 // Create wire from applayed object
2296 TopoDS_Shape anApplyedWire, aLastSegment;
2297 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2301 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2302 if ( aPrs != 0 && !aPrs->IsNull() )
2303 GEOMBase_Helper::displayPreview( aPrs, append, update );
2305 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2306 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2307 if ( aPrs != 0 && !aPrs->IsNull() )
2308 GEOMBase_Helper::displayPreview( aPrs, append, update );
2310 getDisplayer()->UnsetName();
2312 // Enable activation of displayed objects
2313 getDisplayer()->SetToActivate( true );
2316 //================================================================
2317 // Function : displayPntPreview
2318 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2319 //================================================================
2320 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2326 // Get globalCS and working plane
2327 gp_Ax3 globalCS = myLCSList.first(); //gp_Ax3(aOrigin, aDirZ, aDirX);
2328 gp_Ax3 aWPlane = GetActiveLocalCS();
2330 // Build point in localCS
2331 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2333 // Get transfomation from local to global CS
2335 aTrans.SetTransformation(aWPlane, globalCS);
2337 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2338 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2340 // Perform transformation
2341 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2342 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2344 // Build prs with vertex in globalCS
2345 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2346 if ( aPrs != 0 && !aPrs->IsNull() )
2347 GEOMBase_Helper::displayPreview( aPrs, append, update );
2351 //================================================================
2352 // Function : createShapes
2353 // Purpose : Create applyed wire, and last segment from entry object
2354 //================================================================
2355 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2356 TopoDS_Shape& theApplyedWire,
2357 TopoDS_Shape& theLastSegment )
2359 TopoDS_Shape aShape;
2360 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2361 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2364 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2365 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2366 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2367 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2368 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2369 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2370 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2371 theApplyedWire = aShape;
2375 BRepBuilderAPI_MakeWire aBuilder;
2376 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2378 TopoDS_Shape anEdge = anExp.Current();
2380 if ( anExp.More() ) // i.e. non-last edge
2381 aBuilder.Add( TopoDS::Edge( anEdge ) );
2383 theLastSegment = anEdge;
2388 if ( aBuilder.IsDone() )
2389 theApplyedWire = aBuilder.Shape();
2394 //=================================================================================
2395 // function : keyPressEvent()
2397 //=================================================================================
2398 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2400 QDialog::keyPressEvent( e );
2401 if ( e->isAccepted() )
2404 if ( e->key() == Qt::Key_F1 ) {
2410 //=================================================================================
2411 // function : initSpinBox()
2413 //=================================================================================
2414 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2415 double min, double max,
2416 double step, const char* quantity )
2418 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2419 // TODO: Think how to keep the single piece of code...
2421 // Obtain precision from preferences
2422 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2423 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2425 spinBox->setPrecision( aPrecision );
2426 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2427 // by default Qt rounds boundaries to 2 decimals at setRange
2428 spinBox->setRange( min, max );
2429 spinBox->setSingleStep( step );
2431 // Add a hint for the user saying how to tune precision
2432 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2433 spinBox->setProperty( "validity_tune_hint",
2434 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2437 //=================================================================================
2438 // function : SetDoubleSpinBoxStep()
2439 // purpose : Double spin box management
2440 //=================================================================================
2441 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2443 Group1Spin->SpinBox_DX->setSingleStep(step);
2444 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2445 Group2Spin->SpinBox_DX->setSingleStep(step);
2446 Group2Spin->SpinBox_DY->setSingleStep(step);
2447 Group3Spin->SpinBox_DX->setSingleStep(step);
2448 Group3Spin->SpinBox_DY->setSingleStep(step);
2449 Group3Spin->SpinBox_DZ->setSingleStep(step);
2450 Group4Spin->SpinBox_DZ->setSingleStep(step);
2452 // san: Do NOT override the step when a speicifc step value is used
2453 // in some input fields!
2454 //Group4Spin->SpinBox_DX->setSingleStep(step);
2455 //Group4Spin->SpinBox_DY->setSingleStep(step);
2456 //Group4Spin->SpinBox_DS->setSingleStep(step);
2459 //=================================================================================
2460 // function : FindLocalCS()
2461 // purpose : Find All Coordinates systems in study
2462 //=================================================================================
2463 void EntityGUI_SketcherDlg::FindLocalCS()
2467 SalomeApp_Application* app =
2468 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2472 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2476 _PTR(Study) aStudy = appStudy->studyDS();
2479 ComboBox1->addItem(tr("GEOM_GCS"));
2480 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2481 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2482 gp_Dir aDirX = gp_Dir(1, 0, 0);
2483 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2484 myLCSList.push_back(globalCS);
2486 // get GEOM component
2487 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2488 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2491 _PTR(SComponent) fc = obj->GetFatherComponent();
2492 QString geomComp = fc->GetID().c_str();
2493 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2497 // browse through all GEOM data tree
2498 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2499 for ( it->InitEx( true ); it->More(); it->Next() ) {
2500 _PTR(SObject) child( it->Value() );
2501 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2502 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2503 if( CORBA::is_nil( geomObj ) )
2505 if (geomObj->GetType() == GEOM_MARKER) {
2506 ComboBox1->addItem(geomObj->GetName());
2507 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2510 aLCS.Transform(aShape.Location().Transformation());
2511 if (aShape.ShapeType() == TopAbs_FACE) {
2512 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2513 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2514 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2515 gp_Pln aPln = aGPlane->Pln();
2516 aLCS = aPln.Position();
2519 myLCSList.push_back(aLCS);
2524 //=================================================================================
2525 // function : getPnt1ConstructorId()
2527 //=================================================================================
2528 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2530 int buttonId = GroupPt->ButtonGroup->checkedId();
2531 // MESSAGE("buttonId = "<<buttonId)
2535 //=================================================================================
2536 // function : getPnt2ConstructorId()
2538 //=================================================================================
2539 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2541 int buttonId = GroupPt2->ButtonGroup->checkedId();
2542 // MESSAGE("buttonId = "<<buttonId)
2546 //=================================================================================
2547 // function : GetActiveLocalCS()
2548 // purpose : Get Working plane
2549 //=================================================================================
2550 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2552 int ind = ComboBox1->currentIndex();
2554 return myGeometryGUI->GetWorkingPlane();
2556 gp_Ax3 aLCS = myLCSList.at(ind);
2561 //=================================================================================
2562 // function : ActivateLocalCS()
2563 // purpose : Activate & Fit Working plane
2564 //=================================================================================
2565 void EntityGUI_SketcherDlg::ActivateLocalCS()
2567 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2568 myGeometryGUI->ActiveWorkingPlane();