1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
27 #include "EntityGUI_SketcherDlg.h"
28 #include "EntityGUI_Widgets.h"
29 #include <SalomeApp_DoubleSpinBox.h>
31 #include <OCCViewer_ViewPort3d.h>
32 #include <OCCViewer_ViewWindow.h>
35 #include <GeometryGUI.h>
36 #include <GEOMImpl_Types.hxx>
37 #include <Geom_Surface.hxx>
38 #include <Geom_Plane.hxx>
40 #include <SUIT_Desktop.h>
41 #include <SUIT_Session.h>
42 #include <SUIT_MessageBox.h>
43 #include <SUIT_ResourceMgr.h>
44 #include <SalomeApp_Application.h>
45 #include <LightApp_Application.h>
46 #include <LightApp_SelectionMgr.h>
50 #include <BRep_Tool.hxx>
52 #include <TopExp_Explorer.hxx>
53 #include <TopoDS_Vertex.hxx>
55 #include <BRepBuilderAPI_Transform.hxx>
56 #include <BRepBuilderAPI_MakeWire.hxx>
57 #include <BRepBuilderAPI_MakeVertex.hxx>
58 #include <Sketcher_Profile.hxx>
60 #include <SalomeApp_Study.h>
61 #include <SalomeApp_Tools.h>
65 #include <Basics_Utils.hxx>
67 //=================================================================================
68 // class : EntityGUI_SketcherDlg()
69 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
70 // name 'name' and widget flags set to 'f'.
71 // The dialog will by default be modeless, unless you set 'modal' to
72 // TRUE to construct a modal dialog.
73 //=================================================================================
74 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
75 bool modal, Qt::WindowFlags fl,
76 const double lineWidth )
77 : QDialog( parent, fl ),
78 myIsAllAdded( false ),
80 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
82 myLineWidth( lineWidth )
84 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
86 setAttribute( Qt::WA_DeleteOnClose );
88 myGeometryGUI->SetActiveDialogBox(this);
90 MainWidget = new EntityGUI_Skeleton( this );
91 QVBoxLayout* topLayout = new QVBoxLayout( this );
92 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
94 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
95 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_CLOSE" ) );
96 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
97 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
99 QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
100 QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
101 QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
102 QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
103 QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) );
104 QPixmap image5 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
106 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
108 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
109 MainWidget->RadioButton1->setText( "" );
110 MainWidget->RadioButton1->setIcon( image3 );
111 MainWidget->RadioButton2->setText( "" );
112 MainWidget->RadioButton2->setIcon( image4 );
113 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
114 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
115 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
116 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
118 /***************************************************************/
120 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
121 QGridLayout* planeLayout = new QGridLayout(GroupBox1);
122 planeLayout->setSpacing(6);
123 planeLayout->setMargin(11);
125 ComboBox1 = new QComboBox(GroupBox1);
126 //ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
127 planeLayout->addWidget(ComboBox1,0,0,1,2);
129 planeButton = new QPushButton (GroupBox1);
130 //planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
131 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
132 planeLayout->addWidget(planeButton,0,2);
134 selButton = new QPushButton (GroupBox1);
135 selButton->setIcon(image5);
136 planeLayout->addWidget(selButton,1,0);
138 WPlaneLineEdit = new QLineEdit (GroupBox1);
139 WPlaneLineEdit->setReadOnly(true);
140 planeLayout->addWidget(WPlaneLineEdit,1,1,1,2);
142 planeLayout->setColumnStretch(1,1);
144 topLayout->addWidget(GroupBox1);
145 topLayout->addWidget( MainWidget );
146 topLayout->setStretch( 1, 1);
148 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
150 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
151 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
152 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
153 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
155 GroupPt2 = new EntityGUI_Point( MainWidget->DestCnt );
157 GroupPt2->GroupPoint->setTitle( tr( "GEOM_SKETCHER_ADD_PARAMS" ) );
158 GroupPt2->RB_Point1->setText( tr( "GEOM_SKETCHER_NONE" ) );
159 GroupPt2->RB_Point2->setText( tr( "GEOM_SKETCHER_RADIUS" ) );
160 GroupPt2->RB_Point3->setText( tr( "GEOM_SKETCHER_CENTER" ) );
162 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
164 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
165 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
166 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
167 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
168 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
170 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
172 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIST" ) );
173 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
174 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
175 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
177 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
178 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
179 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
180 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
181 Group1Sel->PushButton1->setIcon( image0 );
182 Group1Sel->buttonUndo->setIcon( image1 );
183 Group1Sel->buttonRedo->setIcon( image2 );
184 Group1Sel->LineEdit1->setReadOnly( true );
186 Group2Sel = new EntityGUI_2Sel1Check( MainWidget->SkeletonCnt );
187 Group2Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
188 Group2Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
189 Group2Sel->checkBox->setText( tr( "GEOM_REVERSE" ) );
190 Group2Sel->PushButton1->setIcon( image0 );
191 Group2Sel->PushButton2->setIcon( image0 );
192 Group2Sel->buttonUndo->setIcon( image1 );
193 Group2Sel->buttonRedo->setIcon( image2 );
194 Group2Sel->LineEdit1->setReadOnly( true );
195 Group2Sel->LineEdit2->setReadOnly( true );
197 Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check( MainWidget->SkeletonCnt );
198 Group1Sel1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
199 Group1Sel1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
200 Group1Sel1Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
201 Group1Sel1Spin->PushButton1->setIcon( image0 );
202 Group1Sel1Spin->buttonUndo->setIcon( image1 );
203 Group1Sel1Spin->buttonRedo->setIcon( image2 );
204 Group1Sel1Spin->LineEdit1->setReadOnly( true );
206 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
207 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
208 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
209 Group1Spin->buttonUndo->setIcon( image1 );
210 Group1Spin->buttonRedo->setIcon( image2 );
212 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
213 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
214 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
215 Group2Spin->buttonUndo->setIcon( image1 );
216 Group2Spin->buttonRedo->setIcon( image2 );
218 Group3Spin = new EntityGUI_3Spin1Check( MainWidget->SkeletonCnt );
219 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
220 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
221 Group3Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
222 Group3Spin->buttonUndo->setIcon( image1 );
223 Group3Spin->buttonRedo->setIcon( image2 );
225 Group4Spin = new EntityGUI_4Spin1Check( MainWidget->SkeletonCnt );
226 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
227 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
228 Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
229 Group4Spin->buttonUndo->setIcon( image1 );
230 Group4Spin->buttonRedo->setIcon( image2 );
232 // Defines a palette for the error message on Group4Spin and Group2Sel
235 palette.setColor(Group4Spin->label->foregroundRole(), color);
236 Group4Spin->label->setPalette(palette);
237 palette.setColor(Group2Sel->label->foregroundRole(), color);
238 Group2Sel->label->setPalette(palette);
240 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
241 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
242 DestCntLayout->addWidget( GroupPt, 0, 0 );
243 DestCntLayout->addWidget( GroupPt2, 0, 1 );
244 DestCntLayout->addWidget( GroupD1, 0, 0 );
245 DestCntLayout->addWidget( GroupD2, 0, 1 );
247 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
248 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
249 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
250 SkeletonCntlayout->addWidget( Group2Sel, 0, 0 );
251 SkeletonCntlayout->addWidget( Group1Sel1Spin, 0, 0 );
252 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
253 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
254 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
255 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
256 //SkeletonCntlayout->setStretch( 0, 1);
257 /***************************************************************/
259 QButtonGroup* ButtonGroup = new QButtonGroup( this );
260 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
261 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
263 /* signals and slots connections */
264 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
265 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
266 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
267 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
269 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
270 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
271 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
272 connect( Group2Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
273 connect( Group2Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
274 connect( Group2Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
275 connect( Group1Sel1Spin->buttonApply,SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
276 connect( Group1Sel1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
277 connect( Group1Sel1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
278 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
279 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
280 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
281 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
282 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
283 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
284 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
285 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
286 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
287 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
288 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
289 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
291 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
292 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
293 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
294 connect( GroupPt2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Point2Clicked( int ) ) );
295 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
296 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
298 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
299 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
301 connect( Group2Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
302 connect( Group2Sel->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
303 connect( Group2Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
304 connect( Group2Sel->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
306 connect( Group1Sel1Spin->LineEdit1,SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
307 connect( Group1Sel1Spin->PushButton1,SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
308 connect( Group1Sel1Spin->SpinBox_DX,SIGNAL( valueChanged( double ) ),this, SLOT( ValueChangedInSpinBox( double ) ) );
310 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
311 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
312 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
313 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
314 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
315 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
316 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
317 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
318 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
319 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
321 connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
322 connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
323 connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
324 connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
326 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ActivateLocalCS() ) );
327 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
328 connect( selButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
330 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
332 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
333 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
335 // install event filter on spin-boxes to provide Apply action on Return pressed
336 Group1Spin->SpinBox_DX->installEventFilter(this);
337 Group1Sel1Spin->SpinBox_DX->installEventFilter(this);
338 Group2Spin->SpinBox_DX->installEventFilter(this);
339 Group2Spin->SpinBox_DY->installEventFilter(this);
340 Group3Spin->SpinBox_DX->installEventFilter(this);
341 Group3Spin->SpinBox_DY->installEventFilter(this);
342 Group3Spin->SpinBox_DZ->installEventFilter(this);
343 Group4Spin->SpinBox_DX->installEventFilter(this);
344 Group4Spin->SpinBox_DY->installEventFilter(this);
345 Group4Spin->SpinBox_DZ->installEventFilter(this);
346 Group4Spin->SpinBox_DS->installEventFilter(this);
352 //=================================================================================
353 // function : ~EntityGUI_SketcherDlg()
354 // purpose : Destroys the object and frees any allocated resources
355 //=================================================================================
356 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
358 myGeometryGUI->SetActiveDialogBox( 0 );
362 //=================================================================================
363 // function : eventFilter()
364 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
365 //=================================================================================
366 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
368 if (event->type() == QEvent::KeyPress) {
369 QKeyEvent* ke = (QKeyEvent*)event;
370 if ( ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter ) {
371 if (object == Group1Spin->SpinBox_DX) {
372 Group1Spin->buttonApply->click();
374 } else if (object == Group1Sel1Spin->SpinBox_DX) {
375 Group1Sel1Spin->buttonApply->click();
377 } else if (object == Group2Spin->SpinBox_DX ||
378 object == Group2Spin->SpinBox_DY) {
379 Group2Spin->buttonApply->click();
381 } else if (object == Group3Spin->SpinBox_DX ||
382 object == Group3Spin->SpinBox_DY ||
383 object == Group3Spin->SpinBox_DZ) {
384 Group3Spin->buttonApply->click();
386 } else if (object == Group4Spin->SpinBox_DX ||
387 object == Group4Spin->SpinBox_DY ||
388 object == Group4Spin->SpinBox_DZ ||
389 object == Group4Spin->SpinBox_DS) {
390 Group4Spin->buttonApply->click();
396 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
398 return QDialog::eventFilter(object, event);
402 //=================================================================================
405 //=================================================================================
406 void EntityGUI_SketcherDlg::Init()
411 myEditCurrentArgument = WPlaneLineEdit; // Initiate the parameters selection with the first WPlaneLineEdit
413 myCommand.append( "Sketcher" );
414 myUndoCommand.append( "Sketcher" );
416 mySketchState = FIRST_POINT;
417 globalSelection( GEOM_FACE );
426 myHelpFileName = "create_sketcher_page.html";
428 GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
429 myGlobalCS = aBasicOp->MakeMarker( 0,0,0,
432 myWPlane = myGlobalCS;
433 myLCSList.push_back( WPlaneToLCS(myGlobalCS) );
435 /* Get setting of step value from file configuration */
436 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
438 /* min, max, step and decimals for spin boxes */
439 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
440 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
441 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
442 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
443 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
444 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
445 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
446 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
447 // san: Note specific step values below!
448 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
449 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
450 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
452 /* displays Dialog */
453 MainWidget->GroupConstructors->setEnabled( false );
454 MainWidget->GroupDest1->setEnabled( false );
455 setEnabledUndo( false );
456 setEnabledRedo( false );
458 MainWidget->RadioButton1->setChecked( true );
462 // If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox
463 // that should be filled with the possibly selected face
464 SelectionIntoArgument();
468 setPrefix(tr("GEOM_SKETCH"));
471 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
475 //=================================================================================
476 // function : InitClick()
478 //=================================================================================
479 void EntityGUI_SketcherDlg::InitClick()
481 MESSAGE("EntityGUI_SketcherDlg::InitClick()")
482 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
487 Group1Sel1Spin->hide();
492 globalSelection(); // close local selection to clear it
493 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
497 //=================================================================================
498 // function : TypeClicked()
499 // purpose : Radio button management
500 //=================================================================================
501 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
503 myConstructorId = constructorId;
504 if ( myConstructorId == 0 ) { // SEGMENT
505 GroupPt2->RB_Point1->setChecked( true );
506 GroupPt2->setEnabled( false );
507 GroupD2->setEnabled( true );
508 MainWidget->RB_Dest1->setEnabled( true );
509 MainWidget->RB_Dest1->setChecked( true );
512 else if ( myConstructorId == 1 ) { // ARC
513 GroupPt2->setEnabled( true );
514 GroupD2->RB_Dir21->setChecked( true );
515 GroupD2->setEnabled( false );
516 MainWidget->RB_Dest1->setEnabled( true );
517 MainWidget->RB_Dest1->setChecked( true );
523 //=================================================================================
524 // function : DestClicked()
525 // purpose : Radio button management
526 //=================================================================================
527 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
534 if ( constructorId == 1 ) {
536 GroupPt->RB_Point1->setChecked( true );
539 Group3Spin->checkBox->show();
540 Group4Spin->checkBox->show();
541 PointClicked( 1 ); // XY
543 else if ( constructorId == 0 ) {
545 GroupD1->RB_Dir11->setChecked( true );
548 Group3Spin->checkBox->hide();
549 Group4Spin->checkBox->hide();
550 Dir1Clicked( 2 ); // Angle
552 resize( minimumSizeHint() );
555 //=================================================================================
556 // function : PointClicked()
557 // purpose : Radio button management
558 //=================================================================================
559 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
561 MESSAGE("PointClicked")
562 myConstructorPntId = constructorId;
563 GroupPt->RB_Point3->setEnabled( true );
564 int buttonId = GroupPt2->ButtonGroup->checkedId();
565 MESSAGE("checkedId ="<< buttonId)
566 if (buttonId >= 0){ // = If a button is checked
567 Point2Clicked(buttonId);
570 GroupPt2->RB_Point1->setChecked( true );
575 //=================================================================================
576 // function : Point2Clicked()
577 // purpose : Radio button management
578 //=================================================================================
579 void EntityGUI_SketcherDlg::Point2Clicked( int constructorId )
581 MESSAGE("Point2Clicked")
584 // Get setting of step value from file configuration
585 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
587 if ( myConstructorPntId == 1 ) { // XY
588 if ( constructorId == 1 ){ // No additional parameter
589 mySketchType = PT_ABS;
590 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
591 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
592 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
593 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
595 Group2Spin->SpinBox_DX->setValue( myX );
597 Group2Spin->SpinBox_DY->setValue( myY );
599 Group2Spin->buttonApply->setFocus();
601 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
603 else if ( constructorId == 0 ){ // Point + radius
604 mySketchType = PT_ABS_RADIUS;
605 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
606 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
607 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
608 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
609 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
610 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
612 Group3Spin->SpinBox_DX->setValue( myX );
614 Group3Spin->SpinBox_DY->setValue( myY );
616 Group3Spin->SpinBox_DZ->setValue( myRadius );
618 Group3Spin->buttonApply->setFocus();
620 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
622 else if ( constructorId == 2 ){ // Point + center
623 mySketchType = PT_ABS_CENTER;
624 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
625 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
626 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
627 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
628 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X2" ) );
629 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_Y2" ) );
630 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_X" ) );
631 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_Y" ) );
633 Group4Spin->SpinBox_DX->setValue( myXc );
635 Group4Spin->SpinBox_DY->setValue( myYc );
637 Group4Spin->SpinBox_DZ->setValue( myX );
639 Group4Spin->SpinBox_DS->setValue( myY );
641 Group4Spin->buttonApply->setFocus();
643 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
647 else if ( myConstructorPntId == 0 ) { // DXDY
648 if ( constructorId == 1 ){ // No additional parameter
649 mySketchType = PT_RELATIVE;
650 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
651 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
652 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
653 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
655 Group2Spin->SpinBox_DX->setValue( myDX );
657 Group2Spin->SpinBox_DY->setValue( myDY );
659 Group2Spin->buttonApply->setFocus();
661 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
663 else if ( constructorId == 0 ){ // Point + radius
664 mySketchType = PT_REL_RADIUS;
665 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
666 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
667 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
668 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
669 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
670 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
672 Group3Spin->SpinBox_DX->setValue( myDX );
674 Group3Spin->SpinBox_DY->setValue( myDY );
676 Group3Spin->SpinBox_DZ->setValue( myRadius );
678 Group3Spin->buttonApply->setFocus();
680 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
682 else if ( constructorId == 2 ){ // Point + center
683 mySketchType = PT_REL_CENTER;
684 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
685 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
686 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
687 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, step, "length_precision" );
688 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DX2" ) );
689 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_DY2" ) );
690 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER_DX" ) );
691 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_CENTER_DY" ) );
693 Group4Spin->SpinBox_DX->setValue( myDXc );
695 Group4Spin->SpinBox_DY->setValue( myDYc );
697 Group4Spin->SpinBox_DZ->setValue( myDX );
699 Group4Spin->SpinBox_DS->setValue( myDY );
701 Group4Spin->buttonApply->setFocus();
703 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
707 else if ( myConstructorPntId == 2 ) { // Selection
708 if ( constructorId == 1 ){ // No additional parameter
709 mySketchType = PT_SEL;
710 myEditCurrentArgument = Group1Sel->LineEdit1;
711 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
713 Group1Sel->buttonApply->setFocus();
714 SelectionIntoArgument();
716 else if ( constructorId == 0 ){ // Point + radius
717 mySketchType = PT_SEL_RADIUS;
718 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
719 initSpinBox( Group1Sel1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step/10.0, "length_precision" );
720 Group1Sel1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
721 Group1Sel1Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
723 Group1Sel1Spin->SpinBox_DX->setValue( myRadius );
725 Group1Sel1Spin->show();
726 Group1Sel1Spin->buttonApply->setFocus();
727 SelectionIntoArgument();
729 else if ( constructorId == 2 ){ // Point + center
730 mySketchType = PT_SEL_CENTER;
731 myEditCurrentArgument = Group2Sel->LineEdit1;
732 Group2Sel->TextLabel2->setText( tr( "GEOM_SKETCHER_END_POINT2" ) );
733 Group2Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_CENTER2" ) );
734 Group2Sel->LineEdit1->setEnabled(true);
735 Group2Sel->PushButton1->setDown(true);
736 Group2Sel->LineEdit2->setEnabled(false);
737 Group2Sel->PushButton2->setDown(false);
739 Group2Sel->buttonApply->setFocus();
740 SelectionIntoArgument();
744 resize( minimumSizeHint() );
745 connect( myGeometryGUI->getApp()->selectionMgr(),
746 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
751 //=================================================================================
752 // function : Dir1Clicked()
753 // purpose : Radio button management
754 //=================================================================================
755 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
757 myConstructorDirId = constructorId;
758 int dirButtonId = GroupD2->ButtonGroup->checkedId();
759 MESSAGE("checkedId ="<< dirButtonId)
760 if (dirButtonId >= 0){ // = If a button is checked
761 Dir2Clicked(dirButtonId);
764 GroupD2->RB_Dir21->setChecked( true );
770 //=================================================================================
771 // function : Dir2Clicked()
772 // purpose : Radio button management
773 //=================================================================================
774 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
779 // Get setting of step value from file configuration
780 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
782 if ( myConstructorId == 0 ) { // SEGMENT
786 if ( myConstructorDirId == 2 ) { // Angle
787 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
788 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
789 Group2Spin->SpinBox_DX->setValue( myAngle );
790 Group2Spin->buttonApply->setFocus();
793 if ( constructorId == 2 ) { // Length
794 mySketchType = DIR_ANGLE_LENGTH;
795 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
796 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
797 Group2Spin->SpinBox_DY->setValue( myLength );
799 else if ( constructorId == 0 ) { // X
800 mySketchType = DIR_ANGLE_X;
801 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
802 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
803 Group2Spin->SpinBox_DY->setValue( myX );
805 else if ( constructorId == 1 ) { // Y
806 mySketchType = DIR_ANGLE_Y;
807 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
808 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
809 Group2Spin->SpinBox_DY->setValue( myY );
812 else if ( myConstructorDirId == 0 ) { // Perpendicular
814 Group1Spin->buttonApply->setFocus();
816 if ( constructorId == 2 ) { // Length
817 mySketchType = DIR_PER_LENGTH;
818 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
819 Group1Spin->SpinBox_DX->setValue( myLength );
821 else if ( constructorId == 0 ) { // X
822 mySketchType = DIR_PER_X;
823 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
824 Group1Spin->SpinBox_DX->setValue( myX );
826 else if ( constructorId == 1 ) { // Y
827 mySketchType = DIR_PER_Y;
828 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
829 Group1Spin->SpinBox_DX->setValue( myY );
832 else if ( myConstructorDirId == 1 ) { // Tangent
834 Group1Spin->buttonApply->setFocus();
836 if ( constructorId == 2 ) { // Length
837 mySketchType = DIR_TAN_LENGTH;
838 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
839 Group1Spin->SpinBox_DX->setValue( myLength );
841 else if ( constructorId == 0 ) { // X
842 mySketchType = DIR_TAN_X;
843 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
844 Group1Spin->SpinBox_DX->setValue( myX );
846 else if ( constructorId == 1 ) { // Y
847 mySketchType = DIR_TAN_Y;
848 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
849 Group1Spin->SpinBox_DX->setValue( myY );
852 else if ( myConstructorDirId == 3 ) { // DXDY
853 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
854 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
855 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
856 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
857 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
859 Group3Spin->SpinBox_DX->setValue( myDX );
861 Group3Spin->SpinBox_DY->setValue( myDY );
863 Group3Spin->buttonApply->setFocus();
865 if ( constructorId == 2 ) { // Length
866 mySketchType = DIR_DXDY_LENGTH;
867 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
868 Group3Spin->SpinBox_DZ->setValue( myLength );
870 else if ( constructorId == 0 ) { // X
871 mySketchType = DIR_DXDY_X;
872 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
873 Group3Spin->SpinBox_DZ->setValue( myX );
875 else if ( constructorId == 1 ) { // Y
876 mySketchType = DIR_DXDY_Y;
877 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
878 Group3Spin->SpinBox_DZ->setValue( myY );
882 else if ( myConstructorId == 1 ) { // ARC
883 if ( myConstructorDirId == 2 ) { // Angle
884 if ( constructorId == 2 ) { // Length
885 mySketchType = DIR_ANGLE_LENGTH;
886 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
887 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
888 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
889 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
890 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
891 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
892 Group3Spin->SpinBox_DX->setValue( myAngle );
894 Group3Spin->SpinBox_DY->setValue( myRadius );
896 Group3Spin->SpinBox_DZ->setValue( myLength );
898 Group3Spin->buttonApply->setFocus();
901 else if ( myConstructorDirId == 0 ) { // Perpendicular
902 if ( constructorId == 2 ) { // Length
903 mySketchType = DIR_PER_LENGTH;
904 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
905 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
906 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
907 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
909 Group2Spin->SpinBox_DX->setValue( myRadius );
911 Group2Spin->SpinBox_DY->setValue( myLength );
913 Group2Spin->buttonApply->setFocus();
916 else if ( myConstructorDirId == 1 ) { // Tangent
917 if ( constructorId == 2 ) { // Length
918 mySketchType = DIR_TAN_LENGTH;
919 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
920 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
921 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
922 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
924 Group2Spin->SpinBox_DX->setValue( myRadius );
926 Group2Spin->SpinBox_DY->setValue( myLength );
928 Group2Spin->buttonApply->setFocus();
931 else if ( myConstructorDirId == 3 ) { // DXDY
932 if ( constructorId == 2 ) { // Length
933 mySketchType = DIR_DXDY_LENGTH;
934 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
935 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
936 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
937 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
938 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
939 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
940 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
941 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
943 Group4Spin->SpinBox_DX->setValue( myDX );
945 Group4Spin->SpinBox_DY->setValue( myDY );
947 Group4Spin->SpinBox_DZ->setValue( myRadius );
949 Group4Spin->SpinBox_DS->setValue( myLength );
951 Group4Spin->buttonApply->setFocus();
955 resize( minimumSizeHint() );
956 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
959 //=================================================================================
960 // function : CheckBoxClicked()
961 // purpose : CheckBox management
962 //=================================================================================
963 void EntityGUI_SketcherDlg::CheckBoxClicked(int State)
967 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
971 //=================================================================================
972 // function : ClickOnCancel()
974 //=================================================================================
975 void EntityGUI_SketcherDlg::ClickOnCancel()
981 //=================================================================================
982 // function : ClickOnEnd()
983 // purpose : connected to buttonEnd AND buttonClose
984 //=================================================================================
985 void EntityGUI_SketcherDlg::ClickOnEnd()
987 if ( sender() == MainWidget->buttonClose ) {
988 // Verify validity of commands
989 if ( myCommand.count() <= 2 ) {
990 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
991 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
996 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
997 Sketcher_Profile aProfile( Command.toAscii() );
999 Command = myCommand.join( "" );
1000 aProfile = Sketcher_Profile( Command.toAscii() );
1001 TopoDS_Shape myShape;
1002 if ( aProfile.IsDone() )
1003 myShape = aProfile.GetShape();
1005 if ( myShape.ShapeType() != TopAbs_VERTEX )
1006 myCommand.append( ":WW" );
1009 /*// PAL16008 (Sketcher Validation should be equal to Apply&Close)
1010 if ( ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ) ||
1011 ( Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ) ||
1012 ( Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ) ||
1013 ( Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ) ||
1014 ( Group1Sel->buttonApply->isEnabled() && Group1Sel->isVisible() ) ||
1015 ( Group2Sel->buttonApply->isEnabled() && Group2Sel->isVisible() ) ||
1016 ( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
1019 myIsAllAdded = true;
1022 if ( myCommand.size() > 2 )
1029 //=================================================================================
1030 // function : ClickOnApply()
1032 //=================================================================================
1033 bool EntityGUI_SketcherDlg::ClickOnApply()
1035 if ( sender() && sender()->inherits( "QPushButton" ) )
1036 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
1038 // addSubshapesToStudy();
1040 QString aParameters;
1041 myCommand.append( GetNewCommand( aParameters ) );
1042 mySketchState = NEXT_POINT;
1044 myUndoCommand.clear();
1045 myUndoCommand.append( "Sketcher" );
1047 myParameters.append( aParameters );
1048 myUndoParameters.clear();
1050 MainWidget->GroupConstructors->setEnabled( true );
1051 MainWidget->GroupDest1->setEnabled( true );
1052 setEnabledUndo( true );
1053 setEnabledRedo( false );
1056 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1059 // Set focus to SpinBox_DX
1060 if ( sender() == Group1Spin->buttonApply ) {
1061 (Group1Spin->SpinBox_DX)->setFocus();
1062 (Group1Spin->SpinBox_DX)->selectAll();
1064 else if ( sender() == Group1Sel1Spin->buttonApply ) {
1065 (Group1Sel1Spin->SpinBox_DX)->setFocus();
1066 (Group1Sel1Spin->SpinBox_DX)->selectAll();
1068 else if ( sender() == Group2Spin->buttonApply ) {
1069 (Group2Spin->SpinBox_DX)->setFocus();
1070 (Group2Spin->SpinBox_DX)->selectAll();
1072 else if ( sender() == Group3Spin->buttonApply ) {
1073 (Group3Spin->SpinBox_DX)->setFocus();
1074 (Group3Spin->SpinBox_DX)->selectAll();
1076 else if ( sender() == Group4Spin->buttonApply ) {
1077 (Group4Spin->SpinBox_DX)->setFocus();
1078 (Group4Spin->SpinBox_DX)->selectAll();
1084 //=================================================================================
1085 // function : ClickOnHelp()
1087 //=================================================================================
1088 void EntityGUI_SketcherDlg::ClickOnHelp()
1090 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
1092 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
1096 platform = "winapplication";
1098 platform = "application";
1101 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
1102 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1103 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
1104 QObject::tr( "BUT_OK" ) );
1108 //=================================================================================
1109 // function : ClickOnUndo()
1111 //=================================================================================
1112 void EntityGUI_SketcherDlg::ClickOnUndo()
1114 myUndoCommand.append( myCommand.last() );
1115 myCommand.pop_back();
1117 myUndoParameters.append( myParameters.last() );
1118 myParameters.pop_back();
1120 if ( myCommand.count() == 1 ) {
1121 mySketchState = FIRST_POINT;
1123 MainWidget->RadioButton1->setChecked( true );
1126 connect( myGeometryGUI->getApp()->selectionMgr(),
1127 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1129 MainWidget->GroupConstructors->setEnabled( false );
1130 MainWidget->GroupDest1->setEnabled( false );
1131 setEnabledUndo( false );
1134 setEnabledRedo( true );
1136 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1139 //=================================================================================
1140 // function : ClickOnRedo()
1142 //=================================================================================
1143 void EntityGUI_SketcherDlg::ClickOnRedo()
1145 myCommand.append( myUndoCommand.last() );
1146 myUndoCommand.pop_back();
1148 myParameters.append( myUndoParameters.last() );
1149 myUndoParameters.pop_back();
1151 mySketchState = NEXT_POINT;
1153 MainWidget->GroupConstructors->setEnabled( true );
1154 MainWidget->GroupDest1->setEnabled( true );
1155 setEnabledUndo( true );
1157 if ( myUndoCommand.count() == 1 )
1158 setEnabledRedo( false );
1160 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1163 //=================================================================================
1164 // function : setEnabledUndo()
1166 //=================================================================================
1167 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
1169 Group1Sel->buttonUndo->setEnabled( value );
1170 Group2Sel->buttonUndo->setEnabled( value );
1171 Group1Sel1Spin->buttonUndo->setEnabled( value );
1172 Group1Spin->buttonUndo->setEnabled( value );
1173 Group2Spin->buttonUndo->setEnabled( value );
1174 Group3Spin->buttonUndo->setEnabled( value );
1175 Group4Spin->buttonUndo->setEnabled( value );
1178 //=================================================================================
1179 // function : setEnabledRedo()
1181 //=================================================================================
1182 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
1184 Group1Sel->buttonRedo->setEnabled( value );
1185 Group2Sel->buttonRedo->setEnabled( value );
1186 Group1Sel1Spin->buttonRedo->setEnabled( value );
1187 Group1Spin->buttonRedo->setEnabled( value );
1188 Group2Spin->buttonRedo->setEnabled( value );
1189 Group3Spin->buttonRedo->setEnabled( value );
1190 Group4Spin->buttonRedo->setEnabled( value );
1193 //=================================================================================
1194 // function : SelectionIntoArgument()
1195 // purpose : Called when selection as changed
1196 //=================================================================================
1197 void EntityGUI_SketcherDlg::SelectionIntoArgument()
1199 MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
1200 myEditCurrentArgument->setText( "" );
1202 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1203 SALOME_ListIO aSelList;
1204 aSelMgr->selectedObjects(aSelList);
1206 this->activateWindow();
1208 if (aSelList.Extent() == 0)
1210 selButton->setDown(false);
1211 WPlaneLineEdit->setEnabled(false);
1212 WPlaneLineEdit->setText(tr("GEOM_SKETCHER_WPLANE"));
1215 else if (aSelList.Extent() != 1)
1223 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
1224 if (myEditCurrentArgument == WPlaneLineEdit)
1225 aNeedType = TopAbs_FACE;
1228 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
1229 TopoDS_Shape aShape;
1231 if(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape)
1232 && !aShape.IsNull())
1234 QString aName = GEOMBase::GetName( aSelectedObject.get() );
1235 myEditCurrentArgument->setText(aName);
1236 if (myEditCurrentArgument==WPlaneLineEdit)
1238 AddLocalCS(aSelectedObject.get());
1239 selButton->setDown(false);
1240 WPlaneLineEdit->setEnabled(false);
1246 gp_Ax3 aWPlane = GetActiveLocalCS();
1248 aTrans.SetTransformation(aWPlane);
1249 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1250 aShape = aTransformation.Shape();
1253 if ( GEOMBase::VertexToPoint( aShape, aPnt ) )
1257 double Xcoord = myX;
1258 double Ycoord = myY;
1260 switch (mySketchType)
1263 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1264 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1266 Group2Spin->SpinBox_DX->setValue(Xcoord);
1267 Group2Spin->SpinBox_DY->setValue(Ycoord);
1269 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1270 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1274 if (myLastX1 && myLastY1)
1276 Xcoord = myX - myLastX1;
1277 Ycoord = myY - myLastY1;
1279 else if (mySketchState != FIRST_POINT)
1281 Xcoord = myX - tmpX;
1282 Ycoord = myY - tmpY;
1284 Group2Spin->SpinBox_DX->setValue(Xcoord);
1285 Group2Spin->SpinBox_DY->setValue(Ycoord);
1289 disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1290 disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1292 Group3Spin->SpinBox_DX->setValue(Xcoord);
1293 Group3Spin->SpinBox_DY->setValue(Ycoord);
1295 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1296 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1300 if (myLastX1 && myLastY1)
1302 Xcoord = myX - myLastX1;
1303 Ycoord = myY - myLastY1;
1305 else if (mySketchState != FIRST_POINT)
1307 Xcoord = myX - tmpX;
1308 Ycoord = myY - tmpY;
1310 Group3Spin->SpinBox_DX->setValue(Xcoord);
1311 Group3Spin->SpinBox_DY->setValue(Ycoord);
1315 disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1316 disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1318 Group4Spin->SpinBox_DX->setValue(Xcoord);
1319 Group4Spin->SpinBox_DY->setValue(Ycoord);
1321 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1322 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
1326 if (myLastX1 && myLastY1)
1328 Xcoord = myXc - myLastX1;
1329 Ycoord = myYc - myLastY1;
1331 else if (mySketchState != FIRST_POINT)
1333 Xcoord = myXc - tmpX;
1334 Ycoord = myYc - tmpY;
1342 Group4Spin->SpinBox_DX->setValue(Xcoord);
1343 Group4Spin->SpinBox_DY->setValue(Ycoord);
1352 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1362 //=================================================================================
1363 // function : SetEditCurrentArgument()
1365 //=================================================================================
1366 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
1368 TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX;
1369 if ( sender() == Group1Sel->PushButton1 ) {
1370 myEditCurrentArgument = Group1Sel->LineEdit1;
1371 myEditCurrentArgument->setFocus();
1373 else if ( sender() == Group1Sel1Spin->PushButton1 ) {
1374 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1375 myEditCurrentArgument->setFocus();
1377 else if ( sender() == Group2Sel->PushButton1 ) {
1378 myEditCurrentArgument = Group2Sel->LineEdit1;
1379 Group2Sel->PushButton2->setDown(false);
1380 Group2Sel->PushButton1->setDown(true);
1381 Group2Sel->LineEdit2->setEnabled(false);
1382 Group2Sel->LineEdit1->setEnabled(true);
1383 // myEditCurrentArgument->setFocus();
1385 else if ( sender() == Group2Sel->PushButton2 ) {
1386 myEditCurrentArgument = Group2Sel->LineEdit2;
1387 Group2Sel->PushButton1->setDown(false);
1388 Group2Sel->PushButton2->setDown(true);
1389 Group2Sel->LineEdit1->setEnabled(false);
1390 Group2Sel->LineEdit2->setEnabled(true);
1391 // myEditCurrentArgument->setFocus();
1393 else if ( sender() == selButton ) {
1394 myNeedType = TopAbs_FACE;
1395 myEditCurrentArgument = WPlaneLineEdit;
1396 WPlaneLineEdit->setEnabled(true);
1397 selButton->setDown(true);
1399 globalSelection(); // close local selection to clear it
1400 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
1404 //=================================================================================
1405 // function : LineEditReturnPressed()
1407 //=================================================================================
1408 void EntityGUI_SketcherDlg::LineEditReturnPressed()
1410 if ( sender() == Group1Sel->LineEdit1 )
1411 myEditCurrentArgument = Group1Sel->LineEdit1;
1412 else if ( sender() == Group1Sel1Spin->LineEdit1 )
1413 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1414 else if ( sender() == Group2Sel->LineEdit1 )
1415 myEditCurrentArgument = Group2Sel->LineEdit1;
1416 else if ( sender() == Group2Sel->LineEdit2 )
1417 myEditCurrentArgument = Group2Sel->LineEdit2;
1419 /* User name of object input management */
1420 /* If successfull the selection is changed and signal emitted... */
1421 /* so SelectionIntoArgument() is automatically called. */
1422 const QString objectUserName = myEditCurrentArgument->text();
1423 QWidget* thisWidget = (QWidget*)this;
1425 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
1426 SALOME_ListIO aSelList;
1427 aSelMgr->selectedObjects(aSelList);
1429 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1430 myEditCurrentArgument->setText( objectUserName );
1434 //=================================================================================
1435 // function : DeactivateActiveDialog()
1437 //=================================================================================
1438 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1440 //myGeometryGUI->SetState( -1 );
1442 setEnabled( false );
1444 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1445 myGeometryGUI->SetActiveDialogBox( 0 );
1449 //=================================================================================
1450 // function : ActivateThisDialog()
1452 //=================================================================================
1453 void EntityGUI_SketcherDlg::ActivateThisDialog()
1455 MESSAGE("EntityGUI_SketcherDlg::ActivateThisDialog()")
1456 myGeometryGUI->EmitSignalDeactivateDialog();
1458 myGeometryGUI->SetActiveDialogBox( this );
1460 connect( myGeometryGUI->getApp()->selectionMgr(),
1461 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1463 //myGeometryGUI->SetState( 0 );
1464 // globalSelection( GEOM_POINT );
1466 myEditCurrentArgument = WPlaneLineEdit;
1467 myEditCurrentArgument->setFocus();
1469 if ( sender() == Group1Sel->LineEdit1 ) {
1470 myEditCurrentArgument = Group1Sel->LineEdit1;
1471 myEditCurrentArgument->setFocus();
1473 else if ( sender() == Group1Sel1Spin->LineEdit1 ) {
1474 myEditCurrentArgument = Group1Sel1Spin->LineEdit1;
1475 myEditCurrentArgument->setFocus();
1477 else if ( sender() == Group2Sel->LineEdit1 ) {
1478 myEditCurrentArgument = Group2Sel->LineEdit1;
1479 myEditCurrentArgument->setFocus();
1481 else if ( sender() == Group2Sel->LineEdit2 ) {
1482 myEditCurrentArgument = Group2Sel->LineEdit2;
1483 myEditCurrentArgument->setFocus();
1486 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1490 //=================================================================================
1491 // function : enterEvent [REDEFINED]
1493 //=================================================================================
1494 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1497 ActivateThisDialog();
1501 //=================================================================================
1502 // function : closeEvent()
1504 //=================================================================================
1505 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1507 MESSAGE("EntityGUI_SketcherDlg::closeEvent")
1508 //myGeometryGUI->SetState( -1 );
1509 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1510 myGeometryGUI->getApp()->updateActions();
1511 QDialog::closeEvent( e );
1514 //=================================================================================
1515 // function : OnPointSelected
1517 //=================================================================================
1518 void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt)
1520 MESSAGE("EntityGUI_SketcherDlg::OnPointSelected")
1522 SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
1523 OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
1524 QString theImgFileName;
1525 vp->background().texture( theImgFileName ); ////////////// VSR: temporarily
1530 BRepBuilderAPI_MakeVertex mkVertex (thePnt);
1531 TopoDS_Shape aShape = mkVertex.Shape();
1533 // Taking into account LocalCS
1534 gp_Ax3 aWPlane = GetActiveLocalCS();
1537 aTrans.SetTransformation(aWPlane);
1538 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
1539 aShape = aTransformation.Shape();
1542 GEOMBase::VertexToPoint( aShape, aTrsfPnt );
1544 autoApply = ( (getPnt2ConstructorId() == 1) && (!theImgFileName.isEmpty()) ); // If no additional argument needed after selection and there is a backgroundimage
1545 // -> apply automatically
1547 if ( getPnt1ConstructorId() == 0 ){ // Relative selection mode
1548 x = aTrsfPnt.X() - myLastX1;
1549 y = aTrsfPnt.Y() - myLastY1;
1555 switch (getPnt2ConstructorId()){
1557 Group2Spin->SpinBox_DX->setValue( x );
1558 Group2Spin->SpinBox_DY->setValue( y );
1559 Group2Spin->buttonApply->setFocus(); // Previous setFocus (during preview) may have been inoperative if it was disabled
1562 Group3Spin->SpinBox_DX->setValue( x );
1563 Group3Spin->SpinBox_DY->setValue( y );
1564 Group3Spin->buttonApply->setFocus();
1567 if (modifiers == Qt::MetaModifier){ // Select center with Meta key
1568 Group4Spin->SpinBox_DX->setValue( x );
1569 Group4Spin->SpinBox_DY->setValue( y );
1571 else{ // Select end point
1572 Group4Spin->SpinBox_DZ->setValue( x );
1573 Group4Spin->SpinBox_DS->setValue( y );
1575 Group4Spin->buttonApply->setFocus();
1580 //=================================================================================
1581 // function : ValueChangedInSpinBox()
1583 //=================================================================================
1584 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1586 MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
1587 QObject* send = (QObject*)sender();
1588 Standard_Real vx, vy, vz, vs, minRad, dx, dy;
1589 vx = vy = vz = vs = minRad = dx = dy = 0.0;
1591 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1592 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1593 double LastDecimal = 0.0;
1595 QString vxStr, vyStr, vzStr, vsStr;
1597 QString newValueStr;
1598 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1599 newValueStr = aDoubleSpinBox->text();
1601 if ( send == Group1Spin->SpinBox_DX ) {
1602 vx = newValue; vxStr = newValueStr;
1604 else if ( send == Group1Sel1Spin->SpinBox_DX ) {
1605 vx = newValue; vxStr = newValueStr;
1607 else if ( send == Group2Spin->SpinBox_DX ) {
1608 vx = newValue; vxStr = newValueStr;
1609 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1611 else if ( send == Group2Spin->SpinBox_DY ) {
1612 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1613 vy = newValue; vyStr = newValueStr;
1615 else if ( send == Group3Spin->SpinBox_DX ) {
1616 vx = newValue; vxStr = newValueStr;
1617 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1618 vz = Group3Spin->SpinBox_DZ->value();
1619 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
1620 if (mySketchType == PT_ABS_RADIUS){
1628 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1629 if (aPrecision >= 0) // 'f' format in the QString
1630 LastDecimal = aPrecision;
1631 else // 'g' format in the Qstring
1632 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1633 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1634 if ( Abs(vz) < minRad){
1636 Group3Spin->SpinBox_DZ->setValue( - minRad );
1638 Group3Spin->SpinBox_DZ->setValue( minRad );
1641 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1643 else if ( send == Group3Spin->SpinBox_DY ) {
1644 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1645 vy = newValue; vyStr = newValueStr;
1646 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1647 if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
1648 if (mySketchType == PT_ABS_RADIUS){
1656 minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
1657 if (aPrecision >= 0) // 'f' format in the QString
1658 LastDecimal = aPrecision;
1659 else // 'g' format in the QString
1660 LastDecimal = qAbs( aPrecision ) - ceil( log10(minRad) );
1661 minRad = ceil(pow(10,LastDecimal) * minRad) / pow(10,LastDecimal); // Rounded up at the last allowed decimal place
1662 if ( Abs(vz) < minRad){
1664 Group3Spin->SpinBox_DZ->setValue( - minRad );
1666 Group3Spin->SpinBox_DZ->setValue( minRad );
1669 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1671 else if ( send == Group3Spin->SpinBox_DZ ) {
1672 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1673 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1674 vz = newValue; vzStr = newValueStr;
1676 else if ( send == Group4Spin->SpinBox_DX ) {
1677 vx = newValue; vxStr = newValueStr;
1678 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1679 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1680 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1682 else if ( send == Group4Spin->SpinBox_DY ) {
1683 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1684 vy = newValue; vyStr = newValueStr;
1685 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1686 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1688 else if ( send == Group4Spin->SpinBox_DZ ) {
1689 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1690 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1691 vz = newValue; vzStr = newValueStr;
1692 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1694 else if ( send == Group4Spin->SpinBox_DS ) {
1695 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1696 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1697 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1698 vs = newValue; vsStr = newValueStr;
1700 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1702 if ( myConstructorId == 0 ) { // SEGMENT
1703 if ( mySketchType == PT_ABS ) {
1709 else if ( mySketchType == PT_RELATIVE ) {
1715 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1719 myLengthStr = vyStr;
1721 else if ( mySketchType == DIR_ANGLE_X ) {
1727 else if ( mySketchType == DIR_ANGLE_Y ) {
1733 else if ( mySketchType == DIR_PER_LENGTH ) {
1735 myLengthStr = vxStr;
1737 else if ( mySketchType == DIR_PER_X ) {
1741 else if ( mySketchType == DIR_PER_Y ) {
1745 else if ( mySketchType == DIR_TAN_LENGTH ) {
1747 myLengthStr = vxStr;
1749 else if ( mySketchType == DIR_TAN_X ) {
1753 else if ( mySketchType == DIR_TAN_Y ) {
1757 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1763 myLengthStr = vzStr;
1765 else if ( mySketchType == DIR_DXDY_X ) {
1773 else if ( mySketchType == DIR_DXDY_Y ) {
1782 else if ( myConstructorId == 1 ) { // ARC
1783 if ( mySketchType == PT_ABS ) {
1789 else if ( mySketchType == PT_RELATIVE ) {
1795 if ( mySketchType == PT_ABS_RADIUS ) {
1801 myRadiusStr = vzStr;
1803 else if ( mySketchType == PT_REL_RADIUS ) {
1809 myRadiusStr = vzStr;
1811 else if ( mySketchType == PT_SEL_RADIUS ) {
1813 myRadiusStr = vxStr;
1815 if ( mySketchType == PT_ABS_CENTER ) {
1825 else if ( mySketchType == PT_REL_CENTER ) {
1835 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1840 myRadiusStr = vyStr;
1841 myLengthStr = vzStr;
1843 else if ( mySketchType == DIR_PER_LENGTH ) {
1846 myRadiusStr = vxStr;
1847 myLengthStr = vyStr;
1849 else if ( mySketchType == DIR_TAN_LENGTH ) {
1852 myRadiusStr = vxStr;
1853 myLengthStr = vyStr;
1855 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1862 myRadiusStr = vzStr;
1863 myLengthStr = vsStr;
1868 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
1870 double x, y, xc, yc;
1871 x = y = xc = yc = 0.0;
1872 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER )
1874 if ( mySketchType == PT_REL_CENTER ){
1875 x = myDX + myLastX1;
1876 y = myDY + myLastY1;
1877 xc = myDXc + myLastX1;
1878 yc = myDYc + myLastY1;
1886 displayPntPreview(xc,yc);
1887 displayPntPreview(x,y);
1892 //=================================================================================
1893 // function : GetNewCommand()
1894 // purpose : Build the new command with context
1895 //=================================================================================
1896 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1898 theParameters.clear();
1899 QString myNewCommand = ":";
1900 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1901 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
1902 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
1904 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
1905 Format = 'g'; // g --> DigNum is the maximum number of significant digits
1907 if ( mySketchState == FIRST_POINT ) {
1908 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1909 myNewCommand = myNewCommand + "F " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1910 theParameters = myXStr + ":" + myYStr;
1912 if ( mySketchType == PT_RELATIVE) {
1913 myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1914 theParameters = myDXStr + ":" + myDYStr;
1916 return myNewCommand;
1919 if ( myConstructorId == 0 ) { // SEGMENT
1920 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1921 myNewCommand = myNewCommand + "TT " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1922 theParameters = myXStr + ":" + myYStr;
1924 if ( mySketchType == PT_RELATIVE) {
1925 myNewCommand = myNewCommand + "T " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1926 theParameters = myDXStr + ":" + myDYStr;
1928 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1929 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1930 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1931 theParameters = myAngleStr + ":" + myLengthStr;
1933 if ( mySketchType == DIR_ANGLE_X ) {
1934 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1935 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1936 theParameters = myAngleStr + ":" + myXStr;
1938 if ( mySketchType == DIR_ANGLE_Y ) {
1939 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1940 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1941 theParameters = myAngleStr + ":" + myYStr;
1943 if ( mySketchType == DIR_PER_LENGTH ) {
1944 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1945 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1946 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1948 if ( mySketchType == DIR_PER_X ) {
1949 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1950 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1951 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1953 if ( mySketchType == DIR_PER_Y ) {
1954 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1955 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1956 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1958 if ( mySketchType == DIR_TAN_LENGTH ) {
1959 myNewCommand = myNewCommand + "L " + QString::number( myLength, Format, DigNum );
1960 theParameters = myLengthStr;
1962 if ( mySketchType == DIR_TAN_X ) {
1963 myNewCommand = myNewCommand + "IX " + QString::number( myX, Format, DigNum);
1964 theParameters = myXStr;
1966 if ( mySketchType == DIR_TAN_Y) {
1967 myNewCommand = myNewCommand + "IY " + QString::number(myY, Format, DigNum);
1968 theParameters = myYStr;
1970 if ( mySketchType == DIR_DXDY_LENGTH ) {
1971 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1972 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength, Format, DigNum );
1973 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1975 if ( mySketchType == DIR_DXDY_X ) {
1976 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1977 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX, Format, DigNum);
1978 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1980 if ( mySketchType == DIR_DXDY_Y ) {
1981 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1982 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY, Format, DigNum);
1983 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1986 else if ( myConstructorId == 1 ) { // ARC
1987 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1988 myNewCommand = myNewCommand + "AA " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum);
1989 theParameters = myXStr + ":" + myYStr;
1991 if ( mySketchType == PT_RELATIVE) {
1992 myNewCommand = myNewCommand + "A " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
1993 theParameters = myDXStr + ":" + myDYStr;
1995 if ( mySketchType == PT_ABS_RADIUS || mySketchType == PT_SEL_RADIUS ) {
1996 myNewCommand = myNewCommand + "UU " + QString::number( myX, Format, DigNum) + " " + QString::number( myY, Format, DigNum ) + " " + QString::number( myRadius , Format, DigNum)+ " " + QString::number( myCheckFlag );
1997 theParameters = myXStr + ":" + myYStr + ":" + myRadiusStr;
1999 if ( mySketchType == PT_REL_RADIUS) {
2000 myNewCommand = myNewCommand + "U " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum ) + " " + QString::number( myRadius, Format, DigNum )+ " " + QString::number( myCheckFlag );
2001 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr;
2003 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_SEL_CENTER ) {
2004 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 );
2005 theParameters = myXStr + ":" + myYStr + ":" + myXcStr+ ":" + myYcStr;
2007 if ( mySketchType == PT_REL_CENTER) {
2008 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 );
2009 theParameters = myDXStr + ":" + myDYStr + ":" + myDXcStr + ":" + myDYcStr ;
2011 if ( mySketchType == DIR_ANGLE_LENGTH ) {
2012 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
2013 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2014 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
2016 if ( mySketchType == DIR_PER_LENGTH ) {
2017 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
2018 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2019 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
2021 if ( mySketchType == DIR_TAN_LENGTH ) {
2022 myNewCommand = myNewCommand + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2023 theParameters = myRadiusStr + ":" + myLengthStr;
2025 if ( mySketchType == DIR_DXDY_LENGTH ) {
2026 myNewCommand = myNewCommand + "D " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
2027 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius, Format, DigNum ) + " " + QString::number( myLength, Format, DigNum );
2028 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
2031 return myNewCommand;
2034 //=================================================================================
2035 // function : createOperation
2037 //=================================================================================
2038 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
2040 return getGeomEngine()->GetICurvesOperations( getStudyId() );
2043 //=================================================================================
2044 // function : isValid
2046 //=================================================================================
2047 bool EntityGUI_SketcherDlg::isValid( QString& msg )
2050 bool toCorrect = !IsPreview() || myIsApply;
2052 if( Group1Spin->isVisible() ) {
2053 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2055 else if( Group1Sel1Spin->isVisible() ) {
2056 ok = Group1Sel1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2058 else if( Group2Spin->isVisible() ) {
2059 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2060 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2062 else if( Group3Spin->isVisible() ) {
2063 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2064 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2065 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2067 else if( Group4Spin->isVisible() ) {
2068 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
2069 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
2070 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
2071 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
2074 if( myIsApply && !ok )
2080 //=================================================================================
2081 // function : execute
2083 //=================================================================================
2084 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
2086 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2087 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
2088 int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
2090 if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
2091 Format = 'g'; // g --> DigNum is the maximum number of significant digits
2093 QString aParameters;
2095 if ( mySketchState == FIRST_POINT ) {
2100 //Test if the current point is the same as the last one
2101 TopoDS_Shape myShape1, myShape2;
2103 // Set "C" numeric locale
2104 Kernel_Utils::Localizer loc;
2107 QString Command1 = myCommand.join( "" );
2108 Sketcher_Profile aProfile1( Command1.toAscii() );
2109 if ( aProfile1.IsDone() )
2110 myShape1 = aProfile1.GetShape();
2113 QString Command2 = Command1 + GetNewCommand( aParameters );
2114 Sketcher_Profile aProfile2( Command2.toAscii() );
2117 if ( mySketchType == PT_ABS_CENTER || mySketchType == PT_REL_CENTER ){
2118 if (aProfile2.Error() > Precision::Confusion()){
2119 Group4Spin->label->show();
2120 Group4Spin->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2123 Group4Spin->label->hide();
2127 Group4Spin->label->hide();
2128 if ( mySketchType == PT_SEL_CENTER ){
2129 if (aProfile2.Error() > Precision::Confusion()){
2130 Group2Sel->label->show();
2131 Group2Sel->label->setText( tr("GEOM_SKETCHER_WARNING") + QString::number( aProfile2.Error(), Format, DigNum));
2134 Group2Sel->label->hide();
2138 Group2Sel->label->hide();
2140 if ( aProfile2.IsDone() )
2141 myShape2 = aProfile2.GetShape();
2143 if ( myShape2.IsNull() ) {
2144 //the current point is the same as the last one
2145 myLastX2 = myLastX1;
2146 myLastY2 = myLastY1;
2149 TopoDS_Vertex V1, V2;
2151 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
2152 //the last shape is the first point
2153 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
2158 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
2159 pt = BRep_Tool::Pnt( V2 );
2163 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
2164 pt = BRep_Tool::Pnt( V2 );
2171 if ( ( mySketchState != FIRST_POINT &&
2172 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
2173 cmd = myCommand.join( "" );
2174 if ( Group1Sel->isVisible() ) {
2175 Group1Sel->buttonApply->setEnabled( false );
2176 //Group1Sel->buttonApply->setFocus();
2178 if ( Group2Sel->isVisible() ) {
2179 Group2Sel->buttonApply->setEnabled( false );
2180 //Group2Sel->buttonApply->setFocus();
2182 if ( Group1Sel1Spin->isVisible() ) {
2183 Group1Sel1Spin->buttonApply->setEnabled( false );
2184 //Group1Sel1Spin->buttonApply->setFocus();
2186 if ( Group1Spin->isVisible() ) {
2187 Group1Spin->buttonApply->setEnabled( false );
2188 //Group1Spin->buttonApply->setFocus();
2190 if ( Group2Spin->isVisible() ) {
2191 Group2Spin->buttonApply->setEnabled( false );
2192 //Group2Spin->buttonApply->setFocus();
2194 if ( Group3Spin->isVisible() ) {
2195 Group3Spin->buttonApply->setEnabled( false );
2196 //Group3Spin->buttonApply->setFocus();
2198 if ( Group4Spin->isVisible() ) {
2199 Group4Spin->buttonApply->setEnabled( false );
2200 //Group4Spin->buttonApply->setFocus();
2204 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
2206 if ( Group1Sel->isVisible() ) {
2207 Group1Sel->buttonApply->setEnabled( true );
2209 if ( Group2Sel->isVisible() ) {
2210 Group2Sel->buttonApply->setEnabled( true );
2212 if ( Group1Sel1Spin->isVisible() ) {
2213 Group1Sel1Spin->buttonApply->setEnabled( true );;
2215 if ( Group1Spin->isVisible() ) {
2216 Group1Spin->buttonApply->setEnabled( true );
2218 if ( Group2Spin->isVisible() ) {
2219 Group2Spin->buttonApply->setEnabled( true );
2221 if ( Group3Spin->isVisible() ) {
2222 Group3Spin->buttonApply->setEnabled( true );
2224 if ( Group4Spin->isVisible() ) {
2225 Group4Spin->buttonApply->setEnabled( true );
2229 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
2230 GEOM::GEOM_Object_var anObj = NULL;
2232 int index = ComboBox1->currentIndex();
2233 if(index != -1 && !myWPlane->_is_nil()) // The combobox is not empty
2235 anObj = anOper->MakeSketcherOnPlane( cmd.toLatin1().constData(), myWPlane );
2237 if ( !anObj->_is_nil() )
2239 if( !IsPreview() ) {
2240 QStringList aCurrentParameters = myParameters;
2241 aCurrentParameters << aParameters;
2242 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
2245 objects.push_back( anObj._retn() );
2251 //================================================================
2252 // Function : displayPreview
2253 // Purpose : Method for displaying preview of resulting shape
2254 // Redefined from GEOMBase_Helper.
2255 //================================================================
2256 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
2258 const bool activate,
2260 const double lineWidth,
2261 const int displayMode,
2264 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2266 QColor aColor = resMgr->colorValue("Geometry","line_color",QColor(255,0,0));
2267 Quantity_NameOfColor line_color = SalomeApp_Tools::color( aColor ).Name();
2269 // set width of displayed shape
2272 lw = resMgr->integerValue("Geometry", "preview_edge_width", -1);
2274 getDisplayer()->SetWidth( lw );
2276 // Disable activation of selection
2277 getDisplayer()->SetToActivate( activate );
2279 // Make a reference to GEOM_Object
2280 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
2281 getDisplayer()->SetName( objStr.in() );
2283 // Create wire from applayed object
2284 TopoDS_Shape anApplyedWire, aLastSegment;
2285 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
2289 getDisplayer()->SetColor( line_color );
2290 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
2291 if ( aPrs != 0 && !aPrs->IsNull() )
2292 GEOMBase_Helper::displayPreview( aPrs, append, update );
2294 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
2295 aPrs = getDisplayer()->BuildPrs( aLastSegment );
2296 if ( aPrs != 0 && !aPrs->IsNull() )
2297 GEOMBase_Helper::displayPreview( aPrs, append, update );
2299 getDisplayer()->SetColor( line_color );
2301 getDisplayer()->UnsetName();
2303 // Enable activation of displayed objects
2304 getDisplayer()->SetToActivate( true );
2307 //================================================================
2308 // Function : displayPntPreview
2309 // Purpose : creates a TopoDS_VERTEX and display a preview of it
2310 //================================================================
2311 void EntityGUI_SketcherDlg::displayPntPreview(const double x,
2317 // Get globalCS and working plane
2318 gp_Ax3 globalCS = WPlaneToLCS( myGlobalCS );
2319 gp_Ax3 aWPlane = GetActiveLocalCS();
2321 // Build point in localCS
2322 gp_Pnt aPnt = gp_Pnt(x,y,0.0);
2324 // Get transfomation from local to global CS
2326 aTrans.SetTransformation(aWPlane, globalCS);
2328 BRepBuilderAPI_MakeVertex mkVertex (aPnt);
2329 TopoDS_Shape aLocalVertex = mkVertex.Shape();
2331 // Perform transformation
2332 BRepBuilderAPI_Transform aTransformation (aLocalVertex, aTrans, Standard_False);
2333 TopoDS_Shape aGlobalVertex = aTransformation.Shape();
2335 // Build prs with vertex in globalCS
2336 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( aGlobalVertex );
2337 if ( aPrs != 0 && !aPrs->IsNull() )
2338 GEOMBase_Helper::displayPreview( aPrs, append, update );
2342 //================================================================
2343 // Function : createShapes
2344 // Purpose : Create applyed wire, and last segment from entry object
2345 //================================================================
2346 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
2347 TopoDS_Shape& theApplyedWire,
2348 TopoDS_Shape& theLastSegment )
2350 TopoDS_Shape aShape;
2351 if ( !GEOMBase::GetShape( theObject, aShape ) ||
2352 ( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) )
2355 if ( ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() )||
2356 ( Group2Sel->isVisible() && !Group2Sel->buttonApply->isEnabled() ) ||
2357 ( Group1Sel1Spin->isVisible() && !Group1Sel1Spin->buttonApply->isEnabled() ) ||
2358 ( Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ) ||
2359 ( Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ) ||
2360 ( Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ) ||
2361 ( Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) ) {
2362 theApplyedWire = aShape;
2366 BRepBuilderAPI_MakeWire aBuilder;
2367 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
2369 TopoDS_Shape anEdge = anExp.Current();
2371 if ( anExp.More() ) // i.e. non-last edge
2372 aBuilder.Add( TopoDS::Edge( anEdge ) );
2374 theLastSegment = anEdge;
2379 if ( aBuilder.IsDone() )
2380 theApplyedWire = aBuilder.Shape();
2385 //=================================================================================
2386 // function : acceptMouseEvent()
2388 //=================================================================================
2389 bool EntityGUI_SketcherDlg::acceptMouseEvent() const
2391 return ( (getPnt1ConstructorId() == 1 || getPnt1ConstructorId() == 0) //accept mouse event only on absolute and relative selection mode
2392 && !WPlaneLineEdit->isEnabled()); // called by EntityGUI::OnMousePress()
2395 //=================================================================================
2396 // function : keyPressEvent()
2398 //=================================================================================
2399 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
2401 QDialog::keyPressEvent( e );
2402 if ( e->isAccepted() )
2405 if ( e->key() == Qt::Key_F1 ) {
2411 //=================================================================================
2412 // function : initSpinBox()
2414 //=================================================================================
2415 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
2416 double min, double max,
2417 double step, const char* quantity )
2419 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
2420 // TODO: Think how to keep the single piece of code...
2422 // Obtain precision from preferences
2423 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2424 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
2426 spinBox->setPrecision( aPrecision );
2427 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
2428 // by default Qt rounds boundaries to 2 decimals at setRange
2429 spinBox->setRange( min, max );
2430 spinBox->setSingleStep( step );
2432 // Add a hint for the user saying how to tune precision
2433 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
2434 spinBox->setProperty( "validity_tune_hint",
2435 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
2438 //=================================================================================
2439 // function : SetDoubleSpinBoxStep()
2440 // purpose : Double spin box management
2441 //=================================================================================
2442 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
2444 Group1Spin->SpinBox_DX->setSingleStep(step);
2445 Group1Sel1Spin->SpinBox_DX->setSingleStep(step);
2446 Group2Spin->SpinBox_DX->setSingleStep(step);
2447 Group2Spin->SpinBox_DY->setSingleStep(step);
2448 Group3Spin->SpinBox_DX->setSingleStep(step);
2449 Group3Spin->SpinBox_DY->setSingleStep(step);
2450 Group3Spin->SpinBox_DZ->setSingleStep(step);
2451 Group4Spin->SpinBox_DZ->setSingleStep(step);
2453 // san: Do NOT override the step when a speicifc step value is used
2454 // in some input fields!
2455 //Group4Spin->SpinBox_DX->setSingleStep(step);
2456 //Group4Spin->SpinBox_DY->setSingleStep(step);
2457 //Group4Spin->SpinBox_DS->setSingleStep(step);
2460 //=================================================================================
2461 // function : AddLocalCS()
2462 // purpose : Add All Coordinates systems in study
2463 //=================================================================================
2464 void EntityGUI_SketcherDlg::AddLocalCS(GEOM::GEOM_Object_var aSelectedObject)
2466 MESSAGE("EntityGUI_SketcherDlg::AddLocalCS")
2467 QString aName = GEOMBase::GetName( aSelectedObject );
2469 int index = ComboBox1->findText(aName, Qt::MatchExactly);
2471 if (index==-1) // If the working plane hasn't been added yet
2473 myWPlaneList.push_back(aSelectedObject);
2474 myWPlane = aSelectedObject;
2475 addSubshapesToStudy();
2476 myLCSList.push_back(WPlaneToLCS(aSelectedObject));
2477 ComboBox1->addItem(aName);
2478 index = ComboBox1->count();
2479 ComboBox1->setCurrentIndex(index-1);
2483 ComboBox1->setCurrentIndex(index);
2488 //=================================================================================
2489 // function : FindLocalCS()
2490 // purpose : Find All Coordinates systems in study
2491 //=================================================================================
2492 void EntityGUI_SketcherDlg::FindLocalCS()
2494 MESSAGE("EntityGUI_SketcherDlg::FindLocalCS")
2496 myWPlaneList.clear();
2497 SalomeApp_Application* app =
2498 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2502 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2506 _PTR(Study) aStudy = appStudy->studyDS();
2509 ComboBox1->addItem(tr("GEOM_GCS"));
2510 myWPlaneList.push_back(myGlobalCS);
2512 // get GEOM component
2513 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
2514 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
2517 _PTR(SComponent) fc = obj->GetFatherComponent();
2518 QString geomComp = fc->GetID().c_str();
2519 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
2523 // browse through all GEOM data tree
2524 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
2525 for ( it->InitEx( true ); it->More(); it->Next() )
2527 _PTR(SObject) child( it->Value() );
2528 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
2529 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2530 if( CORBA::is_nil( geomObj ) )
2532 if (geomObj->GetType() == GEOM_MARKER)
2534 myWPlaneList.push_back(geomObj);
2535 myLCSList.push_back(WPlaneToLCS(geomObj));
2536 ComboBox1->addItem(geomObj->GetName());
2537 MESSAGE("ComboBox1->addItem() in EntityGUI_SketcherDlg::FindLocalCS()")
2542 //=================================================================================
2543 // function : WPlaneToLCS ( aWPlane )
2545 //=================================================================================
2546 gp_Ax3 EntityGUI_SketcherDlg::WPlaneToLCS( GEOM::GEOM_Object_var geomObj )
2548 TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
2551 if (CORBA::is_nil( geomObj ) || aShape.IsNull())
2553 MESSAGE("CORBA::is_nil( geomObj ) || aShape.IsNull()")
2555 aLCS.Transform(aShape.Location().Transformation());
2556 if (aShape.ShapeType() == TopAbs_FACE)
2558 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
2559 myGeometryGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
2560 double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
2561 aMeasureOp->GetPosition( geomObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
2562 if ( aMeasureOp->IsDone() )
2564 gp_Pnt aPnt ( Ox, Oy, Oz );
2565 gp_Dir aDirN ( Zx, Zy, Zz );
2566 gp_Dir aDirX ( Xx, Xy, Xz );
2567 aLCS = gp_Ax3( aPnt, aDirN, aDirX );
2574 //=================================================================================
2575 // function : getPnt1ConstructorId()
2577 //=================================================================================
2578 int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
2580 int buttonId = GroupPt->ButtonGroup->checkedId();
2581 // MESSAGE("buttonId = "<<buttonId)
2585 //=================================================================================
2586 // function : getPnt2ConstructorId()
2588 //=================================================================================
2589 int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
2591 int buttonId = GroupPt2->ButtonGroup->checkedId();
2592 // MESSAGE("buttonId = "<<buttonId)
2596 //=================================================================================
2597 // function : GetActiveLocalCS()
2598 // purpose : Get Working plane
2599 //=================================================================================
2600 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
2602 MESSAGE("EntityGUI_SketcherDlg::GetActiveLocalCS()")
2603 int ind = ComboBox1->currentIndex();
2605 return myGeometryGUI->GetWorkingPlane();
2607 gp_Ax3 aLCS = myLCSList.at(ind);
2608 myWPlane = myWPlaneList.at(ind);
2613 //=================================================================================
2614 // function : ActivateLocalCS()
2615 // purpose : Activate & Fit Working plane
2616 //=================================================================================
2617 void EntityGUI_SketcherDlg::ActivateLocalCS()
2619 MESSAGE("EntityGUI_SketcherDlg::ActivateLocalCS")
2620 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
2621 myGeometryGUI->ActiveWorkingPlane();
2624 //=================================================================================
2625 // function : addSubshapeToStudy
2626 // purpose : virtual method to add new SubObjects if local selection
2627 //=================================================================================
2628 void EntityGUI_SketcherDlg::addSubshapesToStudy()
2630 MESSAGE("EntityGUI_SketcherDlg::addSubshapesToStudy()")
2631 GEOMBase::PublishSubObject(myWPlane);