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_InertiaDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "GeometryGUI_InertiaDlg.h"
31 #include "GeometryGUI.h"
33 #include <qbuttongroup.h>
34 #include <qgroupbox.h>
36 #include <qlineedit.h>
37 #include <qpushbutton.h>
38 #include <qradiobutton.h>
42 #include <qwhatsthis.h>
46 //=================================================================================
47 // class : GeometryGUI_InertiaDlg()
48 // purpose : Constructs a GeometryGUI_InertiaDlg which is a child of 'parent', with the
49 // name 'name' and widget flags set to 'f'.
50 // The dialog will by default be modeless, unless you set 'modal' to
51 // TRUE to construct a modal dialog.
52 //=================================================================================
53 GeometryGUI_InertiaDlg::GeometryGUI_InertiaDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
54 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
56 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_INERTIA")));
57 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
60 setName( "GeometryGUI_InertiaDlg" );
62 setCaption( tr( "GEOM_INERTIA_TITLE" ) );
63 setSizeGripEnabled( TRUE );
64 GeometryGUI_InertiaDlgLayout = new QGridLayout( this );
65 GeometryGUI_InertiaDlgLayout->setSpacing( 6 );
66 GeometryGUI_InertiaDlgLayout->setMargin( 11 );
68 /***************************************************************/
69 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
70 GroupConstructors->setTitle( tr( "GEOM_INERTIA_CONSTR" ) );
71 GroupConstructors->setExclusive( TRUE );
72 GroupConstructors->setColumnLayout(0, Qt::Vertical );
73 GroupConstructors->layout()->setSpacing( 0 );
74 GroupConstructors->layout()->setMargin( 0 );
75 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
76 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
77 GroupConstructorsLayout->setSpacing( 6 );
78 GroupConstructorsLayout->setMargin( 11 );
79 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
80 GroupConstructorsLayout->addItem( spacer, 0, 1 );
81 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
82 Constructor1->setText( tr( "" ) );
83 Constructor1->setPixmap( image0 );
84 Constructor1->setChecked( TRUE );
85 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
86 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
87 GeometryGUI_InertiaDlgLayout->addWidget( GroupConstructors, 0, 0 );
89 /***************************************************************/
90 GroupC1 = new QGroupBox( this, "GroupC1" );
91 GroupC1->setTitle( tr( "GEOM_OBJECT_RESULT" ) );
92 GroupC1->setColumnLayout(0, Qt::Vertical );
93 GroupC1->layout()->setSpacing( 0 );
94 GroupC1->layout()->setMargin( 0 );
95 GroupC1Layout = new QGridLayout( GroupC1->layout() );
96 GroupC1Layout->setAlignment( Qt::AlignTop );
97 GroupC1Layout->setSpacing( 6 );
98 GroupC1Layout->setMargin( 11 );
99 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
100 TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) );
101 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
102 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
103 TextLabelC1A1->setFrameShadow( QLabel::Plain );
104 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
105 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
106 SelectButtonC1A1->setText( tr( "" ) );
107 SelectButtonC1A1->setPixmap( image1 );
108 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
109 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
110 LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
111 LineEditC1A1->setMinimumSize( QSize( 220, 0 ) );
112 GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 4 );
113 TextLabel_Matrix = new QLabel( GroupC1, "TextLabel_Matrix" );
114 TextLabel_Matrix->setText( tr( "GEOM_MATRIX" ) );
115 TextLabel_Matrix->setMinimumSize( QSize( 50, 0 ) );
116 TextLabel_Matrix->setFrameShape( QLabel::NoFrame );
117 TextLabel_Matrix->setFrameShadow( QLabel::Plain );
118 GroupC1Layout->addWidget( TextLabel_Matrix, 1, 0 );
119 TextLabelMatrix_11 = new QLabel( GroupC1, "TextLabelMatrix_11" );
120 TextLabelMatrix_11->setText( tr( "GEOM_INERTIA_I" ).arg("1") );
121 TextLabelMatrix_11->setMinimumSize( QSize( 0, 0 ) );
122 TextLabelMatrix_11->setFrameShape( QLabel::NoFrame );
123 TextLabelMatrix_11->setFrameShadow( QLabel::Plain );
124 TextLabelMatrix_11->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
125 GroupC1Layout->addWidget( TextLabelMatrix_11, 1, 1 );
126 TextLabelMatrix_21 = new QLabel( GroupC1, "TextLabelMatrix_21" );
127 TextLabelMatrix_21->setText( tr( "GEOM_INERTIA_I" ).arg("2") );
128 TextLabelMatrix_21->setMinimumSize( QSize( 0, 0 ) );
129 TextLabelMatrix_21->setFrameShape( QLabel::NoFrame );
130 TextLabelMatrix_21->setFrameShadow( QLabel::Plain );
131 TextLabelMatrix_21->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
132 GroupC1Layout->addWidget( TextLabelMatrix_21, 2, 1 );
133 TextLabelMatrix_31 = new QLabel( GroupC1, "TextLabelMatrix_31" );
134 TextLabelMatrix_31->setText( tr( "GEOM_INERTIA_I" ).arg("3") );
135 TextLabelMatrix_31->setMinimumSize( QSize( 0, 0 ) );
136 TextLabelMatrix_31->setFrameShape( QLabel::NoFrame );
137 TextLabelMatrix_31->setFrameShadow( QLabel::Plain );
138 TextLabelMatrix_31->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
139 GroupC1Layout->addWidget( TextLabelMatrix_31, 3, 1 );
140 LineEdit_L1C1 = new QLineEdit( GroupC1, "LineEdit_L1C1" );
141 LineEdit_L1C1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L1C1->sizePolicy().hasHeightForWidth() ) );
142 LineEdit_L1C1->setMinimumSize( QSize( 70, 0 ) );
143 //LineEdit_L1C1->setEnabled( FALSE );
144 LineEdit_L1C1->setReadOnly( TRUE );
145 LineEdit_L1C1->setText( tr( "" ) );
146 GroupC1Layout->addWidget( LineEdit_L1C1, 1, 2 );
147 LineEdit_L1C2 = new QLineEdit( GroupC1, "LineEdit_L1C2" );
148 LineEdit_L1C2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L1C2->sizePolicy().hasHeightForWidth() ) );
149 LineEdit_L1C2->setMinimumSize( QSize( 70, 0 ) );
150 //LineEdit_L1C2->setEnabled( FALSE );
151 LineEdit_L1C2->setReadOnly( TRUE );
152 GroupC1Layout->addWidget( LineEdit_L1C2, 1, 3 );
153 LineEdit_L1C3 = new QLineEdit( GroupC1, "LineEdit_L1C3" );
154 LineEdit_L1C3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L1C3->sizePolicy().hasHeightForWidth() ) );
155 LineEdit_L1C3->setMinimumSize( QSize( 70, 0 ) );
156 //LineEdit_L1C3->setEnabled( FALSE );
157 LineEdit_L1C3->setReadOnly( TRUE );
158 GroupC1Layout->addWidget( LineEdit_L1C3, 1, 4 );
159 LineEdit_L2C1 = new QLineEdit( GroupC1, "LineEdit_L2C1" );
160 LineEdit_L2C1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L2C1->sizePolicy().hasHeightForWidth() ) );
161 LineEdit_L2C1->setMinimumSize( QSize( 70, 0 ) );
162 //LineEdit_L2C1->setEnabled( FALSE );
163 LineEdit_L2C1->setReadOnly( TRUE );
164 GroupC1Layout->addWidget( LineEdit_L2C1, 2, 2 );
165 LineEdit_L2C2 = new QLineEdit( GroupC1, "LineEdit_L2C2" );
166 LineEdit_L2C2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L2C2->sizePolicy().hasHeightForWidth() ) );
167 LineEdit_L2C2->setMinimumSize( QSize( 70, 0 ) );
168 //LineEdit_L2C2->setEnabled( FALSE );
169 LineEdit_L2C2->setReadOnly( TRUE );
170 GroupC1Layout->addWidget( LineEdit_L2C2, 2, 3 );
171 LineEdit_L2C3 = new QLineEdit( GroupC1, "LineEdit_L2C3" );
172 LineEdit_L2C3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L2C3->sizePolicy().hasHeightForWidth() ) );
173 LineEdit_L2C3->setMinimumSize( QSize( 70, 0 ) );
174 //LineEdit_L2C3->setEnabled( FALSE );
175 LineEdit_L2C3->setReadOnly( TRUE );
176 GroupC1Layout->addWidget( LineEdit_L2C3, 2, 4 );
177 LineEdit_L3C1 = new QLineEdit( GroupC1, "LineEdit_L3C1" );
178 LineEdit_L3C1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L3C1->sizePolicy().hasHeightForWidth() ) );
179 LineEdit_L3C1->setMinimumSize( QSize( 70, 0 ) );
180 //LineEdit_L3C1->setEnabled( FALSE );
181 LineEdit_L3C1->setReadOnly( TRUE );
182 GroupC1Layout->addWidget( LineEdit_L3C1, 3, 2 );
183 LineEdit_L3C2 = new QLineEdit( GroupC1, "LineEdit_L3C2" );
184 LineEdit_L3C2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L3C2->sizePolicy().hasHeightForWidth() ) );
185 LineEdit_L3C2->setMinimumSize( QSize( 70, 0 ) );
186 //LineEdit_L3C2->setEnabled( FALSE );
187 LineEdit_L3C2->setReadOnly( TRUE );
188 GroupC1Layout->addWidget( LineEdit_L3C2, 3, 3 );
189 LineEdit_L3C3 = new QLineEdit( GroupC1, "LineEdit_L3C3" );
190 LineEdit_L3C3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L3C3->sizePolicy().hasHeightForWidth() ) );
191 LineEdit_L3C3->setMinimumSize( QSize( 70, 0 ) );
192 //LineEdit_L3C3->setEnabled( FALSE );
193 LineEdit_L3C3->setReadOnly( TRUE );
194 GroupC1Layout->addWidget( LineEdit_L3C3, 3, 4 );
195 LineEdit_IX = new QLineEdit( GroupC1, "LineEdit_IX" );
196 LineEdit_IX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_IX->sizePolicy().hasHeightForWidth() ) );
197 LineEdit_IX->setMinimumSize( QSize( 70, 0 ) );
198 //LineEdit_IX->setEnabled( FALSE );
199 LineEdit_IX->setReadOnly( TRUE );
200 GroupC1Layout->addWidget( LineEdit_IX, 4, 2 );
201 LineEdit_IY = new QLineEdit( GroupC1, "LineEdit_IY" );
202 LineEdit_IY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_IY->sizePolicy().hasHeightForWidth() ) );
203 LineEdit_IY->setMinimumSize( QSize( 70, 0 ) );
204 //LineEdit_IY->setEnabled( FALSE );
205 LineEdit_IY->setReadOnly( TRUE );
206 GroupC1Layout->addWidget( LineEdit_IY, 4, 3 );
207 LineEdit_IZ = new QLineEdit( GroupC1, "LineEdit_IZ" );
208 LineEdit_IZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_IZ->sizePolicy().hasHeightForWidth() ) );
209 LineEdit_IZ->setMinimumSize( QSize( 70, 0 ) );
210 //LineEdit_IZ->setEnabled( FALSE );
211 LineEdit_IZ->setReadOnly( TRUE );
212 GroupC1Layout->addWidget( LineEdit_IZ, 4, 4 );
213 TextLabel_IXIYIZ = new QLabel( GroupC1, "TextLabel_IXIYIZ" );
214 TextLabel_IXIYIZ->setText( tr( "GEOM_INERTIA_IXYZ" ) );
215 TextLabel_IXIYIZ->setMinimumSize( QSize( 50, 0 ) );
216 TextLabel_IXIYIZ->setFrameShape( QLabel::NoFrame );
217 TextLabel_IXIYIZ->setFrameShadow( QLabel::Plain );
218 TextLabel_IXIYIZ->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
219 GroupC1Layout->addMultiCellWidget( TextLabel_IXIYIZ, 4, 4, 0, 1 );
220 GeometryGUI_InertiaDlgLayout->addWidget( GroupC1, 1, 0 );
222 /***************************************************************/
223 GroupButtons = new QGroupBox( this, "GroupButtons" );
224 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
225 GroupButtons->setTitle( tr( "" ) );
226 GroupButtons->setColumnLayout(0, Qt::Vertical );
227 GroupButtons->layout()->setSpacing( 0 );
228 GroupButtons->layout()->setMargin( 0 );
229 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
230 GroupButtonsLayout->setAlignment( Qt::AlignTop );
231 GroupButtonsLayout->setSpacing( 6 );
232 GroupButtonsLayout->setMargin( 11 );
233 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
234 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
235 buttonCancel->setAutoDefault( TRUE );
236 GroupButtonsLayout->addWidget( buttonCancel, 0, 1 );
238 QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
239 GroupButtonsLayout->addItem( spacer_8, 0, 0 );
240 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
241 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
243 GeometryGUI_InertiaDlgLayout->addWidget( GroupButtons, 2, 0 );
244 /***************************************************************/
246 Init(Sel) ; /* Initialisations */
250 //=================================================================================
251 // function : ~GeometryGUI_InertiaDlg()
252 // purpose : Destroys the object and frees any allocated resources
253 //=================================================================================
254 GeometryGUI_InertiaDlg::~GeometryGUI_InertiaDlg()
256 // no need to delete child widgets, Qt does it all for us
260 //=================================================================================
263 //=================================================================================
264 void GeometryGUI_InertiaDlg::Init( SALOME_Selection* Sel )
267 LineEdit_L1C1->setMaxLength( 10 );
268 LineEdit_L1C2->setMaxLength( 10 );
269 LineEdit_L1C3->setMaxLength( 10 );
270 LineEdit_L2C1->setMaxLength( 10 );
271 LineEdit_L2C2->setMaxLength( 10 );
272 LineEdit_L2C3->setMaxLength( 10 );
273 LineEdit_L3C1->setMaxLength( 10 );
274 LineEdit_L3C2->setMaxLength( 10 );
275 LineEdit_L3C3->setMaxLength( 10 );
277 LineEdit_IX->setMaxLength( 10 );
278 LineEdit_IY->setMaxLength( 10 );
279 LineEdit_IZ->setMaxLength( 10 );
281 myConstructorId = 0 ;
282 Constructor1->setChecked( TRUE );
283 myEditCurrentArgument = LineEditC1A1 ;
285 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
286 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
288 // TODO : previous selection into argument ?
290 /* Filter definitions */
291 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
292 myGeom = GEOM::GEOM_Gen::_narrow(comp);
294 /* signals and slots connections */
295 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
296 connect( GroupConstructors, SIGNAL(clicked(int) ), this, SLOT( ConstructorsClicked(int) ) );
297 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
299 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
301 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
302 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
304 /* to close dialog if study change */
305 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
307 /* Move widget on the botton right corner of main widget */
309 myGeomGUI->DefineDlgPosition( this, x, y ) ;
311 this->show() ; /* displays Dialog */
316 //=================================================================================
317 // function : ConstructorsClicked()
318 // purpose : Radio button management
319 //=================================================================================
320 void GeometryGUI_InertiaDlg::ConstructorsClicked(int constructorId)
327 //=================================================================================
328 // function : ClickOnCancel()
330 //=================================================================================
331 void GeometryGUI_InertiaDlg::ClickOnCancel()
333 disconnect( mySelection, 0, this, 0 );
334 myGeomGUI->ResetState() ;
340 //=================================================================================
341 // function : SelectionIntoArgument()
342 // purpose : Called when selection as changed or other case
343 //=================================================================================
344 void GeometryGUI_InertiaDlg::SelectionIntoArgument()
346 LineEdit_L1C1->setText("") ;
347 LineEdit_L1C2->setText("") ;
348 LineEdit_L1C3->setText("") ;
349 LineEdit_L2C1->setText("") ;
350 LineEdit_L2C2->setText("") ;
351 LineEdit_L2C3->setText("") ;
352 LineEdit_L3C1->setText("") ;
353 LineEdit_L3C2->setText("") ;
354 LineEdit_L3C3->setText("") ;
356 LineEdit_IX->setText("") ;
357 LineEdit_IY->setText("") ;
358 LineEdit_IZ->setText("") ;
360 myEditCurrentArgument->setText("") ;
361 QString aString = ""; /* future the name of selection */
363 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
370 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) || S.IsNull() )
373 LineEditC1A1->setText(aString) ;
374 this->CalculateAndDisplayInertia(S) ;
379 //=================================================================================
380 // function : SetEditCurrentArgument()
382 //=================================================================================
383 void GeometryGUI_InertiaDlg::SetEditCurrentArgument()
385 QPushButton* send = (QPushButton*)sender();
386 switch (myConstructorId)
388 case 0: /* default constructor */
390 if(send == SelectButtonC1A1) {
391 LineEditC1A1->setFocus() ;
392 myEditCurrentArgument = LineEditC1A1;
394 SelectionIntoArgument() ;
403 //=================================================================================
404 // function : LineEditReturnPressed()
406 //=================================================================================
407 void GeometryGUI_InertiaDlg::LineEditReturnPressed()
409 QLineEdit* send = (QLineEdit*)sender();
410 if( send == LineEditC1A1 )
411 myEditCurrentArgument = LineEditC1A1 ;
415 /* User name of object input management */
416 /* If successfull the selection is changed and signal emitted... */
417 /* so SelectionIntoArgument() is automatically called. */
418 const QString objectUserName = myEditCurrentArgument->text() ;
419 QWidget* thisWidget = (QWidget*)this ;
420 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
421 myEditCurrentArgument->setText( objectUserName ) ;
428 //=================================================================================
429 // function : DeactivateActiveDialog()
431 //=================================================================================
432 void GeometryGUI_InertiaDlg::DeactivateActiveDialog()
434 if ( GroupConstructors->isEnabled() ) {
435 disconnect( mySelection, 0, this, 0 );
436 GroupConstructors->setEnabled(false) ;
437 GroupC1->setEnabled(false) ;
438 GroupButtons->setEnabled(false) ;
444 //=================================================================================
445 // function : ActivateThisDialog()
447 //=================================================================================
448 void GeometryGUI_InertiaDlg::ActivateThisDialog()
450 /* Emit a signal to deactivate the active dialog */
451 myGeomGUI->EmitSignalDeactivateDialog() ;
452 GroupConstructors->setEnabled(true) ;
453 GroupC1->setEnabled(true) ;
454 GroupButtons->setEnabled(true) ;
455 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
460 //=================================================================================
461 // function : enterEvent()
463 //=================================================================================
464 void GeometryGUI_InertiaDlg::enterEvent(QEvent* e)
466 if ( GroupConstructors->isEnabled() )
468 ActivateThisDialog() ;
473 //=================================================================================
474 // function : closeEvent()
476 //=================================================================================
477 void GeometryGUI_InertiaDlg::closeEvent( QCloseEvent* e )
479 /* same than click on cancel button */
480 this->ClickOnCancel() ;
485 //=================================================================================
486 // function : CalculateAndDisplayInertia()
488 //=================================================================================
489 void GeometryGUI_InertiaDlg::CalculateAndDisplayInertia(const TopoDS_Shape& S)
491 LineEdit_L1C1->setText("") ;
492 LineEdit_L1C2->setText("") ;
493 LineEdit_L1C3->setText("") ;
494 LineEdit_L2C1->setText("") ;
495 LineEdit_L2C2->setText("") ;
496 LineEdit_L2C3->setText("") ;
497 LineEdit_L3C1->setText("") ;
498 LineEdit_L3C2->setText("") ;
499 LineEdit_L3C3->setText("") ;
501 LineEdit_IX->setText("") ;
502 LineEdit_IY->setText("") ;
503 LineEdit_IZ->setText("") ;
514 if ( S.ShapeType() == TopAbs_VERTEX || S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE ) {
515 BRepGProp::LinearProperties(S, System);
517 else if ( S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL ) {
518 BRepGProp::SurfaceProperties(S, System);
521 BRepGProp::VolumeProperties(S, System);
524 gp_Mat I = System.MatrixOfInertia() ;
525 GProp_PrincipalProps Pr = System.PrincipalProperties();
526 Standard_Real Ix,Iy,Iz;
527 Pr.Moments(Ix,Iy,Iz);
530 resString = tr("%1").arg( I(1,1), 12, 'f', 6 ) ;
531 LineEdit_L1C1->setText(resString) ;
532 resString = tr("%1").arg( I(1,2), 12, 'f', 6 ) ;
533 LineEdit_L1C2->setText(resString) ;
534 resString = tr("%1").arg( I(1,3), 12, 'f', 6 ) ;
535 LineEdit_L1C3->setText(resString) ;
537 resString = tr("%1").arg( I(2,1), 12, 'f', 6 ) ;
538 LineEdit_L2C1->setText(resString) ;
539 resString = tr("%1").arg( I(2,2), 12, 'f', 6 ) ;
540 LineEdit_L2C2->setText(resString) ;
541 resString = tr("%1").arg( I(2,3), 12, 'f', 6 ) ;
542 LineEdit_L2C3->setText(resString) ;
544 resString = tr("%1").arg( I(3,1), 12, 'f', 6 ) ;
545 LineEdit_L3C1->setText(resString) ;
546 resString = tr("%1").arg( I(3,2), 12, 'f', 6 ) ;
547 LineEdit_L3C2->setText(resString) ;
548 resString = tr("%1").arg( I(3,3), 12, 'f', 6 ) ;
549 LineEdit_L3C3->setText(resString) ;
552 resString = tr("%1").arg( Ix, 12, 'f', 6 ) ;
553 LineEdit_IX->setText(resString) ;
554 resString = tr("%1").arg( Ix, 12, 'f', 6 ) ;
555 LineEdit_IY->setText(resString) ;
556 resString = tr("%1").arg( Iz, 12, 'f', 6 ) ;
557 LineEdit_IZ->setText(resString) ;
560 catch(Standard_Failure) {
561 MESSAGE("Catch intercepted in CalculateAndDisplayInertia()" << endl ) ;