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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GeometryGUI_PointDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI_PointDlg.h"
32 #include "GeometryGUI.h"
33 #include "QAD_Application.h"
34 #include "QAD_RightFrame.h"
35 #include "QAD_Config.h"
36 #include "QAD_Desktop.h"
37 #include "QAD_Tools.h"
38 #include "OCCViewer_Viewer3d.h"
39 #include "utilities.h"
41 #include <BRepBuilderAPI_MakeVertex.hxx>
42 #include <BRep_Tool.hxx>
43 #if OCC_VERSION_MAJOR >= 5
44 #include <BRepAlgo.hxx>
46 #include <BRepAlgoAPI.hxx>
48 #include <Geom_Curve.hxx>
50 #include <qbuttongroup.h>
52 #include <qgroupbox.h>
54 #include <qlineedit.h>
55 #include <qpushbutton.h>
56 #include <qradiobutton.h>
60 #include <qwhatsthis.h>
63 #include <qvalidator.h>
68 //=================================================================================
69 // class : GeometryGUI_PointDlg()
70 // purpose : Constructs a GeometryGUI_PointDlg which is a child of 'parent', with the
71 // name 'name' and widget flags set to 'f'.
72 // The dialog will by default be modeless, unless you set 'modal' to
73 // TRUE to construct a modal dialog.
74 //=================================================================================
75 GeometryGUI_PointDlg::GeometryGUI_PointDlg( QWidget* parent,
77 SALOME_Selection* Sel,
78 const Handle (AIS_InteractiveContext)& ic,
81 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
84 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_POINT")));
85 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
86 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_POINT_EDGE")));
89 setName( "GeometryGUI_PointDlg" );
91 setCaption( tr( "GEOM_POINT_TITLE" ) );
92 setSizeGripEnabled( TRUE );
93 GeometryGUI_PointDlgLayout = new QGridLayout( this );
94 GeometryGUI_PointDlgLayout->setSpacing( 6 );
95 GeometryGUI_PointDlgLayout->setMargin( 11 );
97 /***************************************************************/
98 GroupButtons = new QGroupBox( this, "GroupButtons" );
99 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
100 GroupButtons->setTitle( tr( "" ) );
101 GroupButtons->setColumnLayout(0, Qt::Vertical );
102 GroupButtons->layout()->setSpacing( 0 );
103 GroupButtons->layout()->setMargin( 0 );
104 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
105 GroupButtonsLayout->setAlignment( Qt::AlignTop );
106 GroupButtonsLayout->setSpacing( 6 );
107 GroupButtonsLayout->setMargin( 11 );
108 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
109 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
110 buttonCancel->setAutoDefault( TRUE );
111 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
112 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
113 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
114 buttonApply->setAutoDefault( TRUE );
115 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
116 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
117 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
118 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
119 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
120 buttonOk->setAutoDefault( TRUE );
121 buttonOk->setDefault( TRUE );
122 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
123 GeometryGUI_PointDlgLayout->addWidget( GroupButtons, 2, 0 );
125 /***************************************************************/
126 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
127 GroupConstructors->setTitle( tr( "Constructors" ) );
128 GroupConstructors->setExclusive( TRUE );
129 GroupConstructors->setColumnLayout(0, Qt::Vertical );
130 GroupConstructors->layout()->setSpacing( 0 );
131 GroupConstructors->layout()->setMargin( 0 );
132 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
133 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
134 GroupConstructorsLayout->setSpacing( 6 );
135 GroupConstructorsLayout->setMargin( 11 );
137 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
138 Constructor1->setText( tr( "" ) );
139 Constructor1->setPixmap( image0 );
140 Constructor1->setChecked( FALSE );
141 Constructor1->setMinimumSize( QSize( 50, 0 ) );
143 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
144 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
145 GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
147 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
148 Constructor2->setText( tr( "" ) );
149 Constructor2->setPixmap( image2 );
150 Constructor2->setChecked( TRUE );
151 Constructor2->setMinimumSize( QSize( 50, 0 ) );
153 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
154 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
155 GroupConstructorsLayout->addItem( spacer_3, 0, 3 );
157 GeometryGUI_PointDlgLayout->addWidget( GroupConstructors, 0, 0 );
160 /***************************************************************/
161 GroupCoordinates = new QGroupBox( this, "GroupCoordinates" );
162 GroupCoordinates->setTitle( tr( "GEOM_COORDINATES" ) );
163 GroupCoordinates->setColumnLayout(0, Qt::Vertical );
164 GroupCoordinates->layout()->setSpacing( 0 );
165 GroupCoordinates->layout()->setMargin( 0 );
166 GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() );
167 GroupCoordinatesLayout->setAlignment( Qt::AlignTop );
168 GroupCoordinatesLayout->setSpacing( 6 );
169 GroupCoordinatesLayout->setMargin( 11 );
171 TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" );
172 TextLabel_X->setText( tr( "GEOM_X" ) );
173 GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 );
174 TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" );
175 TextLabel_Y->setText( tr( "GEOM_Y" ) );
176 GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 );
177 TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" );
178 TextLabel_Z->setText( tr( "GEOM_Z" ) );
179 GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 );
181 /* Spin boxes construction */
182 SpinBox_X = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_X" ) ;
183 GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 );
184 SpinBox_Y = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_Y" ) ;
185 GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 );
186 SpinBox_Z = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_Z" ) ;
187 GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 );
188 GeometryGUI_PointDlgLayout->addWidget( GroupCoordinates, 1, 0 );
190 /***************************************************************/
191 GroupWithEdge = new QGroupBox( this, "GroupWithEdge" );
192 GroupWithEdge->setTitle( tr( "GEOM_PARAM_POINT" ) );
193 GroupWithEdge->setFrameShape( QGroupBox::Box );
194 GroupWithEdge->setFrameShadow( QGroupBox::Sunken );
195 GroupWithEdge->setColumnLayout(0, Qt::Vertical );
196 GroupWithEdge->layout()->setSpacing( 0 );
197 GroupWithEdge->layout()->setMargin( 0 );
198 GroupWithEdgeLayout = new QGridLayout( GroupWithEdge->layout() );
199 GroupWithEdgeLayout->setAlignment( Qt::AlignTop );
200 GroupWithEdgeLayout->setSpacing( 6 );
201 GroupWithEdgeLayout->setMargin( 11 );
203 LineEdit_Edge = new QLineEdit( GroupWithEdge, "LineEdit_Edge" );
204 GroupWithEdgeLayout->addWidget( LineEdit_Edge, 0, 2 );
206 SelectButton_Edge = new QPushButton( GroupWithEdge, "SelectButton_Edge" );
207 SelectButton_Edge->setText( tr( "" ) );
208 SelectButton_Edge->setPixmap( image1 );
209 SelectButton_Edge->setToggleButton( FALSE );
210 GroupWithEdgeLayout->addWidget( SelectButton_Edge, 0, 1 );
213 SpinBox_Parameter = new GeometryGUI_SpinBox( GroupWithEdge, "SpinBox_Parameter" );
214 GroupWithEdgeLayout->addWidget( SpinBox_Parameter, 1, 2 );
216 TextLabel_Edge = new QLabel( GroupWithEdge, "TextLabel_Edge" );
217 TextLabel_Edge->setText( tr( "GEOM_EDGE" ) );
218 TextLabel_Edge->setMinimumSize( QSize( 50, 0 ) );
219 TextLabel_Edge->setFrameShape( QLabel::NoFrame );
220 TextLabel_Edge->setFrameShadow( QLabel::Plain );
221 GroupWithEdgeLayout->addWidget( TextLabel_Edge, 0, 0 );
223 TextLabel_Parameter = new QLabel( GroupWithEdge, "TextLabel_Parameter" );
224 TextLabel_Parameter->setText( tr( "GEOM_PARAMETER" ) );
225 TextLabel_Parameter->setMinimumSize( QSize( 50, 0 ) );
226 TextLabel_Parameter->setFrameShape( QLabel::NoFrame );
227 TextLabel_Parameter->setFrameShadow( QLabel::Plain );
228 GroupWithEdgeLayout->addWidget( TextLabel_Parameter, 1, 0 );
230 GeometryGUI_PointDlgLayout->addWidget( GroupWithEdge, 1, 0 );
231 /***************************************************************/
233 /* Initialisation and display */
236 /* Move widget on the botton right corner of main widget */
237 QAD_Tools::alignWidget(this, parent, AlignBottom | AlignRight);
243 //=======================================================================
244 // function : ~GeometryGUI_PointDlg()
245 // purpose : Destructor
246 //=======================================================================
247 GeometryGUI_PointDlg::~GeometryGUI_PointDlg()
249 /* no need to delete child widgets, Qt does it all for us */
253 //=================================================================================
256 //=================================================================================
257 void GeometryGUI_PointDlg::Init(SALOME_Selection* Sel, const Handle(AIS_InteractiveContext)& ic)
260 /* Get setting of step value from file configuration */
262 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
263 step = St.toDouble() ;
265 /* min, max, step and decimals for spin boxes */
266 SpinBox_X->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
267 SpinBox_X->SetValue( 0.0 ) ;
268 SpinBox_Y->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
269 SpinBox_Y->SetValue( 0.0 ) ;
270 SpinBox_Z->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
271 SpinBox_Z->SetValue( 0.0 ) ;
273 /* spin box for parameter on edge */
274 double specificStep = 0.1 ;
275 SpinBox_Parameter->RangeStepAndValidator( -999999.99999, 999999.99999, specificStep, 5 ) ;
276 SpinBox_Parameter->SetValue( 0.50 ) ;
279 GroupCoordinates->show();
280 GroupWithEdge->hide() ;
281 myConstructorId = 0 ;
282 Constructor1->setChecked( TRUE );
284 /* filter for the second constructor */
285 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
286 myGeom = GEOM::GEOM_Gen::_narrow(comp);
287 myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
289 bool displayPoint = false ;
291 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
292 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
293 myGeomGUI->SetState(POINT_METHOD) ;
298 /* manages local context selection */
301 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
302 myLocalContextId = myIC->OpenLocalContext();
303 myGeomGUI->SetDisplayedObjectList();
304 /* sub shapes selection */
305 myLocalContextMode = TopAbs_VERTEX ;
306 myIC->ActivateStandardMode(myLocalContextMode) ;
307 myUseLocalContext = true ;
309 myUseLocalContext = false ;
313 myPoint.SetCoord( 0.0, 0.0, 0.0 ) ;
316 if( myGeomGUI->GetTopoFromSelection(mySelection, S) ) {
318 /* Filter a possibly previous selection and try to put it into coordinates */
319 if( myGeomGUI->VertexToPoint( S, myPoint) )
320 displayPoint = false ;
322 displayPoint = true ;
325 displayPoint = true ;
328 mySimulationTopoDs.Nullify() ;
329 PointIntoCoordinates(myPoint, displayPoint) ;
331 /* signals and slots connections */
332 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
333 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
334 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
335 connect( SelectButton_Edge, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
337 connect( GroupConstructors, SIGNAL(clicked(int) ), this, SLOT( ConstructorsClicked(int) ) ) ;
339 connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
340 connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
341 connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
343 connect( SpinBox_Parameter, SIGNAL ( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
344 connect( LineEdit_Edge, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
346 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ),this, SLOT( DeactivateActiveDialog() ) ) ;
347 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
348 // connect( mySelection, SIGNAL ( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ) ; done in constructor clicked !
350 /* Move widget on the botton right corner of main widget */
352 myGeomGUI->DefineDlgPosition( this, x, y ) ;
354 this->show() ; /* Displays this Dialog */
359 //=================================================================================
360 // function : ValueChangedInSpinBox()
362 //=================================================================================
363 void GeometryGUI_PointDlg::ValueChangedInSpinBox( double newValue )
365 GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender() ;
367 if( send == SpinBox_X ) {
369 vy = SpinBox_Y->GetValue() ;
370 vz = SpinBox_Z->GetValue() ;
371 } else if ( send == SpinBox_Y ) {
372 vx = SpinBox_X->GetValue() ;
374 vz = SpinBox_Z->GetValue() ;
375 } else if (send == SpinBox_Z ) {
376 vx = SpinBox_X->GetValue() ;
377 vy = SpinBox_Y->GetValue() ;
379 } else if (send == SpinBox_Parameter ) {
380 myParameter = newValue ;
385 switch (myConstructorId) {
386 case 0: // default constructor
388 myPoint.SetCoord(vx, vy, vz) ;
389 myGeomGUI->EraseSimulationShape() ;
390 mySimulationTopoDs = BRepBuilderAPI_MakeVertex (myPoint).Shape() ;
391 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
396 this->SelectionIntoArgument() ;
406 //=======================================================================
407 // funcion : PointIntoCoordinates()
408 // purpose : Sets user point coordinates into this dialog Spin boxes
409 // : and displays it or not according to 'bool displayPoint'
410 //=======================================================================
411 void GeometryGUI_PointDlg::PointIntoCoordinates(gp_Pnt P, bool displayPoint)
413 switch (myConstructorId) {
415 SpinBox_X->SetValue( P.X() ) ;
416 SpinBox_Y->SetValue( P.Y() ) ;
417 SpinBox_Z->SetValue( P.Z() ) ;
418 this->myPoint.SetCoord( P.X(), P.Y(), P.Z() ) ;
420 mySimulationTopoDs = BRepBuilderAPI_MakeVertex(P).Shape() ;
421 myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
435 //=================================================================================
436 // function : ConstructorsClicked()
437 // purpose : Radio button management
438 //=================================================================================
439 void GeometryGUI_PointDlg::ConstructorsClicked(int constructorId)
441 myGeomGUI->EraseSimulationShape() ;
442 myConstructorId = constructorId ;
443 switch (constructorId)
447 if ( myUseLocalContext == false && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
448 myLocalContextId = myIC->OpenLocalContext();
449 myGeomGUI->SetDisplayedObjectList();
450 /* sub shapes selection */
451 myLocalContextMode = TopAbs_VERTEX ;
452 myIC->ActivateStandardMode(myLocalContextMode) ;
453 myUseLocalContext = true ;
455 mySelection->ClearFilters() ;
456 GroupCoordinates->show();
457 GroupWithEdge->hide() ;
458 /* Display point simulation */
459 PointIntoCoordinates( this->myPoint, true ) ;
460 disconnect( mySelection, 0, this, 0 );
465 if ( myUseLocalContext == true && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
466 myIC->CloseLocalContext(myLocalContextId) ;
467 myUseLocalContext = false ;
469 LineEdit_Edge->setText("") ;
470 mySelection->AddFilter( myEdgeFilter );
471 GroupCoordinates->hide();
472 GroupWithEdge->show() ;
474 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
482 //=================================================================================
483 // function : LineEditReturnPressed()
485 //=================================================================================
486 void GeometryGUI_PointDlg::LineEditReturnPressed()
488 QLineEdit* send = (QLineEdit*)sender();
489 if( send == LineEdit_Edge ) {
490 /* User name of object input management */
491 /* If successfull the selection is changed and signal emitted... */
492 /* so SelectionIntoArgument() is automatically called. */
493 const QString objectUserName = send->text() ;
494 QWidget* thisWidget = (QWidget*)this ;
495 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
496 LineEdit_Edge->setText( objectUserName ) ;
504 //=================================================================================
505 // function : ClickOnOk()
507 //=================================================================================
508 void GeometryGUI_PointDlg::ClickOnOk()
510 this->ClickOnApply() ;
511 this->ClickOnCancel() ;
516 //=======================================================================
517 // function : ClickOnApply()
519 //=======================================================================
520 void GeometryGUI_PointDlg::ClickOnApply()
523 myGeomGUI->EraseSimulationShape() ;
525 /* Close local context */
526 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
527 myIC->CloseLocalContext(myLocalContextId) ;
528 myUseLocalContext = false ;
531 switch (myConstructorId) {
535 /* Recup args and call method */
536 double x = SpinBox_X->GetValue() ;
537 double y = SpinBox_Y->GetValue() ;
538 double z = SpinBox_Z->GetValue() ;
540 myGeomGUI->MakePointAndDisplay(x,y,z) ; /* WARNING : no display if a local context is opened */
541 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
542 /* no display if a local context is opened */
543 myLocalContextId = myIC->OpenLocalContext();
544 myGeomGUI->SetDisplayedObjectList();
545 /* sub shapes selection */
546 myLocalContextMode = TopAbs_VERTEX ;
547 myIC->ActivateStandardMode(myLocalContextMode);
548 myUseLocalContext = true ;
554 if( myOkEdge == true ) {
555 /* this constructor method has no idl interface : we use same than constructor 0 */
556 myGeomGUI->MakePointAndDisplay( myPoint.X(), myPoint.Y(), myPoint.Z() ) ;
566 //=================================================================================
567 // function : SelectionIntoArgument()
568 // purpose : Called when selection as changed (for constructors not using local context)
569 //=================================================================================
570 void GeometryGUI_PointDlg::SelectionIntoArgument()
572 myGeomGUI->EraseSimulationShape() ;
573 LineEdit_Edge->setText("") ;
574 QString aString = "" ; /* future name of selection */
575 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
577 this->myOkEdge = false ;
583 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
586 switch (myConstructorId)
592 LineEdit_Edge->setText(aString) ;
593 if( S.ShapeType() == TopAbs_EDGE ) {
594 if( CalculateVertexOnCurve( TopoDS::Edge(S), myParameter, mySimulationTopoDs) ) {
595 if ( myGeomGUI->VertexToPoint( mySimulationTopoDs, myPoint ) ) {
596 this->myOkEdge = true ;
597 myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
609 //=================================================================================
610 // function : SetEditCurrentArgument()
612 //=================================================================================
613 void GeometryGUI_PointDlg::SetEditCurrentArgument()
615 QPushButton* send = (QPushButton*)sender();
616 switch (myConstructorId)
618 case 0: // default constructor
622 if(send == SelectButton_Edge) {
623 LineEdit_Edge->setFocus() ;
624 SelectionIntoArgument() ;
633 //=======================================================================
634 // function : UseLocalContext()
635 // purpose : Return true when this method has opened a local context
636 // : Used from GeometryGUI
637 //=======================================================================
638 bool GeometryGUI_PointDlg::UseLocalContext()
640 return this->myUseLocalContext ;
644 //=======================================================================
645 // function : closeEvent()
647 //=======================================================================
648 void GeometryGUI_PointDlg::closeEvent(QCloseEvent* e)
650 this->ClickOnCancel() ; /* same than click on cancel button */
654 //=======================================================================
655 // function : ClickOnCancel()
657 //=======================================================================
658 void GeometryGUI_PointDlg::ClickOnCancel()
660 if ( myConstructorId == 0 && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
661 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
662 myIC = v3d->getAISContext();
663 if ( myIC->HasOpenedContext() ) {
664 myIC->CloseLocalContext(myLocalContextId) ;
665 myUseLocalContext = false ;
668 mySelection->ClearFilters() ;
669 myGeomGUI->SetActiveDialogBox(0) ;
670 myGeomGUI->EraseSimulationShape() ;
671 myGeomGUI->ResetState() ;
677 //=================================================================================
678 // function : enterEvent()
679 // purpose : to reactivate this dialog box when mouse enter onto the window
680 //=================================================================================
681 void GeometryGUI_PointDlg::enterEvent( QEvent* e)
683 if ( GroupConstructors->isEnabled() )
685 ActivateThisDialog() ;
689 //=================================================================================
690 // function : DeactivateActiveDialog()
691 // purpose : public slot to deactivate if active
692 //=================================================================================
693 void GeometryGUI_PointDlg::DeactivateActiveDialog()
695 if ( GroupConstructors->isEnabled() ) {
697 mySelection->ClearFilters() ;
698 GroupConstructors->setEnabled(false) ;
699 GroupCoordinates->setEnabled(false) ;
700 GroupWithEdge->setEnabled(false) ;
701 GroupButtons->setEnabled(false) ;
702 myGeomGUI->EraseSimulationShape() ;
703 myGeomGUI->ResetState() ;
704 myGeomGUI->SetActiveDialogBox(0) ;
705 if ( myConstructorId == 0 && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
706 myIC->CloseLocalContext(myLocalContextId) ;
707 myUseLocalContext = false ;
715 //=================================================================================
716 // function : ActivateThisDialog()
718 //=================================================================================
719 void GeometryGUI_PointDlg::ActivateThisDialog( )
722 if ( !GroupConstructors->isEnabled() ) { /* if not active */
724 myGeomGUI->EmitSignalDeactivateDialog() ;
725 GroupConstructors->setEnabled(true) ;
726 GroupCoordinates->setEnabled(true) ;
727 GroupWithEdge->setEnabled(true) ;
728 GroupButtons->setEnabled(true) ;
730 myGeomGUI->SetState(POINT_METHOD) ;
731 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
733 if ( myConstructorId == 0 ) {
735 mySelection->ClearFilters() ;
736 if( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
737 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
738 myIC = v3d->getAISContext();
739 myLocalContextId = myIC->OpenLocalContext();
740 myGeomGUI->SetDisplayedObjectList();
741 /* sub shapes selection */
742 myLocalContextMode = TopAbs_VERTEX ;
743 myIC->ActivateStandardMode(myLocalContextMode);
744 myUseLocalContext = true ;
748 if ( myConstructorId == 1 )
749 mySelection->AddFilter( myEdgeFilter );
751 if( !mySimulationTopoDs.IsNull() )
752 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
759 //=================================================================================
760 // function : CalculateVertexOnCurve()
761 // purpose : Calculate a Vertex on the curve given by 'anEdge'.
762 // : The position of resultVertex is given by aParameter.
763 // : For a linear edge, aParameter=0.0 gives the first vertex of edge
764 // : aParameter=1.0 gives the last vertex of edge
765 // : aParameter=0.5 gives the vertex on the middle of edge
766 // : It is possible to get vertices out of edge using values > 1.0 or < 0.0
767 //=================================================================================
768 bool GeometryGUI_PointDlg::CalculateVertexOnCurve(const TopoDS_Edge& anEdge, const Standard_Real aParameter, TopoDS_Shape& resultVertex)
770 #if OCC_VERSION_MAJOR >= 5
771 if( anEdge.IsNull() || !BRepAlgo::IsValid(anEdge) )
773 if( anEdge.IsNull() || !BRepAlgoAPI::IsValid(anEdge) )
777 Standard_Real first, last ;
778 Handle(Geom_Curve) curv = BRep_Tool::Curve(anEdge, first, last);
783 if( anEdge.Orientation() == TopAbs_FORWARD ) {
784 param = first + (last-first) * aParameter ;
787 param = last + (first-last) * aParameter ;
790 curv->D0( param, paramPoint ) ;
791 resultVertex = BRepBuilderAPI_MakeVertex(paramPoint);