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_VectorDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI_VectorDlg.h"
32 #include "GeometryGUI.h"
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "QAD_Config.h"
36 #include "utilities.h"
38 #include <qbuttongroup.h>
40 #include <qgroupbox.h>
41 #include <qcheckbox.h>
42 #include <qlineedit.h>
43 #include <qpushbutton.h>
44 #include <qradiobutton.h>
45 #include <qtoolbutton.h>
50 #include <qwhatsthis.h>
53 #include <qvalidator.h>
59 //=================================================================================
60 // class : GeometryGUI_VectorDlg()
61 // purpose : Constructs a GeometryGUI_VectorDlg which is a child of 'parent', with the
62 // name 'name' and widget flags set to 'f'.
63 // The dialog will by default be modeless, unless you set 'modal' to
64 // TRUE to construct a modal dialog.
65 //=================================================================================
66 GeometryGUI_VectorDlg::GeometryGUI_VectorDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
67 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
69 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_VECTOR_2P")));
70 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
71 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_VECTOR_DXYZ")));
74 setName( "GeometryGUI_VectorDlg" );
76 setCaption( tr( "GEOM_VECTOR_TITLE" ) );
77 setSizeGripEnabled( TRUE );
78 GeometryGUI_VectorDlgLayout = new QGridLayout( this );
79 GeometryGUI_VectorDlgLayout->setSpacing( 6 );
80 GeometryGUI_VectorDlgLayout->setMargin( 11 );
82 /***************************************************************/
83 GroupPoints = new QGroupBox( this, "GroupPoints" );
84 GroupPoints->setGeometry( QRect( 10, 10, 280, 90 ) );
85 GroupPoints->setTitle( tr( "GEOM_POINTS" ) );
86 GroupPoints->setFrameShape( QGroupBox::Box );
87 GroupPoints->setFrameShadow( QGroupBox::Sunken );
88 GroupPoints->setColumnLayout(0, Qt::Vertical );
89 GroupPoints->layout()->setSpacing( 0 );
90 GroupPoints->layout()->setMargin( 0 );
91 GroupPointsLayout = new QGridLayout( GroupPoints->layout() );
92 GroupPointsLayout->setAlignment( Qt::AlignTop );
93 GroupPointsLayout->setSpacing( 6 );
94 GroupPointsLayout->setMargin( 11 );
95 SelectButtonPt2 = new QPushButton( GroupPoints, "SelectButtonPt2" );
96 SelectButtonPt2->setText( tr( "" ) );
97 SelectButtonPt2->setPixmap( image1 );
98 GroupPointsLayout->addWidget( SelectButtonPt2, 1, 1 );
99 LineEditPt1 = new QLineEdit( GroupPoints, "LineEditPt1" );
100 GroupPointsLayout->addWidget( LineEditPt1, 0, 2 );
101 LineEditPt2 = new QLineEdit( GroupPoints, "LineEditPt2" );
102 GroupPointsLayout->addWidget( LineEditPt2, 1, 2 );
103 SelectButtonPt1 = new QPushButton( GroupPoints, "SelectButtonPt1" );
104 SelectButtonPt1->setText( tr( "" ) );
105 SelectButtonPt1->setPixmap( image1 );
106 SelectButtonPt1->setToggleButton( FALSE );
107 GroupPointsLayout->addWidget( SelectButtonPt1, 0, 1 );
108 TextLabelPt1 = new QLabel( GroupPoints, "TextLabelPt1" );
109 TextLabelPt1->setText( tr( "GEOM_POINT_I" ).arg("1") );
110 TextLabelPt1->setMinimumSize( QSize( 50, 0 ) );
111 TextLabelPt1->setFrameShape( QLabel::NoFrame );
112 TextLabelPt1->setFrameShadow( QLabel::Plain );
113 GroupPointsLayout->addWidget( TextLabelPt1, 0, 0 );
114 TextLabelPt2 = new QLabel( GroupPoints, "TextLabelPt2" );
115 TextLabelPt2->setText( tr( "GEOM_POINT_I" ).arg("2") );
116 TextLabelPt2->setMinimumSize( QSize( 50, 0 ) );
117 GroupPointsLayout->addWidget( TextLabelPt2, 1, 0 );
118 GeometryGUI_VectorDlgLayout->addWidget( GroupPoints, 1, 0 );
120 /***************************************************************/
121 GroupButtons = new QGroupBox( this, "GroupButtons" );
122 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
123 GroupButtons->setTitle( tr( "" ) );
124 GroupButtons->setColumnLayout(0, Qt::Vertical );
125 GroupButtons->layout()->setSpacing( 0 );
126 GroupButtons->layout()->setMargin( 0 );
127 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
128 GroupButtonsLayout->setAlignment( Qt::AlignTop );
129 GroupButtonsLayout->setSpacing( 6 );
130 GroupButtonsLayout->setMargin( 11 );
131 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
132 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
133 buttonCancel->setAutoDefault( TRUE );
134 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
135 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
136 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
137 buttonApply->setAutoDefault( TRUE );
138 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
139 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
140 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
141 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
142 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
143 buttonOk->setAutoDefault( TRUE );
144 buttonOk->setDefault( TRUE );
145 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
146 GeometryGUI_VectorDlgLayout->addWidget( GroupButtons, 2, 0 );
148 /***************************************************************/
149 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
150 GroupConstructors->setTitle( tr( "GEOM_VECTOR" ) );
151 GroupConstructors->setColumnLayout(0, Qt::Vertical );
152 GroupConstructors->layout()->setSpacing( 0 );
153 GroupConstructors->layout()->setMargin( 0 );
154 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
155 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
156 GroupConstructorsLayout->setSpacing( 6 );
157 GroupConstructorsLayout->setMargin( 11 );
158 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
159 Constructor1->setText( tr( "" ) );
160 Constructor1->setChecked( TRUE );
161 Constructor1->setPixmap( image0 );
162 Constructor1->setMinimumSize( QSize( 50, 0 ) );
163 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
164 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
165 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
166 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
167 Constructor2->setText( tr( "" ) );
168 Constructor2->setPixmap( image2 );
169 Constructor2->setMinimumSize( QSize( 50, 0 ) );
170 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
171 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
172 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
173 GeometryGUI_VectorDlgLayout->addWidget( GroupConstructors, 0, 0 );
175 /***************************************************************/
176 GroupCoordinates = new QGroupBox( this, "GroupCoordinates" );
177 GroupCoordinates->setGeometry( QRect( 10, 70, 280, 80 ) );
178 GroupCoordinates->setTitle( tr( "GEOM_COORDINATES" ) );
179 GroupCoordinates->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupCoordinates->sizePolicy().hasHeightForWidth() ) );
180 GroupCoordinates->setColumnLayout(0, Qt::Vertical );
181 GroupCoordinates->layout()->setSpacing( 0 );
182 GroupCoordinates->layout()->setMargin( 0 );
183 GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() );
184 GroupCoordinatesLayout->setAlignment( Qt::AlignTop );
185 GroupCoordinatesLayout->setSpacing( 6 );
186 GroupCoordinatesLayout->setMargin( 11 );
188 TextLabel_DZ = new QLabel( GroupCoordinates, "TextLabel_DZ" );
189 TextLabel_DZ->setText( tr( "GEOM_DZ" ) );
190 GroupCoordinatesLayout->addWidget( TextLabel_DZ, 0, 4 );
191 TextLabel_DY = new QLabel( GroupCoordinates, "TextLabel_DY" );
192 TextLabel_DY->setText( tr( "GEOM_DY" ) );
193 GroupCoordinatesLayout->addWidget( TextLabel_DY, 0, 2 );
194 TextLabel_DX = new QLabel( GroupCoordinates, "TextLabel_DX" );
195 TextLabel_DX->setText( tr( "GEOM_DX" ) );
196 GroupCoordinatesLayout->addWidget( TextLabel_DX, 0, 0 );
198 /* Spin boxes construction */
199 SpinBox_DX = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_DX" ) ;
200 GroupCoordinatesLayout->addWidget( SpinBox_DX, 0, 1 );
201 SpinBox_DY = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_DY" ) ;
202 GroupCoordinatesLayout->addWidget( SpinBox_DY, 0, 3 );
203 SpinBox_DZ = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_DZ" ) ;
204 GroupCoordinatesLayout->addWidget( SpinBox_DZ, 0, 5 );
206 QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
207 GroupCoordinatesLayout->addItem( spacer2, 1, 3 );
209 /* QCheckBox to reverse vector */
210 CheckBoxReverseVector = new QCheckBox( GroupCoordinates, "CheckBoxReverseVector" );
211 CheckBoxReverseVector->setText( tr( "GEOM_REVERSE_VECTOR" ) );
212 GroupCoordinatesLayout->addMultiCellWidget( CheckBoxReverseVector, 1, 1, 1, 5 );
213 /* same position than GroupPoints */
214 GeometryGUI_VectorDlgLayout->addWidget( GroupCoordinates, 1, 0 );
216 Init(Sel) ; /* Initialisations */
221 //=================================================================================
222 // function : ~GeometryGUI_VectorDlg()
223 // purpose : Destroys the object and frees any allocated resources
224 //=================================================================================
225 GeometryGUI_VectorDlg::~GeometryGUI_VectorDlg()
227 /* no need to delete child widgets, Qt does it all for us */
231 //=================================================================================
234 //=================================================================================
235 void GeometryGUI_VectorDlg::Init( SALOME_Selection* Sel )
239 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
240 step = St.toDouble() ;
242 /* min, max, step and decimals for spin boxes */
243 SpinBox_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
244 SpinBox_DX->SetValue( 0.0 ) ;
245 SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
246 SpinBox_DY->SetValue( 0.0 ) ;
247 SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
248 SpinBox_DZ->SetValue( 200.0 ) ;
251 GroupCoordinates->hide() ;
252 myConstructorId = 0 ;
253 Constructor1->setChecked( TRUE );
254 CheckBoxReverseVector->setChecked( FALSE );
256 myEditCurrentArgument = LineEditPt1 ;
258 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
259 myPoint1.SetCoord( 0.0, 0.0, 0.0 );
260 myPoint2.SetCoord( 0.0, 0.0, 0.0 );
261 myOkPoint1 = myOkPoint2 = false ;
262 mySimulationTopoDs.Nullify() ;
263 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
265 // TODO : previous selection in argument ?
268 /* Filter definitions */
269 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
270 myGeom = GEOM::GEOM_Gen::_narrow(comp);
271 myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
272 myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
273 mySelection->AddFilter(myVertexFilter) ; /* first filter used */
275 /* signals and slots connections */
276 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
277 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
278 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
279 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
280 connect( SelectButtonPt1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
281 connect( SelectButtonPt2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
283 connect( SpinBox_DX, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
284 connect( SpinBox_DY, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
285 connect( SpinBox_DZ, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
287 connect( LineEditPt1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
288 connect( LineEditPt2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
290 connect( CheckBoxReverseVector, SIGNAL (stateChanged(int) ), this, SLOT( ReverseVector(int) ) ) ;
292 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
293 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
294 /* to close dialog if study change */
295 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
297 /* Move widget on the botton right corner of main widget */
299 myGeomGUI->DefineDlgPosition( this, x, y ) ;
301 this->show() ; /* displays Dialog */
306 //=================================================================================
307 // function : ReverseVector()
308 // purpose : 'state' not used here
309 //=================================================================================
310 void GeometryGUI_VectorDlg::ReverseVector(int state)
312 if( myConstructorId == 1 ) {
318 SpinBox_DX->SetValue( myDx ) ;
319 SpinBox_DY->SetValue( myDy ) ;
320 SpinBox_DZ->SetValue( myDz ) ;
322 myPoint1.SetCoord(0.0, 0.0, 0.0) ;
323 myPoint2.SetCoord(myDx, myDy, myDz) ;
325 myGeomGUI->EraseSimulationShape() ;
326 mySimulationTopoDs.Nullify() ;
327 /* In the appropriate constructor */
328 if( myPoint1.Distance(myPoint2) > Precision::Confusion() ) {
329 mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
330 /* Add arrow in simulation */
331 bool noNeedToTest = AddArrowToSimulation(mySimulationTopoDs) ;
332 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
340 //=================================================================================
341 // function : ConstructorsClicked()
342 // purpose : Radio button management
343 //=================================================================================
344 void GeometryGUI_VectorDlg::ConstructorsClicked(int constructorId)
346 myGeomGUI->EraseSimulationShape() ;
347 mySelection->ClearFilters() ;
349 switch (constructorId)
354 GroupCoordinates->hide() ;
355 myConstructorId = constructorId ;
356 myEditCurrentArgument = LineEditPt1 ;
357 Constructor1->setChecked( TRUE );
358 LineEditPt1->setText(tr("")) ;
359 LineEditPt2->setText(tr("")) ;
360 myOkPoint1 = myOkPoint2 = false ;
362 /* filter for next selections */
363 mySelection->AddFilter( myVertexFilter );
364 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
370 GroupCoordinates->show();
371 myConstructorId = constructorId ;
372 CheckBoxReverseVector->setChecked( FALSE );
373 myOkPoint1 = myOkPoint2 = false ;
375 myEditCurrentArgument = SpinBox_DX ;
376 myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
381 myPoint2.SetCoord( myDx, myDy, myDz ) ;
382 SpinBox_DX->SetValue( myDx ) ;
383 SpinBox_DY->SetValue( myDy ) ;
384 SpinBox_DZ->SetValue( myDz ) ;
386 /* filter for next selections */
387 mySelection->AddFilter( myEdgeFilter );
388 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
390 if( myPoint1.Distance(myPoint2) > Precision::Confusion() ) {
391 mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
392 /* Add arrow in simulation */
393 bool noNeedToTest = AddArrowToSimulation(mySimulationTopoDs) ;
394 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
402 //=================================================================================
403 // function : ClickOnOk()
405 //=================================================================================
406 void GeometryGUI_VectorDlg::ClickOnOk()
408 this->ClickOnApply() ;
409 this->ClickOnCancel() ;
414 //=================================================================================
415 // function : ClickOnApply()
417 //=================================================================================
418 void GeometryGUI_VectorDlg::ClickOnApply()
420 myGeomGUI->EraseSimulationShape() ;
421 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
422 mySimulationTopoDs.Nullify() ;
423 switch(myConstructorId)
427 if(myOkPoint1 && myOkPoint2)
428 myGeomGUI->MakeVectorAndDisplay( myPoint1, myPoint2 ) ;
433 /* Recup args and call method */
434 myDx = SpinBox_DX->GetValue() ;
435 myDy = SpinBox_DY->GetValue() ;
436 myDz = SpinBox_DZ->GetValue() ;
437 myPoint1.SetCoord(0.0, 0.0, 0.0) ;
438 myPoint2.SetCoord(myDx, myDy, myDz) ;
439 myGeomGUI->MakeVectorAndDisplay( myPoint1, myPoint2 ) ;
449 //=================================================================================
450 // function : ClickOnCancel()
452 //=================================================================================
453 void GeometryGUI_VectorDlg::ClickOnCancel()
455 mySelection->ClearFilters() ;
456 myGeomGUI->EraseSimulationShape() ;
457 mySimulationTopoDs.Nullify() ;
458 disconnect( mySelection, 0, this, 0 );
459 myGeomGUI->ResetState() ;
465 //=================================================================================
466 // function : SelectionIntoArgument()
467 // purpose : Called when selection as changed or other case
468 //=================================================================================
469 void GeometryGUI_VectorDlg::SelectionIntoArgument()
471 myGeomGUI->EraseSimulationShape() ;
472 mySimulationTopoDs.Nullify() ;
474 /* Future name of shape */
475 QString aString = "";
477 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
479 if ( myEditCurrentArgument == LineEditPt1 ) {
480 LineEditPt1->setText("") ;
483 else if ( myEditCurrentArgument == LineEditPt2 ) {
484 LineEditPt2->setText("") ;
491 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
494 /* Constructors treatment */
495 if ( myConstructorId == 0 && myEditCurrentArgument == LineEditPt1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
496 LineEditPt1->setText(aString) ;
499 else if ( myConstructorId == 0 && myEditCurrentArgument == LineEditPt2 && myGeomGUI->VertexToPoint(S, myPoint2) ) {
500 LineEditPt2->setText(aString) ;
503 else if( myConstructorId == 1) {
505 /* linear edge selection verified */
506 if( myGeomGUI->LinearEdgeExtremities(S, P1, P2) ) {
508 myGeomGUI->GetBipointDxDyDz( P1, P2, myDx, myDy, myDz ) ;
509 SpinBox_DX->SetValue( myDx ) ;
510 SpinBox_DY->SetValue( myDy ) ;
511 SpinBox_DZ->SetValue( myDz ) ;
513 myPoint1.SetCoord(0.0, 0.0, 0.0) ;
514 myPoint2.SetCoord(myDx, myDy, myDz) ;
518 Standard_Real d = myPoint1.Distance(myPoint2) ;
520 if( ( myConstructorId == 0 && myOkPoint1 && myOkPoint2 && d > Precision::Confusion() ) ||
521 ( myConstructorId == 1 && d > Precision::Confusion() ) ) {
522 mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
523 /* Add arrow in simulation */
524 bool noNeedToTest = AddArrowToSimulation( mySimulationTopoDs ) ;
525 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
532 //=================================================================================
533 // function : SetEditCurrentArgument()
535 //=================================================================================
536 void GeometryGUI_VectorDlg::SetEditCurrentArgument()
538 QPushButton* send = (QPushButton*)sender();
539 switch (myConstructorId)
541 case 0: /* default constructor */
543 if(send == SelectButtonPt1) {
544 LineEditPt1->setFocus() ;
545 myEditCurrentArgument = LineEditPt1;
547 else if(send == SelectButtonPt2) {
548 LineEditPt2->setFocus() ;
549 myEditCurrentArgument = LineEditPt2;
551 mySelection->AddFilter(myVertexFilter) ;
552 SelectionIntoArgument() ;
561 //=================================================================================
562 // function : ValueChangedInSpinBox()
564 //=================================================================================
565 void GeometryGUI_VectorDlg::ValueChangedInSpinBox( double newValue )
567 if(myConstructorId != 1)
570 myGeomGUI->EraseSimulationShape() ;
571 mySimulationTopoDs.Nullify() ;
573 QObject* send = (QObject*)sender() ;
574 if (send == SpinBox_DX) {
576 } else if( send == SpinBox_DY ) {
578 } else if( send == SpinBox_DZ ) {
582 myPoint1.SetCoord(0.0, 0.0, 0.0) ;
583 myPoint2.SetCoord(myDx, myDy, myDz) ;
585 if ( myConstructorId == 1 && myPoint1.Distance(myPoint2) > Precision::Confusion() ) { // mySimulationTopoDs
586 mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
587 /* Create simulation vector with an arrow */
588 this->AddArrowToSimulation(mySimulationTopoDs ) ;
589 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
596 //=================================================================================
597 // function : LineEditReturnPressed()
599 //=================================================================================
600 void GeometryGUI_VectorDlg::LineEditReturnPressed()
602 QLineEdit* send = (QLineEdit*)sender();
603 if( send == LineEditPt1 )
604 myEditCurrentArgument = LineEditPt1 ;
605 else if ( send == LineEditPt2 )
606 myEditCurrentArgument = LineEditPt2 ;
610 /* User name of object input management */
611 /* If successfull the selection is changed and signal emitted... */
612 /* so SelectionIntoArgument() is automatically called. */
613 QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
614 const QString objectUserName = LE->text() ;
615 QWidget* thisWidget = (QWidget*)this ;
616 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
617 LE->setText( objectUserName ) ;
623 //=================================================================================
624 // function : DeactivateActiveDialog()
626 //=================================================================================
627 void GeometryGUI_VectorDlg::DeactivateActiveDialog()
629 if ( GroupConstructors->isEnabled() ) {
631 GroupConstructors->setEnabled(false) ;
632 GroupCoordinates->setEnabled(false) ;
633 GroupButtons->setEnabled(false) ;
634 GroupPoints->setEnabled(false) ;
635 disconnect( mySelection, 0, this, 0 );
636 myGeomGUI->EraseSimulationShape() ;
637 mySelection->ClearFilters() ;
643 //=================================================================================
644 // function : ActivateThisDialog()
646 //=================================================================================
647 void GeometryGUI_VectorDlg::ActivateThisDialog()
649 /* Emit a signal to deactivate the active dialog */
650 myGeomGUI->EmitSignalDeactivateDialog() ;
652 GroupConstructors->setEnabled(true) ;
653 GroupCoordinates->setEnabled(true) ;
654 GroupButtons->setEnabled(true) ;
655 GroupPoints->setEnabled(true) ;
657 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
658 if( !mySimulationTopoDs.IsNull() )
659 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
665 //=================================================================================
666 // function : enterEvent()
668 //=================================================================================
669 void GeometryGUI_VectorDlg::enterEvent(QEvent* e)
671 if ( GroupConstructors->isEnabled() )
673 ActivateThisDialog() ;
678 //=================================================================================
679 // function : closeEvent()
681 //=================================================================================
682 void GeometryGUI_VectorDlg::closeEvent( QCloseEvent* e )
684 this->ClickOnCancel() ; /* same than click on cancel button */
688 //=================================================================================
689 // function : AddArrowToSimulation()
690 // purpose : An arrow (cone topology) is added to 'modifiedShape'
691 // : to simulate a vector or an 'oriented line' display. The result is in 'modifiedShape'.
692 // : If an arrow can't be added returns false and 'modifiedShape' isn't modified !
693 //=================================================================================
694 bool GeometryGUI_VectorDlg::AddArrowToSimulation( TopoDS_Shape& modifiedShape )
697 /* Try to add a cone simulation shape to show direction of a linear edge */
698 if( myGeomGUI->CreateArrowForLinearEdge( modifiedShape, arrow ) ) {
699 TopoDS_Compound Comp ;
701 B.MakeCompound (Comp);
702 B.Add( Comp, modifiedShape ) ;
703 B.Add( Comp, arrow ) ;
704 modifiedShape = Comp ;