1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
27 #include "EntityGUI_SketcherDlg.h"
28 #include "EntityGUI_Widgets.h"
29 #include <SalomeApp_DoubleSpinBox.h>
32 #include <GeometryGUI.h>
33 #include <GEOMImpl_Types.hxx>
34 #include <Geom_Surface.hxx>
35 #include <Geom_Plane.hxx>
37 #include <SUIT_Desktop.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Application.h>
42 #include <LightApp_Application.h>
43 #include <LightApp_SelectionMgr.h>
47 #include <BRep_Tool.hxx>
49 #include <TopExp_Explorer.hxx>
50 #include <TopoDS_Vertex.hxx>
52 #include <BRepBuilderAPI_Transform.hxx>
53 #include <BRepBuilderAPI_MakeWire.hxx>
54 #include <Sketcher_Profile.hxx>
56 #include <SalomeApp_Study.h>
60 #include <Basics_Utils.hxx>
62 //=================================================================================
63 // class : EntityGUI_SketcherDlg()
64 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
65 // name 'name' and widget flags set to 'f'.
66 // The dialog will by default be modeless, unless you set 'modal' to
67 // TRUE to construct a modal dialog.
68 //=================================================================================
69 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
70 bool modal, Qt::WindowFlags fl,
71 const double lineWidth )
72 : QDialog( parent, fl ),
73 myIsAllAdded( false ),
75 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
77 myLineWidth( lineWidth )
80 setAttribute( Qt::WA_DeleteOnClose );
82 myGeometryGUI->SetActiveDialogBox(this);
84 MainWidget = new EntityGUI_Skeleton( this );
85 QVBoxLayout* topLayout = new QVBoxLayout( this );
86 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
88 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
89 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
90 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
91 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
93 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
94 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
95 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
97 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
99 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
100 MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) );
101 MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) );
102 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
103 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
104 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
105 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
107 /***************************************************************/
109 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
110 QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
111 planeLayout->setSpacing(6);
112 planeLayout->setMargin(11);
114 ComboBox1 = new QComboBox(GroupBox1);
115 ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
116 planeLayout->addWidget(ComboBox1);
118 planeButton = new QPushButton (GroupBox1);
119 planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
120 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
121 planeLayout->addWidget(planeButton);
123 topLayout->addWidget(GroupBox1);
124 topLayout->addWidget( MainWidget );
125 topLayout->setStretch( 1, 1);
127 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
129 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
130 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
131 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
132 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
134 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
136 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
137 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
138 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
139 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
141 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
143 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
144 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
145 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
146 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
147 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
149 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
151 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
152 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
153 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
154 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
156 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
157 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
158 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
159 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
160 Group1Sel->PushButton1->setIcon( image0 );
161 Group1Sel->buttonUndo->setIcon( image1 );
162 Group1Sel->buttonRedo->setIcon( image2 );
163 Group1Sel->LineEdit1->setReadOnly( true );
165 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
166 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
167 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
168 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
169 Group2Sel->PushButton1->setIcon( image0 );
170 Group2Sel->PushButton2->setIcon( image0 );
171 Group2Sel->buttonUndo->setIcon( image1 );
172 Group2Sel->buttonRedo->setIcon( image2 );
173 Group2Sel->LineEdit1->setReadOnly( true );
174 Group2Sel->LineEdit2->setReadOnly( true );
176 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
177 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
178 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
179 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
180 Group1Sel1Spin->PushButton1->setIcon( image0 );
181 Group1Sel1Spin->buttonUndo->setIcon( image1 );
182 Group1Sel1Spin->buttonRedo->setIcon( image2 );
183 Group1Sel1Spin->LineEdit1->setReadOnly( true );
185 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
186 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
187 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
188 Group1Spin->buttonUndo->setIcon( image1 );
189 Group1Spin->buttonRedo->setIcon( image2 );
191 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
192 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
193 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
194 Group2Spin->buttonUndo->setIcon( image1 );
195 Group2Spin->buttonRedo->setIcon( image2 );
197 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
198 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
199 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
200 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
201 Group3Spin->buttonUndo->setIcon( image1 );
202 Group3Spin->buttonRedo->setIcon( image2 );
204 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
205 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
206 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
207 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
208 Group4Spin->buttonUndo->setIcon( image1 );
209 Group4Spin->buttonRedo->setIcon( image2 );
211 // Defines a palette for the error message on Group4Spin and Group2Sel
214 palette.setColor(Group4Spin->label->foregroundRole(), color);
215 Group4Spin->label->setPalette(palette);
216 palette.setColor(Group2Sel->label->foregroundRole(), color);
217 Group2Sel->label->setPalette(palette);
219 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
220 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
221 DestCntLayout->addWidget( GroupPt, 0, 0 );
222 DestCntLayout->addWidget( GroupPt2, 0, 1 );
223 DestCntLayout->addWidget( GroupD1, 0, 0 );
224 DestCntLayout->addWidget( GroupD2, 0, 1 );
226 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
227 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
228 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
229 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
230 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
231 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
232 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
233 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
234 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
235 //SkeletonCntlayout->setStretch( 0, 1);
236 /***************************************************************/
238 QButtonGroup* ButtonGroup = new QButtonGroup( this );
239 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
240 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
242 /* signals and slots connections */
243 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
244 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
245 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
246 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
248 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
249 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
250 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
251 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
252 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
253 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
254 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
255 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
256 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
257 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
258 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
259 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
260 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
261 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
262 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
263 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
264 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
265 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
266 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
267 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
268 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
270 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
271 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
272 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
273 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
274 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
275 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
277 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
278 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
280 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
281 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
282 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
283 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
285 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
286 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
287 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
289 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
290 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
291 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
292 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
293 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
294 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
295 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
296 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
297 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
298 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
300 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
301 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
302 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
303 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
305 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
306 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
308 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
310 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
311 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
313 // install event filter on spin-boxes to provide Apply action on Return pressed
314 Group1Spin->SpinBox_DX->installEventFilter(this);
315 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
316 Group2Spin->SpinBox_DX->installEventFilter(this);
317 Group2Spin->SpinBox_DY->installEventFilter(this);
318 Group3Spin->SpinBox_DX->installEventFilter(this);
319 Group3Spin->SpinBox_DY->installEventFilter(this);
320 Group3Spin->SpinBox_DZ->installEventFilter(this);
321 Group4Spin->SpinBox_DX->installEventFilter(this);
322 Group4Spin->SpinBox_DY->installEventFilter(this);
323 Group4Spin->SpinBox_DZ->installEventFilter(this);
324 Group4Spin->SpinBox_DS->installEventFilter(this);
330 //=================================================================================
331 // function : ~EntityGUI_SketcherDlg()
332 // purpose : Destroys the object and frees any allocated resources
333 //=================================================================================
334 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
336 myGeometryGUI->SetActiveDialogBox( 0 );
340 //=================================================================================
341 // function : eventFilter()
342 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
343 //=================================================================================
344 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
346 if (event->type() == QEvent::KeyPress) {
347 QKeyEvent* ke = (QKeyEvent*)event;
348 if (ke->key() == Qt::Key_Return) {
349 if (object == Group1Spin->SpinBox_DX) {
350 Group1Spin->buttonApply->animateClick();
352 } else if (object == Group1Sel1Spin->SpinBox_DX) {
353 Group1Sel1Spin->buttonApply->animateClick();
355 } else if (object == Group2Spin->SpinBox_DX ||
356 object == Group2Spin->SpinBox_DY) {
357 Group2Spin->buttonApply->animateClick();
359 } else if (object == Group3Spin->SpinBox_DX ||
360 object == Group3Spin->SpinBox_DY ||
361 object == Group3Spin->SpinBox_DZ) {
362 Group3Spin->buttonApply->animateClick();
364 } else if (object == Group4Spin->SpinBox_DX ||
365 object == Group4Spin->SpinBox_DY ||
366 object == Group4Spin->SpinBox_DZ ||
367 object == Group4Spin->SpinBox_DS) {
368 Group4Spin->buttonApply->animateClick();
374 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
376 return QDialog::eventFilter(object, event);
380 //=================================================================================
383 //=================================================================================
384 void EntityGUI_SketcherDlg::Init()
387 myEditCurrentArgument = Group1Sel->LineEdit1;
388 myCommand.append( "Sketcher" );
389 myUndoCommand.append( "Sketcher" );
391 mySketchState = FIRST_POINT;
392 globalSelection( GEOM_POINT );
401 myHelpFileName = "create_sketcher_page.html";
403 /* Get setting of step value from file configuration */
404 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
406 /* min, max, step and decimals for spin boxes */
407 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
408 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
409 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
410 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
411 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
412 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
413 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
414 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
415 // san: Note specific step values below!
416 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
417 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
418 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
420 /* displays Dialog */
421 MainWidget->GroupConstructors->setEnabled( false );
422 MainWidget->GroupDest1->setEnabled( false );
423 setEnabledUndo( false );
424 setEnabledRedo( false );
426 MainWidget->RadioButton1->setChecked( true );
434 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
438 //=================================================================================
439 // function : InitClick()
441 //=================================================================================
442 void EntityGUI_SketcherDlg::InitClick()
444 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
449 Group1Sel1Spin->hide();
457 //=================================================================================
458 // function : TypeClicked()
459 // purpose : Radio button management
460 //=================================================================================
461 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
463 myConstructorId = constructorId;
464 if ( myConstructorId == 0 ) { // SEGMENT
465 GroupPt2->setEnabled( false );
466 GroupD2->setEnabled( true );
467 MainWidget->RB_Dest1->setEnabled( true );
468 MainWidget->RB_Dest1->setChecked( true );
471 else if ( myConstructorId == 1 ) { // ARC
472 GroupPt2->setEnabled( true );
473 GroupD2->setEnabled( false );
474 MainWidget->RB_Dest1->setEnabled( true );
475 MainWidget->RB_Dest1->setChecked( true );
481 //=================================================================================
482 // function : DestClicked()
483 // purpose : Radio button management
484 //=================================================================================
485 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
492 if ( constructorId == 1 ) {
494 GroupPt->RB_Point1->setChecked( true );
497 Group3Spin->checkBox->show();
498 Group4Spin->checkBox->show();
499 PointClicked( 1 ); // XY
501 else if ( constructorId == 0 ) {
503 GroupD1->RB_Dir11->setChecked( true );
506 Group3Spin->checkBox->hide();
507 Group4Spin->checkBox->hide();
508 Dir1Clicked( 2 ); // Angle
510 resize( minimumSizeHint() );
513 //=================================================================================
514 // function : PointClicked()
515 // purpose : Radio button management
516 //=================================================================================
517 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
519 MESSAGE("PointClicked")
520 myConstructorPntId = constructorId;
521 GroupPt2->RB_Point1->setChecked( true );
522 GroupPt->RB_Point3->setEnabled( true );
526 //=================================================================================
527 // function : Point2Clicked()
528 // purpose : Radio button management
529 //=================================================================================
530 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
532 MESSAGE("Point2Clicked")
535 // Get setting of step value from file configuration
536 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
538 if ( myConstructorPntId == 1 ) { // XY
539 if ( constructorId == 1 ){ // No additional parameter
540 mySketchType = PT_ABS;
541 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
542 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
543 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
544 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
546 Group2Spin->SpinBox_DX->setValue( myX );
548 Group2Spin->SpinBox_DY->setValue( myY );
550 Group2Spin->buttonApply->setFocus();
552 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
554 else if ( constructorId == 0 ){ // Point + radius
555 mySketchType = PT_ABS_RADIUS;
556 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
557 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
558 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
559 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
560 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
561 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
563 Group3Spin->SpinBox_DX->setValue( myDX );
565 Group3Spin->SpinBox_DY->setValue( myDY );
567 Group3Spin->SpinBox_DZ->setValue( myRadius );
569 Group3Spin->buttonApply->setFocus();
571 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
573 else if ( constructorId == 2 ){ // Point + center
574 mySketchType = PT_ABS_CENTER;
575 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
576 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
577 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
578 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
579 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
580 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
581 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
582 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
584 Group4Spin->SpinBox_DX->setValue( myDX );
586 Group4Spin->SpinBox_DY->setValue( myDY );
588 Group4Spin->SpinBox_DZ->setValue( myXc );
590 Group4Spin->SpinBox_DS->setValue( myYc );
592 Group4Spin->buttonApply->setFocus();
594 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
598 else if ( myConstructorPntId == 0 ) { // DXDY
599 if ( constructorId == 1 ){ // No additional parameter
600 mySketchType = PT_RELATIVE;
601 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
602 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
603 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
604 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
606 Group2Spin->SpinBox_DX->setValue( myDX );
608 Group2Spin->SpinBox_DY->setValue( myDY );
610 Group2Spin->buttonApply->setFocus();
612 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
614 else if ( constructorId == 0 ){ // Point + radius
615 mySketchType = PT_REL_RADIUS;
616 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
617 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
618 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
619 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
620 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
621 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
623 Group3Spin->SpinBox_DX->setValue( myDX );
625 Group3Spin->SpinBox_DY->setValue( myDY );
627 Group3Spin->SpinBox_DZ->setValue( myRadius );
629 Group3Spin->buttonApply->setFocus();
631 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
633 else if ( constructorId == 2 ){ // Point + center
634 mySketchType = PT_REL_CENTER;
635 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
636 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
637 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
638 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
639 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
640 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
641 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
642 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
644 Group4Spin->SpinBox_DX->setValue( myDX );
646 Group4Spin->SpinBox_DY->setValue( myDY );
648 Group4Spin->SpinBox_DZ->setValue( myDXc );
650 Group4Spin->SpinBox_DS->setValue( myDYc );
652 Group4Spin->buttonApply->setFocus();
654 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
658 else if ( myConstructorPntId == 2 ) { // Selection
659 if ( constructorId == 1 ){ // No additional parameter
660 mySketchType = PT_SEL;
661 myEditCurrentArgument = Group1Sel->LineEdit1;
662 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
664 Group1Sel->buttonApply->setFocus();
665 SelectionIntoArgument();
667 else if ( constructorId == 0 ){ // Point + radius
668 mySketchType = PT_SEL_RADIUS;
669 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
670 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
671 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
672 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
674 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
676 Group1Sel1Spin->show();
677 Group1Sel1Spin->buttonApply->setFocus();
678 SelectionIntoArgument();
680 else if ( constructorId == 2 ){ // Point + center
681 mySketchType = PT_SEL_CENTER;
682 myEditCurrentArgument = Group2Sel->LineEdit1;
683 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
684 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
685 Group2Sel->LineEdit1->setEnabled(true);
686 Group2Sel->PushButton1->setDown(true);
687 Group2Sel->LineEdit2->setEnabled(false);
688 Group2Sel->PushButton2->setDown(false);
690 Group2Sel->buttonApply->setFocus();
691 SelectionIntoArgument();
695 resize( minimumSizeHint() );
696 connect( myGeometryGUI->getApp()->selectionMgr(),
697 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
702 //=================================================================================
703 // function : Dir1Clicked()
704 // purpose : Radio button management
705 //=================================================================================
706 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
708 myConstructorDirId = constructorId;
709 GroupD2->RB_Dir21->setChecked( true );
714 //=================================================================================
715 // function : Dir2Clicked()
716 // purpose : Radio button management
717 //=================================================================================
718 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
723 // Get setting of step value from file configuration
724 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
726 if ( myConstructorId == 0 ) { // SEGMENT
730 if ( myConstructorDirId == 2 ) { // Angle
731 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
732 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
733 Group2Spin->SpinBox_DX->setValue( myAngle );
734 Group2Spin->buttonApply->setFocus();
737 if ( constructorId == 2 ) { // Length
738 mySketchType = DIR_ANGLE_LENGTH;
739 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
740 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
741 Group2Spin->SpinBox_DY->setValue( myLength );
743 else if ( constructorId == 0 ) { // X
744 mySketchType = DIR_ANGLE_X;
745 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
746 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
747 Group2Spin->SpinBox_DY->setValue( myX );
749 else if ( constructorId == 1 ) { // Y
750 mySketchType = DIR_ANGLE_Y;
751 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
752 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
753 Group2Spin->SpinBox_DY->setValue( myY );
756 else if ( myConstructorDirId == 0 ) { // Perpendicular
758 Group1Spin->buttonApply->setFocus();
760 if ( constructorId == 2 ) { // Length
761 mySketchType = DIR_PER_LENGTH;
762 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
763 Group1Spin->SpinBox_DX->setValue( myLength );
765 else if ( constructorId == 0 ) { // X
766 mySketchType = DIR_PER_X;
767 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
768 Group1Spin->SpinBox_DX->setValue( myX );
770 else if ( constructorId == 1 ) { // Y
771 mySketchType = DIR_PER_Y;
772 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
773 Group1Spin->SpinBox_DX->setValue( myY );
776 else if ( myConstructorDirId == 1 ) { // Tangent
778 Group1Spin->buttonApply->setFocus();
780 if ( constructorId == 2 ) { // Length
781 mySketchType = DIR_TAN_LENGTH;
782 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
783 Group1Spin->SpinBox_DX->setValue( myLength );
785 else if ( constructorId == 0 ) { // X
786 mySketchType = DIR_TAN_X;
787 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
788 Group1Spin->SpinBox_DX->setValue( myX );
790 else if ( constructorId == 1 ) { // Y
791 mySketchType = DIR_TAN_Y;
792 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
793 Group1Spin->SpinBox_DX->setValue( myY );
796 else if ( myConstructorDirId == 3 ) { // DXDY
797 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
798 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
799 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
800 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
801 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
803 Group3Spin->SpinBox_DX->setValue( myDX );
805 Group3Spin->SpinBox_DY->setValue( myDY );
807 Group3Spin->buttonApply->setFocus();
809 if ( constructorId == 2 ) { // Length
810 mySketchType = DIR_DXDY_LENGTH;
811 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
812 Group3Spin->SpinBox_DZ->setValue( myLength );
814 else if ( constructorId == 0 ) { // X
815 mySketchType = DIR_DXDY_X;
816 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
817 Group3Spin->SpinBox_DZ->setValue( myX );
819 else if ( constructorId == 1 ) { // Y
820 mySketchType = DIR_DXDY_Y;
821 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
822 Group3Spin->SpinBox_DZ->setValue( myY );
826 else if ( myConstructorId == 1 ) { // ARC
827 if ( myConstructorDirId == 2 ) { // Angle
828 if ( constructorId == 2 ) { // Length
829 mySketchType = DIR_ANGLE_LENGTH;
830 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
831 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
832 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
833 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
834 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
835 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
836 Group3Spin->SpinBox_DX->setValue( myAngle );
838 Group3Spin->SpinBox_DY->setValue( myRadius );
840 Group3Spin->SpinBox_DZ->setValue( myLength );
842 Group3Spin->buttonApply->setFocus();
845 else if ( myConstructorDirId == 0 ) { // Perpendicular
846 if ( constructorId == 2 ) { // Length
847 mySketchType = DIR_PER_LENGTH;
848 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
849 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
850 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
851 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
853 Group2Spin->SpinBox_DX->setValue( myRadius );
855 Group2Spin->SpinBox_DY->setValue( myLength );
857 Group2Spin->buttonApply->setFocus();
860 else if ( myConstructorDirId == 1 ) { // Tangent
861 if ( constructorId == 2 ) { // Length
862 mySketchType = DIR_TAN_LENGTH;
863 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
864 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
865 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
866 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
868 Group2Spin->SpinBox_DX->setValue( myRadius );
870 Group2Spin->SpinBox_DY->setValue( myLength );
872 Group2Spin->buttonApply->setFocus();
875 else if ( myConstructorDirId == 3 ) { // DXDY
876 if ( constructorId == 2 ) { // Length
877 mySketchType = DIR_DXDY_LENGTH;
878 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
879 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
880 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
881 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
882 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
883 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
884 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
885 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
887 Group4Spin->SpinBox_DX->setValue( myDX );
889 Group4Spin->SpinBox_DY->setValue( myDY );
891 Group4Spin->SpinBox_DZ->setValue( myRadius );
893 Group4Spin->SpinBox_DS->setValue( myLength );
895 Group4Spin->buttonApply->setFocus();
899 resize( minimumSizeHint() );
900 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
903 //=================================================================================
904 // function : CheckBoxClicked()
905 // purpose : CheckBox management
906 //=================================================================================
907 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
911 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
915 //=================================================================================
916 // function : ClickOnCancel()
918 //=================================================================================
919 void EntityGUI_SketcherDlg::ClickOnCancel()
925 //=================================================================================
926 // function : ClickOnEnd()
927 // purpose : connected to buttonEnd AND buttonClose
928 //=================================================================================
929 void EntityGUI_SketcherDlg::ClickOnEnd()
931 if ( sender() == MainWidget->buttonClose ) {
932 // Verify validity of commands
933 if ( myCommand.count() <= 2 ) {
934 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
935 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
940 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
941 Sketcher_Profile aProfile( Command.toAscii() );
943 Command = myCommand.join( "" );
944 aProfile = Sketcher_Profile( Command.toAscii() );
945 TopoDS_Shape myShape;
946 if ( aProfile.IsDone() )
947 myShape = aProfile.GetShape();
949 if ( myShape.ShapeType() != TopAbs_VERTEX )
950 myCommand.append( ":WW" );
953 // PAL16008 (Sketcher Validation should be equal to Apply&Close)
954 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
955 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
956 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
957 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
958 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
959 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
960 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
966 if ( myCommand.size() > 2 )
973 //=================================================================================
974 // function : ClickOnApply()
976 //=================================================================================
977 bool EntityGUI_SketcherDlg::ClickOnApply()
979 if ( sender() && sender()->inherits( "QPushButton" ) )
980 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
983 myCommand.append( GetNewCommand( aParameters ) );
984 mySketchState = NEXT_POINT;
986 myUndoCommand.clear();
987 myUndoCommand.append( "Sketcher" );
989 myParameters.append( aParameters );
990 myUndoParameters.clear();
992 MainWidget->GroupConstructors->setEnabled( true );
993 MainWidget->GroupDest1->setEnabled( true );
994 setEnabledUndo( true );
995 setEnabledRedo( false );
998 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1001 // Set focus to SpinBox_DX
1002 if ( sender() == Group1Spin->buttonApply ) {
1003 (Group1Spin->SpinBox_DX)->setFocus();
1004 (Group1Spin->SpinBox_DX)->selectAll();
1006 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1007 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1008 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1010 else if ( sender() == Group2Spin->buttonApply ) {
1011 (Group2Spin->SpinBox_DX)->setFocus();
1012 (Group2Spin->SpinBox_DX)->selectAll();
1014 else if ( sender() == Group3Spin->buttonApply ) {
1015 (Group3Spin->SpinBox_DX)->setFocus();
1016 (Group3Spin->SpinBox_DX)->selectAll();
1018 else if ( sender() == Group4Spin->buttonApply ) {
1019 (Group4Spin->SpinBox_DX)->setFocus();
1020 (Group4Spin->SpinBox_DX)->selectAll();
1026 //=================================================================================
1027 // function : ClickOnHelp()
1029 //=================================================================================
1030 void EntityGUI_SketcherDlg::ClickOnHelp()
1032 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1034 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1038 platform = "winapplication";
1040 platform = "application";
1043 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1044 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1045 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1046 QObject::tr( "BUT_OK" ) );
1050 //=================================================================================
1051 // function : ClickOnUndo()
1053 //=================================================================================
1054 void EntityGUI_SketcherDlg::ClickOnUndo()
1056 myUndoCommand.append( myCommand.last() );
1057 myCommand.pop_back();
1059 myUndoParameters.append( myParameters.last() );
1060 myParameters.pop_back();
1062 if ( myCommand.count() == 1 ) {
1063 mySketchState = FIRST_POINT;
1065 MainWidget->RadioButton1->setChecked( true );
1068 connect( myGeometryGUI->getApp()->selectionMgr(),
1069 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1071 MainWidget->GroupConstructors->setEnabled( false );
1072 MainWidget->GroupDest1->setEnabled( false );
1073 setEnabledUndo( false );
1076 setEnabledRedo( true );
1078 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1081 //=================================================================================
1082 // function : ClickOnRedo()
1084 //=================================================================================
1085 void EntityGUI_SketcherDlg::ClickOnRedo()
1087 myCommand.append( myUndoCommand.last() );
1088 myUndoCommand.pop_back();
1090 myParameters.append( myUndoParameters.last() );
1091 myUndoParameters.pop_back();
1093 mySketchState = NEXT_POINT;
1095 MainWidget->GroupConstructors->setEnabled( true );
1096 MainWidget->GroupDest1->setEnabled( true );
1097 setEnabledUndo( true );
1099 if ( myUndoCommand.count() == 1 )
1100 setEnabledRedo( false );
1102 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1105 //=================================================================================
1106 // function : setEnabledUndo()
1108 //=================================================================================
1109 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1111 Group1Sel->buttonUndo->setEnabled( value );
1112 Group2Sel->buttonUndo->setEnabled( value );
1113 Group1Sel1Spin->buttonUndo->setEnabled( value );
1114 Group1Spin->buttonUndo->setEnabled( value );
1115 Group2Spin->buttonUndo->setEnabled( value );
1116 Group3Spin->buttonUndo->setEnabled( value );
1117 Group4Spin->buttonUndo->setEnabled( value );
1120 //=================================================================================
1121 // function : setEnabledRedo()
1123 //=================================================================================
1124 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1126 Group1Sel->buttonRedo->setEnabled( value );
1127 Group2Sel->buttonRedo->setEnabled( value );
1128 Group1Sel1Spin->buttonRedo->setEnabled( value );
1129 Group1Spin->buttonRedo->setEnabled( value );
1130 Group2Spin->buttonRedo->setEnabled( value );
1131 Group3Spin->buttonRedo->setEnabled( value );
1132 Group4Spin->buttonRedo->setEnabled( value );
1135 //=================================================================================
1136 // function : SelectionIntoArgument()
1137 // purpose : Called when selection as changed
1138 //=================================================================================
1139 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1141 myEditCurrentArgument->setText( "" );
1146 // printf ("\nmyX = %f myY = %f", myX, myY);
1147 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
1148 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
1150 if ( sender() == ComboBox1 )
1153 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1154 SALOME_ListIO aSelList;
1155 aSelMgr->selectedObjects(aSelList);
1157 int nbSel = aSelList.Extent();
1158 if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1159 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1160 if ( !CORBA::is_nil(aSelectedObject) ) {
1161 TopoDS_Shape aShape;
1162 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1164 gp_Ax3 aWPlane = GetActiveLocalCS();
1166 aTrans.SetTransformation(aWPlane);
1167 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1168 aShape = aTransformation.Shape();
1171 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1174 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1175 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1176 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1177 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1178 Group2Spin->SpinBox_DX->setValue(myX);
1179 Group2Spin->SpinBox_DY->setValue(myY);
1180 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1181 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1182 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1183 if ( myLastX1 && myLastY1 ) {
1184 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1185 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1187 if ( mySketchState != FIRST_POINT ) {
1188 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1189 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1191 Group2Spin->SpinBox_DX->setValue(myX);
1192 Group2Spin->SpinBox_DY->setValue(myY);
1201 if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1202 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1203 if ( !CORBA::is_nil(aSelectedObject) ) {
1204 TopoDS_Shape aShape;
1205 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1207 gp_Ax3 aWPlane = GetActiveLocalCS();
1209 aTrans.SetTransformation(aWPlane);
1210 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1211 aShape = aTransformation.Shape();
1214 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1217 Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1218 if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1219 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1220 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1221 Group3Spin->SpinBox_DX->setValue(myX);
1222 Group3Spin->SpinBox_DY->setValue(myY);
1223 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1224 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1225 } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1226 if ( myLastX1 && myLastY1 ) {
1227 Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1228 Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1230 if ( mySketchState != FIRST_POINT ) {
1231 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1232 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1234 Group3Spin->SpinBox_DX->setValue(myX);
1235 Group3Spin->SpinBox_DY->setValue(myY);
1244 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1245 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1246 if ( !CORBA::is_nil(aSelectedObject) ) {
1247 TopoDS_Shape aShape;
1248 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1250 gp_Ax3 aWPlane = GetActiveLocalCS();
1252 aTrans.SetTransformation(aWPlane);
1253 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1254 aShape = aTransformation.Shape();
1257 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1260 Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1261 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1262 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1263 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1264 Group4Spin->SpinBox_DX->setValue(myX);
1265 Group4Spin->SpinBox_DY->setValue(myY);
1266 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1267 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1268 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1269 if ( myLastX1 && myLastY1 ) {
1270 Group4Spin->SpinBox_DX->setValue(myX - myLastX1);
1271 Group4Spin->SpinBox_DY->setValue(myY - myLastY1);
1273 if ( mySketchState != FIRST_POINT ) {
1274 Group4Spin->SpinBox_DX->setValue(myX - tmpX);
1275 Group4Spin->SpinBox_DY->setValue(myY - tmpY);
1277 Group4Spin->SpinBox_DX->setValue(myX);
1278 Group4Spin->SpinBox_DY->setValue(myY);
1287 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1288 if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
1289 myX=tmpX; // If yes keep the old values of X and Y
1292 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1293 if ( !CORBA::is_nil(aSelectedObject) ) {
1294 TopoDS_Shape aShape;
1295 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1297 gp_Ax3 aWPlane = GetActiveLocalCS();
1299 aTrans.SetTransformation(aWPlane);
1300 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1301 aShape = aTransformation.Shape();
1304 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1307 Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1308 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1309 disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1310 disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1311 Group4Spin->SpinBox_DZ->setValue(myXc);
1312 Group4Spin->SpinBox_DS->setValue(myYc);
1313 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1314 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1315 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1316 if ( myLastX1 && myLastY1 ) {
1317 Group4Spin->SpinBox_DZ->setValue(myXc - myLastX1);
1318 Group4Spin->SpinBox_DS->setValue(myYc - myLastY1);
1320 if ( mySketchState != FIRST_POINT ) {
1321 Group4Spin->SpinBox_DZ->setValue(myXc - tmpX);
1322 Group4Spin->SpinBox_DS->setValue(myYc - tmpY);
1324 Group4Spin->SpinBox_DZ->setValue(myXc);
1325 Group4Spin->SpinBox_DS->setValue(myYc);
1336 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1340 //=================================================================================
1341 // function : SetEditCurrentArgument()
1343 //=================================================================================
1344 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1346 if ( sender() == Group1Sel->PushButton1 ) {
1347 myEditCurrentArgument = Group1Sel->LineEdit1;
1348 myEditCurrentArgument->setFocus();
1350 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1351 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1352 myEditCurrentArgument->setFocus();
1354 else if ( sender() == Group2Sel->PushButton1 ) {
1355 myEditCurrentArgument = Group2Sel->LineEdit1;
1356 Group2Sel->PushButton2->setDown(false);
1357 Group2Sel->PushButton1->setDown(true);
1358 Group2Sel->LineEdit2->setEnabled(false);
1359 Group2Sel->LineEdit1->setEnabled(true);
1360 // myEditCurrentArgument->setFocus();
1362 else if ( sender() == Group2Sel->PushButton2 ) {
1363 myEditCurrentArgument = Group2Sel->LineEdit2;
1364 Group2Sel->PushButton1->setDown(false);
1365 Group2Sel->PushButton2->setDown(true);
1366 Group2Sel->LineEdit1->setEnabled(false);
1367 Group2Sel->LineEdit2->setEnabled(true);
1368 // myEditCurrentArgument->setFocus();
1370 SelectionIntoArgument();
1374 //=================================================================================
1375 // function : LineEditReturnPressed()
1377 //=================================================================================
1378 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1380 if ( sender() == Group1Sel->LineEdit1 )
1381 myEditCurrentArgument = Group1Sel->LineEdit1;
1382 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1383 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1384 else if ( sender() == Group2Sel->LineEdit1 )
1385 myEditCurrentArgument = Group2Sel->LineEdit1;
1386 else if ( sender() == Group2Sel->LineEdit2 )
1387 myEditCurrentArgument = Group2Sel->LineEdit2;
1389 /* User name of object input management */
1390 /* If successfull the selection is changed and signal emitted... */
1391 /* so SelectionIntoArgument() is automatically called. */
1392 const QString objectUserName = myEditCurrentArgument->text();
1393 QWidget* thisWidget = (QWidget*)this;
1395 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1396 SALOME_ListIO aSelList;
1397 aSelMgr->selectedObjects(aSelList);
1399 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1400 myEditCurrentArgument->setText( objectUserName );
1404 //=================================================================================
1405 // function : DeactivateActiveDialog()
1407 //=================================================================================
1408 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1410 //myGeometryGUI->SetState( -1 );
1412 setEnabled( false );
1414 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1415 myGeometryGUI->SetActiveDialogBox( 0 );
1419 //=================================================================================
1420 // function : ActivateThisDialog()
1422 //=================================================================================
1423 void EntityGUI_SketcherDlg::ActivateThisDialog()
1425 myGeometryGUI->EmitSignalDeactivateDialog();
1427 myGeometryGUI->SetActiveDialogBox( this );
1429 connect( myGeometryGUI->getApp()->selectionMgr(),
1430 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1432 //myGeometryGUI->SetState( 0 );
1433 globalSelection( GEOM_POINT );
1435 myEditCurrentArgument = Group1Sel->LineEdit1;
1436 myEditCurrentArgument->setFocus();
1438 if ( sender() == Group1Sel->LineEdit1 ) {
1439 myEditCurrentArgument = Group1Sel->LineEdit1;
1440 myEditCurrentArgument->setFocus();
1442 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1443 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1444 myEditCurrentArgument->setFocus();
1446 else if ( sender() == Group2Sel->LineEdit1 ) {
1447 myEditCurrentArgument = Group2Sel->LineEdit1;
1448 myEditCurrentArgument->setFocus();
1450 else if ( sender() == Group2Sel->LineEdit2 ) {
1451 myEditCurrentArgument = Group2Sel->LineEdit2;
1452 myEditCurrentArgument->setFocus();
1455 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1459 //=================================================================================
1460 // function : enterEvent [REDEFINED]
1462 //=================================================================================
1463 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1466 ActivateThisDialog();
1470 //=================================================================================
1471 // function : closeEvent()
1473 //=================================================================================
1474 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1476 //myGeometryGUI->SetState( -1 );
1477 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1478 myGeometryGUI->getApp()->updateActions();
1479 QDialog::closeEvent( e );
1483 //=================================================================================
1484 // function : ValueChangedInSpinBox()
1486 //=================================================================================
1487 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1489 QObject* send = (QObject*)sender();
1490 Standard_Real vx, vy, vz, vs, minRad;
1491 vx = vy = vz = vs = minRad =0.0;
1493 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1494 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1495 double LastDecimal = 0.0;
1497 QString vxStr, vyStr, vzStr, vsStr;
1499 QString newValueStr;
1500 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1501 newValueStr = aDoubleSpinBox->text();
1503 if ( send == Group1Spin->SpinBox_DX ) {
1504 vx = newValue; vxStr = newValueStr;
1506 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1507 vx = newValue; vxStr = newValueStr;
1509 else if ( send == Group2Spin->SpinBox_DX ) {
1510 vx = newValue; vxStr = newValueStr;
1511 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1513 else if ( send == Group2Spin->SpinBox_DY ) {
1514 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1515 vy = newValue; vyStr = newValueStr;
1517 else if ( send == Group3Spin->SpinBox_DX ) {
1518 vx = newValue; vxStr = newValueStr;
1519 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1520 vz = Group3Spin->SpinBox_DZ->value();
1521 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1522 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1523 if (aPrecision >= 0) // 'f' format in the QString
1524 LastDecimal = aPrecision;
1525 else // 'g' format in the Qstring
1526 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1527 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1528 if ( Abs(vz) < minRad){
1530 Group3Spin->SpinBox_DZ->setValue( - minRad );
1532 Group3Spin->SpinBox_DZ->setValue( minRad );
1535 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1537 else if ( send == Group3Spin->SpinBox_DY ) {
1538 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1539 vy = newValue; vyStr = newValueStr;
1540 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1541 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1542 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1543 if (aPrecision >= 0) // 'f' format in the QString
1544 LastDecimal = aPrecision;
1545 else // 'g' format in the QString
1546 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1547 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1548 if ( Abs(vz) < minRad){
1550 Group3Spin->SpinBox_DZ->setValue( - minRad );
1552 Group3Spin->SpinBox_DZ->setValue( minRad );
1555 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1557 else if ( send == Group3Spin->SpinBox_DZ ) {
1558 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1559 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1560 vz = newValue; vzStr = newValueStr;
1562 else if ( send == Group4Spin->SpinBox_DX ) {
1563 vx = newValue; vxStr = newValueStr;
1564 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1565 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1566 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1568 else if ( send == Group4Spin->SpinBox_DY ) {
1569 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1570 vy = newValue; vyStr = newValueStr;
1571 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1572 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1574 else if ( send == Group4Spin->SpinBox_DZ ) {
1575 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1576 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1577 vz = newValue; vzStr = newValueStr;
1578 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1580 else if ( send == Group4Spin->SpinBox_DS ) {
1581 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1582 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1583 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1584 vs = newValue; vsStr = newValueStr;
1586 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1588 if ( myConstructorId == 0 ) { // SEGMENT
1589 if ( mySketchType == PT_ABS ) {
1595 else if ( mySketchType == PT_RELATIVE ) {
1601 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1605 myLengthStr = vyStr;
1607 else if ( mySketchType == DIR_ANGLE_X ) {
1613 else if ( mySketchType == DIR_ANGLE_Y ) {
1619 else if ( mySketchType == DIR_PER_LENGTH ) {
1621 myLengthStr = vxStr;
1623 else if ( mySketchType == DIR_PER_X ) {
1627 else if ( mySketchType == DIR_PER_Y ) {
1631 else if ( mySketchType == DIR_TAN_LENGTH ) {
1633 myLengthStr = vxStr;
1635 else if ( mySketchType == DIR_TAN_X ) {
1639 else if ( mySketchType == DIR_TAN_Y ) {
1643 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1649 myLengthStr = vzStr;
1651 else if ( mySketchType == DIR_DXDY_X ) {
1659 else if ( mySketchType == DIR_DXDY_Y ) {
1668 else if ( myConstructorId == 1 ) { // ARC
1669 if ( mySketchType == PT_ABS ) {
1675 else if ( mySketchType == PT_RELATIVE ) {
1681 if ( mySketchType == PT_ABS_RADIUS ) {
1687 myRadiusStr = vzStr;
1689 else if ( mySketchType == PT_REL_RADIUS ) {
1695 myRadiusStr = vzStr;
1697 else if ( mySketchType == PT_SEL_RADIUS ) {
1699 myRadiusStr = vxStr;
1701 if ( mySketchType == PT_ABS_CENTER ) {
1711 else if ( mySketchType == PT_REL_CENTER ) {
1721 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1726 myRadiusStr = vyStr;
1727 myLengthStr = vzStr;
1729 else if ( mySketchType == DIR_PER_LENGTH ) {
1732 myRadiusStr = vxStr;
1733 myLengthStr = vyStr;
1735 else if ( mySketchType == DIR_TAN_LENGTH ) {
1738 myRadiusStr = vxStr;
1739 myLengthStr = vyStr;
1741 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1748 myRadiusStr = vzStr;
1749 myLengthStr = vsStr;
1753 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1757 //=================================================================================
1758 // function : GetNewCommand()
1759 // purpose : Build the new command with context
1760 //=================================================================================
1761 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1763 theParameters.clear();
1764 QString myNewCommand = ":";
1765 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1766 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1767 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1769 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1770 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1772 if ( mySketchState == FIRST_POINT ) {
1773 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1774 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1775 theParameters = myXStr + ":" + myYStr;
1777 if ( mySketchType == PT_RELATIVE) {
1778 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1779 theParameters = myDXStr + ":" + myDYStr;
1781 return myNewCommand;
1784 if ( myConstructorId == 0 ) { // SEGMENT
1785 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1786 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1787 theParameters = myXStr + ":" + myYStr;
1789 if ( mySketchType == PT_RELATIVE) {
1790 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1791 theParameters = myDXStr + ":" + myDYStr;
1793 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1794 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1795 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1796 theParameters = myAngleStr + ":" + myLengthStr;
1798 if ( mySketchType == DIR_ANGLE_X ) {
1799 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1800 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1801 theParameters = myAngleStr + ":" + myXStr;
1803 if ( mySketchType == DIR_ANGLE_Y ) {
1804 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1805 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1806 theParameters = myAngleStr + ":" + myYStr;
1808 if ( mySketchType == DIR_PER_LENGTH ) {
1809 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1810 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1811 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1813 if ( mySketchType == DIR_PER_X ) {
1814 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1815 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1816 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1818 if ( mySketchType == DIR_PER_Y ) {
1819 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1820 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1821 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1823 if ( mySketchType == DIR_TAN_LENGTH ) {
1824 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1825 theParameters = myLengthStr;
1827 if ( mySketchType == DIR_TAN_X ) {
1828 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1829 theParameters = myXStr;
1831 if ( mySketchType == DIR_TAN_Y) {
1832 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1833 theParameters = myYStr;
1835 if ( mySketchType == DIR_DXDY_LENGTH ) {
1836 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1837 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1838 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1840 if ( mySketchType == DIR_DXDY_X ) {
1841 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1842 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1843 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1845 if ( mySketchType == DIR_DXDY_Y ) {
1846 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1847 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1848 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1851 else if ( myConstructorId == 1 ) { // ARC
1852 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1853 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1854 theParameters = myXStr + ":" + myYStr;
1856 if ( mySketchType == PT_RELATIVE) {
1857 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1858 theParameters = myDXStr + ":" + myDYStr;
1860 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1861 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1862 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
1864 if ( mySketchType == PT_REL_RADIUS) {
1865 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1866 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
1868 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
1869 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 );
1870 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
1872 if ( mySketchType == PT_REL_CENTER) {
1873 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 );
1874 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
1876 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1877 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1878 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1879 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1881 if ( mySketchType == DIR_PER_LENGTH ) {
1882 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1883 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1884 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
1886 if ( mySketchType == DIR_TAN_LENGTH ) {
1887 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1888 theParameters = myRadiusStr + ":" + myLengthStr;
1890 if ( mySketchType == DIR_DXDY_LENGTH ) {
1891 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1892 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1893 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
1896 return myNewCommand;
1899 //=================================================================================
1900 // function : createOperation
1902 //=================================================================================
1903 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1905 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1908 //=================================================================================
1909 // function : isValid
1911 //=================================================================================
1912 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1915 bool toCorrect = !IsPreview() || myIsApply;
1917 if( Group1Spin->isVisible() ) {
1918 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1920 else if( Group1Sel1Spin->isVisible() ) {
1921 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1923 else if( Group2Spin->isVisible() ) {
1924 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1925 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1927 else if( Group3Spin->isVisible() ) {
1928 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1929 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1930 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1932 else if( Group4Spin->isVisible() ) {
1933 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1934 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1935 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1936 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
1939 if( myIsApply && !ok )
1945 //=================================================================================
1946 // function : execute
1948 //=================================================================================
1949 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1951 QString aParameters;
1953 if ( mySketchState == FIRST_POINT ) {
1958 //Test if the current point is the same as the last one
1959 TopoDS_Shape myShape1, myShape2;
1961 // Set "C" numeric locale
1962 Kernel_Utils::Localizer loc;
1965 QString Command1 = myCommand.join( "" );
1966 Sketcher_Profile aProfile1( Command1.toAscii() );
1967 if ( aProfile1.IsDone() )
1968 myShape1 = aProfile1.GetShape();
1971 QString Command2 = Command1 + GetNewCommand( aParameters );
1972 Sketcher_Profile aProfile2( Command2.toAscii() );
1975 if ( mySketchType == PT_ABS_CENTER ||
1976 mySketchType == PT_REL_CENTER ){
1977 Group4Spin->label->show();
1978 Group4Spin->label->setText( tr( aProfile2.ErrMsg().c_str() ) );
1981 Group4Spin->label->hide();
1982 if ( mySketchType == PT_SEL_CENTER ){
1983 Group2Sel->label->show();
1984 Group2Sel->label->setText( tr( aProfile2.ErrMsg().c_str() ) );
1987 Group2Sel->label->hide();
1989 if ( aProfile2.IsDone() )
1990 myShape2 = aProfile2.GetShape();
1992 if ( myShape2.IsNull() ) {
1993 //the current point is the same as the last one
1994 myLastX2 = myLastX1;
1995 myLastY2 = myLastY1;
1998 TopoDS_Vertex V1, V2;
2000 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2001 //the last shape is the first point
2002 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2007 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2008 pt = BRep_Tool::Pnt( V2 );
2012 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2013 pt = BRep_Tool::Pnt( V2 );
2020 if ( ( mySketchState != FIRST_POINT &&
2021 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2022 cmd = myCommand.join( "" );
2023 if ( Group1Sel->isVisible() ) {
2024 Group1Sel->buttonApply->setEnabled( false );
2025 //Group1Sel->buttonApply->setFocus();
2027 if ( Group2Sel->isVisible() ) {
2028 Group2Sel->buttonApply->setEnabled( false );
2029 //Group2Sel->buttonApply->setFocus();
2031 if ( Group1Sel1Spin->isVisible() ) {
2032 Group1Sel1Spin->buttonApply->setEnabled( false );
2033 //Group1Sel1Spin->buttonApply->setFocus();
2035 if ( Group1Spin->isVisible() ) {
2036 Group1Spin->buttonApply->setEnabled( false );
2037 //Group1Spin->buttonApply->setFocus();
2039 if ( Group2Spin->isVisible() ) {
2040 Group2Spin->buttonApply->setEnabled( false );
2041 //Group2Spin->buttonApply->setFocus();
2043 if ( Group3Spin->isVisible() ) {
2044 Group3Spin->buttonApply->setEnabled( false );
2045 //Group3Spin->buttonApply->setFocus();
2047 if ( Group4Spin->isVisible() ) {
2048 Group4Spin->buttonApply->setEnabled( false );
2049 //Group4Spin->buttonApply->setFocus();
2053 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2055 if ( Group1Sel->isVisible() ) {
2056 Group1Sel->buttonApply->setEnabled( true );
2057 //Group1Sel->buttonApply->setFocus();
2059 if ( Group2Sel->isVisible() ) {
2060 Group2Sel->buttonApply->setEnabled( true );
2061 //Group2Sel->buttonApply->setFocus();
2063 if ( Group1Sel1Spin->isVisible() ) {
2064 Group1Sel1Spin->buttonApply->setEnabled( true );
2065 //Group1Sel1Spin->buttonApply->setFocus();
2067 if ( Group1Spin->isVisible() ) {
2068 Group1Spin->buttonApply->setEnabled( true );
2069 //Group1Spin->buttonApply->setFocus();
2071 if ( Group2Spin->isVisible() ) {
2072 Group2Spin->buttonApply->setEnabled( true );
2073 //Group2Spin->buttonApply->setFocus();
2075 if ( Group3Spin->isVisible() ) {
2076 Group3Spin->buttonApply->setEnabled( true );
2077 //Group3Spin->buttonApply->setFocus();
2079 if ( Group4Spin->isVisible() ) {
2080 Group4Spin->buttonApply->setEnabled( true );
2081 //Group4Spin->buttonApply->setFocus();
2085 gp_Ax3 myWPlane = GetActiveLocalCS();
2086 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2087 WPlane->length( 9 );
2088 WPlane[0] = myWPlane.Location().X();
2089 WPlane[1] = myWPlane.Location().Y();
2090 WPlane[2] = myWPlane.Location().Z();
2092 WPlane[3] = myWPlane.Direction().X();
2093 WPlane[4] = myWPlane.Direction().Y();
2094 WPlane[5] = myWPlane.Direction().Z();
2096 WPlane[6] = myWPlane.XDirection().X();
2097 WPlane[7] = myWPlane.XDirection().Y();
2098 WPlane[8] = myWPlane.XDirection().Z();
2100 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2101 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2103 if ( !anObj->_is_nil() )
2105 if( !IsPreview() ) {
2106 QStringList aCurrentParameters = myParameters;
2107 aCurrentParameters << aParameters;
2108 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2111 objects.push_back( anObj._retn() );
2117 //================================================================
2118 // Function : displayPreview
2119 // Purpose : Method for displaying preview of resulting shape
2120 // Redefined from GEOMBase_Helper.
2121 //================================================================
2122 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2124 const bool activate,
2126 const double lineWidth,
2127 const int displayMode,
2130 // Set color for preview shape
2131 getDisplayer()->SetColor( Quantity_NOC_RED );
2133 // set width of displayed shape
2134 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2136 // Disable activation of selection
2137 getDisplayer()->SetToActivate( activate );
2139 // Make a reference to GEOM_Object
2140 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2141 getDisplayer()->SetName( objStr.in() );
2143 // Create wire from applayed object
2144 TopoDS_Shape anApplyedWire, aLastSegment;
2145 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2149 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2150 if ( aPrs != 0 && !aPrs->IsNull() )
2151 GEOMBase_Helper::displayPreview( aPrs, append, update );
2153 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2154 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2155 if ( aPrs != 0 && !aPrs->IsNull() )
2156 GEOMBase_Helper::displayPreview( aPrs, append, update );
2158 getDisplayer()->UnsetName();
2160 // Enable activation of displayed objects
2161 getDisplayer()->SetToActivate( true );
2164 //================================================================
2165 // Function : createShapes
2166 // Purpose : Create applyed wire, and last segment from entry object
2167 //================================================================
2168 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2169 TopoDS_Shape& theApplyedWire,
2170 TopoDS_Shape& theLastSegment )
2172 TopoDS_Shape aShape;
2173 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2174 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2177 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2178 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2179 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2180 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2181 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2182 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2183 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2184 theApplyedWire = aShape;
2188 BRepBuilderAPI_MakeWire aBuilder;
2189 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2191 TopoDS_Shape anEdge = anExp.Current();
2193 if ( anExp.More() ) // i.e. non-last edge
2194 aBuilder.Add( TopoDS::Edge( anEdge ) );
2196 theLastSegment = anEdge;
2201 if ( aBuilder.IsDone() )
2202 theApplyedWire = aBuilder.Shape();
2207 //=================================================================================
2208 // function : keyPressEvent()
2210 //=================================================================================
2211 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2213 QDialog::keyPressEvent( e );
2214 if ( e->isAccepted() )
2217 if ( e->key() == Qt::Key_F1 ) {
2223 //=================================================================================
2224 // function : initSpinBox()
2226 //=================================================================================
2227 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2228 double min, double max,
2229 double step, const char* quantity )
2231 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2232 // TODO: Think how to keep the single piece of code...
2234 // Obtain precision from preferences
2235 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2236 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2238 spinBox->setPrecision( aPrecision );
2239 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2240 // by default Qt rounds boundaries to 2 decimals at setRange
2241 spinBox->setRange( min, max );
2242 spinBox->setSingleStep( step );
2244 // Add a hint for the user saying how to tune precision
2245 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2246 spinBox->setProperty( "validity_tune_hint",
2247 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2250 //=================================================================================
2251 // function : SetDoubleSpinBoxStep()
2252 // purpose : Double spin box management
2253 //=================================================================================
2254 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2256 Group1Spin->SpinBox_DX->setSingleStep(step);
2257 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2258 Group2Spin->SpinBox_DX->setSingleStep(step);
2259 Group2Spin->SpinBox_DY->setSingleStep(step);
2260 Group3Spin->SpinBox_DX->setSingleStep(step);
2261 Group3Spin->SpinBox_DY->setSingleStep(step);
2262 Group3Spin->SpinBox_DZ->setSingleStep(step);
2263 Group4Spin->SpinBox_DZ->setSingleStep(step);
2265 // san: Do NOT override the step when a speicifc step value is used
2266 // in some input fields!
2267 //Group4Spin->SpinBox_DX->setSingleStep(step);
2268 //Group4Spin->SpinBox_DY->setSingleStep(step);
2269 //Group4Spin->SpinBox_DS->setSingleStep(step);
2272 //=================================================================================
2273 // function : FindLocalCS()
2274 // purpose : Find All Coordinates systems in study
2275 //=================================================================================
2276 void EntityGUI_SketcherDlg::FindLocalCS()
2280 SalomeApp_Application* app =
2281 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2285 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2289 _PTR(Study) aStudy = appStudy->studyDS();
2292 ComboBox1->addItem(tr("GEOM_GCS"));
2293 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2294 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2295 gp_Dir aDirX = gp_Dir(1, 0, 0);
2296 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2297 myLCSList.push_back(globalCS);
2299 // get GEOM component
2300 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2301 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2304 _PTR(SComponent) fc = obj->GetFatherComponent();
2305 QString geomComp = fc->GetID().c_str();
2306 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2310 // browse through all GEOM data tree
2311 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2312 for ( it->InitEx( true ); it->More(); it->Next() ) {
2313 _PTR(SObject) child( it->Value() );
2314 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2315 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2316 if( CORBA::is_nil( geomObj ) )
2318 if (geomObj->GetType() == GEOM_MARKER) {
2319 ComboBox1->addItem(geomObj->GetName());
2320 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2323 aLCS.Transform(aShape.Location().Transformation());
2324 if (aShape.ShapeType() == TopAbs_FACE) {
2325 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2326 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2327 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2328 gp_Pln aPln = aGPlane->Pln();
2329 aLCS = aPln.Position();
2332 myLCSList.push_back(aLCS);
2337 //=================================================================================
2338 // function : GetActiveLocalCS()
2339 // purpose : Get Working plane
2340 //=================================================================================
2341 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2343 int ind = ComboBox1->currentIndex();
2345 return myGeometryGUI->GetWorkingPlane();
2347 gp_Ax3 aLCS = myLCSList.at(ind);
2352 //=================================================================================
2353 // function : ActivateLocalCS()
2354 // purpose : Activate & Fit Working plane
2355 //=================================================================================
2356 void EntityGUI_SketcherDlg::ActivateLocalCS()
2358 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2359 myGeometryGUI->ActiveWorkingPlane();