1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : MeasureGUI_CheckShapeDlg.cxx
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
27 #include "MeasureGUI_CheckShapeDlg.h"
28 #include "MeasureGUI_Widgets.h"
30 #include <SUIT_Session.h>
31 #include <SUIT_ResourceMgr.h>
32 #include <SalomeApp_Tools.h>
34 #define TEXTEDIT_FONT_FAMILY "Courier"
35 #define TEXTEDIT_FONT_SIZE 11
37 //=================================================================================
38 // class : MeasureGUI_CheckShapeDlg()
39 // purpose : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the
40 // name 'name' and widget flags set to 'f'.
41 // The dialog will by default be modeless, unless you set 'modal' to
42 // true to construct a modal dialog.
43 //=================================================================================
44 MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* parent )
45 : MeasureGUI_Skeleton( GUI, parent )
47 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
48 "GEOM", tr( "ICON_DLG_CHECKSHAPE" ) ) );
49 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
50 "GEOM", tr( "ICON_SELECT" ) ) );
52 setWindowTitle( tr( "GEOM_CHECK_TITLE" ) );
54 /***************************************************************/
56 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
57 mainFrame()->RadioButton1->setIcon( image0 );
59 myGrp = new MeasureGUI_1Sel1TextView1Check( centralWidget() );
60 myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
61 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
62 myGrp->TextView1->setReadOnly( true );
64 QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE );
65 aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias );
66 myGrp->TextView1->setFont( aFont );
67 myGrp->PushButton1->setIcon( image1 );
68 myGrp->LineEdit1->setReadOnly( true );
70 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
71 layout->setMargin( 0 ); layout->setSpacing( 6 );
72 layout->addWidget( myGrp );
74 /***************************************************************/
76 myHelpFileName = "using_measurement_tools_page.html#check_anchor";
82 //=================================================================================
83 // function : ~MeasureGUI_CheckShapeDlg()
84 // purpose : Destroys the object and frees any allocated resources
85 //=================================================================================
86 MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
91 //=================================================================================
94 //=================================================================================
95 void MeasureGUI_CheckShapeDlg::Init()
97 mySelBtn = myGrp->PushButton1;
98 mySelEdit = myGrp->LineEdit1;
99 MeasureGUI_Skeleton::Init();
101 connect( myGrp->CheckBox1, SIGNAL( toggled( bool) ),
102 this, SLOT( SelectionIntoArgument() ) );
105 //=================================================================================
106 // function : getParameters
108 //=================================================================================
109 bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg )
111 if ( myObj->_is_nil() )
114 GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
117 bool isCheckGeometry = myGrp->CheckBox1->isChecked();
118 if ( isCheckGeometry )
119 theIsValid = anOper->CheckShapeWithGeometry( myObj, aMsg );
121 theIsValid = anOper->CheckShape( myObj, aMsg );
124 catch( const SALOME::SALOME_Exception& e ) {
125 SalomeApp_Tools::QtCatchCorbaException( e );
129 return anOper->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.");