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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : MeasureGUI_CheckShapeDlg.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
26 #include "MeasureGUI_CheckShapeDlg.h"
27 #include "MeasureGUI_Widgets.h"
29 #include <SUIT_Session.h>
30 #include <SUIT_ResourceMgr.h>
31 #include <SalomeApp_Tools.h>
33 #define TEXTEDIT_FONT_FAMILY "Courier"
34 #define TEXTEDIT_FONT_SIZE 11
36 //=================================================================================
37 // class : MeasureGUI_CheckShapeDlg()
38 // purpose : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the
39 // name 'name' and widget flags set to 'f'.
40 // The dialog will by default be modeless, unless you set 'modal' to
41 // true to construct a modal dialog.
42 //=================================================================================
43 MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* parent )
44 : MeasureGUI_Skeleton( GUI, parent )
46 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
47 "GEOM", tr( "ICON_DLG_CHECKSHAPE" ) ) );
48 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
49 "GEOM", tr( "ICON_SELECT" ) ) );
51 setWindowTitle( tr( "GEOM_CHECK_TITLE" ) );
53 /***************************************************************/
55 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
56 mainFrame()->RadioButton1->setIcon( image0 );
58 myGrp = new MeasureGUI_1Sel1TextView1Check( centralWidget() );
59 myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
60 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
61 myGrp->TextView1->setReadOnly( true );
63 QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE );
64 aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias );
65 myGrp->TextView1->setFont( aFont );
66 myGrp->PushButton1->setIcon( image1 );
67 myGrp->LineEdit1->setReadOnly( true );
69 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
70 layout->setMargin( 0 ); layout->setSpacing( 6 );
71 layout->addWidget( myGrp );
73 /***************************************************************/
75 myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#check";
81 //=================================================================================
82 // function : ~MeasureGUI_CheckShapeDlg()
83 // purpose : Destroys the object and frees any allocated resources
84 //=================================================================================
85 MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
90 //=================================================================================
93 //=================================================================================
94 void MeasureGUI_CheckShapeDlg::Init()
96 mySelBtn = myGrp->PushButton1;
97 mySelEdit = myGrp->LineEdit1;
98 MeasureGUI_Skeleton::Init();
100 connect( myGrp->CheckBox1, SIGNAL( toggled( bool) ),
101 this, SLOT( SelectionIntoArgument() ) );
104 //=================================================================================
105 // function : getParameters
107 //=================================================================================
108 bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg )
110 if ( myObj->_is_nil() )
115 bool isCheckGeometry = myGrp->CheckBox1->isChecked();
116 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
117 GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
118 if ( isCheckGeometry )
119 theIsValid = aMeasureOp->CheckShapeWithGeometry( myObj, aMsg );
121 theIsValid = aMeasureOp->CheckShape( myObj, aMsg );
124 catch( const SALOME::SALOME_Exception& e ) {
125 SalomeApp_Tools::QtCatchCorbaException( e );
129 return getOperation()->IsDone();
134 //=================================================================================
135 // function : processObject
137 //=================================================================================
138 void MeasureGUI_CheckShapeDlg::processObject()
142 if ( !getParameters( isShapeValid, aMsg ) ) {
143 myGrp->TextView1->setText( "" );
147 if ( isShapeValid ) {
148 myGrp->TextView1->setText( "This Shape seems to be valid." );
151 QString aDescr ( "This Shape is not valid.\n" );
153 myGrp->TextView1->setText( aDescr );
154 // myGrp->TextView1->setText("This Shape is not valid.");