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 #include <BRepAlgoAPI.hxx>
44 #include <Geom_Curve.hxx>
46 #include <qbuttongroup.h>
48 #include <qgroupbox.h>
50 #include <qlineedit.h>
51 #include <qpushbutton.h>
52 #include <qradiobutton.h>
56 #include <qwhatsthis.h>
59 #include <qvalidator.h>
64 //=================================================================================
65 // class : GeometryGUI_PointDlg()
66 // purpose : Constructs a GeometryGUI_PointDlg which is a child of 'parent', with the
67 // name 'name' and widget flags set to 'f'.
68 // The dialog will by default be modeless, unless you set 'modal' to
69 // TRUE to construct a modal dialog.
70 //=================================================================================
71 GeometryGUI_PointDlg::GeometryGUI_PointDlg( QWidget* parent,
73 SALOME_Selection* Sel,
74 const Handle (AIS_InteractiveContext)& ic,
77 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
80 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_POINT")));
81 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
82 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_POINT_EDGE")));
85 setName( "GeometryGUI_PointDlg" );
87 setCaption( tr( "GEOM_POINT_TITLE" ) );
88 setSizeGripEnabled( TRUE );
89 GeometryGUI_PointDlgLayout = new QGridLayout( this );
90 GeometryGUI_PointDlgLayout->setSpacing( 6 );
91 GeometryGUI_PointDlgLayout->setMargin( 11 );
93 /***************************************************************/
94 GroupButtons = new QGroupBox( this, "GroupButtons" );
95 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
96 GroupButtons->setTitle( tr( "" ) );
97 GroupButtons->setColumnLayout(0, Qt::Vertical );
98 GroupButtons->layout()->setSpacing( 0 );
99 GroupButtons->layout()->setMargin( 0 );
100 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
101 GroupButtonsLayout->setAlignment( Qt::AlignTop );
102 GroupButtonsLayout->setSpacing( 6 );
103 GroupButtonsLayout->setMargin( 11 );
104 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
105 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
106 buttonCancel->setAutoDefault( TRUE );
107 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
108 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
109 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
110 buttonApply->setAutoDefault( TRUE );
111 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
112 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
113 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
114 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
115 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
116 buttonOk->setAutoDefault( TRUE );
117 buttonOk->setDefault( TRUE );
118 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
119 GeometryGUI_PointDlgLayout->addWidget( GroupButtons, 2, 0 );
121 /***************************************************************/
122 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
123 GroupConstructors->setTitle( tr( "Constructors" ) );
124 GroupConstructors->setExclusive( TRUE );
125 GroupConstructors->setColumnLayout(0, Qt::Vertical );
126 GroupConstructors->layout()->setSpacing( 0 );
127 GroupConstructors->layout()->setMargin( 0 );
128 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
129 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
130 GroupConstructorsLayout->setSpacing( 6 );
131 GroupConstructorsLayout->setMargin( 11 );
133 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
134 Constructor1->setText( tr( "" ) );
135 Constructor1->setPixmap( image0 );
136 Constructor1->setChecked( FALSE );
137 Constructor1->setMinimumSize( QSize( 50, 0 ) );
139 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
140 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
141 GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
143 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
144 Constructor2->setText( tr( "" ) );
145 Constructor2->setPixmap( image2 );
146 Constructor2->setChecked( TRUE );
147 Constructor2->setMinimumSize( QSize( 50, 0 ) );
149 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
150 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
151 GroupConstructorsLayout->addItem( spacer_3, 0, 3 );
153 GeometryGUI_PointDlgLayout->addWidget( GroupConstructors, 0, 0 );
156 /***************************************************************/
157 GroupCoordinates = new QGroupBox( this, "GroupCoordinates" );
158 GroupCoordinates->setTitle( tr( "GEOM_COORDINATES" ) );
159 GroupCoordinates->setColumnLayout(0, Qt::Vertical );
160 GroupCoordinates->layout()->setSpacing( 0 );
161 GroupCoordinates->layout()->setMargin( 0 );
162 GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() );
163 GroupCoordinatesLayout->setAlignment( Qt::AlignTop );
164 GroupCoordinatesLayout->setSpacing( 6 );
165 GroupCoordinatesLayout->setMargin( 11 );
167 TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" );
168 TextLabel_X->setText( tr( "GEOM_X" ) );
169 GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 );
170 TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" );
171 TextLabel_Y->setText( tr( "GEOM_Y" ) );
172 GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 );
173 TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" );
174 TextLabel_Z->setText( tr( "GEOM_Z" ) );
175 GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 );
177 /* Spin boxes construction */
178 SpinBox_X = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_X" ) ;
179 GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 );
180 SpinBox_Y = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_Y" ) ;
181 GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 );
182 SpinBox_Z = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_Z" ) ;
183 GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 );
184 GeometryGUI_PointDlgLayout->addWidget( GroupCoordinates, 1, 0 );
186 /***************************************************************/
187 GroupWithEdge = new QGroupBox( this, "GroupWithEdge" );
188 GroupWithEdge->setTitle( tr( "GEOM_PARAM_POINT" ) );
189 GroupWithEdge->setFrameShape( QGroupBox::Box );
190 GroupWithEdge->setFrameShadow( QGroupBox::Sunken );
191 GroupWithEdge->setColumnLayout(0, Qt::Vertical );
192 GroupWithEdge->layout()->setSpacing( 0 );
193 GroupWithEdge->layout()->setMargin( 0 );
194 GroupWithEdgeLayout = new QGridLayout( GroupWithEdge->layout() );
195 GroupWithEdgeLayout->setAlignment( Qt::AlignTop );
196 GroupWithEdgeLayout->setSpacing( 6 );
197 GroupWithEdgeLayout->setMargin( 11 );
199 LineEdit_Edge = new QLineEdit( GroupWithEdge, "LineEdit_Edge" );
200 GroupWithEdgeLayout->addWidget( LineEdit_Edge, 0, 2 );
202 SelectButton_Edge = new QPushButton( GroupWithEdge, "SelectButton_Edge" );
203 SelectButton_Edge->setText( tr( "" ) );
204 SelectButton_Edge->setPixmap( image1 );
205 SelectButton_Edge->setToggleButton( FALSE );
206 GroupWithEdgeLayout->addWidget( SelectButton_Edge, 0, 1 );
209 SpinBox_Parameter = new GeometryGUI_SpinBox( GroupWithEdge, "SpinBox_Parameter" );
210 GroupWithEdgeLayout->addWidget( SpinBox_Parameter, 1, 2 );
212 TextLabel_Edge = new QLabel( GroupWithEdge, "TextLabel_Edge" );
213 TextLabel_Edge->setText( tr( "GEOM_EDGE" ) );
214 TextLabel_Edge->setMinimumSize( QSize( 50, 0 ) );
215 TextLabel_Edge->setFrameShape( QLabel::NoFrame );
216 TextLabel_Edge->setFrameShadow( QLabel::Plain );
217 GroupWithEdgeLayout->addWidget( TextLabel_Edge, 0, 0 );
219 TextLabel_Parameter = new QLabel( GroupWithEdge, "TextLabel_Parameter" );
220 TextLabel_Parameter->setText( tr( "GEOM_PARAMETER" ) );
221 TextLabel_Parameter->setMinimumSize( QSize( 50, 0 ) );
222 TextLabel_Parameter->setFrameShape( QLabel::NoFrame );
223 TextLabel_Parameter->setFrameShadow( QLabel::Plain );
224 GroupWithEdgeLayout->addWidget( TextLabel_Parameter, 1, 0 );
226 GeometryGUI_PointDlgLayout->addWidget( GroupWithEdge, 1, 0 );
227 /***************************************************************/
229 /* Initialisation and display */
232 /* Move widget on the botton right corner of main widget */
233 QAD_Tools::alignWidget(this, parent, AlignBottom | AlignRight);
239 //=======================================================================
240 // function : ~GeometryGUI_PointDlg()
241 // purpose : Destructor
242 //=======================================================================
243 GeometryGUI_PointDlg::~GeometryGUI_PointDlg()
245 /* no need to delete child widgets, Qt does it all for us */
249 //=================================================================================
252 //=================================================================================
253 void GeometryGUI_PointDlg::Init(SALOME_Selection* Sel, const Handle(AIS_InteractiveContext)& ic)
256 /* Get setting of step value from file configuration */
258 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
259 step = St.toDouble() ;
261 /* min, max, step and decimals for spin boxes */
262 SpinBox_X->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
263 SpinBox_X->SetValue( 0.0 ) ;
264 SpinBox_Y->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
265 SpinBox_Y->SetValue( 0.0 ) ;
266 SpinBox_Z->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
267 SpinBox_Z->SetValue( 0.0 ) ;
269 /* spin box for parameter on edge */
270 double specificStep = 0.1 ;
271 SpinBox_Parameter->RangeStepAndValidator( -999999.99999, 999999.99999, specificStep, 5 ) ;
272 SpinBox_Parameter->SetValue( 0.50 ) ;
275 GroupCoordinates->show();
276 GroupWithEdge->hide() ;
277 myConstructorId = 0 ;
278 Constructor1->setChecked( TRUE );
280 /* filter for the second constructor */
281 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
282 myGeom = GEOM::GEOM_Gen::_narrow(comp);
283 myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
285 bool displayPoint = false ;
287 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
288 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
289 myGeomGUI->SetState(POINT_METHOD) ;
294 /* manages local context selection */
297 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
298 myLocalContextId = myIC->OpenLocalContext();
299 myGeomGUI->SetDisplayedObjectList();
300 /* sub shapes selection */
301 myLocalContextMode = TopAbs_VERTEX ;
302 myIC->ActivateStandardMode(myLocalContextMode) ;
303 myUseLocalContext = true ;
305 myUseLocalContext = false ;
309 myPoint.SetCoord( 0.0, 0.0, 0.0 ) ;
312 if( myGeomGUI->GetTopoFromSelection(mySelection, S) ) {
314 /* Filter a possibly previous selection and try to put it into coordinates */
315 if( myGeomGUI->VertexToPoint( S, myPoint) )
316 displayPoint = false ;
318 displayPoint = true ;
321 displayPoint = true ;
324 mySimulationTopoDs.Nullify() ;
325 PointIntoCoordinates(myPoint, displayPoint) ;
327 /* signals and slots connections */
328 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
329 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
330 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
331 connect( SelectButton_Edge, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
333 connect( GroupConstructors, SIGNAL(clicked(int) ), this, SLOT( ConstructorsClicked(int) ) ) ;
335 connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
336 connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
337 connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
339 connect( SpinBox_Parameter, SIGNAL ( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
340 connect( LineEdit_Edge, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
342 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ),this, SLOT( DeactivateActiveDialog() ) ) ;
343 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
344 // connect( mySelection, SIGNAL ( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ) ; done in constructor clicked !
346 /* Move widget on the botton right corner of main widget */
348 myGeomGUI->DefineDlgPosition( this, x, y ) ;
350 this->show() ; /* Displays this Dialog */
355 //=================================================================================
356 // function : ValueChangedInSpinBox()
358 //=================================================================================
359 void GeometryGUI_PointDlg::ValueChangedInSpinBox( double newValue )
361 GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender() ;
363 if( send == SpinBox_X ) {
365 vy = SpinBox_Y->GetValue() ;
366 vz = SpinBox_Z->GetValue() ;
367 } else if ( send == SpinBox_Y ) {
368 vx = SpinBox_X->GetValue() ;
370 vz = SpinBox_Z->GetValue() ;
371 } else if (send == SpinBox_Z ) {
372 vx = SpinBox_X->GetValue() ;
373 vy = SpinBox_Y->GetValue() ;
375 } else if (send == SpinBox_Parameter ) {
376 myParameter = newValue ;
381 switch (myConstructorId) {
382 case 0: // default constructor
384 myPoint.SetCoord(vx, vy, vz) ;
385 myGeomGUI->EraseSimulationShape() ;
386 mySimulationTopoDs = BRepBuilderAPI_MakeVertex (myPoint).Shape() ;
387 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
392 this->SelectionIntoArgument() ;
402 //=======================================================================
403 // funcion : PointIntoCoordinates()
404 // purpose : Sets user point coordinates into this dialog Spin boxes
405 // : and displays it or not according to 'bool displayPoint'
406 //=======================================================================
407 void GeometryGUI_PointDlg::PointIntoCoordinates(gp_Pnt P, bool displayPoint)
409 switch (myConstructorId) {
411 SpinBox_X->SetValue( P.X() ) ;
412 SpinBox_Y->SetValue( P.Y() ) ;
413 SpinBox_Z->SetValue( P.Z() ) ;
414 this->myPoint.SetCoord( P.X(), P.Y(), P.Z() ) ;
416 mySimulationTopoDs = BRepBuilderAPI_MakeVertex(P).Shape() ;
417 myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
431 //=================================================================================
432 // function : ConstructorsClicked()
433 // purpose : Radio button management
434 //=================================================================================
435 void GeometryGUI_PointDlg::ConstructorsClicked(int constructorId)
437 myGeomGUI->EraseSimulationShape() ;
438 myConstructorId = constructorId ;
439 switch (constructorId)
443 if ( myUseLocalContext == false && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
444 myLocalContextId = myIC->OpenLocalContext();
445 myGeomGUI->SetDisplayedObjectList();
446 /* sub shapes selection */
447 myLocalContextMode = TopAbs_VERTEX ;
448 myIC->ActivateStandardMode(myLocalContextMode) ;
449 myUseLocalContext = true ;
451 mySelection->ClearFilters() ;
452 GroupCoordinates->show();
453 GroupWithEdge->hide() ;
454 /* Display point simulation */
455 PointIntoCoordinates( this->myPoint, true ) ;
456 disconnect( mySelection, 0, this, 0 );
461 if ( myUseLocalContext == true && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
462 myIC->CloseLocalContext(myLocalContextId) ;
463 myUseLocalContext = false ;
465 LineEdit_Edge->setText("") ;
466 mySelection->AddFilter( myEdgeFilter );
467 GroupCoordinates->hide();
468 GroupWithEdge->show() ;
470 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
478 //=================================================================================
479 // function : LineEditReturnPressed()
481 //=================================================================================
482 void GeometryGUI_PointDlg::LineEditReturnPressed()
484 QLineEdit* send = (QLineEdit*)sender();
485 if( send == LineEdit_Edge ) {
486 /* User name of object input management */
487 /* If successfull the selection is changed and signal emitted... */
488 /* so SelectionIntoArgument() is automatically called. */
489 const QString objectUserName = send->text() ;
490 QWidget* thisWidget = (QWidget*)this ;
491 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
492 LineEdit_Edge->setText( objectUserName ) ;
500 //=================================================================================
501 // function : ClickOnOk()
503 //=================================================================================
504 void GeometryGUI_PointDlg::ClickOnOk()
506 this->ClickOnApply() ;
507 this->ClickOnCancel() ;
512 //=======================================================================
513 // function : ClickOnApply()
515 //=======================================================================
516 void GeometryGUI_PointDlg::ClickOnApply()
519 myGeomGUI->EraseSimulationShape() ;
521 /* Close local context */
522 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
523 myIC->CloseLocalContext(myLocalContextId) ;
524 myUseLocalContext = false ;
527 switch (myConstructorId) {
531 /* Recup args and call method */
532 double x = SpinBox_X->GetValue() ;
533 double y = SpinBox_Y->GetValue() ;
534 double z = SpinBox_Z->GetValue() ;
536 myGeomGUI->MakePointAndDisplay(x,y,z) ; /* WARNING : no display if a local context is opened */
537 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
538 /* no display if a local context is opened */
539 myLocalContextId = myIC->OpenLocalContext();
540 myGeomGUI->SetDisplayedObjectList();
541 /* sub shapes selection */
542 myLocalContextMode = TopAbs_VERTEX ;
543 myIC->ActivateStandardMode(myLocalContextMode);
544 myUseLocalContext = true ;
550 if( myOkEdge == true ) {
551 /* this constructor method has no idl interface : we use same than constructor 0 */
552 myGeomGUI->MakePointAndDisplay( myPoint.X(), myPoint.Y(), myPoint.Z() ) ;
562 //=================================================================================
563 // function : SelectionIntoArgument()
564 // purpose : Called when selection as changed (for constructors not using local context)
565 //=================================================================================
566 void GeometryGUI_PointDlg::SelectionIntoArgument()
568 myGeomGUI->EraseSimulationShape() ;
569 LineEdit_Edge->setText("") ;
570 QString aString = "" ; /* future name of selection */
571 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
573 this->myOkEdge = false ;
579 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
582 switch (myConstructorId)
588 LineEdit_Edge->setText(aString) ;
589 if( S.ShapeType() == TopAbs_EDGE ) {
590 if( CalculateVertexOnCurve( TopoDS::Edge(S), myParameter, mySimulationTopoDs) ) {
591 if ( myGeomGUI->VertexToPoint( mySimulationTopoDs, myPoint ) ) {
592 this->myOkEdge = true ;
593 myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
605 //=================================================================================
606 // function : SetEditCurrentArgument()
608 //=================================================================================
609 void GeometryGUI_PointDlg::SetEditCurrentArgument()
611 QPushButton* send = (QPushButton*)sender();
612 switch (myConstructorId)
614 case 0: // default constructor
618 if(send == SelectButton_Edge) {
619 LineEdit_Edge->setFocus() ;
620 SelectionIntoArgument() ;
629 //=======================================================================
630 // function : UseLocalContext()
631 // purpose : Return true when this method has opened a local context
632 // : Used from GeometryGUI
633 //=======================================================================
634 bool GeometryGUI_PointDlg::UseLocalContext()
636 return this->myUseLocalContext ;
640 //=======================================================================
641 // function : closeEvent()
643 //=======================================================================
644 void GeometryGUI_PointDlg::closeEvent(QCloseEvent* e)
646 this->ClickOnCancel() ; /* same than click on cancel button */
650 //=======================================================================
651 // function : ClickOnCancel()
653 //=======================================================================
654 void GeometryGUI_PointDlg::ClickOnCancel()
656 if ( myConstructorId == 0 && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
657 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
658 myIC = v3d->getAISContext();
659 if ( myIC->HasOpenedContext() ) {
660 myIC->CloseLocalContext(myLocalContextId) ;
661 myUseLocalContext = false ;
664 mySelection->ClearFilters() ;
665 myGeomGUI->SetActiveDialogBox(0) ;
666 myGeomGUI->EraseSimulationShape() ;
667 myGeomGUI->ResetState() ;
673 //=================================================================================
674 // function : enterEvent()
675 // purpose : to reactivate this dialog box when mouse enter onto the window
676 //=================================================================================
677 void GeometryGUI_PointDlg::enterEvent( QEvent* e)
679 if ( GroupConstructors->isEnabled() )
681 ActivateThisDialog() ;
685 //=================================================================================
686 // function : DeactivateActiveDialog()
687 // purpose : public slot to deactivate if active
688 //=================================================================================
689 void GeometryGUI_PointDlg::DeactivateActiveDialog()
691 if ( GroupConstructors->isEnabled() ) {
693 mySelection->ClearFilters() ;
694 GroupConstructors->setEnabled(false) ;
695 GroupCoordinates->setEnabled(false) ;
696 GroupWithEdge->setEnabled(false) ;
697 GroupButtons->setEnabled(false) ;
698 myGeomGUI->EraseSimulationShape() ;
699 myGeomGUI->ResetState() ;
700 myGeomGUI->SetActiveDialogBox(0) ;
701 if ( myConstructorId == 0 && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
702 myIC->CloseLocalContext(myLocalContextId) ;
703 myUseLocalContext = false ;
711 //=================================================================================
712 // function : ActivateThisDialog()
714 //=================================================================================
715 void GeometryGUI_PointDlg::ActivateThisDialog( )
718 if ( !GroupConstructors->isEnabled() ) { /* if not active */
720 myGeomGUI->EmitSignalDeactivateDialog() ;
721 GroupConstructors->setEnabled(true) ;
722 GroupCoordinates->setEnabled(true) ;
723 GroupWithEdge->setEnabled(true) ;
724 GroupButtons->setEnabled(true) ;
726 myGeomGUI->SetState(POINT_METHOD) ;
727 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
729 if ( myConstructorId == 0 ) {
731 mySelection->ClearFilters() ;
732 if( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
733 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
734 myIC = v3d->getAISContext();
735 myLocalContextId = myIC->OpenLocalContext();
736 myGeomGUI->SetDisplayedObjectList();
737 /* sub shapes selection */
738 myLocalContextMode = TopAbs_VERTEX ;
739 myIC->ActivateStandardMode(myLocalContextMode);
740 myUseLocalContext = true ;
744 if ( myConstructorId == 1 )
745 mySelection->AddFilter( myEdgeFilter );
747 if( !mySimulationTopoDs.IsNull() )
748 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
755 //=================================================================================
756 // function : CalculateVertexOnCurve()
757 // purpose : Calculate a Vertex on the curve given by 'anEdge'.
758 // : The position of resultVertex is given by aParameter.
759 // : For a linear edge, aParameter=0.0 gives the first vertex of edge
760 // : aParameter=1.0 gives the last vertex of edge
761 // : aParameter=0.5 gives the vertex on the middle of edge
762 // : It is possible to get vertices out of edge using values > 1.0 or < 0.0
763 //=================================================================================
764 bool GeometryGUI_PointDlg::CalculateVertexOnCurve(const TopoDS_Edge& anEdge, const Standard_Real aParameter, TopoDS_Shape& resultVertex)
766 if( anEdge.IsNull() || !BRepAlgoAPI::IsValid(anEdge) )
769 Standard_Real first, last ;
770 Handle(Geom_Curve) curv = BRep_Tool::Curve(anEdge, first, last);
775 if( anEdge.Orientation() == TopAbs_FORWARD ) {
776 param = first + (last-first) * aParameter ;
779 param = last + (first-last) * aParameter ;
782 curv->D0( param, paramPoint ) ;
783 resultVertex = BRepBuilderAPI_MakeVertex(paramPoint);