From af1734a6c5dc6ec282e3fbc0be7f5c53f9344b5e Mon Sep 17 00:00:00 2001 From: eap Date: Sun, 4 May 2008 10:09:02 +0000 Subject: [PATCH] add more options to BLSURF --- idl/BLSURFPlugin_Algorithm.idl | 68 ++- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 82 ++-- src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx | 18 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 296 +++++++++--- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 53 ++- .../BLSURFPlugin_Hypothesis_i.cxx | 182 +++++++ .../BLSURFPlugin_Hypothesis_i.hxx | 28 ++ src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 443 ++++++++++++++---- src/GUI/BLSURFPluginGUI_HypothesisCreator.h | 55 ++- src/GUI/BLSURFPlugin_msg_en.po | 37 +- src/GUI/Makefile.in | 2 +- 11 files changed, 1047 insertions(+), 217 deletions(-) diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index fc175cc..e81d57d 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -26,12 +26,15 @@ #define _SMESH_BLSURFALGORITHM_IDL_ #include "SMESH_Hypothesis.idl" +#include "SALOME_Exception.idl" /*! * BLSURFPlugin: interfaces to BLSURF related hypotheses and algorithms */ module BLSURFPlugin { + typedef sequence string_array; + /*! * BLSURFPlugin_BLSURF: interface of BLSURF algorithm */ @@ -66,20 +69,50 @@ module BLSURFPlugin void SetPhySize(in double size); double GetPhySize(); + /*! + * Sets lower boundary of mesh element size (PhySize) + */ + void SetPhyMin(in double theMinSize); + double GetPhyMin(); + + /*! + * Sets upper boundary of mesh element size (PhySize) + */ + void SetPhyMax(in double theMaxSize); + double GetPhyMax(); + /*! * Sets a way to define maximum angular deflection of mesh from CAD model * 0 - deflection is defined automatically - * 1 - deflection is set by SetAngleMeshS() method + * 1 - deflection is set by SetAngleMeshS() and SetAngleMeshC() methods */ void SetGeometricMesh(in long isCustom); long GetGeometricMesh(); /*! - * Sets angular deflection (in degrees) of mesh from CAD model + * Sets angular deflection (in degrees) of a mesh face from CAD surface */ void SetAngleMeshS(in double angle); double GetAngleMeshS(); + /*! + * Sets angular deflection (in degrees) of a mesh edge from CAD curve + */ + void SetAngleMeshC(in double angle); + double GetAngleMeshC(); + + /*! + * Sets lower boundary of mesh element size computed to respect angular deflection + */ + void SetGeoMin(in double theMinSize); + double GetGeoMin(); + + /*! + * Sets upper boundary of mesh element size computed to respect angular deflection + */ + void SetGeoMax(in double theMaxSize); + double GetGeoMax(); + /*! * Sets maximal allowed ratio between the lengths of two adjacent edges */ @@ -97,6 +130,37 @@ module BLSURFPlugin */ void SetDecimesh(in boolean toIgnoreEdges); boolean GetDecimesh(); + + /*! + * Sets verbosity level in the range 0 to 100. + */ + void SetVerbosity(in short theVal) raises (SALOME::SALOME_Exception); + short GetVerbosity(); + + /*! + * Sets advanced option value + */ + void SetOptionValue(in string optionName, + in string optionValue) raises (SALOME::SALOME_Exception); + string GetOptionValue(in string optionName) raises (SALOME::SALOME_Exception); + /*! + * Unsets advanced option + */ + void UnsetOption(in string optionName); + + /*! + * Return array of strings each of which is option name concatenated + * with option value devided by semicolon - "option_name:option_value". + * Option value is empty if an option is not set. + * Note: the method is mostly for interaction with GUI. + */ + string_array GetOptionValues(); + + /*! + * Set option values each in the form "option_name[:option_value]". + * Note: the method is mostly for interaction with GUI. + */ + void SetOptionValues(in string_array options); }; }; diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 8899a5b..0322ffa 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -166,45 +166,65 @@ inline std::string to_string(int i) return o.str(); } -void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t *bls) { +void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t *bls) +{ + int _topology = BLSURFPlugin_Hypothesis::GetDefaultTopology(); + int _physicalMesh = BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh(); + double _phySize = BLSURFPlugin_Hypothesis::GetDefaultPhySize(); + int _geometricMesh = BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh(); + double _angleMeshS = BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS(); + double _angleMeshC = BLSURFPlugin_Hypothesis::GetDefaultAngleMeshC(); + double _gradation = BLSURFPlugin_Hypothesis::GetDefaultGradation(); + bool _quadAllowed = BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed(); + bool _decimesh = BLSURFPlugin_Hypothesis::GetDefaultDecimesh(); + int _verb = BLSURFPlugin_Hypothesis::GetDefaultVerbosity(); + if (hyp) { MESSAGE("BLSURFPlugin_BLSURF::SetParameters"); - _topology = (int) hyp->GetTopology(); - _physicalMesh = (int) hyp->GetPhysicalMesh(); - _phySize = hyp->GetPhySize(); + _topology = (int) hyp->GetTopology(); + _physicalMesh = (int) hyp->GetPhysicalMesh(); + _phySize = hyp->GetPhySize(); _geometricMesh = (int) hyp->GetGeometricMesh(); - _angleMeshS = hyp->GetAngleMeshS(); - _gradation = hyp->GetGradation(); - _quadAllowed = hyp->GetQuadAllowed(); - _decimesh = hyp->GetDecimesh(); + _angleMeshS = hyp->GetAngleMeshS(); + _angleMeshC = hyp->GetAngleMeshC(); + _gradation = hyp->GetGradation(); + _quadAllowed = hyp->GetQuadAllowed(); + _decimesh = hyp->GetDecimesh(); + _verb = hyp->GetVerbosity(); + + if ( hyp->GetPhyMin() != ::BLSURFPlugin_Hypothesis::undefinedDouble() ) + blsurf_set_param(bls, "hphymin", to_string(hyp->GetPhyMin()).c_str()); + if ( hyp->GetPhyMax() != ::BLSURFPlugin_Hypothesis::undefinedDouble() ) + blsurf_set_param(bls, "hphymax", to_string(hyp->GetPhyMax()).c_str()); + if ( hyp->GetGeoMin() != ::BLSURFPlugin_Hypothesis::undefinedDouble() ) + blsurf_set_param(bls, "hgeomin", to_string(hyp->GetGeoMin()).c_str()); + if ( hyp->GetGeoMax() != ::BLSURFPlugin_Hypothesis::undefinedDouble() ) + blsurf_set_param(bls, "hgeomax", to_string(hyp->GetGeoMax()).c_str()); + + const BLSURFPlugin_Hypothesis::TOptionValues & opts = hyp->GetOptionValues(); + BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt; + for ( opIt = opts.begin(); opIt != opts.end(); ++opIt ) + if ( !opIt->second.empty() ) + blsurf_set_param(bls, opIt->first.c_str(), opIt->second.c_str()); + } else { MESSAGE("BLSURFPlugin_BLSURF::SetParameters using defaults"); - _topology = BLSURFPlugin_Hypothesis::GetDefaultTopology(); - _physicalMesh = BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh(); - _phySize = BLSURFPlugin_Hypothesis::GetDefaultPhySize(); - _geometricMesh = BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh(); - _angleMeshS = BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS(); - _gradation = BLSURFPlugin_Hypothesis::GetDefaultGradation(); - _quadAllowed = BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed(); - _decimesh = BLSURFPlugin_Hypothesis::GetDefaultDecimesh(); - } - blsurf_set_param(bls, "topo_points", _topology > 0 ? "1" : "0"); - blsurf_set_param(bls, "topo_curves", _topology > 0 ? "1" : "0"); - blsurf_set_param(bls, "topo_project", _topology > 0 ? "1" : "0"); - blsurf_set_param(bls, "clean_boundary", _topology > 1 ? "1" : "0"); - blsurf_set_param(bls, "close_boundary", _topology > 1 ? "1" : "0"); - blsurf_set_param(bls, "hphy_flag", to_string(_physicalMesh).c_str()); - blsurf_set_param(bls, "hphydef", to_string(_phySize).c_str()); - blsurf_set_param(bls, "hgeo_flag", to_string(_geometricMesh).c_str()); - blsurf_set_param(bls, "angle_meshs", to_string(_angleMeshS).c_str()); - blsurf_set_param(bls, "angle_meshc", to_string(_angleMeshS).c_str()); - blsurf_set_param(bls, "gradation", to_string(_gradation).c_str()); - // blsurf_set_param(bls, "patch_independent", to_string(_decimesh).c_str()); + blsurf_set_param(bls, "topo_points", _topology > 0 ? "1" : "0"); + blsurf_set_param(bls, "topo_curves", _topology > 0 ? "1" : "0"); + blsurf_set_param(bls, "topo_project", _topology > 0 ? "1" : "0"); + blsurf_set_param(bls, "clean_boundary", _topology > 1 ? "1" : "0"); + blsurf_set_param(bls, "close_boundary", _topology > 1 ? "1" : "0"); + blsurf_set_param(bls, "hphy_flag", to_string(_physicalMesh).c_str()); + blsurf_set_param(bls, "hphydef", to_string(_phySize).c_str()); + blsurf_set_param(bls, "hgeo_flag", to_string(_geometricMesh).c_str()); + blsurf_set_param(bls, "angle_meshs", to_string(_angleMeshS).c_str()); + blsurf_set_param(bls, "angle_meshc", to_string(_angleMeshC).c_str()); + blsurf_set_param(bls, "gradation", to_string(_gradation).c_str()); blsurf_set_param(bls, "patch_independent", _decimesh ? "1" : "0"); - blsurf_set_param(bls, "element", _quadAllowed ? "q1.0" : "p1"); - blsurf_set_param(bls, "verb", "10"); + blsurf_set_param(bls, "element", _quadAllowed ? "q1.0" : "p1"); + blsurf_set_param(bls, "verb", to_string(_verb).c_str()); } status_t curv_fun(real t, real *uv, real *dt, real *dtt, void *user_data); diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index 7ec8b22..1c57ba1 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -60,15 +60,15 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { protected: const BLSURFPlugin_Hypothesis* _hypothesis; - private: - int _topology; - int _physicalMesh; - double _phySize; - int _geometricMesh; - double _angleMeshS; - double _gradation; - bool _quadAllowed; - bool _decimesh; +// private: +// int _topology; +// int _physicalMesh; +// double _phySize; +// int _geometricMesh; +// double _angleMeshS; +// double _gradation; +// bool _quadAllowed; +// bool _decimesh; }; #endif diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 9a020ae..018bc62 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -30,10 +30,6 @@ using namespace std; #include #include -//============================================================================= -/*! - * - */ //============================================================================= BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId, SMESH_Gen * gen) @@ -41,20 +37,79 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId, _topology(GetDefaultTopology()), _physicalMesh(GetDefaultPhysicalMesh()), _phySize(GetDefaultPhySize()), + _phyMax(GetDefaultMaxSize()), + _phyMin(GetDefaultMinSize()), + _hgeoMax(GetDefaultMaxSize()), + _hgeoMin(GetDefaultMinSize()), _geometricMesh(GetDefaultGeometricMesh()), _angleMeshS(GetDefaultAngleMeshS()), + _angleMeshC(GetDefaultAngleMeshC()), _gradation(GetDefaultGradation()), _quadAllowed(GetDefaultQuadAllowed()), - _decimesh(GetDefaultDecimesh()) + _decimesh(GetDefaultDecimesh()), + _verb( GetDefaultVerbosity() ) { _name = "BLSURF_Parameters"; _param_algo_dim = 2; + + // to desable writing boundaries + //_phyMin = _phyMax = _hgeoMin = _hgeoMax = undefinedDouble(); + + + const char* optionNames[] = { + "addsurf_ivertex", + "background", + "CheckAdjacentEdges", + "CheckCloseEdges", + "CheckWellDefined", + "coiter", + "communication", + "decim", + "export_flag", + "file_h", + "frontal", + "gridnu", + "gridnv", + "hinterpol_flag", + "hmean_flag", + "intermedfile", + "memory", + "normals", + "optim", + "pardom_flag", + "pinch", + "refs", + "rigid", + "surforient", + "tconf", + "topo_collapse", + "addsurf_angle", + "addsurf_R", + "addsurf_H", + "addsurf_FG", + "addsurf_r", + "addsurf_PA", + "angle_compcurv", + "angle_ridge", + "CoefRectangle", + "eps_collapse", + "eps_ends", + "eps_pardom", + "LSS", + "topo_eps1", + "topo_eps2", + "export_format", + "export_option", + "import_option", + "prefix", + "" // mark of end + }; + int i = 0; + while ( optionNames[i][0] ) + _option2value[ optionNames[i++] ].clear(); + } -//============================================================================= -/*! - * - */ //============================================================================= void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) { @@ -64,10 +119,6 @@ void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) } } -//============================================================================= -/*! - * - */ //============================================================================= void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) { @@ -83,10 +134,6 @@ void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) } } -//============================================================================= -/*! - * - */ //============================================================================= void BLSURFPlugin_Hypothesis::SetPhySize(double theVal) { @@ -97,9 +144,42 @@ void BLSURFPlugin_Hypothesis::SetPhySize(double theVal) } //============================================================================= -/*! - * - */ +void BLSURFPlugin_Hypothesis::SetPhyMin(double theMinSize) +{ + if (theMinSize != _phyMin) { + _phyMin = theMinSize; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +void BLSURFPlugin_Hypothesis::SetPhyMax(double theMaxSize) +{ + if (theMaxSize != _phyMax) { + _phyMax = theMaxSize; + NotifySubMeshesHypothesisModification(); + } +} + + +//============================================================================= +void BLSURFPlugin_Hypothesis::SetGeoMin(double theMinSize) +{ + if (theMinSize != _hgeoMin) { + _hgeoMin = theMinSize; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +void BLSURFPlugin_Hypothesis::SetGeoMax(double theMaxSize) +{ + if (theMaxSize != _hgeoMax) { + _hgeoMax = theMaxSize; + NotifySubMeshesHypothesisModification(); + } +} + //============================================================================= void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) { @@ -116,10 +196,6 @@ void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) } } -//============================================================================= -/*! - * - */ //============================================================================= void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal) { @@ -130,9 +206,14 @@ void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal) } //============================================================================= -/*! - * - */ +void BLSURFPlugin_Hypothesis::SetAngleMeshC(double theVal) +{ + if (theVal != _angleMeshC) { + _angleMeshC = theVal; + NotifySubMeshesHypothesisModification(); + } +} + //============================================================================= void BLSURFPlugin_Hypothesis::SetGradation(double theVal) { @@ -142,10 +223,6 @@ void BLSURFPlugin_Hypothesis::SetGradation(double theVal) } } -//============================================================================= -/*! - * - */ //============================================================================= void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) { @@ -155,10 +232,6 @@ void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) } } -//============================================================================= -/*! - * - */ //============================================================================= void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal) { @@ -169,9 +242,50 @@ void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal) } //============================================================================= -/*! - * - */ +void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) +{ + if (theVal != _verb) { + _verb = theVal; + NotifySubMeshesHypothesisModification(); + } +} +//============================================================================= +void BLSURFPlugin_Hypothesis::SetOptionValue(const string& optionName, + const string& optionValue) throw (SALOME_Exception) +{ + TOptionValues::iterator op_val = _option2value.find( optionName ); + if ( op_val == _option2value.end() ) { + string msg = "Unknown BLSURF option: <"; + msg += optionName + ">"; + throw SALOME_Exception(msg.c_str()); + } + if ( op_val->second != optionValue ) { + op_val->second = optionValue; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +string BLSURFPlugin_Hypothesis::GetOptionValue(const string& optionName) + throw (SALOME_Exception) +{ + TOptionValues::iterator op_val = _option2value.find( optionName ); + if ( op_val == _option2value.end() ) { + string msg = "Unknown BLSURF option: <"; + msg += optionName + ">"; + throw SALOME_Exception(msg.c_str()); + } + return op_val->second; +} + +//============================================================================= +void BLSURFPlugin_Hypothesis::ClearOption(const string& optionName) +{ + TOptionValues::iterator op_val = _option2value.find( optionName ); + if ( op_val != _option2value.end() ) + op_val->second.clear(); +} + //============================================================================= ostream & BLSURFPlugin_Hypothesis::SaveTo(ostream & save) { @@ -183,14 +297,23 @@ ostream & BLSURFPlugin_Hypothesis::SaveTo(ostream & save) << " " << _gradation << " " << (int)_quadAllowed << " " << (int)_decimesh; + save << " " << _phyMin + << " " << _phyMax + << " " << _angleMeshC + << " " << _hgeoMin + << " " << _hgeoMax + << " " << _verb; + + TOptionValues::iterator op_val = _option2value.begin(); + for ( ; op_val != _option2value.end(); ++op_val ) { + if ( !op_val->second.empty() ) + save << " " << op_val->first + << " " << op_val->second << "%#"; // "%#" is a mark of value end + } return save; } -//============================================================================= -/*! - * - */ //============================================================================= istream & BLSURFPlugin_Hypothesis::LoadFrom(istream & load) { @@ -246,38 +369,89 @@ istream & BLSURFPlugin_Hypothesis::LoadFrom(istream & load) else load.clear(ios::badbit | load.rdstate()); + isOK = (load >> val); + if (isOK) + _phyMin = val; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> val); + if (isOK) + _phyMax = val; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> val); + if (isOK) + _angleMeshC = val; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> val); + if (isOK) + _hgeoMin = val; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> val); + if (isOK) + _hgeoMax = val; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + _verb = i; + else + load.clear(ios::badbit | load.rdstate()); + + string optName, optValue; + while (isOK) { + isOK = (load >> optName); + if (isOK) + isOK = (load >> optValue); + if (isOK) { + string & value = _option2value[ optName ]; + value = optValue; + int len = value.size(); + // continue reading until "%#" encountered + while ( value[len-1] != '#' || value[len-2] != '%' ) + { + isOK = (load >> optValue); + if (isOK) { + value += " "; + value += optValue; + len = value.size(); + } + else { + break; + } + } + value[ len-2 ] = '\0'; //cut off "%#" + } + } + return load; } -//============================================================================= -/*! - * - */ //============================================================================= ostream & operator <<(ostream & save, BLSURFPlugin_Hypothesis & hyp) { return hyp.SaveTo( save ); } -//============================================================================= -/*! - * - */ //============================================================================= istream & operator >>(istream & load, BLSURFPlugin_Hypothesis & hyp) { return hyp.LoadFrom( load ); } - //================================================================================ /*! * \brief Does nothing - * \param theMesh - the built mesh - * \param theShape - the geometry of interest - * \retval bool - always false */ //================================================================================ + bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) { @@ -302,7 +476,19 @@ double BLSURFPlugin_Hypothesis::GetDefaultPhySize() return 10; } -//============================================================================= +//====================================================================== +double BLSURFPlugin_Hypothesis::GetDefaultMaxSize() +{ + return 1e+4; +} + +//====================================================================== +double BLSURFPlugin_Hypothesis::GetDefaultMinSize() +{ + return 1e-4; +} + +//====================================================================== BLSURFPlugin_Hypothesis::GeometricMesh BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh() { return DefaultGeom; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index e0e0f3b..bd50fb3 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -32,6 +32,7 @@ #include "SMESH_Hypothesis.hxx" #include "Utils_SALOME_Exception.hxx" +#include // Parameters for work of BLSURF @@ -65,12 +66,27 @@ public: void SetPhySize(double thePhySize); double GetPhySize() const { return _phySize; } + void SetPhyMin(double theMinSize); + double GetPhyMin() const { return _phyMin; } + + void SetPhyMax(double theMaxSize); + double GetPhyMax() const { return _phyMax; } + void SetGeometricMesh(GeometricMesh theGeometricMesh); GeometricMesh GetGeometricMesh() const { return _geometricMesh; } void SetAngleMeshS(double theAngle); double GetAngleMeshS() const { return _angleMeshS; } + void SetAngleMeshC(double theAngle); + double GetAngleMeshC() const { return _angleMeshC; } + + void SetGeoMin(double theMinSize); + double GetGeoMin() const { return _hgeoMin; } + + void SetGeoMax(double theMaxSize); + double GetGeoMax() const { return _hgeoMax; } + void SetGradation(double theGradation); double GetGradation() const { return _gradation; } @@ -80,14 +96,31 @@ public: void SetDecimesh(bool theVal); bool GetDecimesh() const { return _decimesh; } - static Topology GetDefaultTopology(); - static PhysicalMesh GetDefaultPhysicalMesh(); - static double GetDefaultPhySize(); + void SetVerbosity(int theVal); + int GetVerbosity() const { return _verb; } + + static Topology GetDefaultTopology(); + static PhysicalMesh GetDefaultPhysicalMesh(); + static double GetDefaultPhySize(); + static double GetDefaultMaxSize(); + static double GetDefaultMinSize(); static GeometricMesh GetDefaultGeometricMesh(); - static double GetDefaultAngleMeshS(); - static double GetDefaultGradation(); - static bool GetDefaultQuadAllowed(); - static bool GetDefaultDecimesh(); + static double GetDefaultAngleMeshS(); + static double GetDefaultAngleMeshC() { return GetDefaultAngleMeshS(); } + static double GetDefaultGradation(); + static bool GetDefaultQuadAllowed(); + static bool GetDefaultDecimesh(); + static int GetDefaultVerbosity() { return 10; } + + static double undefinedDouble() { return -1.0; } + + typedef std::map< std::string, std::string > TOptionValues; + + void SetOptionValue(const std::string& optionName, + const std::string& optionValue) throw (SALOME_Exception); + string GetOptionValue(const std::string& optionName) throw (SALOME_Exception); + void ClearOption(const std::string& optionName); + const TOptionValues& GetOptionValues() const { return _option2value; } // Persistence virtual ostream & SaveTo(ostream & save); @@ -106,12 +139,14 @@ public: private: Topology _topology; PhysicalMesh _physicalMesh; - double _phySize; + double _phySize, _phyMin, _phyMax; GeometricMesh _geometricMesh; - double _angleMeshS; + double _angleMeshS, _angleMeshC, _hgeoMin, _hgeoMax; double _gradation; bool _quadAllowed; bool _decimesh; + int _verb; + TOptionValues _option2value; }; #endif diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 32984aa..4d29bb3 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -155,6 +155,38 @@ CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize() return this->GetImpl()->GetPhySize(); } +//============================================================================= +void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetPhyMin(theMinSize); + SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )"; +} + +//============================================================================= +CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetPhyMin(); +} + + +//============================================================================= +void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetPhyMax(theMaxSize); + SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )"; +} + +//============================================================================= +CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetPhyMax(); +} + + //============================================================================= /*! * BLSURFPlugin_Hypothesis_i::SetGeometricMesh @@ -214,6 +246,49 @@ CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS() return this->GetImpl()->GetAngleMeshS(); } +//============================================================================= +void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetAngleMeshC(angle); + SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )"; +} + +//============================================================================= +CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetAngleMeshC(); +} + +//============================================================================= +void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize) +{ + this->GetImpl()->SetGeoMin(theMinSize); + SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )"; +} + +//============================================================================= +CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetGeoMin(); +} + +//============================================================================= +void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize) +{ + this->GetImpl()->SetGeoMax(theMaxSize); + SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )"; +} + +//============================================================================= +CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetGeoMax(); +} + //============================================================================= /*! * BLSURFPlugin_Hypothesis_i::SetGradation @@ -301,6 +376,113 @@ CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh() return this->GetImpl()->GetDecimesh(); } +//============================================================================= +void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + if ( theVal < 0 || theVal > 100 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM ); + this->GetImpl()->SetVerbosity(theVal); + SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )"; +} + +//============================================================================= + +CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity() +{ + ASSERT(myBaseImpl); + return (CORBA::Short) this->GetImpl()->GetVerbosity(); +} + +//============================================================================= + +void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName, + const char* optionValue) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + bool valueChanged = false; + try { + valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue ); + if ( valueChanged ) + this->GetImpl()->SetOptionValue(optionName, optionValue); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + SMESH::TPythonDump() << _this() << ".SetOptionValue( '" + << optionName << "', '" << optionValue << "' )"; +} + +//============================================================================= + +char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + try { + return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() ); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + return 0; +} + +//============================================================================= + +void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) +{ + ASSERT(myBaseImpl); + this->GetImpl()->ClearOption(optionName); + SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )"; +} + +//============================================================================= + +BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() +{ + ASSERT(myBaseImpl); + BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array(); + + const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues(); + result->length( opts.size() ); + + ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin(); + for ( int i = 0 ; opIt != opts.end(); ++opIt, ++i ) { + string name_value = opIt->first; + if ( !opIt->second.empty() ) { + name_value += ":"; + name_value += opIt->second; + } + result[i] = CORBA::string_dup(name_value.c_str()); + } + return result._retn(); +} + +//============================================================================= + +void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + for (int i = 0; i < options.length(); ++i) + { + string name_value = options[i].in(); + int colonPos = name_value.find( ':' ); + string name, value; + if ( colonPos == string::npos ) // ':' not found + name = name_value; + else { + name = name_value.substr( 0, colonPos); + if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ') + value = name_value.substr( colonPos ); + } + SetOptionValue( name.c_str(), value.c_str() ); + } +} + //============================================================================= /*! * BLSURFPlugin_Hypothesis_i::GetImpl diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index 0df0f0d..01c54cc 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -59,12 +59,27 @@ class BLSURFPlugin_Hypothesis_i: void SetPhySize(CORBA::Double theValue); CORBA::Double GetPhySize(); + void SetPhyMin(CORBA::Double theMinSize); + CORBA::Double GetPhyMin(); + + void SetPhyMax(CORBA::Double theMaxSize); + CORBA::Double GetPhyMax(); + void SetGeometricMesh(CORBA::Long theValue); CORBA::Long GetGeometricMesh(); void SetAngleMeshS(CORBA::Double theValue); CORBA::Double GetAngleMeshS(); + void SetAngleMeshC(CORBA::Double angle); + CORBA::Double GetAngleMeshC(); + + void SetGeoMin(CORBA::Double theMinSize); + CORBA::Double GetGeoMin(); + + void SetGeoMax(CORBA::Double theMaxSize); + CORBA::Double GetGeoMax(); + void SetGradation(CORBA::Double theValue); CORBA::Double GetGradation(); @@ -74,6 +89,19 @@ class BLSURFPlugin_Hypothesis_i: void SetDecimesh(CORBA::Boolean theValue); CORBA::Boolean GetDecimesh(); + void SetVerbosity(CORBA::Short theVal) throw (SALOME::SALOME_Exception); + CORBA::Short GetVerbosity(); + + void SetOptionValue(const char* optionName, + const char* optionValue) throw (SALOME::SALOME_Exception); + char* GetOptionValue(const char* optionName) throw (SALOME::SALOME_Exception); + + void UnsetOption(const char* optionName); + + BLSURFPlugin::string_array* GetOptionValues(); + + void SetOptionValues(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception); + // Get implementation ::BLSURFPlugin_Hypothesis* GetImpl(); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 6f727c5..b1f8ecc 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -30,8 +30,6 @@ #include #include -#include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm) - #include #include @@ -47,6 +45,17 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define WITH_SIZE_BOUNDARIES enum Topology { FromCAD, @@ -67,23 +76,35 @@ enum GeometricMesh UserDefined }; +enum { + STD_TAB = 0, + ADV_TAB, + OPTION_ID_COLUMN = 0, + OPTION_NAME_COLUMN, + OPTION_VALUE_COLUMN, + NB_COLUMNS +}; + BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType ) : SMESHGUI_GenericHypothesisCreator( theHypType ) { - + myPopup = 0; } BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator() { + if ( myPopup ) + delete myPopup; } bool BLSURFPluginGUI_HypothesisCreator::checkParams() const { - BlsurfHypothesisData data_old, data_new; - readParamsFromHypo( data_old ); - readParamsFromWidgets( data_new ); - bool res = storeParamsToHypo( data_new ); - return res; +// BlsurfHypothesisData data_old, data_new; +// readParamsFromHypo( data_old ); +// readParamsFromWidgets( data_new ); +// bool res = storeParamsToHypo( data_new ); +// return res; + return true; } QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() @@ -91,102 +112,203 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() QFrame* fr = new QFrame( 0, "myframe" ); QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 ); - QGroupBox* GroupC1 = new QGroupBox( 2, Qt::Horizontal, fr, "GroupC1" ); - lay->addWidget( GroupC1 ); - - GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupC1->layout()->setSpacing( 6 ); - GroupC1->layout()->setMargin( 11 ); - + // tab + QTabBar* tab = new QTabBar( fr, "QTabBar"); + tab->setShape( QTabBar::RoundedAbove ); + tab->insertTab( new QTab( tr( "SMESH_ARGUMENTS")), STD_TAB); + tab->insertTab( new QTab( tr( "GHS3D_ADV_ARGS")), ADV_TAB); + lay->addWidget( tab ); + + // basic parameters + + myStdGroup = new QGroupBox( 2, Qt::Horizontal, fr, "myStdGroup" ); + myStdGroup->layout()->setSpacing( 6 ); + myStdGroup->layout()->setMargin( 11 ); + lay->addWidget( myStdGroup ); + myName = 0; if( isCreation() ) { - new QLabel( tr( "SMESH_NAME" ), GroupC1 ); - myName = new QLineEdit( GroupC1 ); + new QLabel( tr( "SMESH_NAME" ), myStdGroup ); + myName = new QLineEdit( myStdGroup ); } - new QLabel( tr( "BLSURF_TOPOLOGY" ), GroupC1 ); - myTopology = new QtxComboBox( GroupC1 ); - QStringList topologyTypes; - topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_CAD" ) ); - topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_PROCESS" ) ); - topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_PROCESS2" ) ); - myTopology->insertStringList( topologyTypes ); - - new QLabel( tr( "BLSURF_PHY_MESH" ), GroupC1 ); - myPhysicalMesh = new QtxComboBox( GroupC1 ); + new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ); + myPhysicalMesh = new QtxComboBox( myStdGroup ); QStringList physicalTypes; physicalTypes.append( QObject::tr( "BLSURF_DEFAULT_USER" ) ); physicalTypes.append( QObject::tr( "BLSURF_CUSTOM_USER" ) ); myPhysicalMesh->insertStringList( physicalTypes ); - new QLabel( tr( "BLSURF_HPHYDEF" ), GroupC1 ); - myPhySize = new QtxDblSpinBox( GroupC1 ); + new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup ); + myPhySize = new QtxDblSpinBox( myStdGroup ); myPhySize->setMinValue( 1e-02 ); myPhySize->setMaxValue( 1e+02 ); myPhySize->setLineStep( 1 ); - new QLabel( tr( "BLSURF_GEOM_MESH" ), GroupC1 ); - myGeometricMesh = new QtxComboBox( GroupC1 ); +#ifdef WITH_SIZE_BOUNDARIES + new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ); + myPhyMin = new QtxDblSpinBox( myStdGroup ); + myPhyMin->setMinValue( 1e-06 ); + myPhyMin->setMaxValue( 1e+04 ); + myPhyMin->setLineStep( 1 ); + + new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ); + myPhyMax = new QtxDblSpinBox( myStdGroup ); + myPhyMax->setMinValue( 1e-04 ); + myPhyMax->setMaxValue( 1e+06 ); + myPhyMax->setLineStep( 1 ); +#endif + + new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ); + myGeometricMesh = new QtxComboBox( myStdGroup ); QStringList types; types.append( QObject::tr( "BLSURF_DEFAULT_GEOM" ) ); types.append( QObject::tr( "BLSURF_CUSTOM_GEOM" ) ); myGeometricMesh->insertStringList( types ); -// new QLabel( tr( "BLSURF_GROWTH_RATE" ), GroupC1 ); -// myGrowthRate = new QtxDblSpinBox( GroupC1 ); -// myGrowthRate->setMinValue( 0.1 ); -// myGrowthRate->setMaxValue( 10 ); -// myGrowthRate->setLineStep( 0.1 ); - - new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), GroupC1 ); - myAngleMeshS = new QtxDblSpinBox( GroupC1 ); + new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ); + myAngleMeshS = new QtxDblSpinBox( myStdGroup ); myAngleMeshS->setMinValue( 0 ); myAngleMeshS->setMaxValue( 16 ); myAngleMeshS->setLineStep( 0.5 ); - new QLabel( tr( "BLSURF_GRADATION" ), GroupC1 ); - myGradation = new QtxDblSpinBox( GroupC1 ); + new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ); + myAngleMeshC = new QtxDblSpinBox( myStdGroup ); + myAngleMeshC->setMinValue( 0 ); + myAngleMeshC->setMaxValue( 16 ); + myAngleMeshC->setLineStep( 0.5 ); + +#ifdef WITH_SIZE_BOUNDARIES + new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ); + myGeoMin = new QtxDblSpinBox( myStdGroup ); + myGeoMin->setMinValue( 1e-06 ); + myGeoMin->setMaxValue( 1e+04 ); + myGeoMin->setLineStep( 1 ); + + new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ); + myGeoMax = new QtxDblSpinBox( myStdGroup ); + myGeoMax->setMinValue( 1e-04 ); + myGeoMax->setMaxValue( 1e+06 ); + myGeoMax->setLineStep( 1 ); +#endif + + new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ); + myGradation = new QtxDblSpinBox( myStdGroup ); myGradation->setMinValue( 1.1 ); myGradation->setMaxValue( 2.5 ); myGradation->setLineStep( 0.1 ); -// new QLabel( tr( "BLSURF_SEG_PER_RADIUS" ), GroupC1 ); -// myNbSegPerRadius = new QtxDblSpinBox( GroupC1 ); -// myNbSegPerRadius->setMinValue( 0.2 ); -// myNbSegPerRadius->setMaxValue( 5.0 ); + myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup ); + myStdGroup->addSpace(0); + + myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup ); + myStdGroup->addSpace(0); - myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), GroupC1 ); - GroupC1->addSpace(0); -// myIs2D = true; - myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), GroupC1 ); - GroupC1->addSpace(0); - connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) ); - connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) ); + // advanced parameters + + myAdvGroup = new QGroupBox( 3, Qt::Horizontal, fr, "myAdvGroup" ); + lay->addWidget( myAdvGroup ); + QFrame* anAdvFrame = new QFrame(myAdvGroup, "anAdvFrame"); + QGridLayout* anAdvLayout = new QGridLayout(anAdvFrame, 5, 3); + anAdvLayout->setSpacing(6); + anAdvLayout->setAutoAdd(false); + + QLabel* aTopologyLabel = new QLabel( tr( "BLSURF_TOPOLOGY" ), anAdvFrame ); + myTopology = new QtxComboBox( anAdvFrame ); + QStringList topologyTypes; + topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_CAD" ) ); + topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_PROCESS" ) ); + topologyTypes.append( QObject::tr( "BLSURF_TOPOLOGY_PROCESS2" ) ); + myTopology->insertStringList( topologyTypes ); + + QLabel* aVarbosityLabel = new QLabel( tr( "BLSURF_VERBOSITY" ), anAdvFrame ); + myVerbosity = new QSpinBox( anAdvFrame ); + myVerbosity->setMinValue( 0 ); + myVerbosity->setMaxValue( 100 ); + myVerbosity->setLineStep( 5 ); + + QButton* addBtn = new QPushButton(tr("ADD_OPTION"), anAdvFrame, "addBtn"); + QButton* rmBtn = new QPushButton(tr("REMOVE_OPTION"), anAdvFrame, "rmBtn"); + + myOptionTable = new QTable( 0, NB_COLUMNS, anAdvFrame, "myOptionTable"); + myOptionTable->hideColumn( OPTION_ID_COLUMN ); + myOptionTable->horizontalHeader()->setLabel( OPTION_NAME_COLUMN, tr("OPTION_NAME_COLUMN")); + myOptionTable->horizontalHeader()->setLabel( OPTION_VALUE_COLUMN, tr("OPTION_VALUE_COLUMN")); + myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE ); + myOptionTable->setColumnReadOnly( OPTION_VALUE_COLUMN, FALSE ); + myOptionTable->setLeftMargin( 0 ); + + anAdvLayout->addWidget(aTopologyLabel, 0, 0); + anAdvLayout->addWidget(myTopology, 0, 1); + + anAdvLayout->addWidget(aVarbosityLabel, 1, 0); + anAdvLayout->addWidget(myVerbosity, 1, 1); + + anAdvLayout->addMultiCellWidget( myOptionTable, 2,4, 0,1 ); + anAdvLayout->addWidget( addBtn, 2, 2); + anAdvLayout->addWidget( rmBtn, 3, 2); + + anAdvLayout->setRowStretch( 4, 1 ); + anAdvLayout->setColStretch( 9, 1 ); + + onTabSelected( STD_TAB ); + + connect( tab, SIGNAL( selected ( int ) ), this, SLOT( onTabSelected(int) )); + connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() )); + connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() )); + connect( addBtn, SIGNAL( clicked()), this, SLOT( onAddOption() )); + connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() )); return fr; } void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const { + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + BlsurfHypothesisData data; - readParamsFromHypo( data ); + that->readParamsFromHypo( data ); if( myName ) { myName->setText( data.myName ); QFontMetrics metrics( myName->font() ); myName->setMinimumWidth( metrics.width( data.myName )+5 ); } - myTopology->setCurrentItem( data.myTopology ); - myPhysicalMesh->setCurrentItem( data.myPhysicalMesh ); - myPhySize->setValue( data.myPhySize ); - myGeometricMesh->setCurrentItem( data.myGeometricMesh ); - myAngleMeshS->setValue( data.myAngleMeshS); - myGradation->setValue( data.myGradation); - myAllowQuadrangles->setChecked( data.myAllowQuadrangles ); - myDecimesh->setChecked( data.myDecimesh ); - + myTopology ->setCurrentItem( data.myTopology ); + myPhysicalMesh ->setCurrentItem( data.myPhysicalMesh ); + myPhySize ->setValue ( data.myPhySize ); +#ifdef WITH_SIZE_BOUNDARIES + myPhyMin ->setValue ( data.myPhyMin ); + myPhyMax ->setValue ( data.myPhyMax ); + myGeoMin ->setValue ( data.myGeoMin ); + myGeoMax ->setValue ( data.myGeoMax ); +#endif + myGeometricMesh ->setCurrentItem( data.myGeometricMesh ); + myAngleMeshS ->setValue ( data.myAngleMeshS); + myAngleMeshC ->setValue ( data.myAngleMeshC); + myGradation ->setValue ( data.myGradation); + myAllowQuadrangles->setChecked ( data.myAllowQuadrangles ); + myDecimesh ->setChecked ( data.myDecimesh ); + myVerbosity ->setValue ( data.myVerbosity); + + if ( myOptions.operator->() ) { + BLSURFPluginGUI_HypothesisCreator* that = const_cast(this); + for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) { + QString option = that->myOptions[i].in(); + QStringList name_value = QStringList::split( ":", option ); + if ( name_value.size() > 1 ) { + QString idStr = QString("%1").arg( i ); + int row = myOptionTable->numRows(); + myOptionTable->insertRows( row ); + myOptionTable->setText( row, OPTION_ID_COLUMN, idStr); + myOptionTable->setText( row, OPTION_NAME_COLUMN, name_value[0]); + myOptionTable->setText( row, OPTION_VALUE_COLUMN, name_value[1] ); + } + } + } + myOptionTable->adjustColumn( OPTION_NAME_COLUMN ); // update widgets bool isPhysicalCustom = (myPhysicalMesh->currentItem() == PhysicalUserDefined); @@ -194,26 +316,17 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const bool isCustom = (myGeometricMesh->currentItem() == UserDefined); myAngleMeshS->setEnabled(isCustom); + myAngleMeshC->setEnabled(isCustom); myGradation->setEnabled(isCustom); } QString BLSURFPluginGUI_HypothesisCreator::storeParams() const { - BlsurfHypothesisData data; - readParamsFromWidgets( data ); - storeParamsToHypo( data ); + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - QString guiHyp; - guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( data.myTopology ) + "; "; - guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( data.myPhysicalMesh ) + "; "; - guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( data.myPhySize ) + "; "; - guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( data.myGeometricMesh ) + "; "; - guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( data.myAngleMeshS ) + "; "; - guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( data.myGradation ) + "; "; - guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(data.myAllowQuadrangles ? "yes" : "no") + "; "; - guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(data.myDecimesh ? "yes" : "no") + "; "; - - cout << "guiHyp : " << guiHyp << endl; + BlsurfHypothesisData data; + QString guiHyp = that->readParamsFromWidgets( data ); + that->storeParamsToHypo( data ); return guiHyp; } @@ -226,14 +339,25 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData HypothesisData* data = SMESH::GetHypothesisData( hypType() ); h_data.myName = isCreation() && data ? hypName() : ""; - h_data.myTopology = (int) h->GetTopology(); - h_data.myPhysicalMesh = (int) h->GetPhysicalMesh(); - h_data.myPhySize = h->GetPhySize(); - h_data.myGeometricMesh = (int) h->GetGeometricMesh(); - h_data.myAngleMeshS = h->GetAngleMeshS(); - h_data.myGradation = h->GetGradation(); + h_data.myTopology = (int) h->GetTopology(); + h_data.myPhysicalMesh = (int) h->GetPhysicalMesh(); + h_data.myPhySize = h->GetPhySize(); +#ifdef WITH_SIZE_BOUNDARIES + h_data.myPhyMin = h->GetPhyMin(); + h_data.myPhyMax = h->GetPhyMax(); + h_data.myGeoMin = h->GetGeoMin(); + h_data.myGeoMax = h->GetGeoMax(); +#endif + h_data.myGeometricMesh = (int) h->GetGeometricMesh(); + h_data.myAngleMeshS = h->GetAngleMeshS(); + h_data.myAngleMeshC = h->GetAngleMeshC(); + h_data.myGradation = h->GetGradation(); h_data.myAllowQuadrangles = h->GetQuadAllowed(); - h_data.myDecimesh = h->GetDecimesh(); + h_data.myDecimesh = h->GetDecimesh(); + h_data.myVerbosity = h->GetVerbosity(); + + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + that->myOptions = h->GetOptionValues(); return true; } @@ -263,14 +387,31 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi h->SetQuadAllowed( h_data.myAllowQuadrangles ); if ( h->GetDecimesh() != h_data.myDecimesh ) h->SetDecimesh( h_data.myDecimesh ); + if ( h->GetVerbosity() != h_data.myVerbosity ) + h->SetVerbosity( h_data.myVerbosity ); - if( (int) h_data.myPhysicalMesh == PhysicalUserDefined && - h->GetPhySize() != h_data.myPhySize) - h->SetPhySize( h_data.myPhySize ); - - if( (int) h_data.myGeometricMesh == UserDefined && - h->GetAngleMeshS() != h_data.myAngleMeshS ) - h->SetAngleMeshS( h_data.myAngleMeshS ); + if( (int) h_data.myPhysicalMesh == PhysicalUserDefined ) { + if ( h->GetPhySize() != h_data.myPhySize ) + h->SetPhySize( h_data.myPhySize ); + } + if( (int) h_data.myGeometricMesh == UserDefined ) { + if ( h->GetAngleMeshS() != h_data.myAngleMeshS ) + h->SetAngleMeshS( h_data.myAngleMeshS ); + if ( h->GetAngleMeshC() != h_data.myAngleMeshC ) + h->SetAngleMeshC( h_data.myAngleMeshC ); + } +#ifdef WITH_SIZE_BOUNDARIES + if ( h->GetPhyMin() != h_data.myPhyMin ) + h->SetPhyMin( h_data.myPhyMin ); + if ( h->GetPhyMax() != h_data.myPhyMax ) + h->SetPhyMax( h_data.myPhyMax ); + if ( h->GetGeoMin() != h_data.myGeoMin ) + h->SetGeoMin( h_data.myGeoMin ); + if ( h->GetGeoMax() != h_data.myGeoMax ) + h->SetGeoMax( h_data.myGeoMax ); +#endif + + h->SetOptionValues( myOptions ); } catch(const SALOME::SALOME_Exception& ex) { @@ -280,19 +421,62 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi return ok; } -bool BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const +QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const { h_data.myName = myName ? myName->text() : ""; h_data.myTopology = myTopology->currentItem(); h_data.myPhysicalMesh = myPhysicalMesh->currentItem(); h_data.myPhySize = myPhySize->value(); +#ifdef WITH_SIZE_BOUNDARIES + h_data.myPhyMin = myPhyMin->value(); + h_data.myPhyMax = myPhyMax->value(); + h_data.myGeoMin = myGeoMin->value(); + h_data.myGeoMax = myGeoMax->value(); +#endif h_data.myGeometricMesh = myGeometricMesh->currentItem(); h_data.myAngleMeshS = myAngleMeshS->value(); + h_data.myAngleMeshC = myAngleMeshC->value(); h_data.myGradation = myGradation->value(); h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked(); h_data.myDecimesh = myDecimesh->isChecked(); + h_data.myVerbosity = myVerbosity->value(); - return true; + QString guiHyp; + guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; "; + guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; "; + guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; "; + guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; "; + guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; "; + guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; "; + guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; "; + guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; "; +#ifdef WITH_SIZE_BOUNDARIES + guiHyp += "hphymin = " + QString::number( h_data.myPhyMin ) + "; "; + guiHyp += "hphymax = " + QString::number( h_data.myPhyMax ) + "; "; + guiHyp += "hgeomin = " + QString::number( h_data.myGeoMin ) + "; "; + guiHyp += "hgeomax = " + QString::number( h_data.myGeoMax ) + "; "; +#endif + + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + int row = 0, nbRows = myOptionTable->numRows(); + for ( ; row < nbRows; ++row ) + { + int id = myOptionTable->text( row, OPTION_ID_COLUMN ).toInt(); + if ( id >= 0 && id < myOptions->length() ) + { + QString name = myOptionTable->text( row, OPTION_NAME_COLUMN ); + QString value = myOptionTable->text( row, OPTION_VALUE_COLUMN ); + if ( !value ) + value = ""; + that->myOptions[ id ] = ( name + ":" + value).latin1(); + if ( value != "" ) + guiHyp += name + " = " + value + "; "; + } + } + + cout << "guiHyp : " << guiHyp << endl; + + return guiHyp; } void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() { @@ -319,6 +503,7 @@ void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() { void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { bool isCustom = (myGeometricMesh->currentItem() == UserDefined); myAngleMeshS->setEnabled(isCustom); + myAngleMeshC->setEnabled(isCustom); myGradation->setEnabled(isCustom); if ( ! isCustom ) { @@ -331,6 +516,7 @@ void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { break; } myAngleMeshS->setValue( aAngleMeshS ); + myAngleMeshC->setValue( aAngleMeshS ); myGradation->setValue( aGradation ); // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec) if ( myPhysicalMesh->currentItem() == DefaultSize ) { @@ -340,6 +526,79 @@ void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { } } +void BLSURFPluginGUI_HypothesisCreator::onTabSelected(int tab) +{ + if ( tab == STD_TAB ) { + myAdvGroup->hide(); + myStdGroup->show(); + } + else { + myStdGroup->hide(); + myAdvGroup->show(); + } + qApp->processEvents(); + dlg()->adjustSize(); +} + +void BLSURFPluginGUI_HypothesisCreator::onAddOption() +{ + if (!myPopup) { + // fill popup with option names + myPopup = new QPopupMenu(); + if ( myOptions.operator->() ) { + for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) { + QString name_value = myOptions[i].in(); + QString name = QStringList::split( ":", name_value )[0]; + myPopup->insertItem( name, i ); + } + } + connect( myPopup, SIGNAL( activated( int ) ), SLOT( onOptionChosenInPopup( int ) ) ); + } + if ( myPopup && myPopup->text(0) ) + myPopup->exec( QCursor::pos() ); +} + +void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup(int i) +{ + QString idStr = QString("%1").arg( i ); + QString option = myOptions[i].in(); + QString optionName = QStringList::split( ":", option )[0]; + + // look for a row with optionName + int row = 0, nbRows = myOptionTable->numRows(); + for ( ; row < nbRows; ++row ) + if ( myOptionTable->text( row, OPTION_ID_COLUMN ) == idStr ) + break; + // add a row if not found + if ( row == nbRows ) + myOptionTable->insertRows( nbRows ); + + myOptionTable->setText( row, OPTION_ID_COLUMN, idStr); + myOptionTable->setText( row, OPTION_NAME_COLUMN, optionName); + myOptionTable->editCell( row, OPTION_VALUE_COLUMN ); + myOptionTable->adjustColumn( OPTION_NAME_COLUMN ); +} + +void BLSURFPluginGUI_HypothesisCreator::onDeleteOption() +{ + // clear option values and remember selected row + std::set selectedRows; + int row = 0, nbRows = myOptionTable->numRows(); + for ( ; row < nbRows; ++row ) { + if ( myOptionTable->isRowSelected( row )) { + selectedRows.insert( row ); + int id = myOptionTable->text( row, OPTION_ID_COLUMN ).toInt(); + if ( id >= 0 && id < myOptions->length() ) + myOptions[ id ] = myOptionTable->text( row, OPTION_NAME_COLUMN ); + } + } + // remove selected rows + std::set::reverse_iterator r = selectedRows.rbegin(); + for ( ; r != selectedRows.rend(); ++r ) + myOptionTable->removeRow ( *r ); +} + + QString BLSURFPluginGUI_HypothesisCreator::caption() const { return tr( "BLSURF_TITLE" ); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index 9dbd2ec..9ee08af 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -30,19 +30,25 @@ #define BLSURFPLUGINGUI_HypothesisCreator_HeaderFile #include +#include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm) class QtxDblSpinBox; class QtxComboBox; class QCheckBox; class QLineEdit; +class QTable; +class QSpinBox; +class QPopupMenu; typedef struct { - int myTopology; + int myTopology, myVerbosity; int myPhysicalMesh, myGeometricMesh; - double myPhySize, myAngleMeshS, myGradation; + double myPhySize, myPhyMin, myPhyMax, myAngleMeshS, myAngleMeshC, myGradation; + double myGeoMin, myGeoMax; bool myAllowQuadrangles, myDecimesh; QString myName; + } BlsurfHypothesisData; /*! @@ -72,25 +78,42 @@ protected: virtual QString type() const; protected slots: - virtual void onPhysicalMeshChanged(); - virtual void onGeometricMeshChanged(); + void onPhysicalMeshChanged(); + void onGeometricMeshChanged(); + void onTabSelected(int); + void onAddOption(); + void onDeleteOption(); + void onOptionChosenInPopup(int); private: - bool readParamsFromHypo( BlsurfHypothesisData& ) const; - bool readParamsFromWidgets( BlsurfHypothesisData& ) const; - bool storeParamsToHypo( const BlsurfHypothesisData& ) const; + bool readParamsFromHypo( BlsurfHypothesisData& ) const; + QString readParamsFromWidgets( BlsurfHypothesisData& ) const; + bool storeParamsToHypo( const BlsurfHypothesisData& ) const; private: - QLineEdit* myName; - QtxComboBox* myTopology; - QtxComboBox* myPhysicalMesh; - QtxDblSpinBox* myPhySize; - QtxComboBox* myGeometricMesh; - QtxDblSpinBox* myAngleMeshS; - QtxDblSpinBox* myGradation; - QCheckBox* myAllowQuadrangles; - QCheckBox* myDecimesh; + QGroupBox* myStdGroup; + QLineEdit* myName; + QtxComboBox* myPhysicalMesh; + QtxDblSpinBox* myPhySize; + QtxDblSpinBox* myPhyMin; + QtxDblSpinBox* myPhyMax; + QtxComboBox* myGeometricMesh; + QtxDblSpinBox* myAngleMeshS; + QtxDblSpinBox* myAngleMeshC; + QtxDblSpinBox* myGeoMin; + QtxDblSpinBox* myGeoMax; + QtxDblSpinBox* myGradation; + QCheckBox* myAllowQuadrangles; + QCheckBox* myDecimesh; + + QGroupBox* myAdvGroup; + QtxComboBox* myTopology; + QSpinBox* myVerbosity; + QTable* myOptionTable; + QPopupMenu* myPopup; + + BLSURFPlugin::string_array_var myOptions; }; #endif diff --git a/src/GUI/BLSURFPlugin_msg_en.po b/src/GUI/BLSURFPlugin_msg_en.po index 85d0c1a..2ad1c4b 100755 --- a/src/GUI/BLSURFPlugin_msg_en.po +++ b/src/GUI/BLSURFPlugin_msg_en.po @@ -55,7 +55,8 @@ msgid "BLSURF_PHY_MESH" msgstr "Physical Mesh" msgid "BLSURF_DEFAULT_USER" -msgstr "Default" +msgstr "None" +#msgstr "Default" #PAL19680 msgid "BLSURF_CUSTOM_USER" msgstr "Custom" @@ -63,11 +64,24 @@ msgstr "Custom" msgid "BLSURF_HPHYDEF" msgstr "User Size" +msgid "BLSURF_HPHYMIN" +msgstr "Min Physical Size" + +msgid "BLSURF_HPHYMAX" +msgstr "Max Physical Size" + +msgid "BLSURF_HGEOMIN" +msgstr "Min Geometrical Size" + +msgid "BLSURF_HGEOMAX" +msgstr "Max Geometrical Size" + msgid "BLSURF_GEOM_MESH" msgstr "Geometrical Mesh" msgid "BLSURF_DEFAULT_GEOM" -msgstr "Default" +msgstr "None" +#msgstr "Default" #PAL19680 msgid "BLSURF_CUSTOM_GEOM" msgstr "Custom" @@ -75,14 +89,33 @@ msgstr "Custom" msgid "BLSURF_ANGLE_MESH_S" msgstr "Angle Mesh S" +msgid "BLSURF_ANGLE_MESH_C" +msgstr "Angle Mesh C" + msgid "BLSURF_GRADATION" msgstr "Gradation" msgid "BLSURF_DECIMESH" msgstr "Patch independent" +msgid "BLSURF_VERBOSITY" +msgstr "Verbosity level" + msgid "BLSURF_ALLOW_QUADRANGLES" msgstr "Allow Quadrangles (Test)" msgid "BLSURF_TITLE" msgstr "Hypothesis Construction" + +msgid "ADD_OPTION" +msgstr "Add option" + +msgid "REMOVE_OPTION" +msgstr "Clear option" + +msgid "OPTION_NAME_COLUMN" +msgstr "Option" + +msgid "OPTION_VALUE_COLUMN" +msgstr "Value" + diff --git a/src/GUI/Makefile.in b/src/GUI/Makefile.in index 885f073..63e6625 100644 --- a/src/GUI/Makefile.in +++ b/src/GUI/Makefile.in @@ -18,7 +18,7 @@ # See http://www.salome-platform.org/ # # File : Makefile.in -// Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) +# Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) # Module : BLSURFPLUGIN top_srcdir=@top_srcdir@ -- 2.39.2