Salome HOME
NRI : Merge BRANCH_V1_2c
[modules/geom.git] / src / GEOMGUI / GeometryGUI_MaxToleranceDlg.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_MaxToleranceDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : GEOM
27 //  $Header$
28
29 using namespace std;
30 #include "GeometryGUI_MaxToleranceDlg.h"
31
32 #include "GeometryGUI.h"
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "utilities.h"
36
37 // Open CASCADE Includes
38 #include <TopExp_Explorer.hxx>
39 #include <BRep_Tool.hxx>
40
41 // QT Includes
42 #include <qbuttongroup.h>
43 #include <qgroupbox.h>
44 #include <qlabel.h>
45 #include <qlineedit.h>
46 #include <qpushbutton.h>
47 #include <qradiobutton.h>
48 #include <qlayout.h>
49 #include <qvariant.h>
50 #include <qtooltip.h>
51 #include <qwhatsthis.h>
52 #include <qimage.h>
53 #include <qpixmap.h>
54
55
56
57 //=================================================================================
58 // class    : GeometryGUI_MaxToleranceDlg()
59 // purpose  : Constructs a GeometryGUI_MaxToleranceDlg which is a child of 'parent', with the 
60 //            name 'name' and widget flags set to 'f'.
61 //            The dialog will by default be modeless, unless you set 'modal' to
62 //            TRUE to construct a modal dialog.
63 //=================================================================================
64 GeometryGUI_MaxToleranceDlg::GeometryGUI_MaxToleranceDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
65     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
66 {
67     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_TOLERANCE")));
68     QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
69
70     if ( !name )
71         setName( "GeometryGUI_MaxToleranceDlg" );
72     resize( 303, 275 ); 
73     setCaption( tr( "GEOM_TOLERANCE_TITLE"  ) );
74     setSizeGripEnabled( TRUE );
75     GeometryGUI_MaxToleranceDlgLayout = new QGridLayout( this ); 
76     GeometryGUI_MaxToleranceDlgLayout->setSpacing( 6 );
77     GeometryGUI_MaxToleranceDlgLayout->setMargin( 11 );
78     
79     /***************************************************************/
80     GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
81     GroupConstructors->setTitle( tr( "GEOM_TOLERANCE"  ) );
82     GroupConstructors->setExclusive( TRUE );
83     GroupConstructors->setColumnLayout(0, Qt::Vertical );
84     GroupConstructors->layout()->setSpacing( 0 );
85     GroupConstructors->layout()->setMargin( 0 );
86     GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
87     GroupConstructorsLayout->setAlignment( Qt::AlignTop );
88     GroupConstructorsLayout->setSpacing( 6 );
89     GroupConstructorsLayout->setMargin( 11 );
90     Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
91     Constructor1->setText( tr( ""  ) );
92     Constructor1->setPixmap( image0 );
93     Constructor1->setChecked( TRUE );
94     Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, 
95                                               Constructor1->sizePolicy().hasHeightForWidth() ) );
96     Constructor1->setMinimumSize( QSize( 60, 0 ) );
97     GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
98     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
99     GroupConstructorsLayout->addItem( spacer, 0, 1 );
100     GeometryGUI_MaxToleranceDlgLayout->addWidget( GroupConstructors, 0, 0 );
101
102     /***************************************************************/
103     GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
104     GroupConstructor1->setTitle( tr( "GEOM_TOLERANCE_CONSTR"  ) );
105     GroupConstructor1->setColumnLayout(0, Qt::Vertical );
106     GroupConstructor1->layout()->setSpacing( 0 );
107     GroupConstructor1->layout()->setMargin( 0 );
108     GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() );
109     GroupConstructor1Layout->setAlignment( Qt::AlignTop );
110     GroupConstructor1Layout->setSpacing( 6 );
111     GroupConstructor1Layout->setMargin( 11 );
112
113     LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" );
114     LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
115 //    GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 );
116     SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" );
117     SelectButtonC1A1->setText( tr( ""  ) );
118     SelectButtonC1A1->setPixmap( image1 );
119 //    GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 );
120     TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" );
121     TextLabelC1A1->setText( tr( "GEOM_OBJECT"  ) );
122     TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
123     TextLabelC1A1->setFrameShape( QLabel::NoFrame );
124     TextLabelC1A1->setFrameShadow( QLabel::Plain );
125 //    GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 );
126
127     QHBoxLayout* bl = new QHBoxLayout;
128     bl->setMargin(0); bl->setSpacing(6);
129     bl->addWidget(TextLabelC1A1); bl->addWidget(SelectButtonC1A1); bl->addWidget(LineEditC1A1);
130     GroupConstructor1Layout->addMultiCellLayout(bl, 0, 0, 0, 2);
131
132     TextLabel_Min = new QLabel( GroupConstructor1, "TextLabel_Min" );
133     TextLabel_Min->setText( tr( "GEOM_MIN"  ) );
134     TextLabel_Min->setMinimumSize( QSize( 50, 0 ) );
135     TextLabel_Min->setFrameShape( QLabel::NoFrame );
136     TextLabel_Min->setFrameShadow( QLabel::Plain );
137     GroupConstructor1Layout->addWidget( TextLabel_Min, 1, 1 );
138
139     TextLabel_Max = new QLabel( GroupConstructor1, "TextLabel_Max" );
140     TextLabel_Max->setText( tr( "GEOM_MAX"  ) );
141     TextLabel_Max->setMinimumSize( QSize( 50, 0 ) );
142     TextLabel_Max->setFrameShape( QLabel::NoFrame );
143     TextLabel_Max->setFrameShadow( QLabel::Plain );
144     GroupConstructor1Layout->addWidget( TextLabel_Max, 1, 2 );
145
146     TextLabel_Face = new QLabel( GroupConstructor1, "TextLabel_Face" );
147     TextLabel_Face->setText( tr( "GEOM_TOLERANCE_FACE"  ) );
148     TextLabel_Face->setMinimumSize( QSize( 50, 0 ) );
149     TextLabel_Face->setFrameShape( QLabel::NoFrame );
150     TextLabel_Face->setFrameShadow( QLabel::Plain );
151     GroupConstructor1Layout->addWidget( TextLabel_Face, 2, 0 );
152     LineEdit_MinFace = new QLineEdit( GroupConstructor1, "LineEdit_MinFace" );
153     LineEdit_MinFace->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
154                                                  LineEdit_MinFace->sizePolicy().hasHeightForWidth() ) );
155     //LineEdit_MinFace->setEnabled( FALSE );
156     LineEdit_MinFace->setReadOnly( TRUE );
157     GroupConstructor1Layout->addWidget( LineEdit_MinFace, 2, 1 );
158     LineEdit_MaxFace = new QLineEdit( GroupConstructor1, "LineEdit_MaxFace" );
159     LineEdit_MaxFace->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
160                                                  LineEdit_MaxFace->sizePolicy().hasHeightForWidth() ) );
161     //LineEdit_MaxFace->setEnabled( FALSE );
162     LineEdit_MaxFace->setReadOnly( TRUE );
163     GroupConstructor1Layout->addWidget( LineEdit_MaxFace, 2, 2 );
164
165     TextLabel_Edge = new QLabel( GroupConstructor1, "TextLabel_Edge" );
166     TextLabel_Edge->setText( tr( "GEOM_TOLERANCE_EDGE"  ) );
167     TextLabel_Edge->setMinimumSize( QSize( 50, 0 ) );
168     TextLabel_Edge->setFrameShape( QLabel::NoFrame );
169     TextLabel_Edge->setFrameShadow( QLabel::Plain );
170     GroupConstructor1Layout->addWidget( TextLabel_Edge, 3, 0 );
171     LineEdit_MinEdge = new QLineEdit( GroupConstructor1, "LineEdit_MinEdge" );
172     LineEdit_MinEdge->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
173                                                  LineEdit_MinEdge->sizePolicy().hasHeightForWidth() ) );
174     //LineEdit_MinEdge->setEnabled( FALSE );
175     LineEdit_MinEdge->setReadOnly( TRUE );
176     GroupConstructor1Layout->addWidget( LineEdit_MinEdge, 3, 1 );
177     LineEdit_MaxEdge = new QLineEdit( GroupConstructor1, "LineEdit_MaxEdge" );
178     LineEdit_MaxEdge->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
179                                                  LineEdit_MaxEdge->sizePolicy().hasHeightForWidth() ) );
180     //LineEdit_MaxEdge->setEnabled( FALSE );
181     LineEdit_MaxEdge->setReadOnly( TRUE );
182     GroupConstructor1Layout->addWidget( LineEdit_MaxEdge, 3, 2 );
183
184     TextLabel_Vertex = new QLabel( GroupConstructor1, "TextLabel_Vertex" );
185     TextLabel_Vertex->setText( tr( "GEOM_TOLERANCE_VERTEX"  ) );
186     TextLabel_Vertex->setMinimumSize( QSize( 50, 0 ) );
187     TextLabel_Vertex->setFrameShape( QLabel::NoFrame );
188     TextLabel_Vertex->setFrameShadow( QLabel::Plain );
189     GroupConstructor1Layout->addWidget( TextLabel_Vertex, 4, 0 );
190     LineEdit_MinVertex = new QLineEdit( GroupConstructor1, "LineEdit_MinVertex" );
191     LineEdit_MinVertex->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
192                                                  LineEdit_MinVertex->sizePolicy().hasHeightForWidth() ) );
193     //LineEdit_MinVertex->setEnabled( FALSE );
194     LineEdit_MinVertex->setReadOnly( TRUE );
195     GroupConstructor1Layout->addWidget( LineEdit_MinVertex, 4, 1 );
196     LineEdit_MaxVertex = new QLineEdit( GroupConstructor1, "LineEdit_MaxVertex" );
197     LineEdit_MaxVertex->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
198                                                  LineEdit_MaxVertex->sizePolicy().hasHeightForWidth() ) );
199     //LineEdit_MaxVertex->setEnabled( FALSE );
200     LineEdit_MaxVertex->setReadOnly( TRUE );
201     GroupConstructor1Layout->addWidget( LineEdit_MaxVertex, 4, 2 );
202
203     GeometryGUI_MaxToleranceDlgLayout->addWidget( GroupConstructor1, 1, 0 );
204
205     /***************************************************************/
206     GroupButtons = new QGroupBox( this, "GroupButtons" );
207     GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
208     GroupButtons->setTitle( tr( ""  ) );
209     GroupButtons->setColumnLayout(0, Qt::Vertical );
210     GroupButtons->layout()->setSpacing( 0 );
211     GroupButtons->layout()->setMargin( 0 );
212     GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
213     GroupButtonsLayout->setAlignment( Qt::AlignTop );
214     GroupButtonsLayout->setSpacing( 6 );
215     GroupButtonsLayout->setMargin( 11 );
216     buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
217     buttonCancel->setText( tr( "GEOM_BUT_CLOSE"  ) );
218     buttonCancel->setAutoDefault( TRUE );
219     GroupButtonsLayout->addWidget( buttonCancel, 0, 1 );
220     // buttonApply = new QPushButton( GroupButtons, "buttonApply" );
221 //     buttonApply->setText( tr( "GEOM_BUT_APPLY"  ) );
222 //     buttonApply->setAutoDefault( TRUE );
223 //     GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
224     QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
225     GroupButtonsLayout->addItem( spacer_8, 0, 0 );
226     QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
227     GroupButtonsLayout->addItem( spacer_9, 0, 2 );
228 //     buttonOk = new QPushButton( GroupButtons, "buttonOk" );
229 //     buttonOk->setText( tr( "GEOM_BUT_OK"  ) );
230 //     buttonOk->setAutoDefault( TRUE );
231 //     buttonOk->setDefault( TRUE );
232 //     GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
233     GeometryGUI_MaxToleranceDlgLayout->addWidget( GroupButtons, 2, 0 );
234     /***************************************************************/
235
236     Init(Sel) ; /* Initialisations */
237 }
238
239
240 //=================================================================================
241 // function : ~GeometryGUI_MaxToleranceDlg()
242 // purpose  : Destroys the object and frees any allocated resources
243 //=================================================================================
244 GeometryGUI_MaxToleranceDlg::~GeometryGUI_MaxToleranceDlg()
245 {
246     // no need to delete child widgets, Qt does it all for us
247 }
248
249
250 //=================================================================================
251 // function : Init()
252 // purpose  :
253 //=================================================================================
254 void GeometryGUI_MaxToleranceDlg::Init( SALOME_Selection* Sel )
255 {
256   myConstructorId = 0 ;
257   Constructor1->setChecked( TRUE );
258   myEditCurrentArgument = LineEditC1A1 ;        
259   mySelection = Sel;
260   myGeomGUI = GeometryGUI::GetGeometryGUI() ;
261   myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
262   
263   // TODO : previous selection into argument ?
264
265   /* Filter definitions */
266   Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
267   myGeom = GEOM::GEOM_Gen::_narrow(comp);
268
269   /* signals and slots connections */
270   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
271   connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
272   connect( SelectButtonC1A1, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
273   connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
274
275   connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
276
277   connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
278   /* to close dialog if study change */
279   connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
280
281   /* Move widget on the botton right corner of main widget */
282   int x, y ;
283   myGeomGUI->DefineDlgPosition( this, x, y ) ;
284   this->move( x, y ) ;
285   this->show() ; /* displays Dialog */
286   return ;
287 }
288
289
290 //=================================================================================
291 // function : ConstructorsClicked()
292 // purpose  : Radio button management
293 //=================================================================================
294 void GeometryGUI_MaxToleranceDlg::ConstructorsClicked(int constructorId)
295 {
296   return ;
297 }
298
299
300
301 //=================================================================================
302 // function : ClickOnCancel()
303 // purpose  :
304 //=================================================================================
305 void GeometryGUI_MaxToleranceDlg::ClickOnCancel()
306 {
307   disconnect( mySelection, 0, this, 0 );
308   myGeomGUI->ResetState() ;
309   reject() ;
310   return ;
311 }
312
313
314 //=================================================================================
315 // function : SelectionIntoArgument()
316 // purpose  : Called when selection as changed or other case
317 //=================================================================================
318 void GeometryGUI_MaxToleranceDlg::SelectionIntoArgument()
319 {
320   LineEdit_MinFace->setText("") ;
321   LineEdit_MinEdge->setText("") ;
322   LineEdit_MinVertex->setText("") ;
323   LineEdit_MaxFace->setText("") ;
324   LineEdit_MaxEdge->setText("") ;
325   LineEdit_MaxVertex->setText("") ;  
326   myEditCurrentArgument->setText("") ;
327
328   QString aString = ""; /* future the name of selection */
329
330   int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
331   if ( nbSel != 1 ) {
332     return ;
333   }
334
335   /*  nbSel == 1  */ 
336   TopoDS_Shape S;
337   if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
338     return ;
339   
340   if( S.IsNull() ) {
341     myEditCurrentArgument->setText( "" );
342     return ;
343   }
344  
345   LineEditC1A1->setText(aString) ;
346   this->CalculateMaxTolerance(S) ;
347
348   return ;
349 }
350
351
352 //=================================================================================
353 // function : SetEditCurrentArgument()
354 // purpose  :
355 //=================================================================================
356 void GeometryGUI_MaxToleranceDlg::SetEditCurrentArgument()
357 {
358   QPushButton* send = (QPushButton*)sender();
359   switch (myConstructorId)
360     {
361     case 0: /* default constructor */
362       { 
363         if(send == SelectButtonC1A1) {
364           LineEditC1A1->setFocus() ;
365           myEditCurrentArgument = LineEditC1A1;
366         }
367         SelectionIntoArgument() ;
368         break;
369       }
370     }
371   return ;
372 }
373
374
375
376 //=================================================================================
377 // function : LineEditReturnPressed()
378 // purpose  :
379 //=================================================================================
380 void GeometryGUI_MaxToleranceDlg::LineEditReturnPressed()
381 {
382   QLineEdit* send = (QLineEdit*)sender();  
383   if( send == LineEditC1A1 )
384     myEditCurrentArgument = LineEditC1A1 ;
385   else
386     return ;
387   
388   /* User name of object input management                          */
389   /* If successfull the selection is changed and signal emitted... */
390   /* so SelectionIntoArgument() is automatically called.           */
391   const QString objectUserName = myEditCurrentArgument->text() ;
392   QWidget* thisWidget = (QWidget*)this ;
393   if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
394     myEditCurrentArgument->setText( objectUserName ) ;
395   }
396   return ;
397 }
398
399
400
401 //=================================================================================
402 // function : DeactivateActiveDialog()
403 // purpose  :
404 //=================================================================================
405 void GeometryGUI_MaxToleranceDlg::DeactivateActiveDialog()
406 {
407   if ( GroupConstructors->isEnabled() ) {    
408     disconnect( mySelection, 0, this, 0 );
409     GroupConstructors->setEnabled(false) ;
410     GroupConstructor1->setEnabled(false) ;
411     GroupButtons->setEnabled(false) ;
412   }
413   return ;
414 }
415
416
417 //=================================================================================
418 // function : ActivateThisDialog()
419 // purpose  :
420 //=================================================================================
421 void GeometryGUI_MaxToleranceDlg::ActivateThisDialog()
422 {
423   /* Emit a signal to deactivate the active dialog */
424   myGeomGUI->EmitSignalDeactivateDialog() ;   
425   GroupConstructors->setEnabled(true) ;
426   GroupConstructor1->setEnabled(true) ;
427   GroupButtons->setEnabled(true) ;
428   connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
429   return ;
430 }
431
432
433 //=================================================================================
434 // function : enterEvent()
435 // purpose  :
436 //=================================================================================
437 void GeometryGUI_MaxToleranceDlg::enterEvent(QEvent* e)
438 {
439   if ( GroupConstructors->isEnabled() )
440     return ;  
441   ActivateThisDialog() ;
442   return ;
443 }
444
445
446 //=================================================================================
447 // function : closeEvent()
448 // purpose  :
449 //=================================================================================
450 void GeometryGUI_MaxToleranceDlg::closeEvent( QCloseEvent* e )
451 {
452   /* same than click on cancel button */
453   this->ClickOnCancel() ;
454   return ;
455 }
456
457
458 //=================================================================================
459 // function : CalculateMaxTolerance()
460 // purpose  :
461 //=================================================================================
462 void GeometryGUI_MaxToleranceDlg::CalculateMaxTolerance(const TopoDS_Shape& S)
463 {
464   LineEdit_MinFace->setText("") ;
465   LineEdit_MinEdge->setText("") ;
466   LineEdit_MinVertex->setText("") ;
467   LineEdit_MaxFace->setText("") ;
468   LineEdit_MaxEdge->setText("") ;
469   LineEdit_MaxVertex->setText("") ;
470   if( S.IsNull() ) 
471     return ;
472
473   Standard_Real T,TMF,TME,TMV,TmF,TmE,TmV;
474   Standard_Integer nbF,nbE,nbV;
475   TMF=TME=TMV=-RealLast();
476   TmF=TmE=TmV=RealLast();
477   nbF=nbE=nbV=0;
478
479   bool m_isFace = false;
480   bool m_isEdge = false;
481   bool m_isVertex = false;
482   try 
483     {
484     for( TopExp_Explorer ExF(S,TopAbs_FACE); ExF.More(); ExF.Next() ) 
485       { 
486         m_isFace = true;
487         TopoDS_Face Face=TopoDS::Face(ExF.Current());
488         T=BRep_Tool::Tolerance(Face);
489         if(T>TMF) TMF=T;
490         if(T<TmF) TmF=T;
491         nbF++;
492       }
493     for( TopExp_Explorer ExE(S,TopAbs_EDGE); ExE.More(); ExE.Next() )
494       { 
495         m_isEdge = true;
496         TopoDS_Edge Edge=TopoDS::Edge(ExE.Current());
497         T=BRep_Tool::Tolerance(Edge);
498         if(T>TME) TME=T;
499         if(T<TmE) TmE=T;
500         nbE++;
501       }
502     for( TopExp_Explorer ExV(S,TopAbs_VERTEX); ExV.More(); ExV.Next() )
503       { 
504         m_isVertex = true;
505         TopoDS_Vertex Vertex=TopoDS::Vertex(ExV.Current());
506         T=BRep_Tool::Tolerance(Vertex);
507         if(T>TMV) TMV=T;
508         if(T<TmV) TmV=T;
509         nbV++;
510       }
511     if (m_isFace)
512       {
513         LineEdit_MinFace->setText( tr("%1").arg( TmF, 5, 'e', 8 ) ) ;
514         LineEdit_MaxFace->setText( tr("%1").arg( TMF, 5, 'e', 8 ) ) ;
515       }
516     else
517       {
518         LineEdit_MinFace->setText( "" ) ;
519         LineEdit_MaxFace->setText( "" ) ;
520       }
521     if (m_isEdge)
522       {
523         LineEdit_MinEdge->setText( tr("%1").arg( TmE, 5, 'e', 8 ) ) ;
524         LineEdit_MaxEdge->setText( tr("%1").arg( TME, 5, 'e', 8 ) ) ;
525       }
526     else
527       {
528         LineEdit_MinEdge->setText( "" ) ;
529         LineEdit_MaxEdge->setText( "" ) ;
530       }
531     if (m_isVertex)
532       {
533         LineEdit_MinVertex->setText( tr("%1").arg( TmV, 5, 'e', 8 ) ) ;
534         LineEdit_MaxVertex->setText( tr("%1").arg( TMV, 5, 'e', 8 ) ) ;
535       }
536     else
537       {
538         LineEdit_MinVertex->setText( "" ) ;
539         LineEdit_MaxVertex->setText( "" ) ;
540       }
541   }
542   catch(Standard_Failure) 
543     {
544       MESSAGE("Catch intercepted in CalculateMaxTolerance()" << endl ) ;
545     }
546   return ;
547 }