2 // File : GeometryGUI_VectorDlg.cxx
4 // Author : Lucien PIGNOLONI
6 // Module : GeometryGUI
7 // Copyright : OPEN CASCADE
10 #include "GeometryGUI_VectorDlg.h"
12 #include "GeometryGUI.h"
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Config.h"
16 #include "utilities.h"
18 #include <qbuttongroup.h>
20 #include <qgroupbox.h>
21 #include <qcheckbox.h>
22 #include <qlineedit.h>
23 #include <qpushbutton.h>
24 #include <qradiobutton.h>
25 #include <qtoolbutton.h>
30 #include <qwhatsthis.h>
33 #include <qvalidator.h>
39 //=================================================================================
40 // class : GeometryGUI_VectorDlg()
41 // purpose : Constructs a GeometryGUI_VectorDlg which is a child of 'parent', with the
42 // name 'name' and widget flags set to 'f'.
43 // The dialog will by default be modeless, unless you set 'modal' to
44 // TRUE to construct a modal dialog.
45 //=================================================================================
46 GeometryGUI_VectorDlg::GeometryGUI_VectorDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
47 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
49 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_VECTOR_2P")));
50 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
51 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_VECTOR_DXYZ")));
54 setName( "GeometryGUI_VectorDlg" );
56 setCaption( tr( "GEOM_VECTOR_TITLE" ) );
57 setSizeGripEnabled( TRUE );
58 GeometryGUI_VectorDlgLayout = new QGridLayout( this );
59 GeometryGUI_VectorDlgLayout->setSpacing( 6 );
60 GeometryGUI_VectorDlgLayout->setMargin( 11 );
62 /***************************************************************/
63 GroupPoints = new QGroupBox( this, "GroupPoints" );
64 GroupPoints->setGeometry( QRect( 10, 10, 280, 90 ) );
65 GroupPoints->setTitle( tr( "GEOM_POINTS" ) );
66 GroupPoints->setFrameShape( QGroupBox::Box );
67 GroupPoints->setFrameShadow( QGroupBox::Sunken );
68 GroupPoints->setColumnLayout(0, Qt::Vertical );
69 GroupPoints->layout()->setSpacing( 0 );
70 GroupPoints->layout()->setMargin( 0 );
71 GroupPointsLayout = new QGridLayout( GroupPoints->layout() );
72 GroupPointsLayout->setAlignment( Qt::AlignTop );
73 GroupPointsLayout->setSpacing( 6 );
74 GroupPointsLayout->setMargin( 11 );
75 SelectButtonPt2 = new QPushButton( GroupPoints, "SelectButtonPt2" );
76 SelectButtonPt2->setText( tr( "" ) );
77 SelectButtonPt2->setPixmap( image1 );
78 GroupPointsLayout->addWidget( SelectButtonPt2, 1, 1 );
79 LineEditPt1 = new QLineEdit( GroupPoints, "LineEditPt1" );
80 GroupPointsLayout->addWidget( LineEditPt1, 0, 2 );
81 LineEditPt2 = new QLineEdit( GroupPoints, "LineEditPt2" );
82 GroupPointsLayout->addWidget( LineEditPt2, 1, 2 );
83 SelectButtonPt1 = new QPushButton( GroupPoints, "SelectButtonPt1" );
84 SelectButtonPt1->setText( tr( "" ) );
85 SelectButtonPt1->setPixmap( image1 );
86 SelectButtonPt1->setToggleButton( FALSE );
87 GroupPointsLayout->addWidget( SelectButtonPt1, 0, 1 );
88 TextLabelPt1 = new QLabel( GroupPoints, "TextLabelPt1" );
89 TextLabelPt1->setText( tr( "GEOM_POINT_I" ).arg("1") );
90 TextLabelPt1->setMinimumSize( QSize( 50, 0 ) );
91 TextLabelPt1->setFrameShape( QLabel::NoFrame );
92 TextLabelPt1->setFrameShadow( QLabel::Plain );
93 GroupPointsLayout->addWidget( TextLabelPt1, 0, 0 );
94 TextLabelPt2 = new QLabel( GroupPoints, "TextLabelPt2" );
95 TextLabelPt2->setText( tr( "GEOM_POINT_I" ).arg("2") );
96 TextLabelPt2->setMinimumSize( QSize( 50, 0 ) );
97 GroupPointsLayout->addWidget( TextLabelPt2, 1, 0 );
98 GeometryGUI_VectorDlgLayout->addWidget( GroupPoints, 1, 0 );
100 /***************************************************************/
101 GroupButtons = new QGroupBox( this, "GroupButtons" );
102 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
103 GroupButtons->setTitle( tr( "" ) );
104 GroupButtons->setColumnLayout(0, Qt::Vertical );
105 GroupButtons->layout()->setSpacing( 0 );
106 GroupButtons->layout()->setMargin( 0 );
107 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
108 GroupButtonsLayout->setAlignment( Qt::AlignTop );
109 GroupButtonsLayout->setSpacing( 6 );
110 GroupButtonsLayout->setMargin( 11 );
111 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
112 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
113 buttonCancel->setAutoDefault( TRUE );
114 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
115 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
116 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
117 buttonApply->setAutoDefault( TRUE );
118 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
119 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
120 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
121 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
122 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
123 buttonOk->setAutoDefault( TRUE );
124 buttonOk->setDefault( TRUE );
125 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
126 GeometryGUI_VectorDlgLayout->addWidget( GroupButtons, 2, 0 );
128 /***************************************************************/
129 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
130 GroupConstructors->setTitle( tr( "GEOM_VECTOR" ) );
131 GroupConstructors->setColumnLayout(0, Qt::Vertical );
132 GroupConstructors->layout()->setSpacing( 0 );
133 GroupConstructors->layout()->setMargin( 0 );
134 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
135 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
136 GroupConstructorsLayout->setSpacing( 6 );
137 GroupConstructorsLayout->setMargin( 11 );
138 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
139 Constructor1->setText( tr( "" ) );
140 Constructor1->setChecked( TRUE );
141 Constructor1->setPixmap( image0 );
142 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, 3 );
146 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
147 Constructor2->setText( tr( "" ) );
148 Constructor2->setPixmap( image2 );
149 Constructor2->setMinimumSize( QSize( 50, 0 ) );
150 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
151 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
152 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
153 GeometryGUI_VectorDlgLayout->addWidget( GroupConstructors, 0, 0 );
155 /***************************************************************/
156 GroupCoordinates = new QGroupBox( this, "GroupCoordinates" );
157 GroupCoordinates->setGeometry( QRect( 10, 70, 280, 80 ) );
158 GroupCoordinates->setTitle( tr( "GEOM_COORDINATES" ) );
159 GroupCoordinates->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupCoordinates->sizePolicy().hasHeightForWidth() ) );
160 GroupCoordinates->setColumnLayout(0, Qt::Vertical );
161 GroupCoordinates->layout()->setSpacing( 0 );
162 GroupCoordinates->layout()->setMargin( 0 );
163 GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() );
164 GroupCoordinatesLayout->setAlignment( Qt::AlignTop );
165 GroupCoordinatesLayout->setSpacing( 6 );
166 GroupCoordinatesLayout->setMargin( 11 );
168 TextLabel_DZ = new QLabel( GroupCoordinates, "TextLabel_DZ" );
169 TextLabel_DZ->setText( tr( "GEOM_DZ" ) );
170 GroupCoordinatesLayout->addWidget( TextLabel_DZ, 0, 4 );
171 TextLabel_DY = new QLabel( GroupCoordinates, "TextLabel_DY" );
172 TextLabel_DY->setText( tr( "GEOM_DY" ) );
173 GroupCoordinatesLayout->addWidget( TextLabel_DY, 0, 2 );
174 TextLabel_DX = new QLabel( GroupCoordinates, "TextLabel_DX" );
175 TextLabel_DX->setText( tr( "GEOM_DX" ) );
176 GroupCoordinatesLayout->addWidget( TextLabel_DX, 0, 0 );
178 /* Spin boxes construction */
179 SpinBox_DX = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_DX" ) ;
180 GroupCoordinatesLayout->addWidget( SpinBox_DX, 0, 1 );
181 SpinBox_DY = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_DY" ) ;
182 GroupCoordinatesLayout->addWidget( SpinBox_DY, 0, 3 );
183 SpinBox_DZ = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_DZ" ) ;
184 GroupCoordinatesLayout->addWidget( SpinBox_DZ, 0, 5 );
186 QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
187 GroupCoordinatesLayout->addItem( spacer2, 1, 3 );
189 /* QCheckBox to reverse vector */
190 CheckBoxReverseVector = new QCheckBox( GroupCoordinates, "CheckBoxReverseVector" );
191 CheckBoxReverseVector->setText( tr( "GEOM_REVERSE_VECTOR" ) );
192 GroupCoordinatesLayout->addMultiCellWidget( CheckBoxReverseVector, 1, 1, 1, 5 );
193 /* same position than GroupPoints */
194 GeometryGUI_VectorDlgLayout->addWidget( GroupCoordinates, 1, 0 );
196 Init(Sel) ; /* Initialisations */
201 //=================================================================================
202 // function : ~GeometryGUI_VectorDlg()
203 // purpose : Destroys the object and frees any allocated resources
204 //=================================================================================
205 GeometryGUI_VectorDlg::~GeometryGUI_VectorDlg()
207 /* no need to delete child widgets, Qt does it all for us */
211 //=================================================================================
214 //=================================================================================
215 void GeometryGUI_VectorDlg::Init( SALOME_Selection* Sel )
219 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
220 step = St.toDouble() ;
222 /* min, max, step and decimals for spin boxes */
223 SpinBox_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
224 SpinBox_DX->SetValue( 0.0 ) ;
225 SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
226 SpinBox_DY->SetValue( 0.0 ) ;
227 SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
228 SpinBox_DZ->SetValue( 200.0 ) ;
231 GroupCoordinates->hide() ;
232 myConstructorId = 0 ;
233 Constructor1->setChecked( TRUE );
234 CheckBoxReverseVector->setChecked( FALSE );
236 myEditCurrentArgument = LineEditPt1 ;
238 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
239 myPoint1.SetCoord( 0.0, 0.0, 0.0 );
240 myPoint2.SetCoord( 0.0, 0.0, 0.0 );
241 myOkPoint1 = myOkPoint2 = false ;
242 mySimulationTopoDs.Nullify() ;
243 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
245 // TODO : previous selection in argument ?
248 /* Filter definitions */
249 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
250 myGeom = GEOM::GEOM_Gen::_narrow(comp);
251 myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
252 myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
253 mySelection->AddFilter(myVertexFilter) ; /* first filter used */
255 /* signals and slots connections */
256 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
257 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
258 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
259 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
260 connect( SelectButtonPt1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
261 connect( SelectButtonPt2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
263 connect( SpinBox_DX, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
264 connect( SpinBox_DY, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
265 connect( SpinBox_DZ, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
267 connect( LineEditPt1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
268 connect( LineEditPt2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
270 connect( CheckBoxReverseVector, SIGNAL (stateChanged(int) ), this, SLOT( ReverseVector(int) ) ) ;
272 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
273 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
274 /* to close dialog if study change */
275 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
277 /* Move widget on the botton right corner of main widget */
279 myGeomGUI->DefineDlgPosition( this, x, y ) ;
281 this->show() ; /* displays Dialog */
286 //=================================================================================
287 // function : ReverseVector()
288 // purpose : 'state' not used here
289 //=================================================================================
290 void GeometryGUI_VectorDlg::ReverseVector(int state)
292 if( myConstructorId == 1 ) {
298 SpinBox_DX->SetValue( myDx ) ;
299 SpinBox_DY->SetValue( myDy ) ;
300 SpinBox_DZ->SetValue( myDz ) ;
302 myPoint1.SetCoord(0.0, 0.0, 0.0) ;
303 myPoint2.SetCoord(myDx, myDy, myDz) ;
305 myGeomGUI->EraseSimulationShape() ;
306 mySimulationTopoDs.Nullify() ;
307 /* In the appropriate constructor */
308 if( myPoint1.Distance(myPoint2) > Precision::Confusion() ) {
309 mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
310 /* Add arrow in simulation */
311 bool noNeedToTest = AddArrowToSimulation(mySimulationTopoDs) ;
312 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
320 //=================================================================================
321 // function : ConstructorsClicked()
322 // purpose : Radio button management
323 //=================================================================================
324 void GeometryGUI_VectorDlg::ConstructorsClicked(int constructorId)
326 myGeomGUI->EraseSimulationShape() ;
327 mySelection->ClearFilters() ;
329 switch (constructorId)
334 GroupCoordinates->hide() ;
335 myConstructorId = constructorId ;
336 myEditCurrentArgument = LineEditPt1 ;
337 Constructor1->setChecked( TRUE );
338 LineEditPt1->setText(tr("")) ;
339 LineEditPt2->setText(tr("")) ;
340 myOkPoint1 = myOkPoint2 = false ;
342 /* filter for next selections */
343 mySelection->AddFilter( myVertexFilter );
344 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
350 GroupCoordinates->show();
351 myConstructorId = constructorId ;
352 CheckBoxReverseVector->setChecked( FALSE );
353 myOkPoint1 = myOkPoint2 = false ;
355 myEditCurrentArgument = SpinBox_DX ;
356 myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
361 myPoint2.SetCoord( myDx, myDy, myDz ) ;
362 SpinBox_DX->SetValue( myDx ) ;
363 SpinBox_DY->SetValue( myDy ) ;
364 SpinBox_DZ->SetValue( myDz ) ;
366 /* filter for next selections */
367 mySelection->AddFilter( myEdgeFilter );
368 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
370 if( myPoint1.Distance(myPoint2) > Precision::Confusion() ) {
371 mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
372 /* Add arrow in simulation */
373 bool noNeedToTest = AddArrowToSimulation(mySimulationTopoDs) ;
374 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
382 //=================================================================================
383 // function : ClickOnOk()
385 //=================================================================================
386 void GeometryGUI_VectorDlg::ClickOnOk()
388 this->ClickOnApply() ;
389 this->ClickOnCancel() ;
394 //=================================================================================
395 // function : ClickOnApply()
397 //=================================================================================
398 void GeometryGUI_VectorDlg::ClickOnApply()
400 myGeomGUI->EraseSimulationShape() ;
401 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
402 mySimulationTopoDs.Nullify() ;
403 switch(myConstructorId)
407 if(myOkPoint1 && myOkPoint2)
408 myGeomGUI->MakeVectorAndDisplay( myPoint1, myPoint2 ) ;
413 /* Recup args and call method */
414 myDx = SpinBox_DX->GetValue() ;
415 myDy = SpinBox_DY->GetValue() ;
416 myDz = SpinBox_DZ->GetValue() ;
417 myPoint1.SetCoord(0.0, 0.0, 0.0) ;
418 myPoint2.SetCoord(myDx, myDy, myDz) ;
419 myGeomGUI->MakeVectorAndDisplay( myPoint1, myPoint2 ) ;
429 //=================================================================================
430 // function : ClickOnCancel()
432 //=================================================================================
433 void GeometryGUI_VectorDlg::ClickOnCancel()
435 mySelection->ClearFilters() ;
436 myGeomGUI->EraseSimulationShape() ;
437 mySimulationTopoDs.Nullify() ;
438 disconnect( mySelection, 0, this, 0 );
439 myGeomGUI->ResetState() ;
445 //=================================================================================
446 // function : SelectionIntoArgument()
447 // purpose : Called when selection as changed or other case
448 //=================================================================================
449 void GeometryGUI_VectorDlg::SelectionIntoArgument()
451 myGeomGUI->EraseSimulationShape() ;
452 mySimulationTopoDs.Nullify() ;
454 /* Future name of shape */
455 QString aString = "";
457 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
459 if ( myEditCurrentArgument == LineEditPt1 ) {
460 LineEditPt1->setText("") ;
463 else if ( myEditCurrentArgument == LineEditPt2 ) {
464 LineEditPt2->setText("") ;
471 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
474 /* Constructors treatment */
475 if ( myConstructorId == 0 && myEditCurrentArgument == LineEditPt1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
476 LineEditPt1->setText(aString) ;
479 else if ( myConstructorId == 0 && myEditCurrentArgument == LineEditPt2 && myGeomGUI->VertexToPoint(S, myPoint2) ) {
480 LineEditPt2->setText(aString) ;
483 else if( myConstructorId == 1) {
485 /* linear edge selection verified */
486 if( myGeomGUI->LinearEdgeExtremities(S, P1, P2) ) {
488 myGeomGUI->GetBipointDxDyDz( P1, P2, myDx, myDy, myDz ) ;
489 SpinBox_DX->SetValue( myDx ) ;
490 SpinBox_DY->SetValue( myDy ) ;
491 SpinBox_DZ->SetValue( myDz ) ;
493 myPoint1.SetCoord(0.0, 0.0, 0.0) ;
494 myPoint2.SetCoord(myDx, myDy, myDz) ;
498 Standard_Real d = myPoint1.Distance(myPoint2) ;
500 if( ( myConstructorId == 0 && myOkPoint1 && myOkPoint2 && d > Precision::Confusion() ) ||
501 ( myConstructorId == 1 && d > Precision::Confusion() ) ) {
502 mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
503 /* Add arrow in simulation */
504 bool noNeedToTest = AddArrowToSimulation( mySimulationTopoDs ) ;
505 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
512 //=================================================================================
513 // function : SetEditCurrentArgument()
515 //=================================================================================
516 void GeometryGUI_VectorDlg::SetEditCurrentArgument()
518 QPushButton* send = (QPushButton*)sender();
519 switch (myConstructorId)
521 case 0: /* default constructor */
523 if(send == SelectButtonPt1) {
524 LineEditPt1->setFocus() ;
525 myEditCurrentArgument = LineEditPt1;
527 else if(send == SelectButtonPt2) {
528 LineEditPt2->setFocus() ;
529 myEditCurrentArgument = LineEditPt2;
531 mySelection->AddFilter(myVertexFilter) ;
532 SelectionIntoArgument() ;
541 //=================================================================================
542 // function : ValueChangedInSpinBox()
544 //=================================================================================
545 void GeometryGUI_VectorDlg::ValueChangedInSpinBox( double newValue )
547 if(myConstructorId != 1)
550 myGeomGUI->EraseSimulationShape() ;
551 mySimulationTopoDs.Nullify() ;
553 QObject* send = (QObject*)sender() ;
554 if (send == SpinBox_DX) {
556 } else if( send == SpinBox_DY ) {
558 } else if( send == SpinBox_DZ ) {
562 myPoint1.SetCoord(0.0, 0.0, 0.0) ;
563 myPoint2.SetCoord(myDx, myDy, myDz) ;
565 if ( myConstructorId == 1 && myPoint1.Distance(myPoint2) > Precision::Confusion() ) { // mySimulationTopoDs
566 mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
567 /* Create simulation vector with an arrow */
568 this->AddArrowToSimulation(mySimulationTopoDs ) ;
569 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
576 //=================================================================================
577 // function : LineEditReturnPressed()
579 //=================================================================================
580 void GeometryGUI_VectorDlg::LineEditReturnPressed()
582 QLineEdit* send = (QLineEdit*)sender();
583 if( send == LineEditPt1 )
584 myEditCurrentArgument = LineEditPt1 ;
585 else if ( send == LineEditPt2 )
586 myEditCurrentArgument = LineEditPt2 ;
590 /* User name of object input management */
591 /* If successfull the selection is changed and signal emitted... */
592 /* so SelectionIntoArgument() is automatically called. */
593 QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
594 const QString objectUserName = LE->text() ;
595 QWidget* thisWidget = (QWidget*)this ;
596 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
597 LE->setText( objectUserName ) ;
603 //=================================================================================
604 // function : DeactivateActiveDialog()
606 //=================================================================================
607 void GeometryGUI_VectorDlg::DeactivateActiveDialog()
609 if ( GroupConstructors->isEnabled() ) {
611 GroupConstructors->setEnabled(false) ;
612 GroupCoordinates->setEnabled(false) ;
613 GroupButtons->setEnabled(false) ;
614 GroupPoints->setEnabled(false) ;
615 disconnect( mySelection, 0, this, 0 );
616 myGeomGUI->EraseSimulationShape() ;
617 mySelection->ClearFilters() ;
623 //=================================================================================
624 // function : ActivateThisDialog()
626 //=================================================================================
627 void GeometryGUI_VectorDlg::ActivateThisDialog()
629 /* Emit a signal to deactivate the active dialog */
630 myGeomGUI->EmitSignalDeactivateDialog() ;
632 GroupConstructors->setEnabled(true) ;
633 GroupCoordinates->setEnabled(true) ;
634 GroupButtons->setEnabled(true) ;
635 GroupPoints->setEnabled(true) ;
637 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
638 if( !mySimulationTopoDs.IsNull() )
639 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
645 //=================================================================================
646 // function : enterEvent()
648 //=================================================================================
649 void GeometryGUI_VectorDlg::enterEvent(QEvent* e)
651 if ( GroupConstructors->isEnabled() )
653 ActivateThisDialog() ;
658 //=================================================================================
659 // function : closeEvent()
661 //=================================================================================
662 void GeometryGUI_VectorDlg::closeEvent( QCloseEvent* e )
664 this->ClickOnCancel() ; /* same than click on cancel button */
668 //=================================================================================
669 // function : AddArrowToSimulation()
670 // purpose : An arrow (cone topology) is added to 'modifiedShape'
671 // : to simulate a vector or an 'oriented line' display. The result is in 'modifiedShape'.
672 // : If an arrow can't be added returns false and 'modifiedShape' isn't modified !
673 //=================================================================================
674 bool GeometryGUI_VectorDlg::AddArrowToSimulation( TopoDS_Shape& modifiedShape )
677 /* Try to add a cone simulation shape to show direction of a linear edge */
678 if( myGeomGUI->CreateArrowForLinearEdge( modifiedShape, arrow ) ) {
679 TopoDS_Compound Comp ;
681 B.MakeCompound (Comp);
682 B.Add( Comp, modifiedShape ) ;
683 B.Add( Comp, arrow ) ;
684 modifiedShape = Comp ;