1 // Copyright (C) 2007-2008 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
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : BasicGUI_MarkerDlg.cxx
24 // Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com)
26 #include "BasicGUI_MarkerDlg.h"
29 #include <GeometryGUI.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Session.h>
34 #include <SalomeApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
39 #include <GEOMImpl_Types.hxx>
42 #include <BRep_Tool.hxx>
46 #include <TopoDS_Vertex.hxx>
47 #include <TopoDS_Face.hxx>
48 #include <Geom_Plane.hxx>
49 #include <TopTools_IndexedMapOfShape.hxx>
50 #include <TColStd_IndexedMapOfInteger.hxx>
54 //=================================================================================
55 // class : BasicGUI_MarkerDlg()
56 // purpose : Constructor
57 //=================================================================================
58 BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* theParent )
59 : GEOMBase_Skeleton( theGeometryGUI, theParent, false,
60 Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
62 QPixmap iconCS1 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER" ) ) );
63 QPixmap iconCS2 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER2" ) ) );
64 QPixmap iconCS3 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER3" ) ) );
65 QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
67 setWindowTitle( tr( "CAPTION" ) );
69 mainFrame()->GroupConstructors->setTitle( tr( "LOCALCS" ) );
70 mainFrame()->RadioButton1->setIcon( iconCS1 );
71 mainFrame()->RadioButton2->setIcon( iconCS2 );
72 mainFrame()->RadioButton3->setIcon( iconCS3 );
74 Group1 = new DlgRef_1Sel( centralWidget() );
76 Group1->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
77 Group1->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
78 Group1->PushButton1->setIcon( iconSelect );
79 Group1->PushButton1->setDown( true );
81 Group2 = new DlgRef_3Sel( centralWidget() );
83 Group2->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
84 Group2->TextLabel1->setText( tr( "GEOM_POINT" ) );
85 Group2->TextLabel2->setText( tr( "XDIR" ) );
86 Group2->TextLabel3->setText( tr( "YDIR" ) );
87 Group2->PushButton1->setIcon( iconSelect );
88 Group2->PushButton2->setIcon( iconSelect );
89 Group2->PushButton3->setIcon( iconSelect );
90 Group2->PushButton1->setDown( true );
92 aMainGrp = new QFrame( centralWidget() );
93 aMainGrp->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
94 aMainGrp->setContentsMargins( 0, 0, 0, 0 );
95 QHBoxLayout* aMainGrpLayout = new QHBoxLayout( aMainGrp );
96 aMainGrpLayout->setMargin( 0 );
98 QGroupBox* anOriGrp = new QGroupBox( tr( "ORIGIN" ), aMainGrp );
99 QVBoxLayout* anOriGrpLayout = new QVBoxLayout( anOriGrp );
101 anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), anOriGrp ) );
102 myData[ X ] = new SalomeApp_DoubleSpinBox( anOriGrp );
103 anOriGrpLayout->addWidget( myData[ X ] );
104 anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), anOriGrp ) );
105 myData[ Y ] = new SalomeApp_DoubleSpinBox( anOriGrp );
106 anOriGrpLayout->addWidget( myData[ Y ] );
107 anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), anOriGrp ) );
108 myData[ Z ] = new SalomeApp_DoubleSpinBox( anOriGrp );
109 anOriGrpLayout->addWidget( myData[ Z ] );
111 aMainGrpLayout->addWidget( anOriGrp );
113 QGroupBox* aXAxisGrp = new QGroupBox( tr( "XDIR" ), aMainGrp );
114 QVBoxLayout* aXAxisGrpLayout = new QVBoxLayout( aXAxisGrp );
116 aXAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), aXAxisGrp ) );
117 myData[ DX1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
118 aXAxisGrpLayout->addWidget( myData[ DX1 ] );
119 aXAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), aXAxisGrp ) );
120 myData[ DY1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
121 aXAxisGrpLayout->addWidget( myData[ DY1 ] );
122 aXAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), aXAxisGrp ) );
123 myData[ DZ1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
124 aXAxisGrpLayout->addWidget( myData[ DZ1 ] );
126 aMainGrpLayout->addWidget( aXAxisGrp );
128 QGroupBox* anYAxisGrp = new QGroupBox( tr( "YDIR" ), aMainGrp );
129 QVBoxLayout* anYAxisGrpLayout = new QVBoxLayout( anYAxisGrp );
131 anYAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), anYAxisGrp ) );
132 myData[ DX2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
133 anYAxisGrpLayout->addWidget( myData[ DX2 ] );
134 anYAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), anYAxisGrp ) );
135 myData[ DY2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
136 anYAxisGrpLayout->addWidget( myData[ DY2 ] );
137 anYAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), anYAxisGrp ) );
138 myData[ DZ2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
139 anYAxisGrpLayout->addWidget( myData[ DZ2 ] );
141 aMainGrpLayout->addWidget( anYAxisGrp );
143 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
144 layout->setMargin( 0 ); layout->setSpacing( 6 );
145 layout->addWidget( aMainGrp );
146 layout->addWidget( Group1 );
147 layout->addWidget( Group2 );
149 setHelpFileName( "create_lcs_page.html" );
155 //=================================================================================
156 // function : ~BasicGUI_MarkerDlg()
157 // purpose : Destroys the object and frees any allocated resources
158 //=================================================================================
159 BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
164 //=================================================================================
167 //=================================================================================
168 void BasicGUI_MarkerDlg::Init()
170 myBlockPreview = false;
171 myConstructorId = -1;
172 myEditCurrentArgument = Group1->LineEdit1;
173 Group1->LineEdit1->setReadOnly( true );
174 Group2->LineEdit1->setReadOnly( true );
175 Group2->LineEdit2->setReadOnly( true );
176 Group2->LineEdit3->setReadOnly( true );
177 Group2->LineEdit1->setEnabled( true );
178 Group2->LineEdit2->setEnabled( false );
179 Group2->LineEdit3->setEnabled( false );
181 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
183 connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
184 connect( Group2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
185 connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
186 connect( Group2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
188 connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
189 connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
190 connect( Group2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
191 connect( Group2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
193 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
194 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
196 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() ) );
197 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() ) );
199 connect( myGeomGUI->getApp()->selectionMgr(),
200 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
202 initName( tr( "LCS_NAME" ) );
204 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
205 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
207 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) {
208 initSpinBox( anIter.value(), COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
209 connect( anIter.value(), SIGNAL( valueChanged( double ) ),
210 this, SLOT( onValueChanged( double ) ) );
213 myBlockPreview = true;
214 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
215 anIter.value()->setValue( 0 );
216 myData[ DX1 ]->setValue( 1 );
217 myData[ DY2 ]->setValue( 1 );
218 myBlockPreview = false;
220 ConstructorsClicked( 0 );
225 QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()->
226 getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
228 VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>( aFrame );
231 aVTKFrame->AdjustTrihedrons( true );
235 OCCViewer_ViewFrame* aOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( aFrame );
237 aOCCFrame->AdjustTrihedrons( true );
241 //=================================================================================
242 // function : ConstructorsClicked()
243 // purpose : Radio button management
244 //=================================================================================
245 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
247 if ( myConstructorId == constructorId && myConstructorId == 0 ) {
248 globalSelection(); // close local contexts, if any
249 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
250 activate( GEOM_MARKER );
255 myConstructorId = constructorId;
257 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
259 switch ( constructorId ) {
265 globalSelection(); // close local contexts, if any
266 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
267 activate( GEOM_MARKER );
275 Group1->PushButton1->setDown( true );
276 globalSelection( GEOM_ALLGEOM );
277 myEditCurrentArgument = Group1->LineEdit1;
278 Group1->LineEdit1->setText( "" );
286 Group2->PushButton1->setDown( true );
287 Group2->PushButton2->setDown( false );
288 Group2->PushButton3->setDown( false );
289 globalSelection(); // close local contexts, if any
290 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
291 myEditCurrentArgument = Group2->LineEdit1;
292 Group2->LineEdit1->setText( "" );
293 Group2->LineEdit2->setText( "" );
294 Group2->LineEdit3->setText( "" );
295 Group2->LineEdit1->setEnabled( true );
296 Group2->LineEdit2->setEnabled( false );
297 Group2->LineEdit3->setEnabled( false );
302 qApp->processEvents();
304 resize( minimumSizeHint() );
306 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
307 this, SLOT( onSelectionDone() ) );
311 //=================================================================================
314 //=================================================================================
315 void BasicGUI_MarkerDlg::onOk()
321 //=================================================================================
322 // function : onApply()
324 //=================================================================================
325 bool BasicGUI_MarkerDlg::onApply()
331 ConstructorsClicked( getConstructorId() );
336 //=================================================================================
337 // function : onSelectionDone0()
338 // purpose : Reaction on selection when first method of creation is current one
339 //=================================================================================
340 void BasicGUI_MarkerDlg::onSelectionDone0()
342 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
343 SALOME_ListIO aSelList;
344 aSelMgr->selectedObjects(aSelList);
346 if (aSelList.Extent() == 1) {
347 Standard_Boolean aRes = Standard_False;
348 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
349 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
351 if ( aRes && !aSelectedObj->_is_nil() ) {
353 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
354 // Existing LCS selected
355 if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) {
356 TopoDS_Face aFace = TopoDS::Face( aShape );
357 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
359 if ( !aPlane.IsNull() ) {
360 gp_Ax3 anAx3 = aPlane->Pln().Position();
361 gp_Pnt aLoc = anAx3.Location();
362 gp_Dir aXDir = anAx3.XDirection();
363 gp_Dir aYDir = anAx3.YDirection();
365 myData[ X ]->setValue( aLoc.X() );
366 myData[ Y ]->setValue( aLoc.Y() );
367 myData[ Z ]->setValue( aLoc.Z() );
369 myData[ DX1 ]->setValue( aXDir.X() );
370 myData[ DY1 ]->setValue( aXDir.Y() );
371 myData[ DZ1 ]->setValue( aXDir.Z() );
373 myData[ DX2 ]->setValue( aYDir.X() );
374 myData[ DY2 ]->setValue( aYDir.Y() );
375 myData[ DZ2 ]->setValue( aYDir.Z() );
376 aSelMgr->clearSelected();
380 TColStd_IndexedMapOfInteger aMap;
381 aSelMgr->GetIndexes( anIO, aMap );
382 if ( aMap.Extent() == 1 ) { // Local Selection
383 int anIndex = aMap( 1 );
384 TopTools_IndexedMapOfShape aShapes;
385 TopExp::MapShapes( aShape, aShapes );
386 aShape = aShapes.FindKey( anIndex );
387 aSelMgr->clearSelected(); // ???
390 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
391 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
392 myData[ X ]->setValue( aPnt.X() );
393 myData[ Y ]->setValue( aPnt.Y() );
394 myData[ Z ]->setValue( aPnt.Z() );
405 //=================================================================================
406 // function : onSelectionDone()
407 // purpose : Called when selection as changed or other case
408 //=================================================================================
409 void BasicGUI_MarkerDlg::onSelectionDone()
411 if ( getConstructorId() == 0 ) {
416 myEditCurrentArgument->setText( "" );
418 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
419 SALOME_ListIO aSelList;
420 aSelMgr->selectedObjects(aSelList);
422 if (aSelList.Extent() == 1) {
423 Standard_Boolean aRes = Standard_False;
424 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
425 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
427 if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
428 QString aName = GEOMBase::GetName( aSelectedObj );
430 if ( getConstructorId() == 1 ) { // by shape position
431 // Get shape's position
432 CORBA::Double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz, Yx, Yy, Yz;
433 Ox = Oy = Oz = Zx = Zy = Xy = Xz = Yx = Yz = 0;
436 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
437 myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
438 aMeasureOp->GetPosition( aSelectedObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz );
440 // Calculate Y direction
441 if ( aMeasureOp->IsDone() ) {
442 gp_Pnt aPnt ( Ox, Oy, Oz );
443 gp_Dir aDirN ( Zx, Zy, Zz );
444 gp_Dir aDirX ( Xx, Xy, Xz );
445 gp_Ax3 anAx3 ( aPnt, aDirN, aDirX );
447 gp_Dir aDirY = anAx3.YDirection();
448 aDirY.Coord(Yx,Yy,Yz);
452 myData[ X ]->setValue( Ox );
453 myData[ Y ]->setValue( Oy );
454 myData[ Z ]->setValue( Oz );
456 myData[ DX1 ]->setValue( Xx );
457 myData[ DY1 ]->setValue( Xy );
458 myData[ DZ1 ]->setValue( Xz );
460 myData[ DX2 ]->setValue( Yx );
461 myData[ DY2 ]->setValue( Yy );
462 myData[ DZ2 ]->setValue( Yz );
464 myEditCurrentArgument->setText( aName );
466 else if ( getConstructorId() == 2 ) { // by point and two vectors
468 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
469 TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
470 if ( myEditCurrentArgument == Group2->LineEdit1 )
471 aNeedType = TopAbs_VERTEX;
473 TColStd_IndexedMapOfInteger aMap;
474 aSelMgr->GetIndexes( anIO, aMap );
476 if ( !aMap.IsEmpty() ) {
477 int anIndex = aMap( 1 );
478 if ( aNeedType == TopAbs_EDGE )
479 aName += QString( "_edge_%1" ).arg( anIndex );
481 aName += QString( "_vertex_%1" ).arg( anIndex );
483 TopTools_IndexedMapOfShape aShapes;
484 TopExp::MapShapes( aShape, aShapes );
485 aShape = aShapes.FindKey( anIndex );
488 if ( myEditCurrentArgument == Group2->LineEdit1 ) {
489 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
490 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
491 myData[ X ]->setValue( aPnt.X() );
492 myData[ Y ]->setValue( aPnt.Y() );
493 myData[ Z ]->setValue( aPnt.Z() );
494 myEditCurrentArgument->setText( aName );
495 if (Group2->LineEdit2->text() == "")
496 Group2->PushButton2->click();
499 myData[ X ]->setValue( 0 );
500 myData[ Y ]->setValue( 0 );
501 myData[ Z ]->setValue( 0 );
504 else if (myEditCurrentArgument == Group2->LineEdit2) {
505 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
506 gp_Pnt aP1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShape ) ) );
507 gp_Pnt aP2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShape ) ) );
508 gp_Dir aDir( gp_Vec( aP1, aP2 ) );
510 myData[ DX1 ]->setValue( aDir.X() );
511 myData[ DY1 ]->setValue( aDir.Y() );
512 myData[ DZ1 ]->setValue( aDir.Z() );
513 myEditCurrentArgument->setText( aName );
514 if (Group2->LineEdit3->text() == "")
515 Group2->PushButton3->click();
518 myData[ DX1 ]->setValue( 0 );
519 myData[ DY1 ]->setValue( 0 );
520 myData[ DZ1 ]->setValue( 0 );
523 else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
524 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
525 gp_Pnt aP1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShape ) ) );
526 gp_Pnt aP2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShape ) ) );
527 gp_Dir aDir(gp_Vec( aP1, aP2 ));
529 myData[ DX2 ]->setValue( aDir.X() );
530 myData[ DY2 ]->setValue( aDir.Y() );
531 myData[ DZ2 ]->setValue( aDir.Z() );
532 myEditCurrentArgument->setText( aName );
533 if (Group2->LineEdit1->text() == "")
534 Group2->PushButton1->click();
537 myData[ DX2 ]->setValue( 0 );
538 myData[ DY2 ]->setValue( 0 );
539 myData[ DZ2 ]->setValue( 0 );
547 if ( getConstructorId() == 1 ) {
548 myData[ X ]->setValue( 0 );
549 myData[ Y ]->setValue( 0 );
550 myData[ Z ]->setValue( 0 );
552 myData[ DX1 ]->setValue( 0 );
553 myData[ DY1 ]->setValue( 0 );
554 myData[ DZ1 ]->setValue( 0 );
556 myData[ DX2 ]->setValue( 0 );
557 myData[ DY2 ]->setValue( 0 );
558 myData[ DZ2 ]->setValue( 0 );
560 else if ( getConstructorId() == 2 ) {
561 if ( myEditCurrentArgument == Group2->LineEdit1 ) {
562 myData[ X ]->setValue( 0 );
563 myData[ Y ]->setValue( 0 );
564 myData[ Z ]->setValue( 0 );
566 else if ( myEditCurrentArgument == Group2->LineEdit2 ) {
567 myData[ DX1 ]->setValue( 0 );
568 myData[ DY1 ]->setValue( 0 );
569 myData[ DZ1 ]->setValue( 0 );
571 else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
572 myData[ DX2 ]->setValue( 0 );
573 myData[ DY2 ]->setValue( 0 );
574 myData[ DZ2 ]->setValue( 0 );
582 //=================================================================================
583 // function : SetEditCurrentArgument()
585 //=================================================================================
586 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
588 QPushButton* send = (QPushButton*)sender();
589 globalSelection(); // close local contexts, if any
591 if ( send == Group1->PushButton1 ) {
592 myEditCurrentArgument = Group1->LineEdit1;
593 globalSelection( GEOM_ALLGEOM );
595 else if ( send == Group2->PushButton1 ) {
596 myEditCurrentArgument = Group2->LineEdit1;
597 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
598 Group2->PushButton2->setDown( false );
599 Group2->PushButton3->setDown( false );
600 Group2->LineEdit1->setEnabled( true );
601 Group2->LineEdit2->setEnabled( false );
602 Group2->LineEdit3->setEnabled( false );
604 else if ( send == Group2->PushButton2 ) {
605 myEditCurrentArgument = Group2->LineEdit2;
606 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
607 Group2->PushButton1->setDown( false );
608 Group2->PushButton3->setDown( false );
609 Group2->LineEdit1->setEnabled( false );
610 Group2->LineEdit2->setEnabled( true );
611 Group2->LineEdit3->setEnabled( false );
613 else if ( send == Group2->PushButton3 ) {
614 myEditCurrentArgument = Group2->LineEdit3;
615 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
616 Group2->PushButton1->setDown( false );
617 Group2->PushButton2->setDown( false );
618 Group2->LineEdit1->setEnabled( false );
619 Group2->LineEdit2->setEnabled( false );
620 Group2->LineEdit3->setEnabled( true );
623 myEditCurrentArgument->setFocus();
628 //=================================================================================
629 // function : LineEditReturnPressed()
631 //=================================================================================
632 void BasicGUI_MarkerDlg::LineEditReturnPressed()
634 QLineEdit* send = (QLineEdit*)sender();
636 myEditCurrentArgument = send;
637 GEOMBase_Skeleton::LineEditReturnPressed();
640 //=================================================================================
641 // function : onActivate()
643 //=================================================================================
644 void BasicGUI_MarkerDlg::onActivate()
646 GEOMBase_Skeleton::ActivateThisDialog();
647 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
648 this, SLOT( onSelectionDone() ) );
650 ConstructorsClicked( getConstructorId() );
653 //=================================================================================
654 // function : onDeactivate()
655 // purpose : public slot to deactivate if active
656 //=================================================================================
657 void BasicGUI_MarkerDlg::onDeactivate()
659 GEOMBase_Skeleton::DeactivateActiveDialog();
662 //=================================================================================
663 // function : enterEvent()
665 //=================================================================================
666 void BasicGUI_MarkerDlg::enterEvent( QEvent* )
668 if ( !mainFrame()->GroupConstructors->isEnabled() )
672 //=================================================================================
673 // function : createOperation
675 //=================================================================================
676 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
678 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
681 //=================================================================================
682 // function : isValid
684 //=================================================================================
685 bool BasicGUI_MarkerDlg::isValid( QString& msg )
687 const int id = getConstructorId();
688 gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
689 v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
692 // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
693 // Vectors shouldn't be checked for being orthogonal here!
694 if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
695 isOk = !v1.IsParallel( v2, Precision::Angular() );
697 msg += tr( "VEC_PARALLEL" );
703 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
704 ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
708 return !Group1->LineEdit1->text().isEmpty() && isOk;
710 return !Group2->LineEdit1->text().isEmpty() &&
711 !Group2->LineEdit2->text().isEmpty() &&
712 !Group2->LineEdit3->text().isEmpty() && isOk;
717 //=================================================================================
718 // function : execute
720 //=================================================================================
721 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
723 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
724 GEOM::GEOM_Object_var anObj = anOper->MakeMarker( myData[ X ]->value(),
725 myData[ Y ]->value(),
726 myData[ Z ]->value(),
727 myData[ DX1 ]->value(),
728 myData[ DY1 ]->value(),
729 myData[ DZ1 ]->value(),
730 myData[ DX2 ]->value(),
731 myData[ DY2 ]->value(),
732 myData[ DZ2 ]->value() );
733 QStringList aParameters;
734 aParameters<<myData[X]->text();
735 aParameters<<myData[Y]->text();
736 aParameters<<myData[Z]->text();
737 aParameters<<myData[ DX1 ]->text();
738 aParameters<<myData[ DY1 ]->text();
739 aParameters<<myData[ DZ1 ]->text();
740 aParameters<<myData[ DX2 ]->text();
741 aParameters<<myData[ DY2 ]->text();
742 aParameters<<myData[ DZ2 ]->text();
744 if ( !anObj->_is_nil() ) {
746 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
747 objects.push_back( anObj._retn() );
753 //=================================================================================
754 // function : onValueChanged
756 //=================================================================================
757 void BasicGUI_MarkerDlg::onValueChanged( double )
762 //=================================================================================
763 // function : displayPreview
765 //=================================================================================
766 void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
768 const bool toRemoveFromEngine,
769 const double lineWidth )
771 if ( !myBlockPreview ) {
772 GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
773 if ( myConstructorId == 0 )
774 GEOMBase_Skeleton::activate( GEOM_MARKER );