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 : MeasureGUI_MaxToleranceDlg.cxx
25 // Author : Nicolas REJNERI
29 #include "MeasureGUI_MaxToleranceDlg.h"
30 #include "MeasureGUI_1Sel6LineEdit_QTD.h"
31 #include "SALOMEGUI_QtCatchCorbaException.hxx"
33 #include "utilities.h"
34 #include "QAD_Desktop.h"
36 #include <qlineedit.h>
38 #include <qpushbutton.h>
39 #include <qradiobutton.h>
40 #include <qbuttongroup.h>
42 //=================================================================================
43 // class : MeasureGUI_MaxToleranceDlg()
44 // purpose : Constructs a MeasureGUI_MaxToleranceDlg which is a child of 'parent', with the
45 // name 'name' and widget flags set to 'f'.
46 // The dialog will by default be modeless, unless you set 'modal' to
47 // TRUE to construct a modal dialog.
48 //=================================================================================
49 MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg( QWidget* parent, SALOME_Selection* Sel )
50 : MeasureGUI_Skeleton( parent, "MeasureGUI_MaxToleranceDlg", Sel )
52 QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap(
53 "GEOM",tr( "ICON_DLG_TOLERANCE" ) ) );
54 QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap(
55 "GEOM",tr( "ICON_SELECT" ) ) );
57 setCaption( tr( "GEOM_TOLERANCE_TITLE" ) );
59 /***************************************************************/
61 GroupConstructors->setTitle( tr( "GEOM_TOLERANCE" ) );
62 RadioButton1->setPixmap( image0 );
64 myGrp = new MeasureGUI_1Sel6LineEdit_QTD( this, "myGrp" );
65 myGrp->GroupBox1->setTitle( tr( "GEOM_TOLERANCE_CONSTR" ) );
66 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
67 myGrp->TextLabel2->setText( tr( "GEOM_MIN" ) );
68 myGrp->TextLabel3->setText( tr( "GEOM_MAX" ) );
69 myGrp->TextLabel4->setText( tr( "GEOM_TOLERANCE_FACE" ) );
70 myGrp->TextLabel5->setText( tr( "GEOM_TOLERANCE_EDGE" ) );
71 myGrp->TextLabel6->setText( tr( "GEOM_TOLERANCE_VERTEX" ) );
72 myGrp->LineEdit11->setReadOnly( TRUE );
73 myGrp->LineEdit12->setReadOnly( TRUE );
74 myGrp->LineEdit21->setReadOnly( TRUE );
75 myGrp->LineEdit22->setReadOnly( TRUE );
76 myGrp->LineEdit31->setReadOnly( TRUE );
77 myGrp->LineEdit32->setReadOnly( TRUE );
78 myGrp->PushButton1->setPixmap( image1 );
79 myGrp->LineEdit1->setReadOnly( true );
81 Layout1->addWidget( myGrp, 1, 0 );
83 /***************************************************************/
90 //=================================================================================
91 // function : ~MeasureGUI_MaxToleranceDlg()
92 // purpose : Destroys the object and frees any allocated resources
93 //=================================================================================
94 MeasureGUI_MaxToleranceDlg::~MeasureGUI_MaxToleranceDlg()
99 //=================================================================================
102 //=================================================================================
103 void MeasureGUI_MaxToleranceDlg::Init( SALOME_Selection* Sel )
105 mySelBtn = myGrp->PushButton1;
106 mySelEdit = myGrp->LineEdit1;
107 MeasureGUI_Skeleton::Init( Sel );
110 //=================================================================================
111 // function : processObject
113 //=================================================================================
114 void MeasureGUI_MaxToleranceDlg::processObject()
116 double aMinFaceToler, aMaxFaceToler;
117 double aMinEdgeToler, aMaxEdgeToler;
118 double aMinVertexToler, aMaxVertexToler;
120 if ( !getParameters( aMinFaceToler, aMaxFaceToler,
121 aMinEdgeToler, aMaxEdgeToler,
122 aMinVertexToler, aMaxVertexToler ) )
124 myGrp->LineEdit11->setText( "" );
125 myGrp->LineEdit12->setText( "" );
127 myGrp->LineEdit21->setText( "" );
128 myGrp->LineEdit22->setText( "" );
130 myGrp->LineEdit31->setText( "" );
131 myGrp->LineEdit32->setText( "" );
136 double invalidMin = RealLast();
137 double invalidMax = -RealLast();
139 myGrp->LineEdit11->setText( aMinFaceToler != invalidMin ? QString( "%1" ).arg( aMinFaceToler, 5, 'e', 8 ) : QString("") );
140 myGrp->LineEdit12->setText( aMaxFaceToler != invalidMax ? QString( "%1" ).arg( aMaxFaceToler, 5, 'e', 8 ) : QString("") );
142 myGrp->LineEdit21->setText( aMinEdgeToler != invalidMin ? QString( "%1" ).arg( aMinEdgeToler, 5, 'e', 8 ) : QString("") );
143 myGrp->LineEdit22->setText( aMaxEdgeToler != invalidMax ? QString( "%1" ).arg( aMaxEdgeToler, 5, 'e', 8 ) : QString("") );
145 myGrp->LineEdit31->setText( aMinVertexToler != invalidMin ? QString( "%1" ).arg( aMinVertexToler, 5, 'e', 8 ) : QString("") );
146 myGrp->LineEdit32->setText( aMaxVertexToler != invalidMax ? QString( "%1" ).arg( aMaxVertexToler, 5, 'e', 8 ) : QString("") );
149 //=================================================================================
150 // function : getParameters
151 // purpose : Get tolerances. Returns false is myObj is nill. If there is no a
152 // type of entity ( face, edge or vertex ) in selected object then corresponding
153 // tolerances is less than 0
154 //=================================================================================
155 bool MeasureGUI_MaxToleranceDlg::getParameters( double& theMinFaceToler,
156 double& theMaxFaceToler,
157 double& theMinEdgeToler,
158 double& theMaxEdgeToler,
159 double& theMinVertexToler,
160 double& theMaxVertexToler )
162 if ( myObj->_is_nil() )
168 GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetTolerance( myObj,
169 theMinFaceToler, theMaxFaceToler, theMinEdgeToler,
170 theMaxEdgeToler, theMinVertexToler, theMaxVertexToler );
172 catch( const SALOME::SALOME_Exception& e )
174 QtCatchCorbaException( e );
178 return getOperation()->IsDone();