Salome HOME
Update mail address
[modules/geom.git] / src / MeasureGUI / MeasureGUI_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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : MeasureGUI_MaxToleranceDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : GEOM
27 //  $Header$
28
29 #include "MeasureGUI_MaxToleranceDlg.h"
30 #include "MeasureGUI_1Sel6LineEdit_QTD.h"
31
32 #include "utilities.h"
33 #include "SUIT_Session.h"
34 #include "SalomeApp_Tools.h"
35
36 #include <qlineedit.h>
37 #include <qlabel.h>
38 #include <qlayout.h>
39 #include <qpushbutton.h>
40 #include <qradiobutton.h>
41 #include <qbuttongroup.h>
42
43 //=================================================================================
44 // class    : MeasureGUI_MaxToleranceDlg()
45 // purpose  : Constructs a MeasureGUI_MaxToleranceDlg which is a child of 'parent', with the
46 //            name 'name' and widget flags set to 'f'.
47 //            The dialog will by default be modeless, unless you set 'modal' to
48 //            TRUE to construct a modal dialog.
49 //=================================================================================
50 MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg( GeometryGUI* GUI, QWidget* parent )
51 : MeasureGUI_Skeleton( GUI, parent, "MeasureGUI_MaxToleranceDlg" )
52 {
53   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
54     "GEOM",tr( "ICON_DLG_TOLERANCE" ) ) );
55   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
56     "GEOM",tr( "ICON_SELECT" ) ) );
57
58   setCaption( tr( "GEOM_TOLERANCE_TITLE" ) );
59
60   /***************************************************************/
61   
62   GroupConstructors->setTitle( tr( "GEOM_TOLERANCE" ) );
63   RadioButton1->setPixmap( image0 );
64
65   myGrp = new MeasureGUI_1Sel6LineEdit_QTD( this, "myGrp" );
66   myGrp->GroupBox1->setTitle( tr( "GEOM_TOLERANCE_CONSTR" ) );
67   myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
68   myGrp->TextLabel2->setText( tr( "GEOM_MIN" ) );
69   myGrp->TextLabel3->setText( tr( "GEOM_MAX" ) );
70   myGrp->TextLabel4->setText( tr( "GEOM_TOLERANCE_FACE" ) );
71   myGrp->TextLabel5->setText( tr( "GEOM_TOLERANCE_EDGE" ) );
72   myGrp->TextLabel6->setText( tr( "GEOM_TOLERANCE_VERTEX" ) );
73   myGrp->LineEdit11->setReadOnly( TRUE );
74   myGrp->LineEdit12->setReadOnly( TRUE );
75   myGrp->LineEdit21->setReadOnly( TRUE );
76   myGrp->LineEdit22->setReadOnly( TRUE );
77   myGrp->LineEdit31->setReadOnly( TRUE );
78   myGrp->LineEdit32->setReadOnly( TRUE );
79   myGrp->PushButton1->setPixmap( image1 );
80   myGrp->LineEdit1->setReadOnly( true );
81
82   Layout1->addWidget( myGrp, 1, 0 );
83   
84   /***************************************************************/
85
86   myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#Tolerance";
87   
88   /* Initialisation */
89   Init();
90 }
91
92
93 //=================================================================================
94 // function : ~MeasureGUI_MaxToleranceDlg()
95 // purpose  : Destroys the object and frees any allocated resources
96 //=================================================================================
97 MeasureGUI_MaxToleranceDlg::~MeasureGUI_MaxToleranceDlg()
98 {
99 }
100
101
102 //=================================================================================
103 // function : Init()
104 // purpose  :
105 //=================================================================================
106 void MeasureGUI_MaxToleranceDlg::Init()
107 {
108   mySelBtn = myGrp->PushButton1;
109   mySelEdit = myGrp->LineEdit1;
110   MeasureGUI_Skeleton::Init();
111 }
112
113 //=================================================================================
114 // function : processObject
115 // purpose  :
116 //=================================================================================
117 void MeasureGUI_MaxToleranceDlg::processObject()
118 {
119   double aMinFaceToler, aMaxFaceToler;
120   double aMinEdgeToler, aMaxEdgeToler;
121   double aMinVertexToler, aMaxVertexToler;
122   
123   if ( !getParameters( aMinFaceToler, aMaxFaceToler,
124                        aMinEdgeToler, aMaxEdgeToler,
125                        aMinVertexToler, aMaxVertexToler ) )
126   {
127     myGrp->LineEdit11->setText( "" );
128     myGrp->LineEdit12->setText( "" );
129
130     myGrp->LineEdit21->setText( "" );
131     myGrp->LineEdit22->setText( "" );
132
133     myGrp->LineEdit31->setText( "" );
134     myGrp->LineEdit32->setText( "" );
135
136     return;
137   }
138
139   double invalidMin = RealLast();
140   double invalidMax = -RealLast();
141
142   myGrp->LineEdit11->setText( aMinFaceToler != invalidMin ? QString( "%1" ).arg( aMinFaceToler, 5, 'e', 8 ) : QString("") );
143   myGrp->LineEdit12->setText( aMaxFaceToler != invalidMax ? QString( "%1" ).arg( aMaxFaceToler, 5, 'e', 8 ) : QString("") );
144
145   myGrp->LineEdit21->setText( aMinEdgeToler != invalidMin ? QString( "%1" ).arg( aMinEdgeToler, 5, 'e', 8 ) : QString("") );
146   myGrp->LineEdit22->setText( aMaxEdgeToler != invalidMax ? QString( "%1" ).arg( aMaxEdgeToler, 5, 'e', 8 ) : QString("") );
147
148   myGrp->LineEdit31->setText( aMinVertexToler != invalidMin ? QString( "%1" ).arg( aMinVertexToler, 5, 'e', 8 ) : QString("") );
149   myGrp->LineEdit32->setText( aMaxVertexToler != invalidMax ? QString( "%1" ).arg( aMaxVertexToler, 5, 'e', 8 ) : QString("") );
150 }
151
152 //=================================================================================
153 // function : getParameters
154 // purpose  : Get tolerances. Returns false is myObj is nill. If there is no a
155 //            type of entity ( face, edge or vertex ) in selected object then corresponding
156 //            tolerances is less than 0
157 //=================================================================================
158 bool MeasureGUI_MaxToleranceDlg::getParameters( double& theMinFaceToler,
159                                                 double& theMaxFaceToler,
160                                                 double& theMinEdgeToler,
161                                                 double& theMaxEdgeToler,
162                                                 double& theMinVertexToler,
163                                                 double& theMaxVertexToler )
164 {
165   if ( myObj->_is_nil() )
166     return false;
167   else
168   {
169     try
170     {
171       GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetTolerance( myObj,
172         theMinFaceToler, theMaxFaceToler, theMinEdgeToler,
173         theMaxEdgeToler, theMinVertexToler, theMaxVertexToler  );
174     }
175     catch( const SALOME::SALOME_Exception& e )
176     {
177       SalomeApp_Tools::QtCatchCorbaException( e );
178       return false;
179     }
180
181     return getOperation()->IsDone();
182   }
183 }
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204