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"
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( "create_lcs_page.html" );
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( myGeomGUI->getApp()->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 ); // VSR: TODO: DBL_DIGITS_DISPLAY
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 globalSelection(); // close local contexts, if any
244 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
245 activate( GEOM_MARKER );
250 myConstructorId = constructorId;
252 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
254 switch ( constructorId ) {
260 globalSelection(); // close local contexts, if any
261 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
262 activate( GEOM_MARKER );
271 globalSelection( GEOM_ALLGEOM );
272 myEditCurrentArgument = Group1->LineEdit1;
273 Group1->LineEdit1->setText( "" );
282 globalSelection(); // close local contexts, if any
283 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
284 myEditCurrentArgument = Group2->LineEdit1;
285 Group2->LineEdit1->setText( "" );
286 Group2->LineEdit2->setText( "" );
287 Group2->LineEdit3->setText( "" );
292 qApp->processEvents();
294 resize( minimumSize() );
296 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
297 this, SLOT( onSelectionDone() ) );
301 //=================================================================================
304 //=================================================================================
305 void BasicGUI_MarkerDlg::onOk()
311 //=================================================================================
312 // function : onApply()
314 //=================================================================================
315 bool BasicGUI_MarkerDlg::onApply()
321 ConstructorsClicked( getConstructorId() );
326 //=================================================================================
327 // function : onSelectionDone0()
328 // purpose : Reaction on selection when first method of creation is current one
329 //=================================================================================
330 void BasicGUI_MarkerDlg::onSelectionDone0()
332 if ( IObjectCount() == 1 ) {
333 Standard_Boolean aRes = Standard_False;
334 Handle(SALOME_InteractiveObject) anIO = firstIObject();
335 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
337 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
339 if ( aRes && !aSelectedObj->_is_nil() ) {
341 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
342 // Existing LCS selected
343 if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) {
344 TopoDS_Face aFace = TopoDS::Face( aShape );
345 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
347 if ( !aPlane.IsNull() ) {
348 gp_Ax3 anAx3 = aPlane->Pln().Position();
349 gp_Pnt aLoc = anAx3.Location();
350 gp_Dir aXDir = anAx3.XDirection();
351 gp_Dir aYDir = anAx3.YDirection();
353 myData[ X ]->setValue( aLoc.X() );
354 myData[ Y ]->setValue( aLoc.Y() );
355 myData[ Z ]->setValue( aLoc.Z() );
357 myData[ DX1 ]->setValue( aXDir.X() );
358 myData[ DY1 ]->setValue( aXDir.Y() );
359 myData[ DZ1 ]->setValue( aXDir.Z() );
361 myData[ DX2 ]->setValue( aYDir.X() );
362 myData[ DY2 ]->setValue( aYDir.Y() );
363 myData[ DZ2 ]->setValue( aYDir.Z() );
364 aSelMgr->clearSelected();
368 TColStd_IndexedMapOfInteger aMap;
369 aSelMgr->GetIndexes( anIO, aMap );
370 if ( aMap.Extent() == 1 ) { // Local Selection
371 int anIndex = aMap( 1 );
372 TopTools_IndexedMapOfShape aShapes;
373 TopExp::MapShapes( aShape, aShapes );
374 aShape = aShapes.FindKey( anIndex );
375 aSelMgr->clearSelected(); // ???
378 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
379 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
380 myData[ X ]->setValue( aPnt.X() );
381 myData[ Y ]->setValue( aPnt.Y() );
382 myData[ Z ]->setValue( aPnt.Z() );
393 //=================================================================================
394 // function : onSelectionDone()
395 // purpose : Called when selection as changed or other case
396 //=================================================================================
397 void BasicGUI_MarkerDlg::onSelectionDone()
399 if ( getConstructorId() == 0 ) {
404 myEditCurrentArgument->setText( "" );
406 if ( IObjectCount() == 1 ) {
407 Standard_Boolean aRes = Standard_False;
408 Handle(SALOME_InteractiveObject) anIO = firstIObject();
409 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
411 if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
412 QString aName = GEOMBase::GetName( aSelectedObj );
414 if ( getConstructorId() == 1 ) { // by shape position
415 // Get shape's position
416 CORBA::Double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz, Yx, Yy, Yz;
417 Ox = Oy = Oz = Zx = Zy = Xy = Xz = Yx = Yz = 0;
420 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
421 myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
422 aMeasureOp->GetPosition( aSelectedObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz );
424 // Calculate Y direction
425 if ( aMeasureOp->IsDone() ) {
426 gp_Pnt aPnt ( Ox, Oy, Oz );
427 gp_Dir aDirN ( Zx, Zy, Zz );
428 gp_Dir aDirX ( Xx, Xy, Xz );
429 gp_Ax3 anAx3 ( aPnt, aDirN, aDirX );
431 gp_Dir aDirY = anAx3.YDirection();
432 aDirY.Coord(Yx,Yy,Yz);
436 myData[ X ]->setValue( Ox );
437 myData[ Y ]->setValue( Oy );
438 myData[ Z ]->setValue( Oz );
440 myData[ DX1 ]->setValue( Xx );
441 myData[ DY1 ]->setValue( Xy );
442 myData[ DZ1 ]->setValue( Xz );
444 myData[ DX2 ]->setValue( Yx );
445 myData[ DY2 ]->setValue( Yy );
446 myData[ DZ2 ]->setValue( Yz );
448 myEditCurrentArgument->setText( aName );
450 else if ( getConstructorId() == 2 ) { // by point and two vectors
452 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
453 TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
454 if ( myEditCurrentArgument == Group2->LineEdit1 )
455 aNeedType = TopAbs_VERTEX;
457 TColStd_IndexedMapOfInteger aMap;
458 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
459 aSelMgr->GetIndexes( anIO, aMap );
461 if ( !aMap.IsEmpty() ) {
462 int anIndex = aMap( 1 );
463 if ( aNeedType == TopAbs_EDGE )
464 aName += QString( "_edge_%1" ).arg( anIndex );
466 aName += QString( "_vertex_%1" ).arg( anIndex );
468 TopTools_IndexedMapOfShape aShapes;
469 TopExp::MapShapes( aShape, aShapes );
470 aShape = aShapes.FindKey( anIndex );
473 if ( myEditCurrentArgument == Group2->LineEdit1 ) {
474 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
475 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
476 myData[ X ]->setValue( aPnt.X() );
477 myData[ Y ]->setValue( aPnt.Y() );
478 myData[ Z ]->setValue( aPnt.Z() );
479 myEditCurrentArgument->setText( aName );
482 myData[ X ]->setValue( 0 );
483 myData[ Y ]->setValue( 0 );
484 myData[ Z ]->setValue( 0 );
487 else if (myEditCurrentArgument == Group2->LineEdit2) {
488 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
489 gp_Pnt aP1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShape ) ) );
490 gp_Pnt aP2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShape ) ) );
491 gp_Dir aDir( gp_Vec( aP1, aP2 ) );
493 myData[ DX1 ]->setValue( aDir.X() );
494 myData[ DY1 ]->setValue( aDir.Y() );
495 myData[ DZ1 ]->setValue( aDir.Z() );
496 myEditCurrentArgument->setText( aName );
499 myData[ DX1 ]->setValue( 0 );
500 myData[ DY1 ]->setValue( 0 );
501 myData[ DZ1 ]->setValue( 0 );
504 else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
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[ DX2 ]->setValue( aDir.X() );
511 myData[ DY2 ]->setValue( aDir.Y() );
512 myData[ DZ2 ]->setValue( aDir.Z() );
513 myEditCurrentArgument->setText( aName );
516 myData[ DX2 ]->setValue( 0 );
517 myData[ DY2 ]->setValue( 0 );
518 myData[ DZ2 ]->setValue( 0 );
526 if ( getConstructorId() == 1 ) {
527 myData[ X ]->setValue( 0 );
528 myData[ Y ]->setValue( 0 );
529 myData[ Z ]->setValue( 0 );
531 myData[ DX1 ]->setValue( 0 );
532 myData[ DY1 ]->setValue( 0 );
533 myData[ DZ1 ]->setValue( 0 );
535 myData[ DX2 ]->setValue( 0 );
536 myData[ DY2 ]->setValue( 0 );
537 myData[ DZ2 ]->setValue( 0 );
539 else if ( getConstructorId() == 2 ) {
540 if ( myEditCurrentArgument == Group2->LineEdit1 ) {
541 myData[ X ]->setValue( 0 );
542 myData[ Y ]->setValue( 0 );
543 myData[ Z ]->setValue( 0 );
545 else if ( myEditCurrentArgument == Group2->LineEdit2 ) {
546 myData[ DX1 ]->setValue( 0 );
547 myData[ DY1 ]->setValue( 0 );
548 myData[ DZ1 ]->setValue( 0 );
550 else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
551 myData[ DX2 ]->setValue( 0 );
552 myData[ DY2 ]->setValue( 0 );
553 myData[ DZ2 ]->setValue( 0 );
561 //=================================================================================
562 // function : SetEditCurrentArgument()
564 //=================================================================================
565 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
567 QPushButton* send = (QPushButton*)sender();
569 if ( send == Group1->PushButton1 ) {
570 myEditCurrentArgument = Group1->LineEdit1;
571 globalSelection( GEOM_ALLGEOM );
573 else if ( send == Group2->PushButton1 ) {
574 myEditCurrentArgument = Group2->LineEdit1;
575 //globalSelection( GEOM_POINT );
576 globalSelection(); // close local contexts, if any
577 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
579 else if ( send == Group2->PushButton2 ) {
580 myEditCurrentArgument = Group2->LineEdit2;
581 //globalSelection( GEOM_LINE );
582 globalSelection(); // close local contexts, if any
583 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
585 else if ( send == Group2->PushButton3 ) {
586 myEditCurrentArgument = Group2->LineEdit3;
587 globalSelection(); // close local contexts, if any
588 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
591 myEditCurrentArgument->setFocus();
595 //=================================================================================
596 // function : LineEditReturnPressed()
598 //=================================================================================
599 void BasicGUI_MarkerDlg::LineEditReturnPressed()
601 QLineEdit* send = (QLineEdit*)sender();
603 myEditCurrentArgument = send;
604 GEOMBase_Skeleton::LineEditReturnPressed();
607 //=================================================================================
608 // function : onActivate()
610 //=================================================================================
611 void BasicGUI_MarkerDlg::onActivate()
613 GEOMBase_Skeleton::ActivateThisDialog();
614 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
615 this, SLOT( onSelectionDone() ) );
617 ConstructorsClicked( getConstructorId() );
620 //=================================================================================
621 // function : onDeactivate()
622 // purpose : public slot to deactivate if active
623 //=================================================================================
624 void BasicGUI_MarkerDlg::onDeactivate()
626 GEOMBase_Skeleton::DeactivateActiveDialog();
629 //=================================================================================
630 // function : enterEvent()
632 //=================================================================================
633 void BasicGUI_MarkerDlg::enterEvent( QEvent* )
635 if ( !mainFrame()->GroupConstructors->isEnabled() )
639 //=================================================================================
640 // function : createOperation
642 //=================================================================================
643 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
645 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
648 //=================================================================================
649 // function : isValid
651 //=================================================================================
652 bool BasicGUI_MarkerDlg::isValid( QString& msg )
654 const int id = getConstructorId();
655 gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
656 v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
659 // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
660 // Vectors shouldn't be checked for being orthogonal here!
661 if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
662 isOk = !v1.IsParallel( v2, Precision::Angular() );
664 msg += tr( "VEC_PARALLEL" );
671 return !Group1->LineEdit1->text().isEmpty() && isOk;
673 return !Group2->LineEdit1->text().isEmpty() &&
674 !Group2->LineEdit2->text().isEmpty() &&
675 !Group2->LineEdit3->text().isEmpty() && isOk;
680 //=================================================================================
681 // function : execute
683 //=================================================================================
684 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
686 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow(
687 getOperation() )->MakeMarker( myData[ X ]->value(), myData[ Y ]->value(), myData[ Z ]->value(),
688 myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value(),
689 myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
691 if ( !anObj->_is_nil() )
692 objects.push_back( anObj._retn() );
697 //=================================================================================
698 // function : onValueChanged
700 //=================================================================================
701 void BasicGUI_MarkerDlg::onValueChanged( double )
706 //=================================================================================
707 // function : displayPreview
709 //=================================================================================
710 void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
712 const bool toRemoveFromEngine,
713 const double lineWidth )
715 if ( !myBlockPreview ) {
716 GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
717 if ( myConstructorId == 0 )
718 GEOMBase_Skeleton::activate( GEOM_MARKER );