Back to index

salome-geom  6.5.0
MeasureGUI_MaxToleranceDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : MeasureGUI_MaxToleranceDlg.cxx
00025 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
00026 //
00027 #include "MeasureGUI_MaxToleranceDlg.h"
00028 #include "MeasureGUI_Widgets.h"
00029 #include "DlgRef.h"
00030 
00031 #include <SUIT_Session.h>
00032 #include <SUIT_ResourceMgr.h>
00033 #include <SalomeApp_Tools.h>
00034 
00035 //=================================================================================
00036 // class    : MeasureGUI_MaxToleranceDlg()
00037 // purpose  : Constructs a MeasureGUI_MaxToleranceDlg which is a child of 'parent', with the
00038 //            name 'name' and widget flags set to 'f'.
00039 //            The dialog will by default be modeless, unless you set 'modal' to
00040 //            true to construct a modal dialog.
00041 //=================================================================================
00042 MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg( GeometryGUI* GUI, QWidget* parent )
00043   : MeasureGUI_Skeleton( GUI, parent )
00044 {
00045   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
00046     "GEOM", tr( "ICON_DLG_TOLERANCE" ) ) );
00047   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
00048     "GEOM", tr( "ICON_SELECT" ) ) );
00049 
00050   setWindowTitle( tr( "GEOM_TOLERANCE_TITLE" ) );
00051 
00052   /***************************************************************/
00053   
00054   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_TOLERANCE" ) );
00055   mainFrame()->RadioButton1->setIcon( image0 );
00056 
00057   myGrp = new MeasureGUI_1Sel6LineEdit( centralWidget() );
00058   myGrp->GroupBox1->setTitle( tr( "GEOM_TOLERANCE_CONSTR" ) );
00059   myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
00060   myGrp->TextLabel2->setText( tr( "GEOM_MIN" ) );
00061   myGrp->TextLabel3->setText( tr( "GEOM_MAX" ) );
00062   myGrp->TextLabel4->setText( tr( "GEOM_TOLERANCE_FACE" ) );
00063   myGrp->TextLabel5->setText( tr( "GEOM_TOLERANCE_EDGE" ) );
00064   myGrp->TextLabel6->setText( tr( "GEOM_TOLERANCE_VERTEX" ) );
00065   myGrp->LineEdit11->setReadOnly( true );
00066   myGrp->LineEdit12->setReadOnly( true );
00067   myGrp->LineEdit21->setReadOnly( true );
00068   myGrp->LineEdit22->setReadOnly( true );
00069   myGrp->LineEdit31->setReadOnly( true );
00070   myGrp->LineEdit32->setReadOnly( true );
00071   myGrp->PushButton1->setIcon( image1 );
00072   myGrp->LineEdit1->setReadOnly( true );
00073 
00074   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
00075   layout->setMargin( 0 ); layout->setSpacing( 6 );
00076   layout->addWidget( myGrp );
00077   
00078   /***************************************************************/
00079 
00080   myHelpFileName = "using_measurement_tools_page.html#tolerance_anchor";
00081   
00082   /* Initialisation */
00083   Init();
00084 }
00085 
00086 
00087 //=================================================================================
00088 // function : ~MeasureGUI_MaxToleranceDlg()
00089 // purpose  : Destroys the object and frees any allocated resources
00090 //=================================================================================
00091 MeasureGUI_MaxToleranceDlg::~MeasureGUI_MaxToleranceDlg()
00092 {
00093 }
00094 
00095 
00096 //=================================================================================
00097 // function : Init()
00098 // purpose  :
00099 //=================================================================================
00100 void MeasureGUI_MaxToleranceDlg::Init()
00101 {
00102   mySelBtn = myGrp->PushButton1;
00103   mySelEdit = myGrp->LineEdit1;
00104   MeasureGUI_Skeleton::Init();
00105 }
00106 
00107 //=================================================================================
00108 // function : processObject
00109 // purpose  :
00110 //=================================================================================
00111 void MeasureGUI_MaxToleranceDlg::processObject()
00112 {
00113   double aMinFaceToler, aMaxFaceToler;
00114   double aMinEdgeToler, aMaxEdgeToler;
00115   double aMinVertexToler, aMaxVertexToler;
00116   
00117   if ( !getParameters( aMinFaceToler, aMaxFaceToler,
00118                        aMinEdgeToler, aMaxEdgeToler,
00119                        aMinVertexToler, aMaxVertexToler ) ) {
00120     myGrp->LineEdit11->setText( "" );
00121     myGrp->LineEdit12->setText( "" );
00122 
00123     myGrp->LineEdit21->setText( "" );
00124     myGrp->LineEdit22->setText( "" );
00125 
00126     myGrp->LineEdit31->setText( "" );
00127     myGrp->LineEdit32->setText( "" );
00128 
00129     return;
00130   }
00131 
00132   double invalidMin = RealLast();
00133   double invalidMax = -RealLast();
00134 
00135   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
00136   int aPrecision = resMgr->integerValue( "Geometry", "len_tol_precision", -9);
00137 
00138   myGrp->LineEdit11->setText( aMinFaceToler != invalidMin ? DlgRef::PrintDoubleValue( aMinFaceToler, aPrecision ) : QString("") );
00139   myGrp->LineEdit12->setText( aMaxFaceToler != invalidMax ? DlgRef::PrintDoubleValue( aMaxFaceToler, aPrecision ) : QString("") );
00140 
00141   myGrp->LineEdit21->setText( aMinEdgeToler != invalidMin ? DlgRef::PrintDoubleValue( aMinEdgeToler, aPrecision ) : QString("") );
00142   myGrp->LineEdit22->setText( aMaxEdgeToler != invalidMax ? DlgRef::PrintDoubleValue( aMaxEdgeToler, aPrecision ) : QString("") );
00143 
00144   myGrp->LineEdit31->setText( aMinVertexToler != invalidMin ? DlgRef::PrintDoubleValue( aMinVertexToler, aPrecision ) : QString("") );
00145   myGrp->LineEdit32->setText( aMaxVertexToler != invalidMax ? DlgRef::PrintDoubleValue( aMaxVertexToler, aPrecision ) : QString("") );
00146 }
00147 
00148 //=================================================================================
00149 // function : getParameters
00150 // purpose  : Get tolerances. Returns false is myObj is nill. If there is no a
00151 //            type of entity ( face, edge or vertex ) in selected object then corresponding
00152 //            tolerances is less than 0
00153 //=================================================================================
00154 bool MeasureGUI_MaxToleranceDlg::getParameters( double& theMinFaceToler,
00155                                                 double& theMaxFaceToler,
00156                                                 double& theMinEdgeToler,
00157                                                 double& theMaxEdgeToler,
00158                                                 double& theMinVertexToler,
00159                                                 double& theMaxVertexToler )
00160 {
00161   if ( myObj->_is_nil() )
00162     return false;
00163   else {
00164     GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
00165     try {
00166       anOper->GetTolerance( myObj, 
00167                             theMinFaceToler, theMaxFaceToler,   theMinEdgeToler,
00168                             theMaxEdgeToler, theMinVertexToler, theMaxVertexToler );
00169     }
00170     catch( const SALOME::SALOME_Exception& e ) {
00171       SalomeApp_Tools::QtCatchCorbaException( e );
00172       return false;
00173     }
00174 
00175     return anOper->IsDone();
00176   }
00177 }