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 <BRepBuilderAPI_MakeVertex.hxx>
55 #include <Sketcher_Profile.hxx>
57 #include <SalomeApp_Study.h>
61 #include <Basics_Utils.hxx>
63 //=================================================================================
64 // class : EntityGUI_SketcherDlg()
65 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
66 // name 'name' and widget flags set to 'f'.
67 // The dialog will by default be modeless, unless you set 'modal' to
68 // TRUE to construct a modal dialog.
69 //=================================================================================
70 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
71 bool modal, Qt::WindowFlags fl,
72 const double lineWidth )
73 : QDialog( parent, fl ),
74 myIsAllAdded( false ),
76 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
78 myLineWidth( lineWidth )
80 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
82 setAttribute( Qt::WA_DeleteOnClose );
84 myGeometryGUI->SetActiveDialogBox(this);
86 MainWidget = new EntityGUI_Skeleton( this );
87 QVBoxLayout* topLayout = new QVBoxLayout( this );
88 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
90 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
91 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
92 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
93 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
95 QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
96 QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
97 QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
98 QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
99 QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) );
101 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
103 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
104 MainWidget->RadioButton1->setText( "" );
105 MainWidget->RadioButton1->setIcon( image3 );
106 MainWidget->RadioButton2->setText( "" );
107 MainWidget->RadioButton2->setIcon( image4 );
108 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
109 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
110 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
111 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
113 /***************************************************************/
115 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
116 QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
117 planeLayout->setSpacing(6);
118 planeLayout->setMargin(11);
120 ComboBox1 = new QComboBox(GroupBox1);
121 ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
122 planeLayout->addWidget(ComboBox1);
124 planeButton = new QPushButton (GroupBox1);
125 planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
126 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
127 planeLayout->addWidget(planeButton);
129 topLayout->addWidget(GroupBox1);
130 topLayout->addWidget( MainWidget );
131 topLayout->setStretch( 1, 1);
133 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
135 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
136 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
137 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
138 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
140 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
142 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
143 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
144 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
145 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
147 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
149 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
150 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
151 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
152 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
153 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
155 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
157 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
158 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
159 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
160 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
162 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
163 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
164 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
165 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
166 Group1Sel->PushButton1->setIcon( image0 );
167 Group1Sel->buttonUndo->setIcon( image1 );
168 Group1Sel->buttonRedo->setIcon( image2 );
169 Group1Sel->LineEdit1->setReadOnly( true );
171 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
172 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
173 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
174 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
175 Group2Sel->PushButton1->setIcon( image0 );
176 Group2Sel->PushButton2->setIcon( image0 );
177 Group2Sel->buttonUndo->setIcon( image1 );
178 Group2Sel->buttonRedo->setIcon( image2 );
179 Group2Sel->LineEdit1->setReadOnly( true );
180 Group2Sel->LineEdit2->setReadOnly( true );
182 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
183 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
184 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
185 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
186 Group1Sel1Spin->PushButton1->setIcon( image0 );
187 Group1Sel1Spin->buttonUndo->setIcon( image1 );
188 Group1Sel1Spin->buttonRedo->setIcon( image2 );
189 Group1Sel1Spin->LineEdit1->setReadOnly( true );
191 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
192 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
193 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
194 Group1Spin->buttonUndo->setIcon( image1 );
195 Group1Spin->buttonRedo->setIcon( image2 );
197 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
198 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
199 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
200 Group2Spin->buttonUndo->setIcon( image1 );
201 Group2Spin->buttonRedo->setIcon( image2 );
203 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
204 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
205 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
206 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
207 Group3Spin->buttonUndo->setIcon( image1 );
208 Group3Spin->buttonRedo->setIcon( image2 );
210 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
211 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
212 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
213 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
214 Group4Spin->buttonUndo->setIcon( image1 );
215 Group4Spin->buttonRedo->setIcon( image2 );
217 // Defines a palette for the error message on Group4Spin and Group2Sel
220 palette.setColor(Group4Spin->label->foregroundRole(), color);
221 Group4Spin->label->setPalette(palette);
222 palette.setColor(Group2Sel->label->foregroundRole(), color);
223 Group2Sel->label->setPalette(palette);
225 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
226 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
227 DestCntLayout->addWidget( GroupPt, 0, 0 );
228 DestCntLayout->addWidget( GroupPt2, 0, 1 );
229 DestCntLayout->addWidget( GroupD1, 0, 0 );
230 DestCntLayout->addWidget( GroupD2, 0, 1 );
232 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
233 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
234 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
235 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
236 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
237 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
238 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
239 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
240 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
241 //SkeletonCntlayout->setStretch( 0, 1);
242 /***************************************************************/
244 QButtonGroup* ButtonGroup = new QButtonGroup( this );
245 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
246 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
248 /* signals and slots connections */
249 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
250 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
251 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
252 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
254 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
255 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
256 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
257 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
258 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
259 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
260 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
261 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
262 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
263 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
264 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
265 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
266 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
267 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
268 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
269 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
270 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
271 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
272 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
273 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
274 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
276 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
277 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
278 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
279 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
280 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
281 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
283 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
284 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
286 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
287 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
288 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
289 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
291 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
292 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
293 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
295 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
296 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
297 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
298 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
299 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
300 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
301 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
302 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
303 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
304 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
306 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
307 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
308 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
309 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
311 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
312 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
314 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
316 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
317 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
319 // install event filter on spin-boxes to provide Apply action on Return pressed
320 Group1Spin->SpinBox_DX->installEventFilter(this);
321 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
322 Group2Spin->SpinBox_DX->installEventFilter(this);
323 Group2Spin->SpinBox_DY->installEventFilter(this);
324 Group3Spin->SpinBox_DX->installEventFilter(this);
325 Group3Spin->SpinBox_DY->installEventFilter(this);
326 Group3Spin->SpinBox_DZ->installEventFilter(this);
327 Group4Spin->SpinBox_DX->installEventFilter(this);
328 Group4Spin->SpinBox_DY->installEventFilter(this);
329 Group4Spin->SpinBox_DZ->installEventFilter(this);
330 Group4Spin->SpinBox_DS->installEventFilter(this);
336 //=================================================================================
337 // function : ~EntityGUI_SketcherDlg()
338 // purpose : Destroys the object and frees any allocated resources
339 //=================================================================================
340 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
342 myGeometryGUI->SetActiveDialogBox( 0 );
346 //=================================================================================
347 // function : eventFilter()
348 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
349 //=================================================================================
350 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
352 if (event->type() == QEvent::KeyPress) {
353 QKeyEvent* ke = (QKeyEvent*)event;
354 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
355 if (object == Group1Spin->SpinBox_DX) {
356 Group1Spin->buttonApply->click();
358 } else if (object == Group1Sel1Spin->SpinBox_DX) {
359 Group1Sel1Spin->buttonApply->click();
361 } else if (object == Group2Spin->SpinBox_DX ||
362 object == Group2Spin->SpinBox_DY) {
363 Group2Spin->buttonApply->click();
365 } else if (object == Group3Spin->SpinBox_DX ||
366 object == Group3Spin->SpinBox_DY ||
367 object == Group3Spin->SpinBox_DZ) {
368 Group3Spin->buttonApply->click();
370 } else if (object == Group4Spin->SpinBox_DX ||
371 object == Group4Spin->SpinBox_DY ||
372 object == Group4Spin->SpinBox_DZ ||
373 object == Group4Spin->SpinBox_DS) {
374 Group4Spin->buttonApply->click();
380 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
382 return QDialog::eventFilter(object, event);
386 //=================================================================================
389 //=================================================================================
390 void EntityGUI_SketcherDlg::Init()
394 myEditCurrentArgument = Group1Sel->LineEdit1;
395 myCommand.append( "Sketcher" );
396 myUndoCommand.append( "Sketcher" );
398 mySketchState = FIRST_POINT;
399 globalSelection( GEOM_POINT );
408 myHelpFileName = "create_sketcher_page.html";
410 /* Get setting of step value from file configuration */
411 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
413 /* min, max, step and decimals for spin boxes */
414 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
415 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
416 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
417 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
418 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
419 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
420 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
421 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
422 // san: Note specific step values below!
423 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
424 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
425 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
427 /* displays Dialog */
428 MainWidget->GroupConstructors->setEnabled( false );
429 MainWidget->GroupDest1->setEnabled( false );
430 setEnabledUndo( false );
431 setEnabledRedo( false );
433 MainWidget->RadioButton1->setChecked( true );
441 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
445 //=================================================================================
446 // function : InitClick()
448 //=================================================================================
449 void EntityGUI_SketcherDlg::InitClick()
451 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
456 Group1Sel1Spin->hide();
461 globalSelection(); // close local selection to clear it
462 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
466 //=================================================================================
467 // function : TypeClicked()
468 // purpose : Radio button management
469 //=================================================================================
470 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
472 myConstructorId = constructorId;
473 if ( myConstructorId == 0 ) { // SEGMENT
474 GroupPt2->RB_Point1->setChecked( true );
475 GroupPt2->setEnabled( false );
476 GroupD2->setEnabled( true );
477 MainWidget->RB_Dest1->setEnabled( true );
478 MainWidget->RB_Dest1->setChecked( true );
481 else if ( myConstructorId == 1 ) { // ARC
482 GroupPt2->setEnabled( true );
483 GroupD2->RB_Dir21->setChecked( true );
484 GroupD2->setEnabled( false );
485 MainWidget->RB_Dest1->setEnabled( true );
486 MainWidget->RB_Dest1->setChecked( true );
492 //=================================================================================
493 // function : DestClicked()
494 // purpose : Radio button management
495 //=================================================================================
496 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
503 if ( constructorId == 1 ) {
505 GroupPt->RB_Point1->setChecked( true );
508 Group3Spin->checkBox->show();
509 Group4Spin->checkBox->show();
510 PointClicked( 1 ); // XY
512 else if ( constructorId == 0 ) {
514 GroupD1->RB_Dir11->setChecked( true );
517 Group3Spin->checkBox->hide();
518 Group4Spin->checkBox->hide();
519 Dir1Clicked( 2 ); // Angle
521 resize( minimumSizeHint() );
524 //=================================================================================
525 // function : PointClicked()
526 // purpose : Radio button management
527 //=================================================================================
528 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
530 MESSAGE("PointClicked")
531 myConstructorPntId = constructorId;
532 GroupPt->RB_Point3->setEnabled( true );
533 int buttonId = GroupPt2->ButtonGroup->checkedId();
534 MESSAGE("checkedId ="<< buttonId)
535 if (buttonId >= 0){ // = If a button is checked
536 Point2Clicked(buttonId);
539 GroupPt2->RB_Point1->setChecked( true );
544 //=================================================================================
545 // function : Point2Clicked()
546 // purpose : Radio button management
547 //=================================================================================
548 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
550 MESSAGE("Point2Clicked")
553 // Get setting of step value from file configuration
554 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
556 if ( myConstructorPntId == 1 ) { // XY
557 if ( constructorId == 1 ){ // No additional parameter
558 mySketchType = PT_ABS;
559 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
560 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
561 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
562 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
564 Group2Spin->SpinBox_DX->setValue( myX );
566 Group2Spin->SpinBox_DY->setValue( myY );
568 Group2Spin->buttonApply->setFocus();
570 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
572 else if ( constructorId == 0 ){ // Point + radius
573 mySketchType = PT_ABS_RADIUS;
574 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
575 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
576 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
577 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
578 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
579 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
581 Group3Spin->SpinBox_DX->setValue( myX );
583 Group3Spin->SpinBox_DY->setValue( myY );
585 Group3Spin->SpinBox_DZ->setValue( myRadius );
587 Group3Spin->buttonApply->setFocus();
589 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
591 else if ( constructorId == 2 ){ // Point + center
592 mySketchType = PT_ABS_CENTER;
593 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
594 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
595 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
596 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
597 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
598 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
599 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
600 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
602 Group4Spin->SpinBox_DX->setValue( myXc );
604 Group4Spin->SpinBox_DY->setValue( myYc );
606 Group4Spin->SpinBox_DZ->setValue( myX );
608 Group4Spin->SpinBox_DS->setValue( myY );
610 Group4Spin->buttonApply->setFocus();
612 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
616 else if ( myConstructorPntId == 0 ) { // DXDY
617 if ( constructorId == 1 ){ // No additional parameter
618 mySketchType = PT_RELATIVE;
619 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
620 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
621 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
622 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
624 Group2Spin->SpinBox_DX->setValue( myDX );
626 Group2Spin->SpinBox_DY->setValue( myDY );
628 Group2Spin->buttonApply->setFocus();
630 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
632 else if ( constructorId == 0 ){ // Point + radius
633 mySketchType = PT_REL_RADIUS;
634 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
635 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
636 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
637 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
638 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
639 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
641 Group3Spin->SpinBox_DX->setValue( myDX );
643 Group3Spin->SpinBox_DY->setValue( myDY );
645 Group3Spin->SpinBox_DZ->setValue( myRadius );
647 Group3Spin->buttonApply->setFocus();
649 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
651 else if ( constructorId == 2 ){ // Point + center
652 mySketchType = PT_REL_CENTER;
653 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
654 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
655 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
656 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
657 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
658 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
659 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
660 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
662 Group4Spin->SpinBox_DX->setValue( myDXc );
664 Group4Spin->SpinBox_DY->setValue( myDYc );
666 Group4Spin->SpinBox_DZ->setValue( myDX );
668 Group4Spin->SpinBox_DS->setValue( myDY );
670 Group4Spin->buttonApply->setFocus();
672 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
676 else if ( myConstructorPntId == 2 ) { // Selection
677 if ( constructorId == 1 ){ // No additional parameter
678 mySketchType = PT_SEL;
679 myEditCurrentArgument = Group1Sel->LineEdit1;
680 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
682 Group1Sel->buttonApply->setFocus();
683 SelectionIntoArgument();
685 else if ( constructorId == 0 ){ // Point + radius
686 mySketchType = PT_SEL_RADIUS;
687 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
688 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
689 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
690 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
692 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
694 Group1Sel1Spin->show();
695 Group1Sel1Spin->buttonApply->setFocus();
696 SelectionIntoArgument();
698 else if ( constructorId == 2 ){ // Point + center
699 mySketchType = PT_SEL_CENTER;
700 myEditCurrentArgument = Group2Sel->LineEdit1;
701 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
702 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
703 Group2Sel->LineEdit1->setEnabled(true);
704 Group2Sel->PushButton1->setDown(true);
705 Group2Sel->LineEdit2->setEnabled(false);
706 Group2Sel->PushButton2->setDown(false);
708 Group2Sel->buttonApply->setFocus();
709 SelectionIntoArgument();
713 resize( minimumSizeHint() );
714 connect( myGeometryGUI->getApp()->selectionMgr(),
715 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
720 //=================================================================================
721 // function : Dir1Clicked()
722 // purpose : Radio button management
723 //=================================================================================
724 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
726 myConstructorDirId = constructorId;
727 int dirButtonId = GroupD2->ButtonGroup->checkedId();
728 MESSAGE("checkedId ="<< dirButtonId)
729 if (dirButtonId >= 0){ // = If a button is checked
730 Dir2Clicked(dirButtonId);
733 GroupD2->RB_Dir21->setChecked( true );
739 //=================================================================================
740 // function : Dir2Clicked()
741 // purpose : Radio button management
742 //=================================================================================
743 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
748 // Get setting of step value from file configuration
749 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
751 if ( myConstructorId == 0 ) { // SEGMENT
755 if ( myConstructorDirId == 2 ) { // Angle
756 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
757 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
758 Group2Spin->SpinBox_DX->setValue( myAngle );
759 Group2Spin->buttonApply->setFocus();
762 if ( constructorId == 2 ) { // Length
763 mySketchType = DIR_ANGLE_LENGTH;
764 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
765 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
766 Group2Spin->SpinBox_DY->setValue( myLength );
768 else if ( constructorId == 0 ) { // X
769 mySketchType = DIR_ANGLE_X;
770 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
771 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
772 Group2Spin->SpinBox_DY->setValue( myX );
774 else if ( constructorId == 1 ) { // Y
775 mySketchType = DIR_ANGLE_Y;
776 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
777 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
778 Group2Spin->SpinBox_DY->setValue( myY );
781 else if ( myConstructorDirId == 0 ) { // Perpendicular
783 Group1Spin->buttonApply->setFocus();
785 if ( constructorId == 2 ) { // Length
786 mySketchType = DIR_PER_LENGTH;
787 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
788 Group1Spin->SpinBox_DX->setValue( myLength );
790 else if ( constructorId == 0 ) { // X
791 mySketchType = DIR_PER_X;
792 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
793 Group1Spin->SpinBox_DX->setValue( myX );
795 else if ( constructorId == 1 ) { // Y
796 mySketchType = DIR_PER_Y;
797 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
798 Group1Spin->SpinBox_DX->setValue( myY );
801 else if ( myConstructorDirId == 1 ) { // Tangent
803 Group1Spin->buttonApply->setFocus();
805 if ( constructorId == 2 ) { // Length
806 mySketchType = DIR_TAN_LENGTH;
807 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
808 Group1Spin->SpinBox_DX->setValue( myLength );
810 else if ( constructorId == 0 ) { // X
811 mySketchType = DIR_TAN_X;
812 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
813 Group1Spin->SpinBox_DX->setValue( myX );
815 else if ( constructorId == 1 ) { // Y
816 mySketchType = DIR_TAN_Y;
817 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
818 Group1Spin->SpinBox_DX->setValue( myY );
821 else if ( myConstructorDirId == 3 ) { // DXDY
822 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
823 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
824 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
825 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
826 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
828 Group3Spin->SpinBox_DX->setValue( myDX );
830 Group3Spin->SpinBox_DY->setValue( myDY );
832 Group3Spin->buttonApply->setFocus();
834 if ( constructorId == 2 ) { // Length
835 mySketchType = DIR_DXDY_LENGTH;
836 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
837 Group3Spin->SpinBox_DZ->setValue( myLength );
839 else if ( constructorId == 0 ) { // X
840 mySketchType = DIR_DXDY_X;
841 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
842 Group3Spin->SpinBox_DZ->setValue( myX );
844 else if ( constructorId == 1 ) { // Y
845 mySketchType = DIR_DXDY_Y;
846 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
847 Group3Spin->SpinBox_DZ->setValue( myY );
851 else if ( myConstructorId == 1 ) { // ARC
852 if ( myConstructorDirId == 2 ) { // Angle
853 if ( constructorId == 2 ) { // Length
854 mySketchType = DIR_ANGLE_LENGTH;
855 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
856 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
857 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
858 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
859 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
860 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
861 Group3Spin->SpinBox_DX->setValue( myAngle );
863 Group3Spin->SpinBox_DY->setValue( myRadius );
865 Group3Spin->SpinBox_DZ->setValue( myLength );
867 Group3Spin->buttonApply->setFocus();
870 else if ( myConstructorDirId == 0 ) { // Perpendicular
871 if ( constructorId == 2 ) { // Length
872 mySketchType = DIR_PER_LENGTH;
873 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
874 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
875 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
876 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
878 Group2Spin->SpinBox_DX->setValue( myRadius );
880 Group2Spin->SpinBox_DY->setValue( myLength );
882 Group2Spin->buttonApply->setFocus();
885 else if ( myConstructorDirId == 1 ) { // Tangent
886 if ( constructorId == 2 ) { // Length
887 mySketchType = DIR_TAN_LENGTH;
888 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
889 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
890 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
891 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
893 Group2Spin->SpinBox_DX->setValue( myRadius );
895 Group2Spin->SpinBox_DY->setValue( myLength );
897 Group2Spin->buttonApply->setFocus();
900 else if ( myConstructorDirId == 3 ) { // DXDY
901 if ( constructorId == 2 ) { // Length
902 mySketchType = DIR_DXDY_LENGTH;
903 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
904 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
905 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
906 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
907 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
908 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
909 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
910 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
912 Group4Spin->SpinBox_DX->setValue( myDX );
914 Group4Spin->SpinBox_DY->setValue( myDY );
916 Group4Spin->SpinBox_DZ->setValue( myRadius );
918 Group4Spin->SpinBox_DS->setValue( myLength );
920 Group4Spin->buttonApply->setFocus();
924 resize( minimumSizeHint() );
925 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
928 //=================================================================================
929 // function : CheckBoxClicked()
930 // purpose : CheckBox management
931 //=================================================================================
932 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
936 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
940 //=================================================================================
941 // function : ClickOnCancel()
943 //=================================================================================
944 void EntityGUI_SketcherDlg::ClickOnCancel()
950 //=================================================================================
951 // function : ClickOnEnd()
952 // purpose : connected to buttonEnd AND buttonClose
953 //=================================================================================
954 void EntityGUI_SketcherDlg::ClickOnEnd()
956 if ( sender() == MainWidget->buttonClose ) {
957 // Verify validity of commands
958 if ( myCommand.count() <= 2 ) {
959 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
960 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
965 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
966 Sketcher_Profile aProfile( Command.toAscii() );
968 Command = myCommand.join( "" );
969 aProfile = Sketcher_Profile( Command.toAscii() );
970 TopoDS_Shape myShape;
971 if ( aProfile.IsDone() )
972 myShape = aProfile.GetShape();
974 if ( myShape.ShapeType() != TopAbs_VERTEX )
975 myCommand.append( ":WW" );
978 // PAL16008 (Sketcher Validation should be equal to Apply&Close)
979 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
980 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
981 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
982 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
983 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
984 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
985 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
991 if ( myCommand.size() > 2 )
998 //=================================================================================
999 // function : ClickOnApply()
1001 //=================================================================================
1002 bool EntityGUI_SketcherDlg::ClickOnApply()
1004 if ( sender() && sender()->inherits( "QPushButton" ) )
1005 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1007 QString aParameters;
1008 myCommand.append( GetNewCommand( aParameters ) );
1009 mySketchState = NEXT_POINT;
1011 myUndoCommand.clear();
1012 myUndoCommand.append( "Sketcher" );
1014 myParameters.append( aParameters );
1015 myUndoParameters.clear();
1017 MainWidget->GroupConstructors->setEnabled( true );
1018 MainWidget->GroupDest1->setEnabled( true );
1019 setEnabledUndo( true );
1020 setEnabledRedo( false );
1023 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1026 // Set focus to SpinBox_DX
1027 if ( sender() == Group1Spin->buttonApply ) {
1028 (Group1Spin->SpinBox_DX)->setFocus();
1029 (Group1Spin->SpinBox_DX)->selectAll();
1031 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1032 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1033 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1035 else if ( sender() == Group2Spin->buttonApply ) {
1036 (Group2Spin->SpinBox_DX)->setFocus();
1037 (Group2Spin->SpinBox_DX)->selectAll();
1039 else if ( sender() == Group3Spin->buttonApply ) {
1040 (Group3Spin->SpinBox_DX)->setFocus();
1041 (Group3Spin->SpinBox_DX)->selectAll();
1043 else if ( sender() == Group4Spin->buttonApply ) {
1044 (Group4Spin->SpinBox_DX)->setFocus();
1045 (Group4Spin->SpinBox_DX)->selectAll();
1051 //=================================================================================
1052 // function : ClickOnHelp()
1054 //=================================================================================
1055 void EntityGUI_SketcherDlg::ClickOnHelp()
1057 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1059 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1063 platform = "winapplication";
1065 platform = "application";
1068 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1069 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1070 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1071 QObject::tr( "BUT_OK" ) );
1075 //=================================================================================
1076 // function : ClickOnUndo()
1078 //=================================================================================
1079 void EntityGUI_SketcherDlg::ClickOnUndo()
1081 myUndoCommand.append( myCommand.last() );
1082 myCommand.pop_back();
1084 myUndoParameters.append( myParameters.last() );
1085 myParameters.pop_back();
1087 if ( myCommand.count() == 1 ) {
1088 mySketchState = FIRST_POINT;
1090 MainWidget->RadioButton1->setChecked( true );
1093 connect( myGeometryGUI->getApp()->selectionMgr(),
1094 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1096 MainWidget->GroupConstructors->setEnabled( false );
1097 MainWidget->GroupDest1->setEnabled( false );
1098 setEnabledUndo( false );
1101 setEnabledRedo( true );
1103 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1106 //=================================================================================
1107 // function : ClickOnRedo()
1109 //=================================================================================
1110 void EntityGUI_SketcherDlg::ClickOnRedo()
1112 myCommand.append( myUndoCommand.last() );
1113 myUndoCommand.pop_back();
1115 myParameters.append( myUndoParameters.last() );
1116 myUndoParameters.pop_back();
1118 mySketchState = NEXT_POINT;
1120 MainWidget->GroupConstructors->setEnabled( true );
1121 MainWidget->GroupDest1->setEnabled( true );
1122 setEnabledUndo( true );
1124 if ( myUndoCommand.count() == 1 )
1125 setEnabledRedo( false );
1127 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1130 //=================================================================================
1131 // function : setEnabledUndo()
1133 //=================================================================================
1134 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1136 Group1Sel->buttonUndo->setEnabled( value );
1137 Group2Sel->buttonUndo->setEnabled( value );
1138 Group1Sel1Spin->buttonUndo->setEnabled( value );
1139 Group1Spin->buttonUndo->setEnabled( value );
1140 Group2Spin->buttonUndo->setEnabled( value );
1141 Group3Spin->buttonUndo->setEnabled( value );
1142 Group4Spin->buttonUndo->setEnabled( value );
1145 //=================================================================================
1146 // function : setEnabledRedo()
1148 //=================================================================================
1149 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1151 Group1Sel->buttonRedo->setEnabled( value );
1152 Group2Sel->buttonRedo->setEnabled( value );
1153 Group1Sel1Spin->buttonRedo->setEnabled( value );
1154 Group1Spin->buttonRedo->setEnabled( value );
1155 Group2Spin->buttonRedo->setEnabled( value );
1156 Group3Spin->buttonRedo->setEnabled( value );
1157 Group4Spin->buttonRedo->setEnabled( value );
1160 //=================================================================================
1161 // function : SelectionIntoArgument()
1162 // purpose : Called when selection as changed
1163 //=================================================================================
1164 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1166 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1167 myEditCurrentArgument->setText( "" );
1172 // printf ("\nmyX = %f myY = %f", myX, myY);
1173 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
1174 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
1176 if ( sender() == ComboBox1 )
1179 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1180 SALOME_ListIO aSelList;
1181 aSelMgr->selectedObjects(aSelList);
1183 int nbSel = aSelList.Extent();
1184 MESSAGE("NbSel = "<<nbSel)
1185 if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
1186 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1187 if ( !CORBA::is_nil(aSelectedObject) ) {
1188 TopoDS_Shape aShape;
1189 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1191 gp_Ax3 aWPlane = GetActiveLocalCS();
1193 aTrans.SetTransformation(aWPlane);
1194 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1195 aShape = aTransformation.Shape();
1198 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1201 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1202 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
1203 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1204 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1205 Group2Spin->SpinBox_DX->setValue(myX);
1206 Group2Spin->SpinBox_DY->setValue(myY);
1207 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1208 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1209 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1210 if ( myLastX1 && myLastY1 ) {
1211 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
1212 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
1214 if ( mySketchState != FIRST_POINT ) {
1215 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
1216 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
1218 Group2Spin->SpinBox_DX->setValue(myX);
1219 Group2Spin->SpinBox_DY->setValue(myY);
1228 if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
1229 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1230 if ( !CORBA::is_nil(aSelectedObject) ) {
1231 TopoDS_Shape aShape;
1232 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1234 gp_Ax3 aWPlane = GetActiveLocalCS();
1236 aTrans.SetTransformation(aWPlane);
1237 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1238 aShape = aTransformation.Shape();
1241 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1244 Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1245 if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
1246 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1247 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1248 Group3Spin->SpinBox_DX->setValue(myX);
1249 Group3Spin->SpinBox_DY->setValue(myY);
1250 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1251 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1252 } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1253 if ( myLastX1 && myLastY1 ) {
1254 Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
1255 Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
1257 if ( mySketchState != FIRST_POINT ) {
1258 Group3Spin->SpinBox_DX->setValue(myX - tmpX);
1259 Group3Spin->SpinBox_DY->setValue(myY - tmpY);
1261 Group3Spin->SpinBox_DX->setValue(myX);
1262 Group3Spin->SpinBox_DY->setValue(myY);
1271 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
1272 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1273 if ( !CORBA::is_nil(aSelectedObject) ) {
1274 TopoDS_Shape aShape;
1275 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1277 gp_Ax3 aWPlane = GetActiveLocalCS();
1279 aTrans.SetTransformation(aWPlane);
1280 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1281 aShape = aTransformation.Shape();
1284 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1287 Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
1288 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1289 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1290 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1291 Group4Spin->SpinBox_DX->setValue(myXc);
1292 Group4Spin->SpinBox_DY->setValue(myYc);
1293 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1294 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1295 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1296 if ( myLastX1 && myLastY1 ) {
1297 Group4Spin->SpinBox_DX->setValue(myXc - myLastX1);
1298 Group4Spin->SpinBox_DY->setValue(myYc - myLastY1);
1300 if ( mySketchState != FIRST_POINT ) {
1301 Group4Spin->SpinBox_DX->setValue(myXc - tmpX);
1302 Group4Spin->SpinBox_DY->setValue(myYc - tmpY);
1304 Group4Spin->SpinBox_DX->setValue(myXc);
1305 Group4Spin->SpinBox_DY->setValue(myYc);
1314 if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
1315 if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
1316 myX=tmpX; // If yes keep the old values of X and Y
1319 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
1320 if ( !CORBA::is_nil(aSelectedObject) ) {
1321 TopoDS_Shape aShape;
1322 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
1324 gp_Ax3 aWPlane = GetActiveLocalCS();
1326 aTrans.SetTransformation(aWPlane);
1327 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1328 aShape = aTransformation.Shape();
1331 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
1334 Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
1335 if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
1336 disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1337 disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1338 Group4Spin->SpinBox_DZ->setValue(myX);
1339 Group4Spin->SpinBox_DS->setValue(myY);
1340 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1341 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1342 } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
1343 if ( myLastX1 && myLastY1 ) {
1344 Group4Spin->SpinBox_DZ->setValue(myX - myLastX1);
1345 Group4Spin->SpinBox_DS->setValue(myY - myLastY1);
1347 if ( mySketchState != FIRST_POINT ) {
1348 Group4Spin->SpinBox_DZ->setValue(myX - tmpX);
1349 Group4Spin->SpinBox_DS->setValue(myY - tmpY);
1351 Group4Spin->SpinBox_DZ->setValue(myX);
1352 Group4Spin->SpinBox_DS->setValue(myY);
1360 if (nbSel == 0){ // If no object selected
1361 myX=tmpX; // Don't change the point coordinates
1362 myY=tmpY; // and don't redisplay the preview
1364 else if(!autoApply){
1365 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1371 this->activateWindow();
1376 //=================================================================================
1377 // function : SetEditCurrentArgument()
1379 //=================================================================================
1380 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1382 if ( sender() == Group1Sel->PushButton1 ) {
1383 myEditCurrentArgument = Group1Sel->LineEdit1;
1384 myEditCurrentArgument->setFocus();
1386 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1387 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1388 myEditCurrentArgument->setFocus();
1390 else if ( sender() == Group2Sel->PushButton1 ) {
1391 myEditCurrentArgument = Group2Sel->LineEdit1;
1392 Group2Sel->PushButton2->setDown(false);
1393 Group2Sel->PushButton1->setDown(true);
1394 Group2Sel->LineEdit2->setEnabled(false);
1395 Group2Sel->LineEdit1->setEnabled(true);
1396 // myEditCurrentArgument->setFocus();
1398 else if ( sender() == Group2Sel->PushButton2 ) {
1399 myEditCurrentArgument = Group2Sel->LineEdit2;
1400 Group2Sel->PushButton1->setDown(false);
1401 Group2Sel->PushButton2->setDown(true);
1402 Group2Sel->LineEdit1->setEnabled(false);
1403 Group2Sel->LineEdit2->setEnabled(true);
1404 // myEditCurrentArgument->setFocus();
1406 SelectionIntoArgument();
1410 //=================================================================================
1411 // function : LineEditReturnPressed()
1413 //=================================================================================
1414 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1416 if ( sender() == Group1Sel->LineEdit1 )
1417 myEditCurrentArgument = Group1Sel->LineEdit1;
1418 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1419 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1420 else if ( sender() == Group2Sel->LineEdit1 )
1421 myEditCurrentArgument = Group2Sel->LineEdit1;
1422 else if ( sender() == Group2Sel->LineEdit2 )
1423 myEditCurrentArgument = Group2Sel->LineEdit2;
1425 /* User name of object input management */
1426 /* If successfull the selection is changed and signal emitted... */
1427 /* so SelectionIntoArgument() is automatically called. */
1428 const QString objectUserName = myEditCurrentArgument->text();
1429 QWidget* thisWidget = (QWidget*)this;
1431 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1432 SALOME_ListIO aSelList;
1433 aSelMgr->selectedObjects(aSelList);
1435 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1436 myEditCurrentArgument->setText( objectUserName );
1440 //=================================================================================
1441 // function : DeactivateActiveDialog()
1443 //=================================================================================
1444 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1446 //myGeometryGUI->SetState( -1 );
1448 setEnabled( false );
1450 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1451 myGeometryGUI->SetActiveDialogBox( 0 );
1455 //=================================================================================
1456 // function : ActivateThisDialog()
1458 //=================================================================================
1459 void EntityGUI_SketcherDlg::ActivateThisDialog()
1461 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1462 myGeometryGUI->EmitSignalDeactivateDialog();
1464 myGeometryGUI->SetActiveDialogBox( this );
1466 connect( myGeometryGUI->getApp()->selectionMgr(),
1467 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1469 //myGeometryGUI->SetState( 0 );
1470 globalSelection( GEOM_POINT );
1472 myEditCurrentArgument = Group1Sel->LineEdit1;
1473 myEditCurrentArgument->setFocus();
1475 if ( sender() == Group1Sel->LineEdit1 ) {
1476 myEditCurrentArgument = Group1Sel->LineEdit1;
1477 myEditCurrentArgument->setFocus();
1479 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1480 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1481 myEditCurrentArgument->setFocus();
1483 else if ( sender() == Group2Sel->LineEdit1 ) {
1484 myEditCurrentArgument = Group2Sel->LineEdit1;
1485 myEditCurrentArgument->setFocus();
1487 else if ( sender() == Group2Sel->LineEdit2 ) {
1488 myEditCurrentArgument = Group2Sel->LineEdit2;
1489 myEditCurrentArgument->setFocus();
1492 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1496 //=================================================================================
1497 // function : enterEvent [REDEFINED]
1499 //=================================================================================
1500 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1503 ActivateThisDialog();
1507 //=================================================================================
1508 // function : closeEvent()
1510 //=================================================================================
1511 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1513 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1514 //myGeometryGUI->SetState( -1 );
1515 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1516 myGeometryGUI->getApp()->updateActions();
1517 QDialog::closeEvent( e );
1520 //=================================================================================
1521 // function : OnPointSelected
1523 //=================================================================================
1524 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt)
1526 MESSAGE("EntityGUI_SketcherDlg::OnPointSelected")
1531 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1532 TopoDS_Shape aShape = mkVertex.Shape();
1534 // Taking into account LocalCS
1535 gp_Ax3 aWPlane = GetActiveLocalCS();
1538 aTrans.SetTransformation(aWPlane);
1539 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1540 aShape = aTransformation.Shape();
1543 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1545 autoApply = ( getPnt2ConstructorId() == 1 && false ); // If no additional argument needed after selection
1546 // -> apply automatically --> disabled for now
1548 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1549 x = aTrsfPnt.X() - myLastX1;
1550 y = aTrsfPnt.Y() - myLastY1;
1556 switch (getPnt2ConstructorId()){
1558 Group2Spin->SpinBox_DX->setValue( x );
1559 Group2Spin->SpinBox_DY->setValue( y );
1560 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1563 Group3Spin->SpinBox_DX->setValue( x );
1564 Group3Spin->SpinBox_DY->setValue( y );
1565 Group3Spin->buttonApply->setFocus();
1568 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1569 Group4Spin->SpinBox_DX->setValue( x );
1570 Group4Spin->SpinBox_DY->setValue( y );
1572 else{ // Select end point
1573 Group4Spin->SpinBox_DZ->setValue( x );
1574 Group4Spin->SpinBox_DS->setValue( y );
1576 Group4Spin->buttonApply->setFocus();
1581 //=================================================================================
1582 // function : ValueChangedInSpinBox()
1584 //=================================================================================
1585 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1587 MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
1588 QObject* send = (QObject*)sender();
1589 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1590 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1592 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1593 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1594 double LastDecimal = 0.0;
1596 QString vxStr, vyStr, vzStr, vsStr;
1598 QString newValueStr;
1599 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1600 newValueStr = aDoubleSpinBox->text();
1602 if ( send == Group1Spin->SpinBox_DX ) {
1603 vx = newValue; vxStr = newValueStr;
1605 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1606 vx = newValue; vxStr = newValueStr;
1608 else if ( send == Group2Spin->SpinBox_DX ) {
1609 vx = newValue; vxStr = newValueStr;
1610 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1612 else if ( send == Group2Spin->SpinBox_DY ) {
1613 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1614 vy = newValue; vyStr = newValueStr;
1616 else if ( send == Group3Spin->SpinBox_DX ) {
1617 vx = newValue; vxStr = newValueStr;
1618 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1619 vz = Group3Spin->SpinBox_DZ->value();
1620 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1621 if (mySketchType == PT_ABS_RADIUS){
1629 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1630 if (aPrecision >= 0) // 'f' format in the QString
1631 LastDecimal = aPrecision;
1632 else // 'g' format in the Qstring
1633 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1634 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1635 if ( Abs(vz) < minRad){
1637 Group3Spin->SpinBox_DZ->setValue( - minRad );
1639 Group3Spin->SpinBox_DZ->setValue( minRad );
1642 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1644 else if ( send == Group3Spin->SpinBox_DY ) {
1645 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1646 vy = newValue; vyStr = newValueStr;
1647 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1648 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1649 if (mySketchType == PT_ABS_RADIUS){
1657 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1658 if (aPrecision >= 0) // 'f' format in the QString
1659 LastDecimal = aPrecision;
1660 else // 'g' format in the QString
1661 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1662 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1663 if ( Abs(vz) < minRad){
1665 Group3Spin->SpinBox_DZ->setValue( - minRad );
1667 Group3Spin->SpinBox_DZ->setValue( minRad );
1670 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1672 else if ( send == Group3Spin->SpinBox_DZ ) {
1673 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1674 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1675 vz = newValue; vzStr = newValueStr;
1677 else if ( send == Group4Spin->SpinBox_DX ) {
1678 vx = newValue; vxStr = newValueStr;
1679 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1680 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1681 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1683 else if ( send == Group4Spin->SpinBox_DY ) {
1684 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1685 vy = newValue; vyStr = newValueStr;
1686 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1687 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1689 else if ( send == Group4Spin->SpinBox_DZ ) {
1690 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1691 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1692 vz = newValue; vzStr = newValueStr;
1693 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1695 else if ( send == Group4Spin->SpinBox_DS ) {
1696 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1697 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1698 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1699 vs = newValue; vsStr = newValueStr;
1701 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1703 if ( myConstructorId == 0 ) { // SEGMENT
1704 if ( mySketchType == PT_ABS ) {
1710 else if ( mySketchType == PT_RELATIVE ) {
1716 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1720 myLengthStr = vyStr;
1722 else if ( mySketchType == DIR_ANGLE_X ) {
1728 else if ( mySketchType == DIR_ANGLE_Y ) {
1734 else if ( mySketchType == DIR_PER_LENGTH ) {
1736 myLengthStr = vxStr;
1738 else if ( mySketchType == DIR_PER_X ) {
1742 else if ( mySketchType == DIR_PER_Y ) {
1746 else if ( mySketchType == DIR_TAN_LENGTH ) {
1748 myLengthStr = vxStr;
1750 else if ( mySketchType == DIR_TAN_X ) {
1754 else if ( mySketchType == DIR_TAN_Y ) {
1758 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1764 myLengthStr = vzStr;
1766 else if ( mySketchType == DIR_DXDY_X ) {
1774 else if ( mySketchType == DIR_DXDY_Y ) {
1783 else if ( myConstructorId == 1 ) { // ARC
1784 if ( mySketchType == PT_ABS ) {
1790 else if ( mySketchType == PT_RELATIVE ) {
1796 if ( mySketchType == PT_ABS_RADIUS ) {
1802 myRadiusStr = vzStr;
1804 else if ( mySketchType == PT_REL_RADIUS ) {
1810 myRadiusStr = vzStr;
1812 else if ( mySketchType == PT_SEL_RADIUS ) {
1814 myRadiusStr = vxStr;
1816 if ( mySketchType == PT_ABS_CENTER ) {
1826 else if ( mySketchType == PT_REL_CENTER ) {
1836 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1841 myRadiusStr = vyStr;
1842 myLengthStr = vzStr;
1844 else if ( mySketchType == DIR_PER_LENGTH ) {
1847 myRadiusStr = vxStr;
1848 myLengthStr = vyStr;
1850 else if ( mySketchType == DIR_TAN_LENGTH ) {
1853 myRadiusStr = vxStr;
1854 myLengthStr = vyStr;
1856 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1863 myRadiusStr = vzStr;
1864 myLengthStr = vsStr;
1869 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1871 double x, y, xc, yc;
1872 x = y = xc = yc = 0.0;
1873 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
1875 if ( mySketchType == PT_REL_CENTER ){
1876 x = myDX + myLastX1;
1877 y = myDY + myLastY1;
1878 xc = myDXc + myLastX1;
1879 yc = myDYc + myLastY1;
1887 displayPntPreview(xc,yc);
1888 displayPntPreview(x,y);
1893 //=================================================================================
1894 // function : GetNewCommand()
1895 // purpose : Build the new command with context
1896 //=================================================================================
1897 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1899 theParameters.clear();
1900 QString myNewCommand = ":";
1901 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1902 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1903 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1905 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1906 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1908 if ( mySketchState == FIRST_POINT ) {
1909 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1910 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1911 theParameters = myXStr + ":" + myYStr;
1913 if ( mySketchType == PT_RELATIVE) {
1914 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1915 theParameters = myDXStr + ":" + myDYStr;
1917 return myNewCommand;
1920 if ( myConstructorId == 0 ) { // SEGMENT
1921 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1922 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1923 theParameters = myXStr + ":" + myYStr;
1925 if ( mySketchType == PT_RELATIVE) {
1926 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1927 theParameters = myDXStr + ":" + myDYStr;
1929 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1930 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1931 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1932 theParameters = myAngleStr + ":" + myLengthStr;
1934 if ( mySketchType == DIR_ANGLE_X ) {
1935 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1936 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1937 theParameters = myAngleStr + ":" + myXStr;
1939 if ( mySketchType == DIR_ANGLE_Y ) {
1940 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1941 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1942 theParameters = myAngleStr + ":" + myYStr;
1944 if ( mySketchType == DIR_PER_LENGTH ) {
1945 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1946 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1947 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1949 if ( mySketchType == DIR_PER_X ) {
1950 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1951 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1952 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1954 if ( mySketchType == DIR_PER_Y ) {
1955 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1956 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1957 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1959 if ( mySketchType == DIR_TAN_LENGTH ) {
1960 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1961 theParameters = myLengthStr;
1963 if ( mySketchType == DIR_TAN_X ) {
1964 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1965 theParameters = myXStr;
1967 if ( mySketchType == DIR_TAN_Y) {
1968 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1969 theParameters = myYStr;
1971 if ( mySketchType == DIR_DXDY_LENGTH ) {
1972 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1973 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1974 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1976 if ( mySketchType == DIR_DXDY_X ) {
1977 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1978 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1979 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1981 if ( mySketchType == DIR_DXDY_Y ) {
1982 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1983 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1984 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1987 else if ( myConstructorId == 1 ) { // ARC
1988 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1989 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1990 theParameters = myXStr + ":" + myYStr;
1992 if ( mySketchType == PT_RELATIVE) {
1993 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1994 theParameters = myDXStr + ":" + myDYStr;
1996 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1997 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1998 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
2000 if ( mySketchType == PT_REL_RADIUS) {
2001 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
2002 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
2004 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2005 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 );
2006 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2008 if ( mySketchType == PT_REL_CENTER) {
2009 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 );
2010 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2012 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2013 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2014 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2015 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2017 if ( mySketchType == DIR_PER_LENGTH ) {
2018 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2019 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2020 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2022 if ( mySketchType == DIR_TAN_LENGTH ) {
2023 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2024 theParameters = myRadiusStr + ":" + myLengthStr;
2026 if ( mySketchType == DIR_DXDY_LENGTH ) {
2027 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2028 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2029 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2032 return myNewCommand;
2035 //=================================================================================
2036 // function : createOperation
2038 //=================================================================================
2039 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2041 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2044 //=================================================================================
2045 // function : isValid
2047 //=================================================================================
2048 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2051 bool toCorrect = !IsPreview() || myIsApply;
2053 if( Group1Spin->isVisible() ) {
2054 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2056 else if( Group1Sel1Spin->isVisible() ) {
2057 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2059 else if( Group2Spin->isVisible() ) {
2060 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2061 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2063 else if( Group3Spin->isVisible() ) {
2064 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2065 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2066 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2068 else if( Group4Spin->isVisible() ) {
2069 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2070 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2071 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2072 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2075 if( myIsApply && !ok )
2081 //=================================================================================
2082 // function : execute
2084 //=================================================================================
2085 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2087 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2088 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2089 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2091 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2092 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2094 QString aParameters;
2096 if ( mySketchState == FIRST_POINT ) {
2101 //Test if the current point is the same as the last one
2102 TopoDS_Shape myShape1, myShape2;
2104 // Set "C" numeric locale
2105 Kernel_Utils::Localizer loc;
2108 QString Command1 = myCommand.join( "" );
2109 Sketcher_Profile aProfile1( Command1.toAscii() );
2110 if ( aProfile1.IsDone() )
2111 myShape1 = aProfile1.GetShape();
2114 QString Command2 = Command1 + GetNewCommand( aParameters );
2115 Sketcher_Profile aProfile2( Command2.toAscii() );
2118 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2119 if (aProfile2.Error() > Precision::Confusion()){
2120 Group4Spin->label->show();
2121 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2124 Group4Spin->label->hide();
2128 Group4Spin->label->hide();
2129 if ( mySketchType == PT_SEL_CENTER ){
2130 if (aProfile2.Error() > Precision::Confusion()){
2131 Group2Sel->label->show();
2132 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2135 Group2Sel->label->hide();
2139 Group2Sel->label->hide();
2141 if ( aProfile2.IsDone() )
2142 myShape2 = aProfile2.GetShape();
2144 if ( myShape2.IsNull() ) {
2145 //the current point is the same as the last one
2146 myLastX2 = myLastX1;
2147 myLastY2 = myLastY1;
2150 TopoDS_Vertex V1, V2;
2152 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2153 //the last shape is the first point
2154 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2159 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2160 pt = BRep_Tool::Pnt( V2 );
2164 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2165 pt = BRep_Tool::Pnt( V2 );
2172 if ( ( mySketchState != FIRST_POINT &&
2173 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2174 cmd = myCommand.join( "" );
2175 if ( Group1Sel->isVisible() ) {
2176 Group1Sel->buttonApply->setEnabled( false );
2177 //Group1Sel->buttonApply->setFocus();
2179 if ( Group2Sel->isVisible() ) {
2180 Group2Sel->buttonApply->setEnabled( false );
2181 //Group2Sel->buttonApply->setFocus();
2183 if ( Group1Sel1Spin->isVisible() ) {
2184 Group1Sel1Spin->buttonApply->setEnabled( false );
2185 //Group1Sel1Spin->buttonApply->setFocus();
2187 if ( Group1Spin->isVisible() ) {
2188 Group1Spin->buttonApply->setEnabled( false );
2189 //Group1Spin->buttonApply->setFocus();
2191 if ( Group2Spin->isVisible() ) {
2192 Group2Spin->buttonApply->setEnabled( false );
2193 //Group2Spin->buttonApply->setFocus();
2195 if ( Group3Spin->isVisible() ) {
2196 Group3Spin->buttonApply->setEnabled( false );
2197 //Group3Spin->buttonApply->setFocus();
2199 if ( Group4Spin->isVisible() ) {
2200 Group4Spin->buttonApply->setEnabled( false );
2201 //Group4Spin->buttonApply->setFocus();
2205 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2207 if ( Group1Sel->isVisible() ) {
2208 Group1Sel->buttonApply->setEnabled( true );
2210 if ( Group2Sel->isVisible() ) {
2211 Group2Sel->buttonApply->setEnabled( true );
2213 if ( Group1Sel1Spin->isVisible() ) {
2214 Group1Sel1Spin->buttonApply->setEnabled( true );;
2216 if ( Group1Spin->isVisible() ) {
2217 Group1Spin->buttonApply->setEnabled( true );
2219 if ( Group2Spin->isVisible() ) {
2220 Group2Spin->buttonApply->setEnabled( true );
2222 if ( Group3Spin->isVisible() ) {
2223 Group3Spin->buttonApply->setEnabled( true );
2225 if ( Group4Spin->isVisible() ) {
2226 Group4Spin->buttonApply->setEnabled( true );
2230 gp_Ax3 myWPlane = GetActiveLocalCS();
2231 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
2232 WPlane->length( 9 );
2233 WPlane[0] = myWPlane.Location().X();
2234 WPlane[1] = myWPlane.Location().Y();
2235 WPlane[2] = myWPlane.Location().Z();
2237 WPlane[3] = myWPlane.Direction().X();
2238 WPlane[4] = myWPlane.Direction().Y();
2239 WPlane[5] = myWPlane.Direction().Z();
2241 WPlane[6] = myWPlane.XDirection().X();
2242 WPlane[7] = myWPlane.XDirection().Y();
2243 WPlane[8] = myWPlane.XDirection().Z();
2245 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2246 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
2248 if ( !anObj->_is_nil() )
2250 if( !IsPreview() ) {
2251 QStringList aCurrentParameters = myParameters;
2252 aCurrentParameters << aParameters;
2253 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2256 objects.push_back( anObj._retn() );
2262 //================================================================
2263 // Function : displayPreview
2264 // Purpose : Method for displaying preview of resulting shape
2265 // Redefined from GEOMBase_Helper.
2266 //================================================================
2267 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2269 const bool activate,
2271 const double lineWidth,
2272 const int displayMode,
2275 // Set color for preview shape
2276 getDisplayer()->SetColor( Quantity_NOC_RED );
2278 // set width of displayed shape
2279 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
2281 // Disable activation of selection
2282 getDisplayer()->SetToActivate( activate );
2284 // Make a reference to GEOM_Object
2285 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2286 getDisplayer()->SetName( objStr.in() );
2288 // Create wire from applayed object
2289 TopoDS_Shape anApplyedWire, aLastSegment;
2290 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2294 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2295 if ( aPrs != 0 && !aPrs->IsNull() )
2296 GEOMBase_Helper::displayPreview( aPrs, append, update );
2298 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2299 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2300 if ( aPrs != 0 && !aPrs->IsNull() )
2301 GEOMBase_Helper::displayPreview( aPrs, append, update );
2303 getDisplayer()->UnsetName();
2305 // Enable activation of displayed objects
2306 getDisplayer()->SetToActivate( true );
2309 //================================================================
2310 // Function : displayPntPreview
2311 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2312 //================================================================
2313 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2319 // Get globalCS and working plane
2320 gp_Ax3 globalCS = myLCSList.first(); //gp_Ax3(aOrigin, aDirZ, aDirX);
2321 gp_Ax3 aWPlane = GetActiveLocalCS();
2323 // Build point in localCS
2324 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2326 // Get transfomation from local to global CS
2328 aTrans.SetTransformation(aWPlane, globalCS);
2330 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2331 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2333 // Perform transformation
2334 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2335 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2337 // Build prs with vertex in globalCS
2338 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2339 if ( aPrs != 0 && !aPrs->IsNull() )
2340 GEOMBase_Helper::displayPreview( aPrs, append, update );
2344 //================================================================
2345 // Function : createShapes
2346 // Purpose : Create applyed wire, and last segment from entry object
2347 //================================================================
2348 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2349 TopoDS_Shape& theApplyedWire,
2350 TopoDS_Shape& theLastSegment )
2352 TopoDS_Shape aShape;
2353 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2354 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2357 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2358 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2359 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2360 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2361 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2362 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2363 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2364 theApplyedWire = aShape;
2368 BRepBuilderAPI_MakeWire aBuilder;
2369 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2371 TopoDS_Shape anEdge = anExp.Current();
2373 if ( anExp.More() ) // i.e. non-last edge
2374 aBuilder.Add( TopoDS::Edge( anEdge ) );
2376 theLastSegment = anEdge;
2381 if ( aBuilder.IsDone() )
2382 theApplyedWire = aBuilder.Shape();
2387 //=================================================================================
2388 // function : keyPressEvent()
2390 //=================================================================================
2391 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2393 QDialog::keyPressEvent( e );
2394 if ( e->isAccepted() )
2397 if ( e->key() == Qt::Key_F1 ) {
2403 //=================================================================================
2404 // function : initSpinBox()
2406 //=================================================================================
2407 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2408 double min, double max,
2409 double step, const char* quantity )
2411 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2412 // TODO: Think how to keep the single piece of code...
2414 // Obtain precision from preferences
2415 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2416 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2418 spinBox->setPrecision( aPrecision );
2419 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2420 // by default Qt rounds boundaries to 2 decimals at setRange
2421 spinBox->setRange( min, max );
2422 spinBox->setSingleStep( step );
2424 // Add a hint for the user saying how to tune precision
2425 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2426 spinBox->setProperty( "validity_tune_hint",
2427 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2430 //=================================================================================
2431 // function : SetDoubleSpinBoxStep()
2432 // purpose : Double spin box management
2433 //=================================================================================
2434 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2436 Group1Spin->SpinBox_DX->setSingleStep(step);
2437 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2438 Group2Spin->SpinBox_DX->setSingleStep(step);
2439 Group2Spin->SpinBox_DY->setSingleStep(step);
2440 Group3Spin->SpinBox_DX->setSingleStep(step);
2441 Group3Spin->SpinBox_DY->setSingleStep(step);
2442 Group3Spin->SpinBox_DZ->setSingleStep(step);
2443 Group4Spin->SpinBox_DZ->setSingleStep(step);
2445 // san: Do NOT override the step when a speicifc step value is used
2446 // in some input fields!
2447 //Group4Spin->SpinBox_DX->setSingleStep(step);
2448 //Group4Spin->SpinBox_DY->setSingleStep(step);
2449 //Group4Spin->SpinBox_DS->setSingleStep(step);
2452 //=================================================================================
2453 // function : FindLocalCS()
2454 // purpose : Find All Coordinates systems in study
2455 //=================================================================================
2456 void EntityGUI_SketcherDlg::FindLocalCS()
2460 SalomeApp_Application* app =
2461 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2465 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2469 _PTR(Study) aStudy = appStudy->studyDS();
2472 ComboBox1->addItem(tr("GEOM_GCS"));
2473 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
2474 gp_Dir aDirZ = gp_Dir(0, 0, 1);
2475 gp_Dir aDirX = gp_Dir(1, 0, 0);
2476 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
2477 myLCSList.push_back(globalCS);
2479 // get GEOM component
2480 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2481 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2484 _PTR(SComponent) fc = obj->GetFatherComponent();
2485 QString geomComp = fc->GetID().c_str();
2486 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2490 // browse through all GEOM data tree
2491 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2492 for ( it->InitEx( true ); it->More(); it->Next() ) {
2493 _PTR(SObject) child( it->Value() );
2494 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2495 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2496 if( CORBA::is_nil( geomObj ) )
2498 if (geomObj->GetType() == GEOM_MARKER) {
2499 ComboBox1->addItem(geomObj->GetName());
2500 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2503 aLCS.Transform(aShape.Location().Transformation());
2504 if (aShape.ShapeType() == TopAbs_FACE) {
2505 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
2506 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
2507 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
2508 gp_Pln aPln = aGPlane->Pln();
2509 aLCS = aPln.Position();
2512 myLCSList.push_back(aLCS);
2517 //=================================================================================
2518 // function : getPnt1ConstructorId()
2520 //=================================================================================
2521 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2523 int buttonId = GroupPt->ButtonGroup->checkedId();
2524 // MESSAGE("buttonId = "<<buttonId)
2528 //=================================================================================
2529 // function : getPnt2ConstructorId()
2531 //=================================================================================
2532 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2534 int buttonId = GroupPt2->ButtonGroup->checkedId();
2535 // MESSAGE("buttonId = "<<buttonId)
2539 //=================================================================================
2540 // function : GetActiveLocalCS()
2541 // purpose : Get Working plane
2542 //=================================================================================
2543 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2545 int ind = ComboBox1->currentIndex();
2547 return myGeometryGUI->GetWorkingPlane();
2549 gp_Ax3 aLCS = myLCSList.at(ind);
2554 //=================================================================================
2555 // function : ActivateLocalCS()
2556 // purpose : Activate & Fit Working plane
2557 //=================================================================================
2558 void EntityGUI_SketcherDlg::ActivateLocalCS()
2560 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2561 myGeometryGUI->ActiveWorkingPlane();