*/
interface StdMeshers_NumberOfSegments : SMESH::SMESH_Hypothesis
{
+ /*!
+ * Builds and returns point distribution according to passed density function
+ */
+ SMESH::double_array BuildDistributionExpr( in string func, in long nbSeg, in long conv )
+ raises (SALOME::SALOME_Exception);
+ SMESH::double_array BuildDistributionTab( in SMESH::double_array func, in long nbSeg, in long conv )
+ raises (SALOME::SALOME_Exception);
+
/*!
* Sets <number of segments> parameter value
*/
raises (SALOME::SALOME_Exception);
/*!
- * Sets <exponent mode> parameter value for functional distributions
+ * Sets <conversion mode> parameter value for functional distributions
*/
- void SetExponentMode(in boolean isExponent)
+ void SetConversionMode(in long conv )
raises (SALOME::SALOME_Exception);
/*!
- * Returns <exponent mode> parameter value for functional distributions
+ * Returns <conversion mode> parameter value for functional distributions
*/
- boolean IsExponentMode()
+ long ConversionMode()
raises (SALOME::SALOME_Exception);
};
SMESHGUI_Hypotheses.h \
SMESHGUI_HypothesesUtils.h \
SMESHGUI_SpinBox.h \
- SMESHGUI_aParameter.h \
- SMESHGUI_aParameterDlg.h \
- SMESHGUI_Selection.h \
- SMESHGUI_FunctionPreview.h
+ SMESHGUI_Selection.h
# .po files to transform in .qm
PO_FILES = \
SMESHGUI_Preferences_ColorDlg.cxx \
SMESHGUI_Preferences_ScalarBarDlg.cxx \
SMESHGUI_Preferences_SelectionDlg.cxx \
- SMESHGUI_aParameterDlg.cxx \
SMESHGUI_Swig.cxx \
SMESHGUI_MoveNodesDlg.cxx \
SMESHGUI_AddMeshElementDlg.cxx \
SMESHGUI_FilterLibraryDlg.cxx \
SMESHGUI_SingleEditDlg.cxx \
SMESHGUI_MultiEditDlg.cxx \
- SMESHGUI_aParameter.cxx \
SMESHGUI_DeleteGroupDlg.cxx \
SMESHGUI_GroupOpDlg.cxx \
SMESHGUI_SmoothingDlg.cxx \
SMESHGUI_MeshDlg.cxx \
SMESHGUI_MeshOp.cxx \
SMESHGUI_Displayer.cxx \
- SMESHGUI_FunctionPreview.cxx
+ SMESHGUI_Hypotheses.cxx
LIB_MOC = \
SMESHGUI.h \
SMESHGUI_Preferences_ColorDlg.h \
SMESHGUI_Preferences_ScalarBarDlg.h \
SMESHGUI_Preferences_SelectionDlg.h \
- SMESHGUI_aParameterDlg.h \
SMESHGUI_MoveNodesDlg.h \
SMESHGUI_AddMeshElementDlg.h \
SMESHGUI_EditHypothesesDlg.h \
SMESHGUI_SewingDlg.h \
SMESHGUI_PrecisionDlg.h \
SMESHGUI_MergeNodesDlg.h \
- SMESHGUI_aParameter.h \
SMESHGUI_EditMeshDlg.h \
SMESHGUI_CreatePolyhedralVolumeDlg.h \
SMESHGUI_Operation.h \
SMESHGUI_Dialog.h \
SMESHGUI_MeshDlg.h \
SMESHGUI_MeshOp.h \
- SMESHGUI_FunctionPreview.h
+ SMESHGUI_Hypotheses.h
LIB_CLIENT_IDL = SALOME_Exception.idl \
CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \
-I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
- -I${GEOM_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) $(QWT_INCLUDES)
+ -I${GEOM_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome
-
LDFLAGS += -lSMESHObject -lSMESHFiltersSelection -lSMDS -lSMESHControls -lDlgRef \
$(OCC_KERNEL_LIBS) -lTKBO -lTKAdvTools -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome \
-lVTKViewer -lSalomeApp -lSalomePrs -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject \
-lEvent -lSALOMELocalTrace -lSVTK -lOCCViewer -L${GEOM_ROOT_DIR}/lib/salome -lGEOM -lGEOMClient \
- -lGEOMBase -lGEOMObject -lGEOMFiltersSelection $(QWT_LIBS)
+ -lGEOMBase -lGEOMObject -lGEOMFiltersSelection
LDFLAGSFORBIN += $(LDFLAGS)
char* sName = Hyp->GetName();
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
if (aCreator)
- {
- aCreator->EditHypothesis(Hyp);
- }
+ aCreator->edit( Hyp.in(), desktop() );
else
{
// report error
SMESHGUI_GenericHypothesisCreator* aCreator =
SMESH::GetHypothesisCreator(sHypType);
- // Create hypothesis/algorithm
- aCreator->CreateHypothesis(myIsAlgo, this);
+ if( aCreator )
+ // Create hypothesis/algorithm
+ aCreator->create( myIsAlgo, this );
+ else
+ {
+ // report about error
+ }
}
// buttonApply->setEnabled(FALSE);
+++ /dev/null
-// Copyright (C) 2005 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 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
-//
-// See http://www.salome-platform.org/
-//
-
-#include "SMESHGUI_FunctionPreview.h"
-#include <Expr_NamedUnknown.hxx>
-#include <Expr_GeneralExpression.hxx>
-#include <CASCatch_CatchSignals.hxx>
-#include <CASCatch_Failure.hxx>
-#include <CASCatch_ErrorHandler.hxx>
-#include <OSD.hxx>
-
-SMESHGUI_FunctionPreview::SMESHGUI_FunctionPreview( QWidget* p )
-: QwtPlot( p ),
- myXmin( 0.0 ),
- myXmax( 1.0 ),
- myPoints( 50 ),
- myIsTable( false ),
- myVars( 1, 1 ),
- myValues( 1, 1 ),
- myIsExp( false ),
- myIsDone( true )
-{
- myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" );
- myCurve = insertCurve( QString() );
- setCurvePen( myCurve, QPen( Qt::red, 1 ) );
-}
-
-SMESHGUI_FunctionPreview::~SMESHGUI_FunctionPreview()
-{
-}
-
-bool SMESHGUI_FunctionPreview::isTableFunc() const
-{
- return myIsTable;
-}
-
-void SMESHGUI_FunctionPreview::tableFunc( SMESH::double_array& f ) const
-{
- f = myTableFunc;
-}
-
-QString SMESHGUI_FunctionPreview::function() const
-{
- return myFunction;
-}
-
-void SMESHGUI_FunctionPreview::interval( double& xmin, double& xmax ) const
-{
- xmin = myXmin;
- xmax = myXmax;
-}
-
-int SMESHGUI_FunctionPreview::pointsCount() const
-{
- return myPoints;
-}
-
-void SMESHGUI_FunctionPreview::setIsExp( const bool exp, const bool update )
-{
- myIsExp = exp;
- if( update )
- repaint();
-}
-
-bool SMESHGUI_FunctionPreview::setParams( const QString& func,
- const double xmin, const double xmax,
- const int points, const bool update )
-{
- myIsTable = false;
- myTableFunc = SMESH::double_array();
- myFunction = func.isEmpty() ? "0" : func;
- myXmin = xmin;
- myXmax = xmax<myXmin ? myXmax : xmax;
- myPoints = points>0 ? points : 2;
- bool res = init( func );
- if( update )
- repaint();
- return res;
-}
-
-bool SMESHGUI_FunctionPreview::setParams( const SMESH::double_array& f, const double xmin, const double xmax,
- const bool update )
-{
- myIsTable = true;
- myTableFunc = f;
- if( myTableFunc.length()%2==1 )
- myTableFunc.length( myTableFunc.length()-1 );
-
- myFunction = "0";
- myXmin = xmin;
- myXmax = xmax<myXmin ? myXmax : xmax;
- myPoints = myTableFunc.length()/2;
-
- if( update )
- repaint();
-
- return myTableFunc.length()>0;
-}
-
-bool SMESHGUI_FunctionPreview::createTable( SMESH::double_array& func )
-{
- if( myExpr.IsNull() )
- {
- func.length( 0 );
- return false;
- }
-
- double d = (myXmax-myXmin)/double(myPoints-1);
- func.length( 2*myPoints );
- int err = 0;
- for( int i=0, j=0; i<myPoints; j++ )
- {
- bool ok;
- double t = myXmin + d*j, f = funcValue( t, ok );
- if( ok )
- {
- func[2*i] = t;
- func[2*i+1] = f;
- i++;
- }
- else
- err++;
- }
- func.length( func.length()-2*err );
- return err==0;
-}
-
-void SMESHGUI_FunctionPreview::drawContents( QPainter* p )
-{
- SMESH::double_array f;
- if( isTableFunc() )
- {
- myIsDone = true;
- f = myTableFunc;
- }
- else
- myIsDone = createTable( f );
-
- int size = f.length()/2;
- if( size==0 )
- {
- setAxisScale( curveXAxis( myCurve ), 0.0, 0.0 );
- setAxisScale( curveYAxis( myCurve ), 0.0, 0.0 );
- setCurveData( myCurve, 0, 0, 0 );
- replot();
- QwtPlot::drawContents( p );
- return;
- }
-
- double* x = new double[size], *y = new double[size];
- double min_x, max_x, min_y, max_y;
- for( int i=0; i<size; i++ )
- {
- x[i] = f[2*i];
- y[i] = myIsExp ? pow( 10.0, f[2*i+1] ) : f[2*i+1];
- if( i==0 || y[i]<min_y )
- min_y = y[i];
- if( i==0 || y[i]>max_y )
- max_y = y[i];
- if( i==0 || x[i]<min_x )
- min_x = x[i];
- if( i==0 || x[i]>max_x )
- max_x = x[i];
- }
-
- setAxisScale( curveXAxis( myCurve ), min_x, max_x );
- setAxisScale( curveYAxis( myCurve ), min_y, max_y );
- setCurveData( myCurve, x, y, size );
- delete[] x;
- delete[] y;
-
- replot();
- QwtPlot::drawContents( p );
-}
-
-bool isCorrectArg( const Handle( Expr_GeneralExpression )& expr )
-{
- Handle( Expr_NamedUnknown ) sub = Handle( Expr_NamedUnknown )::DownCast( expr );
- if( !sub.IsNull() )
- return sub->GetName()=="t";
-
- bool res = true;
- for( int i=1, n=expr->NbSubExpressions(); i<=n && res; i++ )
- {
- Handle( Expr_GeneralExpression ) sub = expr->SubExpression( i );
- Handle( Expr_NamedUnknown ) name = Handle( Expr_NamedUnknown )::DownCast( sub );
- if( !name.IsNull() )
- {
- if( name->GetName()!="t" )
- res = false;
- }
- else
- res = isCorrectArg( sub );
- }
- return res;
-}
-
-bool SMESHGUI_FunctionPreview::init( const QString& str )
-{
- myExpr = ExprIntrp_GenExp::Create();
- myExpr->Process( ( Standard_CString ) str.latin1() );
-
- bool syntax = false, args = false;
- if( myExpr->IsDone() )
- {
- syntax = true;
- args = isCorrectArg( myExpr->Expression() );
- }
-
- bool res = syntax && args;
- if( !res )
- myExpr.Nullify();
- return res;
-}
-
-double SMESHGUI_FunctionPreview::funcValue( const double t, bool& ok )
-{
- if( myExpr.IsNull() )
- return 0;
-
- myValues.ChangeValue( 1 ) = t;
-
- ok = true;
- double res = calc( ok );
-
- return res;
-}
-
-double SMESHGUI_FunctionPreview::calc( bool& ok )
-{
- OSD::SetSignal( true );
- double res = 0.0;
-
- CASCatch_CatchSignals aCatchSignals;
- aCatchSignals.Activate();
-
- ok = true;
- CASCatch_TRY {
- res = myExpr->Expression()->Evaluate( myVars, myValues );
- }
- CASCatch_CATCH(CASCatch_Failure) {
- aCatchSignals.Deactivate();
- Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
- ok = false;
- res = 0.0;
- }
- aCatchSignals.Deactivate();
- return res;
-}
-
-bool SMESHGUI_FunctionPreview::isDone() const
-{
- return myIsDone;
-}
+++ /dev/null
-// Copyright (C) 2005 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 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
-//
-// See http://www.salome-platform.org/
-//
-
-#ifndef SMESHGUI_FUNCTION_PREVIEW_HEADER
-#define SMESHGUI_FUNCTION_PREVIEW_HEADER
-
-#include "qwt_plot.h"
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-#include <ExprIntrp_GenExp.hxx>
-#include <Expr_Array1OfNamedUnknown.hxx>
-#include <TColStd_Array1OfReal.hxx>
-
-class SMESHGUI_FunctionPreview : public QwtPlot
-{
- Q_OBJECT
-
-public:
- SMESHGUI_FunctionPreview( QWidget* );
- virtual ~SMESHGUI_FunctionPreview();
-
- QString function() const;
- bool isTableFunc() const;
- void tableFunc( SMESH::double_array& ) const;
- void interval( double&, double& ) const;
- int pointsCount() const;
- bool isDone() const;
-
- bool setParams( const QString&, const double = 0.0, const double = 1.0, const int = 50, const bool = true );
- bool setParams( const SMESH::double_array&, const double = 0.0, const double = 1.0, const bool = true );
- void setIsExp( const bool, const bool = true );
-
-protected:
- virtual bool init( const QString& );
- virtual double funcValue( const double, bool& );
- virtual bool createTable( SMESH::double_array& );
- virtual void drawContents( QPainter* );
-
-private:
- double calc( bool& );
-
-private:
- QString myFunction;
- double myXmin, myXmax;
- int myPoints;
- bool myIsTable;
- bool myIsExp;
- SMESH::double_array myTableFunc;
- long myCurve;
- Handle(ExprIntrp_GenExp) myExpr;
- Expr_Array1OfNamedUnknown myVars;
- TColStd_Array1OfReal myValues;
- bool myIsDone;
-};
-
-#endif
--- /dev/null
+
+#include "SMESHGUI_Hypotheses.h"
+#include "SMESHGUI.h"
+#include "SMESHGUI_HypothesesUtils.h"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_SpinBox.h"
+
+#include <SALOMEDSClient_Study.hxx>
+#include <utilities.h>
+
+#include <QtxIntSpinBox.h>
+
+#include <qframe.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qpixmap.h>
+#include <qgroupbox.h>
+
+SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& aHypType )
+: myHypType( aHypType ),
+ myIsCreate( false )
+{
+}
+
+SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
+{
+}
+
+void SMESHGUI_GenericHypothesisCreator::create( const bool isAlgo, QWidget* parent )
+{
+ MESSAGE( "Creation of hypothesis" );
+
+ // Get default name for hypothesis/algorithm creation
+ HypothesisData* aHypData = SMESH::GetHypothesisData( hypType().latin1() );
+ QString aHypName = aHypData ? aHypData->Label : hypType();
+
+ myIsCreate = true;
+
+ // Create hypothesis/algorithm
+ if (isAlgo)
+ SMESH::CreateHypothesis( hypType(), aHypName, isAlgo );
+
+ else
+ {
+ SMESH::SMESH_Hypothesis_var newHypo = SMESH::SMESH_Hypothesis::_narrow
+ ( SMESH::CreateHypothesis( hypType(), aHypName, false ) );
+
+ if( !editHypothesis( newHypo.in(), parent ) )
+ { //remove just created hypothesis
+ _PTR(SObject) SHyp = SMESH::FindSObject( newHypo.in() );
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ if( aStudy && !aStudy->GetProperties()->IsLocked() )
+ {
+ _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+ aBuilder->RemoveObjectWithChildren( SHyp );
+ }
+ }
+ }
+ SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
+}
+
+void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr h, QWidget* parent )
+{
+ if( CORBA::is_nil( h ) )
+ return;
+
+ MESSAGE("Edition of hypothesis");
+
+ myIsCreate = false;
+
+ if( !editHypothesis( h, parent ) )
+ return;
+
+ SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( h );
+ if( listSOmesh.size() > 0 )
+ for( int i=0; i<listSOmesh.size(); i++ )
+ {
+ _PTR(SObject) submSO = listSOmesh[i];
+ SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
+ SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
+ if( !aSubMesh->_is_nil() )
+ aMesh = aSubMesh->GetFather();
+ _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
+ SMESH::ModifiedMesh( meshSO, false);
+ }
+ SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
+}
+
+bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h, QWidget* parent )
+{
+ if( CORBA::is_nil( h ) )
+ return false;
+
+ bool res = true;
+ myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
+ QFrame* fr = buildFrame();
+ if( fr )
+ {
+ SMESHGUI_HypothesisDlg* dlg =
+ new SMESHGUI_HypothesisDlg( const_cast<SMESHGUI_GenericHypothesisCreator*>( this ), parent );
+ dlg->setCustomFrame( fr );
+ dlg->setCaption( caption() );
+ dlg->setHIcon( icon() );
+ dlg->setType( type() );
+ retrieveParams();
+ res = dlg->exec()==QDialog::Accepted;
+ if( res )
+ storeParams();
+ delete dlg;
+ }
+ changeWidgets().clear();
+ myHypo = SMESH::SMESH_Hypothesis::_nil();
+ return res;
+}
+
+QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
+{
+ if( CORBA::is_nil( hypothesis() ) )
+ return 0;
+
+ ListOfStdParams params;
+ if( !stdParams( params ) || params.isEmpty() )
+ return 0;
+
+ QFrame* fr = new QFrame( 0, "myframe" );
+ QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 );
+
+ QGroupBox* GroupC1 = new QGroupBox( fr, "GroupC1" );
+ lay->addWidget( GroupC1 );
+
+ GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
+ GroupC1->setColumnLayout(0, Qt::Vertical );
+ GroupC1->layout()->setSpacing( 0 );
+ GroupC1->layout()->setMargin( 0 );
+ QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
+ GroupC1Layout->setAlignment( Qt::AlignTop );
+ GroupC1Layout->setSpacing( 6 );
+ GroupC1Layout->setMargin( 11 );
+
+ ListOfStdParams::const_iterator anIt = params.begin(), aLast = params.end();
+ for( int i=0; anIt!=aLast; anIt++, i++ )
+ {
+ QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
+ GroupC1Layout->addWidget( lab, i, 0 );
+
+ QWidget* w = 0;
+ switch( (*anIt).myValue.type() )
+ {
+ case QVariant::Int:
+ {
+ QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
+ attuneStdWidget( sb, i );
+ sb->setValue( (*anIt).myValue.toInt() );
+ connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
+ w = sb;
+ }
+ break;
+ case QVariant::Double:
+ {
+ QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
+ attuneStdWidget( sb, i );
+ sb->setValue( (*anIt).myValue.toDouble() );
+ connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
+ w = sb;
+ }
+ break;
+ case QVariant::String:
+ {
+ QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
+ attuneStdWidget( le, i );
+ le->setText( (*anIt).myValue.toString() );
+ connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
+ w = le;
+ }
+ break;
+ }
+
+ if( w )
+ {
+ GroupC1Layout->addWidget( w, i, 1 );
+ changeWidgets().append( w );
+ }
+ }
+
+ return fr;
+}
+
+void SMESHGUI_GenericHypothesisCreator::onValueChanged()
+{
+}
+
+bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
+{
+ return false;
+}
+
+bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
+{
+ bool res = true;
+ StdParam item;
+ ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ item.myName = (*anIt)->name();
+ if( (*anIt)->inherits( "QtxIntSpinBox" ) )
+ {
+ QtxIntSpinBox* sb = ( QtxIntSpinBox* )( *anIt );
+ item.myValue = sb->value();
+ params.append( item );
+ }
+
+ else if( (*anIt)->inherits( "QtxDblSpinBox" ) )
+ {
+ QtxDblSpinBox* sb = ( QtxDblSpinBox* )( *anIt );
+ item.myValue = sb->value();
+ params.append( item );
+ }
+
+ else if( (*anIt)->inherits( "QLineEdit" ) )
+ {
+ QLineEdit* line = ( QLineEdit* )( *anIt );
+ item.myValue = line->text();
+ params.append( item );
+ }
+
+ else
+ res = false;
+ }
+ return res;
+}
+
+SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
+{
+ return myHypo;
+}
+
+QString SMESHGUI_GenericHypothesisCreator::hypType() const
+{
+ return myHypType;
+}
+
+const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
+{
+ return myParamWidgets;
+}
+
+SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
+{
+ return myParamWidgets;
+}
+
+bool SMESHGUI_GenericHypothesisCreator::isCreation() const
+{
+ return myIsCreate;
+}
+
+void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
+{
+}
+
+QString SMESHGUI_GenericHypothesisCreator::caption() const
+{
+ return QString();
+}
+
+QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
+{
+ return QPixmap();
+}
+
+QString SMESHGUI_GenericHypothesisCreator::type() const
+{
+ return QString();
+}
+
+
+
+
+
+
+
+
+SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
+: QtxDialog( parent, "", true, true, QtxDialog::OKCancel ),
+ myCreator( creator )
+{
+ setMinimumSize( 300, height() );
+// setFixedSize( 300, height() );
+ myLayout = new QVBoxLayout( mainFrame(), 0, 0 );
+
+ QFrame* titFrame = new QFrame( mainFrame() );
+ QHBoxLayout* titLay = new QHBoxLayout( titFrame, 0, 5 );
+
+ myIconLabel = new QLabel( titFrame );
+ myIconLabel->setScaledContents( false );
+ myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
+ myTypeLabel = new QLabel( titFrame );
+ if( creator )
+ myTypeLabel->setText( creator->hypType() );
+
+ titLay->addWidget( myIconLabel, 0 );
+ titLay->addWidget( myTypeLabel, 0 );
+ titLay->addStretch( 1 );
+
+ myLayout->addWidget( titFrame, 0 );
+}
+
+SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
+{
+}
+
+void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
+{
+ if( f )
+ {
+ f->reparent( mainFrame(), QPoint( 0, 0 ) );
+ myLayout->insertWidget( 1, f, 1 );
+ }
+}
+
+void SMESHGUI_HypothesisDlg::accept()
+{
+ if( !myCreator || myCreator->checkParams() )
+ QtxDialog::accept();
+}
+
+void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
+{
+ myIconLabel->setPixmap( p );
+}
+
+void SMESHGUI_HypothesisDlg::setType( const QString& t )
+{
+ myTypeLabel->setText( t );
+}
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
-// QT Includes
-#include <qstring.h>
-#include <qwidget.h>
-#include <qvaluevector.h>
-#include <qstringlist.h>
+#include <QtxDialog.h>
+#include <qvariant.h>
+
+class QVBoxLayout;
+class QPixmap;
/*!
* \brief Auxiliary class for creation of hypotheses
*/
-class SMESHGUI_GenericHypothesisCreator
+class SMESHGUI_GenericHypothesisCreator : public QObject
{
- public:
- virtual void CreateHypothesis (const bool isAlgo, QWidget* parent) = 0;
- virtual void EditHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp) = 0;
+ Q_OBJECT
+
+public:
+ SMESHGUI_GenericHypothesisCreator( const QString& );
+ virtual ~SMESHGUI_GenericHypothesisCreator();
+
+ void create( const bool isAlgo, QWidget* );
+ void edit( SMESH::SMESH_Hypothesis_ptr, QWidget* );
+ virtual bool checkParams() const = 0;
+
+ QString hypType() const;
+ bool isCreation() const;
+
+protected:
+ typedef struct
+ {
+ QString myName;
+ QVariant myValue;
+
+ } StdParam;
+
+ typedef QValueList<StdParam> ListOfStdParams;
+ typedef QPtrList<QWidget> ListOfWidgets;
+
+ SMESH::SMESH_Hypothesis_var hypothesis() const;
+ const ListOfWidgets& widgets() const;
+ ListOfWidgets& changeWidgets();
+
+ virtual QFrame* buildFrame () = 0;
+ QFrame* buildStdFrame ();
+ virtual void retrieveParams() const = 0;
+ virtual void storeParams () const = 0;
+ virtual bool stdParams ( ListOfStdParams& ) const;
+ bool getStdParamFromDlg( ListOfStdParams& ) const;
+ virtual void attuneStdWidget( QWidget*, const int ) const;
+ virtual QString caption() const;
+ virtual QPixmap icon() const;
+ virtual QString type() const;
+
+protected slots:
+ virtual void onValueChanged();
+
+private:
+ bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, QWidget* );
+
+private:
+ SMESH::SMESH_Hypothesis_var myHypo;
+ QString myHypType;
+ ListOfWidgets myParamWidgets;
+ bool myIsCreate;
+};
+
+class SMESHGUI_HypothesisDlg : public QtxDialog
+{
+ Q_OBJECT
+
+public:
+ SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
+ virtual ~SMESHGUI_HypothesisDlg();
+
+ void setHIcon( const QPixmap& );
+ void setCustomFrame( QFrame* );
+ void setType( const QString& );
+
+protected slots:
+ virtual void accept();
+
+private:
+ SMESHGUI_GenericHypothesisCreator* myCreator;
+ QVBoxLayout* myLayout;
+ QLabel *myIconLabel, *myTypeLabel;
};
/*!
// get method, returning hypothesis creator
if(MYDEBUG) MESSAGE("Find GetHypothesisCreator() method ...");
typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \
- (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI);
+ ( const QString& );
GetHypothesisCreator procHandle =
(GetHypothesisCreator)dlsym(libHandle, "GetHypothesisCreator");
if (!procHandle) {
else {
// get hypothesis creator
if(MYDEBUG) MESSAGE("Get Hypothesis Creator for " << aHypType);
- aCreator = procHandle(aHypType, aServerLibName, SMESHGUI::GetSMESHGUI());
+ aCreator = procHandle( aHypType );
if (!aCreator) {
if(MYDEBUG) MESSAGE("no such a hypothesis in this plugin");
}
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aHypTypeName );
// Create hypothesis
- aCreator->CreateHypothesis( false, myDlg );
+ if( aCreator )
+ aCreator->create( false, myDlg );
}
QStringList aNewHyps;
char* aTypeName = aHyp->GetName();
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aTypeName );
if ( aCreator )
- aCreator->EditHypothesis( aHyp );
+ aCreator->edit( aHyp.in(), dlg() );
}
//================================================================================
SMESHGUI_GenericHypothesisCreator* aCreator =
SMESH::GetHypothesisCreator( aHypName );
if ( aCreator )
- aCreator->CreateHypothesis( true, myDlg );
+ aCreator->create( true, myDlg );
}
QStringList tmpList;
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
+++ /dev/null
-// SMESH SMESHGUI : GUI for SMESH component
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : SMESHGUI_aParameter.cxx
-// Module : SMESH
-// $Header$
-
-#include "SMESHGUI_aParameter.h"
-
-#include <qspinbox.h>
-#include <qvalidator.h>
-#include <qlineedit.h>
-#include <qtextedit.h>
-#include <qcombobox.h>
-#include <qcheckbox.h>
-#include <qtable.h>
-#include <qvalidator.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-
-#include <QtxDblSpinBox.h>
-
-SMESHGUI_aParameter::SMESHGUI_aParameter( const QString& label, const bool preview )
-: _needPreview( preview ),
- _label(label)
-{
-}
-
-SMESHGUI_aParameter::~SMESHGUI_aParameter()
-{
-}
-
-bool SMESHGUI_aParameter::needPreview() const
-{
- return _needPreview;
-}
-
-QString& SMESHGUI_aParameter::Label()
-{
- return _label;
-}
-
-QString SMESHGUI_aParameter::sigValueChanged() const
-{
- return QString::null;
-}
-
-//=================================================================================
-// class : SMESHGUI_intParameter
-// purpose :
-//=================================================================================
-SMESHGUI_intParameter::SMESHGUI_intParameter (const int theInitValue,
- const QString& theLabel,
- const int theBottom,
- const int theTop,
- const bool preview )
- :SMESHGUI_aParameter(theLabel, preview),
- _top(theTop), _bottom(theBottom), _initValue(theInitValue),
- _newValue( theInitValue )
-{
-}
-SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const
-{
- return SMESHGUI_aParameter::INT;
-}
-bool SMESHGUI_intParameter::GetNewInt (int & theValue) const
-{
- theValue = _newValue;
- return _newValue != _initValue;
-}
-bool SMESHGUI_intParameter::GetNewDouble (double & Value) const
-{
- return false;
-}
-bool SMESHGUI_intParameter::GetNewText (QString & Value) const
-{
- return false;
-}
-
-QWidget* SMESHGUI_intParameter::CreateWidget( QWidget* parent ) const
-{
- return new QSpinBox( parent );
-}
-
-void SMESHGUI_intParameter::InitializeWidget (QWidget* theQWidget) const
-{
- QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
- if (aSpin) {
- aSpin->setMinValue(_bottom);
- aSpin->setMaxValue(_top);
- aSpin->setValue(_initValue);
- }
-}
-void SMESHGUI_intParameter::TakeValue (QWidget* theQWidget)
-{
- QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
- if (aSpin)
- _newValue = aSpin->value();
-}
-
-QString SMESHGUI_intParameter::sigValueChanged() const
-{
- return SIGNAL( valueChanged( int ) );
-}
-
-//=================================================================================
-// class : SMESHGUI_doubleParameter
-// purpose :
-//=================================================================================
-SMESHGUI_doubleParameter::SMESHGUI_doubleParameter (const double theInitValue,
- const QString& theLabel,
- const double theBottom,
- const double theTop,
- const double theStep,
- const int theDecimals,
- const bool preview )
- :SMESHGUI_aParameter(theLabel, preview),
- _top(theTop), _bottom(theBottom), _step(theStep),
- _initValue(theInitValue), _decimals(theDecimals)
-{
-}
-SMESHGUI_aParameter::Type SMESHGUI_doubleParameter::GetType() const
-{
- return SMESHGUI_aParameter::DOUBLE;
-}
-bool SMESHGUI_doubleParameter::GetNewInt (int & theValue) const
-{
- return false;
-}
-bool SMESHGUI_doubleParameter::GetNewDouble (double & Value) const
-{
- Value = _newValue;
- return _newValue != _initValue;
-}
-bool SMESHGUI_doubleParameter::GetNewText (QString & Value) const
-{
- return false;
-}
-
-QWidget* SMESHGUI_doubleParameter::CreateWidget( QWidget* parent ) const
-{
- return new QtxDblSpinBox( parent );
-}
-
-void SMESHGUI_doubleParameter::InitializeWidget (QWidget* theQWidget) const
-{
- QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
- if (aSpin) {
- aSpin->setPrecision(_decimals);
-#ifdef NEW_GUI
- aSpin->setDblPrecision(_bottom);
-#endif
- aSpin->setRange(_bottom, _top);
- aSpin->setValue(_initValue);
- aSpin->setLineStep(_step);
- }
-}
-void SMESHGUI_doubleParameter::TakeValue (QWidget* theQWidget)
-{
- QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
- if (aSpin)
- _newValue = aSpin->value();
-}
-
-QString SMESHGUI_doubleParameter::sigValueChanged() const
-{
- return SIGNAL( valueChanged( double ) );
-}
-
-//=================================================================================
-// class : SMESHGUI_strParameter
-// purpose :
-//=================================================================================
-SMESHGUI_strParameter::SMESHGUI_strParameter (const QString& theInitValue,
- const QString& theLabel,
- const bool preview )
- :SMESHGUI_aParameter(theLabel, preview),
- _initValue(theInitValue)
-{
-}
-SMESHGUI_aParameter::Type SMESHGUI_strParameter::GetType() const
-{
- return SMESHGUI_aParameter::STRING;
-}
-
-bool SMESHGUI_strParameter::GetNewInt (int & theValue) const
-{
- return false;
-}
-bool SMESHGUI_strParameter::GetNewDouble (double & Value) const
-{
- return false;
-}
-bool SMESHGUI_strParameter::GetNewText (QString & theValue) const
-{
- theValue = _newValue;
- return _newValue != _initValue;
-}
-
-QWidget* SMESHGUI_strParameter::CreateWidget( QWidget* parent ) const
-{
- return new QLineEdit( parent );
-}
-
-void SMESHGUI_strParameter::InitializeWidget (QWidget* theQWidget) const
-{
- QLineEdit* anEdit = dynamic_cast< QLineEdit* >(theQWidget);
- if (anEdit) {
- anEdit->setText(_initValue);
- }
-}
-void SMESHGUI_strParameter::TakeValue (QWidget* theQWidget)
-{
- QLineEdit* anEdit = dynamic_cast< QLineEdit* >(theQWidget);
- if (anEdit)
- _newValue = anEdit->text();
-}
-
-QString SMESHGUI_strParameter::sigValueChanged() const
-{
- return SIGNAL( textChanged( const QString& ) );
-}
-
-
-
-//=================================================================================
-// class : SMESHGUI_dependParameter
-// purpose :
-//=================================================================================
-SMESHGUI_dependParameter::SMESHGUI_dependParameter( const QString& label, const bool preview )
-: SMESHGUI_aParameter( label, preview )
-{
-}
-
-const SMESHGUI_dependParameter::ShownMap& SMESHGUI_dependParameter::shownMap() const
-{
- return myShownMap;
-}
-
-SMESHGUI_dependParameter::ShownMap& SMESHGUI_dependParameter::shownMap()
-{
- return myShownMap;
-}
-
-
-
-
-
-//=================================================================================
-// class : SMESHGUI_enumParameter
-// purpose :
-//=================================================================================
-SMESHGUI_enumParameter::SMESHGUI_enumParameter( const QStringList& values,
- const int initValue,
- const QString& label,
- const bool preview )
-: SMESHGUI_dependParameter( label, preview ),
- myInitValue( initValue ),
- myValue( initValue ),
- myValues( values )
-{
-}
-
-SMESHGUI_enumParameter::~SMESHGUI_enumParameter()
-{
-}
-
-SMESHGUI_aParameter::Type SMESHGUI_enumParameter::GetType() const
-{
- return SMESHGUI_aParameter::ENUM;
-}
-
-bool SMESHGUI_enumParameter::GetNewInt( int& v ) const
-{
- v = myValue;
- return myValue!=myInitValue;
-}
-
-bool SMESHGUI_enumParameter::GetNewDouble( double& ) const
-{
- return false;
-}
-
-bool SMESHGUI_enumParameter::GetNewText( QString& v ) const
-{
- bool res = myValue>=0 && myValue<Count();
-
- if( res )
- v = myValues[ myValue ];
-
- return res && v!=myInitValue;
-}
-
-QWidget* SMESHGUI_enumParameter::CreateWidget( QWidget* parent ) const
-{
- return new QComboBox( parent );
-}
-
-void SMESHGUI_enumParameter::InitializeWidget( QWidget* w ) const
-{
- if( w && w->inherits( "QComboBox" ) )
- {
- QComboBox* c = ( QComboBox* ) w;
- c->clear();
- c->insertStringList( myValues );
- c->setCurrentItem( myInitValue );
- }
-}
-
-void SMESHGUI_enumParameter::TakeValue( QWidget* w )
-{
- if( w && w->inherits( "QComboBox" ) )
- {
- QComboBox* c = ( QComboBox* ) w;
- myValue = c->currentItem();
- }
-}
-
-int SMESHGUI_enumParameter::Count() const
-{
- return myValues.count();
-}
-
-QString SMESHGUI_enumParameter::sigValueChanged() const
-{
- return SIGNAL( activated( int ) );
-}
-
-
-//=================================================================================
-// class : SMESHGUI_boolParameter
-// purpose :
-//=================================================================================
-SMESHGUI_boolParameter::SMESHGUI_boolParameter( const bool initValue,
- const QString& label,
- const bool preview )
-: SMESHGUI_dependParameter( label, preview ),
- myInitValue( initValue ),
- myValue( myInitValue )
-{
-}
-
-SMESHGUI_boolParameter::~SMESHGUI_boolParameter()
-{
-}
-
-SMESHGUI_aParameter::Type SMESHGUI_boolParameter::GetType() const
-{
- return BOOL;
-}
-
-bool SMESHGUI_boolParameter::GetNewInt( int& v ) const
-{
- if( myValue )
- v = 1;
- else
- v = 0;
- return v!=myInitValue;
-}
-
-bool SMESHGUI_boolParameter::GetNewDouble( double& ) const
-{
- return false;
-}
-
-bool SMESHGUI_boolParameter::GetNewText( QString& ) const
-{
- return false;
-}
-
-QWidget* SMESHGUI_boolParameter::CreateWidget( QWidget* parent ) const
-{
- return new QCheckBox( parent );
-}
-
-void SMESHGUI_boolParameter::InitializeWidget( QWidget* w ) const
-{
- if( w && w->inherits( "QCheckBox" ) )
- {
- QCheckBox* box = ( QCheckBox* )w;
- box->setChecked( myInitValue );
- }
-}
-
-void SMESHGUI_boolParameter::TakeValue( QWidget* w )
-{
- if( w && w->inherits( "QCheckBox" ) )
- {
- QCheckBox* box = ( QCheckBox* )w;
- myValue = box->isChecked();
- }
-}
-
-QString SMESHGUI_boolParameter::sigValueChanged() const
-{
- return SIGNAL( stateChanged( int ) );
-}
-
-
-
-
-//=================================================================================
-// class : SMESHGUI_doubleItem
-// purpose : Custom table item which contains double and has double validator
-//=================================================================================
-class SMESHGUI_doubleItem: public QTableItem
-{
-public:
- SMESHGUI_doubleItem( QTable*, EditType, const double );
- virtual ~SMESHGUI_doubleItem();
-
- void setValidator( const double, const double, const int );
- void validator( double&, double&, int& );
- virtual QWidget* createEditor() const;
-
-private:
- QDoubleValidator* myValidator;
-};
-
-SMESHGUI_doubleItem::SMESHGUI_doubleItem( QTable* t, EditType e, const double num )
-: QTableItem( t, e, QString( "%1" ).arg( num ) ),
- myValidator( new QDoubleValidator( 0.0, 1.0, 3, t ) )
-{
-}
-
-SMESHGUI_doubleItem::~SMESHGUI_doubleItem()
-{
-}
-
-void SMESHGUI_doubleItem::setValidator( const double bot, const double top, const int dec )
-{
- myValidator->setBottom( bot );
- myValidator->setTop( top );
- myValidator->setDecimals( dec );
-}
-
-void SMESHGUI_doubleItem::validator( double& bot, double& top, int& dec )
-{
- bot = myValidator->bottom();
- top = myValidator->top();
- dec = myValidator->decimals();
-}
-
-QWidget* SMESHGUI_doubleItem::createEditor() const
-{
- QWidget* res = QTableItem::createEditor();
- if( res && res->inherits( "QLineEdit" ) )
- {
- QLineEdit* l = ( QLineEdit* )res;
- l->setValidator( myValidator );
- }
- return res;
-}
-
-
-//=================================================================================
-// class : SMESHGUI_Table
-// purpose :
-//=================================================================================
-SMESHGUI_Table::SMESHGUI_Table( const SMESHGUI_tableParameter* tab, int numRows, int numCols,
- QWidget* parent, const char* name )
-: QTable( numRows, numCols, parent, name ),
- myParam( ( SMESHGUI_tableParameter* )tab )
-{
-}
-
-SMESHGUI_Table::~SMESHGUI_Table()
-{
-}
-
-QSize SMESHGUI_Table::sizeHint() const
-{
- if( cachedSizeHint().isValid() )
- return cachedSizeHint();
-
- constPolish();
-
- QSize sh = QScrollView::sizeHint();
- if( sh.width()<400 )
- sh.setWidth( 400 );
- if( sh.height()<200 )
- sh.setHeight( 200 );
-
- setCachedSizeHint( sh );
- return sh;
-}
-
-void SMESHGUI_Table::stopEditing()
-{
- endEdit( currEditRow(), currEditCol(), false, false );
-}
-
-void SMESHGUI_Table::validator( const int row, const int col, double& minV, double& maxV, int& dec )
-{
- SMESHGUI_doubleItem* it = dynamic_cast<SMESHGUI_doubleItem*>( item( row, col ) );
- if( it )
- it->validator( minV, maxV, dec );
-}
-
-void SMESHGUI_Table::setValidator( const double minV, const double maxV, const int dec,
- const int rmin, const int rmax,
- const int cmin, const int cmax )
-{
- int r1 = rmin>=0 ? rmin : 0,
- r2 = rmax>=0 ? rmax : numRows(),
- c1 = cmin>=0 ? cmin : 0,
- c2 = cmax>=0 ? cmax : numCols();
-
- for( int i=r1; i<=r2; i++ )
- for( int j=c1; j<=c2; j++ )
- {
- SMESHGUI_doubleItem* it = dynamic_cast<SMESHGUI_doubleItem*>( item( i, j ) );
- if( it )
- it->setValidator( minV, maxV, dec );
- }
-}
-
-bool SMESHGUI_Table::eventFilter( QObject* o, QEvent* e )
-{
- if( o && e && e->type()==QEvent::KeyPress )
- {
- QKeyEvent* ke = ( QKeyEvent* )e;
- if( ke->key()==Qt::Key_Tab || ke->key()==Qt::Key_Backtab || ke->key()==Qt::Key_Return )
- {
- keyPressEvent( ke );
- return true;
- }
- }
-
- return QTable::eventFilter( o, e );
-}
-
-void SMESHGUI_Table::keyPressEvent( QKeyEvent* e )
-{
- if( e )
- {
- bool shift = ( e->state() & Qt::ShiftButton );
- int col = currentColumn(), row = currentRow();
- if( e->key()==Qt::Key_Tab || e->key()==Qt::Key_Backtab )
- {
- if( e->key()==Qt::Key_Tab )
- col++;
- else
- col--;
- if( col<0 )
- {
- col = numCols()-1;
- row--;
- if( row<0 )
- {
- col = 0;
- row = 0;
- }
- }
- if( col>=numCols() )
- {
- col = 0;
- row++;
- if( row>=numRows() )
- row = numRows()-1;
- }
- e->accept();
- }
- else if( e->key()==Qt::Key_Return )
- {
- col = 0;
- if( shift )
- row--;
- else
- row++;
- if( row<0 )
- row = 0;
- else if( row>=numRows() )
- {
- //add row
- myParam->onEdit( this, SMESHGUI_TableFrame::ADD_ROW, 1 );
- }
- e->accept();
- }
- if( e->isAccepted() )
- {
- clearSelection();
- setCurrentCell( row, col );
- }
- else
- QTable::keyPressEvent( e );
- }
-}
-
-QWidget* SMESHGUI_Table::createEditor( int r, int c, bool init ) const
-{
- QWidget* w = QTable::createEditor( r, c, init );
- if( w )
- w->installEventFilter( this );
- return w;
-}
-
-
-
-//=================================================================================
-// class : SMESHGUI_TableFrame
-// purpose :
-//=================================================================================
-SMESHGUI_TableFrame::SMESHGUI_TableFrame( const SMESHGUI_tableParameter* param, QWidget* parent )
-: QFrame( parent )
-{
- QVBoxLayout* main = new QVBoxLayout( this, 0, 0 );
-
- myTable = new SMESHGUI_Table( param, 1, 1, this );
- connect( myTable, SIGNAL( valueChanged( int, int ) ), this, SIGNAL( valueChanged( int, int ) ) );
-
- QFrame* aButFrame = new QFrame( this );
- QHBoxLayout* butLay = new QHBoxLayout( aButFrame, 5, 5 );
-
- myAddColumn = new QPushButton( "Add column", aButFrame );
-
- myRemoveColumn = new QPushButton( "Remove column", aButFrame );
-
- myAddRow = new QPushButton( "Add row", aButFrame );
-
- myRemoveRow = new QPushButton( "Remove row", aButFrame );
-
- butLay->addWidget( myAddColumn, 0 );
- butLay->addWidget( myRemoveColumn, 0 );
- butLay->addWidget( myAddRow, 0 );
- butLay->addWidget( myRemoveRow, 0 );
- butLay->addStretch( 1 );
-
- main->addWidget( myTable, 1 );
- main->addWidget( aButFrame, 0 );
-
- connect( myAddColumn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myRemoveColumn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myAddRow, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myRemoveRow, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
-}
-
-SMESHGUI_TableFrame::~SMESHGUI_TableFrame()
-{
-}
-
-SMESHGUI_Table* SMESHGUI_TableFrame::table() const
-{
- return myTable;
-}
-
-void SMESHGUI_TableFrame::setShown( const Button b, const bool sh )
-{
- if( button( b ) )
- button( b )->setShown( sh );
-}
-
-bool SMESHGUI_TableFrame::isShown( const Button b ) const
-{
- bool res = false;
- if( button( b ) )
- res = button( b )->isShown();
- return res;
-}
-
-QButton* SMESHGUI_TableFrame::button( const Button b ) const
-{
- QButton* res = 0;
- switch( b )
- {
- case ADD_COLUMN:
- res = myAddColumn;
- break;
-
- case REMOVE_COLUMN:
- res = myRemoveColumn;
- break;
-
- case ADD_ROW:
- res = myAddRow;
- break;
-
- case REMOVE_ROW:
- res = myRemoveRow;
- break;
- }
- return res;
-}
-
-void SMESHGUI_TableFrame::onButtonClicked()
-{
- if( sender()==button( ADD_COLUMN ) )
- emit toEdit( ADD_COLUMN, table()->currentColumn() );
-
- else if( sender()==button( REMOVE_COLUMN ) )
- emit toEdit( REMOVE_COLUMN, table()->currentColumn() );
-
- else if( sender()==button( ADD_ROW ) )
- emit toEdit( ADD_ROW, table()->currentRow() );
-
- else if( sender()==button( REMOVE_ROW ) )
- emit toEdit( REMOVE_ROW, table()->currentRow() );
-}
-
-
-//=================================================================================
-// class : SMESHGUI_tableParameter
-// purpose :
-//=================================================================================
-SMESHGUI_tableParameter::SMESHGUI_tableParameter( const double init,
- const QString& label,
- const bool preview )
-: SMESHGUI_aParameter( label, preview ),
- myInitValue( init ),
- myColsInt( 1 ),
- myRowsInt( 1 ),
- myEditCols( false ),
- myEditRows( false )
-{
-}
-
-SMESHGUI_tableParameter::~SMESHGUI_tableParameter()
-{
-}
-
-bool operator<( const QPair<double,double>& p1, const QPair<double,double>& p2 )
-{
- return p1.first < p2.first;
-}
-
-void SMESHGUI_tableParameter::sortData( SMESH::double_array& arr )
-{
- QValueList< QPair<double,double> > aData;
- if( arr.length()%2==1 )
- arr.length( arr.length()-1 );
-
- int aLen = arr.length();
- for( int i=0; i<aLen/2; i++ )
- aData.append( QPair<double,double>( arr[2*i], arr[2*i+1] ) );
-
- qHeapSort( aData );
-
- QValueList< QPair<double,double> >::const_iterator anIt = aData.begin(), aLast = aData.end();
- QValueList<double> unique_values;
- double prev; int i=0;
- if( (*anIt).first>0.0 )
- {
- unique_values.append( 0.0 );
- unique_values.append( 0.0 );
- i++; prev = 0.0;
- }
- for( ; anIt!=aLast; anIt++ )
- {
- if( i==0 || (*anIt).first>prev )
- {
- unique_values.append( (*anIt).first );
- unique_values.append( (*anIt).second );
- i++;
- }
- prev = (*anIt).first;
- }
- if( prev<1.0 )
- {
- unique_values.append( 1.0 );
- unique_values.append( 0.0 );
- }
-
- arr.length( unique_values.count() );
- QValueList<double>::const_iterator anIt1 = unique_values.begin(), aLast1 = unique_values.end();
- for( int j=0; anIt1!=aLast1; anIt1++, j++ )
- arr[j] = *anIt1;
-}
-
-SMESHGUI_aParameter::Type SMESHGUI_tableParameter::GetType() const
-{
- return TABLE;
-}
-
-bool SMESHGUI_tableParameter::GetNewInt( int& ) const
-{
- return false;
-}
-
-bool SMESHGUI_tableParameter::GetNewDouble( double& ) const
-{
- return false;
-}
-
-bool SMESHGUI_tableParameter::GetNewText( QString& ) const
-{
- return false;
-}
-
-QWidget* SMESHGUI_tableParameter::CreateWidget( QWidget* par ) const
-{
- SMESHGUI_TableFrame* t = new SMESHGUI_TableFrame( this, par );
- connect( t, SIGNAL( toEdit( SMESHGUI_TableFrame::Button, int ) ),
- this, SLOT ( onEdit( SMESHGUI_TableFrame::Button, int ) ) );
-
- update( t );
- return t;
-}
-
-void SMESHGUI_tableParameter::setItems( QWidget* w,
- int old_row, int new_row,
- int old_col, int new_col ) const
-{
- if( w && w->inherits( "SMESHGUI_TableFrame" ) )
- {
- QTable* tab = ( ( SMESHGUI_TableFrame* )w )->table();
-
- if( old_row<0 )
- old_row = 0;
- if( new_row<0 )
- new_row = tab->numRows();
- if( old_col<0 )
- old_col = 0;
- if( new_col<0 )
- new_col = tab->numCols();
-
- for( int i=old_row, m=new_row; i<m; i++ )
- for( int j=0, n=new_col; j<n; j++ )
- tab->setItem( i, j, new SMESHGUI_doubleItem( tab, QTableItem::WhenCurrent, myInitValue ) );
-
- for( int i=0, m=new_row; i<m; i++ )
- for( int j=old_col, n=new_col; j<n; j++ )
- tab->setItem( i, j, new SMESHGUI_doubleItem( tab, QTableItem::WhenCurrent, myInitValue ) );
-
- for( int j=old_col; j<new_col; j++ )
- tab->setColumnWidth( j, 50 );
- }
-}
-
-void SMESHGUI_tableParameter::InitializeWidget( QWidget* w ) const
-{
- setItems( w );
-
- if( w && w->inherits( "SMESHGUI_TableFrame" ) )
- {
- SMESHGUI_Table* tab = ( ( SMESHGUI_TableFrame* )w )->table();
- tab->stopEditing();
-
- int col = tab->numCols(),
- row = tab->numRows();
-
- for( int i=0, m=row; i<m; i++ )
- for( int j=0, n=col; j<n; j++ )
- if( row*j+i<myData.length() )
- tab->item( i, j )->setText( QString( "%1" ).arg( myData[col*i+j] ) );
- }
-}
-
-void SMESHGUI_tableParameter::TakeValue( QWidget* w )
-{
- if( w && w->inherits( "SMESHGUI_TableFrame" ) )
- {
- QTable* tab = ( ( SMESHGUI_TableFrame* )w )->table();
-
- int col = tab->numCols(),
- row = tab->numRows();
-
- myData.length( col*row );
- for( int i=0; i<row; i++ )
- for( int j=0; j<col; j++ )
- myData[ col*i+j ] = tab->text( i, j ).toDouble();
- }
-}
-
-void SMESHGUI_tableParameter::data( SMESH::double_array& v ) const
-{
- v = myData;
- sortData( v );
-}
-
-void SMESHGUI_tableParameter::setData( const SMESH::double_array& d )
-{
- myData = d;
- sortData( myData );
-}
-
-void SMESHGUI_tableParameter::update( QWidget* w ) const
-{
- if( w && w->inherits( "SMESHGUI_TableFrame" ) )
- {
- SMESHGUI_TableFrame* tabfr = ( SMESHGUI_TableFrame* ) w;
- SMESHGUI_Table* tab = tabfr->table();
-
- int old_col = tab->numCols(),
- old_row = tab->numRows();
-
- int col = myColsInt, row = myRowsInt;
- if( myCols.get() )
- myCols->GetNewInt( col );
-
- if( myRows.get() )
- myRows->GetNewInt( row );
-
- if( col<=0 )
- col = 1;
- if( row<=0 )
- row = 1;
-
- if( col!=tab->numCols() )
- tab->setNumCols( col );
-
- if( row!=tab->numRows() )
- tab->setNumRows( row );
-
- tabfr->setShown( SMESHGUI_TableFrame::ADD_COLUMN, myEditCols );
- tabfr->setShown( SMESHGUI_TableFrame::REMOVE_COLUMN, myEditCols );
- tabfr->setShown( SMESHGUI_TableFrame::ADD_ROW, myEditRows );
- tabfr->setShown( SMESHGUI_TableFrame::REMOVE_ROW, myEditRows );
-
- setItems( w, old_row, row, old_col, col );
-
- QMap< int, QString >::const_iterator aNIt = myColNames.begin(),
- aNLast = myColNames.end();
- for( ; aNIt!=aNLast; aNIt++ )
- tab->horizontalHeader()->setLabel( aNIt.key(), aNIt.data() );
-
- ValidatorsMap::const_iterator anIt = myValidators.begin(),
- aLast = myValidators.end();
- for( ; anIt!=aLast; anIt++ )
- {
- int row = anIt.key(), dec;
- double minV, maxV;
- validator( row, minV, maxV, dec );
- tab->setValidator( minV, maxV, dec, -1, -1, col, col );
- }
-
- QSize s = tab->sizeHint();
- tab->resize( s.width(), s.height() );
- }
-}
-
-void SMESHGUI_tableParameter::setColCount( const int c, QWidget* w )
-{
- myColsInt = c;
- update( w );
-}
-
-void SMESHGUI_tableParameter::setRowCount( const int c, QWidget* w )
-{
- myRowsInt = c;
- update( w );
-}
-
-void SMESHGUI_tableParameter::setColCount( const SMESHGUI_aParameterPtr p, QWidget* w )
-{
- if( p.get() )
- {
- myCols = p;
- update( w );
- }
-}
-
-void SMESHGUI_tableParameter::setRowCount( const SMESHGUI_aParameterPtr p, QWidget* w )
-{
- if( p.get() )
- {
- myRows = p;
- update( w );
- }
-}
-
-QString SMESHGUI_tableParameter::sigValueChanged() const
-{
- return SIGNAL( valueChanged( int, int ) );
-}
-
-void SMESHGUI_tableParameter::setValidator( const int ind, const double minV, const double maxV, const int dec )
-{
- ValidatorInfo inf;
- inf.myMin = minV;
- inf.myMax = maxV;
- inf.myDecimals = dec;
- myValidators[ ind ] = inf;
-}
-
-void SMESHGUI_tableParameter::validator( const int ind, double& minV, double& maxV, int& dec ) const
-{
- if( myValidators.contains( ind ) )
- {
- const ValidatorInfo& inf = myValidators[ ind ];
- minV = inf.myMin;
- maxV = inf.myMax;
- dec = inf.myDecimals;
- }
-}
-
-void SMESHGUI_tableParameter::setEditCols( const bool ed )
-{
- myEditCols = ed;
-}
-
-void SMESHGUI_tableParameter::setEditRows( const bool ed )
-{
- myEditRows = ed;
-}
-
-void SMESHGUI_tableParameter::setColName( const int ind, const QString& name )
-{
- myColNames.insert( ind, name );
-}
-
-QString SMESHGUI_tableParameter::colName( const int ind ) const
-{
- if( myColNames.contains( ind ) )
- return myColNames[ ind ];
- else
- return QString::null;
-}
-
-void SMESHGUI_tableParameter::onEdit( SMESHGUI_TableFrame::Button b, int n )
-{
- if( sender() && sender()->inherits( "SMESHGUI_TableFrame" ) )
- {
- SMESHGUI_TableFrame* fr = ( SMESHGUI_TableFrame* )sender();
- SMESHGUI_Table* tab = fr->table();
- onEdit( tab, b, n );
- }
-}
-
-void SMESHGUI_tableParameter::onEdit( SMESHGUI_Table* tab, SMESHGUI_TableFrame::Button b, int n )
-{
- if( !tab )
- return;
-
- SMESHGUI_TableFrame* fr = dynamic_cast<SMESHGUI_TableFrame*>( tab->parent() );
-
- switch( b )
- {
- case SMESHGUI_TableFrame::ADD_COLUMN:
- {
- if( !myEditCols || myCols.get() )
- return;
-
- myColsInt++; update( fr );
- if( n>=0 )
- for( int i=0; i<myRowsInt; i++ )
- for( int j=myColsInt-1; j>=n; j-- )
- if( j==n )
- tab->setText( i, j, QString( "%1" ).arg( myInitValue ) );
- else
- tab->setText( i, j, tab->text( i, j-1 ) );
- break;
- }
-
- case SMESHGUI_TableFrame::REMOVE_COLUMN:
- {
- if( !myEditCols || myCols.get() || myColsInt<=1 )
- return;
-
- if( n>=0 )
- for( int i=0; i<myRowsInt; i++ )
- for( int j=n; j<myColsInt-1; j++ )
- tab->setText( i, j, tab->text( i, j+1 ) );
- myColsInt--; update( fr );
-
- break;
- }
-
- case SMESHGUI_TableFrame::ADD_ROW:
- {
- if( !myEditRows || myRows.get() )
- return;
-
- myRowsInt++; update( fr );
- if( n>=0 )
- for( int i=myRowsInt-1; i>=n; i-- )
- for( int j=0; j<myColsInt; j++ )
- if( i==n )
- tab->setText( i, j, QString( "%1" ).arg( myInitValue ) );
- else
- tab->setText( i, j, tab->text( i-1, j ) );
- break;
- }
-
- case SMESHGUI_TableFrame::REMOVE_ROW:
- {
- if( !myEditRows || myRows.get() || myRowsInt<=1 )
- return;
-
- if( n>=0 )
- for( int i=n; i<myRowsInt-1; i++ )
- for( int j=0; j<myColsInt; j++ )
- tab->setText( i, j, tab->text( i+1, j ) );
- myRowsInt--; update( fr );
-
- break;
- }
- }
-}
+++ /dev/null
-// SMESH SMESHGUI : GUI for SMESH component
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : SMESHGUI_aParameter.h
-// Module : SMESH
-// $Header$
-
-#ifndef SMESHGUI_aParameter_H
-#define SMESHGUI_aParameter_H
-
-#include <boost/shared_ptr.hpp>
-#include <qstringlist.h>
-#include <qmap.h>
-#include <qtable.h>
-
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-
-class QWidget;
-class SMESHGUI_aParameter;
-
-typedef boost::shared_ptr<SMESHGUI_aParameter> SMESHGUI_aParameterPtr;
-
-/*!
- * \brief This class is the base class of all parameters
- */
-class SMESHGUI_aParameter
-{
-public:
- typedef bool (*VALIDATION_FUNC)( SMESHGUI_aParameter* );
-
- SMESHGUI_aParameter(const QString& label, const bool = false );
- virtual ~SMESHGUI_aParameter();
-
- enum Type { INT, DOUBLE, STRING, ENUM, BOOL, TABLE };
- virtual Type GetType() const = 0;
- virtual bool GetNewInt( int & Value ) const = 0;
- virtual bool GetNewDouble( double & Value ) const = 0;
- virtual bool GetNewText( QString & Value ) const = 0;
- virtual void TakeValue( QWidget* ) = 0;
- virtual QWidget* CreateWidget( QWidget* ) const = 0;
- virtual void InitializeWidget( QWidget* ) const = 0;
-
- bool needPreview() const;
-
- /*!
- * \brief Returns string representation of signal emitted when value in corrsponding widget is changed
- */
- virtual QString sigValueChanged() const;
-
- QString & Label();
-
-private:
- QString _label;
- bool _needPreview;
-};
-
-/*!
- * \brief This class provides parameter with integer value
- */
-class SMESHGUI_intParameter: public SMESHGUI_aParameter
-{
-public:
- SMESHGUI_intParameter(const int initValue = 0,
- const QString& label = QString::null,
- const int bottom = 0,
- const int top = 1000,
- const bool = false );
- int & InitValue() { return _initValue; }
- int & Top() { return _top; }
- int & Bottom() { return _bottom; }
- virtual Type GetType() const;
- virtual bool GetNewInt( int & Value ) const;
- virtual bool GetNewDouble( double & Value ) const;
- virtual bool GetNewText( QString & Value ) const;
- virtual void TakeValue( QWidget* );
- virtual QWidget* CreateWidget( QWidget* ) const;
- virtual void InitializeWidget( QWidget* ) const;
-
- virtual QString sigValueChanged() const;
-
-private:
- int _top, _bottom;
- int _initValue, _newValue;
-};
-
-/*!
- * \brief This class provides parameter with double value
- */
-class SMESHGUI_doubleParameter: public SMESHGUI_aParameter
-{
-public:
- SMESHGUI_doubleParameter(const double initValue = 0.0,
- const QString& label = QString::null,
- const double bottom = -1E6,
- const double top = +1E6,
- const double step = 1.0,
- const int decimals = 3,
- const bool = false);
- double & InitValue() { return _initValue; }
- double & Top() { return _top; }
- double & Bottom() { return _bottom; }
- double & Step() { return _step; }
- int & Decimals() { return _decimals; }
- virtual Type GetType() const;
- virtual bool GetNewInt( int & Value ) const;
- virtual bool GetNewDouble( double & Value ) const;
- virtual bool GetNewText( QString & Value ) const;
- virtual QWidget* CreateWidget( QWidget* ) const;
- virtual void InitializeWidget( QWidget* ) const;
- virtual void TakeValue( QWidget* );
-
- virtual QString sigValueChanged() const;
-
-private:
- double _top, _bottom, _step;
- double _initValue, _newValue;
- int _decimals;
-};
-
-/*!
- * \brief This class provides parameter with string value
- */
-class SMESHGUI_strParameter: public SMESHGUI_aParameter
-{
-public:
- SMESHGUI_strParameter( const QString& initValue = "",
- const QString& label = QString::null,
- const bool = false );
- QString& InitValue() { return _initValue; }
- virtual Type GetType() const;
- virtual bool GetNewInt( int & Value ) const;
- virtual bool GetNewDouble( double & Value ) const;
- virtual bool GetNewText( QString & Value ) const;
- virtual QWidget* CreateWidget( QWidget* ) const;
- virtual void InitializeWidget( QWidget* ) const;
- virtual void TakeValue( QWidget* );
-
- virtual QString sigValueChanged() const;
-
-private:
- QString _initValue, _newValue;
-};
-
-
-/*!
- * \brief This class represents the base parameter which contains dependency of
- * shown state of other parameters on value of current
- */
-class SMESHGUI_dependParameter: public SMESHGUI_aParameter
-{
-public:
- /*!
- * \brief This map describes what parameters must be shown when this parameter has value as key
- * The list contains some indices of parameters (for example, order in some list)
- * Value is integer based 0. If map is empty, it means that there is no dependencies.
- */
- typedef QValueList< int > IntList;
- typedef QMap< int, IntList > ShownMap;
-
-public:
- SMESHGUI_dependParameter( const QString& = QString::null, const bool = false );
-
- const ShownMap& shownMap() const;
- ShownMap& shownMap();
-
-private:
- ShownMap myShownMap;
-};
-
-/*!
- * \brief This class represents parameter which can have value from fixed set
- */
-class SMESHGUI_enumParameter: public SMESHGUI_dependParameter
-{
-public:
- /*!
- * \brief Creates parameter with set of values 'values', default value 'init' and title 'label'
- * Every value can be described both by integer based 0 or by string value
- */
- SMESHGUI_enumParameter( const QStringList& values,
- const int init = 0,
- const QString& label = QString::null,
- const bool = false );
- virtual ~SMESHGUI_enumParameter();
-
- /*!
- * \brief Returns count of possible values
- */
- int Count() const;
-
- int& InitValue() { return myInitValue; }
- virtual Type GetType() const;
- virtual bool GetNewInt( int& ) const;
- virtual bool GetNewDouble( double& ) const;
- virtual bool GetNewText( QString& ) const;
- virtual QWidget* CreateWidget( QWidget* ) const;
- virtual void InitializeWidget( QWidget* ) const;
- virtual void TakeValue( QWidget* );
-
- virtual QString sigValueChanged() const;
-
-private:
- int myInitValue, myValue;
- QStringList myValues;
-};
-
-
-/*!
- * \brief This class represents parameter which can have value true or false
- */
-class SMESHGUI_boolParameter: public SMESHGUI_dependParameter
-{
-public:
- SMESHGUI_boolParameter( const bool = false,
- const QString& = QString::null,
- const bool = false );
- virtual ~SMESHGUI_boolParameter();
-
- bool& InitValue() { return myInitValue; }
- virtual Type GetType() const;
- virtual bool GetNewInt( int& ) const;
- virtual bool GetNewDouble( double& ) const;
- virtual bool GetNewText( QString& ) const;
- virtual QWidget* CreateWidget( QWidget* ) const;
- virtual void InitializeWidget( QWidget* ) const;
- virtual void TakeValue( QWidget* );
-
- virtual QString sigValueChanged() const;
-
-private:
- bool myInitValue, myValue;
-};
-
-
-class QButton;
-class SMESHGUI_tableParameter;
-
-
-/*!
- * \brief This class represents custom table. It has only double values and
- editor for every cell has validator
- */
-class SMESHGUI_Table : public QTable
-{
- Q_OBJECT
-
-public:
- SMESHGUI_Table( const SMESHGUI_tableParameter*, int numRows, int numCols, QWidget* = 0, const char* = 0 );
- virtual ~SMESHGUI_Table();
-
-/*!
- * \brief Hides current editor of cell
- */
- void stopEditing();
-
- virtual QSize sizeHint() const;
-
-/*!
- * \brief Returns parameters of double validator corresponding to cell (row,col)
- */
- void validator( const int row, const int col, double&, double&, int& );
-
-/*!
- * \brief Sets the double validator parameters to every cell in row range [rmin,rmax]
- * and column range [cmin,cmax].
- * If rmin=-1 then rmin is set to 0, if rmax=-1 then rmax = last row.
- * Analogically cmin and cmax are set
- */
- void setValidator( const double, const double, const int,
- const int rmin = -1, const int rmax = -1,
- const int cmin = -1, const int cmax = -1 );
-
-protected:
- virtual void keyPressEvent( QKeyEvent* );
- virtual bool eventFilter( QObject*, QEvent* );
- virtual QWidget* createEditor( int, int, bool ) const;
-
-private:
- SMESHGUI_tableParameter* myParam;
-};
-
-
-/*!
- * \brief This class represents frame for table and buttons
- */
-class SMESHGUI_TableFrame : public QFrame
-{
- Q_OBJECT
-
-public:
-/*!
- * \brief Values corresponding to buttons for table resize
- */
- typedef enum { ADD_COLUMN, REMOVE_COLUMN, ADD_ROW, REMOVE_ROW } Button;
-
-public:
- SMESHGUI_TableFrame( const SMESHGUI_tableParameter*, QWidget* );
- ~SMESHGUI_TableFrame();
-
- SMESHGUI_Table* table() const;
-
-/*!
- * \brief Changes shown state of some button for table resize
- */
- void setShown( const Button, const bool );
-
-/*!
- * \brief Returns shown state of some button for table resize
- */
- bool isShown( const Button ) const;
-
-private:
- QButton* button( const Button ) const;
-
-private slots:
- void onButtonClicked();
-
-signals:
-/*!
- * \brief This signal is emitted if some of button for table resize is clicked
- * Second parameter is current column for ADD_COLUMN, REMOVE_COLUMN buttons
- * and current row for ADD_ROW, REMOVE_ROW buttons. Take into account that
- * this object resize table ( returned by table() ) automatically
- */
- void toEdit( SMESHGUI_TableFrame::Button, int );
- void valueChanged( int, int );
-
-private:
- QButton *myAddColumn, *myRemoveColumn, *myAddRow, *myRemoveRow;
- SMESHGUI_Table* myTable;
-};
-
-
-/*!
- * \brief This class represents parameter which can have two-dimensional array of values
- */
-class SMESHGUI_tableParameter: public QObject, public SMESHGUI_aParameter
-{
- Q_OBJECT
-
-public:
-/*!
- * \brief Creates table parameter with default value 'init' and title 'label'.
- * The default value means that by default the table is filled with default value
- * and if new column or row is added then it is filled with default value
- */
- SMESHGUI_tableParameter( const double init = 0.0,
- const QString& label = QString::null,
- const bool preview = false );
- virtual ~SMESHGUI_tableParameter();
-
- virtual Type GetType() const;
- virtual bool GetNewInt( int& ) const;
- virtual bool GetNewDouble( double& ) const;
- virtual bool GetNewText( QString& ) const;
- virtual QWidget* CreateWidget( QWidget* ) const;
- virtual void InitializeWidget( QWidget* ) const;
- virtual void TakeValue( QWidget* );
-
- static void sortData( SMESH::double_array& );
-
-/*!
- * \brief Updates look of widget in accordance with all parameters of this object
- */
- void update( QWidget* ) const;
-
-/*!
- * \brief Returns data taken from widget. Please don't forget to call TakeValue before.
- */
- void data( SMESH::double_array& ) const;
-
-/*!
- * \brief Sets data. The InitializeWidget must be called in order to change values in widget
- */
- void setData( const SMESH::double_array& );
-
-/*!
- * \brief Sets count of columns and updates widget
- */
- void setColCount( const int, QWidget* = 0 );
-
-/*!
- * \brief Sets count of rows and updates widget
- */
- void setRowCount( const int, QWidget* = 0 );
-
-/*!
- * \brief Binds count of columns to some parameter and updates widget. Take into account that
- * if this parameter is changed, the update() must be called to resize table
- */
- void setColCount( const SMESHGUI_aParameterPtr, QWidget* = 0 );
-
-/*!
- * \brief Binds count of rows to some parameter and updates widget. Take into account that
- * if this parameter is changed, the update() must be called to resize table
- */
- void setRowCount( const SMESHGUI_aParameterPtr, QWidget* = 0 );
-
-/*!
- * \brief Enables or disables to change count of columns by buttons
- */
- void setEditCols( const bool );
-
-/*!
- * \brief Enables or disables to change count of rows by buttons
- */
- void setEditRows( const bool );
-
- virtual QString sigValueChanged() const;
-
- void setValidator( const int col, const double, const double, const int );
- void validator( const int col, double&, double&, int& ) const;
-
-/*!
- * \brief These methods allow to read and change name of column
- */
- void setColName( const int, const QString& );
- QString colName( const int ) const;
-
-private slots:
- void onEdit( SMESHGUI_TableFrame::Button, int );
- void onEdit( SMESHGUI_Table*, SMESHGUI_TableFrame::Button, int );
-
-private:
- void setItems( QWidget*, int = -1, int = -1, int = -1, int = -1 ) const;
-
-private:
- typedef struct
- {
- double myMin, myMax;
- int myDecimals;
- } ValidatorInfo;
-
- typedef QMap<int, ValidatorInfo> ValidatorsMap;
-
-private:
- int myColsInt, myRowsInt;
- SMESHGUI_aParameterPtr myCols, myRows;
- double myInitValue;
- SMESH::double_array myData;
- ValidatorsMap myValidators;
- bool myEditCols, myEditRows;
- QMap< int, QString > myColNames;
-
- friend class SMESHGUI_Table;
-};
-
-#endif // SMESHGUI_aParameter.h
-
+++ /dev/null
-// SMESH SMESHGUI : GUI for SMESH component
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : SMESHGUI_aParameterDlg.cxx
-// Author : Nicolas REJNERI
-// Module : SMESH
-// $Header$
-
-#include "SMESHGUI_aParameterDlg.h"
-#include "SMESHGUI_aParameter.h"
-#include "SMESHGUI.h"
-#include "SMESHGUI_SpinBox.h"
-#include "SMESHGUI_Utils.h"
-#include "SMESHGUI_FunctionPreview.h"
-
-#include "SUIT_Tools.h"
-#include "SUIT_Desktop.h"
-
-// QT Includes
-#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-#include <qspinbox.h>
-#include <qvalidator.h>
-#include <qlineedit.h>
-
-using namespace std;
-
-//======================================================================================
-// function : SMESHGUI_aParameterDlg()
-//
-// The dialog will by default be modal, unless you set 'modal' to
-// false when constructing dialog
-//
-//======================================================================================
-SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg
- ( SMESHGUI* theModule,
- std::list<SMESHGUI_aParameterPtr> params,
- QString title,
- bool modal)
-: QDialog( SMESH::GetDesktop( theModule ), "MyParameterDialog", modal, WStyle_Customize |
- WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myParamList(params),
- mySMESHGUI(theModule)
-{
- /* creating widgets */
- init();
- /* title */
- setCaption(title);
-
- /* Move widget on the botton right corner of main widget */
- SUIT_Tools::centerWidget(this, SMESH::GetDesktop( theModule ) );
-}
-
-//======================================================================================
-// function : SMESHGUI_aParameterDlg::init()
-// purpose : creates dialog's layout
-//======================================================================================
-void SMESHGUI_aParameterDlg::init()
-{
- setSizeGripEnabled(TRUE);
-
- QVBoxLayout* topLayout = new QVBoxLayout(this);
- topLayout->setMargin(11); topLayout->setSpacing(6);
-
- /***************************************************************/
- QGroupBox* GroupC1 = new QGroupBox(this, "GroupC1");
- GroupC1->setColumnLayout(0, Qt::Vertical);
- GroupC1->layout()->setSpacing(0);
- GroupC1->layout()->setMargin(0);
- QGridLayout* GroupC1Layout = new QGridLayout(GroupC1->layout());
- GroupC1Layout->setAlignment(Qt::AlignTop);
- GroupC1Layout->setSpacing(6);
- GroupC1Layout->setMargin(11);
- /* Spin boxes with labels */
- list<SMESHGUI_aParameterPtr>::iterator paramIt = myParamList.begin();
- int row;
- for( row = 0; paramIt != myParamList.end(); paramIt++ , row++)
- {
- SMESHGUI_aParameterPtr param = (*paramIt);
- QLabel * label = new QLabel(GroupC1, "TextLabel");
- GroupC1Layout->addWidget(label, row, 0);
- label->setText(param->Label());
- QWidget* aSpinWidget = param->CreateWidget( GroupC1 );
- if (aSpinWidget) {
- GroupC1Layout->addWidget(aSpinWidget, row, 1);
- aSpinWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
- aSpinWidget->setMinimumSize(150, 0);
-
- QString sig = param->sigValueChanged();
- if( !sig.isEmpty() /*&& param->GetType()!=SMESHGUI_aParameter::TABLE*/ )
- connect( aSpinWidget, sig.latin1(), this, SLOT( onValueChanged() ) );
-
- param->InitializeWidget(aSpinWidget);
- mySpinList.push_back(aSpinWidget);
- myLabelList.push_back(label);
- }
- }
-
- myPreview = new SMESHGUI_FunctionPreview( GroupC1 );
- myPreview->hide();
- GroupC1Layout->addWidget( myPreview, row, 1 );
-
- paramIt = myParamList.begin();
- std::list<QWidget*>::const_iterator anIt = mySpinList.begin();
- for( ; paramIt!=myParamList.end(); paramIt++, anIt++ )
- {
- (*paramIt)->TakeValue( *anIt );
- UpdateShown( *paramIt, *anIt );
- FunctionPreview( *paramIt, *anIt );
- }
-
- /***************************************************************/
- QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons");
- GroupButtons->setColumnLayout(0, Qt::Vertical);
- GroupButtons->layout()->setSpacing(0);
- GroupButtons->layout()->setMargin(0);
- QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
- GroupButtonsLayout->setAlignment(Qt::AlignTop);
- GroupButtonsLayout->setSpacing(6);
- GroupButtonsLayout->setMargin(11);
- /* Ok button */
- myButtonOk = new QPushButton(GroupButtons, "buttonOk");
- myButtonOk->setText(tr("SMESH_BUT_OK"));
- myButtonOk->setAutoDefault(TRUE);
- myButtonOk->setDefault(TRUE);
- GroupButtonsLayout->addWidget(myButtonOk, 0, 0);
- /* add spacer between buttons */
- GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
- /* Cancel button */
- myButtonCancel = new QPushButton(GroupButtons, "buttonCancel");
- myButtonCancel->setText(tr("SMESH_BUT_CANCEL"));
- myButtonCancel->setAutoDefault(TRUE);
- GroupButtonsLayout->addWidget(myButtonCancel, 0, 2);
-
- /***************************************************************/
- topLayout->addWidget(GroupC1, 1 );
- topLayout->addWidget(GroupButtons, 0 );
-
- /* signals and slots connections */
- connect(myButtonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
- connect(myButtonCancel, SIGNAL(clicked()), this, SLOT(reject()));
-}
-
-//======================================================================================
-// function : ~SMESHGUI_aParameterDlg()
-// purpose : Destructor
-//======================================================================================
-SMESHGUI_aParameterDlg::~SMESHGUI_aParameterDlg()
-{
-}
-
-//=======================================================================
-//function : ClickOnOk
-//purpose :
-//=======================================================================
-void SMESHGUI_aParameterDlg::ClickOnOk()
-{
- if (!mySMESHGUI->isActiveStudyLocked()) {
- list<SMESHGUI_aParameterPtr>::iterator paramIt = myParamList.begin();
- list<QWidget*>::iterator widgetIt = mySpinList.begin();
- for (;
- paramIt != myParamList.end() && widgetIt != mySpinList.end();
- paramIt++ , widgetIt++)
- (*paramIt)->TakeValue(*widgetIt);
-
- accept();
- }
-}
-
-//=======================================================================
-// function : Parameters()
-// purpose : return a list of parameters from a dialog box
-//=======================================================================
-bool SMESHGUI_aParameterDlg::Parameters( SMESHGUI* theModule,
- list<SMESHGUI_aParameterPtr> params,
- const char *aTitle)
-{
- if (!params.empty()) {
- SMESHGUI_aParameterDlg *Dialog =
- new SMESHGUI_aParameterDlg( theModule, params, aTitle, TRUE);
- return (Dialog->exec() == QDialog::Accepted);
- }
- return false;
-}
-
-//=======================================================================
-// function : FunctionPreview
-// purpose :
-//=======================================================================
-void SMESHGUI_aParameterDlg::FunctionPreview( const SMESHGUI_aParameterPtr p, QWidget* w )
-{
- if( !w || !w->isShown() )
- return;
-
- SMESHGUI_strParameter* str_param = dynamic_cast<SMESHGUI_strParameter*>( p.operator->() );
- SMESHGUI_tableParameter* tab_param = dynamic_cast<SMESHGUI_tableParameter*>( p.operator->() );
- SMESHGUI_boolParameter* bool_param = dynamic_cast<SMESHGUI_boolParameter*>( p.operator->() );
- if( str_param && str_param->needPreview() )
- {
- QString val; str_param->GetNewText( val );
- if( !val.isNull() )
- myPreview->setParams( val );
- }
- else if( tab_param && tab_param->needPreview() )
- {
- SMESH::double_array d;
- tab_param->data( d );
- myPreview->setParams( d );
- }
- else if( bool_param && bool_param->needPreview() )
- {
- int exp=0;
- bool_param->GetNewInt( exp );
- myPreview->setIsExp( exp );
- }
-}
-
-//=======================================================================
-// function : onValueChanged
-// purpose :
-//=======================================================================
-void SMESHGUI_aParameterDlg::onValueChanged()
-{
- if( sender()->inherits( "QWidget" ) )
- {
- QWidget* w = ( QWidget* )sender();
-
-
- std::list<QWidget*>::const_iterator anIt = mySpinList.begin(),
- aLast = mySpinList.end();
- std::list<SMESHGUI_aParameterPtr>::const_iterator aPIt = myParamList.begin();
- for( ; anIt!=aLast; anIt++, aPIt++ )
- if( *anIt == w )
- {
- (*aPIt)->TakeValue( w );
- UpdateShown( *aPIt, w );
- FunctionPreview( *aPIt, w );
- break;
- }
- }
-}
-
-//=======================================================================
-// function : onValueChanged
-// purpose :
-//=======================================================================
-void SMESHGUI_aParameterDlg::UpdateShown( const SMESHGUI_aParameterPtr param, QWidget* w )
-{
- SMESHGUI_dependParameter* depPar = dynamic_cast<SMESHGUI_enumParameter*>( param.get() );
- if( !depPar )
- depPar = dynamic_cast<SMESHGUI_boolParameter*>( param.get() );
-
- if( !depPar )
- return;
-
- SMESHGUI_dependParameter::ShownMap& map = depPar->shownMap();
- if( map.isEmpty() )
- return;
-
- int val;
- depPar->TakeValue( w );
- depPar->GetNewInt( val );
- bool hasValue = map.contains( val );
-
- std::list<QWidget*>::const_iterator anIt = mySpinList.begin(),
- aLast = mySpinList.end(),
- aLIt = myLabelList.begin();
- std::list<SMESHGUI_aParameterPtr>::iterator aPIt = myParamList.begin();
- bool preview = false;
- for( int i=0; anIt!=aLast; anIt++, aLIt++, i++, aPIt++ )
- {
- bool shown = hasValue && map[ val ].contains( i );
- (*anIt)->setShown( shown );
- (*aLIt)->setShown( shown );
- if( shown )
- {
- SMESHGUI_strParameter* str_param = dynamic_cast<SMESHGUI_strParameter*>( (*aPIt).operator->() );
- SMESHGUI_tableParameter* tab_param = dynamic_cast<SMESHGUI_tableParameter*>( (*aPIt).operator->() );
- preview = preview || ( str_param && str_param->needPreview() ) || ( tab_param && tab_param->needPreview() );
- }
- }
- myPreview->setShown( preview );
-}
+++ /dev/null
-// SMESH SMESHGUI : GUI for SMESH component
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : SMESHGUI_aParameterDlg.h
-// Author : Nicolas REJNERI
-// Module : SMESH
-// $Header$
-
-#ifndef SMESHGUI_aParameterDlg_H
-#define SMESHGUI_aParameterDlg_H
-
-// QT Includes
-#include <qdialog.h>
-
-#include <list>
-#include "SMESHGUI_aParameter.h"
-
-class QLabel;
-class QPushButton;
-class SMESHGUI;
-class QWidget;
-class SMESHGUI_FunctionPreview;
-
-//=================================================================================
-// class : SMESHGUI_aParameterDlg
-// purpose :
-//=================================================================================
-class SMESHGUI_aParameterDlg : public QDialog
-{
- Q_OBJECT
-
-public:
- SMESHGUI_aParameterDlg( SMESHGUI*,
- std::list<SMESHGUI_aParameterPtr> params,
- QString title = QString::null,
- bool modal = TRUE);
-
- ~SMESHGUI_aParameterDlg();
-
- /* Parameter function */
- static bool Parameters( SMESHGUI*, std::list<SMESHGUI_aParameterPtr> params, const char *aTitle);
-
-protected:
- void init();
-
-protected slots:
- virtual void onValueChanged();
-
-private slots:
- void ClickOnOk();
- void UpdateShown( const SMESHGUI_aParameterPtr, QWidget* );
-
-private:
- void FunctionPreview( const SMESHGUI_aParameterPtr, QWidget* );
-
-private:
- SMESHGUI* mySMESHGUI;
-
- QPushButton* myButtonOk;
- QPushButton* myButtonCancel;
-
- std::list<QWidget*> mySpinList, myLabelList;
- std::list<SMESHGUI_aParameterPtr> myParamList;
- SMESHGUI_FunctionPreview* myPreview;
-};
-
-#endif // SMESHGUI_aParameterDlg.h
hypNbSeg3 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
hypNbSeg3.SetDistrType(2)
hypNbSeg3.SetNumberOfSegments(7)
-hypNbSeg3.SetTableFunction( [0.25, 0.5, 0.5, 0.25] )
+hypNbSeg3.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] )
+hypNbSeg3.SetConversionMode(0)
print hypNbSeg3.GetName()
print hypNbSeg3.GetId()
print hypNbSeg3.GetNumberOfSegments()
hypNbSeg4.SetDistrType(3)
hypNbSeg4.SetNumberOfSegments(10)
hypNbSeg4.SetExpressionFunction("sin(3*t)")
+hypNbSeg4.SetConversionMode(1)
print hypNbSeg4.GetName()
print hypNbSeg4.GetId()
print hypNbSeg4.GetNumberOfSegments()
StdMeshers_Quadrangle_2D.hxx \
StdMeshers_MEFISTO_2D.hxx \
StdMeshers_Hexa_3D.hxx \
- StdMeshers_AutomaticLength.hxx
+ StdMeshers_AutomaticLength.hxx \
+ StdMeshers_Distribution.hxx
EXPORT_PYSCRIPTS =
StdMeshers_MEFISTO_2D.cxx \
StdMeshers_Penta_3D.cxx \
StdMeshers_Hexa_3D.cxx \
- StdMeshers_AutomaticLength.cxx
+ StdMeshers_AutomaticLength.cxx \
+ StdMeshers_Distribution.cxx
LIB_SERVER_IDL =
--- /dev/null
+// SMESH StdMeshers : implementaion of point distribution algorithm
+//
+// Copyright (C) 2003 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : StdMeshers_Distribution.cxx
+// Author : Alexandre SOLOVYOV
+// Module : SMESH
+// $Header$
+
+#include "StdMeshers_Distribution.hxx"
+#include <CASCatch_CatchSignals.hxx>
+#include <CASCatch_Failure.hxx>
+#include <CASCatch_ErrorHandler.hxx>
+#include <OSD.hxx>
+#include <math_GaussSingleIntegration.hxx>
+#include <utilities.h>
+
+Function::Function( const int conv )
+: myConv( conv )
+{
+}
+
+Function::~Function()
+{
+}
+
+bool Function::value( const double, double& f ) const
+{
+ CASCatch_CatchSignals aCatchSignals;
+ aCatchSignals.Activate();
+
+ bool ok = true;
+ if( myConv==0 )
+ {
+ CASCatch_TRY
+ {
+ f = pow( 10, f );
+ }
+ CASCatch_CATCH(CASCatch_Failure)
+ {
+ aCatchSignals.Deactivate();
+ Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+ f = 0.0;
+ ok = false;
+ }
+ }
+ else if( myConv==1 && f<0.0 )
+ f = 0.0;
+
+ return ok;
+}
+
+FunctionIntegral::FunctionIntegral( const Function* f, const double st )
+: Function( -1 ),
+ myFunc( const_cast<Function*>( f ) ),
+ myStart( st )
+{
+}
+
+FunctionIntegral::~FunctionIntegral()
+{
+}
+
+bool FunctionIntegral::value( const double t, double& f ) const
+{
+ f = myFunc ? myFunc->integral( myStart, t ) : 0;
+ return myFunc!=0 && Function::value( t, f );
+}
+
+double FunctionIntegral::integral( const double, const double ) const
+{
+ return 0;
+}
+
+FunctionTable::FunctionTable( const std::vector<double>& data, const int conv )
+: Function( conv )
+{
+ myData = data;
+}
+
+FunctionTable::~FunctionTable()
+{
+}
+
+bool FunctionTable::value( const double t, double& f ) const
+{
+ int i1, i2;
+ if( !findBounds( t, i1, i2 ) )
+ return false;
+
+ double
+ x1 = myData[2*i1], y1 = myData[2*i1+1],
+ x2 = myData[2*i2], y2 = myData[2*i2+1];
+
+ Function::value( x1, y1 );
+ Function::value( x2, y2 );
+
+ f = y1 + ( y2-y1 ) * ( t-x1 ) / ( x2-x1 );
+ return true;
+}
+
+double FunctionTable::integral( const int i ) const
+{
+ if( i>=0 && i<myData.size()-1 )
+ return integral( i, myData[2*(i+1)]-myData[2*i] );
+ else
+ return 0;
+}
+
+double FunctionTable::integral( const int i, const double d ) const
+{
+ double f, res = 0.0;
+ if( value( myData[2*i]+d, f ) )
+ res = ( myData[2*i+1] + f ) / 2.0 * d;
+
+ return res;
+}
+
+double FunctionTable::integral( const double a, const double b ) const
+{
+ int x1s, x1f, x2s, x2f;
+ findBounds( a, x1s, x1f );
+ findBounds( b, x2s, x2f );
+ double J = 0;
+ for( int i=x1s; i<x2s; i++ )
+ J+=integral( i );
+ J-=integral( x1s, a-myData[2*x1s] );
+ J+=integral( x2s, b-myData[2*x2s] );
+ return J;
+}
+
+bool FunctionTable::findBounds( const double x, int& x_ind_1, int& x_ind_2 ) const
+{
+ int n = myData.size();
+ if( n==0 || x<myData[0] )
+ {
+ x_ind_1 = x_ind_2 = 0;
+ return false;
+ }
+
+ for( int i=0; i<n-1; i++ )
+ if( myData[2*i]<=x && x<=myData[2*(i+1)] )
+ {
+ x_ind_1 = i;
+ x_ind_2 = i+1;
+ return true;
+ }
+ x_ind_1 = n-1;
+ x_ind_2 = n-1;
+ return false;
+}
+
+FunctionExpr::FunctionExpr( const char* str, const int conv )
+: Function( conv ),
+ myVars( 1, 1 ),
+ myValues( 1, 1 )
+{
+ CASCatch_CatchSignals aCatchSignals;
+ aCatchSignals.Activate();
+
+ bool ok = true;
+ CASCatch_TRY
+ {
+ myExpr = ExprIntrp_GenExp::Create();
+ myExpr->Process( ( Standard_CString )str );
+ }
+ CASCatch_CATCH(CASCatch_Failure)
+ {
+ aCatchSignals.Deactivate();
+ Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+ ok = false;
+ }
+ aCatchSignals.Deactivate();
+
+ if( !ok || !myExpr->IsDone() )
+ myExpr.Nullify();
+
+ myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" );
+}
+
+FunctionExpr::~FunctionExpr()
+{
+}
+
+Standard_Boolean FunctionExpr::Value( Standard_Real T, Standard_Real& F )
+{
+ double f;
+ Standard_Boolean res = value( T, f );
+ F = f;
+ return res;
+}
+
+bool FunctionExpr::value( const double t, double& f ) const
+{
+ if( myExpr.IsNull() )
+ return false;
+
+ OSD::SetSignal( true );
+ CASCatch_CatchSignals aCatchSignals;
+ aCatchSignals.Activate();
+
+ ( ( TColStd_Array1OfReal& )myValues ).ChangeValue( 1 ) = t;
+ bool ok = true;
+ CASCatch_TRY {
+ f = myExpr->Expression()->Evaluate( myVars, myValues );
+ }
+ CASCatch_CATCH(CASCatch_Failure) {
+ aCatchSignals.Deactivate();
+ Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+ f = 0.0;
+ ok = false;
+ }
+
+ aCatchSignals.Deactivate();
+ ok = Function::value( t, f ) && ok;
+ return ok;
+}
+
+double FunctionExpr::integral( const double a, const double b ) const
+{
+ double res = 0.0;
+ CASCatch_TRY
+ {
+ math_GaussSingleIntegration _int( ( math_Function& )*this, a, b, 20 );
+ if( _int.IsDone() )
+ res = _int.Value();
+ }
+ CASCatch_CATCH(CASCatch_Failure)
+ {
+ res = 0.0;
+ MESSAGE( "Exception in integral calculating" );
+ }
+ return res;
+}
+
+double dihotomySolve( Function& f, const double val, const double _start, const double _fin, const double eps, bool& ok )
+{
+ double start = _start, fin = _fin, start_val, fin_val; bool ok1, ok2;
+ ok1 = f.value( start, start_val );
+ ok2 = f.value( fin, fin_val );
+
+ if( !ok1 || !ok2 )
+ {
+ ok = false;
+ return 0.0;
+ }
+
+ bool start_pos = start_val>=val, fin_pos = fin_val>=val;
+ ok = true;
+
+ while( fin-start>eps )
+ {
+ double mid = ( start+fin )/2.0, mid_val;
+ ok = f.value( mid, mid_val );
+ if( !ok )
+ return 0.0;
+
+ //char buf[1024];
+ //sprintf( buf, "start=%f\nfin=%f\nmid_val=%f\n", float( start ), float( fin ), float( mid_val ) );
+ //MESSAGE( buf );
+
+ bool mid_pos = mid_val>=val;
+ if( start_pos!=mid_pos )
+ {
+ fin_pos = mid_pos;
+ fin = mid;
+ }
+ else if( fin_pos!=mid_pos )
+ {
+ start_pos = mid_pos;
+ start = mid;
+ }
+ else
+ {
+ ok = false;
+ break;
+ }
+ }
+ return (start+fin)/2.0;
+}
+
+bool buildDistribution( const TCollection_AsciiString& f, const int conv, const double start, const double end,
+ const int nbSeg, vector<double>& data, const double eps )
+{
+ return buildDistribution( FunctionExpr( f.ToCString(), conv ), start, end, nbSeg, data, eps );
+}
+
+bool buildDistribution( const std::vector<double>& f, const int conv, const double start, const double end,
+ const int nbSeg, vector<double>& data, const double eps )
+{
+ return buildDistribution( FunctionTable( f, conv ), start, end, nbSeg, data, eps );
+}
+
+bool buildDistribution( const Function& func, const double start, const double end, const int nbSeg,
+ vector<double>& data, const double eps )
+{
+ if( nbSeg<=0 )
+ return false;
+
+ data.resize( nbSeg+1 );
+ data[0] = start;
+ double J = func.integral( start, end ) / nbSeg;
+ if( J<1E-10 )
+ return false;
+
+ bool ok;
+ //MESSAGE( "distribution:" );
+ //char buf[1024];
+ for( int i=1; i<nbSeg; i++ )
+ {
+ FunctionIntegral f_int( &func, data[i-1] );
+ data[i] = dihotomySolve( f_int, J, data[i-1], end, eps, ok );
+ //sprintf( buf, "%f\n", float( data[i] ) );
+ //MESSAGE( buf );
+ if( !ok )
+ return false;
+ }
+
+ data[nbSeg] = end;
+ return true;
+}
--- /dev/null
+// SMESH StdMeshers : implementaion of point distribution algorithm
+//
+// Copyright (C) 2003 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : StdMeshers_Distribution.hxx
+// Author : Alexandre SOLOVYOV
+// Module : SMESH
+// $Header$
+
+#ifndef _STD_MESHERS_DISTRIBUTION_HXX_
+#define _STD_MESHERS_DISTRIBUTION_HXX_
+
+#include <vector>
+#include <math_Function.hxx>
+#include <ExprIntrp_GenExp.hxx>
+#include <Expr_Array1OfNamedUnknown.hxx>
+#include <TColStd_Array1OfReal.hxx>
+
+
+class Function
+{
+public:
+ Function( const int );
+ virtual ~Function();
+ virtual bool value( const double, double& ) const;
+ virtual double integral( const double, const double ) const = 0;
+
+private:
+ int myConv;
+};
+
+class FunctionIntegral : public Function
+{
+public:
+ FunctionIntegral( const Function*, const double );
+ virtual ~FunctionIntegral();
+ virtual bool value( const double, double& ) const;
+ virtual double integral( const double, const double ) const;
+
+private:
+ Function* myFunc;
+ double myStart;
+};
+
+class FunctionTable : public Function
+{
+public:
+ FunctionTable( const std::vector<double>&, const int );
+ virtual ~FunctionTable();
+ virtual bool value( const double, double& ) const;
+ virtual double integral( const double, const double ) const;
+
+private:
+ bool findBounds( const double, int&, int& ) const;
+
+ //integral from x[i] to x[i+1]
+ double integral( const int i ) const;
+
+ //integral from x[i] to x[i]+d
+ //warning: function is presented as linear on interaval from x[i] to x[i]+d,
+ // for correct result d must be >=0 and <=x[i+1]-x[i]
+ double integral( const int i, const double d ) const;
+
+private:
+ std::vector<double> myData;
+};
+
+class FunctionExpr : public Function, public math_Function
+{
+public:
+ FunctionExpr( const char*, const int );
+ virtual ~FunctionExpr();
+ virtual Standard_Boolean Value( Standard_Real, Standard_Real& );
+ virtual bool value( const double, double& ) const;
+ virtual double integral( const double, const double ) const;
+
+private:
+ Handle(ExprIntrp_GenExp) myExpr;
+ Expr_Array1OfNamedUnknown myVars;
+ TColStd_Array1OfReal myValues;
+};
+
+bool buildDistribution( const Function& f,
+ const double start, const double end,
+ const int nbSeg,
+ vector<double>& data,
+ const double eps );
+
+bool buildDistribution( const TCollection_AsciiString& f, const int conv, const double start, const double end,
+ const int nbSeg, vector<double>& data, const double eps );
+bool buildDistribution( const std::vector<double>& f, const int conv, const double start, const double end,
+ const int nbSeg, vector<double>& data, const double eps );
+
+#endif
using namespace std;
#include "StdMeshers_NumberOfSegments.hxx"
+#include "StdMeshers_Distribution.hxx"
#include <Standard_ErrorHandler.hxx>
#include <TCollection_AsciiString.hxx>
#include <ExprIntrp_GenExp.hxx>
_numberOfSegments(1),
_distrType(DT_Regular),
_scaleFactor(1.),
- _expMode(false)
+ _convMode(1) //cut negative by default
{
_name = "NumberOfSegments";
_param_algo_dim = 1;
{
}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+const std::vector<double>& StdMeshers_NumberOfSegments::BuildDistributionExpr( const char* expr, int nbSeg, int conv )
+throw ( SALOME_Exception )
+{
+ if( !buildDistribution( TCollection_AsciiString( ( Standard_CString )expr ), conv, 0.0, 1.0, nbSeg, _distr, 1E-4 ) )
+ _distr.resize( 0 );
+ return _distr;
+}
+
+const std::vector<double>& StdMeshers_NumberOfSegments::BuildDistributionTab( const std::vector<double>& tab,
+ int nbSeg, int conv )
+throw ( SALOME_Exception )
+{
+ if( !buildDistribution( tab, conv, 0.0, 1.0, nbSeg, _distr, 1E-4 ) )
+ _distr.resize( 0 );
+ return _distr;
+}
+
//=============================================================================
/*!
*
double prev = -PRECISION;
bool isSame = table.size() == _table.size();
+ OSD::SetSignal( true );
+ CASCatch_CatchSignals aCatchSignals;
+ aCatchSignals.Activate();
+
bool pos = false;
for (i=0; i < table.size()/2; i++) {
double par = table[i*2];
double val = table[i*2+1];
+ if( _convMode==0 )
+ {
+ CASCatch_TRY
+ {
+ val = pow( 10.0, val );
+ }
+ CASCatch_CATCH(CASCatch_Failure)
+ {
+ aCatchSignals.Deactivate();
+ Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+ throw SALOME_Exception( LOCALIZED( "invalid value"));
+ return;
+ }
+ }
+ else if( _convMode==1 && val<0.0 )
+ val = 0.0;
+
if ( par<0 || par > 1)
throw SALOME_Exception(LOCALIZED("parameter of table function is out of range [0,1]"));
if ( fabs(par-prev)<PRECISION )
}
prev = par;
}
+ aCatchSignals.Deactivate();
if( !pos )
throw SALOME_Exception(LOCALIZED("value of table function is not positive"));
* ( result in 'syntax' ) and if only 't' is unknown variable in expression ( result in 'args' )
*/
//================================================================================
-bool process( const TCollection_AsciiString& str,
+bool process( const TCollection_AsciiString& str, int convMode,
bool& syntax, bool& args,
bool& non_neg, bool& non_zero,
bool& singulars, double& sing_point )
{
- Handle( ExprIntrp_GenExp ) myExpr = ExprIntrp_GenExp::Create();
- myExpr->Process( str.ToCString() );
+ OSD::SetSignal( true );
+ CASCatch_CatchSignals aCatchSignals;
+ aCatchSignals.Activate();
+
+ bool parsed_ok = true;
+ Handle( ExprIntrp_GenExp ) myExpr;
+ CASCatch_TRY
+ {
+ myExpr = ExprIntrp_GenExp::Create();
+ myExpr->Process( str.ToCString() );
+ }
+ CASCatch_CATCH(CASCatch_Failure)
+ {
+ aCatchSignals.Deactivate();
+ Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+ parsed_ok = false;
+ }
+ aCatchSignals.Deactivate();
- if( myExpr->IsDone() )
+ syntax = false;
+ args = false;
+ if( parsed_ok && myExpr->IsDone() )
{
syntax = true;
args = isCorrectArg( myExpr->Expression() );
}
- bool res = syntax && args;
+ bool res = parsed_ok && syntax && args;
if( !res )
myExpr.Nullify();
if( res )
{
- OSD::SetSignal( true );
- CASCatch_CatchSignals aCatchSignals;
- aCatchSignals.Activate();
- double res;
- Expr_Array1OfNamedUnknown myVars( 1, 1 );
- TColStd_Array1OfReal myValues( 1, 1 );
- myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" );
-
+ FunctionExpr f( str.ToCString(), convMode );
const int max = 500;
for( int i=0; i<=max; i++ )
{
- double t = double(i)/double(max);
- myValues.ChangeValue( 1 ) = t;
- CASCatch_TRY
- {
- res = myExpr->Expression()->Evaluate( myVars, myValues );
- }
- CASCatch_CATCH(CASCatch_Failure)
+ double t = double(i)/double(max), val;
+ if( !f.value( t, val ) )
{
- aCatchSignals.Deactivate();
- Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
sing_point = t;
singulars = true;
break;
}
- if( res<0 )
+ if( val<0 )
{
non_neg = false;
break;
}
- if( res>PRECISION )
+ if( val>PRECISION )
non_zero = true;
}
- aCatchSignals.Deactivate();
}
- return res && non_neg && ( !singulars );
+ return res && non_neg && non_zero && ( !singulars );
}
//================================================================================
bool syntax, args, non_neg, singulars, non_zero;
double sing_point;
- bool res = true;//process( str, syntax, args, non_neg, non_zero, singulars, sing_point );
+ bool res = process( str, _convMode, syntax, args, non_neg, non_zero, singulars, sing_point );
if( !res )
{
if( !syntax )
*/
//================================================================================
-void StdMeshers_NumberOfSegments::SetExponentMode(bool isExp)
+void StdMeshers_NumberOfSegments::SetConversionMode( int conv )
throw(SALOME_Exception)
{
if (_distrType != DT_TabFunc && _distrType != DT_ExprFunc)
throw SALOME_Exception(LOCALIZED("not a functional distribution"));
- if (isExp != _expMode)
+ if( conv != _convMode )
{
- _expMode = isExp;
+ _convMode = conv;
NotifySubMeshesHypothesisModification();
}
}
*/
//================================================================================
-bool StdMeshers_NumberOfSegments::IsExponentMode() const
+int StdMeshers_NumberOfSegments::ConversionMode() const
throw(SALOME_Exception)
{
if (_distrType != DT_TabFunc && _distrType != DT_ExprFunc)
throw SALOME_Exception(LOCALIZED("not a functional distribution"));
- return _expMode;
+ return _convMode;
}
//=============================================================================
}
if (_distrType == DT_TabFunc || _distrType == DT_ExprFunc)
- save << " " << (int)_expMode;
+ save << " " << _convMode;
return save;
}
{
isOK = (load >> a);
if (isOK)
- _expMode = (bool) a;
+ _convMode = a;
else
load.clear(ios::badbit | load.rdstate());
}
StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_NumberOfSegments();
+ // Builds point distribution according to passed function
+ const std::vector<double>& BuildDistributionExpr( const char*, int, int ) throw ( SALOME_Exception );
+ const std::vector<double>& BuildDistributionTab( const std::vector<double>&, int, int ) throw ( SALOME_Exception );
+
/*!
* \brief Set the number of segments
* \param segmentsNumber - must be greater than zero
throw (SALOME_Exception);
/*!
- * \brief When exponent mode is set, the function of distribution of density
- * is used as an exponent of 10, i,e, 10^f(t). This mode is sensible only when
- * function distribution is used (DT_TabFunc or DT_ExprFunc)
- * \param isExp - boolean switching on/off the mode
+ * \brief Set conversion mode. When it is 0, it means "exponent mode":
+ * the function of distribution of density is used as an exponent of 10, i,e, 10^f(t).
+ * When it is 1, it means "cut negative mode". The function of distribution is used as
+ * F(t), where F(t0)=f(t0), if f(t0)>=0, otherwise F(t0) = 0.
+ * This mode is sensible only when function distribution is used (DT_TabFunc or DT_ExprFunc)
*
* Throws SALOME_Exception if distribution type is not functional
*/
- void SetExponentMode(bool isExp)
+ void SetConversionMode( int conv )
throw (SALOME_Exception);
/*!
- * \brief Returns true if the exponent mode is set
+ * \brief Returns conversion mode
*
* Throws SALOME_Exception if distribution type is not functional
*/
- bool IsExponentMode() const
+ int ConversionMode() const
throw (SALOME_Exception);
virtual ostream & SaveTo(ostream & save);
int _numberOfSegments; //!< an edge will be split on to this number of segments
DistrType _distrType; //!< the type of distribution of density function
double _scaleFactor; //!< the scale parameter for DT_Scale
- std::vector<double> _table; //!< the table for DT_TabFunc, a sequence of pairs of numbers
+ std::vector<double> _table, _distr; //!< the table for DT_TabFunc, a sequence of pairs of numbers
std::string _func; //!< the expression of the function for DT_ExprFunc
- bool _expMode; //!< flag of exponent mode
+ int _convMode; //!< flag of conversion mode: 0=exponent, 1=cut negative
};
#endif
using namespace std;
#include "StdMeshers_Regular_1D.hxx"
+#include "StdMeshers_Distribution.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
+#include <OSD.hxx>
+
#include "StdMeshers_LocalLength.hxx"
#include "StdMeshers_NumberOfSegments.hxx"
#include "StdMeshers_Arithmetic1D.hxx"
#include <TColStd_Array1OfReal.hxx>
#include <ExprIntrp_GenExp.hxx>
-#include <CASCatch_CatchSignals.hxx>
-#include <CASCatch_Failure.hxx>
-#include <CASCatch_ErrorHandler.hxx>
-#include <OSD.hxx>
-#include <math_GaussSingleIntegration.hxx>
-
#include <string>
#include <math.h>
}
if (_ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_TabFunc ||
_ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_ExprFunc)
- _ivalue[ EXP_MODE_IND ] = (int) hyp->IsExponentMode();
+ _ivalue[ CONV_MODE_IND ] = hyp->ConversionMode();
_hypType = NB_SEGMENTS;
aStatus = SMESH_Hypothesis::HYP_OK;
}
}
}
-class Function
-{
-public:
- Function( const bool exp )
- : myExp( exp )
- {
- }
-
- virtual ~Function()
- {
- }
-
- virtual bool value( const double, double& f )
- {
- if( myExp )
- f = pow( 10, f );
- return true;
- }
- virtual double integral( const double, const double ) = 0;
-
-private:
- bool myExp;
-};
-
-class FunctionIntegral : public Function
-{
-public:
- FunctionIntegral( Function*, const double );
- virtual ~FunctionIntegral();
- virtual bool value( const double, double& );
- virtual double integral( const double, const double );
-
-private:
- Function* myFunc;
- double myStart;
-};
-
-FunctionIntegral::FunctionIntegral( Function* f, const double st )
-: Function( false )
-{
- myFunc = f;
- myStart = st;
-}
-
-FunctionIntegral::~FunctionIntegral()
-{
-}
-
-bool FunctionIntegral::value( const double t, double& f )
-{
- f = myFunc ? myFunc->integral( myStart, t ) : 0;
- return myFunc!=0 && Function::value( t, f );
-}
-
-double FunctionIntegral::integral( const double, const double )
-{
- return 0;
-}
-
-class FunctionTable : public Function
-{
-public:
- FunctionTable( const std::vector<double>&, const bool );
- virtual ~FunctionTable();
- virtual bool value( const double, double& );
- virtual double integral( const double, const double );
-
-private:
- bool findBounds( const double, int&, int& ) const;
-
- //integral from x[i] to x[i+1]
- double integral( const int i );
-
- //integral from x[i] to x[i]+d
- //warning: function is presented as linear on interaval from x[i] to x[i]+d,
- // for correct result d must be >=0 and <=x[i+1]-x[i]
- double integral( const int i, const double d );
-
-private:
- std::vector<double> myData;
-};
-
-FunctionTable::FunctionTable( const std::vector<double>& data, const bool exp )
-: Function( exp )
-{
- myData = data;
-}
-
-FunctionTable::~FunctionTable()
-{
-}
-
-bool FunctionTable::value( const double t, double& f )
-{
- int i1, i2;
- if( !findBounds( t, i1, i2 ) )
- return false;
-
- double
- x1 = myData[2*i1], y1 = myData[2*i1+1],
- x2 = myData[2*i2], y2 = myData[2*i2+1];
-
- Function::value( x1, y1 );
- Function::value( x2, y2 );
-
- f = y1 + ( y2-y1 ) * ( t-x1 ) / ( x2-x1 );
- return true;
-}
-
-double FunctionTable::integral( const int i )
-{
- if( i>=0 && i<myData.size()-1 )
- return integral( i, myData[2*(i+1)]-myData[2*i] );
- else
- return 0;
-}
-
-double FunctionTable::integral( const int i, const double d )
-{
- double f, res = 0.0;
- if( value( myData[2*i]+d, f ) )
- res = ( myData[2*i] + f ) / 2.0 * d;
-
- return res;
-}
-
-double FunctionTable::integral( const double a, const double b )
-{
- int x1s, x1f, x2s, x2f;
- findBounds( a, x1s, x1f );
- findBounds( b, x2s, x2f );
- double J = 0;
- for( int i=x1s; i<x2s; i++ )
- J+=integral( i );
- J-=integral( x1s, a-myData[2*x1s] );
- J+=integral( x2s, b-myData[2*x2s] );
- return J;
-}
-
-bool FunctionTable::findBounds( const double x, int& x_ind_1, int& x_ind_2 ) const
-{
- int n = myData.size();
- if( n==0 || x<myData[0] )
- {
- x_ind_1 = x_ind_2 = 0;
- return false;
- }
-
- for( int i=0; i<n-1; i++ )
- if( myData[2*i]<=x && x<=myData[2*(i+1)] )
- {
- x_ind_1 = i;
- x_ind_2 = i+1;
- return true;
- }
- x_ind_1 = n-1;
- x_ind_2 = n-1;
- return false;
-}
-
-
-
-class FunctionExpr : public Function, public math_Function
-{
-public:
- FunctionExpr( const char*, const bool );
- virtual ~FunctionExpr();
- virtual Standard_Boolean Value( Standard_Real, Standard_Real& );
- virtual bool value( const double, double& ); //inherited from Function
- virtual double integral( const double, const double );
-
-private:
- Handle(ExprIntrp_GenExp) myExpr;
- Expr_Array1OfNamedUnknown myVars;
- TColStd_Array1OfReal myValues;
-};
-
-FunctionExpr::FunctionExpr( const char* str, const bool exp )
-: Function( exp ),
- myVars( 1, 1 ),
- myValues( 1, 1 )
-{
- myExpr = ExprIntrp_GenExp::Create();
- myExpr->Process( ( Standard_CString )str );
- if( !myExpr->IsDone() )
- myExpr.Nullify();
-
- myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" );
-}
-
-FunctionExpr::~FunctionExpr()
-{
-}
-
-Standard_Boolean FunctionExpr::Value( Standard_Real T, Standard_Real& F )
-{
- double f;
- Standard_Boolean res = value( T, f );
- F = f;
- return res;
-}
-
-bool FunctionExpr::value( const double t, double& f )
-{
- if( myExpr.IsNull() )
- return false;
-
- CASCatch_CatchSignals aCatchSignals;
- aCatchSignals.Activate();
-
- myValues.ChangeValue( 1 ) = t;
- bool ok = true;
- CASCatch_TRY {
- f = myExpr->Expression()->Evaluate( myVars, myValues );
- }
- CASCatch_CATCH(CASCatch_Failure) {
- aCatchSignals.Deactivate();
- Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
- f = 0.0;
- }
-
- aCatchSignals.Deactivate();
- ok = Function::value( t, f ) && ok;
- return ok;
-}
-
-double FunctionExpr::integral( const double a, const double b )
-{
- double res = 0.0;
- CASCatch_TRY
- {
- math_GaussSingleIntegration _int( *this, a, b, 20 );
- if( _int.IsDone() )
- res = _int.Value();
- }
- CASCatch_CATCH(CASCatch_Failure)
- {
- res = 0.0;
- MESSAGE( "Exception in integral calculating" );
- }
- return res;
-}
-
-
-
-
-
-
-
-double dihotomySolve( Function& f, const double val, const double _start, const double _fin, const double eps, bool& ok )
-{
- double start = _start, fin = _fin, start_val, fin_val; bool ok1, ok2;
- ok1 = f.value( start, start_val );
- ok2 = f.value( fin, fin_val );
-
- if( !ok1 || !ok2 )
- {
- ok = false;
- return 0.0;
- }
-
- bool start_pos = start_val>=val, fin_pos = fin_val>=val;
- ok = true;
-
- while( fin-start>eps )
- {
- double mid = ( start+fin )/2.0, mid_val;
- ok = f.value( mid, mid_val );
- if( !ok )
- return 0.0;
-
-// char buf[1024];
-// sprintf( buf, "start=%f\nfin=%f\nmid_val=%f\n", float( start ), float( fin ), float( mid_val ) );
-// MESSAGE( buf );
-
- bool mid_pos = mid_val>=val;
- if( start_pos!=mid_pos )
- {
- fin_pos = mid_pos;
- fin = mid;
- }
- else if( fin_pos!=mid_pos )
- {
- start_pos = mid_pos;
- start = mid;
- }
- else
- break;
- }
- return (start+fin)/2.0;
-}
-
static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last,
double length, bool theReverse,
int nbSeg, Function& func,
list<double>& theParams)
{
OSD::SetSignal( true );
+
if( nbSeg<=0 )
return false;
int nbPnt = 1 + nbSeg;
vector<double> x(nbPnt, 0.);
- x[0] = 0.0;
- double J = func.integral( 0.0, 1.0 ) / nbSeg;
- bool ok;
- for( int i=1; i<nbSeg; i++ )
- {
- FunctionIntegral f_int( &func, x[i-1] );
- x[i] = dihotomySolve( f_int, J, x[i-1], 1.0, 1E-4, ok );
- if( !ok )
- return false;
- }
+ if( !buildDistribution( func, 0.0, 1.0, nbSeg, x, 1E-4 ) )
+ return false;
- x[nbSeg] = 1.0;
MESSAGE( "Points:\n" );
char buf[1024];
for( int i=0; i<=nbSeg; i++ )
break;
case StdMeshers_NumberOfSegments::DT_TabFunc:
{
- FunctionTable func(_vvalue[ TAB_FUNC_IND ], (bool)_ivalue[ EXP_MODE_IND ]);
+ FunctionTable func(_vvalue[ TAB_FUNC_IND ], _ivalue[ CONV_MODE_IND ]);
return computeParamByFunc(C3d, f, l, length, theReverse,
_ivalue[ NB_SEGMENTS_IND ], func,
theParams);
break;
case StdMeshers_NumberOfSegments::DT_ExprFunc:
{
- FunctionExpr func(_svalue[ EXPR_FUNC_IND ].c_str(), (bool)_ivalue[ EXP_MODE_IND ]);
+ FunctionExpr func(_svalue[ EXPR_FUNC_IND ].c_str(), _ivalue[ CONV_MODE_IND ]);
return computeParamByFunc(C3d, f, l, length, theReverse,
_ivalue[ NB_SEGMENTS_IND ], func,
theParams);
enum IValueIndex {
NB_SEGMENTS_IND = 0,
DISTR_TYPE_IND = 1,
- EXP_MODE_IND = 2
+ CONV_MODE_IND = 2
};
enum VValueIndex {
LIB = libStdMeshersGUI.la
LIB_SRC = \
StdMeshersGUI.cxx \
- StdMeshersGUI_CreateHypothesisDlg.cxx \
- StdMeshersGUI_CreateStdHypothesisDlg.cxx \
- StdMeshersGUI_Parameters.cxx
+ StdMeshersGUI_StdHypothesisCreator.cxx \
+ StdMeshersGUI_DistrPreview.cxx \
+ StdMeshersGUI_DistrTable.cxx \
+ StdMeshersGUI_NbSegmentsCreator.cxx
LIB_MOC = \
- StdMeshersGUI_CreateHypothesisDlg.h \
- StdMeshersGUI_CreateStdHypothesisDlg.h
+ StdMeshersGUI_StdHypothesisCreator.h \
+ StdMeshersGUI_DistrPreview.h \
+ StdMeshersGUI_DistrTable.h \
+ StdMeshersGUI_NbSegmentsCreator.h
-EXPORT_HEADERS = StdMeshersGUI_CreateHypothesisDlg.h \
- StdMeshersGUI_Parameters.h
+EXPORT_HEADERS =
LIB_CLIENT_IDL = \
SALOME_Exception.idl \
SMESH_Hypothesis.idl \
- SMESH_BasicHypothesis.idl
+ SMESH_BasicHypothesis.idl \
+ SMESH_Mesh.idl
## pb in dependencies search
LIB_CLIENT_IDL += \
+ SALOMEDS.idl \
SALOME_GenericObj.idl \
SALOME_Component.idl \
GEOM_Gen.idl
CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \
-I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \
$(BOOST_CPPFLAGS) $(QWT_INCLUDES)
+
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
-
-#$(OCC_CXXFLAGS)
-LDFLAGS += -lSMESH -lVTKViewer -lSalomeApp -lSMESHObject -lSMESHFiltersSelection $(OCC_KERNEL_LIBS) -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome $(QWT_LIBS)
+LDFLAGS += -lSMESH -lVTKViewer -lSalomeApp -lSMESHObject -lSMESHFiltersSelection $(OCC_KERNEL_LIBS) \
+ -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome \
+ $(QWT_LIBS)
@CONCLUDE@
//
//
// File : StdMeshersGUI.cxx
-// Author : Julia DOROVSKIKH
+// Author : Alexander SOLOVYOV
// Module : SMESH
// $Header$
-#include "SALOMEconfig.h"
-#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+#include "StdMeshersGUI_StdHypothesisCreator.h"
+#include "StdMeshersGUI_NbSegmentsCreator.h"
-#include "SMESHGUI.h"
-#include "SMESHGUI_Utils.h"
-#include "SMESHGUI_Hypotheses.h"
-#include "SMESHGUI_HypothesesUtils.h"
-
-#include "SMESHGUI_aParameterDlg.h"
-#include "StdMeshersGUI_Parameters.h"
-#include "StdMeshersGUI_CreateStdHypothesisDlg.h"
-
-#include "SUIT_Desktop.h"
-#include "SUIT_ResourceMgr.h"
-
-#include <SalomeApp_Tools.h>
-
-#include <qobject.h>
-
-#include "utilities.h"
-
-using namespace std;
-
-//=============================================================================
-/*! class HypothesisCreator
- *
- */
//=============================================================================
-class StdMeshersGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
-{
- public:
- StdMeshersGUI_HypothesisCreator (const QString& aHypType,
- const QString& aServerLibName,
- SMESHGUI* aSMESHGUI)
- : myHypType(aHypType),
- myServerLibName(aServerLibName),
- mySMESHGUI(aSMESHGUI) {}
-
- virtual void CreateHypothesis (const bool isAlgo, QWidget* parent = 0);
- virtual void EditHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp);
-
- private:
- QString myHypType;
- QString myServerLibName;
- SMESHGUI* mySMESHGUI;
-};
-
-//=============================================================================
-/*! HypothesisCreator::CreateHypothesis
+/*! GetHypothesisCreator
*
*/
//=============================================================================
-void StdMeshersGUI_HypothesisCreator::CreateHypothesis
- (bool isAlgo, QWidget* parent)
+extern "C"
{
- MESSAGE("StdMeshersGUI_HypothesisCreator::CreateHypothesis");
-
- // Get default name for hypothesis/algorithm creation
- char* sHypType = (char*)myHypType.latin1();
- HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType);
- QString aHypName;
- if (aHypData)
- aHypName = aHypData->Label;
- else
- aHypName = myHypType;
-
- // Create hypothesis/algorithm
- if (isAlgo)
- {
- SMESH::CreateHypothesis(myHypType, aHypName, isAlgo);
- }
- else
+ SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& aHypType )
{
- if ( StdMeshersGUI_Parameters::HasParameters( myHypType ))
- {
- // Show Dialog for hypothesis creation
- StdMeshersGUI_CreateStdHypothesisDlg *aDlg =
- new StdMeshersGUI_CreateStdHypothesisDlg(myHypType, parent, "");
- /* Move widget on the botton right corner of main widget */
-// int x, y ;
-// mySMESHGUI->DefineDlgPosition( aDlg, x, y ) ;
-// aDlg->move( x, y ) ;
- aDlg->exec() ; /* displays Dialog */
- }
+ if( aHypType=="NumberOfSegments" )
+ return new StdMeshersGUI_NbSegmentsCreator();
else
- SMESH::CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI
+ return new StdMeshersGUI_StdHypothesisCreator( aHypType );
}
}
-
-//=============================================================================
-/*! HypothesisCreator::EditHypothesis
- *
- */
-//=============================================================================
-void StdMeshersGUI_HypothesisCreator::EditHypothesis
- (SMESH::SMESH_Hypothesis_ptr theHyp)
-{
- MESSAGE("StdMeshersGUI_HypothesisCreator::EditHypothesis");
-
- SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis(theHyp);
-
- list<SMESHGUI_aParameterPtr> paramList;
- StdMeshersGUI_Parameters::GetParameters( theHyp, paramList );
-
- bool modified = false;
- if ( SMESHGUI_aParameterDlg::Parameters( SMESHGUI::GetSMESHGUI(), paramList, QObject::tr("SMESH_VALUE")) )
- {
- try
- {
- modified = StdMeshersGUI_Parameters::SetParameters( theHyp, paramList );
- }
- catch (const SALOME::SALOME_Exception& S_ex)
- {
- SalomeApp_Tools::QtCatchCorbaException(S_ex);
- return;
- }
- }
-
- if ( modified ) {
- //set new Attribute Comment for hypothesis which parameters were modified
- QString aParams = "";
- StdMeshersGUI_Parameters::GetParameters( theHyp, paramList, aParams );
- _PTR(SObject) SHyp = SMESH::FindSObject(theHyp);
- if (SHyp)
- if (!aParams.isEmpty()) {
- SMESH::SetValue(SHyp, aParams);
- //mySMESHGUI->GetActiveStudy()->updateObjBrowser(true);
- }
-
- if ( listSOmesh.size() > 0 ) {
- _PTR(SObject) submSO = listSOmesh[0];
- SMESH::SMESH_Mesh_var aMesh =
- SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(submSO);
- SMESH::SMESH_subMesh_var aSubMesh =
- SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(submSO);
- if ( !aSubMesh->_is_nil() )
- aMesh = aSubMesh->GetFather();
- _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
- SMESH::ModifiedMesh( meshSO, false);
- }
- }
-}
-
-//=============================================================================
-/*! GetHypothesisCreator
- *
- */
-//=============================================================================
-extern "C"
-{
- SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator
- (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI)
- {
- return new StdMeshersGUI_HypothesisCreator
- (aHypType, aServerLibName, aSMESHGUI);
- }
-}
+++ /dev/null
-// SMESH StdMeshersGUI : GUI for StdMeshers plugin
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : StdMeshersGUI_CreateHypothesisDlg.cxx
-// Moved here from SMESHGUI_CreateHypothesisDlg.cxx
-// Author : Nicolas REJNERI
-// Module : SMESH
-// $Header$
-
-#include "StdMeshersGUI_CreateHypothesisDlg.h"
-#include "StdMeshersGUI_Parameters.h"
-#include "SMESHGUI.h"
-#include "SMESHGUI_SpinBox.h"
-#include "SMESHGUI_Hypotheses.h"
-#include "SMESHGUI_HypothesesUtils.h"
-#include "SMESHGUI_Utils.h"
-#include "SMESHGUI_FunctionPreview.h"
-
-#include "SUIT_Application.h"
-#include "SUIT_Desktop.h"
-#include "SUIT_MessageBox.h"
-#include "SUIT_OverrideCursor.h"
-#include "utilities.h"
-
-#include "SalomeApp_Tools.h"
-#include "SalomeApp_Application.h"
-
-#include "OB_Browser.h"
-
-// QT Includes
-#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-#include <qpixmap.h>
-#include <qspinbox.h>
-#include <qtextedit.h>
-#include <qcombobox.h>
-#include <qcheckbox.h>
-
-using namespace std;
-
-//=================================================================================
-// class : StdMeshersGUI_CreateHypothesisDlg()
-// purpose : Constructs a StdMeshersGUI_CreateHypothesisDlg which is a child of 'parent', with the
-// name 'name' and widget flags set to 'f'.
-// The dialog will by default be modeless, unless you set 'modal' to
-// TRUE to construct a modal dialog.
-//=================================================================================
-StdMeshersGUI_CreateHypothesisDlg::StdMeshersGUI_CreateHypothesisDlg (const QString& hypType,
- QWidget* parent,
- const char* name,
- bool modal,
- WFlags /*fl*/)
- : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), myHypType( hypType )
-{
-}
-
-//=======================================================================
-//function : CreateDlgLayout
-//purpose :
-//=======================================================================
-
-void StdMeshersGUI_CreateHypothesisDlg::CreateDlgLayout(const QString & theCaption,
- const QPixmap & theHypIcon,
- const QString & theHypTypeName)
-{
- setCaption( theCaption );
-
- setSizeGripEnabled( TRUE );
- QVBoxLayout* StdMeshersGUI_CreateHypothesisDlgLayout = new QVBoxLayout( this );
- StdMeshersGUI_CreateHypothesisDlgLayout->setSpacing( 6 );
- StdMeshersGUI_CreateHypothesisDlgLayout->setMargin( 11 );
-
- /***************************************************************/
- QFrame* titFrame = new QFrame( this );
- QHBoxLayout* titLay = new QHBoxLayout( titFrame, 0, 0 );
-
- iconLabel = new QLabel( titFrame );
- iconLabel->setPixmap( theHypIcon );
- iconLabel->setScaledContents( false );
- iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
- typeLabel = new QLabel( titFrame );
- typeLabel->setText( theHypTypeName );
- titLay->addWidget( iconLabel, 0 );
- titLay->addWidget( typeLabel, 0 );
- titLay->addStretch( 1 );
-
- StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( titFrame, 0);
-
- /***************************************************************/
- GroupC1 = new QGroupBox( this, "GroupC1" );
- GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
- GroupC1->setColumnLayout(0, Qt::Vertical );
- GroupC1->layout()->setSpacing( 0 );
- GroupC1->layout()->setMargin( 0 );
- QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
- GroupC1Layout->setAlignment( Qt::AlignTop );
- GroupC1Layout->setSpacing( 6 );
- GroupC1Layout->setMargin( 11 );
-
- TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" );
- TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) );
- GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 );
-
- LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" );
- GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 );
-
- myParamMap.clear();
- std::list<SMESHGUI_aParameterPtr> aParamList;
- GetParameters( myHypType, aParamList );
- ASSERT( !aParamList.empty() );
-
- /* Spin boxes with labels */
- list<SMESHGUI_aParameterPtr>::iterator paramIt = aParamList.begin();
- int row;
- for ( row = 1; paramIt != aParamList.end(); paramIt++ , row++ )
- {
- SMESHGUI_aParameterPtr param = (*paramIt);
- QLabel * label = new QLabel( GroupC1, "TextLabel" );
- GroupC1Layout->addWidget( label, row, 0 );
- label->setText( param->Label() );
- QWidget* aWidget = param->CreateWidget( GroupC1 );
-
- if ( aWidget ) {
- GroupC1Layout->addWidget( aWidget, row, 1 );
- aWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
- aWidget->setMinimumSize( 150, 0 );
-
- QString sig = param->sigValueChanged();
- if( !sig.isEmpty() /* && param->GetType()!=SMESHGUI_aParameter::TABLE*/ )
- connect( aWidget, sig.latin1(), this, SLOT( onValueChanged() ) );
-
- param->InitializeWidget( aWidget );
-
- ParamInfo info;
- info.editor = aWidget;
- info.label = label;
- info.order = row-1;
-
- myParamMap.insert( param, info );
- }
- }
- myPreview = new SMESHGUI_FunctionPreview( GroupC1 );
- myPreview->hide();
- GroupC1Layout->addWidget( myPreview, row, 1 );
-
- StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( GroupC1, 1 );
-
- /***************************************************************/
- GroupButtons = new QGroupBox( this, "GroupButtons" );
- GroupButtons->setColumnLayout(0, Qt::Vertical );
- GroupButtons->layout()->setSpacing( 0 );
- GroupButtons->layout()->setMargin( 0 );
- QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
- GroupButtonsLayout->setAlignment( Qt::AlignTop );
- GroupButtonsLayout->setSpacing( 6 );
- GroupButtonsLayout->setMargin( 11 );
- buttonOk = new QPushButton( GroupButtons, "buttonOk" );
- buttonOk->setText( tr( "SMESH_BUT_OK" ) );
- buttonOk->setAutoDefault( TRUE );
- buttonOk->setDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
- buttonApply = new QPushButton( GroupButtons, "buttonApply" );
- buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
- buttonApply->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
- QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
- GroupButtonsLayout->addItem( spacer, 0, 2 );
- buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
- buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
- buttonCancel->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
- StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( GroupButtons, 0 );
-
- /***************************************************************/
- Init() ;
-}
-
-
-//=================================================================================
-// function : ~StdMeshersGUI_CreateHypothesisDlg()
-// purpose : Destroys the object and frees any allocated resources
-//=================================================================================
-StdMeshersGUI_CreateHypothesisDlg::~StdMeshersGUI_CreateHypothesisDlg()
-{
- // no need to delete child widgets, Qt does it all for us
-}
-
-
-//=================================================================================
-// function : Init()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateHypothesisDlg::Init()
-{
- ParameterMap::const_iterator anIt = myParamMap.begin(),
- aLast = myParamMap.end();
- for( ; anIt!=aLast; anIt++ )
- UpdateShown( anIt.key() );
-
- mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
-
- char* sHypType = const_cast<char*>(myHypType.latin1());
- HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType);
- LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : QString("") );
-
- mySMESHGUI->SetActiveDialogBox( (QDialog*)this );
-
- /* signals and slots connections */
- connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) );
- connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ;
- connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) );
-
- connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
- connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
-
- /* Move widget on the botton right corner of main widget */
- int x, y ;
- mySMESHGUI->DefineDlgPosition( this, x, y ) ;
- this->move( x, y ) ;
- this->show() ; /* displays Dialog */
-}
-
-
-//=================================================================================
-// function : ClickOnOk()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateHypothesisDlg::ClickOnOk()
-{
- if ( ClickOnApply() )
- ClickOnCancel() ;
-}
-
-//=================================================================================
-// function : ClickOnApply()
-// purpose :
-//=================================================================================
-bool StdMeshersGUI_CreateHypothesisDlg::ClickOnApply()
-{
- if ( !mySMESHGUI || mySMESHGUI->isActiveStudyLocked() )
- return false;
-
- QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace();
- if ( myHypName.isEmpty() ) {
- SUIT_MessageBox::warn1 (this, tr( "SMESH_WRN_WARNING" ),
- tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) );
- return false;
- }
-
- SUIT_OverrideCursor wc;
-
- SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow
- ( SMESH::CreateHypothesis( myHypType, myHypName, false ) ); // isAlgorithm
-
- try {
-
- list<SMESHGUI_aParameterPtr> aParamList;
- ParameterMap::const_iterator anIt = myParamMap.begin(),
- aLast = myParamMap.end();
- for( int i=0; i<myParamMap.count(); i++ )
- for( anIt=myParamMap.begin(); anIt!=aLast; anIt++ )
- if( (*anIt).order==i )
- {
- anIt.key()->TakeValue( anIt.data().editor );
- aParamList.push_back( anIt.key() );
- break;
- }
-
- if( !SetParameters( Hyp, aParamList ) )
- return false;
-
- //set new Attribute Comment for hypothesis which parameters were set
- QString aParams = "";
- StdMeshersGUI_Parameters::GetParameters( Hyp.in(), aParamList, aParams );
- _PTR(SObject) SHyp = SMESH::FindSObject(Hyp.in());
- if (SHyp)
- if (!aParams.isEmpty())
- {
- SMESH::SetValue(SHyp, aParams);
- mySMESHGUI->getApp()->objectBrowser()->updateTree();
- }
- }
- catch (const SALOME::SALOME_Exception& S_ex)
- {
- wc.suspend();
-
- _PTR(SObject) SHyp = SMESH::FindSObject(Hyp.in());
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- if( aStudy && !aStudy->GetProperties()->IsLocked() )
- {
- _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
- aBuilder->RemoveObjectWithChildren( SHyp );
- mySMESHGUI->updateObjBrowser( true, 0 );
- }
-
- SalomeApp_Tools::QtCatchCorbaException(S_ex);
- return false;
- }
- return true;
-}
-
-//=================================================================================
-// function : ClickOnCancel()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateHypothesisDlg::ClickOnCancel()
-{
- close();
-}
-
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateHypothesisDlg::DeactivateActiveDialog()
-{
-// iconLabel->setEnabled(false) ;
-// typeLabel->setEnabled(false) ;
-// GroupC1->setEnabled(false) ;
-// GroupButtons->setEnabled(false) ;
- setEnabled(false);
-}
-
-
-//=================================================================================
-// function : ActivateThisDialog()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateHypothesisDlg::ActivateThisDialog()
-{
- if (! isEnabled() ) {
- mySMESHGUI->EmitSignalDeactivateDialog() ;
-// iconLabel->setEnabled(true) ;
-// typeLabel->setEnabled(true) ;
-// GroupC1->setEnabled(true) ;
-// GroupButtons->setEnabled(true) ;
- setEnabled(true) ;
- }
-}
-
-
-//=================================================================================
-// function : enterEvent()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateHypothesisDlg::enterEvent(QEvent* e)
-{
- ActivateThisDialog() ;
-}
-
-
-//=================================================================================
-// function : closeEvent()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateHypothesisDlg::closeEvent( QCloseEvent* e )
-{
- mySMESHGUI->ResetState();
- QDialog::closeEvent( e );
-}
-
-//=================================================================================
-// function : onValueChanged()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateHypothesisDlg::onValueChanged()
-{
- if( sender()->inherits( "QWidget" ) )
- {
- QWidget* w = ( QWidget* )sender();
-
- SMESHGUI_aParameterPtr param;
-
- ParameterMap::const_iterator anIt = myParamMap.begin(),
- aLast = myParamMap.end();
- for( ; anIt!=aLast; anIt++ )
- if( anIt.data().editor == w )
- {
- param = anIt.key();
- param->TakeValue( w );
-
- SMESHGUI_strParameter* str_param = dynamic_cast<SMESHGUI_strParameter*>( param.operator->() );
- SMESHGUI_tableParameter* tab_param = dynamic_cast<SMESHGUI_tableParameter*>( param.operator->() );
- SMESHGUI_boolParameter* bool_param = dynamic_cast<SMESHGUI_boolParameter*>( param.operator->() );
-
- if( str_param && str_param->needPreview() )
- {
- QString val; str_param->GetNewText( val );
- myPreview->setParams( val );
- }
- else if( tab_param && tab_param->needPreview() )
- {
- SMESH::double_array d;
- tab_param->data( d );
- myPreview->setParams( d );
- }
- else if( bool_param && bool_param->needPreview() )
- {
- int exp=0;
- bool_param->GetNewInt( exp );
- myPreview->setIsExp( exp );
- }
- UpdateShown( param );
- break;
- }
- }
-}
-
-//=================================================================================
-// function : UpdateShown()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateHypothesisDlg::UpdateShown( const SMESHGUI_aParameterPtr param )
-{
- SMESHGUI_dependParameter* depPar = dynamic_cast<SMESHGUI_enumParameter*>( param.get() );
- if( !depPar )
- depPar = dynamic_cast<SMESHGUI_boolParameter*>( param.get() );
-
- if( !depPar )
- return;
-
- SMESHGUI_dependParameter::ShownMap& map = depPar->shownMap();
- if( map.isEmpty() )
- return;
-
- int val;
- depPar->TakeValue( myParamMap[ param ].editor );
- depPar->GetNewInt( val );
-
- bool hasValue = map.contains( val );
-
- ParameterMap::const_iterator anIt = myParamMap.begin(),
- aLast = myParamMap.end();
- bool preview = false;
- for( ; anIt!=aLast; anIt++ )
- {
- bool shown = hasValue && map[ val ].contains( (*anIt).order );
- (*anIt).editor->setShown( shown );
- (*anIt).label->setShown( shown );
- if( shown )
- {
- SMESHGUI_strParameter* str_param = dynamic_cast<SMESHGUI_strParameter*>( anIt.key().operator->() );
- SMESHGUI_tableParameter* tab_param = dynamic_cast<SMESHGUI_tableParameter*>( anIt.key().operator->() );
- preview = preview || ( str_param && str_param->needPreview() ) || ( tab_param && tab_param->needPreview() );
- }
- }
- myPreview->setShown( preview );
-}
+++ /dev/null
-// SMESH SMESHGUI : GUI for SMESH component
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : StdMeshersGUI_CreateHypothesisDlg.h
-// Module : SMESH
-// $Header$
-
-#ifndef DIALOGBOX_CreateHypothesisDlg_H
-#define DIALOGBOX_CreateHypothesisDlg_H
-
-// QT Includes
-#include <qdialog.h>
-#include <qmap.h>
-#include <qpair.h>
-
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
-
-#include "SMESHGUI_aParameter.h"
-
-#include <list>
-
-class QGroupBox;
-class QLabel;
-class QLineEdit;
-class QPushButton;
-class SMESHGUI;
-class SMESHGUI_SpinBox;
-class SMESHGUI_FunctionPreview;
-
-//=================================================================================
-// class : StdMeshersGUI_CreateHypothesisDlg
-// purpose :
-//=================================================================================
-class StdMeshersGUI_CreateHypothesisDlg : public QDialog
-{
- Q_OBJECT
-
-public:
- StdMeshersGUI_CreateHypothesisDlg (const QString& hypType,
- QWidget* parent = 0,
- const char* name = 0,
- bool modal = FALSE,
- WFlags fl = 0);
- ~StdMeshersGUI_CreateHypothesisDlg ();
-
-protected:
-
- void CreateDlgLayout(const QString & caption,
- const QPixmap & hypIcon,
- const QString & hypTypeName);
-
- virtual void GetParameters( const QString& hypType,
- std::list<SMESHGUI_aParameterPtr>& ) = 0;
-
- virtual bool SetParameters( SMESH::SMESH_Hypothesis_ptr theHyp,
- const std::list<SMESHGUI_aParameterPtr> & params ) = 0;
-
-protected slots:
- virtual void onValueChanged();
-
-private:
- void UpdateShown( const SMESHGUI_aParameterPtr );
- void Init() ;
- void closeEvent( QCloseEvent* e ) ;
- void enterEvent ( QEvent * ) ;
-
- SMESHGUI* mySMESHGUI;
- QString myHypType;
-
- typedef struct
- {
- QWidget* editor;
- QLabel* label;
- int order;
-
- } ParamInfo;
-
- typedef QMap< SMESHGUI_aParameterPtr, ParamInfo > ParameterMap;
- ParameterMap myParamMap;
-
- QLabel* iconLabel;
- QLabel* typeLabel;
- QGroupBox* GroupC1;
- QLabel* TextLabel_NameHypothesis ;
- QLineEdit* LineEdit_NameHypothesis ;
- QLabel* TextLabel_Length ;
- QGroupBox* GroupButtons;
- QPushButton* buttonOk;
- QPushButton* buttonApply;
- QPushButton* buttonCancel;
- SMESHGUI_FunctionPreview* myPreview;
-
-private slots:
-
- void ClickOnOk();
- void ClickOnCancel();
- bool ClickOnApply();
- void DeactivateActiveDialog() ;
- void ActivateThisDialog() ;
-};
-
-#endif // DIALOGBOX_LOCAL_LENGTH_H
+++ /dev/null
-// SMESH StdMeshersGUI : GUI for StdMeshers plugin
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : StdMeshersGUI_CreateStdHypothesisDlg.cxx
-// Moved here from SMESHGUI_CreateStdHypothesisDlg.cxx
-// Author : Nicolas REJNERI
-// Module : SMESH
-// $Header$
-
-using namespace std;
-#include "StdMeshersGUI_CreateStdHypothesisDlg.h"
-#include "StdMeshersGUI_Parameters.h"
-#include "SMESHGUI.h"
-#include "SMESHGUI_Hypotheses.h"
-
-#include "utilities.h"
-
-#include "SUIT_MessageBox.h"
-#include "SUIT_ResourceMgr.h"
-#include "SUIT_OverrideCursor.h"
-#include "SUIT_Desktop.h"
-
-//=================================================================================
-// class : StdMeshersGUI_CreateStdHypothesisDlg()
-// purpose :
-//=================================================================================
-StdMeshersGUI_CreateStdHypothesisDlg::StdMeshersGUI_CreateStdHypothesisDlg (const QString& hypType,
- QWidget* parent,
- const char* name,
- bool /*modal*/,
- WFlags fl)
- : StdMeshersGUI_CreateHypothesisDlg (hypType, parent, name, true, fl)
-{
- QString hypTypeStr;
- if (hypType.compare("LocalLength") == 0)
- hypTypeStr = "LOCAL_LENGTH";
- else if (hypType.compare("NumberOfSegments") == 0)
- hypTypeStr = "NB_SEGMENTS";
- else if (hypType.compare("MaxElementArea") == 0)
- hypTypeStr = "MAX_ELEMENT_AREA";
- else if (hypType.compare("MaxElementVolume") == 0)
- hypTypeStr = "MAX_ELEMENT_VOLUME";
- else if (hypType.compare("StartEndLength") == 0)
- hypTypeStr = "START_END_LENGTH";
- else if (hypType.compare("Deflection1D") == 0)
- hypTypeStr = "DEFLECTION1D";
- else if (hypType.compare("Arithmetic1D") == 0)
- hypTypeStr = "ARITHMETIC_1D";
- else
- return;
-
- QString caption( tr ( QString( "SMESH_%1_TITLE" ).arg( hypTypeStr )));
- QString hypTypeName( tr ( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeStr )));
- QString hypIconName( tr ( QString( "ICON_DLG_%1" ).arg( hypTypeStr )));
-
- CreateDlgLayout(caption,
- SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName ),
- hypTypeName);
-}
-
-//=================================================================================
-// function : ~StdMeshersGUI_CreateStdHypothesisDlg()
-// purpose : Destroys the object and frees any allocated resources
-//=================================================================================
-StdMeshersGUI_CreateStdHypothesisDlg::~StdMeshersGUI_CreateStdHypothesisDlg()
-{
- // no need to delete child widgets, Qt does it all for us
-}
-//=================================================================================
-// function : FillParameters()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateStdHypothesisDlg::GetParameters
- (const QString & hypType,
- std::list<SMESHGUI_aParameterPtr> & params)
-{
- StdMeshersGUI_Parameters::GetParameters( hypType, params );
-}
-
-//=================================================================================
-// function : SetParameters()
-// purpose :
-//=================================================================================
-bool StdMeshersGUI_CreateStdHypothesisDlg::SetParameters
- (SMESH::SMESH_Hypothesis_ptr theHyp, const list<SMESHGUI_aParameterPtr> & params)
-{
- StdMeshersGUI_Parameters::SetParameters( theHyp, params );
- return true;
-}
+++ /dev/null
-// SMESH SMESHGUI : GUI for SMESH component
-//
-// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : StdMeshersGUI_CreateStdHypothesisDlg.h
-// Moved here from SMESHGUI_CreateStdHypothesisDlg.h
-// Author : Nicolas REJNERI
-// Module : SMESH
-// $Header$
-
-#ifndef DIALOGBOX_CreateStdHypothesisDlg_H
-#define DIALOGBOX_CreateStdHypothesisDlg_H
-
-#include "StdMeshersGUI_CreateHypothesisDlg.h"
-
-//=================================================================================
-// class : StdMeshersGUI_CreateStdHypothesisDlg
-// purpose :
-//=================================================================================
-class StdMeshersGUI_CreateStdHypothesisDlg : public StdMeshersGUI_CreateHypothesisDlg
-{
- Q_OBJECT
-
- public:
- StdMeshersGUI_CreateStdHypothesisDlg (const QString& hypType,
- QWidget* parent = 0,
- const char* name = 0,
- bool modal = FALSE,
- WFlags fl = 0);
- ~StdMeshersGUI_CreateStdHypothesisDlg ();
-
- private:
- virtual void GetParameters(const QString & hypType,
- std::list<SMESHGUI_aParameterPtr> & params);
-
- virtual bool SetParameters(SMESH::SMESH_Hypothesis_ptr theHyp,
- const std::list<SMESHGUI_aParameterPtr> & params);
-};
-
-#endif
--- /dev/null
+
+#include "StdMeshersGUI_DistrPreview.h"
+#include <Expr_NamedUnknown.hxx>
+#include <Expr_GeneralExpression.hxx>
+#include <CASCatch_CatchSignals.hxx>
+#include <CASCatch_Failure.hxx>
+#include <CASCatch_ErrorHandler.hxx>
+#include <OSD.hxx>
+
+StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::StdMeshers_NumberOfSegments_ptr h )
+: QwtPlot( p ),
+ myPoints( 50 ),
+ myIsTable( false ),
+ myVars( 1, 1 ),
+ myValues( 1, 1 ),
+ myConv( CUT_NEGATIVE ),
+ myIsDone( true ),
+ myNbSeg( 1 )
+{
+ myHypo = StdMeshers::StdMeshers_NumberOfSegments::_duplicate( h );
+ myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" );
+ myCurve1 = insertCurve( QString() );
+ myCurve2 = insertCurve( QString() );
+ myMsg = insertMarker( new QwtPlotMarker( this ) );
+ setMarkerPos( myMsg, 0.5, 0.5 );
+ setMarkerLabelPen( myMsg, QPen( Qt::red, 1 ) );
+ QFont f = markerFont( myMsg );
+ f.setPointSize( 14 );
+ f.setBold( true );
+ setMarkerFont( myMsg, f );
+ setCurvePen( myCurve1, QPen( Qt::red, 1 ) );
+
+ QColor dc = Qt::blue;
+ setCurvePen( myCurve2, QPen( dc, 1 ) );
+ setCurveSymbol( myCurve2, QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) );
+}
+
+StdMeshersGUI_DistrPreview::~StdMeshersGUI_DistrPreview()
+{
+}
+
+bool StdMeshersGUI_DistrPreview::isTableFunc() const
+{
+ return myIsTable;
+}
+
+void StdMeshersGUI_DistrPreview::tableFunc( SMESH::double_array& f ) const
+{
+ f = myTableFunc;
+}
+
+QString StdMeshersGUI_DistrPreview::function() const
+{
+ return myFunction;
+}
+
+int StdMeshersGUI_DistrPreview::nbSeg() const
+{
+ return myNbSeg;
+}
+
+int StdMeshersGUI_DistrPreview::pointsCount() const
+{
+ return myPoints;
+}
+
+void StdMeshersGUI_DistrPreview::setConversion( Conversion conv, const bool upd )
+{
+ myConv = conv;
+ if( upd )
+ update();
+}
+
+bool StdMeshersGUI_DistrPreview::setParams( const QString& func, const int nbSeg, const int points, const bool upd )
+{
+ myIsTable = false;
+ myTableFunc = SMESH::double_array();
+ myFunction = func.isEmpty() ? "0" : func;
+ myPoints = points>0 ? points : 2;
+ myNbSeg = nbSeg>0 ? nbSeg : 1;
+ bool res = init( func );
+ if( upd )
+ update();
+ return res;
+}
+
+bool StdMeshersGUI_DistrPreview::setParams( const SMESH::double_array& f, const int nbSeg, const bool upd )
+{
+ myIsTable = true;
+ myTableFunc = f;
+ if( myTableFunc.length()%2==1 )
+ myTableFunc.length( myTableFunc.length()-1 );
+
+ myFunction = "0";
+ myPoints = myTableFunc.length()/2;
+ myNbSeg = nbSeg>0 ? nbSeg : 1;
+
+ if( upd )
+ update();
+
+ return myTableFunc.length()>0;
+}
+
+bool StdMeshersGUI_DistrPreview::createTable( SMESH::double_array& func )
+{
+ if( myExpr.IsNull() )
+ {
+ func.length( 0 );
+ return false;
+ }
+
+ const double xmin = 0.0, xmax = 1.0;
+
+ double d = (xmax-xmin)/double(myPoints-1);
+ func.length( 2*myPoints );
+ int err = 0;
+ for( int i=0, j=0; i<myPoints; j++ )
+ {
+ bool ok;
+ double t = xmin + d*j, f = funcValue( t, ok );
+ if( ok )
+ {
+ func[2*i] = t;
+ func[2*i+1] = f;
+ i++;
+ }
+ else
+ err++;
+ }
+ func.length( func.length()-2*err );
+ return err==0;
+}
+
+void StdMeshersGUI_DistrPreview::update()
+{
+ SMESH::double_array graph, distr;
+ if( isTableFunc() )
+ {
+ myIsDone = true;
+ graph = myTableFunc;
+ }
+ else
+ myIsDone = createTable( graph );
+
+ if( graph.length()>=2 )
+ {
+ StdMeshers::StdMeshers_NumberOfSegments_var h =
+ StdMeshers::StdMeshers_NumberOfSegments::_narrow( myHypo );
+
+ if( !CORBA::is_nil( h.in() ) )
+ {
+ SMESH::double_array* arr = 0;
+ if( isTableFunc() )
+ arr = h->BuildDistributionTab( myTableFunc, myNbSeg, ( int )myConv );
+ else
+ arr = h->BuildDistributionExpr( myFunction.latin1(), myNbSeg, ( int )myConv );
+ if( arr )
+ {
+ distr = *arr;
+ delete arr;
+ }
+ }
+ }
+
+ bool correct = graph.length()>=2 && distr.length()>=2;
+ if( !correct )
+ {
+ showError();
+ return;
+ }
+ else
+ setMarkerLabel( myMsg, QString() );
+
+ int size = graph.length()/2;
+ double* x = new double[size], *y = new double[size];
+ double min_x, max_x, min_y, max_y;
+ for( int i=0; i<size; i++ )
+ {
+ x[i] = graph[2*i];
+ y[i] = graph[2*i+1];
+ if( !convert( y[i] ) )
+ {
+ min_x = 0.0; max_x = 1.0; min_y = 0.0; max_y = 1.0;
+ delete[] x; delete[] y;
+ x = y = 0;
+ showError();
+ return;
+ }
+ if( i==0 || y[i]<min_y )
+ min_y = y[i];
+ if( i==0 || y[i]>max_y )
+ max_y = y[i];
+ if( i==0 || x[i]<min_x )
+ min_x = x[i];
+ if( i==0 || x[i]>max_x )
+ max_x = x[i];
+ }
+
+ setAxisScale( curveXAxis( myCurve1 ), min_x, max_x );
+ setAxisScale( curveYAxis( myCurve1 ), min( 0.0, min_y ), max( 0.0, max_y ) );
+ setCurveData( myCurve1, x, y, size );
+ if( x )
+ delete[] x;
+ if( y )
+ delete[] y;
+ x = y = 0;
+
+ size = distr.length();
+ x = new double[size];
+ y = new double[size];
+ for( int i=0; i<size; i++ )
+ {
+ x[i] = distr[i];
+ y[i] = 0;
+ }
+ setCurveData( myCurve2, x, y, size );
+ delete[] x;
+ delete[] y;
+ x = y = 0;
+ replot();
+}
+
+void StdMeshersGUI_DistrPreview::showError()
+{
+ setAxisScale( curveXAxis( myCurve1 ), 0.0, 1.0 );
+ setAxisScale( curveYAxis( myCurve1 ), 0.0, 1.0 );
+ setCurveData( myCurve1, 0, 0, 0 );
+ setCurveData( myCurve2, 0, 0, 0 );
+ setMarkerLabel( myMsg, tr( "SMESH_INVALID_FUNCTION" ) );
+ replot();
+}
+
+bool isCorrectArg( const Handle( Expr_GeneralExpression )& expr )
+{
+ Handle( Expr_NamedUnknown ) sub = Handle( Expr_NamedUnknown )::DownCast( expr );
+ if( !sub.IsNull() )
+ return sub->GetName()=="t";
+
+ bool res = true;
+ for( int i=1, n=expr->NbSubExpressions(); i<=n && res; i++ )
+ {
+ Handle( Expr_GeneralExpression ) sub = expr->SubExpression( i );
+ Handle( Expr_NamedUnknown ) name = Handle( Expr_NamedUnknown )::DownCast( sub );
+ if( !name.IsNull() )
+ {
+ if( name->GetName()!="t" )
+ res = false;
+ }
+ else
+ res = isCorrectArg( sub );
+ }
+ return res;
+}
+
+bool StdMeshersGUI_DistrPreview::init( const QString& str )
+{
+ CASCatch_CatchSignals aCatchSignals;
+ aCatchSignals.Activate();
+
+ bool parsed_ok = true;
+ CASCatch_TRY
+ {
+ myExpr = ExprIntrp_GenExp::Create();
+ myExpr->Process( ( Standard_CString ) str.latin1() );
+ }
+ CASCatch_CATCH(CASCatch_Failure)
+ {
+ aCatchSignals.Deactivate();
+ Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+ parsed_ok = false;
+ }
+ aCatchSignals.Deactivate();
+
+ bool syntax = false, args = false;
+ if( parsed_ok && myExpr->IsDone() )
+ {
+ syntax = true;
+ args = isCorrectArg( myExpr->Expression() );
+ }
+
+ bool res = parsed_ok && syntax && args;
+ if( !res )
+ myExpr.Nullify();
+ return res;
+}
+
+double StdMeshersGUI_DistrPreview::funcValue( const double t, bool& ok )
+{
+ if( myExpr.IsNull() )
+ return 0;
+
+ myValues.ChangeValue( 1 ) = t;
+
+ ok = true;
+ double res = calc( ok );
+
+ return res;
+}
+
+double StdMeshersGUI_DistrPreview::calc( bool& ok )
+{
+ OSD::SetSignal( true );
+ double res = 0.0;
+
+ CASCatch_CatchSignals aCatchSignals;
+ aCatchSignals.Activate();
+
+ ok = true;
+ CASCatch_TRY {
+ res = myExpr->Expression()->Evaluate( myVars, myValues );
+ }
+ CASCatch_CATCH(CASCatch_Failure) {
+ aCatchSignals.Deactivate();
+ Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+ ok = false;
+ res = 0.0;
+ }
+ aCatchSignals.Deactivate();
+ return res;
+}
+
+bool StdMeshersGUI_DistrPreview::isDone() const
+{
+ return myIsDone;
+}
+
+bool StdMeshersGUI_DistrPreview::convert( double& v ) const
+{
+ CASCatch_CatchSignals aCatchSignals;
+ aCatchSignals.Activate();
+
+ bool ok = true;
+ switch( myConv )
+ {
+ case EXPONENT:
+ {
+ CASCatch_TRY
+ {
+ v = pow( 10.0, v );
+ }
+ CASCatch_CATCH(CASCatch_Failure)
+ {
+ aCatchSignals.Deactivate();
+ Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+ v = 0.0;
+ ok = false;
+ }
+ }
+ break;
+
+ case CUT_NEGATIVE:
+ if( v<0 )
+ v = 0;
+ break;
+ }
+ aCatchSignals.Deactivate();
+ return ok;
+}
--- /dev/null
+
+#ifndef STD_MESHERS_GUI_DISTR_PREVIEW_HEADER
+#define STD_MESHERS_GUI_DISTR_PREVIEW_HEADER
+
+#include <qwt_plot.h>
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+#include <ExprIntrp_GenExp.hxx>
+#include <Expr_Array1OfNamedUnknown.hxx>
+#include <TColStd_Array1OfReal.hxx>
+
+class StdMeshersGUI_DistrPreview : public QwtPlot
+{
+ Q_OBJECT
+
+public:
+ typedef enum { EXPONENT, CUT_NEGATIVE } Conversion;
+
+ StdMeshersGUI_DistrPreview( QWidget*, StdMeshers::StdMeshers_NumberOfSegments_ptr );
+ virtual ~StdMeshersGUI_DistrPreview();
+
+ QString function() const;
+ bool isTableFunc() const;
+ void tableFunc( SMESH::double_array& ) const;
+ int pointsCount() const;
+ int nbSeg() const;
+ bool isDone() const;
+
+ bool setParams( const QString&, const int, const int = 50, const bool = true );
+ bool setParams( const SMESH::double_array&, const int, const bool = true );
+ void setConversion( Conversion, const bool = true );
+
+protected:
+ virtual bool init( const QString& );
+ virtual double funcValue( const double, bool& );
+ virtual bool createTable( SMESH::double_array& );
+ virtual bool convert( double& ) const;
+ void update();
+
+private:
+ double calc( bool& );
+ void showError();
+
+private:
+ QString myFunction;
+ int myPoints, myNbSeg;
+ bool myIsTable;
+ Conversion myConv;
+ SMESH::double_array myTableFunc;
+ long myCurve1, myCurve2, myMsg;
+ Handle(ExprIntrp_GenExp) myExpr;
+ Expr_Array1OfNamedUnknown myVars;
+ TColStd_Array1OfReal myValues;
+ bool myIsDone;
+ StdMeshers::StdMeshers_NumberOfSegments_var myHypo;
+};
+
+#endif
--- /dev/null
+// SMESH StdMeshersGUI
+//
+// Copyright (C) 2003 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : StdMeshersGUI_DistrTable.cxx
+// Module : SMESH
+// $Header$
+
+#include "StdMeshersGUI_DistrTable.h"
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qvalidator.h>
+#include <qlineedit.h>
+
+//=================================================================================
+// class : StdMeshersGUI_DistrTable
+// purpose :
+//=================================================================================
+StdMeshersGUI_DistrTable::StdMeshersGUI_DistrTable( const int rows, QWidget* parent, const char* name )
+: QTable( rows, 2, parent, name )
+{
+ horizontalHeader()->setLabel( 0, "t" );
+ horizontalHeader()->setLabel( 1, "f(t)" );
+ myArgV = new QDoubleValidator( 0.0, 1.0, 3, this );
+ myFuncV = new QDoubleValidator( 0.0, 1E10, 3, this );
+}
+
+StdMeshersGUI_DistrTable::~StdMeshersGUI_DistrTable()
+{
+}
+
+QSize StdMeshersGUI_DistrTable::sizeHint() const
+{
+ if( cachedSizeHint().isValid() )
+ return cachedSizeHint();
+
+ constPolish();
+
+ QSize sh = QScrollView::sizeHint();
+ if( sh.width()<400 )
+ sh.setWidth( 400 );
+ if( sh.height()<200 )
+ sh.setHeight( 200 );
+
+ setCachedSizeHint( sh );
+ return sh;
+}
+
+void StdMeshersGUI_DistrTable::stopEditing( const bool accept )
+{
+ endEdit( currEditRow(), currEditCol(), accept, false );
+}
+
+void StdMeshersGUI_DistrTable::edit( const int r, const int c )
+{
+ if( isEditing() )
+ endEdit( currEditRow(), currEditCol(), true, false );
+ clearSelection();
+ setCurrentCell( r, c );
+ if( beginEdit( r, c, false ) )
+ setEditMode( Editing, r, c );
+ QTableSelection sel;
+ sel.init( r, c );
+ sel.expandTo( r, c );
+ addSelection( sel );
+}
+
+bool StdMeshersGUI_DistrTable::eventFilter( QObject* o, QEvent* e )
+{
+ if( e && e->type()==QEvent::KeyPress )
+ {
+ QKeyEvent* ke = ( QKeyEvent* )e;
+ int k = ke->key();
+ if( k==Qt::Key_Tab || k==Qt::Key_BackTab || k==Qt::Key_Return || k==Qt::Key_Up || k==Qt::Key_Down )
+ {
+ keyPressEvent( ke );
+ return true;
+ }
+ }
+ return QTable::eventFilter( o, e );
+}
+
+void StdMeshersGUI_DistrTable::keyPressEvent( QKeyEvent* e )
+{
+ if( e )
+ {
+ int r = currentRow(), c = currentColumn(), nr, nc;
+ bool shift = e->state() & Qt::ShiftButton, cr = false;
+ switch( e->key() )
+ {
+ case Qt::Key_Tab:
+ nc = c+1;
+ nr = r;
+ break;
+
+ case Qt::Key_BackTab:
+ nc = c-1;
+ nr = r;
+ break;
+
+ case Qt::Key_Return:
+ nc = 0;
+ nr = shift ? r-1 : r+1;
+ cr = true;
+ break;
+
+ case Qt::Key_Up:
+ nc = c;
+ nr = r-1;
+ break;
+
+ case Qt::Key_Down:
+ nc = c;
+ nr = r+1;
+ break;
+
+ default:
+ QTable::keyPressEvent( e );
+ return;
+ }
+
+ if( nc<0 )
+ {
+ nc=1; nr--;
+ }
+ if( nc>1 )
+ {
+ nc=0; nr++;
+ }
+
+ if( nr>=numRows() && cr )
+ {
+ if( isEditing() )
+ endEdit( currEditRow(), currEditCol(), true, false );
+ onEdit( INSERT_ROW, nr );
+ }
+
+ else if( nr<0 || nr>=numRows() )
+ {
+ nr = r; nc = c;
+ }
+ edit( nr, nc );
+ e->accept();
+ }
+}
+
+QWidget* StdMeshersGUI_DistrTable::createEditor( int r, int c, bool init ) const
+{
+ QWidget* w = QTable::createEditor( r, c, init );
+ if( w )
+ {
+ //w->installEventFilter( this );
+ if( w->inherits( "QLineEdit" ) )
+ {
+ QLineEdit* le = ( QLineEdit* )w;
+ le->setValidator( c==0 ? myArgV : myFuncV );
+ }
+ }
+
+ return w;
+}
+
+void StdMeshersGUI_DistrTable::onEdit( TableButton b, int cur )
+{
+ switch( b )
+ {
+ case INSERT_ROW:
+ setNumRows( numRows()+1 );
+ for( int i=numRows()-1; i>=cur; i-- )
+ for( int j=0; j<numCols(); j++ )
+ if( i>cur )
+ setText( i, j, text( i-1, j ) );
+ else
+ setText( i, j, "0" );
+ emit( valueChanged( cur, 0 ) );
+ break;
+
+ case REMOVE_ROW:
+ if( numRows()>1 )
+ {
+ for( int i=cur; i<numRows(); i++ )
+ for( int j=0; j<numCols(); j++ )
+ setText( i, j, text( i+1, j ) );
+ setNumRows( numRows()-1 );
+ }
+ emit( valueChanged( cur, 0 ) );
+ break;
+ }
+}
+
+void StdMeshersGUI_DistrTable::sortData( SMESH::double_array& arr )
+{
+ QValueList< QPair<double,double> > aData;
+ if( arr.length()%2==1 )
+ arr.length( arr.length()-1 );
+
+ int aLen = arr.length();
+ for( int i=0; i<aLen/2; i++ )
+ aData.append( QPair<double,double>( arr[2*i], arr[2*i+1] ) );
+
+ qHeapSort( aData );
+
+ QValueList< QPair<double,double> >::const_iterator anIt = aData.begin(), aLast = aData.end();
+ QValueList<double> unique_values;
+ double prev; int i=0;
+ if( (*anIt).first>0.0 )
+ {
+ unique_values.append( 0.0 );
+ unique_values.append( (*anIt).second );
+ i++; prev = 0.0;
+ }
+ for( ; anIt!=aLast; anIt++ )
+ {
+ if( i==0 || (*anIt).first>prev )
+ {
+ unique_values.append( (*anIt).first );
+ unique_values.append( (*anIt).second );
+ i++;
+ }
+ prev = (*anIt).first;
+ }
+ if( prev<1.0 )
+ {
+ unique_values.append( 1.0 );
+ anIt--;
+ unique_values.append( (*anIt).second );
+ }
+
+ arr.length( unique_values.count() );
+ QValueList<double>::const_iterator anIt1 = unique_values.begin(), aLast1 = unique_values.end();
+ for( int j=0; anIt1!=aLast1; anIt1++, j++ )
+ arr[j] = *anIt1;
+}
+
+void StdMeshersGUI_DistrTable::data( SMESH::double_array& v )
+{
+ stopEditing( true );
+ v.length( 2*numRows() );
+ for( int i=0; i<numRows(); i++ )
+ for( int j=0; j<numCols(); j++ )
+ v[numCols()*i+j] = text( i, j ).toDouble();
+ sortData( v );
+}
+
+void StdMeshersGUI_DistrTable::setData( const SMESH::double_array& d )
+{
+ stopEditing( false );
+ setNumRows( d.length()/2 );
+ for( int i=0; i<d.length(); i++ )
+ setText( i/2, i%2, QString( "%1" ).arg( d[i] ) );
+}
+
+//=================================================================================
+// class : StdMeshersGUI_DistrTableFrame
+// purpose :
+//=================================================================================
+StdMeshersGUI_DistrTableFrame::StdMeshersGUI_DistrTableFrame( QWidget* parent )
+: QFrame( parent )
+{
+ QVBoxLayout* main = new QVBoxLayout( this, 0, 0 );
+
+ myTable = new StdMeshersGUI_DistrTable( 1, this );
+ connect( myTable, SIGNAL( valueChanged( int, int ) ), this, SIGNAL( valueChanged( int, int ) ) );
+ connect( this, SIGNAL( toEdit( TableButton, int ) ), myTable, SLOT( onEdit( TableButton, int ) ) );
+
+ QFrame* aButFrame = new QFrame( this );
+ QHBoxLayout* butLay = new QHBoxLayout( aButFrame, 5, 5 );
+
+ myInsertRow = new QPushButton( tr( "SMESH_INSERT_ROW" ), aButFrame );
+ myRemoveRow = new QPushButton( tr( "SMESH_REMOVE_ROW" ), aButFrame );
+
+ butLay->addWidget( myInsertRow, 0 );
+ butLay->addWidget( myRemoveRow, 0 );
+ butLay->addStretch( 1 );
+
+ main->addWidget( myTable, 1 );
+ main->addWidget( aButFrame, 0 );
+
+ connect( myInsertRow, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+ connect( myRemoveRow, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+}
+
+StdMeshersGUI_DistrTableFrame::~StdMeshersGUI_DistrTableFrame()
+{
+}
+
+StdMeshersGUI_DistrTable* StdMeshersGUI_DistrTableFrame::table() const
+{
+ return myTable;
+}
+
+void StdMeshersGUI_DistrTableFrame::setShown( const TableButton b, const bool sh )
+{
+ if( button( b ) )
+ button( b )->setShown( sh );
+}
+
+bool StdMeshersGUI_DistrTableFrame::isShown( const TableButton b ) const
+{
+ bool res = false;
+ if( button( b ) )
+ res = button( b )->isShown();
+ return res;
+}
+
+QButton* StdMeshersGUI_DistrTableFrame::button( const TableButton b ) const
+{
+ QButton* res = 0;
+ switch( b )
+ {
+ case INSERT_ROW:
+ res = myInsertRow;
+ break;
+
+ case REMOVE_ROW:
+ res = myRemoveRow;
+ break;
+ }
+ return res;
+}
+
+void StdMeshersGUI_DistrTableFrame::onButtonClicked()
+{
+ if( sender()==button( INSERT_ROW ) )
+ emit toEdit( INSERT_ROW, table()->currentRow() );
+
+ else if( sender()==button( REMOVE_ROW ) )
+ emit toEdit( REMOVE_ROW, table()->currentRow() );
+}
--- /dev/null
+// SMESH StdMeshersGUI
+//
+// Copyright (C) 2003 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : StdMeshersGUI_DistrTable.h
+// Module : SMESH
+// $Header$
+
+#ifndef StdMesherGUI_DistrTable_Header
+#define StdMesherGUI_DistrTable_Header
+
+#include <qtable.h>
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+class QButton;
+class QDoubleValidator;
+
+/*!
+ * \brief Values corresponding to buttons for table resize
+ */
+typedef enum { INSERT_ROW, REMOVE_ROW } TableButton;
+
+/*!
+ * \brief This class represents custom table. It has only double values and
+ editor for every cell has validator
+ */
+class StdMeshersGUI_DistrTable : public QTable
+{
+ Q_OBJECT
+
+public:
+ StdMeshersGUI_DistrTable( const int rows, QWidget* = 0, const char* = 0 );
+ virtual ~StdMeshersGUI_DistrTable();
+
+/*!
+ * \brief Hides current editor of cell
+ */
+ void stopEditing( const bool accept );
+
+ virtual QSize sizeHint() const;
+
+ static void sortData( SMESH::double_array& );
+
+ void data( SMESH::double_array& );
+ void setData( const SMESH::double_array& );
+
+protected:
+ virtual QWidget* createEditor( int, int, bool ) const;
+ virtual bool eventFilter( QObject*, QEvent* );
+ virtual void keyPressEvent( QKeyEvent* );
+ virtual void edit( const int, const int );
+
+private slots:
+ void onEdit( TableButton, int );
+
+private:
+ QDoubleValidator *myArgV, *myFuncV;
+};
+
+
+/*!
+ * \brief This class represents frame for table and buttons
+ */
+class StdMeshersGUI_DistrTableFrame : public QFrame
+{
+ Q_OBJECT
+
+public:
+ StdMeshersGUI_DistrTableFrame( QWidget* );
+ ~StdMeshersGUI_DistrTableFrame();
+
+ StdMeshersGUI_DistrTable* table() const;
+
+/*!
+ * \brief Changes shown state of some button for table resize
+ */
+ void setShown( const TableButton, const bool );
+
+/*!
+ * \brief Returns shown state of some button for table resize
+ */
+ bool isShown( const TableButton ) const;
+
+private:
+ QButton* button( const TableButton ) const;
+
+private slots:
+ void onButtonClicked();
+
+signals:
+/*!
+ * \brief This signal is emitted if some of button for table resize is clicked
+ * Second parameter is current row. Take into account that
+ * this object resize table ( returned by table() ) automatically
+ */
+ void toEdit( TableButton, int );
+ void valueChanged( int, int );
+
+private:
+ QButton *myInsertRow, *myRemoveRow;
+ StdMeshersGUI_DistrTable *myTable;
+};
+
+
+#endif
+
--- /dev/null
+
+#include "StdMeshersGUI_NbSegmentsCreator.h"
+#include "StdMeshersGUI_DistrTable.h"
+#include "StdMeshersGUI_DistrPreview.h"
+
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include <SalomeApp_Tools.h>
+
+#include <QtxIntSpinBox.h>
+#include <QtxComboBox.h>
+#include <SMESHGUI_SpinBox.h>
+
+#include <qlabel.h>
+#include <qgroupbox.h>
+#include <qframe.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+
+StdMeshersGUI_NbSegmentsCreator::StdMeshersGUI_NbSegmentsCreator()
+: StdMeshersGUI_StdHypothesisCreator( "NumberOfSegments" ),
+ myNbSeg( 0 ),
+ myDistr( 0 ),
+ myScale( 0 ),
+ myTable( 0 ),
+ myPreview( 0 ),
+ myExpr( 0 ),
+ myConv( 0 ),
+ myLScale( 0 ),
+ myLTable( 0 ),
+ myLExpr( 0 ),
+ myLConv( 0 ),
+ myInfo( 0 ),
+ myGroupLayout( 0 ),
+ myTableRow( 0 ),
+ myPreviewRow( 0 )
+{
+}
+
+StdMeshersGUI_NbSegmentsCreator::~StdMeshersGUI_NbSegmentsCreator()
+{
+}
+
+bool StdMeshersGUI_NbSegmentsCreator::checkParams() const
+{
+ NbSegmentsHypothesisData data_old, data_new;
+ readParamsFromHypo( data_old );
+ readParamsFromWidgets( data_new );
+ bool res = storeParamsToHypo( data_new );
+ storeParamsToHypo( data_old );
+ return res;
+}
+
+QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
+{
+ QFrame* fr = new QFrame( 0, "myframe" );
+ QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 );
+
+ QGroupBox* GroupC1 = new QGroupBox( fr, "GroupC1" );
+ lay->addWidget( GroupC1 );
+
+ StdMeshers::StdMeshers_NumberOfSegments_var h =
+ StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
+ myPreview = new StdMeshersGUI_DistrPreview( GroupC1, h.in() );
+
+ GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
+ GroupC1->setColumnLayout(0, Qt::Vertical );
+ GroupC1->layout()->setSpacing( 0 );
+ GroupC1->layout()->setMargin( 0 );
+ myGroupLayout = new QGridLayout( GroupC1->layout() );
+ myGroupLayout->setAlignment( Qt::AlignTop );
+ myGroupLayout->setSpacing( 6 );
+ myGroupLayout->setMargin( 11 );
+ myGroupLayout->setColStretch( 0, 0 );
+ myGroupLayout->setColStretch( 1, 1 );
+
+ int row = 0;
+ // 1) number of segments
+ myGroupLayout->addWidget( new QLabel( tr( "SMESH_NB_SEGMENTS_PARAM" ), GroupC1 ), row, 0 );
+ myNbSeg = new QtxIntSpinBox( GroupC1 );
+ myNbSeg->setMinValue( 1 );
+ myNbSeg->setMaxValue( 9999 );
+ myGroupLayout->addWidget( myNbSeg, row, 1 );
+ row++;
+
+ // 2) type of distribution
+ myGroupLayout->addWidget( new QLabel( tr( "SMESH_DISTR_TYPE" ), GroupC1 ), row, 0 );
+ myDistr = new QtxComboBox( GroupC1 );
+ QStringList types;
+ types.append( QObject::tr( "SMESH_DISTR_REGULAR" ) );
+ types.append( QObject::tr( "SMESH_DISTR_SCALE" ) );
+ types.append( QObject::tr( "SMESH_DISTR_TAB" ) );
+ types.append( QObject::tr( "SMESH_DISTR_EXPR" ) );
+ myDistr->insertStringList( types );
+ myGroupLayout->addWidget( myDistr, row, 1 );
+ row++;
+
+ // 3) scale
+ myGroupLayout->addWidget( myLScale = new QLabel( tr( "SMESH_NB_SEGMENTS_SCALE_PARAM" ), GroupC1 ), row, 0 );
+ myScale = new SMESHGUI_SpinBox( GroupC1 );
+ myScale->RangeStepAndValidator( 1E-5, 1E+5, 0.1, 6 );
+ myGroupLayout->addWidget( myScale, row, 1 );
+ row++;
+
+ myInfo = new QLabel( tr( "SMESH_FUNC_DOMAIN" ), GroupC1 );
+ myGroupLayout->addMultiCellWidget( myInfo, row, row, 0, 1 );
+ row++;
+
+ // 4) table
+ myGroupLayout->addWidget( myLTable = new QLabel( tr( "SMESH_TAB_FUNC" ), GroupC1 ), row, 0 );
+ myTable = new StdMeshersGUI_DistrTableFrame( GroupC1 );
+ myGroupLayout->addWidget( myTable, row, 1 );
+ myGroupLayout->setRowStretch( row, 1 );
+ myTableRow = row;
+ row++;
+
+ // 5) expression
+ myGroupLayout->addWidget( myLExpr = new QLabel( tr( "SMESH_EXPR_FUNC" ), GroupC1 ), row, 0 );
+ myExpr = new QLineEdit( GroupC1 );
+ myGroupLayout->addWidget( myExpr, row, 1 );
+ row++;
+
+ // 6) conversion (radiogroup)
+ myGroupLayout->addWidget( myLConv = new QLabel( tr( "SMESH_CONV_MODE" ), GroupC1 ), row, 0 );
+ myConv = new QButtonGroup( GroupC1 );
+ myConv->setExclusive( true );
+ myConv->setColumnLayout( 0, Qt::Vertical );
+ QGridLayout* convLay = new QGridLayout( myConv->layout() );
+ convLay->addWidget( new QRadioButton( tr( "SMESH_EXP_MODE" ), myConv ), 0, 0 );
+ convLay->addWidget( new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
+ myGroupLayout->addWidget( myConv, row, 1 );
+ row++;
+
+ // 7) distribution preview
+ myGroupLayout->addMultiCellWidget( myPreview, row, row, 0, 1 );
+ myGroupLayout->setRowStretch( row, 1 );
+ myPreviewRow = row;
+ row++;
+
+ connect( myNbSeg, SIGNAL( valueChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
+ connect( myDistr, SIGNAL( activated( int ) ), this, SLOT( onValueChanged() ) );
+ connect( myTable, SIGNAL( valueChanged( int, int ) ), this, SLOT( onValueChanged() ) );
+ connect( myExpr, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
+ connect( myConv, SIGNAL( clicked( int ) ), this, SLOT( onValueChanged() ) );
+
+ return fr;
+}
+
+void StdMeshersGUI_NbSegmentsCreator::retrieveParams() const
+{
+ NbSegmentsHypothesisData data;
+ readParamsFromHypo( data );
+
+ myNbSeg->setValue( data.myNbSeg );
+ myDistr->setCurrentItem( data.myDistrType );
+ myScale->setValue( data.myScale );
+ myConv->setButton( data.myConv );
+ myTable->table()->setData( data.myTable );
+ myExpr->setText( data.myExpr );
+}
+
+void StdMeshersGUI_NbSegmentsCreator::storeParams() const
+{
+ NbSegmentsHypothesisData data;
+ readParamsFromWidgets( data );
+ storeParamsToHypo( data );
+}
+
+bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisData& h_data ) const
+{
+ StdMeshers::StdMeshers_NumberOfSegments_var h =
+ StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
+
+ h_data.myNbSeg = (int) h->GetNumberOfSegments();
+ int distr = (int) h->GetDistrType();
+ h_data.myDistrType = distr;
+ h_data.myScale = distr==1 ? h->GetScaleFactor() : 1.0;
+ if( distr==2 )
+ {
+ SMESH::double_array* a = h->GetTableFunction();
+ h_data.myTable = *a;
+ delete a;
+ }
+ else
+ {
+ SMESH::double_array& a = h_data.myTable;
+ // by default, constant table function f(t)=1
+ a.length( 4 );
+ a[0] = 0.0; a[1] = 1.0;
+ a[2] = 1.0; a[3] = 1.0;
+ }
+
+ h_data.myExpr = distr==3 ? h->GetExpressionFunction() : "1";
+ h_data.myConv = distr==2 || distr==3 ? h->ConversionMode() : 1; /*cut negative by default*/
+
+ return true;
+}
+
+bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothesisData& h_data ) const
+{
+ StdMeshers::StdMeshers_NumberOfSegments_var h =
+ StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
+
+ bool ok = true;
+ try
+ {
+ h->SetNumberOfSegments( h_data.myNbSeg );
+ int distr = h_data.myDistrType;
+ h->SetDistrType( distr );
+
+ if( distr==1 )
+ h->SetScaleFactor( h_data.myScale );
+
+ if( distr==2 || distr==3 )
+ h->SetConversionMode( h_data.myConv );
+
+ if( distr==2 )
+ h->SetTableFunction( h_data.myTable );
+
+ if( distr==3 )
+ h->SetExpressionFunction( h_data.myExpr.latin1() );
+ //setting of function must follow after setConversionMode, because otherwise
+ //the function will be checked with old conversion mode, so that it may occurs
+ //unexpected errors for user
+ }
+ catch(const SALOME::SALOME_Exception& ex)
+ {
+ SalomeApp_Tools::QtCatchCorbaException(ex);
+ ok = false;
+ }
+ return ok;
+}
+
+bool StdMeshersGUI_NbSegmentsCreator::readParamsFromWidgets( NbSegmentsHypothesisData& h_data ) const
+{
+ h_data.myNbSeg = myNbSeg->value();
+ h_data.myDistrType = myDistr->currentItem();
+ h_data.myConv = myConv->id( myConv->selected() );
+ h_data.myScale = myScale->value();
+ myTable->table()->data( h_data.myTable );
+ h_data.myExpr = myExpr->text();
+ return true;
+}
+
+void StdMeshersGUI_NbSegmentsCreator::onValueChanged()
+{
+ int distr = myDistr->currentItem();
+
+ myScale->setShown( distr==1 );
+ myLScale->setShown( distr==1 );
+
+ bool isFunc = distr==2 || distr==3;
+ myPreview->setShown( isFunc );
+ myGroupLayout->setRowStretch( myPreviewRow, isFunc ? 1 : 0 );
+
+ myConv->setShown( isFunc );
+ myLConv->setShown( isFunc );
+
+ if( distr==2 )
+ myTable->show();
+ else
+ myTable->hide();
+ myLTable->setShown( distr==2 );
+ myGroupLayout->setRowStretch( myTableRow, distr==2 ? 1 : 0 );
+
+ myExpr->setShown( distr==3 );
+ myLExpr->setShown( distr==3 );
+ myInfo->setShown( isFunc );
+
+ //change of preview
+ int nbSeg = myNbSeg->value();
+ if( distr==2 ) //preview for table-described function
+ {
+ SMESH::double_array a;
+ myTable->table()->data( a );
+ myPreview->setParams( a, nbSeg, false );
+ }
+ else if( distr==3 ) //preview for analytic-described function
+ myPreview->setParams( myExpr->text(), nbSeg, 100, false );
+
+ if( isFunc )
+ myPreview->setConversion( StdMeshersGUI_DistrPreview::Conversion( myConv->id( myConv->selected() ) ) );
+}
--- /dev/null
+
+#ifndef NB_SEGMENTS_CREATOR_HEADER
+#define NB_SEGMENTS_CREATOR_HEADER
+
+#include "StdMeshersGUI_StdHypothesisCreator.h"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+class QtxIntSpinBox;
+class QtxComboBox;
+class SMESHGUI_SpinBox;
+class StdMeshersGUI_DistrTableFrame;
+class StdMeshersGUI_DistrPreview;
+class QLineEdit;
+class QButtonGroup;
+class QGridLayout;
+
+typedef struct
+{
+ int myNbSeg, myDistrType, myConv;
+ double myScale;
+ SMESH::double_array myTable;
+ QString myExpr;
+
+} NbSegmentsHypothesisData;
+
+class StdMeshersGUI_NbSegmentsCreator : public StdMeshersGUI_StdHypothesisCreator
+{
+ Q_OBJECT
+
+public:
+ StdMeshersGUI_NbSegmentsCreator();
+ virtual ~StdMeshersGUI_NbSegmentsCreator();
+
+ virtual bool checkParams() const;
+
+protected:
+ virtual QFrame* buildFrame();
+ virtual void retrieveParams() const;
+ virtual void storeParams() const;
+
+protected slots:
+ virtual void onValueChanged();
+
+private:
+ bool readParamsFromHypo( NbSegmentsHypothesisData& ) const;
+ bool readParamsFromWidgets( NbSegmentsHypothesisData& ) const;
+ bool storeParamsToHypo( const NbSegmentsHypothesisData& ) const;
+
+private:
+ QtxIntSpinBox* myNbSeg;
+ QtxComboBox* myDistr;
+ SMESHGUI_SpinBox* myScale;
+ StdMeshersGUI_DistrTableFrame* myTable;
+ StdMeshersGUI_DistrPreview* myPreview;
+ QLineEdit* myExpr;
+ QButtonGroup* myConv;
+ QLabel *myLScale, *myLTable, *myLExpr, *myLConv, *myInfo;
+ QGridLayout* myGroupLayout;
+ int myTableRow, myPreviewRow;
+};
+
+#endif
+++ /dev/null
-// SMESH StdMeshersGUI : GUI for standard meshers
-//
-// Copyright (C) 2003 CEA
-//
-// 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.
-//
-// 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.org
-//
-//
-//
-// File : StdMeshersGUI_Parameters.cxx
-// Module : SMESH
-// $Header$
-
-#include "StdMeshersGUI_Parameters.h"
-
-//#include "SMESHGUI_SpinBox.h" // for the sake of COORD_MAX, COORD_MIN definition
-
-#include <qobject.h>
-
-using namespace std;
-
-#define VALUE_MAX 1.0e+15 // COORD_MAX
-#define VALUE_MAX_2 (VALUE_MAX*VALUE_MAX)
-#define VALUE_MAX_3 (VALUE_MAX*VALUE_MAX*VALUE_MAX)
-
-#define VALUE_SMALL 1.0e-15
-#define VALUE_SMALL_2 (VALUE_SMALL*VALUE_SMALL)
-#define VALUE_SMALL_3 (VALUE_SMALL*VALUE_SMALL*VALUE_SMALL)
-
-//=======================================================================
-//function : HasParameters
-//purpose :
-//=======================================================================
-
-bool StdMeshersGUI_Parameters::HasParameters (const QString& hypType)
-{
- return ((hypType.compare("LocalLength") == 0) ||
- (hypType.compare("NumberOfSegments") == 0) ||
- (hypType.compare("MaxElementArea") == 0) ||
- (hypType.compare("MaxElementVolume") == 0) ||
- (hypType.compare("StartEndLength") == 0) ||
- (hypType.compare("Deflection1D") == 0) ||
- (hypType.compare("Arithmetic1D") == 0));
-}
-
-//=======================================================================
-//function : SetInitValue
-//purpose :
-//=======================================================================
-
-void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
- int initValue)
-{
- SMESHGUI_intParameter* p = dynamic_cast<SMESHGUI_intParameter*>(param.get());
- if ( p )
- {
- p->InitValue() = initValue;
- return;
- }
-
- SMESHGUI_enumParameter* q = dynamic_cast<SMESHGUI_enumParameter*>(param.get());
- if( q )
- {
- q->InitValue() = initValue;
- return;
- }
-
- SMESHGUI_boolParameter* b = dynamic_cast<SMESHGUI_boolParameter*>(param.get());
- if( b )
- {
- b->InitValue() = (bool)initValue;
- return;
- }
-}
-
-//=======================================================================
-//function : SetInitValue
-//purpose :
-//=======================================================================
-
-void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
- double initValue)
-{
- SMESHGUI_doubleParameter* p = dynamic_cast<SMESHGUI_doubleParameter*>(param.get());
- if ( p ) p->InitValue() = initValue;
-}
-
-//=======================================================================
-//function : SetInitValue
-//purpose :
-//=======================================================================
-
-void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
- const char* initValue)
-{
- SMESHGUI_strParameter* p = dynamic_cast<SMESHGUI_strParameter*>(param.get());
- if ( p ) p->InitValue() = initValue;
-}
-
-//=======================================================================
-//function : SetInitValue
-//purpose :
-//=======================================================================
-void StdMeshersGUI_Parameters::SetInitValue( SMESHGUI_aParameterPtr param,
- SMESH::double_array& initValue)
-{
- SMESHGUI_tableParameter* p = dynamic_cast<SMESHGUI_tableParameter*>(param.get());
- if( p )
- {
- p->setRowCount( initValue.length()/2 );
- p->setData( initValue );
- }
-}
-
-//=======================================================================
-//function : GetParameters
-//purpose :
-//=======================================================================
-
-// SMESHGUI_doubleParameter( initValue, label, bottom, top, step, decimals )
-#define DOUBLE_PARAM(v,l,b,t,s,d) SMESHGUI_aParameterPtr(new SMESHGUI_doubleParameter(v,l,b,t,s,d))
-#define INT_PARAM(v,l,b,t) SMESHGUI_aParameterPtr(new SMESHGUI_intParameter(v,l,b,t))
-#define ENUM_PARAM(v,i,l) SMESHGUI_aParameterPtr(new SMESHGUI_enumParameter(v,i,l))
-#define STR_PARAM(i,l,preview) SMESHGUI_aParameterPtr(new SMESHGUI_strParameter(i,l,preview))
-#define BOOL_PARAM(i,l,preview) SMESHGUI_aParameterPtr(new SMESHGUI_boolParameter(i,l,preview))
-
-void StdMeshersGUI_Parameters::GetParameters (const QString& hypType,
- list<SMESHGUI_aParameterPtr> & paramList )
-{
- paramList.clear();
-
- if (hypType.compare("LocalLength") == 0)
- {
- paramList.push_back( DOUBLE_PARAM (1.0,
- QObject::tr("SMESH_LOCAL_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1.0, 6));
- }
- else if (hypType.compare("NumberOfSegments") == 0)
- {
- //0-th parameter in list
- paramList.push_back ( INT_PARAM (3,
- QObject::tr("SMESH_NB_SEGMENTS_PARAM"),
- 1, 9999 ));
- QStringList types;
- types.append( QObject::tr( "SMESH_DISTR_REGULAR" ) );
- types.append( QObject::tr( "SMESH_DISTR_SCALE" ) );
- types.append( QObject::tr( "SMESH_DISTR_TAB" ) );
- types.append( QObject::tr( "SMESH_DISTR_EXPR" ) );
- //string description of distribution types
-
- SMESHGUI_enumParameter* type = new SMESHGUI_enumParameter( types, 0, QObject::tr( "SMESH_DISTR_TYPE" ) );
- SMESHGUI_dependParameter::ShownMap& aMap = type->shownMap();
- aMap[0].append( 0 ); // if DistrType=0 (regular), then number of segments and types are shown (0-th and 1-th)
- aMap[0].append( 1 );
- aMap[1].append( 0 ); // if DistrType=1 (scale), then number of segments, types and scale are shown
- aMap[1].append( 1 );
- aMap[1].append( 2 );
- aMap[2].append( 0 ); // if DistrType=2 (table), then number of segments, types, table and exponent are shown
- aMap[2].append( 1 );
- aMap[2].append( 3 );
- aMap[2].append( 5 );
- aMap[3].append( 0 ); // if DistrType=3 (expression), then number of segments, types, expression and exponent are shown
- aMap[3].append( 1 );
- aMap[3].append( 4 );
- aMap[3].append( 5 );
- //1-th parameter in list
- paramList.push_back ( SMESHGUI_aParameterPtr( type ) );
-
- //2-th parameter in list
- paramList.push_back ( DOUBLE_PARAM (1.0,
- QObject::tr("SMESH_NB_SEGMENTS_SCALE_PARAM"),
- VALUE_SMALL, VALUE_MAX, 0.1, 6 ));
- SMESHGUI_tableParameter* tab = new SMESHGUI_tableParameter( 0.0, QObject::tr( "SMESH_TAB_FUNC" ), true );
- tab->setRowCount( 5 );
- tab->setColCount( 2 );
- //default size of table: 5x2
-
- tab->setColName( 0, "t" );
- tab->setColName( 1, "f(t)" );
- tab->setValidator( 0, 0.0, 1.0, 3 );
- tab->setValidator( 1, 1E-7, 1E+300, 3 );
- tab->setEditRows( true );
-
- //3-th parameter in list
- paramList.push_back ( SMESHGUI_aParameterPtr( tab ) );
-
- //4-th parameter in list
- paramList.push_back ( STR_PARAM ( "", QObject::tr( "SMESH_EXPR_FUNC" ), true ) );
-
- //5-th parameter in list
- paramList.push_back ( BOOL_PARAM ( false, QObject::tr( "SMESH_EXP_MODE" ), true ) );
- }
- else if (hypType.compare("Arithmetic1D") == 0)
- {
- paramList.push_back( DOUBLE_PARAM ( 1.0,
- QObject::tr("SMESH_START_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- paramList.push_back( DOUBLE_PARAM ( 10.0,
- QObject::tr("SMESH_END_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- }
- else if (hypType.compare("MaxElementArea") == 0)
- {
- paramList.push_back( DOUBLE_PARAM (1.0,
- QObject::tr("SMESH_MAX_ELEMENT_AREA_PARAM"),
- VALUE_SMALL_2, VALUE_MAX_2, 1.0, 6));
- }
- else if (hypType.compare("MaxElementVolume") == 0)
- {
- paramList.push_back( DOUBLE_PARAM ( 1.0,
- QObject::tr("SMESH_MAX_ELEMENT_VOLUME_PARAM"),
- VALUE_SMALL_3, VALUE_MAX_3, 1.0, 6));
- }
- else if (hypType.compare("StartEndLength") == 0)
- {
- paramList.push_back( DOUBLE_PARAM ( 1.0,
- QObject::tr("SMESH_START_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- paramList.push_back( DOUBLE_PARAM ( 10.0,
- QObject::tr("SMESH_END_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- }
- else if (hypType.compare("Deflection1D") == 0)
- {
- paramList.push_back( DOUBLE_PARAM ( 1.0,
- QObject::tr("SMESH_DEFLECTION1D_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- }
-}
-
-//=======================================================================
-//function : GetParameters
-//purpose :
-//=======================================================================
-
-void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr theHyp,
- list<SMESHGUI_aParameterPtr> & paramList )
-{
- paramList.clear();
-
- if (theHyp->_is_nil()) return;
-
- QString hypType = theHyp->GetName();
- GetParameters( hypType, paramList ); // get default parameters
- if ( paramList.empty() )
- return;
-
- // set current values
- if (hypType.compare("LocalLength") == 0)
- {
- StdMeshers::StdMeshers_LocalLength_var LL =
- StdMeshers::StdMeshers_LocalLength::_narrow(theHyp);
- SetInitValue( paramList.front(), LL->GetLength() );
- }
- else if (hypType.compare("NumberOfSegments") == 0)
- {
- StdMeshers::StdMeshers_NumberOfSegments_var NOS =
- StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
-
- list<SMESHGUI_aParameterPtr>::iterator anIt = paramList.begin();
- SetInitValue( *anIt, (int) NOS->GetNumberOfSegments()); anIt++;
- int DType = (int) NOS->GetDistrType();
- SetInitValue( *anIt, DType ); anIt++;
-
- if( DType==1 )
- SetInitValue( *anIt, NOS->GetScaleFactor());
- anIt++;
-
- if( DType==2 )
- {
- SMESH::double_array* tab_func = NOS->GetTableFunction();
- SetInitValue( *anIt, *tab_func );
- delete tab_func;
- }
- anIt++;
-
- if( DType==3 )
- {
- char* expr_func = NOS->GetExpressionFunction();
- SetInitValue( *anIt, expr_func );
- //delete expr_func;
- }
- anIt++;
-
- if( DType==2 || DType==3 )
- SetInitValue( *anIt, (bool)NOS->IsExponentMode());
- }
- else if (hypType.compare("Arithmetic1D") == 0)
- {
- StdMeshers::StdMeshers_Arithmetic1D_var hyp =
- StdMeshers::StdMeshers_Arithmetic1D::_narrow(theHyp);
- SetInitValue( paramList.front(), hyp->GetLength( true )) ;
- SetInitValue( paramList.back(), hyp->GetLength( false )) ;
- }
- else if (hypType.compare("MaxElementArea") == 0)
- {
- StdMeshers::StdMeshers_MaxElementArea_var MEA =
- StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp);
- SetInitValue( paramList.front(), MEA->GetMaxElementArea() );
- }
- else if (hypType.compare("MaxElementVolume") == 0)
- {
- StdMeshers::StdMeshers_MaxElementVolume_var MEV =
- StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp);
- SetInitValue( paramList.front(), MEV->GetMaxElementVolume() );
- }
- else if (hypType.compare("StartEndLength") == 0)
- {
- StdMeshers::StdMeshers_StartEndLength_var hyp =
- StdMeshers::StdMeshers_StartEndLength::_narrow(theHyp);
- SetInitValue( paramList.front(), hyp->GetLength( true ));
- SetInitValue( paramList.back(), hyp->GetLength( false ));
- }
- else if (hypType.compare("Deflection1D") == 0)
- {
- StdMeshers::StdMeshers_Deflection1D_var hyp =
- StdMeshers::StdMeshers_Deflection1D::_narrow(theHyp);
- SetInitValue( paramList.back(), hyp->GetDeflection()) ;
- }
-}
-
-//=======================================================================
-//function : GetParameters
-//purpose :
-//=======================================================================
-void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr hyp,
- list<SMESHGUI_aParameterPtr> & paramList,
- QString& params)
-{
- params = "";
- list<SMESHGUI_aParameterPtr>::iterator paramIt = paramList.begin();
- for ( ; paramIt != paramList.end(); paramIt++) {
- if (params.compare("")) params += " ; ";
-
- SMESHGUI_aParameter::Type t = (*paramIt)->GetType();
- if( t==SMESHGUI_aParameter::DOUBLE )
- {
- double aDoubleValue = 0.;
- (*paramIt)->GetNewDouble(aDoubleValue);
- params += QString::number(aDoubleValue);
- }
- else if( t==SMESHGUI_aParameter::STRING || t==SMESHGUI_aParameter::ENUM )
- {
- QString aStrValue( "" );
- (*paramIt)->GetNewText(aStrValue);
- params += aStrValue.simplifyWhiteSpace();
- }
- else if( t==SMESHGUI_aParameter::TABLE )
- {
- params += "TABLE";
- }
- else
- {
- int aIntValue = 0;
- (*paramIt)->GetNewInt(aIntValue);
- params += QString::number(aIntValue);
- }
- }
-}
-
-//=======================================================================
-//function : SetParameters
-//purpose :
-//=======================================================================
-
-bool StdMeshersGUI_Parameters::SetParameters(SMESH::SMESH_Hypothesis_ptr theHyp,
- const list<SMESHGUI_aParameterPtr> & paramList )
-{
- if (theHyp->_is_nil() || paramList.empty()) return false;
-
- bool modified = false;
-
- QString hypType = theHyp->GetName();
-
- if (hypType.compare("LocalLength") == 0)
- {
- StdMeshers::StdMeshers_LocalLength_var LL =
- StdMeshers::StdMeshers_LocalLength::_narrow(theHyp);
- double length = LL->GetLength();
- modified = paramList.front()->GetNewDouble( length );
- LL->SetLength(length);
- }
- else if (hypType.compare("NumberOfSegments") == 0)
- {
- StdMeshers::StdMeshers_NumberOfSegments_var NOS =
- StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
-
- list<SMESHGUI_aParameterPtr>::const_iterator anIt = paramList.begin();
- int NbSeg, DType;
- double Scale;
- SMESH::double_array TabF;
- QString exprF;
- int expType;
-
- modified = (*anIt)->GetNewInt( NbSeg ); anIt++;
- modified = (*anIt)->GetNewInt( DType ) || modified; anIt++;
- modified = (*anIt)->GetNewDouble( Scale ) || modified; anIt++;
- SMESHGUI_aParameterPtr p = *anIt;
- ((SMESHGUI_tableParameter*)p.get())->data( TabF ); anIt++; modified = true;
- modified = (*anIt)->GetNewText( exprF ) || modified; anIt++;
- modified = (*anIt)->GetNewInt( expType ) || modified;
-
- NOS->SetNumberOfSegments( NbSeg );
- NOS->SetDistrType( DType );
- if( DType==1 )
- NOS->SetScaleFactor( Scale );
- if( DType==2 )
- NOS->SetTableFunction( TabF );
- if( DType==3 )
- NOS->SetExpressionFunction( CORBA::string_dup( exprF.latin1() ) );
- if( DType==2 || DType==3 )
- NOS->SetExponentMode( (bool)expType );
- }
- else if (hypType.compare("Arithmetic1D") == 0)
- {
- if ( paramList.size() != 2 )
- return false;
- StdMeshers::StdMeshers_Arithmetic1D_var hyp =
- StdMeshers::StdMeshers_Arithmetic1D::_narrow(theHyp);
- double begLength = hyp->GetLength( true ) ;
- double endLength = hyp->GetLength( false ) ;
- modified = paramList.front()->GetNewDouble( begLength );
- modified = paramList.back()->GetNewDouble( endLength ) || modified;
- hyp->SetLength( begLength, true );
- hyp->SetLength( endLength, false );
- }
- else if (hypType.compare("MaxElementArea") == 0)
- {
- StdMeshers::StdMeshers_MaxElementArea_var MEA =
- StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp);
- double MaxArea = MEA->GetMaxElementArea();
- modified = paramList.front()->GetNewDouble( MaxArea );
- MEA->SetMaxElementArea(MaxArea);
- }
- else if (hypType.compare("MaxElementVolume") == 0)
- {
- StdMeshers::StdMeshers_MaxElementVolume_var MEV =
- StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp);
- double MaxVolume = MEV->GetMaxElementVolume() ;
- modified = paramList.front()->GetNewDouble( MaxVolume );
- MEV->SetMaxElementVolume(MaxVolume);
- }
- else if (hypType.compare("StartEndLength") == 0)
- {
- if ( paramList.size() != 2 )
- return false;
- StdMeshers::StdMeshers_StartEndLength_var hyp =
- StdMeshers::StdMeshers_StartEndLength::_narrow(theHyp);
- double begLength = hyp->GetLength( true ) ;
- double endLength = hyp->GetLength( false ) ;
- modified = paramList.front()->GetNewDouble( begLength );
- modified = paramList.back()->GetNewDouble( endLength ) || modified;
- hyp->SetLength( begLength, true );
- hyp->SetLength( endLength, false );
- }
- else if (hypType.compare("Deflection1D") == 0)
- {
- StdMeshers::StdMeshers_Deflection1D_var hyp =
- StdMeshers::StdMeshers_Deflection1D::_narrow(theHyp);
- double value = hyp->GetDeflection() ;
- modified = paramList.front()->GetNewDouble( value );
- hyp->SetDeflection( value );
- }
- return modified ;
-}
-
+++ /dev/null
-// SMESH StdMeshersGUI : GUI for standard meshers
-//
-// Copyright (C) 2003 CEA
-//
-// 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.
-//
-// 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.org
-//
-//
-//
-// File : StdMeshersGUI_Parameters.h
-// Module : SMESH
-// $Header$
-
-#ifndef STDMESHERSGUI_PARAMETERS_H
-#define STDMESHERSGUI_PARAMETERS_H
-
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-
-#include "SMESHGUI_aParameter.h"
-
-#include <list>
-#include <vector>
-
-class StdMeshersGUI_Parameters
-{
- public:
- static bool HasParameters (const QString& hypType);
-
- static void GetParameters (const QString& hypType,
- std::list<SMESHGUI_aParameterPtr> & params );
-
- static void GetParameters (SMESH::SMESH_Hypothesis_ptr hyp,
- std::list<SMESHGUI_aParameterPtr> & params );
- static void GetParameters (SMESH::SMESH_Hypothesis_ptr hyp,
- std::list<SMESHGUI_aParameterPtr> & paramList,
- QString& params);
-
- static bool SetParameters(SMESH::SMESH_Hypothesis_ptr hyp,
- const std::list<SMESHGUI_aParameterPtr> & params );
-
- static void SetInitValue(SMESHGUI_aParameterPtr param,
- int initValue);
- static void SetInitValue(SMESHGUI_aParameterPtr param,
- double initValue);
- static void SetInitValue(SMESHGUI_aParameterPtr param,
- const char* initValue);
- static void SetInitValue(SMESHGUI_aParameterPtr param,
- SMESH::double_array& initValue);
-};
-#endif
--- /dev/null
+// SMESH StdMeshersGUI : GUI for plugged-in meshers
+//
+// Copyright (C) 2003 CEA
+//
+// 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.
+//
+// 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.org
+//
+//
+//
+// File : StdMeshersGUI_StdHypothesisCreator.cxx
+// Author : Alexander SOLOVYOV
+// Module : SMESH
+// $Header: /home/server/cvs/SMESH/SMESH_SRC/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx
+
+#include "StdMeshersGUI_StdHypothesisCreator.h"
+
+#include <SMESHGUI.h>
+#include <SMESHGUI_SpinBox.h>
+#include <SMESHGUI_HypothesesUtils.h>
+#include <SMESHGUI_Utils.h>
+
+#include <SUIT_ResourceMgr.h>
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+#include <qpixmap.h>
+
+
+const double VALUE_MAX = 1.0e+15, // COORD_MAX
+ VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
+ VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
+ VALUE_SMALL = 1.0e-15,
+ VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
+ VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
+
+StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
+: SMESHGUI_GenericHypothesisCreator( type )
+{
+}
+
+StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
+{
+}
+
+QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
+{
+ return buildStdFrame();
+}
+
+bool StdMeshersGUI_StdHypothesisCreator::checkParams() const
+{
+ return true;
+}
+
+void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
+{
+ //here this method must be empty because buildStdParam sets values itself
+}
+
+void StdMeshersGUI_StdHypothesisCreator::storeParams() const
+{
+ ListOfStdParams params;
+ bool res = getStdParamFromDlg( params );
+ if( isCreation() )
+ {
+ SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().latin1() );
+ params.remove( params.begin() );
+ }
+
+ if( res && !params.isEmpty() )
+ {
+ if( hypType()=="LocalLength" )
+ {
+ StdMeshers::StdMeshers_LocalLength_var h =
+ StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
+
+ h->SetLength( params[0].myValue.toDouble() );
+ }
+ else if( hypType()=="Arithmetic1D" )
+ {
+ StdMeshers::StdMeshers_Arithmetic1D_var h =
+ StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
+
+ h->SetLength( params[0].myValue.toDouble(), true );
+ h->SetLength( params[1].myValue.toDouble(), false );
+ }
+ else if( hypType()=="MaxElementArea" )
+ {
+ StdMeshers::StdMeshers_MaxElementArea_var h =
+ StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
+
+ h->SetMaxElementArea( params[0].myValue.toDouble() );
+ }
+ else if( hypType()=="MaxElementVolume" )
+ {
+ StdMeshers::StdMeshers_MaxElementVolume_var h =
+ StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
+
+ h->SetMaxElementVolume( params[0].myValue.toDouble() );
+ }
+ else if( hypType()=="StartEndLength" )
+ {
+ StdMeshers::StdMeshers_StartEndLength_var h =
+ StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
+
+ h->SetLength( params[0].myValue.toDouble(), true );
+ h->SetLength( params[1].myValue.toDouble(), false );
+ }
+ else if( hypType()=="Deflection1D" )
+ {
+ StdMeshers::StdMeshers_Deflection1D_var h =
+ StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
+
+ h->SetDeflection( params[0].myValue.toDouble() );
+ }
+ }
+}
+
+bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
+{
+ bool res = true;
+ SMESHGUI_GenericHypothesisCreator::StdParam item;
+
+ p.clear();
+ if( isCreation() )
+ {
+ HypothesisData* data = SMESH::GetHypothesisData( hypType() );
+ item.myName = tr( "SMESH_NAME" );
+ item.myValue = data ? data->Label : QString();
+ p.append( item );
+ }
+
+ if( hypType()=="LocalLength" )
+ {
+ StdMeshers::StdMeshers_LocalLength_var h =
+ StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
+
+ item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
+ item.myValue = isCreation() ? 1.0 : h->GetLength();
+ p.append( item );
+ }
+ else if( hypType()=="Arithmetic1D" )
+ {
+ StdMeshers::StdMeshers_Arithmetic1D_var h =
+ StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
+
+ item.myName = tr( "SMESH_START_LENGTH_PARAM" );
+ item.myValue = isCreation() ? 1.0 : h->GetLength( true );
+ p.append( item );
+ item.myName = tr( "SMESH_END_LENGTH_PARAM" );
+ item.myValue = isCreation() ? 10.0 : h->GetLength( false );
+ p.append( item );
+ }
+ else if( hypType()=="MaxElementArea" )
+ {
+ StdMeshers::StdMeshers_MaxElementArea_var h =
+ StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
+
+ item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
+ item.myValue = isCreation() ? 1.0 : h->GetMaxElementArea();
+ p.append( item );
+ }
+ else if( hypType()=="MaxElementVolume" )
+ {
+ StdMeshers::StdMeshers_MaxElementVolume_var h =
+ StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
+
+ item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
+ item.myValue = isCreation() ? 1.0 : h->GetMaxElementVolume();
+ p.append( item );
+ }
+ else if( hypType()=="StartEndLength" )
+ {
+ StdMeshers::StdMeshers_StartEndLength_var h =
+ StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
+
+ item.myName = tr( "SMESH_START_LENGTH_PARAM" );
+ item.myValue = isCreation() ? 1.0 : h->GetLength( true );
+ p.append( item );
+ item.myName = tr( "SMESH_END_LENGTH_PARAM" );
+ item.myValue = isCreation() ? 10.0 : h->GetLength( false );
+ p.append( item );
+ }
+ else if( hypType()=="Deflection1D" )
+ {
+ StdMeshers::StdMeshers_Deflection1D_var h =
+ StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
+
+ item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
+ item.myValue = isCreation() ? 1.0 : h->GetDeflection();
+ p.append( item );
+ }
+ else
+ res = false;
+ return res;
+}
+
+void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget( QWidget* w, const int ) const
+{
+ SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
+ if( hypType()=="LocalLength" && sb )
+ {
+ sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
+ }
+ else if( hypType()=="Arithmetic1D" && sb )
+ {
+ sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
+ }
+ else if( hypType()=="MaxElementArea" && sb )
+ {
+ sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, 6 );
+ }
+ else if( hypType()=="MaxElementVolume" && sb )
+ {
+ sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, 6 );
+ }
+ else if( hypType()=="StartEndLength" && sb )
+ {
+ sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
+ }
+ else if( hypType()=="Deflection1D" && sb )
+ {
+ sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
+ }
+}
+
+QString StdMeshersGUI_StdHypothesisCreator::caption() const
+{
+ return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ) );
+}
+
+QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
+{
+ QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ) );
+ return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
+}
+
+QString StdMeshersGUI_StdHypothesisCreator::type() const
+{
+ return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ) );
+}
+
+QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
+{
+ static QMap<QString,QString> types;
+ if( types.isEmpty() )
+ {
+ types.insert( "LocalLength", "LOCAL_LENGTH" );
+ types.insert( "NumberOfSegments", "NB_SEGMENTS" );
+ types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
+ types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
+ types.insert( "StartEndLength", "START_END_LENGTH" );
+ types.insert( "Deflection1D", "DEFLECTION1D" );
+ types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
+ }
+
+ QString res;
+ if( types.contains( t ) )
+ res = types[ t ];
+
+ return res;
+}
--- /dev/null
+// SMESH StdMeshersGUI : GUI for plugged-in meshers
+//
+// Copyright (C) 2003 CEA
+//
+// 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.
+//
+// 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.org
+//
+//
+//
+// File : StdMeshersGUI_StdHypothesisCreator.h
+// Author : Alexander SOLOVYOV
+// Module : SMESH
+// $Header: /home/server/cvs/SMESH/SMESH_SRC/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h
+
+#ifndef STDMESHERSGUI_StdHypothesisCreator_HeaderFile
+#define STDMESHERSGUI_StdHypothesisCreator_HeaderFile
+
+#include <SMESHGUI_Hypotheses.h>
+
+/*!
+ * \brief Class for creation of simple hypotheses (only set of parameters without dependencies)
+*/
+class StdMeshersGUI_StdHypothesisCreator : public SMESHGUI_GenericHypothesisCreator
+{
+ Q_OBJECT
+
+public:
+ StdMeshersGUI_StdHypothesisCreator( const QString& );
+ virtual ~StdMeshersGUI_StdHypothesisCreator();
+
+ virtual bool checkParams() const;
+
+protected:
+ virtual QFrame* buildFrame ();
+ virtual void retrieveParams() const;
+ virtual void storeParams () const;
+ virtual bool stdParams ( ListOfStdParams& ) const;
+ virtual void attuneStdWidget( QWidget*, const int ) const;
+ virtual QString caption() const;
+ virtual QPixmap icon() const;
+ virtual QString type() const;
+
+private:
+ QString hypTypeName( const QString& ) const;
+};
+
+#endif
msgid "SMESH_EXPR_FUNC"
msgstr "Density function f(t) = "
-msgid "SMESH_EXP_MODE"
-msgstr "Exponent mode "
+msgid "SMESH_CONV_MODE"
+msgstr "Conversion mode "
msgid "SMESH_NB_SEGMENTS_TITLE"
msgstr "Hypothesis Construction"
+msgid "SMESH_EXP_MODE"
+msgstr "Exponent"
+
+msgid "SMESH_CUT_NEG_MODE"
+msgstr "Cut negative"
+
+msgid "SMESH_INSERT_ROW"
+msgstr "Insert row"
+
+msgid "SMESH_REMOVE_ROW"
+msgstr "Remove row"
+
+msgid "SMESH_FUNC_DOMAIN"
+msgstr "Warning: function must be defined on segment [0..1]"
+
+msgid "SMESH_INVALID_FUNCTION"
+msgstr "Function is invalid"
+
# ----------- Max. Element Area ------------
msgid "SMESH_MAX_ELEMENT_AREA_PARAM"
msgstr "End Length"
msgid "SMESH_START_END_LENGTH_HYPOTHESIS"
-msgstr "Start and EndLocal Length"
+msgstr "Start and End local Length"
msgid "SMESH_START_END_LENGTH_TITLE"
msgstr "Hypothesis Construction"
MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
}
+//=============================================================================
+/*!
+ * StdMeshers_NumberOfSegments_i::BuildDistribution
+ *
+ * Builds point distribution according to passed function
+ */
+//=============================================================================
+SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func, long nbSeg, long conv )
+throw ( SALOME::SALOME_Exception )
+{
+ MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
+ ASSERT( myBaseImpl );
+ try
+ {
+ SMESH::double_array_var aRes = new SMESH::double_array();
+ const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
+ aRes->length( res.size() );
+ for (int i = 0; i < res.size(); i++)
+ aRes[i] = res[i];
+ return aRes._retn();
+ }
+ catch( SALOME_Exception& S_ex )
+ {
+ THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
+ }
+}
+
+SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
+ long nbSeg, long conv )
+throw ( SALOME::SALOME_Exception )
+{
+ MESSAGE( "StdMeshers_NumberOfSegments_i::BuildDistribution" );
+ ASSERT( myBaseImpl );
+
+ std::vector<double> tbl( func.length() );
+ for (int i = 0; i < func.length(); i++)
+ tbl[i] = func[i];
+
+ try
+ {
+ SMESH::double_array_var aRes = new SMESH::double_array();
+ const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
+ aRes->length( res.size() );
+ for (int i = 0; i < res.size(); i++)
+ aRes[i] = res[i];
+ return aRes._retn();
+ }
+ catch( SALOME_Exception& S_ex )
+ {
+ THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
+ }
+}
+
//=============================================================================
/*!
* StdMeshers_NumberOfSegments_i::SetNumberOfSegments
*/
//=============================================================================
-void StdMeshers_NumberOfSegments_i::SetExponentMode(CORBA::Boolean isExp)
+void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
throw ( SALOME::SALOME_Exception )
{
- MESSAGE( "StdMeshers_NumberOfSegments_i::SetExponentMode" );
+ MESSAGE( "StdMeshers_NumberOfSegments_i::SetConversionMode" );
ASSERT( myBaseImpl );
try {
- this->GetImpl()->SetExponentMode( isExp );
+ this->GetImpl()->SetConversionMode( conv );
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
*/
//=============================================================================
-CORBA::Boolean StdMeshers_NumberOfSegments_i::IsExponentMode()
+CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
throw ( SALOME::SALOME_Exception )
{
- MESSAGE( "StdMeshers_NumberOfSegments_i::IsExponentMode" );
+ MESSAGE( "StdMeshers_NumberOfSegments_i::ConversionMode" );
ASSERT( myBaseImpl );
- bool isExp;
+ int conv;
try {
- isExp = this->GetImpl()->IsExponentMode();
+ conv = this->GetImpl()->ConversionMode();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
SALOME::BAD_PARAM );
}
- return isExp;
+ return conv;
}
//=============================================================================
// Destructor
virtual ~StdMeshers_NumberOfSegments_i();
+ // Builds point distribution according to passed function
+ SMESH::double_array* BuildDistributionExpr( const char*, CORBA::Long, CORBA::Long )
+ throw ( SALOME::SALOME_Exception );
+ SMESH::double_array* BuildDistributionTab( const SMESH::double_array&, CORBA::Long, CORBA::Long )
+ throw ( SALOME::SALOME_Exception );
+
// Set number of segments
void SetNumberOfSegments( CORBA::Long theSegmentsNumber )
throw ( SALOME::SALOME_Exception );
throw ( SALOME::SALOME_Exception );
// Set the exponent mode on/off
- void SetExponentMode(CORBA::Boolean isExp)
+ void SetConversionMode( CORBA::Long conv )
throw ( SALOME::SALOME_Exception );
// Returns true if the exponent mode is set
- CORBA::Boolean IsExponentMode()
+ CORBA::Long ConversionMode()
throw ( SALOME::SALOME_Exception );
// Get implementation