geom/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx

157 lines
5.5 KiB
C++
Raw Normal View History

2014-02-18 12:44:41 +06:00
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +06:00
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +06:00
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +06:00
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// GEOM GEOMGUI : GUI for Geometry component
// File : MeasureGUI_CheckShapeDlg.cxx
// Author : Nicolas REJNERI, Open CASCADE S.A.S.
2004-01-07 20:46:21 +05:00
//
#include "MeasureGUI_CheckShapeDlg.h"
2009-02-13 17:16:39 +05:00
#include "MeasureGUI_Widgets.h"
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Tools.h>
2004-01-07 20:46:21 +05:00
2004-12-01 15:39:14 +05:00
#define TEXTEDIT_FONT_FAMILY "Courier"
#define TEXTEDIT_FONT_SIZE 11
2004-06-16 21:24:55 +06:00
2004-01-07 20:46:21 +05:00
//=================================================================================
// class : MeasureGUI_CheckShapeDlg()
2004-12-01 15:39:14 +05:00
// purpose : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the
2004-01-07 20:46:21 +05:00
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
2009-02-13 17:16:39 +05:00
// true to construct a modal dialog.
2004-01-07 20:46:21 +05:00
//=================================================================================
MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* parent )
2009-02-13 17:16:39 +05:00
: MeasureGUI_Skeleton( GUI, parent )
2004-01-07 20:46:21 +05:00
{
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
2009-02-13 17:16:39 +05:00
"GEOM", tr( "ICON_DLG_CHECKSHAPE" ) ) );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
2009-02-13 17:16:39 +05:00
"GEOM", tr( "ICON_SELECT" ) ) );
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
setWindowTitle( tr( "GEOM_CHECK_TITLE" ) );
2004-01-07 20:46:21 +05:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
mainFrame()->RadioButton1->setIcon( image0 );
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
myGrp = new MeasureGUI_1Sel1TextView1Check( centralWidget() );
2004-12-01 15:39:14 +05:00
myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
2009-02-13 17:16:39 +05:00
myGrp->TextView1->setReadOnly( true );
2004-12-01 15:39:14 +05:00
QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE );
aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias );
2009-02-13 17:16:39 +05:00
myGrp->TextView1->setFont( aFont );
myGrp->PushButton1->setIcon( image1 );
2004-12-01 15:39:14 +05:00
myGrp->LineEdit1->setReadOnly( true );
2009-02-13 17:16:39 +05:00
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( myGrp );
2004-01-07 20:46:21 +05:00
/***************************************************************/
myHelpFileName = "using_measurement_tools_page.html#check_anchor";
2004-01-07 20:46:21 +05:00
/* Initialisation */
Init();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ~MeasureGUI_CheckShapeDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void MeasureGUI_CheckShapeDlg::Init()
2004-01-07 20:46:21 +05:00
{
2004-12-01 15:39:14 +05:00
mySelBtn = myGrp->PushButton1;
mySelEdit = myGrp->LineEdit1;
MeasureGUI_Skeleton::Init();
2009-02-13 17:16:39 +05:00
connect( myGrp->CheckBox1, SIGNAL( toggled( bool) ),
2012-08-09 13:58:02 +06:00
this, SLOT( SelectionIntoArgument() ) );
2004-01-07 20:46:21 +05:00
}
//=================================================================================
2004-12-01 15:39:14 +05:00
// function : getParameters
2004-01-07 20:46:21 +05:00
// purpose :
//=================================================================================
2004-12-01 15:39:14 +05:00
bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg )
2004-01-07 20:46:21 +05:00
{
2004-12-01 15:39:14 +05:00
if ( myObj->_is_nil() )
return false;
2009-02-13 17:16:39 +05:00
else {
2012-08-09 13:58:02 +06:00
GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
2009-02-13 17:16:39 +05:00
try {
2004-12-01 15:39:14 +05:00
char* aMsg;
2009-02-13 17:16:39 +05:00
bool isCheckGeometry = myGrp->CheckBox1->isChecked();
if ( isCheckGeometry )
2012-08-09 13:58:02 +06:00
theIsValid = anOper->CheckShapeWithGeometry( myObj, aMsg );
else
2012-08-09 13:58:02 +06:00
theIsValid = anOper->CheckShape( myObj, aMsg );
2004-12-01 15:39:14 +05:00
theMsg = aMsg;
}
2009-02-13 17:16:39 +05:00
catch( const SALOME::SALOME_Exception& e ) {
SalomeApp_Tools::QtCatchCorbaException( e );
2004-12-01 15:39:14 +05:00
return false;
}
2012-08-09 13:58:02 +06:00
return anOper->IsDone();
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
}
//=================================================================================
2004-12-01 15:39:14 +05:00
// function : processObject
2004-01-07 20:46:21 +05:00
// purpose :
//=================================================================================
2004-12-01 15:39:14 +05:00
void MeasureGUI_CheckShapeDlg::processObject()
2004-01-07 20:46:21 +05:00
{
2004-12-01 15:39:14 +05:00
bool isShapeValid;
QString aMsg;
2009-02-13 17:16:39 +05:00
if ( !getParameters( isShapeValid, aMsg ) ) {
myGrp->TextView1->setText( "" );
2004-01-07 20:46:21 +05:00
return;
}
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
if ( isShapeValid ) {
myGrp->TextView1->setText( "This Shape seems to be valid." );
}
else {
QString aDescr ( "This Shape is not valid.\n" );
2004-12-01 15:39:14 +05:00
aDescr += aMsg;
2009-02-13 17:16:39 +05:00
myGrp->TextView1->setText( aDescr );
// myGrp->TextView1->setText("This Shape is not valid.");
2004-01-07 20:46:21 +05:00
}
}