-// SMESH SMESHGUI : GUI for SMESH component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 CEA
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// 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
-// version 2.1 of the License.
+// 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
+// version 2.1 of the License.
//
-// 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.
+// 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.
//
-// 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
+// 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
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_Hypotheses.cxx
// Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
-//
-
// SMESH includes
+//
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI.h"
#include <utilities.h>
// SALOME GUI includes
-#include <QtxIntSpinBox.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <LightApp_Application.h>
+#include <SalomeApp_IntSpinBox.h>
// Qt includes
#include <QFrame>
{
}
+void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr hyp)
+{
+ if ( !CORBA::is_nil( hyp ) && hypType() == hyp->GetName() )
+ myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
+}
+
void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
const QString& theHypName,
QWidget* parent)
{
MESSAGE( "Creation of hypothesis with initial params" );
-
- if ( !CORBA::is_nil( initParamsHyp ) && hypType() == initParamsHyp->GetName() )
- myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( initParamsHyp );
+ setInitParamsHypothesis( initParamsHyp );
create( false, theHypName, parent );
}
{
case QVariant::Int:
{
- QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1 );
+ SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
sb->setObjectName( (*anIt).myName );
attuneStdWidget( sb, i );
sb->setValue( (*anIt).myValue.toInt() );
break;
case QVariant::Double:
{
- QtxDoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
+ SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
sb->setObjectName( (*anIt).myName );
attuneStdWidget( sb, i );
sb->setValue( (*anIt).myValue.toDouble() );
break;
case QVariant::String:
{
- QLineEdit* le = new QLineEdit( GroupC1 );
- le->setObjectName( (*anIt).myName );
- attuneStdWidget( le, i );
- le->setText( (*anIt).myValue.toString() );
- connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
- w = le;
+ if((*anIt).isVariable) {
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ QString aVar = (*anIt).myValue.toString();
+ if(aStudy->IsInteger(aVar.toLatin1().constData())){
+ SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
+ sb->setObjectName( (*anIt).myName );
+ attuneStdWidget( sb, i );
+ sb->setText( aVar );
+ connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
+ w = sb;
+ }
+ else if(aStudy->IsReal(aVar.toLatin1().constData())){
+ SalomeApp_DoubleSpinBox* sb = new SalomeApp_DoubleSpinBox( GroupC1 );
+ sb->setObjectName( (*anIt).myName );
+ attuneStdWidget( sb, i );
+ sb->setText( aVar );
+ connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
+ w = sb;
+ }
+ }
+ else {
+ QLineEdit* le = new QLineEdit( GroupC1 );
+ le->setObjectName( (*anIt).myName );
+ attuneStdWidget( le, i );
+ le->setText( (*anIt).myValue.toString() );
+ connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
+ w = le;
+ }
}
break;
}
}
void SMESHGUI_GenericHypothesisCreator::onValueChanged()
+{
+ valueChanged( (QWidget*) sender() );
+}
+
+void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
{
}
for( ; anIt!=aLast; anIt++ )
{
item.myName = (*anIt)->objectName();
- if( (*anIt)->inherits( "QtxIntSpinBox" ) )
+ if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
{
- QtxIntSpinBox* sb = ( QtxIntSpinBox* )( *anIt );
+ SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
item.myValue = sb->value();
params.append( item );
}
- else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) )
+ else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
{
- QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt );
+ SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
item.myValue = sb->value();
params.append( item );
}
return res;
}
+
+QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
+{
+ QStringList aResult;
+ ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
+ for( ; anIt!=aLast; anIt++ ) {
+ if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) ) {
+ SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
+ aResult.append(sb->text());
+ }
+ else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) ) {
+ QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt );
+ aResult.append(sb->text());
+ }
+ }
+ return aResult;
+}
+
QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
{
QString valueStr = "";
return myHypo;
}
-SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis() const
+//================================================================================
+/*!
+ * \brief Return hypothesis containing initial parameters
+ * \param strictly - if true, always return myInitParamsHypo,
+ * else, return myInitParamsHypo only in creation mode and if it
+ * is non-nil
+ */
+//================================================================================
+
+SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
{
- if ( CORBA::is_nil( myInitParamsHypo ))
+ if ( strictly )
+ return myInitParamsHypo;
+ if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
return myHypo;
return myInitParamsHypo;
}
+bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
+{
+ return !CORBA::is_nil( myInitParamsHypo );
+}
+
QString SMESHGUI_GenericHypothesisCreator::hypType() const
{
return myHypType;
return false;
}
+bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
+{
+ bool ok = true;
+ ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
+ {
+ SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
+ ok = sb->isValid( msg, true ) && ok;
+ }
+ else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
+ {
+ SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
+ ok = sb->isValid( msg, true ) && ok;
+ }
+ }
+ return ok;
+}
+
void SMESHGUI_GenericHypothesisCreator::onReject()
{
}
+QString SMESHGUI_GenericHypothesisCreator::helpPage() const
+{
+ QString aHypType = hypType();
+ QString aHelpFileName;
+ if ( aHypType == "LocalLength" )
+ aHelpFileName = "a1d_meshing_hypo_page.html#average_length_anchor";
+ else if ( aHypType == "Arithmetic1D")
+ aHelpFileName = "a1d_meshing_hypo_page.html#arithmetic_1d_anchor";
+ else if ( aHypType == "MaxElementArea")
+ aHelpFileName = "a2d_meshing_hypo_page.html#max_element_area_anchor";
+ else if ( aHypType == "MaxElementVolume")
+ aHelpFileName = "max_element_volume_hypo_page.html";
+ else if ( aHypType == "StartEndLength")
+ aHelpFileName = "a1d_meshing_hypo_page.html#start_and_end_length_anchor";
+ else if ( aHypType == "Deflection1D")
+ aHelpFileName = "a1d_meshing_hypo_page.html#deflection_1d_anchor";
+ else if ( aHypType == "AutomaticLength")
+ aHelpFileName = "a1d_meshing_hypo_page.html#automatic_length_anchor";
+ else if ( aHypType == "NumberOfSegments")
+ aHelpFileName = "a1d_meshing_hypo_page.html#number_of_segments_anchor";
+ else if ( aHypType == "ProjectionSource1D")
+ aHelpFileName = "projection_algos_page.html";
+ else if ( aHypType == "ProjectionSource2D")
+ aHelpFileName = "projection_algos_page.html";
+ else if ( aHypType == "ProjectionSource3D")
+ aHelpFileName = "projection_algos_page.html";
+ else if ( aHypType == "NumberOfLayers")
+ aHelpFileName = "radial_prism_algo_page.html";
+ else if ( aHypType == "LayerDistribution")
+ aHelpFileName = "radial_prism_algo_page.html";
+ else if ( aHypType == "SegmentLengthAroundVertex")
+ aHelpFileName = "segments_around_vertex_algo.html";
+ else
+ aHelpFileName = "";
+ return aHelpFileName;
+}
+
topLayout->addWidget( titFrame, 0 );
- QString aHypType = creator->hypType();
- if ( aHypType == "LocalLength" )
- myHelpFileName = "a1d_meshing_hypo_page.html#average_length_anchor";
- else if ( aHypType == "Arithmetic1D")
- myHelpFileName = "a1d_meshing_hypo_page.html#arithmetic_1d_anchor";
- else if ( aHypType == "MaxElementArea")
- myHelpFileName = "a2d_meshing_hypo_page.html#max_element_area_anchor";
- else if ( aHypType == "MaxElementVolume")
- myHelpFileName = "max_element_volume_hypo_page.html";
- else if ( aHypType == "StartEndLength")
- myHelpFileName = "a1d_meshing_hypo_page.html#start_and_end_length_anchor";
- else if ( aHypType == "Deflection1D")
- myHelpFileName = "a1d_meshing_hypo_page.html#deflection_1d_anchor";
- else if ( aHypType == "AutomaticLength")
- myHelpFileName = "a1d_meshing_hypo_page.html#automatic_length_anchor";
- else if ( aHypType == "NumberOfSegments")
- myHelpFileName = "a1d_meshing_hypo_page.html#number_of_segments_anchor";
- else
- myHelpFileName = "";
+ myHelpFileName = creator->helpPage();
connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
}
void SMESHGUI_HypothesisDlg::accept()
{
- if ( myCreator && !myCreator->checkParams() )
+ QString msg;
+ if ( myCreator && !myCreator->checkParams( msg ) )
+ {
+ QString str( tr( "SMESH_INCORRECT_INPUT" ) );
+ if ( !msg.isEmpty() )
+ str += "\n" + msg;
+ SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
return;
+ }
QtxDialog::accept();
}
const QStringList& theOptionalHypos,
const QStringList& theInputTypes,
const QStringList& theOutputTypes,
- const bool theIsNeedGeometry )
+ const bool theIsNeedGeometry,
+ const bool supportSub)
: TypeName( theTypeName ),
PluginName( thePluginName ),
ServerLibName( theServerLibName ),
OptionalHypos( theOptionalHypos ),
InputTypes( theInputTypes ),
OutputTypes( theOutputTypes ),
- IsNeedGeometry( theIsNeedGeometry )
+ IsNeedGeometry( theIsNeedGeometry ),
+ IsSupportSubmeshes( supportSub )
{
}