Salome HOME
sources v1.2
[modules/geom.git] / src / GEOMGUI / GeometryGUI_CenterMassDlg.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : GeometryGUI_CenterMassDlg.cxx
25 //  Author : Lucien PIGNOLONI
26 //  Module : GEOM
27 //  $Header$
28
29 using namespace std;
30 #include "GeometryGUI_CenterMassDlg.h"
31 #include "GeometryGUI.h"
32
33 #include <BRepBuilderAPI_MakeVertex.hxx>
34
35 #include <qbuttongroup.h>
36 #include <qgroupbox.h>
37 #include <qlabel.h>
38 #include <qlineedit.h>
39 #include <qpushbutton.h>
40 #include <qradiobutton.h>
41 #include <qlayout.h>
42 #include <qvariant.h>
43 #include <qtooltip.h>
44 #include <qwhatsthis.h>
45 #include <qimage.h>
46 #include <qvalidator.h>
47 #include <qpixmap.h>
48
49 //=================================================================================
50 // class    : GeometryGUI_CenterMassDlg()
51 // purpose  : Constructs a GeometryGUI_CenterMassDlg which is a child of 'parent', with the 
52 //            name 'name' and widget flags set to 'f'.
53 //            The dialog will by default be modeless, unless you set 'modal' to
54 //            TRUE to construct a modal dialog.
55 //=================================================================================
56 GeometryGUI_CenterMassDlg::GeometryGUI_CenterMassDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
57     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
58 {
59     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CENTERMASS")));
60     QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
61
62     if ( !name )
63         setName( "GeometryGUI_CenterMassDlg" );
64     resize( 398, 219 ); 
65     setCaption( tr( "GEOM_CMASS_TITLE"  ) );
66     setSizeGripEnabled( TRUE );
67     GeometryGUI_CenterMassDlgLayout = new QGridLayout( this ); 
68     GeometryGUI_CenterMassDlgLayout->setSpacing( 6 );
69     GeometryGUI_CenterMassDlgLayout->setMargin( 11 );
70     
71     /***************************************************************/
72     GroupButtons = new QGroupBox( this, "GroupButtons" );
73     GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
74     GroupButtons->setTitle( tr( ""  ) );
75     GroupButtons->setColumnLayout(0, Qt::Vertical );
76     GroupButtons->layout()->setSpacing( 0 );
77     GroupButtons->layout()->setMargin( 0 );
78     GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
79     GroupButtonsLayout->setAlignment( Qt::AlignTop );
80     GroupButtonsLayout->setSpacing( 6 );
81     GroupButtonsLayout->setMargin( 11 );
82     buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
83     buttonCancel->setText( tr( "GEOM_BUT_CLOSE"  ) );
84     buttonCancel->setAutoDefault( TRUE );
85     GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
86     buttonApply = new QPushButton( GroupButtons, "buttonApply" );
87     buttonApply->setText( tr( "GEOM_BUT_APPLY"  ) );
88     buttonApply->setAutoDefault( TRUE );
89     GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
90     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
91     GroupButtonsLayout->addItem( spacer, 0, 2 );
92     buttonOk = new QPushButton( GroupButtons, "buttonOk" );
93     buttonOk->setText( tr( "GEOM_BUT_OK"  ) );
94     buttonOk->setAutoDefault( TRUE );
95     buttonOk->setDefault( TRUE );
96     GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
97     GeometryGUI_CenterMassDlgLayout->addWidget( GroupButtons, 2, 0 );
98
99     /***************************************************************/
100     GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
101     GroupConstructors->setTitle( tr( "GEOM_CMASS"  ) );
102     GroupConstructors->setExclusive( TRUE );
103     GroupConstructors->setColumnLayout(0, Qt::Vertical );
104     GroupConstructors->layout()->setSpacing( 0 );
105     GroupConstructors->layout()->setMargin( 0 );
106     GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
107     GroupConstructorsLayout->setAlignment( Qt::AlignTop );
108     GroupConstructorsLayout->setSpacing( 6 );
109     GroupConstructorsLayout->setMargin( 11 );
110     Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
111     Constructor1->setText( tr( ""  ) );
112     Constructor1->setPixmap( image0 );
113     Constructor1->setChecked( TRUE );
114     Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
115     Constructor1->setMinimumSize( QSize( 50, 0 ) );
116     GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
117     QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
118     GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
119     GeometryGUI_CenterMassDlgLayout->addWidget( GroupConstructors, 0, 0 );
120
121     /***************************************************************/
122     GroupC1 = new QGroupBox( this, "GroupC1" );
123     GroupC1->setTitle( tr( "GEOM_OBJECT_RESULT"  ) );
124     GroupC1->setMinimumSize( QSize( 0, 0 ) );
125     GroupC1->setFrameShape( QGroupBox::Box );
126     GroupC1->setFrameShadow( QGroupBox::Sunken );
127     GroupC1->setColumnLayout(0, Qt::Vertical );
128     GroupC1->layout()->setSpacing( 0 );
129     GroupC1->layout()->setMargin( 0 );
130     GroupC1Layout = new QGridLayout( GroupC1->layout() );
131     GroupC1Layout->setAlignment( Qt::AlignTop );
132     GroupC1Layout->setSpacing( 6 );
133     GroupC1Layout->setMargin( 11 );
134     SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
135     SelectButtonC1A1->setText( tr( ""  ) );
136     SelectButtonC1A1->setPixmap( image1 );
137     SelectButtonC1A1->setToggleButton( FALSE );
138     GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
139     LineEdit_X = new QLineEdit( GroupC1, "LineEdit_X" );
140     LineEdit_X->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_X->sizePolicy().hasHeightForWidth() ) );
141     LineEdit_X->setMinimumSize( QSize( 70, 0 ) );
142     //LineEdit_X->setEnabled( FALSE );
143     LineEdit_X->setReadOnly( TRUE );
144     GroupC1Layout->addWidget( LineEdit_X, 1, 2 );
145     TextLabel_Z = new QLabel( GroupC1, "TextLabel_Z" );
146     TextLabel_Z->setText( tr( "GEOM_Z"  ) );
147     TextLabel_Z->setMinimumSize( QSize( 15, 0 ) );
148     TextLabel_Z->setFrameShape( QLabel::NoFrame );
149     TextLabel_Z->setFrameShadow( QLabel::Plain );
150     TextLabel_Z->setMaximumSize( QSize( 15, 32767 ) );
151     GroupC1Layout->addWidget( TextLabel_Z, 1, 5 );
152     LineEdit_Z = new QLineEdit( GroupC1, "LineEdit_Z" );
153     LineEdit_Z->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Z->sizePolicy().hasHeightForWidth() ) );
154     LineEdit_Z->setMinimumSize( QSize( 70, 0 ) );
155     //LineEdit_Z->setEnabled( FALSE );
156     LineEdit_Z->setReadOnly( TRUE );
157     GroupC1Layout->addWidget( LineEdit_Z, 1, 6 );
158     TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
159     TextLabelC1A1->setText( tr( "GEOM_OBJECT"  ) );
160     TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
161     TextLabelC1A1->setFrameShape( QLabel::NoFrame );
162     TextLabelC1A1->setFrameShadow( QLabel::Plain );
163     GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
164     LineEdit_Y = new QLineEdit( GroupC1, "LineEdit_Y" );
165     LineEdit_Y->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Y->sizePolicy().hasHeightForWidth() ) );
166     LineEdit_Y->setMinimumSize( QSize( 70, 0 ) );
167     //LineEdit_Y->setEnabled( FALSE );
168     LineEdit_Y->setReadOnly( TRUE );
169     GroupC1Layout->addWidget( LineEdit_Y, 1, 4 );
170     TextLabel_Y = new QLabel( GroupC1, "TextLabel_Y" );
171     TextLabel_Y->setText( tr( "GEOM_Y"  ) );
172     TextLabel_Y->setMinimumSize( QSize( 15, 0 ) );
173     TextLabel_Y->setFrameShape( QLabel::NoFrame );
174     TextLabel_Y->setFrameShadow( QLabel::Plain );
175     TextLabel_Y->setMaximumSize( QSize( 15, 32767 ) );
176     GroupC1Layout->addWidget( TextLabel_Y, 1, 3 );
177     TextLabel_X = new QLabel( GroupC1, "TextLabel_X" );
178     TextLabel_X->setText( tr( "GEOM_X"  ) );
179     TextLabel_X->setMinimumSize( QSize( 15, 0 ) );
180     TextLabel_X->setFrameShape( QLabel::NoFrame );
181     TextLabel_X->setFrameShadow( QLabel::Plain );
182     TextLabel_X->setMaximumSize( QSize( 15, 32767 ) );
183     GroupC1Layout->addWidget( TextLabel_X, 1, 1 );
184     TextLabel_Center = new QLabel( GroupC1, "TextLabel_Center" );
185     TextLabel_Center->setText( tr( "GEOM_CENTER"  ) );
186     TextLabel_Center->setMinimumSize( QSize( 50, 0 ) );
187     TextLabel_Center->setFrameShape( QLabel::NoFrame );
188     TextLabel_Center->setFrameShadow( QLabel::Plain );
189     GroupC1Layout->addWidget( TextLabel_Center, 1, 0 );
190     LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
191     LineEditC1A1->setMinimumSize( QSize( 260, 0 ) );
192     GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 6 );
193     GeometryGUI_CenterMassDlgLayout->addWidget( GroupC1, 1, 0 );
194     /***************************************************************/
195
196     Init(Sel) ; /* Initialisations */
197
198 }
199
200
201 //=================================================================================
202 // function : ~GeometryGUI_CenterMassDlg()
203 // purpose  : Destroys the object and frees any allocated resources
204 //=================================================================================
205 GeometryGUI_CenterMassDlg::~GeometryGUI_CenterMassDlg()
206 {
207     // no need to delete child widgets, Qt does it all for us
208 }
209
210
211
212 //=================================================================================
213 // function : Init()
214 // purpose  :
215 //=================================================================================
216 void GeometryGUI_CenterMassDlg::Init( SALOME_Selection* Sel )
217 {
218   LineEdit_X->setMaxLength( 9 );
219   LineEdit_Y->setMaxLength( 9 );
220   LineEdit_Z->setMaxLength( 9 );
221   QDoubleValidator *Va = new QDoubleValidator( -999999, +999999, 3, LineEdit_X ) ;
222   QDoubleValidator *Vb = new QDoubleValidator( -999999, +999999, 3, LineEdit_Y ) ;
223   QDoubleValidator *Vc = new QDoubleValidator( -999999, +999999, 3, LineEdit_Z ) ; 
224   LineEdit_X->setValidator( Va ) ;
225   LineEdit_Y->setValidator( Vb ) ;
226   LineEdit_Z->setValidator( Vc ) ;
227
228   myConstructorId = 0 ;
229
230   LineEdit_X->setText("") ;
231   LineEdit_Y->setText("") ;
232   LineEdit_Z->setText("") ;
233
234   Constructor1->setChecked( TRUE );
235   myEditCurrentArgument = LineEditC1A1 ;        
236   mySelection = Sel;
237   myGeomGUI = GeometryGUI::GetGeometryGUI() ;
238   myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
239   mySimulationTopoDs.Nullify() ;
240   myShape.Nullify() ;
241   myOkCenterMass = false ;
242
243   // TODO : previous selection into argument ?
244
245   /* Filter definitions */
246   Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
247   myGeom = GEOM::GEOM_Gen::_narrow(comp);
248
249   /* signals and slots connections */
250   connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ) ;
251   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
252   connect( buttonApply, SIGNAL( clicked() ),     this, SLOT( ClickOnApply() ) );
253   connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
254   connect( SelectButtonC1A1, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
255   connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
256
257   connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
258   /* to close dialog if study change */
259   connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
260
261   /* Move widget on the botton right corner of main widget */
262   int x, y ;
263   myGeomGUI->DefineDlgPosition( this, x, y ) ;
264   this->move( x, y ) ;
265   this->show() ; /* displays Dialog */
266   
267   return ;
268 }
269
270
271 //=================================================================================
272 // function : ConstructorsClicked()
273 // purpose  : Radio button management
274 //=================================================================================
275 void GeometryGUI_CenterMassDlg::ConstructorsClicked(int constructorId)
276 {
277   return ;
278 }
279
280
281
282 //=================================================================================
283 // function : ClickOnCancel()
284 // purpose  :
285 //=================================================================================
286 void GeometryGUI_CenterMassDlg::ClickOnCancel()
287 {
288   myGeomGUI->EraseSimulationShape() ;
289   mySimulationTopoDs.Nullify() ;
290   disconnect( mySelection, 0, this, 0 );
291   myGeomGUI->ResetState() ;
292   reject() ;
293   return ;
294 }
295
296 //=================================================================================
297 // function : ClickOnOk()
298 // purpose  :
299 //=================================================================================
300 void GeometryGUI_CenterMassDlg::ClickOnOk()
301 {
302   this->ClickOnApply() ;
303   this->ClickOnCancel() ;
304
305   return ;
306 }
307
308 //=================================================================================
309 // function : ClickOnApply()
310 // purpose  :
311 //=================================================================================
312 void GeometryGUI_CenterMassDlg::ClickOnApply()
313 {
314   myGeomGUI->EraseSimulationShape() ;
315   mySimulationTopoDs.Nullify() ;
316   myGeomGUI->GetDesktop()->putInfo( tr("") ) ; 
317   if( myOkCenterMass) {    
318     myGeomGUI->MakeCDGAndDisplay( myGeomShape ) ;
319   }
320   return ;
321 }
322
323
324
325
326 //=================================================================================
327 // function : SelectionIntoArgument()
328 // purpose  : Called when selection as changed or other case
329 //=================================================================================
330 void GeometryGUI_CenterMassDlg::SelectionIntoArgument()
331 {
332   myGeomGUI->EraseSimulationShape() ;
333   myEditCurrentArgument->setText("") ;
334   myOkCenterMass = false ;
335   Standard_Boolean testResult ;
336
337   LineEdit_X->setText("") ;
338   LineEdit_Y->setText("") ;
339   LineEdit_Z->setText("") ;
340
341   QString aString = ""; /* future the name of selection */
342
343   int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
344   if ( nbSel != 1 ) {
345     return ;
346   }
347
348   /*  nbSel == 1  */
349   Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
350   if( !myGeomGUI->GetTopoFromSelection(mySelection, this->myShape) )
351     return ;  
352
353   myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
354   if( !testResult )
355             return ;
356   myEditCurrentArgument->setText(aString) ;
357   if( this->CalculateAndDisplayCenterMass() ) {
358     myOkCenterMass = true ;
359   }
360
361   return ;
362 }
363
364
365 //=================================================================================
366 // function : SetEditCurrentArgument()
367 // purpose  :
368 //=================================================================================
369 void GeometryGUI_CenterMassDlg::SetEditCurrentArgument()
370 {
371   QPushButton* send = (QPushButton*)sender();
372   switch (myConstructorId)
373     {
374     case 0: /* default constructor */
375       { 
376         if(send == SelectButtonC1A1) {
377           LineEditC1A1->setFocus() ;
378           myEditCurrentArgument = LineEditC1A1;
379         }
380         SelectionIntoArgument() ;
381         break;
382       }
383     }
384   return ;
385 }
386
387
388
389 //=================================================================================
390 // function : LineEditReturnPressed()
391 // purpose  :
392 //=================================================================================
393 void GeometryGUI_CenterMassDlg::LineEditReturnPressed()
394 {
395   QLineEdit* send = (QLineEdit*)sender();  
396   if( send == LineEditC1A1 )
397     myEditCurrentArgument = LineEditC1A1 ;
398   else
399     return ;
400   
401   /* User name of object input management                          */
402   /* If successfull the selection is changed and signal emitted... */
403   /* so SelectionIntoArgument() is automatically called.           */
404   const QString objectUserName = myEditCurrentArgument->text() ;
405   QWidget* thisWidget = (QWidget*)this ;
406   if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
407     myEditCurrentArgument->setText( objectUserName ) ;
408   }
409   return ;
410 }
411
412
413 //=================================================================================
414 // function : DeactivateActiveDialog()
415 // purpose  :
416 //=================================================================================
417 void GeometryGUI_CenterMassDlg::DeactivateActiveDialog()
418 {
419   if ( GroupConstructors->isEnabled() ) {    
420     myGeomGUI->EraseSimulationShape() ;  
421     disconnect( mySelection, 0, this, 0 );
422     GroupConstructors->setEnabled(false) ;
423     GroupC1->setEnabled(false) ;
424     GroupButtons->setEnabled(false) ;
425   }
426   return ;
427 }
428
429
430 //=================================================================================
431 // function : ActivateThisDialog()
432 // purpose  :
433 //=================================================================================
434 void GeometryGUI_CenterMassDlg::ActivateThisDialog()
435 {
436   /* Emit a signal to deactivate the active dialog */
437   myGeomGUI->EmitSignalDeactivateDialog() ;   
438   GroupConstructors->setEnabled(true) ;
439   GroupC1->setEnabled(true) ;
440   GroupButtons->setEnabled(true) ;
441   connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
442   if( !mySimulationTopoDs.IsNull() )
443     myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
444   return ;
445 }
446
447
448 //=================================================================================
449 // function : enterEvent()
450 // purpose  :
451 //=================================================================================
452 void GeometryGUI_CenterMassDlg::enterEvent(QEvent* e)
453 {
454   if ( GroupConstructors->isEnabled() )
455     return ;  
456   ActivateThisDialog() ;
457   return ;
458 }
459
460
461 //=================================================================================
462 // function : closeEvent()
463 // purpose  :
464 //=================================================================================
465 void GeometryGUI_CenterMassDlg::closeEvent( QCloseEvent* e )
466 {
467   /* same than click on cancel button */
468   this->ClickOnCancel() ;
469   return ;
470 }
471
472
473 //=================================================================================
474 // function : CalculateAndDisplayCenterMass()
475 // purpose  :
476 //=================================================================================
477 bool GeometryGUI_CenterMassDlg::CalculateAndDisplayCenterMass()
478 {
479   myGeomGUI->EraseSimulationShape() ;
480   mySimulationTopoDs.Nullify() ;
481
482   try {
483
484     QString resString;     
485     GProp_GProps System;
486
487     if ( this->myShape.ShapeType() == TopAbs_VERTEX) {
488       myGeomGUI->VertexToPoint( this->myShape, this->myCenterMass  );
489     } 
490     else if ( this->myShape.ShapeType() == TopAbs_EDGE || this->myShape.ShapeType() == TopAbs_WIRE ) {
491       BRepGProp::LinearProperties(this->myShape, System);
492       this->myCenterMass = System.CentreOfMass() ;
493     }
494     else if ( this->myShape.ShapeType() == TopAbs_FACE || this->myShape.ShapeType() == TopAbs_SHELL ) {
495       BRepGProp::SurfaceProperties(this->myShape, System);
496       this->myCenterMass = System.CentreOfMass() ;
497     }
498     else {
499       BRepGProp::VolumeProperties(this->myShape, System);
500       this->myCenterMass = System.CentreOfMass() ;
501     }
502     
503     BRepBuilderAPI_MakeVertex V(this->myCenterMass) ;
504     mySimulationTopoDs = V.Shape() ;
505     
506     resString = tr("%1").arg( myCenterMass.X(), 12, 'f', 6 ) ;    
507     LineEdit_X->setText(resString) ;
508     
509     resString = tr("%1").arg( myCenterMass.Y(), 12, 'f', 6 ) ;    
510     LineEdit_Y->setText(resString) ;
511     
512     resString = tr("%1").arg( myCenterMass.Z(), 12, 'f', 6 ) ;    
513     LineEdit_Z->setText(resString) ;
514     
515     
516     if( !mySimulationTopoDs.IsNull() ) {
517       myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
518       return true ;
519     }
520   }
521   catch(Standard_Failure) {
522     MESSAGE("Catch intercepted in CalculateAndDisplayCenterMass()" << endl ) ;
523   }
524   return false ;
525 }
526
527