1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 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 // File : BasicGUI_MarkerDlg.cxx
23 // Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com)
26 #include "BasicGUI_MarkerDlg.h"
28 #include <GEOM_DlgRef.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 );
80 Group2 = new DlgRef_3Sel( centralWidget() );
82 Group2->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
83 Group2->TextLabel1->setText( tr( "GEOM_POINT" ) );
84 Group2->TextLabel2->setText( tr( "XDIR" ) );
85 Group2->TextLabel3->setText( tr( "YDIR" ) );
86 Group2->PushButton1->setIcon( iconSelect );
87 Group2->PushButton2->setIcon( iconSelect );
88 Group2->PushButton3->setIcon( iconSelect );
90 aMainGrp = new QFrame( centralWidget() );
91 aMainGrp->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
92 aMainGrp->setContentsMargins( 0, 0, 0, 0 );
93 QHBoxLayout* aMainGrpLayout = new QHBoxLayout( aMainGrp );
94 aMainGrpLayout->setMargin( 0 );
96 QGroupBox* anOriGrp = new QGroupBox( tr( "ORIGIN" ), aMainGrp );
97 QVBoxLayout* anOriGrpLayout = new QVBoxLayout( anOriGrp );
99 anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), anOriGrp ) );
100 myData[ X ] = new QDoubleSpinBox( anOriGrp );
101 anOriGrpLayout->addWidget( myData[ X ] );
102 anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), anOriGrp ) );
103 myData[ Y ] = new QDoubleSpinBox( anOriGrp );
104 anOriGrpLayout->addWidget( myData[ Y ] );
105 anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), anOriGrp ) );
106 myData[ Z ] = new QDoubleSpinBox( anOriGrp );
107 anOriGrpLayout->addWidget( myData[ Z ] );
109 aMainGrpLayout->addWidget( anOriGrp );
111 QGroupBox* aXAxisGrp = new QGroupBox( tr( "XDIR" ), aMainGrp );
112 QVBoxLayout* aXAxisGrpLayout = new QVBoxLayout( aXAxisGrp );
114 aXAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), aXAxisGrp ) );
115 myData[ DX1 ] = new QDoubleSpinBox( aXAxisGrp );
116 aXAxisGrpLayout->addWidget( myData[ DX1 ] );
117 aXAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), aXAxisGrp ) );
118 myData[ DY1 ] = new QDoubleSpinBox( aXAxisGrp );
119 aXAxisGrpLayout->addWidget( myData[ DY1 ] );
120 aXAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), aXAxisGrp ) );
121 myData[ DZ1 ] = new QDoubleSpinBox( aXAxisGrp );
122 aXAxisGrpLayout->addWidget( myData[ DZ1 ] );
124 aMainGrpLayout->addWidget( aXAxisGrp );
126 QGroupBox* anYAxisGrp = new QGroupBox( tr( "YDIR" ), aMainGrp );
127 QVBoxLayout* anYAxisGrpLayout = new QVBoxLayout( anYAxisGrp );
129 anYAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), anYAxisGrp ) );
130 myData[ DX2 ] = new QDoubleSpinBox( anYAxisGrp );
131 anYAxisGrpLayout->addWidget( myData[ DX2 ] );
132 anYAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), anYAxisGrp ) );
133 myData[ DY2 ] = new QDoubleSpinBox( anYAxisGrp );
134 anYAxisGrpLayout->addWidget( myData[ DY2 ] );
135 anYAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), anYAxisGrp ) );
136 myData[ DZ2 ] = new QDoubleSpinBox( anYAxisGrp );
137 anYAxisGrpLayout->addWidget( myData[ DZ2 ] );
139 aMainGrpLayout->addWidget( anYAxisGrp );
141 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
142 layout->setMargin( 0 ); layout->setSpacing( 6 );
143 layout->addWidget( aMainGrp );
144 layout->addWidget( Group1 );
145 layout->addWidget( Group2 );
147 setHelpFileName( "local_coordinate_system.htm" );
153 //=================================================================================
154 // function : ~BasicGUI_MarkerDlg()
155 // purpose : Destroys the object and frees any allocated resources
156 //=================================================================================
157 BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
162 //=================================================================================
165 //=================================================================================
166 void BasicGUI_MarkerDlg::Init()
168 myBlockPreview = false;
169 myConstructorId = -1;
170 myEditCurrentArgument = Group1->LineEdit1;
171 Group1->LineEdit1->setReadOnly( true );
172 Group2->LineEdit1->setReadOnly( true );
173 Group2->LineEdit2->setReadOnly( true );
174 Group2->LineEdit3->setReadOnly( true );
176 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
178 connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
179 connect( Group2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
180 connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
181 connect( Group2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
183 connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
184 connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
185 connect( Group2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
186 connect( Group2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
188 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
189 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
191 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() ) );
192 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() ) );
194 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
195 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
197 initName( tr( "LCS_NAME" ) );
199 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
200 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
202 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) {
203 initSpinBox( anIter.value(), COORD_MIN, COORD_MAX, step, 3 );
204 connect( anIter.value(), SIGNAL( valueChanged( double ) ),
205 this, SLOT( onValueChanged( double ) ) );
208 myBlockPreview = true;
209 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
210 anIter.value()->setValue( 0 );
211 myData[ DX1 ]->setValue( 1 );
212 myData[ DY2 ]->setValue( 1 );
213 myBlockPreview = false;
215 ConstructorsClicked( 0 );
220 QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()->
221 getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
223 VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>( aFrame );
226 aVTKFrame->AdjustTrihedrons( true );
230 OCCViewer_ViewFrame* aOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( aFrame );
232 aOCCFrame->AdjustTrihedrons( true );
236 //=================================================================================
237 // function : ConstructorsClicked()
238 // purpose : Radio button management
239 //=================================================================================
240 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
242 if ( myConstructorId == constructorId && myConstructorId == 0 ) {
243 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
244 activate( GEOM_MARKER );
249 myConstructorId = constructorId;
251 disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 );
253 switch ( constructorId ) {
259 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
260 activate( GEOM_MARKER );
269 globalSelection( GEOM_ALLGEOM );
270 myEditCurrentArgument = Group1->LineEdit1;
271 Group1->LineEdit1->setText( "" );
280 globalSelection( GEOM_POINT );
281 myEditCurrentArgument = Group2->LineEdit1;
282 Group2->LineEdit1->setText( "" );
283 Group2->LineEdit2->setText( "" );
284 Group2->LineEdit3->setText( "" );
289 qApp->processEvents();
291 resize( minimumSize() );
293 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
294 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
298 //=================================================================================
301 //=================================================================================
302 void BasicGUI_MarkerDlg::onOk()
308 //=================================================================================
309 // function : onApply()
311 //=================================================================================
312 bool BasicGUI_MarkerDlg::onApply()
318 ConstructorsClicked( getConstructorId() );
323 //=================================================================================
324 // function : onSelectionDone0()
325 // purpose : Reaction on selection when first method of creation is current one
326 //=================================================================================
327 void BasicGUI_MarkerDlg::onSelectionDone0()
329 if ( IObjectCount() == 1 ) {
330 Standard_Boolean aRes = Standard_False;
331 Handle(SALOME_InteractiveObject) anIO = firstIObject();
332 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
334 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
336 if ( aRes && !aSelectedObj->_is_nil() ) {
338 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
339 // Existing LCS selected
340 if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) {
341 TopoDS_Face aFace = TopoDS::Face( aShape );
342 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
344 if ( !aPlane.IsNull() ) {
345 gp_Ax3 anAx3 = aPlane->Pln().Position();
346 gp_Pnt aLoc = anAx3.Location();
347 gp_Dir aXDir = anAx3.XDirection();
348 gp_Dir aYDir = anAx3.YDirection();
350 myData[ X ]->setValue( aLoc.X() );
351 myData[ Y ]->setValue( aLoc.Y() );
352 myData[ Z ]->setValue( aLoc.Z() );
354 myData[ DX1 ]->setValue( aXDir.X() );
355 myData[ DY1 ]->setValue( aXDir.Y() );
356 myData[ DZ1 ]->setValue( aXDir.Z() );
358 myData[ DX2 ]->setValue( aYDir.X() );
359 myData[ DY2 ]->setValue( aYDir.Y() );
360 myData[ DZ2 ]->setValue( aYDir.Z() );
361 aSelMgr->clearSelected();
365 TColStd_IndexedMapOfInteger aMap;
366 aSelMgr->GetIndexes( anIO, aMap );
367 if ( aMap.Extent() == 1 ) {
368 int anIndex = aMap( 1 );
369 TopTools_IndexedMapOfShape aShapes;
370 TopExp::MapShapes( aShape, aShapes );
371 aShape = aShapes.FindKey( anIndex );
372 aSelMgr->clearSelected();
375 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
376 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
377 myData[ X ]->setValue( aPnt.X() );
378 myData[ Y ]->setValue( aPnt.Y() );
379 myData[ Z ]->setValue( aPnt.Z() );
390 //=================================================================================
391 // function : onSelectionDone()
392 // purpose : Called when selection as changed or other case
393 //=================================================================================
394 void BasicGUI_MarkerDlg::onSelectionDone()
396 if ( getConstructorId() == 0 ) {
401 myEditCurrentArgument->setText( "" );
404 if ( IObjectCount() == 1 ) {
405 Standard_Boolean aRes = Standard_False;
406 Handle(SALOME_InteractiveObject) anIO = firstIObject();
407 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
409 if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
410 aName = GEOMBase::GetName( aSelectedObj );
412 if ( getConstructorId() == 1 ) { // by shape position
413 // Get shape's position
414 CORBA::Double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz, Yx, Yy, Yz;
415 Ox = Oy = Oz = Zx = Zy = Xy = Xz = Yx = Yz = 0;
418 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
419 myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
420 aMeasureOp->GetPosition( aSelectedObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz );
422 // Calculate Y direction
423 if ( aMeasureOp->IsDone() ) {
424 gp_Pnt aPnt ( Ox, Oy, Oz );
425 gp_Dir aDirN ( Zx, Zy, Zz );
426 gp_Dir aDirX ( Xx, Xy, Xz );
427 gp_Ax3 anAx3 ( aPnt, aDirN, aDirX );
429 gp_Dir aDirY = anAx3.YDirection();
430 aDirY.Coord(Yx,Yy,Yz);
434 myData[ X ]->setValue( Ox );
435 myData[ Y ]->setValue( Oy );
436 myData[ Z ]->setValue( Oz );
438 myData[ DX1 ]->setValue( Xx );
439 myData[ DY1 ]->setValue( Xy );
440 myData[ DZ1 ]->setValue( Xz );
442 myData[ DX2 ]->setValue( Yx );
443 myData[ DY2 ]->setValue( Yy );
444 myData[ DZ2 ]->setValue( Yz );
446 myEditCurrentArgument->setText( aName );
448 else if ( getConstructorId() == 2 ) { // by point and two vectors
450 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
451 GEOM::short_array anIndexes;
453 TColStd_IndexedMapOfInteger aMap;
454 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
455 aSelMgr->GetIndexes( anIO, aMap );
457 if ( !aMap.IsEmpty() ) {
458 int anIndex = aMap( 1 );
459 TopTools_IndexedMapOfShape aShapes;
460 TopExp::MapShapes( aShape, aShapes );
461 aShape = aShapes.FindKey( anIndex );
464 if ( myEditCurrentArgument == Group2->LineEdit1 ) {
465 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
466 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
467 myData[ X ]->setValue( aPnt.X() );
468 myData[ Y ]->setValue( aPnt.Y() );
469 myData[ Z ]->setValue( aPnt.Z() );
470 myEditCurrentArgument->setText( aName );
473 myData[ X ]->setValue( 0 );
474 myData[ Y ]->setValue( 0 );
475 myData[ Z ]->setValue( 0 );
478 else if (myEditCurrentArgument == Group2->LineEdit2) {
479 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
480 gp_Pnt aP1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShape ) ) );
481 gp_Pnt aP2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShape ) ) );
482 gp_Dir aDir( gp_Vec( aP1, aP2 ) );
484 myData[ DX1 ]->setValue( aDir.X() );
485 myData[ DY1 ]->setValue( aDir.Y() );
486 myData[ DZ1 ]->setValue( aDir.Z() );
487 myEditCurrentArgument->setText( aName );
490 myData[ DX1 ]->setValue( 0 );
491 myData[ DY1 ]->setValue( 0 );
492 myData[ DZ1 ]->setValue( 0 );
495 else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
496 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
497 gp_Pnt aP1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShape ) ) );
498 gp_Pnt aP2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShape ) ) );
499 gp_Dir aDir(gp_Vec( aP1, aP2 ));
501 myData[ DX2 ]->setValue( aDir.X() );
502 myData[ DY2 ]->setValue( aDir.Y() );
503 myData[ DZ2 ]->setValue( aDir.Z() );
504 myEditCurrentArgument->setText( aName );
507 myData[ DX2 ]->setValue( 0 );
508 myData[ DY2 ]->setValue( 0 );
509 myData[ DZ2 ]->setValue( 0 );
517 if ( getConstructorId() == 1 ) {
518 myData[ X ]->setValue( 0 );
519 myData[ Y ]->setValue( 0 );
520 myData[ Z ]->setValue( 0 );
522 myData[ DX1 ]->setValue( 0 );
523 myData[ DY1 ]->setValue( 0 );
524 myData[ DZ1 ]->setValue( 0 );
526 myData[ DX2 ]->setValue( 0 );
527 myData[ DY2 ]->setValue( 0 );
528 myData[ DZ2 ]->setValue( 0 );
530 else if ( getConstructorId() == 2 ) {
531 if ( myEditCurrentArgument == Group2->LineEdit1 ) {
532 myData[ X ]->setValue( 0 );
533 myData[ Y ]->setValue( 0 );
534 myData[ Z ]->setValue( 0 );
536 else if ( myEditCurrentArgument == Group2->LineEdit2 ) {
537 myData[ DX1 ]->setValue( 0 );
538 myData[ DY1 ]->setValue( 0 );
539 myData[ DZ1 ]->setValue( 0 );
541 else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
542 myData[ DX2 ]->setValue( 0 );
543 myData[ DY2 ]->setValue( 0 );
544 myData[ DZ2 ]->setValue( 0 );
552 //=================================================================================
553 // function : SetEditCurrentArgument()
555 //=================================================================================
556 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
558 QPushButton* send = (QPushButton*)sender();
560 if ( send == Group1->PushButton1 ) {
561 myEditCurrentArgument = Group1->LineEdit1;
562 globalSelection( GEOM_ALLGEOM );
564 else if ( send == Group2->PushButton1 ) {
565 myEditCurrentArgument = Group2->LineEdit1;
566 globalSelection( GEOM_POINT );
568 else if ( send == Group2->PushButton2 ) {
569 myEditCurrentArgument = Group2->LineEdit2;
570 globalSelection( GEOM_LINE );
572 else if ( send == Group2->PushButton3 ) {
573 myEditCurrentArgument = Group2->LineEdit3;
574 globalSelection( GEOM_LINE );
577 myEditCurrentArgument->setFocus();
581 //=================================================================================
582 // function : LineEditReturnPressed()
584 //=================================================================================
585 void BasicGUI_MarkerDlg::LineEditReturnPressed()
587 QLineEdit* send = (QLineEdit*)sender();
589 myEditCurrentArgument = send;
590 GEOMBase_Skeleton::LineEditReturnPressed();
593 //=================================================================================
594 // function : onActivate()
596 //=================================================================================
597 void BasicGUI_MarkerDlg::onActivate()
599 GEOMBase_Skeleton::ActivateThisDialog();
600 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
601 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
603 ConstructorsClicked( getConstructorId() );
606 //=================================================================================
607 // function : onDeactivate()
608 // purpose : public slot to deactivate if active
609 //=================================================================================
610 void BasicGUI_MarkerDlg::onDeactivate()
612 GEOMBase_Skeleton::DeactivateActiveDialog();
615 //=================================================================================
616 // function : enterEvent()
618 //=================================================================================
619 void BasicGUI_MarkerDlg::enterEvent( QEvent* )
621 if ( !mainFrame()->GroupConstructors->isEnabled() )
625 //=================================================================================
626 // function : createOperation
628 //=================================================================================
629 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
631 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
634 //=================================================================================
635 // function : isValid
637 //=================================================================================
638 bool BasicGUI_MarkerDlg::isValid( QString& msg )
640 const int id = getConstructorId();
641 gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
642 v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
645 // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
646 // Vectors shouldn't be checked for being orthogonal here!
647 if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
648 isOk = !v1.IsParallel( v2, Precision::Angular() );
650 msg += tr( "VEC_PARALLEL" );
657 return !Group1->LineEdit1->text().isEmpty() && isOk;
659 return !Group2->LineEdit1->text().isEmpty() &&
660 !Group2->LineEdit2->text().isEmpty() &&
661 !Group2->LineEdit3->text().isEmpty() && isOk;
666 //=================================================================================
667 // function : execute
669 //=================================================================================
670 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
672 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow(
673 getOperation() )->MakeMarker( myData[ X ]->value(), myData[ Y ]->value(), myData[ Z ]->value(),
674 myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value(),
675 myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
677 if ( !anObj->_is_nil() )
678 objects.push_back( anObj._retn() );
683 //=================================================================================
684 // function : closeEvent
686 //=================================================================================
687 void BasicGUI_MarkerDlg::closeEvent( QCloseEvent* e )
689 GEOMBase_Skeleton::closeEvent( e );
692 //=================================================================================
693 // function : onValueChanged
695 //=================================================================================
696 void BasicGUI_MarkerDlg::onValueChanged( double )
701 //=================================================================================
702 // function : displayPreview
704 //=================================================================================
705 void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
707 const bool toRemoveFromEngine,
708 const double lineWidth )
710 if ( !myBlockPreview ) {
711 GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
712 if ( myConstructorId == 0 )
713 GEOMBase_Skeleton::activate( GEOM_MARKER );