1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
27 #include "EntityGUI_SketcherDlg.h"
28 #include "EntityGUI_Widgets.h"
29 #include <SalomeApp_DoubleSpinBox.h>
32 #include <GeometryGUI.h>
33 #include <GEOMImpl_Types.hxx>
34 #include <Geom_Surface.hxx>
35 #include <Geom_Plane.hxx>
37 #include <SUIT_Desktop.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Application.h>
42 #include <LightApp_Application.h>
43 #include <LightApp_SelectionMgr.h>
47 #include <BRep_Tool.hxx>
49 #include <TopExp_Explorer.hxx>
50 #include <TopoDS_Vertex.hxx>
52 #include <BRepBuilderAPI_Transform.hxx>
53 #include <BRepBuilderAPI_MakeWire.hxx>
54 #include <Sketcher_Profile.hxx>
56 #include <SalomeApp_Study.h>
60 #include <Basics_Utils.hxx>
62 //=================================================================================
63 // class : EntityGUI_SketcherDlg()
64 // purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
65 // name 'name' and widget flags set to 'f'.
66 // The dialog will by default be modeless, unless you set 'modal' to
67 // TRUE to construct a modal dialog.
68 //=================================================================================
69 EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
70 bool modal, Qt::WindowFlags fl,
71 const double lineWidth )
72 : QDialog( parent, fl ),
73 myIsAllAdded( false ),
75 GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
77 myLineWidth( lineWidth )
80 setAttribute( Qt::WA_DeleteOnClose );
82 myGeometryGUI->SetActiveDialogBox(this);
84 MainWidget = new EntityGUI_Skeleton( this );
85 QVBoxLayout* topLayout = new QVBoxLayout( this );
86 topLayout->setMargin( 9 ); topLayout->setSpacing( 6 );
88 MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) );
89 MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) );
90 MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
91 MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) );
93 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
94 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
95 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
97 setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
99 MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) );
100 MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) );
101 MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) );
102 MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) );
103 MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) );
104 MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) );
105 MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) );
107 /***************************************************************/
109 GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
110 QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
111 planeLayout->setSpacing(6);
112 planeLayout->setMargin(11);
114 ComboBox1 = new QComboBox(GroupBox1);
115 ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
116 planeLayout->addWidget(ComboBox1);
118 planeButton = new QPushButton (GroupBox1);
119 planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
120 planeLayout->addWidget(planeButton);
122 topLayout->addWidget(GroupBox1);
123 topLayout->addWidget( MainWidget );
125 GroupPt = new EntityGUI_Point( MainWidget->DestCnt );
127 GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) );
128 GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) );
129 GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) );
130 GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) );
132 GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt );
134 GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
135 GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) );
136 GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) );
137 GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) );
138 GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) );
140 GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt );
142 GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) );
143 GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) );
144 GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) );
145 GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) );
147 Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt );
149 Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) );
150 Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
151 Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
152 Group1Sel->PushButton1->setIcon( image0 );
153 Group1Sel->buttonUndo->setIcon( image1 );
154 Group1Sel->buttonRedo->setIcon( image2 );
155 Group1Sel->LineEdit1->setReadOnly( true );
157 Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt );
158 Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
159 Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
160 Group1Spin->buttonUndo->setIcon( image1 );
161 Group1Spin->buttonRedo->setIcon( image2 );
163 Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt );
164 Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
165 Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
166 Group2Spin->buttonUndo->setIcon( image1 );
167 Group2Spin->buttonRedo->setIcon( image2 );
169 Group3Spin = new EntityGUI_3Spin( MainWidget->SkeletonCnt );
170 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
171 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
172 Group3Spin->buttonUndo->setIcon( image1 );
173 Group3Spin->buttonRedo->setIcon( image2 );
175 Group4Spin = new EntityGUI_4Spin( MainWidget->SkeletonCnt );
176 Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
177 Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
178 Group4Spin->buttonUndo->setIcon( image1 );
179 Group4Spin->buttonRedo->setIcon( image2 );
181 QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt );
182 DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 );
183 DestCntLayout->addWidget( GroupPt, 0, 0, 1, 2 );
184 DestCntLayout->addWidget( GroupD1, 1, 0 );
185 DestCntLayout->addWidget( GroupD2, 1, 1 );
187 QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt );
188 SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 );
189 SkeletonCntlayout->addWidget( Group1Sel, 0, 0 );
190 SkeletonCntlayout->addWidget( Group1Spin, 0, 0 );
191 SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
192 SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
193 SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
194 /***************************************************************/
196 QButtonGroup* ButtonGroup = new QButtonGroup( this );
197 ButtonGroup->addButton( MainWidget->RB_Dest1, 1 );
198 ButtonGroup->addButton( MainWidget->RB_Dest2, 0 );
200 /* signals and slots connections */
201 connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
202 connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) );
203 connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
204 connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
206 connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
207 connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
208 connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
209 connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
210 connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
211 connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
212 connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
213 connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
214 connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
215 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
216 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
217 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
218 connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
219 connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
220 connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) );
222 connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
223 connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) );
224 connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) );
225 connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) );
226 connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) ));
228 connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
229 connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
231 connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
232 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
233 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
234 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
235 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
236 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
237 connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
238 connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
239 connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
240 connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
242 connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
243 connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
245 connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
247 connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
248 connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
250 // install event filter on spin-boxes to provide Apply action on Return pressed
251 Group1Spin->SpinBox_DX->installEventFilter(this);
252 Group2Spin->SpinBox_DX->installEventFilter(this);
253 Group2Spin->SpinBox_DY->installEventFilter(this);
254 Group3Spin->SpinBox_DX->installEventFilter(this);
255 Group3Spin->SpinBox_DY->installEventFilter(this);
256 Group3Spin->SpinBox_DZ->installEventFilter(this);
257 Group4Spin->SpinBox_DX->installEventFilter(this);
258 Group4Spin->SpinBox_DY->installEventFilter(this);
259 Group4Spin->SpinBox_DZ->installEventFilter(this);
260 Group4Spin->SpinBox_DS->installEventFilter(this);
266 //=================================================================================
267 // function : ~EntityGUI_SketcherDlg()
268 // purpose : Destroys the object and frees any allocated resources
269 //=================================================================================
270 EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
272 myGeometryGUI->SetActiveDialogBox( 0 );
276 //=================================================================================
277 // function : eventFilter()
278 // purpose : event filter for spin-boxes to provide Apply action on Return pressed
279 //=================================================================================
280 bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
282 if (event->type() == QEvent::KeyPress) {
283 QKeyEvent* ke = (QKeyEvent*)event;
284 if (ke->key() == Qt::Key_Return) {
285 if (object == Group1Spin->SpinBox_DX) {
286 Group1Spin->buttonApply->animateClick();
288 } else if (object == Group2Spin->SpinBox_DX ||
289 object == Group2Spin->SpinBox_DY) {
290 Group2Spin->buttonApply->animateClick();
292 } else if (object == Group3Spin->SpinBox_DX ||
293 object == Group3Spin->SpinBox_DY ||
294 object == Group3Spin->SpinBox_DZ) {
295 Group3Spin->buttonApply->animateClick();
297 } else if (object == Group4Spin->SpinBox_DX ||
298 object == Group4Spin->SpinBox_DY ||
299 object == Group4Spin->SpinBox_DZ ||
300 object == Group4Spin->SpinBox_DS) {
301 Group4Spin->buttonApply->animateClick();
307 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
309 return QDialog::eventFilter(object, event);
313 //=================================================================================
316 //=================================================================================
317 void EntityGUI_SketcherDlg::Init()
320 myEditCurrentArgument = Group1Sel->LineEdit1;
321 myCommand.append( "Sketcher" );
322 myUndoCommand.append( "Sketcher" );
324 mySketchState = FIRST_POINT;
325 globalSelection( GEOM_POINT );
332 myHelpFileName = "create_sketcher_page.html";
334 /* Get setting of step value from file configuration */
335 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
337 /* min, max, step and decimals for spin boxes */
338 initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
339 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
340 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
341 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
342 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
343 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
344 initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
345 // san: Note specific step values below!
346 initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
347 initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
348 initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
350 /* displays Dialog */
351 MainWidget->GroupConstructors->setEnabled( false );
352 MainWidget->GroupDest1->setEnabled( false );
353 setEnabledUndo( false );
354 setEnabledRedo( false );
356 MainWidget->RadioButton1->setChecked( true );
364 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
368 //=================================================================================
369 // function : InitClick()
371 //=================================================================================
372 void EntityGUI_SketcherDlg::InitClick()
374 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
384 //=================================================================================
385 // function : TypeClicked()
386 // purpose : Radio button management
387 //=================================================================================
388 void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
390 myConstructorId = constructorId;
391 if ( myConstructorId == 0 ) { // SEGMENT
392 GroupD2->setEnabled( true );
393 MainWidget->RB_Dest1->setEnabled( true );
394 MainWidget->RB_Dest1->setChecked( true );
397 else if ( myConstructorId == 1 ) { // ARC
398 GroupD2->setEnabled( false );
399 MainWidget->RB_Dest1->setEnabled( true );
400 MainWidget->RB_Dest2->setChecked( true );
406 //=================================================================================
407 // function : DestClicked()
408 // purpose : Radio button management
409 //=================================================================================
410 void EntityGUI_SketcherDlg::DestClicked( int constructorId )
416 if ( constructorId == 1 ) {
418 GroupPt->RB_Point1->setChecked( true );
420 PointClicked( 1 ); // XY
422 else if ( constructorId == 0 ) {
424 GroupD1->RB_Dir11->setChecked( true );
427 Dir1Clicked( 2 ); // Angle
432 //=================================================================================
433 // function : PointClicked()
434 // purpose : Radio button management
435 //=================================================================================
436 void EntityGUI_SketcherDlg::PointClicked( int constructorId )
440 // Get setting of step value from file configuration
441 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
443 if ( (myConstructorId == 0) || (myConstructorId == 1) ) { // SEGMENT OR ARC
444 if ( constructorId == 1 ) { // XY
445 mySketchType = PT_ABS;
446 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
447 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
448 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
449 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
451 Group2Spin->SpinBox_DX->setValue( myX );
453 Group2Spin->SpinBox_DY->setValue( myY );
455 Group2Spin->buttonApply->setFocus();
457 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
459 else if ( constructorId == 0 ) { // DXDY
460 mySketchType = PT_RELATIVE;
461 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
462 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
463 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
464 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
466 Group2Spin->SpinBox_DX->setValue( myDX );
468 Group2Spin->SpinBox_DY->setValue( myDY );
470 Group2Spin->buttonApply->setFocus();
472 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
474 else if ( constructorId == 2 ) { // Selection
475 mySketchType = PT_SEL;
476 myEditCurrentArgument = Group1Sel->LineEdit1;
478 Group1Sel->buttonApply->setFocus();
479 SelectionIntoArgument();
482 connect( myGeometryGUI->getApp()->selectionMgr(),
483 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
488 //=================================================================================
489 // function : Dir1Clicked()
490 // purpose : Radio button management
491 //=================================================================================
492 void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
494 myConstructorDirId = constructorId;
495 GroupD2->RB_Dir21->setChecked( true );
500 //=================================================================================
501 // function : Dir2Clicked()
502 // purpose : Radio button management
503 //=================================================================================
504 void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
509 // Get setting of step value from file configuration
510 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
512 if ( myConstructorId == 0 ) { // SEGMENT
516 if ( myConstructorDirId == 2 ) { // Angle
517 initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
518 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
519 Group2Spin->SpinBox_DX->setValue( myAngle );
520 Group2Spin->buttonApply->setFocus();
523 if ( constructorId == 2 ) { // Length
524 mySketchType = DIR_ANGLE_LENGTH;
525 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
526 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
527 Group2Spin->SpinBox_DY->setValue( myLength );
529 else if ( constructorId == 0 ) { // X
530 mySketchType = DIR_ANGLE_X;
531 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
532 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
533 Group2Spin->SpinBox_DY->setValue( myX );
535 else if ( constructorId == 1 ) { // Y
536 mySketchType = DIR_ANGLE_Y;
537 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
538 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
539 Group2Spin->SpinBox_DY->setValue( myY );
542 else if ( myConstructorDirId == 0 ) { // Perpendicular
544 Group1Spin->buttonApply->setFocus();
546 if ( constructorId == 2 ) { // Length
547 mySketchType = DIR_PER_LENGTH;
548 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
549 Group1Spin->SpinBox_DX->setValue( myLength );
551 else if ( constructorId == 0 ) { // X
552 mySketchType = DIR_PER_X;
553 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
554 Group1Spin->SpinBox_DX->setValue( myX );
556 else if ( constructorId == 1 ) { // Y
557 mySketchType = DIR_PER_Y;
558 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
559 Group1Spin->SpinBox_DX->setValue( myY );
562 else if ( myConstructorDirId == 1 ) { // Tangent
564 Group1Spin->buttonApply->setFocus();
566 if ( constructorId == 2 ) { // Length
567 mySketchType = DIR_TAN_LENGTH;
568 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
569 Group1Spin->SpinBox_DX->setValue( myLength );
571 else if ( constructorId == 0 ) { // X
572 mySketchType = DIR_TAN_X;
573 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) );
574 Group1Spin->SpinBox_DX->setValue( myX );
576 else if ( constructorId == 1 ) { // Y
577 mySketchType = DIR_TAN_Y;
578 Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) );
579 Group1Spin->SpinBox_DX->setValue( myY );
582 else if ( myConstructorDirId == 3 ) { // DXDY
583 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
584 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
585 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
586 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
587 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
589 Group3Spin->SpinBox_DX->setValue( myDX );
591 Group3Spin->SpinBox_DY->setValue( myDY );
593 Group3Spin->buttonApply->setFocus();
595 if ( constructorId == 2 ) { // Length
596 mySketchType = DIR_DXDY_LENGTH;
597 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
598 Group3Spin->SpinBox_DZ->setValue( myLength );
600 else if ( constructorId == 0 ) { // X
601 mySketchType = DIR_DXDY_X;
602 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) );
603 Group3Spin->SpinBox_DZ->setValue( myX );
605 else if ( constructorId == 1 ) { // Y
606 mySketchType = DIR_DXDY_Y;
607 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) );
608 Group3Spin->SpinBox_DZ->setValue( myY );
612 else if ( myConstructorId == 1 ) { // ARC
613 if ( myConstructorDirId == 2 ) { // Angle
614 if ( constructorId == 2 ) { // Length
615 mySketchType = DIR_ANGLE_LENGTH;
616 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
617 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
618 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
619 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
620 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
621 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
622 Group3Spin->SpinBox_DX->setValue( myAngle );
624 Group3Spin->SpinBox_DY->setValue( myRadius );
626 Group3Spin->SpinBox_DZ->setValue( myLength );
628 Group3Spin->buttonApply->setFocus();
631 else if ( myConstructorDirId == 0 ) { // Perpendicular
632 if ( constructorId == 2 ) { // Length
633 mySketchType = DIR_PER_LENGTH;
634 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
635 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
636 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
637 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
639 Group2Spin->SpinBox_DX->setValue( myRadius );
641 Group2Spin->SpinBox_DY->setValue( myLength );
643 Group2Spin->buttonApply->setFocus();
646 else if ( myConstructorDirId == 1 ) { // Tangent
647 if ( constructorId == 2 ) { // Length
648 mySketchType = DIR_TAN_LENGTH;
649 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
650 initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
651 Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
652 Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
654 Group2Spin->SpinBox_DX->setValue( myRadius );
656 Group2Spin->SpinBox_DY->setValue( myLength );
658 Group2Spin->buttonApply->setFocus();
661 else if ( myConstructorDirId == 3 ) { // DXDY
662 if ( constructorId == 2 ) { // Length
663 mySketchType = DIR_DXDY_LENGTH;
664 Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
665 Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
666 Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
667 Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
669 Group4Spin->SpinBox_DX->setValue( myDX );
671 Group4Spin->SpinBox_DY->setValue( myDY );
673 Group4Spin->SpinBox_DZ->setValue( myRadius );
675 Group4Spin->SpinBox_DS->setValue( myLength );
677 Group4Spin->buttonApply->setFocus();
682 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
686 //=================================================================================
687 // function : ClickOnCancel()
689 //=================================================================================
690 void EntityGUI_SketcherDlg::ClickOnCancel()
696 //=================================================================================
697 // function : ClickOnEnd()
698 // purpose : connected to buttonEnd AND buttonClose
699 //=================================================================================
700 void EntityGUI_SketcherDlg::ClickOnEnd()
702 if ( sender() == MainWidget->buttonClose ) {
703 // Verify validity of commands
704 if ( myCommand.count() <= 2 ) {
705 SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
706 tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
711 QString Command = myCommand.join( "" ) + GetNewCommand( Parameters );
712 Sketcher_Profile aProfile( Command.toAscii() );
714 Command = myCommand.join( "" );
715 aProfile = Sketcher_Profile( Command.toAscii() );
716 TopoDS_Shape myShape;
717 if ( aProfile.IsDone() )
718 myShape = aProfile.GetShape();
720 if ( myShape.ShapeType() != TopAbs_VERTEX )
721 myCommand.append( ":WW" );
724 // PAL16008 (Sketcher Validation should be equal to Apply&Close)
725 if ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ||
726 Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ||
727 Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ||
728 Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ||
729 Group1Sel ->buttonApply->isEnabled() && Group1Sel->isVisible() ) {
735 if ( myCommand.size() > 2 )
742 //=================================================================================
743 // function : ClickOnApply()
745 //=================================================================================
746 bool EntityGUI_SketcherDlg::ClickOnApply()
748 if ( sender() && sender()->inherits( "QPushButton" ) )
749 ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
752 myCommand.append( GetNewCommand( aParameters ) );
753 mySketchState = NEXT_POINT;
755 myUndoCommand.clear();
756 myUndoCommand.append( "Sketcher" );
758 myParameters.append( aParameters );
759 myUndoParameters.clear();
761 MainWidget->GroupConstructors->setEnabled( true );
762 MainWidget->GroupDest1->setEnabled( true );
763 setEnabledUndo( true );
764 setEnabledRedo( false );
767 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
770 // Set focus to SpinBox_DX
771 if ( sender() == Group1Spin->buttonApply ) {
772 (Group1Spin->SpinBox_DX)->setFocus();
773 (Group1Spin->SpinBox_DX)->selectAll();
775 else if ( sender() == Group2Spin->buttonApply ) {
776 (Group2Spin->SpinBox_DX)->setFocus();
777 (Group2Spin->SpinBox_DX)->selectAll();
779 else if ( sender() == Group3Spin->buttonApply ) {
780 (Group3Spin->SpinBox_DX)->setFocus();
781 (Group3Spin->SpinBox_DX)->selectAll();
783 else if ( sender() == Group4Spin->buttonApply ) {
784 (Group4Spin->SpinBox_DX)->setFocus();
785 (Group4Spin->SpinBox_DX)->selectAll();
791 //=================================================================================
792 // function : ClickOnHelp()
794 //=================================================================================
795 void EntityGUI_SketcherDlg::ClickOnHelp()
797 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
799 app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName );
803 platform = "winapplication";
805 platform = "application";
808 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
809 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
810 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ),
811 QObject::tr( "BUT_OK" ) );
815 //=================================================================================
816 // function : ClickOnUndo()
818 //=================================================================================
819 void EntityGUI_SketcherDlg::ClickOnUndo()
821 myUndoCommand.append( myCommand.last() );
822 myCommand.pop_back();
824 myUndoParameters.append( myParameters.last() );
825 myParameters.pop_back();
827 if ( myCommand.count() == 1 ) {
828 mySketchState = FIRST_POINT;
830 MainWidget->RadioButton1->setChecked( true );
833 connect( myGeometryGUI->getApp()->selectionMgr(),
834 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
836 MainWidget->GroupConstructors->setEnabled( false );
837 MainWidget->GroupDest1->setEnabled( false );
838 setEnabledUndo( false );
841 setEnabledRedo( true );
843 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
846 //=================================================================================
847 // function : ClickOnRedo()
849 //=================================================================================
850 void EntityGUI_SketcherDlg::ClickOnRedo()
852 myCommand.append( myUndoCommand.last() );
853 myUndoCommand.pop_back();
855 myParameters.append( myUndoParameters.last() );
856 myUndoParameters.pop_back();
858 mySketchState = NEXT_POINT;
860 MainWidget->GroupConstructors->setEnabled( true );
861 MainWidget->GroupDest1->setEnabled( true );
862 setEnabledUndo( true );
864 if ( myUndoCommand.count() == 1 )
865 setEnabledRedo( false );
867 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
870 //=================================================================================
871 // function : setEnabledUndo()
873 //=================================================================================
874 void EntityGUI_SketcherDlg::setEnabledUndo( bool value )
876 Group1Sel->buttonUndo->setEnabled( value );
877 Group1Spin->buttonUndo->setEnabled( value );
878 Group2Spin->buttonUndo->setEnabled( value );
879 Group3Spin->buttonUndo->setEnabled( value );
880 Group4Spin->buttonUndo->setEnabled( value );
883 //=================================================================================
884 // function : setEnabledRedo()
886 //=================================================================================
887 void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
889 Group1Sel->buttonRedo->setEnabled( value );
890 Group1Spin->buttonRedo->setEnabled( value );
891 Group2Spin->buttonRedo->setEnabled( value );
892 Group3Spin->buttonRedo->setEnabled( value );
893 Group4Spin->buttonRedo->setEnabled( value );
896 //=================================================================================
897 // function : SelectionIntoArgument()
898 // purpose : Called when selection as changed
899 //=================================================================================
900 void EntityGUI_SketcherDlg::SelectionIntoArgument()
902 myEditCurrentArgument->setText( "" );
907 // printf ("\nmyX = %f myY = %f", myX, myY);
908 // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
909 // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
911 if ( sender() == ComboBox1 )
914 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
915 SALOME_ListIO aSelList;
916 aSelMgr->selectedObjects(aSelList);
918 int nbSel = aSelList.Extent();
919 if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
920 Standard_Boolean aRes = Standard_False;
921 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
922 if (!CORBA::is_nil(aSelectedObject) && aRes) {
924 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
926 gp_Ax3 aWPlane = GetActiveLocalCS();
928 aTrans.SetTransformation(aWPlane);
929 BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
930 aShape = aTransformation.Shape();
933 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
936 Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
937 if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
938 disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
939 disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
940 Group2Spin->SpinBox_DX->setValue(myX);
941 Group2Spin->SpinBox_DY->setValue(myY);
942 connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
943 connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
944 } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
945 if ( myLastX1 && myLastY1 ) {
946 Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
947 Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
949 if ( mySketchState != FIRST_POINT ) {
950 Group2Spin->SpinBox_DX->setValue(myX - tmpX);
951 Group2Spin->SpinBox_DY->setValue(myY - tmpY);
953 Group2Spin->SpinBox_DX->setValue(myX);
954 Group2Spin->SpinBox_DY->setValue(myY);
963 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
967 //=================================================================================
968 // function : SetEditCurrentArgument()
970 //=================================================================================
971 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
973 if ( sender() == Group1Sel->PushButton1 ) {
974 myEditCurrentArgument = Group1Sel->LineEdit1;
975 myEditCurrentArgument->setFocus();
977 SelectionIntoArgument();
981 //=================================================================================
982 // function : LineEditReturnPressed()
984 //=================================================================================
985 void EntityGUI_SketcherDlg::LineEditReturnPressed()
987 if ( sender() == Group1Sel->LineEdit1 ) {
988 myEditCurrentArgument = Group1Sel->LineEdit1;
990 /* User name of object input management */
991 /* If successfull the selection is changed and signal emitted... */
992 /* so SelectionIntoArgument() is automatically called. */
993 const QString objectUserName = myEditCurrentArgument->text();
994 QWidget* thisWidget = (QWidget*)this;
996 LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
997 SALOME_ListIO aSelList;
998 aSelMgr->selectedObjects(aSelList);
1000 if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList))
1001 myEditCurrentArgument->setText( objectUserName );
1006 //=================================================================================
1007 // function : DeactivateActiveDialog()
1009 //=================================================================================
1010 void EntityGUI_SketcherDlg::DeactivateActiveDialog()
1012 //myGeometryGUI->SetState( -1 );
1014 setEnabled( false );
1016 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1017 myGeometryGUI->SetActiveDialogBox( 0 );
1021 //=================================================================================
1022 // function : ActivateThisDialog()
1024 //=================================================================================
1025 void EntityGUI_SketcherDlg::ActivateThisDialog()
1027 myGeometryGUI->EmitSignalDeactivateDialog();
1029 myGeometryGUI->SetActiveDialogBox( this );
1031 connect( myGeometryGUI->getApp()->selectionMgr(),
1032 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1034 //myGeometryGUI->SetState( 0 );
1035 globalSelection( GEOM_POINT );
1037 myEditCurrentArgument = Group1Sel->LineEdit1;
1038 myEditCurrentArgument->setFocus();
1040 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1044 //=================================================================================
1045 // function : enterEvent [REDEFINED]
1047 //=================================================================================
1048 void EntityGUI_SketcherDlg::enterEvent( QEvent* )
1050 if ( !MainWidget->GroupConstructors->isEnabled() )
1051 ActivateThisDialog();
1055 //=================================================================================
1056 // function : closeEvent()
1058 //=================================================================================
1059 void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
1061 //myGeometryGUI->SetState( -1 );
1062 disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
1063 myGeometryGUI->getApp()->updateActions();
1064 QDialog::closeEvent( e );
1068 //=================================================================================
1069 // function : ValueChangedInSpinBox()
1071 //=================================================================================
1072 void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
1074 QObject* send = (QObject*)sender();
1075 Standard_Real vx, vy, vz, vs;
1076 vx = vy = vz = vs = 0.0;
1078 QString vxStr, vyStr, vzStr, vsStr;
1080 QString newValueStr;
1081 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send )
1082 newValueStr = aDoubleSpinBox->text();
1084 if ( send == Group1Spin->SpinBox_DX ) {
1085 vx = newValue; vxStr = newValueStr;
1087 else if ( send == Group2Spin->SpinBox_DX ) {
1088 vx = newValue; vxStr = newValueStr;
1089 vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text();
1091 else if ( send == Group2Spin->SpinBox_DY ) {
1092 vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text();
1093 vy = newValue; vyStr = newValueStr;
1095 else if ( send == Group3Spin->SpinBox_DX ) {
1096 vx = newValue; vxStr = newValueStr;
1097 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1098 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1100 else if ( send == Group3Spin->SpinBox_DY ) {
1101 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1102 vy = newValue; vyStr = newValueStr;
1103 vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
1105 else if ( send == Group3Spin->SpinBox_DZ ) {
1106 vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text();
1107 vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
1108 vz = newValue; vzStr = newValueStr;
1110 else if ( send == Group4Spin->SpinBox_DX ) {
1111 vx = newValue; vxStr = newValueStr;
1112 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1113 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1114 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1116 else if ( send == Group4Spin->SpinBox_DY ) {
1117 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1118 vy = newValue; vyStr = newValueStr;
1119 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1120 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1122 else if ( send == Group4Spin->SpinBox_DZ ) {
1123 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1124 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1125 vz = newValue; vzStr = newValueStr;
1126 vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text();
1128 else if ( send == Group4Spin->SpinBox_DS ) {
1129 vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text();
1130 vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text();
1131 vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text();
1132 vs = newValue; vsStr = newValueStr;
1134 // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
1136 if ( myConstructorId == 0 ) { // SEGMENT
1137 if ( mySketchType == PT_ABS ) {
1143 else if ( mySketchType == PT_RELATIVE ) {
1149 else if ( mySketchType == DIR_ANGLE_LENGTH ) {
1153 myLengthStr = vyStr;
1155 else if ( mySketchType == DIR_ANGLE_X ) {
1161 else if ( mySketchType == DIR_ANGLE_Y ) {
1167 else if ( mySketchType == DIR_PER_LENGTH ) {
1169 myLengthStr = vxStr;
1171 else if ( mySketchType == DIR_PER_X ) {
1175 else if ( mySketchType == DIR_PER_Y ) {
1179 else if ( mySketchType == DIR_TAN_LENGTH ) {
1181 myLengthStr = vxStr;
1183 else if ( mySketchType == DIR_TAN_X ) {
1187 else if ( mySketchType == DIR_TAN_Y ) {
1191 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1197 myLengthStr = vzStr;
1199 else if ( mySketchType == DIR_DXDY_X ) {
1207 else if ( mySketchType == DIR_DXDY_Y ) {
1216 else if ( myConstructorId == 1 ) { // ARC
1217 if ( mySketchType == PT_ABS ) {
1223 else if ( mySketchType == PT_RELATIVE ) {
1229 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1234 myRadiusStr = vyStr;
1235 myLengthStr = vzStr;
1237 else if ( mySketchType == DIR_PER_LENGTH ) {
1240 myRadiusStr = vxStr;
1241 myLengthStr = vyStr;
1243 else if ( mySketchType == DIR_TAN_LENGTH ) {
1246 myRadiusStr = vxStr;
1247 myLengthStr = vyStr;
1249 else if ( mySketchType == DIR_DXDY_LENGTH ) {
1256 myRadiusStr = vzStr;
1257 myLengthStr = vsStr;
1261 GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
1265 //=================================================================================
1266 // function : GetNewCommand()
1267 // purpose : Build the new command with context
1268 //=================================================================================
1269 QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
1271 theParameters.clear();
1272 QString myNewCommand = ":";
1273 if ( mySketchState == FIRST_POINT ) {
1274 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1275 myNewCommand = myNewCommand + "F " + QString::number( myX ) + " " + QString::number( myY );
1276 theParameters = myXStr + ":" + myYStr;
1278 if ( mySketchType == PT_RELATIVE) {
1279 myNewCommand = myNewCommand + "F " + QString::number( myDX ) + " " + QString::number( myDY );
1280 theParameters = myDXStr + ":" + myDYStr;
1282 return myNewCommand;
1285 if ( myConstructorId == 0 ) { // SEGMENT
1286 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1287 myNewCommand = myNewCommand + "TT " + QString::number( myX ) + " " + QString::number( myY );
1288 theParameters = myXStr + ":" + myYStr;
1290 if ( mySketchType == PT_RELATIVE) {
1291 myNewCommand = myNewCommand + "T " + QString::number( myDX ) + " " + QString::number( myDY );
1292 theParameters = myDXStr + ":" + myDYStr;
1294 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1295 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1296 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength );
1297 theParameters = myAngleStr + ":" + myLengthStr;
1299 if ( mySketchType == DIR_ANGLE_X ) {
1300 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1301 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX );
1302 theParameters = myAngleStr + ":" + myXStr;
1304 if ( mySketchType == DIR_ANGLE_Y ) {
1305 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1306 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY );
1307 theParameters = myAngleStr + ":" + myYStr;
1309 if ( mySketchType == DIR_PER_LENGTH ) {
1310 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1311 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength );
1312 theParameters = QString::number( 90.0 ) + ":" + myLengthStr;
1314 if ( mySketchType == DIR_PER_X ) {
1315 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1316 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX );
1317 theParameters = QString::number( 90.0 ) + ":" + myXStr;
1319 if ( mySketchType == DIR_PER_Y ) {
1320 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1321 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY );
1322 theParameters = QString::number( 90.0 ) + ":" + myYStr;
1324 if ( mySketchType == DIR_TAN_LENGTH ) {
1325 myNewCommand = myNewCommand + "L " + QString::number( myLength );
1326 theParameters = myLengthStr;
1328 if ( mySketchType == DIR_TAN_X ) {
1329 myNewCommand = myNewCommand + "IX " + QString::number( myX );
1330 theParameters = myXStr;
1332 if ( mySketchType == DIR_TAN_Y) {
1333 myNewCommand = myNewCommand + "IY " + QString::number(myY);
1334 theParameters = myYStr;
1336 if ( mySketchType == DIR_DXDY_LENGTH ) {
1337 myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY );
1338 myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength );
1339 theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr;
1341 if ( mySketchType == DIR_DXDY_X ) {
1342 myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY );
1343 myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX );
1344 theParameters = myDXStr + ":" + myDYStr + ":" + myXStr;
1346 if ( mySketchType == DIR_DXDY_Y ) {
1347 myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY );
1348 myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY );
1349 theParameters = myDXStr + ":" + myDYStr + ":" + myYStr;
1352 else if ( myConstructorId == 1 ) { // ARC
1353 if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
1354 myNewCommand = myNewCommand + "AA " + QString::number( myX ) + " " + QString::number( myY );
1355 theParameters = myXStr + ":" + myYStr;
1357 if ( mySketchType == PT_RELATIVE) {
1358 myNewCommand = myNewCommand + "A " + QString::number( myDX ) + " " + QString::number( myDY );
1359 theParameters = myDXStr + ":" + myDYStr;
1361 if ( mySketchType == DIR_ANGLE_LENGTH ) {
1362 myNewCommand = myNewCommand + "R " + QString::number( myAngle );
1363 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
1364 theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr;
1366 if ( mySketchType == DIR_PER_LENGTH ) {
1367 myNewCommand = myNewCommand + "R " + QString::number( 90.0 );
1368 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
1369 theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr;
1371 if ( mySketchType == DIR_TAN_LENGTH ) {
1372 myNewCommand = myNewCommand + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
1373 theParameters = myRadiusStr + ":" + myLengthStr;
1375 if ( mySketchType == DIR_DXDY_LENGTH ) {
1376 myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY );
1377 myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
1378 theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
1381 return myNewCommand;
1384 //=================================================================================
1385 // function : createOperation
1387 //=================================================================================
1388 GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
1390 return getGeomEngine()->GetICurvesOperations( getStudyId() );
1393 //=================================================================================
1394 // function : isValid
1396 //=================================================================================
1397 bool EntityGUI_SketcherDlg::isValid( QString& msg )
1400 bool toCorrect = !IsPreview() || myIsApply;
1402 if( Group1Spin->isVisible() ) {
1403 ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1405 else if( Group2Spin->isVisible() ) {
1406 ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1407 ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1409 else if( Group3Spin->isVisible() ) {
1410 ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1411 ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1412 ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1414 else if( Group4Spin->isVisible() ) {
1415 ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok;
1416 ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok;
1417 ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok;
1418 ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok;
1421 if( myIsApply && !ok )
1427 //=================================================================================
1428 // function : execute
1430 //=================================================================================
1431 bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
1433 QString aParameters;
1435 if ( mySketchState == FIRST_POINT ) {
1440 //Test if the current point is the same as the last one
1441 TopoDS_Shape myShape1, myShape2;
1443 // Set "C" numeric locale
1444 Kernel_Utils::Localizer loc;
1447 QString Command1 = myCommand.join( "" );
1448 Sketcher_Profile aProfile1( Command1.toAscii() );
1449 if ( aProfile1.IsDone() )
1450 myShape1 = aProfile1.GetShape();
1453 QString Command2 = Command1 + GetNewCommand( aParameters );
1454 Sketcher_Profile aProfile2( Command2.toAscii() );
1455 if ( aProfile2.IsDone() )
1456 myShape2 = aProfile2.GetShape();
1458 if ( myShape2.IsNull() ) {
1459 //the current point is the same as the last one
1460 myLastX2 = myLastX1;
1461 myLastY2 = myLastY1;
1464 TopoDS_Vertex V1, V2;
1466 if ( myShape1.ShapeType() == TopAbs_VERTEX ) {
1467 //the last shape is the first point
1468 pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) );
1473 TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 );
1474 pt = BRep_Tool::Pnt( V2 );
1478 TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 );
1479 pt = BRep_Tool::Pnt( V2 );
1486 if ( ( mySketchState != FIRST_POINT &&
1487 myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
1488 cmd = myCommand.join( "" );
1490 if ( Group1Sel->isVisible() ) {
1491 Group1Sel->buttonApply->setEnabled( false );
1492 //Group1Sel->buttonApply->setFocus();
1494 if ( Group1Spin->isVisible() ) {
1495 Group1Spin->buttonApply->setEnabled( false );
1496 //Group1Spin->buttonApply->setFocus();
1498 if ( Group2Spin->isVisible() ) {
1499 Group2Spin->buttonApply->setEnabled( false );
1500 //Group2Spin->buttonApply->setFocus();
1502 if ( Group3Spin->isVisible() ) {
1503 Group3Spin->buttonApply->setEnabled( false );
1504 //Group3Spin->buttonApply->setFocus();
1506 if ( Group4Spin->isVisible() ) {
1507 Group4Spin->buttonApply->setEnabled( false );
1508 //Group4Spin->buttonApply->setFocus();
1512 cmd = myCommand.join( "" ) + GetNewCommand( aParameters );
1514 if ( Group1Sel->isVisible() ) {
1515 Group1Sel->buttonApply->setEnabled( true );
1516 //Group1Sel->buttonApply->setFocus();
1518 if ( Group1Spin->isVisible() ) {
1519 Group1Spin->buttonApply->setEnabled( true );
1520 //Group1Spin->buttonApply->setFocus();
1522 if ( Group2Spin->isVisible() ) {
1523 Group2Spin->buttonApply->setEnabled( true );
1524 //Group2Spin->buttonApply->setFocus();
1526 if ( Group3Spin->isVisible() ) {
1527 Group3Spin->buttonApply->setEnabled( true );
1528 //Group3Spin->buttonApply->setFocus();
1530 if ( Group4Spin->isVisible() ) {
1531 Group4Spin->buttonApply->setEnabled( true );
1532 //Group4Spin->buttonApply->setFocus();
1536 gp_Ax3 myWPlane = GetActiveLocalCS();
1537 GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
1538 WPlane->length( 9 );
1539 WPlane[0] = myWPlane.Location().X();
1540 WPlane[1] = myWPlane.Location().Y();
1541 WPlane[2] = myWPlane.Location().Z();
1543 WPlane[3] = myWPlane.Direction().X();
1544 WPlane[4] = myWPlane.Direction().Y();
1545 WPlane[5] = myWPlane.Direction().Z();
1547 WPlane[6] = myWPlane.XDirection().X();
1548 WPlane[7] = myWPlane.XDirection().Y();
1549 WPlane[8] = myWPlane.XDirection().Z();
1551 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
1552 GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
1554 if ( !anObj->_is_nil() )
1556 if( !IsPreview() ) {
1557 QStringList aCurrentParameters = myParameters;
1558 aCurrentParameters << aParameters;
1559 anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData());
1562 objects.push_back( anObj._retn() );
1568 //================================================================
1569 // Function : displayPreview
1570 // Purpose : Method for displaying preview of resulting shape
1571 // Redefined from GEOMBase_Helper.
1572 //================================================================
1573 void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
1575 const bool activate,
1577 const double lineWidth,
1578 const int displayMode,
1581 // Set color for preview shape
1582 getDisplayer()->SetColor( Quantity_NOC_RED );
1584 // set width of displayed shape
1585 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
1587 // Disable activation of selection
1588 getDisplayer()->SetToActivate( activate );
1590 // Make a reference to GEOM_Object
1591 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
1592 getDisplayer()->SetName( objStr.in() );
1594 // Create wire from applayed object
1595 TopoDS_Shape anApplyedWire, aLastSegment;
1596 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
1600 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
1601 if ( aPrs != 0 && !aPrs->IsNull() )
1602 GEOMBase_Helper::displayPreview( aPrs, append, update );
1604 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
1605 aPrs = getDisplayer()->BuildPrs( aLastSegment );
1606 if ( aPrs != 0 && !aPrs->IsNull() )
1607 GEOMBase_Helper::displayPreview( aPrs, append, update );
1609 getDisplayer()->UnsetName();
1611 // Enable activation of displayed objects
1612 getDisplayer()->SetToActivate( true );
1615 //================================================================
1616 // Function : createShapes
1617 // Purpose : Create applyed wire, and last segment from entry object
1618 //================================================================
1619 bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
1620 TopoDS_Shape& theApplyedWire,
1621 TopoDS_Shape& theLastSegment )
1623 TopoDS_Shape aShape;
1624 if ( !GEOMBase::GetShape( theObject, aShape ) ||
1625 aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
1628 if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() ||
1629 Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
1630 Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
1631 Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
1632 Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) {
1633 theApplyedWire = aShape;
1637 BRepBuilderAPI_MakeWire aBuilder;
1638 TopExp_Explorer anExp( aShape, TopAbs_EDGE );
1640 TopoDS_Shape anEdge = anExp.Current();
1642 if ( anExp.More() ) // i.e. non-last edge
1643 aBuilder.Add( TopoDS::Edge( anEdge ) );
1645 theLastSegment = anEdge;
1650 if ( aBuilder.IsDone() )
1651 theApplyedWire = aBuilder.Shape();
1656 //=================================================================================
1657 // function : keyPressEvent()
1659 //=================================================================================
1660 void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
1662 QDialog::keyPressEvent( e );
1663 if ( e->isAccepted() )
1666 if ( e->key() == Qt::Key_F1 ) {
1672 //=================================================================================
1673 // function : initSpinBox()
1675 //=================================================================================
1676 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
1677 double min, double max,
1678 double step, const char* quantity )
1680 // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
1681 // TODO: Think how to keep the single piece of code...
1683 // Obtain precision from preferences
1684 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1685 int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
1687 spinBox->setPrecision( aPrecision );
1688 spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
1689 // by default Qt rounds boundaries to 2 decimals at setRange
1690 spinBox->setRange( min, max );
1691 spinBox->setSingleStep( step );
1693 // Add a hint for the user saying how to tune precision
1694 QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
1695 spinBox->setProperty( "validity_tune_hint",
1696 QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
1699 //=================================================================================
1700 // function : SetDoubleSpinBoxStep()
1701 // purpose : Double spin box management
1702 //=================================================================================
1703 void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
1705 Group1Spin->SpinBox_DX->setSingleStep(step);
1706 Group2Spin->SpinBox_DX->setSingleStep(step);
1707 Group2Spin->SpinBox_DY->setSingleStep(step);
1708 Group3Spin->SpinBox_DX->setSingleStep(step);
1709 Group3Spin->SpinBox_DY->setSingleStep(step);
1710 Group3Spin->SpinBox_DZ->setSingleStep(step);
1711 Group4Spin->SpinBox_DZ->setSingleStep(step);
1713 // san: Do NOT override the step when a speicifc step value is used
1714 // in some input fields!
1715 //Group4Spin->SpinBox_DX->setSingleStep(step);
1716 //Group4Spin->SpinBox_DY->setSingleStep(step);
1717 //Group4Spin->SpinBox_DS->setSingleStep(step);
1720 //=================================================================================
1721 // function : FindLocalCS()
1722 // purpose : Find All Coordinates systems in study
1723 //=================================================================================
1724 void EntityGUI_SketcherDlg::FindLocalCS()
1728 SalomeApp_Application* app =
1729 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1733 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1737 _PTR(Study) aStudy = appStudy->studyDS();
1740 ComboBox1->addItem(tr("GEOM_GCS"));
1741 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
1742 gp_Dir aDirZ = gp_Dir(0, 0, 1);
1743 gp_Dir aDirX = gp_Dir(1, 0, 0);
1744 gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
1745 myLCSList.push_back(globalCS);
1747 // get GEOM component
1748 CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
1749 _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() );
1752 _PTR(SComponent) fc = obj->GetFatherComponent();
1753 QString geomComp = fc->GetID().c_str();
1754 _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
1758 // browse through all GEOM data tree
1759 _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
1760 for ( it->InitEx( true ); it->More(); it->Next() ) {
1761 _PTR(SObject) child( it->Value() );
1762 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
1763 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
1764 if( CORBA::is_nil( geomObj ) )
1766 if (geomObj->GetType() == GEOM_MARKER) {
1767 ComboBox1->addItem(geomObj->GetName());
1768 TopoDS_Shape aShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
1771 aLCS.Transform(aShape.Location().Transformation());
1772 if (aShape.ShapeType() == TopAbs_FACE) {
1773 Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
1774 if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
1775 Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
1776 gp_Pln aPln = aGPlane->Pln();
1777 aLCS = aPln.Position();
1780 myLCSList.push_back(aLCS);
1785 //=================================================================================
1786 // function : GetActiveLocalCS()
1787 // purpose : Get Working plane
1788 //=================================================================================
1789 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
1791 int ind = ComboBox1->currentIndex();
1793 return myGeometryGUI->GetWorkingPlane();
1795 gp_Ax3 aLCS = myLCSList.at(ind);
1800 //=================================================================================
1801 // function : ActivateLocalCS()
1802 // purpose : Activate & Fit Working plane
1803 //=================================================================================
1804 void EntityGUI_SketcherDlg::ActivateLocalCS()
1806 myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
1807 myGeometryGUI->ActiveWorkingPlane();