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
24 // File : MeasureGUI_CheckShapeDlg.cxx
25 // Author : Nicolas REJNERI
29 #include "MeasureGUI_CheckShapeDlg.h"
31 #include "utilities.h"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Tools.h"
35 #include <qtextedit.h>
36 #include <qlineedit.h>
39 #include <qpushbutton.h>
40 #include <qradiobutton.h>
41 #include <qbuttongroup.h>
42 #include <qcheckbox.h>
44 #define TEXTEDIT_FONT_FAMILY "Courier"
45 #define TEXTEDIT_FONT_SIZE 11
47 MeasureGUI_1Sel1TextView1Check_QTD::MeasureGUI_1Sel1TextView1Check_QTD(QWidget* parent,
48 const char* name, WFlags fl)
49 : MeasureGUI_1Sel1TextView_QTD(parent, name, fl)
51 CheckBoxGeom = new QCheckBox(GroupBox1, "CheckBoxGeom");
52 CheckBoxGeom->setText(tr("CHECK_SHAPE_GEOMETRY"));
53 Layout1->addMultiCellWidget(CheckBoxGeom, 2, 2, 0, 2);
55 CheckBoxGeom->setChecked(false);
58 MeasureGUI_1Sel1TextView1Check_QTD::~MeasureGUI_1Sel1TextView1Check_QTD()
60 // no need to delete child widgets, Qt does it all for us
63 //=================================================================================
64 // class : MeasureGUI_CheckShapeDlg()
65 // purpose : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the
66 // name 'name' and widget flags set to 'f'.
67 // The dialog will by default be modeless, unless you set 'modal' to
68 // TRUE to construct a modal dialog.
69 //=================================================================================
70 MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* parent )
71 : MeasureGUI_Skeleton( GUI, parent, "MeasureGUI_CheckShapeDlg" )
73 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
74 "GEOM",tr( "ICON_DLG_CHECKSHAPE" ) ) );
75 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
76 "GEOM",tr( "ICON_SELECT" ) ) );
78 setCaption( tr( "GEOM_CHECK_TITLE" ) );
80 /***************************************************************/
82 GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
83 RadioButton1->setPixmap( image0 );
85 myGrp = new MeasureGUI_1Sel1TextView1Check_QTD( this, "myGrp" );
86 myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
87 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
88 myGrp->TextEdit1->setReadOnly( TRUE );
90 QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE );
91 aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias );
92 myGrp->TextEdit1->setFont( aFont );
93 myGrp->PushButton1->setPixmap( image1 );
94 myGrp->LineEdit1->setReadOnly( true );
96 Layout1->addWidget( myGrp, 1, 0 );
98 /***************************************************************/
100 myHelpFileName = "using_measurement_tools_page.html#check_anchor";
106 //=================================================================================
107 // function : ~MeasureGUI_CheckShapeDlg()
108 // purpose : Destroys the object and frees any allocated resources
109 //=================================================================================
110 MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
115 //=================================================================================
118 //=================================================================================
119 void MeasureGUI_CheckShapeDlg::Init()
121 mySelBtn = myGrp->PushButton1;
122 mySelEdit = myGrp->LineEdit1;
123 MeasureGUI_Skeleton::Init();
125 connect(myGrp->CheckBoxGeom, SIGNAL(toggled(bool)),
126 this, SLOT(SelectionIntoArgument()));
129 //=================================================================================
130 // function : getParameters
132 //=================================================================================
133 bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg )
135 if ( myObj->_is_nil() )
142 bool isCheckGeometry = myGrp->CheckBoxGeom->isChecked();
143 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
144 GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
146 theIsValid = aMeasureOp->CheckShapeWithGeometry(myObj, aMsg);
148 theIsValid = aMeasureOp->CheckShape(myObj, aMsg);
151 catch( const SALOME::SALOME_Exception& e )
153 SalomeApp_Tools::QtCatchCorbaException( e );
157 return getOperation()->IsDone();
162 //=================================================================================
163 // function : processObject
165 //=================================================================================
166 void MeasureGUI_CheckShapeDlg::processObject()
170 if ( !getParameters( isShapeValid, aMsg ) )
172 myGrp->TextEdit1->setText( "" );
177 myGrp->TextEdit1->setText("This Shape seems to be valid.");
179 QString aDescr ("This Shape is not valid.\n");
181 myGrp->TextEdit1->setText(aDescr);
182 // myGrp->TextEdit1->setText("This Shape is not valid.");