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 myShape = myPoint = myVectorX = myVectorY = GEOM::GEOM_Object::_nil();
171 myBlockPreview = false;
172 myConstructorId = -1;
173 myEditCurrentArgument = Group1->LineEdit1;
174 Group1->LineEdit1->setReadOnly( true );
175 Group2->LineEdit1->setReadOnly( true );
176 Group2->LineEdit2->setReadOnly( true );
177 Group2->LineEdit3->setReadOnly( true );
178 Group2->LineEdit1->setEnabled( true );
179 Group2->LineEdit2->setEnabled( false );
180 Group2->LineEdit3->setEnabled( false );
182 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
184 connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
185 connect( Group2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
186 connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
187 connect( Group2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
189 connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
190 connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
191 connect( Group2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
192 connect( Group2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
194 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
195 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
197 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() ) );
198 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() ) );
200 connect( myGeomGUI->getApp()->selectionMgr(),
201 SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
203 initName( tr( "LCS_NAME" ) );
205 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
206 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
208 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) {
209 initSpinBox( anIter.value(), COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
210 connect( anIter.value(), SIGNAL( valueChanged( double ) ),
211 this, SLOT( onValueChanged( double ) ) );
214 myBlockPreview = true;
215 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
216 anIter.value()->setValue( 0 );
217 myData[ DX1 ]->setValue( 1 );
218 myData[ DY2 ]->setValue( 1 );
219 myBlockPreview = false;
221 ConstructorsClicked( 0 );
224 //=================================================================================
225 // function : ConstructorsClicked()
226 // purpose : Radio button management
227 //=================================================================================
228 void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
230 if ( myConstructorId == constructorId && myConstructorId == 0 ) {
231 globalSelection(); // close local contexts, if any
232 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
233 activate( GEOM_MARKER );
237 myConstructorId = constructorId;
239 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
241 switch ( constructorId ) {
247 globalSelection(); // close local contexts, if any
248 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
249 activate( GEOM_MARKER );
257 Group1->PushButton1->setDown( true );
258 globalSelection( GEOM_ALLGEOM );
259 myEditCurrentArgument = Group1->LineEdit1;
260 Group1->LineEdit1->setText( "" );
261 myShape = GEOM::GEOM_Object::_nil();
269 Group2->PushButton1->setDown( true );
270 Group2->PushButton2->setDown( false );
271 Group2->PushButton3->setDown( false );
272 globalSelection(); // close local contexts, if any
273 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
274 myEditCurrentArgument = Group2->LineEdit1;
275 Group2->LineEdit1->setText( "" );
276 Group2->LineEdit2->setText( "" );
277 Group2->LineEdit3->setText( "" );
278 Group2->LineEdit1->setEnabled( true );
279 Group2->LineEdit2->setEnabled( false );
280 Group2->LineEdit3->setEnabled( false );
281 myPoint = GEOM::GEOM_Object::_nil();
282 myVectorX = GEOM::GEOM_Object::_nil();
283 myVectorY = GEOM::GEOM_Object::_nil();
290 qApp->processEvents();
292 resize( minimumSizeHint() );
294 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
295 this, SLOT( onSelectionDone() ) );
299 //=================================================================================
302 //=================================================================================
303 void BasicGUI_MarkerDlg::onOk()
309 //=================================================================================
310 // function : onApply()
312 //=================================================================================
313 bool BasicGUI_MarkerDlg::onApply()
319 ConstructorsClicked( getConstructorId() );
324 //=================================================================================
325 // function : onSelectionDone0()
326 // purpose : Reaction on selection when first method of creation is current one
327 //=================================================================================
328 void BasicGUI_MarkerDlg::onSelectionDone0()
330 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
331 SALOME_ListIO aSelList;
332 aSelMgr->selectedObjects(aSelList);
334 if (aSelList.Extent() == 1) {
335 Standard_Boolean aRes = Standard_False;
336 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
337 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
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 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
407 SALOME_ListIO aSelList;
408 aSelMgr->selectedObjects(aSelList);
410 if (aSelList.Extent() == 1) {
411 Standard_Boolean aRes = Standard_False;
412 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
413 GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
415 if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
416 QString aName = GEOMBase::GetName( aSelectedObj );
418 if ( getConstructorId() == 1 ) { // by shape position
420 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
421 myShape = aSelectedObj;
422 myEditCurrentArgument->setText( aName );
424 else if ( getConstructorId() == 2 ) { // by point and two vectors
426 if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
427 TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
428 if ( myEditCurrentArgument == Group2->LineEdit1 )
429 aNeedType = TopAbs_VERTEX;
431 TColStd_IndexedMapOfInteger aMap;
432 aSelMgr->GetIndexes( anIO, aMap );
434 if ( !aMap.IsEmpty() ) {
435 int anIndex = aMap( 1 );
436 if ( aNeedType == TopAbs_EDGE )
437 aName += QString( "_edge_%1" ).arg( anIndex );
439 aName += QString( "_vertex_%1" ).arg( anIndex );
441 TopTools_IndexedMapOfShape aShapes;
442 TopExp::MapShapes( aShape, aShapes );
443 aShape = aShapes.FindKey( anIndex );
446 if ( myEditCurrentArgument == Group2->LineEdit1 ) {
447 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
448 myPoint = aSelectedObj;
449 myEditCurrentArgument->setText( aName );
450 if (Group2->LineEdit2->text() == "")
451 Group2->PushButton2->click();
454 else if (myEditCurrentArgument == Group2->LineEdit2) {
455 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
456 myVectorX = aSelectedObj;
457 myEditCurrentArgument->setText( aName );
458 if (Group2->LineEdit3->text() == "")
459 Group2->PushButton3->click();
462 else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
463 if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
464 myVectorY = aSelectedObj;
465 myEditCurrentArgument->setText( aName );
466 if (Group2->LineEdit1->text() == "")
467 Group2->PushButton1->click();
475 if ( getConstructorId() == 1 ) {
476 myShape = GEOM::GEOM_Object::_nil();
477 } else if ( getConstructorId() == 2 ) {
478 if ( myEditCurrentArgument == Group2->LineEdit1 )
479 myPoint = GEOM::GEOM_Object::_nil();
480 else if ( myEditCurrentArgument == Group2->LineEdit2 )
481 myVectorX = GEOM::GEOM_Object::_nil();
482 else if ( myEditCurrentArgument == Group2->LineEdit3 )
483 myVectorY = GEOM::GEOM_Object::_nil();
490 //=================================================================================
491 // function : SetEditCurrentArgument()
493 //=================================================================================
494 void BasicGUI_MarkerDlg::SetEditCurrentArgument()
496 QPushButton* send = (QPushButton*)sender();
497 globalSelection(); // close local contexts, if any
499 if ( send == Group1->PushButton1 ) {
500 myEditCurrentArgument = Group1->LineEdit1;
501 globalSelection( GEOM_ALLGEOM );
503 else if ( send == Group2->PushButton1 ) {
504 myEditCurrentArgument = Group2->LineEdit1;
505 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
506 Group2->PushButton2->setDown( false );
507 Group2->PushButton3->setDown( false );
508 Group2->LineEdit1->setEnabled( true );
509 Group2->LineEdit2->setEnabled( false );
510 Group2->LineEdit3->setEnabled( false );
512 else if ( send == Group2->PushButton2 ) {
513 myEditCurrentArgument = Group2->LineEdit2;
514 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
515 Group2->PushButton1->setDown( false );
516 Group2->PushButton3->setDown( false );
517 Group2->LineEdit1->setEnabled( false );
518 Group2->LineEdit2->setEnabled( true );
519 Group2->LineEdit3->setEnabled( false );
521 else if ( send == Group2->PushButton3 ) {
522 myEditCurrentArgument = Group2->LineEdit3;
523 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
524 Group2->PushButton1->setDown( false );
525 Group2->PushButton2->setDown( false );
526 Group2->LineEdit1->setEnabled( false );
527 Group2->LineEdit2->setEnabled( false );
528 Group2->LineEdit3->setEnabled( true );
531 myEditCurrentArgument->setFocus();
536 //=================================================================================
537 // function : LineEditReturnPressed()
539 //=================================================================================
540 void BasicGUI_MarkerDlg::LineEditReturnPressed()
542 QLineEdit* send = (QLineEdit*)sender();
544 myEditCurrentArgument = send;
545 GEOMBase_Skeleton::LineEditReturnPressed();
548 //=================================================================================
549 // function : onActivate()
551 //=================================================================================
552 void BasicGUI_MarkerDlg::onActivate()
554 GEOMBase_Skeleton::ActivateThisDialog();
555 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
556 this, SLOT( onSelectionDone() ) );
558 ConstructorsClicked( getConstructorId() );
561 //=================================================================================
562 // function : onDeactivate()
563 // purpose : public slot to deactivate if active
564 //=================================================================================
565 void BasicGUI_MarkerDlg::onDeactivate()
567 GEOMBase_Skeleton::DeactivateActiveDialog();
570 //=================================================================================
571 // function : enterEvent()
573 //=================================================================================
574 void BasicGUI_MarkerDlg::enterEvent( QEvent* )
576 if ( !mainFrame()->GroupConstructors->isEnabled() )
580 //=================================================================================
581 // function : createOperation
583 //=================================================================================
584 GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
586 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
589 //=================================================================================
590 // function : isValid
592 //=================================================================================
593 bool BasicGUI_MarkerDlg::isValid( QString& msg )
595 const int id = getConstructorId();
598 gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
599 v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
602 // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
603 // Vectors shouldn't be checked for being orthogonal here!
604 if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
605 isOk = !v1.IsParallel( v2, Precision::Angular() );
607 msg += tr( "VEC_PARALLEL" );
610 for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
611 ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
615 return !myShape->_is_nil();
617 return !myPoint->_is_nil() && !myVectorX->_is_nil() && !myVectorY->_is_nil();
622 //=================================================================================
623 // function : execute
625 //=================================================================================
626 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
628 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
629 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil();
630 QStringList aParameters;
631 const int id = getConstructorId();
633 anObj = anOper->MakeMarker( myData[ X ]->value(), myData[ Y ]->value(),
634 myData[ Z ]->value(), myData[ DX1 ]->value(),
635 myData[ DY1 ]->value(), myData[ DZ1 ]->value(),
636 myData[ DX2 ]->value(), myData[ DY2 ]->value(),
637 myData[ DZ2 ]->value() );
638 aParameters<<myData[X]->text();
639 aParameters<<myData[Y]->text();
640 aParameters<<myData[Z]->text();
641 aParameters<<myData[ DX1 ]->text();
642 aParameters<<myData[ DY1 ]->text();
643 aParameters<<myData[ DZ1 ]->text();
644 aParameters<<myData[ DX2 ]->text();
645 aParameters<<myData[ DY2 ]->text();
646 aParameters<<myData[ DZ2 ]->text();
647 } else if (id == 1) {
648 anObj = anOper->MakeMarkerFromShape( myShape );
649 } else if (id == 2) {
650 anObj = anOper->MakeMarkerPntTwoVec( myPoint, myVectorX, myVectorY );
653 if ( !anObj->_is_nil() ) {
654 if ( !IsPreview() && id == 0)
655 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
656 objects.push_back( anObj._retn() );
662 //=================================================================================
663 // function : onValueChanged
665 //=================================================================================
666 void BasicGUI_MarkerDlg::onValueChanged( double )
671 //=================================================================================
672 // function : displayPreview
674 //=================================================================================
675 void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
677 const bool toRemoveFromEngine,
678 const double lineWidth )
680 if ( !myBlockPreview ) {
681 GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
682 if ( myConstructorId == 0 )
683 GEOMBase_Skeleton::activate( GEOM_MARKER );