1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
27 #include "EntityGUI_SketcherDlg.h"
28 #include "EntityGUI_Widgets.h"
29 #include <SalomeApp_DoubleSpinBox.h>
32 #include <GeometryGUI.h>
33 #include <GEOMImpl_Types.hxx>
34 #include <Geom_Surface.hxx>
35 #include <Geom_Plane.hxx>
37 #include <SUIT_Desktop.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Application.h>
42 #include <LightApp_Application.h>
43 #include <LightApp_SelectionMgr.h>
47 #include <BRep_Tool.hxx>
49 #include <TopExp_Explorer.hxx>
50 #include <TopoDS_Vertex.hxx>
52 #include <BRepBuilderAPI_Transform.hxx>
53 #include <BRepBuilderAPI_MakeWire.hxx>
54 #include <Sketcher_Profile.hxx>
56 #include <SalomeApp_Study.h>
60 #include <Basics_Utils.hxx>
62 //=================================================================================
63 // class : EntityGUI_SketcherDlg()
64 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
65 // name 'name' and widget flags set to 'f'.
66 // The dialog will by default be modeless, unless you set 'modal' to
67 // TRUE to construct a modal dialog.
68 //=================================================================================
69 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
70 bool modal, Qt::WindowFlags fl,
71 const double lineWidth )
72 : QDialog( parent, fl ),
73 myIsAllAdded( false ),
75 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
77 myLineWidth( lineWidth )
80 setAttribute( Qt::WA_DeleteOnClose );
82 myGeometryGUI->SetActiveDialogBox(this);
84 MainWidget = new EntityGUI_Skeleton( this );
85 QVBoxLayout* topLayout = new QVBoxLayout( this );
86 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
88 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
89 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
90 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
91 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
93 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
94 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
95 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
97 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
99 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
100 MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) );
101 MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) );
102 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
103 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
104 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
105 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
107 /***************************************************************/
109 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
110 QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
111 planeLayout->setSpacing(6);
112 planeLayout->setMargin(11);
114 ComboBox1 = new QComboBox(GroupBox1);
115 ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
116 planeLayout->addWidget(ComboBox1);
118 planeButton = new QPushButton (GroupBox1);
119 planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
120 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
121 planeLayout->addWidget(planeButton);
123 topLayout->addWidget(GroupBox1);
124 topLayout->addWidget( MainWidget );
125 topLayout->setStretch( 1, 1);
127 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
129 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
130 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
131 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
132 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
134 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
136 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
137 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
138 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
139 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
141 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
143 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
144 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
145 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
146 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
147 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
149 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
151 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
152 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
153 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
154 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
156 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
157 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
158 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
159 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
160 Group1Sel->PushButton1->setIcon( image0 );
161 Group1Sel->buttonUndo->setIcon( image1 );
162 Group1Sel->buttonRedo->setIcon( image2 );
163 Group1Sel->LineEdit1->setReadOnly( true );
165 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
166 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
167 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
168 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
169 Group2Sel->PushButton1->setIcon( image0 );
170 Group2Sel->PushButton2->setIcon( image0 );
171 Group2Sel->buttonUndo->setIcon( image1 );
172 Group2Sel->buttonRedo->setIcon( image2 );
173 Group2Sel->LineEdit1->setReadOnly( true );
174 Group2Sel->LineEdit2->setReadOnly( true );
176 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
177 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
178 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
179 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
180 Group1Sel1Spin->PushButton1->setIcon( image0 );
181 Group1Sel1Spin->buttonUndo->setIcon( image1 );
182 Group1Sel1Spin->buttonRedo->setIcon( image2 );
183 Group1Sel1Spin->LineEdit1->setReadOnly( true );
185 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
186 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
187 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
188 Group1Spin->buttonUndo->setIcon( image1 );
189 Group1Spin->buttonRedo->setIcon( image2 );
191 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
192 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
193 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
194 Group2Spin->buttonUndo->setIcon( image1 );
195 Group2Spin->buttonRedo->setIcon( image2 );
197 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
198 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
199 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
200 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
201 Group3Spin->buttonUndo->setIcon( image1 );
202 Group3Spin->buttonRedo->setIcon( image2 );
204 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
205 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
206 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
207 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
208 Group4Spin->buttonUndo->setIcon( image1 );
209 Group4Spin->buttonRedo->setIcon( image2 );
211 // Defines a palette for the error message on Group4Spin and Group2Sel
214 palette.setColor(Group4Spin->label->foregroundRole(), color);
215 Group4Spin->label->setPalette(palette);
216 palette.setColor(Group2Sel->label->foregroundRole(), color);
217 Group2Sel->label->setPalette(palette);
219 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
220 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
221 DestCntLayout->addWidget( GroupPt, 0, 0 );
222 DestCntLayout->addWidget( GroupPt2, 0, 1 );
223 DestCntLayout->addWidget( GroupD1, 0, 0 );
224 DestCntLayout->addWidget( GroupD2, 0, 1 );
226 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
227 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
228 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
229 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
230 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
231 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
232 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
233 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
234 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
235 //SkeletonCntlayout->setStretch( 0, 1);
236 /***************************************************************/
238 QButtonGroup* ButtonGroup = new QButtonGroup( this );
239 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
240 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
242 /* signals and slots connections */
243 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
244 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
245 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
246 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
248 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
249 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
250 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
251 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
252 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
253 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
254 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
255 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
256 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
257 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
258 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
259 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
260 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
261 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
262 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
263 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
264 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
265 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
266 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
267 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
268 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
270 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
271 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
272 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
273 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
274 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
275 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
277 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
278 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
280 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
281 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
282 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
283 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
285 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
286 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
287 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
289 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
290 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
291 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
292 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
293 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
294 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
295 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
296 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
297 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
298 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
300 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
301 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
302 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
303 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
305 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
306 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
308 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
310 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
311 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
313 // install event filter on spin-boxes to provide Apply action on Return pressed
314 Group1Spin->SpinBox_DX->installEventFilter(this);
315 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
316 Group2Spin->SpinBox_DX->installEventFilter(this);
317 Group2Spin->SpinBox_DY->installEventFilter(this);
318 Group3Spin->SpinBox_DX->installEventFilter(this);
319 Group3Spin->SpinBox_DY->installEventFilter(this);
320 Group3Spin->SpinBox_DZ->installEventFilter(this);
321 Group4Spin->SpinBox_DX->installEventFilter(this);
322 Group4Spin->SpinBox_DY->installEventFilter(this);
323 Group4Spin->SpinBox_DZ->installEventFilter(this);
324 Group4Spin->SpinBox_DS->installEventFilter(this);
330 //=================================================================================
331 // function : ~EntityGUI_SketcherDlg()
332 // purpose : Destroys the object and frees any allocated resources
333 //=================================================================================
334 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
336 myGeometryGUI->SetActiveDialogBox( 0 );
340 //=================================================================================
341 // function : eventFilter()
342 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
343 //=================================================================================
344 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
346 if (event->type() == QEvent::KeyPress) {
347 QKeyEvent* ke = (QKeyEvent*)event;
348 if (ke->key() == Qt::Key_Return) {
349 if (object == Group1Spin->SpinBox_DX) {
350 Group1Spin->buttonApply->animateClick();
352 } else if (object == Group1Sel1Spin->SpinBox_DX) {
353 Group1Sel1Spin->buttonApply->animateClick();
355 } else if (object == Group2Spin->SpinBox_DX ||
356 object == Group2Spin->SpinBox_DY) {
357 Group2Spin->buttonApply->animateClick();
359 } else if (object == Group3Spin->SpinBox_DX ||
360 object == Group3Spin->SpinBox_DY ||
361 object == Group3Spin->SpinBox_DZ) {
362 Group3Spin->buttonApply->animateClick();
364 } else if (object == Group4Spin->SpinBox_DX ||
365 object == Group4Spin->SpinBox_DY ||
366 object == Group4Spin->SpinBox_DZ ||
367 object == Group4Spin->SpinBox_DS) {
368 Group4Spin->buttonApply->animateClick();
374 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
376 return QDialog::eventFilter(object, event);
380 //=================================================================================
383 //=================================================================================
384 void EntityGUI_SketcherDlg::Init()
387 myEditCurrentArgument = Group1Sel->LineEdit1;
388 myCommand.append( "Sketcher" );
389 myUndoCommand.append( "Sketcher" );
391 mySketchState = FIRST_POINT;
392 globalSelection( GEOM_POINT );
401 myHelpFileName = "create_sketcher_page.html";
403 /* Get setting of step value from file configuration */
404 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
406 /* min, max, step and decimals for spin boxes */
407 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
408 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
409 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
410 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
411 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
412 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
413 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
414 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
415 // san: Note specific step values below!
416 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
417 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
418 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
420 /* displays Dialog */
421 MainWidget->GroupConstructors->setEnabled( false );
422 MainWidget->GroupDest1->setEnabled( false );
423 setEnabledUndo( false );
424 setEnabledRedo( false );
426 MainWidget->RadioButton1->setChecked( true );
434 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
438 //=================================================================================
439 // function : InitClick()
441 //=================================================================================
442 void EntityGUI_SketcherDlg::InitClick()
444 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
449 Group1Sel1Spin->hide();
457 //=================================================================================
458 // function : TypeClicked()
459 // purpose : Radio button management
460 //=================================================================================
461 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
463 myConstructorId = constructorId;
464 if ( myConstructorId == 0 ) { // SEGMENT
465 GroupPt2->RB_Point1->setChecked( true );
466 GroupPt2->setEnabled( false );
467 GroupD2->setEnabled( true );
468 MainWidget->RB_Dest1->setEnabled( true );
469 MainWidget->RB_Dest1->setChecked( true );
472 else if ( myConstructorId == 1 ) { // ARC
473 GroupPt2->setEnabled( true );
474 GroupD2->RB_Dir21->setChecked( true );
475 GroupD2->setEnabled( false );
476 MainWidget->RB_Dest1->setEnabled( true );
477 MainWidget->RB_Dest1->setChecked( true );
483 //=================================================================================
484 // function : DestClicked()
485 // purpose : Radio button management
486 //=================================================================================
487 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
494 if ( constructorId == 1 ) {
496 GroupPt->RB_Point1->setChecked( true );
499 Group3Spin->checkBox->show();
500 Group4Spin->checkBox->show();
501 PointClicked( 1 ); // XY
503 else if ( constructorId == 0 ) {
505 GroupD1->RB_Dir11->setChecked( true );
508 Group3Spin->checkBox->hide();
509 Group4Spin->checkBox->hide();
510 Dir1Clicked( 2 ); // Angle
512 resize( minimumSizeHint() );
515 //=================================================================================
516 // function : PointClicked()
517 // purpose : Radio button management
518 //=================================================================================
519 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
521 MESSAGE("PointClicked")
522 myConstructorPntId = constructorId;
523 GroupPt->RB_Point3->setEnabled( true );
524 int buttonId = GroupPt2->ButtonGroup->checkedId();
525 MESSAGE("checkedId ="<< buttonId)
526 if (buttonId >= 0){ // = If a button is checked
527 Point2Clicked(buttonId);
530 GroupPt2->RB_Point1->setChecked( true );
535 //=================================================================================
536 // function : Point2Clicked()
537 // purpose : Radio button management
538 //=================================================================================
539 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
541 MESSAGE("Point2Clicked")
544 // Get setting of step value from file configuration
545 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
547 if ( myConstructorPntId == 1 ) { // XY
548 if ( constructorId == 1 ){ // No additional parameter
549 mySketchType = PT_ABS;
550 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
551 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
552 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
553 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
555 Group2Spin->SpinBox_DX->setValue( myX );
557 Group2Spin->SpinBox_DY->setValue( myY );
559 Group2Spin->buttonApply->setFocus();
561 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
563 else if ( constructorId == 0 ){ // Point + radius
564 mySketchType = PT_ABS_RADIUS;
565 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
566 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
567 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
568 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
569 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
570 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
572 Group3Spin->SpinBox_DX->setValue( myX );
574 Group3Spin->SpinBox_DY->setValue( myY );
576 Group3Spin->SpinBox_DZ->setValue( myRadius );
578 Group3Spin->buttonApply->setFocus();
580 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
582 else if ( constructorId == 2 ){ // Point + center
583 mySketchType = PT_ABS_CENTER;
584 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
585 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
586 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
587 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
588 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
589 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
590 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
591 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
593 Group4Spin->SpinBox_DX->setValue( myXc );
595 Group4Spin->SpinBox_DY->setValue( myYc );
597 Group4Spin->SpinBox_DZ->setValue( myX );
599 Group4Spin->SpinBox_DS->setValue( myY );
601 Group4Spin->buttonApply->setFocus();
603 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
607 else if ( myConstructorPntId == 0 ) { // DXDY
608 if ( constructorId == 1 ){ // No additional parameter
609 mySketchType = PT_RELATIVE;
610 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
611 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
612 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
613 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
615 Group2Spin->SpinBox_DX->setValue( myDX );
617 Group2Spin->SpinBox_DY->setValue( myDY );
619 Group2Spin->buttonApply->setFocus();
621 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
623 else if ( constructorId == 0 ){ // Point + radius
624 mySketchType = PT_REL_RADIUS;
625 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
626 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
627 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
628 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
629 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
630 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
632 Group3Spin->SpinBox_DX->setValue( myDX );
634 Group3Spin->SpinBox_DY->setValue( myDY );
636 Group3Spin->SpinBox_DZ->setValue( myRadius );
638 Group3Spin->buttonApply->setFocus();
640 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
642 else if ( constructorId == 2 ){ // Point + center
643 mySketchType = PT_REL_CENTER;
644 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
645 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
646 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
647 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
648 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
649 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
650 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
651 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
653 Group4Spin->SpinBox_DX->setValue( myDXc );
655 Group4Spin->SpinBox_DY->setValue( myDYc );
657 Group4Spin->SpinBox_DZ->setValue( myDX );
659 Group4Spin->SpinBox_DS->setValue( myDY );
661 Group4Spin->buttonApply->setFocus();
663 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
667 else if ( myConstructorPntId == 2 ) { // Selection
668 if ( constructorId == 1 ){ // No additional parameter
669 mySketchType = PT_SEL;
670 myEditCurrentArgument = Group1Sel->LineEdit1;
671 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
673 Group1Sel->buttonApply->setFocus();
674 SelectionIntoArgument();
676 else if ( constructorId == 0 ){ // Point + radius
677 mySketchType = PT_SEL_RADIUS;
678 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
679 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
680 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
681 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
683 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
685 Group1Sel1Spin->show();
686 Group1Sel1Spin->buttonApply->setFocus();
687 SelectionIntoArgument();
689 else if ( constructorId == 2 ){ // Point + center
690 mySketchType = PT_SEL_CENTER;
691 myEditCurrentArgument = Group2Sel->LineEdit1;
692 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
693 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
694 Group2Sel->LineEdit1->setEnabled(true);
695 Group2Sel->PushButton1->setDown(true);
696 Group2Sel->LineEdit2->setEnabled(false);
697 Group2Sel->PushButton2->setDown(false);
699 Group2Sel->buttonApply->setFocus();
700 SelectionIntoArgument();
704 resize( minimumSizeHint() );
705 connect( myGeometryGUI->getApp()->selectionMgr(),
706 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
711 //=================================================================================
712 // function : Dir1Clicked()
713 // purpose : Radio button management
714 //=================================================================================
715 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
717 myConstructorDirId = constructorId;
718 int dirButtonId = GroupD2->ButtonGroup->checkedId();
719 MESSAGE("checkedId ="<< dirButtonId)
720 if (dirButtonId >= 0){ // = If a button is checked
721 Dir2Clicked(dirButtonId);
724 GroupD2->RB_Dir21->setChecked( true );
730 //=================================================================================
731 // function : Dir2Clicked()
732 // purpose : Radio button management
733 //=================================================================================
734 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
739 // Get setting of step value from file configuration
740 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
742 if ( myConstructorId == 0 ) { // SEGMENT
746 if ( myConstructorDirId == 2 ) { // Angle
747 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
748 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
749 Group2Spin->SpinBox_DX->setValue( myAngle );
750 Group2Spin->buttonApply->setFocus();
753 if ( constructorId == 2 ) { // Length
754 mySketchType = DIR_ANGLE_LENGTH;
755 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
756 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
757 Group2Spin->SpinBox_DY->setValue( myLength );
759 else if ( constructorId == 0 ) { // X
760 mySketchType = DIR_ANGLE_X;
761 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
762 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
763 Group2Spin->SpinBox_DY->setValue( myX );
765 else if ( constructorId == 1 ) { // Y
766 mySketchType = DIR_ANGLE_Y;
767 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
768 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
769 Group2Spin->SpinBox_DY->setValue( myY );
772 else if ( myConstructorDirId == 0 ) { // Perpendicular
774 Group1Spin->buttonApply->setFocus();
776 if ( constructorId == 2 ) { // Length
777 mySketchType = DIR_PER_LENGTH;
778 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
779 Group1Spin->SpinBox_DX->setValue( myLength );
781 else if ( constructorId == 0 ) { // X
782 mySketchType = DIR_PER_X;
783 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
784 Group1Spin->SpinBox_DX->setValue( myX );
786 else if ( constructorId == 1 ) { // Y
787 mySketchType = DIR_PER_Y;
788 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
789 Group1Spin->SpinBox_DX->setValue( myY );
792 else if ( myConstructorDirId == 1 ) { // Tangent
794 Group1Spin->buttonApply->setFocus();
796 if ( constructorId == 2 ) { // Length
797 mySketchType = DIR_TAN_LENGTH;
798 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
799 Group1Spin->SpinBox_DX->setValue( myLength );
801 else if ( constructorId == 0 ) { // X
802 mySketchType = DIR_TAN_X;
803 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
804 Group1Spin->SpinBox_DX->setValue( myX );
806 else if ( constructorId == 1 ) { // Y
807 mySketchType = DIR_TAN_Y;
808 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
809 Group1Spin->SpinBox_DX->setValue( myY );
812 else if ( myConstructorDirId == 3 ) { // DXDY
813 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
814 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
815 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
816 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
817 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
819 Group3Spin->SpinBox_DX->setValue( myDX );
821 Group3Spin->SpinBox_DY->setValue( myDY );
823 Group3Spin->buttonApply->setFocus();
825 if ( constructorId == 2 ) { // Length
826 mySketchType = DIR_DXDY_LENGTH;
827 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
828 Group3Spin->SpinBox_DZ->setValue( myLength );
830 else if ( constructorId == 0 ) { // X
831 mySketchType = DIR_DXDY_X;
832 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
833 Group3Spin->SpinBox_DZ->setValue( myX );
835 else if ( constructorId == 1 ) { // Y
836 mySketchType = DIR_DXDY_Y;
837 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
838 Group3Spin->SpinBox_DZ->setValue( myY );
842 else if ( myConstructorId == 1 ) { // ARC
843 if ( myConstructorDirId == 2 ) { // Angle
844 if ( constructorId == 2 ) { // Length
845 mySketchType = DIR_ANGLE_LENGTH;
846 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
847 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
848 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
849 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
850 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
851 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
852 Group3Spin->SpinBox_DX->setValue( myAngle );
854 Group3Spin->SpinBox_DY->setValue( myRadius );
856 Group3Spin->SpinBox_DZ->setValue( myLength );
858 Group3Spin->buttonApply->setFocus();
861 else if ( myConstructorDirId == 0 ) { // Perpendicular
862 if ( constructorId == 2 ) { // Length
863 mySketchType = DIR_PER_LENGTH;
864 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
865 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
866 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
867 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
869 Group2Spin->SpinBox_DX->setValue( myRadius );
871 Group2Spin->SpinBox_DY->setValue( myLength );
873 Group2Spin->buttonApply->setFocus();
876 else if ( myConstructorDirId == 1 ) { // Tangent
877 if ( constructorId == 2 ) { // Length
878 mySketchType = DIR_TAN_LENGTH;
879 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
880 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
881 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
882 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
884 Group2Spin->SpinBox_DX->setValue( myRadius );
886 Group2Spin->SpinBox_DY->setValue( myLength );
888 Group2Spin->buttonApply->setFocus();
891 else if ( myConstructorDirId == 3 ) { // DXDY
892 if ( constructorId == 2 ) { // Length
893 mySketchType = DIR_DXDY_LENGTH;
894 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
895 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
896 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
897 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
898 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
899 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
900 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
901 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
903 Group4Spin->SpinBox_DX->setValue( myDX );
905 Group4Spin->SpinBox_DY->setValue( myDY );
907 Group4Spin->SpinBox_DZ->setValue( myRadius );
909 Group4Spin->SpinBox_DS->setValue( myLength );
911 Group4Spin->buttonApply->setFocus();
915 resize( minimumSizeHint() );
916 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
919 //=================================================================================
920 // function : CheckBoxClicked()
921 // purpose : CheckBox management
922 //=================================================================================
923 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
927 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
931 //=================================================================================
932 // function : ClickOnCancel()
934 //=================================================================================
935 void EntityGUI_SketcherDlg::ClickOnCancel()
941 //=================================================================================
942 // function : ClickOnEnd()
943 // purpose : connected to buttonEnd AND buttonClose
944 //=================================================================================
945 void EntityGUI_SketcherDlg::ClickOnEnd()
947 if ( sender() == MainWidget->buttonClose ) {
948 // Verify validity of commands
949 if ( myCommand.count() <= 2 ) {
950 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
951 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
956 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
957 Sketcher_Profile aProfile( Command.toAscii() );
959 Command = myCommand.join( "" );
960 aProfile = Sketcher_Profile( Command.toAscii() );
961 TopoDS_Shape myShape;
962 if ( aProfile.IsDone() )
963 myShape = aProfile.GetShape();
965 if ( myShape.ShapeType() != TopAbs_VERTEX )
966 myCommand.append( ":WW" );
969 // PAL16008 (Sketcher Validation should be equal to Apply&Close)
970 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
971 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
972 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
973 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
974 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
975 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
976 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
982 if ( myCommand.size() > 2 )
989 //=================================================================================
990 // function : ClickOnApply()
992 //=================================================================================
993 bool EntityGUI_SketcherDlg::ClickOnApply()
995 if ( sender() && sender()->inherits( "QPushButton" ) )
996 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
999 myCommand.append( GetNewCommand( aParameters ) );
1000 mySketchState = NEXT_POINT;
1002 myUndoCommand.clear();
1003 myUndoCommand.append( "Sketcher" );
1005 myParameters.append( aParameters );
1006 myUndoParameters.clear();
1008 MainWidget->GroupConstructors->setEnabled( true );
1009 MainWidget->GroupDest1->setEnabled( true );
1010 setEnabledUndo( true );
1011 setEnabledRedo( false );
1014 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1017 // Set focus to SpinBox_DX
1018 if ( sender() == Group1Spin->buttonApply ) {
1019 (Group1Spin->SpinBox_DX)->setFocus();
1020 (Group1Spin->SpinBox_DX)->selectAll();
1022 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1023 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1024 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1026 else if ( sender() == Group2Spin->buttonApply ) {
1027 (Group2Spin->SpinBox_DX)->setFocus();
1028 (Group2Spin->SpinBox_DX)->selectAll();
1030 else if ( sender() == Group3Spin->buttonApply ) {
1031 (Group3Spin->SpinBox_DX)->setFocus();
1032 (Group3Spin->SpinBox_DX)->selectAll();
1034 else if ( sender() == Group4Spin->buttonApply ) {
1035 (Group4Spin->SpinBox_DX)->setFocus();
1036 (Group4Spin->SpinBox_DX)->selectAll();
1042 //=================================================================================
1043 // function : ClickOnHelp()
1045 //=================================================================================
1046 void EntityGUI_SketcherDlg::ClickOnHelp()
1048 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1050 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1054 platform = "winapplication";
1056 platform = "application";
1059 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1060 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1061 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1062 QObject::tr( "BUT_OK" ) );
1066 //=================================================================================
1067 // function : ClickOnUndo()
1069 //=================================================================================
1070 void EntityGUI_SketcherDlg::ClickOnUndo()
1072 myUndoCommand.append( myCommand.last() );
1073 myCommand.pop_back();
1075 myUndoParameters.append( myParameters.last() );
1076 myParameters.pop_back();
1078 if ( myCommand.count() == 1 ) {
1079 mySketchState = FIRST_POINT;
1081 MainWidget->RadioButton1->setChecked( true );
1084 connect( myGeometryGUI->getApp()->selectionMgr(),
1085 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1087 MainWidget->GroupConstructors->setEnabled( false );
1088 MainWidget->GroupDest1->setEnabled( false );
1089 setEnabledUndo( false );
1092 setEnabledRedo( true );
1094 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1097 //=================================================================================
1098 // function : ClickOnRedo()
1100 //=================================================================================
1101 void EntityGUI_SketcherDlg::ClickOnRedo()
1103 myCommand.append( myUndoCommand.last() );
1104 myUndoCommand.pop_back();
1106 myParameters.append( myUndoParameters.last() );
1107 myUndoParameters.pop_back();
1109 mySketchState = NEXT_POINT;
1111 MainWidget->GroupConstructors->setEnabled( true );
1112 MainWidget->GroupDest1->setEnabled( true );
1113 setEnabledUndo( true );
1115 if ( myUndoCommand.count() == 1 )
1116 setEnabledRedo( false );
1118 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1121 //=================================================================================
1122 // function : setEnabledUndo()
1124 //=================================================================================
1125 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1127 Group1Sel->buttonUndo->setEnabled( value );
1128 Group2Sel->buttonUndo->setEnabled( value );
1129 Group1Sel1Spin->buttonUndo->setEnabled( value );
1130 Group1Spin->buttonUndo->setEnabled( value );
1131 Group2Spin->buttonUndo->setEnabled( value );
1132 Group3Spin->buttonUndo->setEnabled( value );
1133 Group4Spin->buttonUndo->setEnabled( value );
1136 //=================================================================================
1137 // function : setEnabledRedo()
1139 //=================================================================================
1140 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1142 Group1Sel->buttonRedo->setEnabled( value );
1143 Group2Sel->buttonRedo->setEnabled( value );
1144 Group1Sel1Spin->buttonRedo->setEnabled( value );
1145 Group1Spin->buttonRedo->setEnabled( value );
1146 Group2Spin->buttonRedo->setEnabled( value );
1147 Group3Spin->buttonRedo->setEnabled( value );
1148 Group4Spin->buttonRedo->setEnabled( value );
1151 //=================================================================================
1152 // function : SelectionIntoArgument()
1153 // purpose : Called when selection as changed
1154 //=================================================================================
1155 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1157 myEditCurrentArgument->setText( "" );
1162 // printf ("\nmyX = %f myY = %f", myX, myY);
1163 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
1164 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
1166 if ( sender() == ComboBox1 )
1169 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1170 SALOME_ListIO aSelList;
1171 aSelMgr->selectedObjects(aSelList);
1173 int nbSel = aSelList.Extent();
1174 if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1175 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1176 if ( !CORBA::is_nil(aSelectedObject) ) {
1177 TopoDS_Shape aShape;
1178 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1180 gp_Ax3 aWPlane = GetActiveLocalCS();
1182 aTrans.SetTransformation(aWPlane);
1183 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1184 aShape = aTransformation.Shape();
1187 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1190 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1191 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1192 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1193 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1194 Group2Spin->SpinBox_DX->setValue(myX);
1195 Group2Spin->SpinBox_DY->setValue(myY);
1196 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1197 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1198 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1199 if ( myLastX1 && myLastY1 ) {
1200 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1201 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1203 if ( mySketchState != FIRST_POINT ) {
1204 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1205 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1207 Group2Spin->SpinBox_DX->setValue(myX);
1208 Group2Spin->SpinBox_DY->setValue(myY);
1217 if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1218 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1219 if ( !CORBA::is_nil(aSelectedObject) ) {
1220 TopoDS_Shape aShape;
1221 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1223 gp_Ax3 aWPlane = GetActiveLocalCS();
1225 aTrans.SetTransformation(aWPlane);
1226 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1227 aShape = aTransformation.Shape();
1230 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1233 Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1234 if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1235 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1236 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1237 Group3Spin->SpinBox_DX->setValue(myX);
1238 Group3Spin->SpinBox_DY->setValue(myY);
1239 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1240 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1241 } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1242 if ( myLastX1 && myLastY1 ) {
1243 Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1244 Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1246 if ( mySketchState != FIRST_POINT ) {
1247 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1248 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1250 Group3Spin->SpinBox_DX->setValue(myX);
1251 Group3Spin->SpinBox_DY->setValue(myY);
1260 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1261 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1262 if ( !CORBA::is_nil(aSelectedObject) ) {
1263 TopoDS_Shape aShape;
1264 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1266 gp_Ax3 aWPlane = GetActiveLocalCS();
1268 aTrans.SetTransformation(aWPlane);
1269 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1270 aShape = aTransformation.Shape();
1273 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1276 Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1277 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1278 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1279 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1280 Group4Spin->SpinBox_DX->setValue(myXc);
1281 Group4Spin->SpinBox_DY->setValue(myYc);
1282 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1283 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1284 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1285 if ( myLastX1 && myLastY1 ) {
1286 Group4Spin->SpinBox_DX->setValue(myXc - myLastX1);
1287 Group4Spin->SpinBox_DY->setValue(myYc - myLastY1);
1289 if ( mySketchState != FIRST_POINT ) {
1290 Group4Spin->SpinBox_DX->setValue(myXc - tmpX);
1291 Group4Spin->SpinBox_DY->setValue(myYc - tmpY);
1293 Group4Spin->SpinBox_DX->setValue(myXc);
1294 Group4Spin->SpinBox_DY->setValue(myYc);
1303 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1304 if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
1305 myX=tmpX; // If yes keep the old values of X and Y
1308 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1309 if ( !CORBA::is_nil(aSelectedObject) ) {
1310 TopoDS_Shape aShape;
1311 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1313 gp_Ax3 aWPlane = GetActiveLocalCS();
1315 aTrans.SetTransformation(aWPlane);
1316 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1317 aShape = aTransformation.Shape();
1320 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1323 Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1324 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1325 disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1326 disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1327 Group4Spin->SpinBox_DZ->setValue(myX);
1328 Group4Spin->SpinBox_DS->setValue(myY);
1329 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1330 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1331 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1332 if ( myLastX1 && myLastY1 ) {
1333 Group4Spin->SpinBox_DZ->setValue(myX - myLastX1);
1334 Group4Spin->SpinBox_DS->setValue(myY - myLastY1);
1336 if ( mySketchState != FIRST_POINT ) {
1337 Group4Spin->SpinBox_DZ->setValue(myX - tmpX);
1338 Group4Spin->SpinBox_DS->setValue(myY - tmpY);
1340 Group4Spin->SpinBox_DZ->setValue(myX);
1341 Group4Spin->SpinBox_DS->setValue(myY);
1352 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1356 //=================================================================================
1357 // function : SetEditCurrentArgument()
1359 //=================================================================================
1360 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1362 if ( sender() == Group1Sel->PushButton1 ) {
1363 myEditCurrentArgument = Group1Sel->LineEdit1;
1364 myEditCurrentArgument->setFocus();
1366 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1367 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1368 myEditCurrentArgument->setFocus();
1370 else if ( sender() == Group2Sel->PushButton1 ) {
1371 myEditCurrentArgument = Group2Sel->LineEdit1;
1372 Group2Sel->PushButton2->setDown(false);
1373 Group2Sel->PushButton1->setDown(true);
1374 Group2Sel->LineEdit2->setEnabled(false);
1375 Group2Sel->LineEdit1->setEnabled(true);
1376 // myEditCurrentArgument->setFocus();
1378 else if ( sender() == Group2Sel->PushButton2 ) {
1379 myEditCurrentArgument = Group2Sel->LineEdit2;
1380 Group2Sel->PushButton1->setDown(false);
1381 Group2Sel->PushButton2->setDown(true);
1382 Group2Sel->LineEdit1->setEnabled(false);
1383 Group2Sel->LineEdit2->setEnabled(true);
1384 // myEditCurrentArgument->setFocus();
1386 SelectionIntoArgument();
1390 //=================================================================================
1391 // function : LineEditReturnPressed()
1393 //=================================================================================
1394 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1396 if ( sender() == Group1Sel->LineEdit1 )
1397 myEditCurrentArgument = Group1Sel->LineEdit1;
1398 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1399 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1400 else if ( sender() == Group2Sel->LineEdit1 )
1401 myEditCurrentArgument = Group2Sel->LineEdit1;
1402 else if ( sender() == Group2Sel->LineEdit2 )
1403 myEditCurrentArgument = Group2Sel->LineEdit2;
1405 /* User name of object input management */
1406 /* If successfull the selection is changed and signal emitted... */
1407 /* so SelectionIntoArgument() is automatically called. */
1408 const QString objectUserName = myEditCurrentArgument->text();
1409 QWidget* thisWidget = (QWidget*)this;
1411 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1412 SALOME_ListIO aSelList;
1413 aSelMgr->selectedObjects(aSelList);
1415 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1416 myEditCurrentArgument->setText( objectUserName );
1420 //=================================================================================
1421 // function : DeactivateActiveDialog()
1423 //=================================================================================
1424 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1426 //myGeometryGUI->SetState( -1 );
1428 setEnabled( false );
1430 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1431 myGeometryGUI->SetActiveDialogBox( 0 );
1435 //=================================================================================
1436 // function : ActivateThisDialog()
1438 //=================================================================================
1439 void EntityGUI_SketcherDlg::ActivateThisDialog()
1441 myGeometryGUI->EmitSignalDeactivateDialog();
1443 myGeometryGUI->SetActiveDialogBox( this );
1445 connect( myGeometryGUI->getApp()->selectionMgr(),
1446 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1448 //myGeometryGUI->SetState( 0 );
1449 globalSelection( GEOM_POINT );
1451 myEditCurrentArgument = Group1Sel->LineEdit1;
1452 myEditCurrentArgument->setFocus();
1454 if ( sender() == Group1Sel->LineEdit1 ) {
1455 myEditCurrentArgument = Group1Sel->LineEdit1;
1456 myEditCurrentArgument->setFocus();
1458 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1459 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1460 myEditCurrentArgument->setFocus();
1462 else if ( sender() == Group2Sel->LineEdit1 ) {
1463 myEditCurrentArgument = Group2Sel->LineEdit1;
1464 myEditCurrentArgument->setFocus();
1466 else if ( sender() == Group2Sel->LineEdit2 ) {
1467 myEditCurrentArgument = Group2Sel->LineEdit2;
1468 myEditCurrentArgument->setFocus();
1471 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1475 //=================================================================================
1476 // function : enterEvent [REDEFINED]
1478 //=================================================================================
1479 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1482 ActivateThisDialog();
1486 //=================================================================================
1487 // function : closeEvent()
1489 //=================================================================================
1490 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1492 //myGeometryGUI->SetState( -1 );
1493 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1494 myGeometryGUI->getApp()->updateActions();
1495 QDialog::closeEvent( e );
1499 //=================================================================================
1500 // function : ValueChangedInSpinBox()
1502 //=================================================================================
1503 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1505 QObject* send = (QObject*)sender();
1506 Standard_Real vx, vy, vz, vs, minRad;
1507 vx = vy = vz = vs = minRad =0.0;
1509 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1510 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1511 double LastDecimal = 0.0;
1513 QString vxStr, vyStr, vzStr, vsStr;
1515 QString newValueStr;
1516 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1517 newValueStr = aDoubleSpinBox->text();
1519 if ( send == Group1Spin->SpinBox_DX ) {
1520 vx = newValue; vxStr = newValueStr;
1522 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1523 vx = newValue; vxStr = newValueStr;
1525 else if ( send == Group2Spin->SpinBox_DX ) {
1526 vx = newValue; vxStr = newValueStr;
1527 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1529 else if ( send == Group2Spin->SpinBox_DY ) {
1530 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1531 vy = newValue; vyStr = newValueStr;
1533 else if ( send == Group3Spin->SpinBox_DX ) {
1534 vx = newValue; vxStr = newValueStr;
1535 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1536 vz = Group3Spin->SpinBox_DZ->value();
1537 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1538 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1539 if (aPrecision >= 0) // 'f' format in the QString
1540 LastDecimal = aPrecision;
1541 else // 'g' format in the Qstring
1542 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1543 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1544 if ( Abs(vz) < minRad){
1546 Group3Spin->SpinBox_DZ->setValue( - minRad );
1548 Group3Spin->SpinBox_DZ->setValue( minRad );
1551 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1553 else if ( send == Group3Spin->SpinBox_DY ) {
1554 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1555 vy = newValue; vyStr = newValueStr;
1556 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1557 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1558 minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
1559 if (aPrecision >= 0) // 'f' format in the QString
1560 LastDecimal = aPrecision;
1561 else // 'g' format in the QString
1562 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1563 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1564 if ( Abs(vz) < minRad){
1566 Group3Spin->SpinBox_DZ->setValue( - minRad );
1568 Group3Spin->SpinBox_DZ->setValue( minRad );
1571 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1573 else if ( send == Group3Spin->SpinBox_DZ ) {
1574 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1575 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1576 vz = newValue; vzStr = newValueStr;
1578 else if ( send == Group4Spin->SpinBox_DX ) {
1579 vx = newValue; vxStr = newValueStr;
1580 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1581 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1582 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1584 else if ( send == Group4Spin->SpinBox_DY ) {
1585 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1586 vy = newValue; vyStr = newValueStr;
1587 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1588 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1590 else if ( send == Group4Spin->SpinBox_DZ ) {
1591 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1592 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1593 vz = newValue; vzStr = newValueStr;
1594 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1596 else if ( send == Group4Spin->SpinBox_DS ) {
1597 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1598 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1599 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1600 vs = newValue; vsStr = newValueStr;
1602 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1604 if ( myConstructorId == 0 ) { // SEGMENT
1605 if ( mySketchType == PT_ABS ) {
1611 else if ( mySketchType == PT_RELATIVE ) {
1617 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1621 myLengthStr = vyStr;
1623 else if ( mySketchType == DIR_ANGLE_X ) {
1629 else if ( mySketchType == DIR_ANGLE_Y ) {
1635 else if ( mySketchType == DIR_PER_LENGTH ) {
1637 myLengthStr = vxStr;
1639 else if ( mySketchType == DIR_PER_X ) {
1643 else if ( mySketchType == DIR_PER_Y ) {
1647 else if ( mySketchType == DIR_TAN_LENGTH ) {
1649 myLengthStr = vxStr;
1651 else if ( mySketchType == DIR_TAN_X ) {
1655 else if ( mySketchType == DIR_TAN_Y ) {
1659 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1665 myLengthStr = vzStr;
1667 else if ( mySketchType == DIR_DXDY_X ) {
1675 else if ( mySketchType == DIR_DXDY_Y ) {
1684 else if ( myConstructorId == 1 ) { // ARC
1685 if ( mySketchType == PT_ABS ) {
1691 else if ( mySketchType == PT_RELATIVE ) {
1697 if ( mySketchType == PT_ABS_RADIUS ) {
1703 myRadiusStr = vzStr;
1705 else if ( mySketchType == PT_REL_RADIUS ) {
1711 myRadiusStr = vzStr;
1713 else if ( mySketchType == PT_SEL_RADIUS ) {
1715 myRadiusStr = vxStr;
1717 if ( mySketchType == PT_ABS_CENTER ) {
1727 else if ( mySketchType == PT_REL_CENTER ) {
1737 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1742 myRadiusStr = vyStr;
1743 myLengthStr = vzStr;
1745 else if ( mySketchType == DIR_PER_LENGTH ) {
1748 myRadiusStr = vxStr;
1749 myLengthStr = vyStr;
1751 else if ( mySketchType == DIR_TAN_LENGTH ) {
1754 myRadiusStr = vxStr;
1755 myLengthStr = vyStr;
1757 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1764 myRadiusStr = vzStr;
1765 myLengthStr = vsStr;
1769 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1773 //=================================================================================
1774 // function : GetNewCommand()
1775 // purpose : Build the new command with context
1776 //=================================================================================
1777 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1779 theParameters.clear();
1780 QString myNewCommand = ":";
1781 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1782 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1783 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1785 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1786 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1788 if ( mySketchState == FIRST_POINT ) {
1789 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1790 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1791 theParameters = myXStr + ":" + myYStr;
1793 if ( mySketchType == PT_RELATIVE) {
1794 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1795 theParameters = myDXStr + ":" + myDYStr;
1797 return myNewCommand;
1800 if ( myConstructorId == 0 ) { // SEGMENT
1801 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1802 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1803 theParameters = myXStr + ":" + myYStr;
1805 if ( mySketchType == PT_RELATIVE) {
1806 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1807 theParameters = myDXStr + ":" + myDYStr;
1809 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1810 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1811 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1812 theParameters = myAngleStr + ":" + myLengthStr;
1814 if ( mySketchType == DIR_ANGLE_X ) {
1815 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1816 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1817 theParameters = myAngleStr + ":" + myXStr;
1819 if ( mySketchType == DIR_ANGLE_Y ) {
1820 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1821 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1822 theParameters = myAngleStr + ":" + myYStr;
1824 if ( mySketchType == DIR_PER_LENGTH ) {
1825 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1826 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1827 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1829 if ( mySketchType == DIR_PER_X ) {
1830 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1831 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1832 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1834 if ( mySketchType == DIR_PER_Y ) {
1835 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1836 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1837 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1839 if ( mySketchType == DIR_TAN_LENGTH ) {
1840 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1841 theParameters = myLengthStr;
1843 if ( mySketchType == DIR_TAN_X ) {
1844 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1845 theParameters = myXStr;
1847 if ( mySketchType == DIR_TAN_Y) {
1848 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1849 theParameters = myYStr;
1851 if ( mySketchType == DIR_DXDY_LENGTH ) {
1852 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1853 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1854 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1856 if ( mySketchType == DIR_DXDY_X ) {
1857 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1858 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1859 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1861 if ( mySketchType == DIR_DXDY_Y ) {
1862 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1863 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1864 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1867 else if ( myConstructorId == 1 ) { // ARC
1868 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1869 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1870 theParameters = myXStr + ":" + myYStr;
1872 if ( mySketchType == PT_RELATIVE) {
1873 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1874 theParameters = myDXStr + ":" + myDYStr;
1876 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1877 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1878 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
1880 if ( mySketchType == PT_REL_RADIUS) {
1881 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
1882 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
1884 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
1885 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 );
1886 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
1888 if ( mySketchType == PT_REL_CENTER) {
1889 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 );
1890 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
1892 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1893 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1894 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1895 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1897 if ( mySketchType == DIR_PER_LENGTH ) {
1898 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1899 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1900 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
1902 if ( mySketchType == DIR_TAN_LENGTH ) {
1903 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1904 theParameters = myRadiusStr + ":" + myLengthStr;
1906 if ( mySketchType == DIR_DXDY_LENGTH ) {
1907 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1908 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
1909 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
1912 return myNewCommand;
1915 //=================================================================================
1916 // function : createOperation
1918 //=================================================================================
1919 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1921 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1924 //=================================================================================
1925 // function : isValid
1927 //=================================================================================
1928 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1931 bool toCorrect = !IsPreview() || myIsApply;
1933 if( Group1Spin->isVisible() ) {
1934 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1936 else if( Group1Sel1Spin->isVisible() ) {
1937 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1939 else if( Group2Spin->isVisible() ) {
1940 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1941 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1943 else if( Group3Spin->isVisible() ) {
1944 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1945 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1946 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1948 else if( Group4Spin->isVisible() ) {
1949 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1950 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1951 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1952 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
1955 if( myIsApply && !ok )
1961 //=================================================================================
1962 // function : execute
1964 //=================================================================================
1965 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1967 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1968 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1969 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1971 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1972 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1974 QString aParameters;
1976 if ( mySketchState == FIRST_POINT ) {
1981 //Test if the current point is the same as the last one
1982 TopoDS_Shape myShape1, myShape2;
1984 // Set "C" numeric locale
1985 Kernel_Utils::Localizer loc;
1988 QString Command1 = myCommand.join( "" );
1989 Sketcher_Profile aProfile1( Command1.toAscii() );
1990 if ( aProfile1.IsDone() )
1991 myShape1 = aProfile1.GetShape();
1994 QString Command2 = Command1 + GetNewCommand( aParameters );
1995 Sketcher_Profile aProfile2( Command2.toAscii() );
1998 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
1999 if (aProfile2.Error() > Precision::Confusion()){
2000 Group4Spin->label->show();
2001 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2004 Group4Spin->label->hide();
2008 Group4Spin->label->hide();
2009 if ( mySketchType == PT_SEL_CENTER ){
2010 if (aProfile2.Error() > Precision::Confusion()){
2011 Group2Sel->label->show();
2012 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2015 Group2Sel->label->hide();
2019 Group2Sel->label->hide();
2021 if ( aProfile2.IsDone() )
2022 myShape2 = aProfile2.GetShape();
2024 if ( myShape2.IsNull() ) {
2025 //the current point is the same as the last one
2026 myLastX2 = myLastX1;
2027 myLastY2 = myLastY1;
2030 TopoDS_Vertex V1, V2;
2032 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2033 //the last shape is the first point
2034 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2039 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2040 pt = BRep_Tool::Pnt( V2 );
2044 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2045 pt = BRep_Tool::Pnt( V2 );
2052 if ( ( mySketchState != FIRST_POINT &&
2053 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2054 cmd = myCommand.join( "" );
2055 if ( Group1Sel->isVisible() ) {
2056 Group1Sel->buttonApply->setEnabled( false );
2057 //Group1Sel->buttonApply->setFocus();
2059 if ( Group2Sel->isVisible() ) {
2060 Group2Sel->buttonApply->setEnabled( false );
2061 //Group2Sel->buttonApply->setFocus();
2063 if ( Group1Sel1Spin->isVisible() ) {
2064 Group1Sel1Spin->buttonApply->setEnabled( false );
2065 //Group1Sel1Spin->buttonApply->setFocus();
2067 if ( Group1Spin->isVisible() ) {
2068 Group1Spin->buttonApply->setEnabled( false );
2069 //Group1Spin->buttonApply->setFocus();
2071 if ( Group2Spin->isVisible() ) {
2072 Group2Spin->buttonApply->setEnabled( false );
2073 //Group2Spin->buttonApply->setFocus();
2075 if ( Group3Spin->isVisible() ) {
2076 Group3Spin->buttonApply->setEnabled( false );
2077 //Group3Spin->buttonApply->setFocus();
2079 if ( Group4Spin->isVisible() ) {
2080 Group4Spin->buttonApply->setEnabled( false );
2081 //Group4Spin->buttonApply->setFocus();
2085 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2087 if ( Group1Sel->isVisible() ) {
2088 Group1Sel->buttonApply->setEnabled( true );
2089 //Group1Sel->buttonApply->setFocus();
2091 if ( Group2Sel->isVisible() ) {
2092 Group2Sel->buttonApply->setEnabled( true );
2093 //Group2Sel->buttonApply->setFocus();
2095 if ( Group1Sel1Spin->isVisible() ) {
2096 Group1Sel1Spin->buttonApply->setEnabled( true );
2097 //Group1Sel1Spin->buttonApply->setFocus();
2099 if ( Group1Spin->isVisible() ) {
2100 Group1Spin->buttonApply->setEnabled( true );
2101 //Group1Spin->buttonApply->setFocus();
2103 if ( Group2Spin->isVisible() ) {
2104 Group2Spin->buttonApply->setEnabled( true );
2105 //Group2Spin->buttonApply->setFocus();
2107 if ( Group3Spin->isVisible() ) {
2108 Group3Spin->buttonApply->setEnabled( true );
2109 //Group3Spin->buttonApply->setFocus();
2111 if ( Group4Spin->isVisible() ) {
2112 Group4Spin->buttonApply->setEnabled( true );
2113 //Group4Spin->buttonApply->setFocus();
2117 gp_Ax3 myWPlane = GetActiveLocalCS();
2118 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2119 WPlane->length( 9 );
2120 WPlane[0] = myWPlane.Location().X();
2121 WPlane[1] = myWPlane.Location().Y();
2122 WPlane[2] = myWPlane.Location().Z();
2124 WPlane[3] = myWPlane.Direction().X();
2125 WPlane[4] = myWPlane.Direction().Y();
2126 WPlane[5] = myWPlane.Direction().Z();
2128 WPlane[6] = myWPlane.XDirection().X();
2129 WPlane[7] = myWPlane.XDirection().Y();
2130 WPlane[8] = myWPlane.XDirection().Z();
2132 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2133 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2135 if ( !anObj->_is_nil() )
2137 if( !IsPreview() ) {
2138 QStringList aCurrentParameters = myParameters;
2139 aCurrentParameters << aParameters;
2140 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2143 objects.push_back( anObj._retn() );
2149 //================================================================
2150 // Function : displayPreview
2151 // Purpose : Method for displaying preview of resulting shape
2152 // Redefined from GEOMBase_Helper.
2153 //================================================================
2154 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2156 const bool activate,
2158 const double lineWidth,
2159 const int displayMode,
2162 // Set color for preview shape
2163 getDisplayer()->SetColor( Quantity_NOC_RED );
2165 // set width of displayed shape
2166 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2168 // Disable activation of selection
2169 getDisplayer()->SetToActivate( activate );
2171 // Make a reference to GEOM_Object
2172 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2173 getDisplayer()->SetName( objStr.in() );
2175 // Create wire from applayed object
2176 TopoDS_Shape anApplyedWire, aLastSegment;
2177 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2181 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2182 if ( aPrs != 0 && !aPrs->IsNull() )
2183 GEOMBase_Helper::displayPreview( aPrs, append, update );
2185 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2186 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2187 if ( aPrs != 0 && !aPrs->IsNull() )
2188 GEOMBase_Helper::displayPreview( aPrs, append, update );
2190 getDisplayer()->UnsetName();
2192 // Enable activation of displayed objects
2193 getDisplayer()->SetToActivate( true );
2196 //================================================================
2197 // Function : createShapes
2198 // Purpose : Create applyed wire, and last segment from entry object
2199 //================================================================
2200 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2201 TopoDS_Shape& theApplyedWire,
2202 TopoDS_Shape& theLastSegment )
2204 TopoDS_Shape aShape;
2205 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2206 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2209 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2210 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2211 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2212 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2213 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2214 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2215 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2216 theApplyedWire = aShape;
2220 BRepBuilderAPI_MakeWire aBuilder;
2221 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2223 TopoDS_Shape anEdge = anExp.Current();
2225 if ( anExp.More() ) // i.e. non-last edge
2226 aBuilder.Add( TopoDS::Edge( anEdge ) );
2228 theLastSegment = anEdge;
2233 if ( aBuilder.IsDone() )
2234 theApplyedWire = aBuilder.Shape();
2239 //=================================================================================
2240 // function : keyPressEvent()
2242 //=================================================================================
2243 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2245 QDialog::keyPressEvent( e );
2246 if ( e->isAccepted() )
2249 if ( e->key() == Qt::Key_F1 ) {
2255 //=================================================================================
2256 // function : initSpinBox()
2258 //=================================================================================
2259 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2260 double min, double max,
2261 double step, const char* quantity )
2263 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2264 // TODO: Think how to keep the single piece of code...
2266 // Obtain precision from preferences
2267 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2268 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2270 spinBox->setPrecision( aPrecision );
2271 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2272 // by default Qt rounds boundaries to 2 decimals at setRange
2273 spinBox->setRange( min, max );
2274 spinBox->setSingleStep( step );
2276 // Add a hint for the user saying how to tune precision
2277 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2278 spinBox->setProperty( "validity_tune_hint",
2279 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2282 //=================================================================================
2283 // function : SetDoubleSpinBoxStep()
2284 // purpose : Double spin box management
2285 //=================================================================================
2286 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2288 Group1Spin->SpinBox_DX->setSingleStep(step);
2289 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2290 Group2Spin->SpinBox_DX->setSingleStep(step);
2291 Group2Spin->SpinBox_DY->setSingleStep(step);
2292 Group3Spin->SpinBox_DX->setSingleStep(step);
2293 Group3Spin->SpinBox_DY->setSingleStep(step);
2294 Group3Spin->SpinBox_DZ->setSingleStep(step);
2295 Group4Spin->SpinBox_DZ->setSingleStep(step);
2297 // san: Do NOT override the step when a speicifc step value is used
2298 // in some input fields!
2299 //Group4Spin->SpinBox_DX->setSingleStep(step);
2300 //Group4Spin->SpinBox_DY->setSingleStep(step);
2301 //Group4Spin->SpinBox_DS->setSingleStep(step);
2304 //=================================================================================
2305 // function : FindLocalCS()
2306 // purpose : Find All Coordinates systems in study
2307 //=================================================================================
2308 void EntityGUI_SketcherDlg::FindLocalCS()
2312 SalomeApp_Application* app =
2313 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2317 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2321 _PTR(Study) aStudy = appStudy->studyDS();
2324 ComboBox1->addItem(tr("GEOM_GCS"));
2325 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2326 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2327 gp_Dir aDirX = gp_Dir(1, 0, 0);
2328 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2329 myLCSList.push_back(globalCS);
2331 // get GEOM component
2332 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2333 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2336 _PTR(SComponent) fc = obj->GetFatherComponent();
2337 QString geomComp = fc->GetID().c_str();
2338 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2342 // browse through all GEOM data tree
2343 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2344 for ( it->InitEx( true ); it->More(); it->Next() ) {
2345 _PTR(SObject) child( it->Value() );
2346 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2347 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2348 if( CORBA::is_nil( geomObj ) )
2350 if (geomObj->GetType() == GEOM_MARKER) {
2351 ComboBox1->addItem(geomObj->GetName());
2352 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2355 aLCS.Transform(aShape.Location().Transformation());
2356 if (aShape.ShapeType() == TopAbs_FACE) {
2357 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2358 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2359 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2360 gp_Pln aPln = aGPlane->Pln();
2361 aLCS = aPln.Position();
2364 myLCSList.push_back(aLCS);
2369 //=================================================================================
2370 // function : GetActiveLocalCS()
2371 // purpose : Get Working plane
2372 //=================================================================================
2373 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2375 int ind = ComboBox1->currentIndex();
2377 return myGeometryGUI->GetWorkingPlane();
2379 gp_Ax3 aLCS = myLCSList.at(ind);
2384 //=================================================================================
2385 // function : ActivateLocalCS()
2386 // purpose : Activate & Fit Working plane
2387 //=================================================================================
2388 void EntityGUI_SketcherDlg::ActivateLocalCS()
2390 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2391 myGeometryGUI->ActiveWorkingPlane();