Back to index

salome-geom  6.5.0
MeasureGUI_CheckShapeDlg.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_CheckShapeDlg.cxx
00025 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
00026 //
00027 #include "MeasureGUI_CheckShapeDlg.h"
00028 #include "MeasureGUI_Widgets.h"
00029 
00030 #include <SUIT_Session.h>
00031 #include <SUIT_ResourceMgr.h>
00032 #include <SalomeApp_Tools.h>
00033 
00034 #define TEXTEDIT_FONT_FAMILY "Courier"
00035 #define TEXTEDIT_FONT_SIZE 11
00036 
00037 //=================================================================================
00038 // class    : MeasureGUI_CheckShapeDlg()
00039 // purpose  : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the
00040 //            name 'name' and widget flags set to 'f'.
00041 //            The dialog will by default be modeless, unless you set 'modal' to
00042 //            true to construct a modal dialog.
00043 //=================================================================================
00044 MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* parent )
00045   : MeasureGUI_Skeleton( GUI, parent )
00046 {
00047   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
00048     "GEOM", tr( "ICON_DLG_CHECKSHAPE" ) ) );
00049   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
00050     "GEOM", tr( "ICON_SELECT" ) ) );
00051 
00052   setWindowTitle( tr( "GEOM_CHECK_TITLE" ) );
00053 
00054   /***************************************************************/
00055 
00056   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
00057   mainFrame()->RadioButton1->setIcon( image0 );
00058 
00059   myGrp = new MeasureGUI_1Sel1TextView1Check( centralWidget() );
00060   myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
00061   myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
00062   myGrp->TextView1->setReadOnly( true );
00063 
00064   QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE );
00065   aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias );
00066   myGrp->TextView1->setFont( aFont );
00067   myGrp->PushButton1->setIcon( image1 );
00068   myGrp->LineEdit1->setReadOnly( true );
00069 
00070   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
00071   layout->setMargin( 0 ); layout->setSpacing( 6 );
00072   layout->addWidget( myGrp );
00073 
00074   /***************************************************************/
00075 
00076   myHelpFileName = "using_measurement_tools_page.html#check_anchor";
00077 
00078   /* Initialisation */
00079   Init();
00080 }
00081 
00082 //=================================================================================
00083 // function : ~MeasureGUI_CheckShapeDlg()
00084 // purpose  : Destroys the object and frees any allocated resources
00085 //=================================================================================
00086 MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
00087 {
00088 }
00089 
00090 
00091 //=================================================================================
00092 // function : Init()
00093 // purpose  :
00094 //=================================================================================
00095 void MeasureGUI_CheckShapeDlg::Init()
00096 {
00097   mySelBtn = myGrp->PushButton1;
00098   mySelEdit = myGrp->LineEdit1;
00099   MeasureGUI_Skeleton::Init();
00100 
00101   connect( myGrp->CheckBox1, SIGNAL( toggled( bool) ), 
00102            this, SLOT( SelectionIntoArgument() ) );
00103 }
00104 
00105 //=================================================================================
00106 // function : getParameters
00107 // purpose  :
00108 //=================================================================================
00109 bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg )
00110 {
00111   if ( myObj->_is_nil() )
00112     return false;
00113   else {
00114     GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
00115     try {
00116       char* aMsg;
00117       bool isCheckGeometry = myGrp->CheckBox1->isChecked();
00118       if ( isCheckGeometry )
00119         theIsValid = anOper->CheckShapeWithGeometry( myObj, aMsg );
00120       else
00121         theIsValid = anOper->CheckShape( myObj, aMsg );
00122       theMsg = aMsg;
00123     }
00124     catch( const SALOME::SALOME_Exception& e ) {
00125       SalomeApp_Tools::QtCatchCorbaException( e );
00126       return false;
00127     }
00128 
00129     return anOper->IsDone();
00130   }
00131 }
00132 
00133 
00134 //=================================================================================
00135 // function : processObject
00136 // purpose  :
00137 //=================================================================================
00138 void MeasureGUI_CheckShapeDlg::processObject()
00139 {
00140   bool isShapeValid;
00141   QString aMsg;
00142   if ( !getParameters( isShapeValid, aMsg ) ) {
00143     myGrp->TextView1->setText( "" );
00144     return;
00145   }
00146 
00147   if ( isShapeValid ) {
00148     myGrp->TextView1->setText( "This Shape seems to be valid." );
00149   } 
00150   else {
00151     QString aDescr ( "This Shape is not valid.\n" );
00152     aDescr += aMsg;
00153     myGrp->TextView1->setText( aDescr );
00154 //    myGrp->TextView1->setText("This Shape is not valid.");
00155   }
00156 }