2 // File : GeometryGUI_PointDlg.cxx
4 // Author : Lucien PIGNOLONI
6 // Module : GeometryGUI
7 // Copyright : OPEN CASCADE
11 #include "GeometryGUI_PointDlg.h"
13 #include "GeometryGUI.h"
14 #include "QAD_Application.h"
15 #include "QAD_RightFrame.h"
16 #include "QAD_Config.h"
17 #include "QAD_Desktop.h"
18 #include "QAD_Tools.h"
19 #include "OCCViewer_Viewer3d.h"
20 #include "utilities.h"
22 #include <BRepBuilderAPI_MakeVertex.hxx>
23 #include <BRep_Tool.hxx>
24 #include <BRepAlgoAPI.hxx>
25 #include <Geom_Curve.hxx>
27 #include <qbuttongroup.h>
29 #include <qgroupbox.h>
31 #include <qlineedit.h>
32 #include <qpushbutton.h>
33 #include <qradiobutton.h>
37 #include <qwhatsthis.h>
40 #include <qvalidator.h>
45 //=================================================================================
46 // class : GeometryGUI_PointDlg()
47 // purpose : Constructs a GeometryGUI_PointDlg which is a child of 'parent', with the
48 // name 'name' and widget flags set to 'f'.
49 // The dialog will by default be modeless, unless you set 'modal' to
50 // TRUE to construct a modal dialog.
51 //=================================================================================
52 GeometryGUI_PointDlg::GeometryGUI_PointDlg( QWidget* parent,
54 SALOME_Selection* Sel,
55 const Handle (AIS_InteractiveContext)& ic,
58 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
61 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_POINT")));
62 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
63 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_POINT_EDGE")));
66 setName( "GeometryGUI_PointDlg" );
68 setCaption( tr( "GEOM_POINT_TITLE" ) );
69 setSizeGripEnabled( TRUE );
70 GeometryGUI_PointDlgLayout = new QGridLayout( this );
71 GeometryGUI_PointDlgLayout->setSpacing( 6 );
72 GeometryGUI_PointDlgLayout->setMargin( 11 );
74 /***************************************************************/
75 GroupButtons = new QGroupBox( this, "GroupButtons" );
76 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
77 GroupButtons->setTitle( tr( "" ) );
78 GroupButtons->setColumnLayout(0, Qt::Vertical );
79 GroupButtons->layout()->setSpacing( 0 );
80 GroupButtons->layout()->setMargin( 0 );
81 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
82 GroupButtonsLayout->setAlignment( Qt::AlignTop );
83 GroupButtonsLayout->setSpacing( 6 );
84 GroupButtonsLayout->setMargin( 11 );
85 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
86 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
87 buttonCancel->setAutoDefault( TRUE );
88 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
89 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
90 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
91 buttonApply->setAutoDefault( TRUE );
92 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
93 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
94 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
95 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
96 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
97 buttonOk->setAutoDefault( TRUE );
98 buttonOk->setDefault( TRUE );
99 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
100 GeometryGUI_PointDlgLayout->addWidget( GroupButtons, 2, 0 );
102 /***************************************************************/
103 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
104 GroupConstructors->setTitle( tr( "Constructors" ) );
105 GroupConstructors->setExclusive( TRUE );
106 GroupConstructors->setColumnLayout(0, Qt::Vertical );
107 GroupConstructors->layout()->setSpacing( 0 );
108 GroupConstructors->layout()->setMargin( 0 );
109 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
110 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
111 GroupConstructorsLayout->setSpacing( 6 );
112 GroupConstructorsLayout->setMargin( 11 );
114 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
115 Constructor1->setText( tr( "" ) );
116 Constructor1->setPixmap( image0 );
117 Constructor1->setChecked( FALSE );
118 Constructor1->setMinimumSize( QSize( 50, 0 ) );
120 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
121 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
122 GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
124 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
125 Constructor2->setText( tr( "" ) );
126 Constructor2->setPixmap( image2 );
127 Constructor2->setChecked( TRUE );
128 Constructor2->setMinimumSize( QSize( 50, 0 ) );
130 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
131 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
132 GroupConstructorsLayout->addItem( spacer_3, 0, 3 );
134 GeometryGUI_PointDlgLayout->addWidget( GroupConstructors, 0, 0 );
137 /***************************************************************/
138 GroupCoordinates = new QGroupBox( this, "GroupCoordinates" );
139 GroupCoordinates->setTitle( tr( "GEOM_COORDINATES" ) );
140 GroupCoordinates->setColumnLayout(0, Qt::Vertical );
141 GroupCoordinates->layout()->setSpacing( 0 );
142 GroupCoordinates->layout()->setMargin( 0 );
143 GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() );
144 GroupCoordinatesLayout->setAlignment( Qt::AlignTop );
145 GroupCoordinatesLayout->setSpacing( 6 );
146 GroupCoordinatesLayout->setMargin( 11 );
148 TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" );
149 TextLabel_X->setText( tr( "GEOM_X" ) );
150 GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 );
151 TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" );
152 TextLabel_Y->setText( tr( "GEOM_Y" ) );
153 GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 );
154 TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" );
155 TextLabel_Z->setText( tr( "GEOM_Z" ) );
156 GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 );
158 /* Spin boxes construction */
159 SpinBox_X = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_X" ) ;
160 GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 );
161 SpinBox_Y = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_Y" ) ;
162 GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 );
163 SpinBox_Z = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_Z" ) ;
164 GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 );
165 GeometryGUI_PointDlgLayout->addWidget( GroupCoordinates, 1, 0 );
167 /***************************************************************/
168 GroupWithEdge = new QGroupBox( this, "GroupWithEdge" );
169 GroupWithEdge->setTitle( tr( "GEOM_PARAM_POINT" ) );
170 GroupWithEdge->setFrameShape( QGroupBox::Box );
171 GroupWithEdge->setFrameShadow( QGroupBox::Sunken );
172 GroupWithEdge->setColumnLayout(0, Qt::Vertical );
173 GroupWithEdge->layout()->setSpacing( 0 );
174 GroupWithEdge->layout()->setMargin( 0 );
175 GroupWithEdgeLayout = new QGridLayout( GroupWithEdge->layout() );
176 GroupWithEdgeLayout->setAlignment( Qt::AlignTop );
177 GroupWithEdgeLayout->setSpacing( 6 );
178 GroupWithEdgeLayout->setMargin( 11 );
180 LineEdit_Edge = new QLineEdit( GroupWithEdge, "LineEdit_Edge" );
181 GroupWithEdgeLayout->addWidget( LineEdit_Edge, 0, 2 );
183 SelectButton_Edge = new QPushButton( GroupWithEdge, "SelectButton_Edge" );
184 SelectButton_Edge->setText( tr( "" ) );
185 SelectButton_Edge->setPixmap( image1 );
186 SelectButton_Edge->setToggleButton( FALSE );
187 GroupWithEdgeLayout->addWidget( SelectButton_Edge, 0, 1 );
190 SpinBox_Parameter = new GeometryGUI_SpinBox( GroupWithEdge, "SpinBox_Parameter" );
191 GroupWithEdgeLayout->addWidget( SpinBox_Parameter, 1, 2 );
193 TextLabel_Edge = new QLabel( GroupWithEdge, "TextLabel_Edge" );
194 TextLabel_Edge->setText( tr( "GEOM_EDGE" ) );
195 TextLabel_Edge->setMinimumSize( QSize( 50, 0 ) );
196 TextLabel_Edge->setFrameShape( QLabel::NoFrame );
197 TextLabel_Edge->setFrameShadow( QLabel::Plain );
198 GroupWithEdgeLayout->addWidget( TextLabel_Edge, 0, 0 );
200 TextLabel_Parameter = new QLabel( GroupWithEdge, "TextLabel_Parameter" );
201 TextLabel_Parameter->setText( tr( "GEOM_PARAMETER" ) );
202 TextLabel_Parameter->setMinimumSize( QSize( 50, 0 ) );
203 TextLabel_Parameter->setFrameShape( QLabel::NoFrame );
204 TextLabel_Parameter->setFrameShadow( QLabel::Plain );
205 GroupWithEdgeLayout->addWidget( TextLabel_Parameter, 1, 0 );
207 GeometryGUI_PointDlgLayout->addWidget( GroupWithEdge, 1, 0 );
208 /***************************************************************/
210 /* Initialisation and display */
213 /* Move widget on the botton right corner of main widget */
214 QAD_Tools::alignWidget(this, parent, AlignBottom | AlignRight);
220 //=======================================================================
221 // function : ~GeometryGUI_PointDlg()
222 // purpose : Destructor
223 //=======================================================================
224 GeometryGUI_PointDlg::~GeometryGUI_PointDlg()
226 /* no need to delete child widgets, Qt does it all for us */
230 //=================================================================================
233 //=================================================================================
234 void GeometryGUI_PointDlg::Init(SALOME_Selection* Sel, const Handle(AIS_InteractiveContext)& ic)
237 /* Get setting of step value from file configuration */
239 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
240 step = St.toDouble() ;
242 /* min, max, step and decimals for spin boxes */
243 SpinBox_X->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
244 SpinBox_X->SetValue( 0.0 ) ;
245 SpinBox_Y->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
246 SpinBox_Y->SetValue( 0.0 ) ;
247 SpinBox_Z->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
248 SpinBox_Z->SetValue( 0.0 ) ;
250 /* spin box for parameter on edge */
251 double specificStep = 0.1 ;
252 SpinBox_Parameter->RangeStepAndValidator( -999999.99999, 999999.99999, specificStep, 5 ) ;
253 SpinBox_Parameter->SetValue( 0.50 ) ;
256 GroupCoordinates->show();
257 GroupWithEdge->hide() ;
258 myConstructorId = 0 ;
259 Constructor1->setChecked( TRUE );
261 /* filter for the second constructor */
262 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
263 myGeom = GEOM::GEOM_Gen::_narrow(comp);
264 myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
266 bool displayPoint = false ;
268 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
269 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
270 myGeomGUI->SetState(POINT_METHOD) ;
275 /* manages local context selection */
278 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
279 myLocalContextId = myIC->OpenLocalContext();
280 myGeomGUI->SetDisplayedObjectList();
281 /* sub shapes selection */
282 myLocalContextMode = TopAbs_VERTEX ;
283 myIC->ActivateStandardMode(myLocalContextMode) ;
284 myUseLocalContext = true ;
286 myUseLocalContext = false ;
290 myPoint.SetCoord( 0.0, 0.0, 0.0 ) ;
293 if( myGeomGUI->GetTopoFromSelection(mySelection, S) ) {
295 /* Filter a possibly previous selection and try to put it into coordinates */
296 if( myGeomGUI->VertexToPoint( S, myPoint) )
297 displayPoint = false ;
299 displayPoint = true ;
302 displayPoint = true ;
305 mySimulationTopoDs.Nullify() ;
306 PointIntoCoordinates(myPoint, displayPoint) ;
308 /* signals and slots connections */
309 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
310 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
311 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
312 connect( SelectButton_Edge, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
314 connect( GroupConstructors, SIGNAL(clicked(int) ), this, SLOT( ConstructorsClicked(int) ) ) ;
316 connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
317 connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
318 connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
320 connect( SpinBox_Parameter, SIGNAL ( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
321 connect( LineEdit_Edge, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
323 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ),this, SLOT( DeactivateActiveDialog() ) ) ;
324 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
325 // connect( mySelection, SIGNAL ( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ) ; done in constructor clicked !
327 /* Move widget on the botton right corner of main widget */
329 myGeomGUI->DefineDlgPosition( this, x, y ) ;
331 this->show() ; /* Displays this Dialog */
336 //=================================================================================
337 // function : ValueChangedInSpinBox()
339 //=================================================================================
340 void GeometryGUI_PointDlg::ValueChangedInSpinBox( double newValue )
342 GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender() ;
344 if( send == SpinBox_X ) {
346 vy = SpinBox_Y->GetValue() ;
347 vz = SpinBox_Z->GetValue() ;
348 } else if ( send == SpinBox_Y ) {
349 vx = SpinBox_X->GetValue() ;
351 vz = SpinBox_Z->GetValue() ;
352 } else if (send == SpinBox_Z ) {
353 vx = SpinBox_X->GetValue() ;
354 vy = SpinBox_Y->GetValue() ;
356 } else if (send == SpinBox_Parameter ) {
357 myParameter = newValue ;
362 switch (myConstructorId) {
363 case 0: // default constructor
365 myPoint.SetCoord(vx, vy, vz) ;
366 myGeomGUI->EraseSimulationShape() ;
367 mySimulationTopoDs = BRepBuilderAPI_MakeVertex (myPoint).Shape() ;
368 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
373 this->SelectionIntoArgument() ;
383 //=======================================================================
384 // funcion : PointIntoCoordinates()
385 // purpose : Sets user point coordinates into this dialog Spin boxes
386 // : and displays it or not according to 'bool displayPoint'
387 //=======================================================================
388 void GeometryGUI_PointDlg::PointIntoCoordinates(gp_Pnt P, bool displayPoint)
390 switch (myConstructorId) {
392 SpinBox_X->SetValue( P.X() ) ;
393 SpinBox_Y->SetValue( P.Y() ) ;
394 SpinBox_Z->SetValue( P.Z() ) ;
395 this->myPoint.SetCoord( P.X(), P.Y(), P.Z() ) ;
397 mySimulationTopoDs = BRepBuilderAPI_MakeVertex(P).Shape() ;
398 myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
412 //=================================================================================
413 // function : ConstructorsClicked()
414 // purpose : Radio button management
415 //=================================================================================
416 void GeometryGUI_PointDlg::ConstructorsClicked(int constructorId)
418 myGeomGUI->EraseSimulationShape() ;
419 myConstructorId = constructorId ;
420 switch (constructorId)
424 if ( myUseLocalContext == false && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
425 myLocalContextId = myIC->OpenLocalContext();
426 myGeomGUI->SetDisplayedObjectList();
427 /* sub shapes selection */
428 myLocalContextMode = TopAbs_VERTEX ;
429 myIC->ActivateStandardMode(myLocalContextMode) ;
430 myUseLocalContext = true ;
432 mySelection->ClearFilters() ;
433 GroupCoordinates->show();
434 GroupWithEdge->hide() ;
435 /* Display point simulation */
436 PointIntoCoordinates( this->myPoint, true ) ;
437 disconnect( mySelection, 0, this, 0 );
442 if ( myUseLocalContext == true && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
443 myIC->CloseLocalContext(myLocalContextId) ;
444 myUseLocalContext = false ;
446 LineEdit_Edge->setText("") ;
447 mySelection->AddFilter( myEdgeFilter );
448 GroupCoordinates->hide();
449 GroupWithEdge->show() ;
451 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
459 //=================================================================================
460 // function : LineEditReturnPressed()
462 //=================================================================================
463 void GeometryGUI_PointDlg::LineEditReturnPressed()
465 QLineEdit* send = (QLineEdit*)sender();
466 if( send == LineEdit_Edge ) {
467 /* User name of object input management */
468 /* If successfull the selection is changed and signal emitted... */
469 /* so SelectionIntoArgument() is automatically called. */
470 const QString objectUserName = send->text() ;
471 QWidget* thisWidget = (QWidget*)this ;
472 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
473 LineEdit_Edge->setText( objectUserName ) ;
481 //=================================================================================
482 // function : ClickOnOk()
484 //=================================================================================
485 void GeometryGUI_PointDlg::ClickOnOk()
487 this->ClickOnApply() ;
488 this->ClickOnCancel() ;
493 //=======================================================================
494 // function : ClickOnApply()
496 //=======================================================================
497 void GeometryGUI_PointDlg::ClickOnApply()
500 myGeomGUI->EraseSimulationShape() ;
502 /* Close local context */
503 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
504 myIC->CloseLocalContext(myLocalContextId) ;
505 myUseLocalContext = false ;
508 switch (myConstructorId) {
512 /* Recup args and call method */
513 double x = SpinBox_X->GetValue() ;
514 double y = SpinBox_Y->GetValue() ;
515 double z = SpinBox_Z->GetValue() ;
517 myGeomGUI->MakePointAndDisplay(x,y,z) ; /* WARNING : no display if a local context is opened */
518 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
519 /* no display if a local context is opened */
520 myLocalContextId = myIC->OpenLocalContext();
521 myGeomGUI->SetDisplayedObjectList();
522 /* sub shapes selection */
523 myLocalContextMode = TopAbs_VERTEX ;
524 myIC->ActivateStandardMode(myLocalContextMode);
525 myUseLocalContext = true ;
531 if( myOkEdge == true ) {
532 /* this constructor method has no idl interface : we use same than constructor 0 */
533 myGeomGUI->MakePointAndDisplay( myPoint.X(), myPoint.Y(), myPoint.Z() ) ;
543 //=================================================================================
544 // function : SelectionIntoArgument()
545 // purpose : Called when selection as changed (for constructors not using local context)
546 //=================================================================================
547 void GeometryGUI_PointDlg::SelectionIntoArgument()
549 myGeomGUI->EraseSimulationShape() ;
550 LineEdit_Edge->setText("") ;
551 QString aString = "" ; /* future name of selection */
552 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
554 this->myOkEdge = false ;
560 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
563 switch (myConstructorId)
569 LineEdit_Edge->setText(aString) ;
570 if( S.ShapeType() == TopAbs_EDGE ) {
571 if( CalculateVertexOnCurve( TopoDS::Edge(S), myParameter, mySimulationTopoDs) ) {
572 if ( myGeomGUI->VertexToPoint( mySimulationTopoDs, myPoint ) ) {
573 this->myOkEdge = true ;
574 myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
586 //=================================================================================
587 // function : SetEditCurrentArgument()
589 //=================================================================================
590 void GeometryGUI_PointDlg::SetEditCurrentArgument()
592 QPushButton* send = (QPushButton*)sender();
593 switch (myConstructorId)
595 case 0: // default constructor
599 if(send == SelectButton_Edge) {
600 LineEdit_Edge->setFocus() ;
601 SelectionIntoArgument() ;
610 //=======================================================================
611 // function : UseLocalContext()
612 // purpose : Return true when this method has opened a local context
613 // : Used from GeometryGUI
614 //=======================================================================
615 bool GeometryGUI_PointDlg::UseLocalContext()
617 return this->myUseLocalContext ;
621 //=======================================================================
622 // function : closeEvent()
624 //=======================================================================
625 void GeometryGUI_PointDlg::closeEvent(QCloseEvent* e)
627 this->ClickOnCancel() ; /* same than click on cancel button */
631 //=======================================================================
632 // function : ClickOnCancel()
634 //=======================================================================
635 void GeometryGUI_PointDlg::ClickOnCancel()
637 if ( myConstructorId == 0 && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
638 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
639 myIC = v3d->getAISContext();
640 if ( myIC->HasOpenedContext() ) {
641 myIC->CloseLocalContext(myLocalContextId) ;
642 myUseLocalContext = false ;
645 mySelection->ClearFilters() ;
646 myGeomGUI->SetActiveDialogBox(0) ;
647 myGeomGUI->EraseSimulationShape() ;
648 myGeomGUI->ResetState() ;
654 //=================================================================================
655 // function : enterEvent()
656 // purpose : to reactivate this dialog box when mouse enter onto the window
657 //=================================================================================
658 void GeometryGUI_PointDlg::enterEvent( QEvent* e)
660 if ( GroupConstructors->isEnabled() )
662 ActivateThisDialog() ;
666 //=================================================================================
667 // function : DeactivateActiveDialog()
668 // purpose : public slot to deactivate if active
669 //=================================================================================
670 void GeometryGUI_PointDlg::DeactivateActiveDialog()
672 if ( GroupConstructors->isEnabled() ) {
674 mySelection->ClearFilters() ;
675 GroupConstructors->setEnabled(false) ;
676 GroupCoordinates->setEnabled(false) ;
677 GroupWithEdge->setEnabled(false) ;
678 GroupButtons->setEnabled(false) ;
679 myGeomGUI->EraseSimulationShape() ;
680 myGeomGUI->ResetState() ;
681 myGeomGUI->SetActiveDialogBox(0) ;
682 if ( myConstructorId == 0 && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
683 myIC->CloseLocalContext(myLocalContextId) ;
684 myUseLocalContext = false ;
692 //=================================================================================
693 // function : ActivateThisDialog()
695 //=================================================================================
696 void GeometryGUI_PointDlg::ActivateThisDialog( )
699 if ( !GroupConstructors->isEnabled() ) { /* if not active */
701 myGeomGUI->EmitSignalDeactivateDialog() ;
702 GroupConstructors->setEnabled(true) ;
703 GroupCoordinates->setEnabled(true) ;
704 GroupWithEdge->setEnabled(true) ;
705 GroupButtons->setEnabled(true) ;
707 myGeomGUI->SetState(POINT_METHOD) ;
708 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
710 if ( myConstructorId == 0 ) {
712 mySelection->ClearFilters() ;
713 if( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
714 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
715 myIC = v3d->getAISContext();
716 myLocalContextId = myIC->OpenLocalContext();
717 myGeomGUI->SetDisplayedObjectList();
718 /* sub shapes selection */
719 myLocalContextMode = TopAbs_VERTEX ;
720 myIC->ActivateStandardMode(myLocalContextMode);
721 myUseLocalContext = true ;
725 if ( myConstructorId == 1 )
726 mySelection->AddFilter( myEdgeFilter );
728 if( !mySimulationTopoDs.IsNull() )
729 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
736 //=================================================================================
737 // function : CalculateVertexOnCurve()
738 // purpose : Calculate a Vertex on the curve given by 'anEdge'.
739 // : The position of resultVertex is given by aParameter.
740 // : For a linear edge, aParameter=0.0 gives the first vertex of edge
741 // : aParameter=1.0 gives the last vertex of edge
742 // : aParameter=0.5 gives the vertex on the middle of edge
743 // : It is possible to get vertices out of edge using values > 1.0 or < 0.0
744 //=================================================================================
745 bool GeometryGUI_PointDlg::CalculateVertexOnCurve(const TopoDS_Edge& anEdge, const Standard_Real aParameter, TopoDS_Shape& resultVertex)
747 if( anEdge.IsNull() || !BRepAlgoAPI::IsValid(anEdge) )
750 Standard_Real first, last ;
751 Handle(Geom_Curve) curv = BRep_Tool::Curve(anEdge, first, last);
756 if( anEdge.Orientation() == TopAbs_FORWARD ) {
757 param = first + (last-first) * aParameter ;
760 param = last + (first-last) * aParameter ;
763 curv->D0( param, paramPoint ) ;
764 resultVertex = BRepBuilderAPI_MakeVertex(paramPoint);