Implementation notebook in the SMESH module.

This commit is contained in:
rnv 2008-11-25 13:58:31 +00:00
parent e184ed39fa
commit 6c1ba1451c
13 changed files with 300 additions and 200 deletions

View File

@ -39,8 +39,11 @@ module SMESH
DIM_3D DIM_3D
}; };
typedef sequence<string> ListOfParameters;
interface SMESH_Hypothesis : SALOME::GenericObj interface SMESH_Hypothesis : SALOME::GenericObj
{ {
/*! /*!
* Get the Hypothesis typeName * Get the Hypothesis typeName
*/ */
@ -68,6 +71,11 @@ module SMESH
*/ */
string GetParameters(); string GetParameters();
/*!
* Return list of last notebook variables used for Hypothesis creation.
*/
ListOfParameters GetLastParameters();
/*! /*!
* Verify whether hypothesis supports given entity type * Verify whether hypothesis supports given entity type
*/ */

View File

@ -1239,6 +1239,16 @@ SalomeApp_Study* SMESHGUI::activeStudy()
return NULL; return NULL;
} }
//=============================================================================
/*!
*
*/
//=============================================================================
char* SMESHGUI::JoinObjectParameters(const QStringList& theParametersList)
{
return theParametersList.join(":").toLatin1().data();
}
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -70,6 +70,8 @@ public :
static SUIT_ResourceMgr* resourceMgr(); static SUIT_ResourceMgr* resourceMgr();
static SUIT_Desktop* desktop(); static SUIT_Desktop* desktop();
static SalomeApp_Study* activeStudy(); static SalomeApp_Study* activeStudy();
static char* JoinObjectParameters(const QStringList& theParametersList);
bool isActiveStudyLocked(); bool isActiveStudyLocked();
static bool automaticUpdate(); static bool automaticUpdate();

View File

@ -238,7 +238,7 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
w = sb; w = sb;
} }
else if(aStudy->IsReal(aVar.toLatin1().constData())){ else if(aStudy->IsReal(aVar.toLatin1().constData())){
SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 ); SalomeApp_DoubleSpinBox* sb = new SalomeApp_DoubleSpinBox( GroupC1 );
sb->setObjectName( (*anIt).myName ); sb->setObjectName( (*anIt).myName );
attuneStdWidget( sb, i ); attuneStdWidget( sb, i );
sb->setText( aVar ); sb->setText( aVar );
@ -327,34 +327,16 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
{ {
QStringList aResult; QStringList aResult;
QString item; ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); for( ; anIt!=aLast; anIt++ ) {
if(aStudy) { if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) ) {
ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end(); SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
for( ; anIt!=aLast; anIt++ ) { aResult.append(sb->text());
if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) ) }
{ else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) ) {
SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt ); QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt );
item = sb->text(); aResult.append(sb->text());
bool isVariable = aStudy->IsVariable(item.toLatin1().constData());
isVariable ? aResult.append( item ) : aResult.append(QString());
}
else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) )
{
QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt );
item = sb->text();
bool isVariable = aStudy->IsVariable(item.toLatin1().constData());
isVariable ? aResult.append( item ) : aResult.append(QString());
}
} }
bool hasVar = false;
for (int i = 0;i<aResult.size();i++)
if(!aResult[i].isEmpty())
hasVar = true;
if(!hasVar)
aResult.clear();
} }
return aResult; return aResult;
} }

View File

@ -473,6 +473,7 @@ public:
void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters); void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters);
char* GetParameters(CORBA::Object_ptr theObject); char* GetParameters(CORBA::Object_ptr theObject);
private: private:
// Create hypothesis of given type // Create hypothesis of given type
SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName, SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName,

View File

@ -882,14 +882,27 @@ void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theP
if ( !aHyp->_is_nil() ) { if ( !aHyp->_is_nil() ) {
CORBA::String_var objStr = aHyp->GetParameters(); CORBA::String_var objStr = aHyp->GetParameters();
TCollection_AsciiString aParams(theParameters); TCollection_AsciiString aNewParams;
if(aParams.Length()) { TCollection_AsciiString anInputParams;
SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(theParameters);
anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
SALOMEDS::AttributeString::_narrow(anAttr)->SetValue( aParams.ToCString() ); SALOMEDS::GenericAttribute_var anAttr;
anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
TCollection_AsciiString aOldParameters(aStringAttr->Value());
SALOMEDS::ListOfStrings aVars= aSections[0];
for(int i=0;i<aVars.length();i++ ) {
anInputParams += aStudy->IsVariable(aVars[i].in()) ?
TCollection_AsciiString(aVars[i].in()) : TCollection_AsciiString("");
if(i != aVars.length()-1)
anInputParams+=":";
} }
if(!aOldParameters.Length())
aNewParams = anInputParams;
else else
aStudyBuilder->RemoveAttribute(aSObj,"AttributeString"); aNewParams = aOldParameters+"|"+anInputParams;
aStringAttr->SetValue( aNewParams.ToCString() );
} }
} }

View File

@ -130,19 +130,48 @@ CORBA::Long SMESH_Hypothesis_i::GetId()
//============================================================================= //=============================================================================
void SMESH_Hypothesis_i::SetParameters(const char* theParameters) void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
{ {
string aNewParameters(theParameters); SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),
string anOldParameters(GetParameters()); CORBA::string_dup(theParameters));
if(aNewParameters.compare(anOldParameters) != 0)
SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),
theParameters);
} }
//=============================================================================
/*!
* SMESH_Hypothesis_i::GetParameters()
*
*/
//=============================================================================
char* SMESH_Hypothesis_i::GetParameters() char* SMESH_Hypothesis_i::GetParameters()
{ {
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
return CORBA::string_dup(gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this()))); return CORBA::string_dup(gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this())));
} }
//=============================================================================
/*!
* SMESH_Hypothesis_i::GetLastParameters()
*
*/
//=============================================================================
SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters()
{
SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters();
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
if(gen) {
char *aParameters = GetParameters();
SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy();
if(!aStudy->_is_nil()) {
SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
if(aSections->length() > 0) {
SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1];
aResult->length(aVars.length());
for(int i = 0;i < aVars.length();i++)
aResult[i] = CORBA::string_dup( aVars[i]);
}
}
}
return aResult._retn();
}
//============================================================================= //=============================================================================
/*! /*!
* SMESH_Hypothesis_i::GetImpl * SMESH_Hypothesis_i::GetImpl

View File

@ -72,6 +72,9 @@ public:
// Return list of notebook variables used for Hypothesis creation separated by ":" symbol // Return list of notebook variables used for Hypothesis creation separated by ":" symbol
char* GetParameters(); char* GetParameters();
//Return list of last notebook variables used for Hypothesis creation.
SMESH::ListOfParameters* GetLastParameters();
// Get implementation // Get implementation
::SMESH_Hypothesis* GetImpl(); ::SMESH_Hypothesis* GetImpl();

View File

@ -39,6 +39,80 @@ static int MYDEBUG = 0;
using namespace std; using namespace std;
//================================================================================
/*!
* \brief Constructor
*/
//================================================================================
ObjectStates::ObjectStates(TCollection_AsciiString theType)
{
_type = theType;
_dumpstate = 0;
}
//================================================================================
/*!
* \brief Destructor
*/
//================================================================================
ObjectStates::~ObjectStates()
{
}
//================================================================================
/*!
* \brief Add new object state
* \param theState - Object state (vector of notebook variable)
*/
//================================================================================
void ObjectStates::AddState(const TState &theState)
{
_states.push_back(theState);
}
//================================================================================
/*!
* \brief Return current object state
* \\retval state - Object state (vector of notebook variable)
*/
//================================================================================
TState ObjectStates::GetCurrectState() const
{
return _states[_dumpstate];
}
//================================================================================
/*!
*
*/
//================================================================================
TAllStates ObjectStates::GetAllStates() const
{
return _states;
}
//================================================================================
/*!
*
*/
//================================================================================
void ObjectStates::IncrementState()
{
_dumpstate++;
}
//================================================================================
/*!
*
*/
//================================================================================
TCollection_AsciiString ObjectStates::GetObjectType() const{
return _type;
}
//================================================================================ //================================================================================
/*! /*!
* \brief Constructor * \brief Constructor
@ -51,11 +125,16 @@ SMESH_NoteBook::SMESH_NoteBook()
//================================================================================ //================================================================================
/*! /*!
* \brief Constructor * \brief Destructor
*/ */
//================================================================================ //================================================================================
SMESH_NoteBook::~SMESH_NoteBook() SMESH_NoteBook::~SMESH_NoteBook()
{ {
TVariablesMap::const_iterator it = _objectMap.begin();
for(;it!=_objectMap.end();it++) {
if((*it).second)
delete (*it).second;
}
} }
//================================================================================ //================================================================================
@ -72,12 +151,21 @@ TCollection_AsciiString SMESH_NoteBook::ReplaceVariables(const TCollection_Ascii
TCollection_AsciiString aObject = aCmd.GetObject(); TCollection_AsciiString aObject = aCmd.GetObject();
TVariablesMap::const_iterator it = _objectMap.find(aObject); TVariablesMap::const_iterator it = _objectMap.find(aObject);
if(!aMethod.IsEmpty() && it != _objectMap.end() ) { if(!aMethod.IsEmpty() && it != _objectMap.end() ) {
ObjectStates *aStates = (*it).second;
if(aMethod == "SetLength" && !(*it).second.at(0).IsEmpty() ) { bool modified = false;
aCmd.SetArg(1,(*it).second.at(0)); if(MYDEBUG)
} cout<<"SMESH_NoteBook::ReplaceVariables :Object Type : "<<aStates->GetObjectType()<<endl;
else if(aMethod == "SetPrecision" && !(*it).second.at(1).IsEmpty() ){ if(aStates->GetObjectType().IsEqual("LocalLength")) {
aCmd.SetArg(1,(*it).second.at(1)); if(aMethod == "SetLength") {
if(!aStates->GetCurrectState().at(0).IsEmpty() )
aCmd.SetArg(1,aStates->GetCurrectState().at(0));
aStates->IncrementState();
}
else if(aMethod == "SetPrecision") {
if(!aStates->GetCurrectState().at(1).IsEmpty() )
aCmd.SetArg(1,aStates->GetCurrectState().at(1));
aStates->IncrementState();
}
} }
return aCmd.GetString(); return aCmd.GetString();
} }
@ -104,58 +192,47 @@ void SMESH_NoteBook::InitObjectMap()
return; return;
SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO); SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
TCollection_AsciiString aParameters; char* aParameters;
for(Itr->InitEx(true); Itr->More(); Itr->Next()) { for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
SALOMEDS::SObject_var aSObject = Itr->Value(); SALOMEDS::SObject_var aSObject = Itr->Value();
SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::GenericAttribute_var anAttr;
if ( aSObject->FindAttribute(anAttr, "AttributeString")) { if ( aSObject->FindAttribute(anAttr, "AttributeString")) {
aParameters = TCollection_AsciiString(SALOMEDS::AttributeString::_narrow(anAttr)->Value()); aParameters = SALOMEDS::AttributeString::_narrow(anAttr)->Value();
vector<string> vect = ParseVariables(aParameters.ToCString(),':'); SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
if(MYDEBUG) { if(MYDEBUG) {
cout<<"Entry : "<< aSObject->GetID()<<endl; cout<<"Entry : "<< aSObject->GetID()<<endl;
cout<<"aParameters : "<<aParameters<<endl; cout<<"aParameters : "<<aParameters<<endl;
} }
vector<TCollection_AsciiString> aVars; TCollection_AsciiString anObjType;
for(int i = 0;i<vect.size();i++) { CORBA::Object_var anObject = SMESH_Gen_i::SObjectToObject(aSObject);
TCollection_AsciiString aVar(vect[i].c_str()); SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject);
if(!aVar.IsEmpty() && aStudy->IsVariable(vect[i].c_str())) { if(!aHyp->_is_nil()) {
aVar.InsertBefore(1,"\""); anObjType = TCollection_AsciiString(aHyp->GetName());
aVar.InsertAfter(aVar.Length(),"\"");
}
aVars.push_back(aVar);
if(MYDEBUG) {
cout<<"Variable: "<<aVar<<endl;
}
} }
_objectMap.insert(pair<TCollection_AsciiString,vector<TCollection_AsciiString> >(TCollection_AsciiString(aSObject->GetID()),aVars)); else if(SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObject)) {
anObjType = TCollection_AsciiString("Mesh");
}
if(MYDEBUG)
cout<<"The object Type : "<<anObjType<<endl;
ObjectStates *aState = new ObjectStates(anObjType);
for(int i = 0; i < aSections->length(); i++) {
TState aVars;
SALOMEDS::ListOfStrings aListOfVars = aSections[i];
for(int j = 0;j<aListOfVars.length();j++) {
TCollection_AsciiString aVar(aListOfVars[j].in());
if(!aVar.IsEmpty() && aStudy->IsVariable(aVar.ToCString())) {
aVar.InsertBefore(1,"\"");
aVar.InsertAfter(aVar.Length(),"\"");
}
aVars.push_back(aVar);
if(MYDEBUG) {
cout<<"Variable: '"<<aVar<<"'"<<endl;
}
}
aState->AddState(aVars);
}
_objectMap.insert(pair<TCollection_AsciiString,ObjectStates*>(TCollection_AsciiString(aSObject->GetID()),aState));
} }
} }
} }
//================================================================================
/*!
* \brief Private method
*/
//================================================================================
vector<string> SMESH_NoteBook::ParseVariables(const string& theVariables, const char sep) const
{
vector<string> aResult;
if(theVariables[0] == sep ) aResult.push_back(string());
int pos = theVariables.find(sep);
if(pos < 0) {
aResult.push_back(theVariables);
return aResult;
}
string s = theVariables;
if(s[0] == sep) s = s.substr(1, s.size());
while((pos = s.find(sep)) >= 0) {
aResult.push_back(s.substr(0, pos));
s = s.substr(pos+1, s.size());
}
if(!s.empty() && s[0] != sep) aResult.push_back(s);
if(theVariables[theVariables.size()-1] == sep) aResult.push_back(string());
return aResult;
}

View File

@ -30,6 +30,30 @@
#include <vector> #include <vector>
#include <string> #include <string>
typedef std::vector<TCollection_AsciiString> TState;
typedef std::vector<TState> TAllStates;
class ObjectStates{
public:
ObjectStates(TCollection_AsciiString theType);
~ObjectStates();
void AddState(const TState &theState);
TState GetCurrectState() const;
TAllStates GetAllStates() const;
void IncrementState();
TCollection_AsciiString GetObjectType() const;
private:
TCollection_AsciiString _type;
TAllStates _states;
int _dumpstate;
};
class SMESH_NoteBook class SMESH_NoteBook
{ {
@ -38,11 +62,10 @@ public:
~SMESH_NoteBook(); ~SMESH_NoteBook();
TCollection_AsciiString ReplaceVariables(const TCollection_AsciiString& theString) const; TCollection_AsciiString ReplaceVariables(const TCollection_AsciiString& theString) const;
typedef std::map<TCollection_AsciiString,std::vector<TCollection_AsciiString> > TVariablesMap; typedef std::map<TCollection_AsciiString,ObjectStates*> TVariablesMap;
private: private:
void InitObjectMap(); void InitObjectMap();
std::vector<std::string> ParseVariables(const std::string& theVariables, const char sep) const;
private: private:
TVariablesMap _objectMap; TVariablesMap _objectMap;

View File

@ -155,6 +155,9 @@ DefaultSize, DefaultGeom, Custom = 0,0,1
PrecisionConfusion = 1e-07 PrecisionConfusion = 1e-07
# Salome notebook variable separator
variable_separator = ":"
def IsEqual(val1, val2, tol=PrecisionConfusion): def IsEqual(val1, val2, tol=PrecisionConfusion):
if abs(val1 - val2) < tol: if abs(val1 - val2) < tol:
return True return True
@ -164,8 +167,6 @@ NO_NAME = "NoName"
## Gets object name ## Gets object name
def GetName(obj): def GetName(obj):
if isinstance(obj, BaseWrapper):
obj = obj.GetAlgorithm()
ior = salome.orb.object_to_string(obj) ior = salome.orb.object_to_string(obj)
sobj = salome.myStudy.FindObjectIOR(ior) sobj = salome.myStudy.FindObjectIOR(ior)
if sobj is None: if sobj is None:
@ -176,8 +177,6 @@ def GetName(obj):
## Sets a name to the object ## Sets a name to the object
def SetName(obj, name): def SetName(obj, name):
if isinstance(obj, BaseWrapper):
obj = obj.GetAlgorithm()
ior = salome.orb.object_to_string(obj) ior = salome.orb.object_to_string(obj)
sobj = salome.myStudy.FindObjectIOR(ior) sobj = salome.myStudy.FindObjectIOR(ior)
if not sobj is None: if not sobj is None:
@ -348,17 +347,6 @@ class smeshDC(SMESH._objref_SMESH_Gen):
aMesh = Mesh(self, self.geompyD, aSmeshMesh) aMesh = Mesh(self, self.geompyD, aSmeshMesh)
return aMesh return aMesh
## Create hyporthesis
# @return an instance of hypothesis
# @ingroup l2_impexp
def CreateHypothesis(self, hyp, so):
hypo = SMESH._objref_SMESH_Gen.CreateHypothesis(self, hyp, so)
if hyp == "LocalLength":
hypo = LocalLength(hypo)
return hypo
## Creates a Mesh object(s) importing data from the given MED file ## Creates a Mesh object(s) importing data from the given MED file
# @return a list of Mesh class instances # @return a list of Mesh class instances
# @ingroup l2_impexp # @ingroup l2_impexp
@ -957,7 +945,7 @@ class Mesh:
# @return SMESH.Hypothesis_Status # @return SMESH.Hypothesis_Status
# @ingroup l2_hypotheses # @ingroup l2_hypotheses
def AddHypothesis(self, hyp, geom=0): def AddHypothesis(self, hyp, geom=0):
if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper): if isinstance( hyp, Mesh_Algorithm ):
hyp = hyp.GetAlgorithm() hyp = hyp.GetAlgorithm()
pass pass
if not geom: if not geom:
@ -976,7 +964,7 @@ class Mesh:
# @return SMESH.Hypothesis_Status # @return SMESH.Hypothesis_Status
# @ingroup l2_hypotheses # @ingroup l2_hypotheses
def RemoveHypothesis(self, hyp, geom=0): def RemoveHypothesis(self, hyp, geom=0):
if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper): if isinstance( hyp, Mesh_Algorithm ):
hyp = hyp.GetAlgorithm() hyp = hyp.GetAlgorithm()
pass pass
if not geom: if not geom:
@ -2889,12 +2877,7 @@ class Mesh_Algorithm:
pass pass
SetName(hypo, hyp + a) SetName(hypo, hyp + a)
pass pass
bhypo = None status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
if isinstance(hypo,BaseWrapper):
bhypo = hypo.GetAlgorithm()
else:
bhypo = hypo
status = self.mesh.mesh.AddHypothesis(self.geom, bhypo)
TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 ) TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
return hypo return hypo
@ -4034,67 +4017,44 @@ class Mesh_UseExisting(Mesh_Algorithm):
self.Create(mesh, geom, "UseExisting_2D") self.Create(mesh, geom, "UseExisting_2D")
import salome_notebook
notebook = salome_notebook.notebook
##Return values of the notebook variables
from salome_notebook import * def ParseParameters(last, nbParams,nbParam, value):
result = None
##Base class for wrap all StdMeshers interfaces strResult = ""
class BaseWrapper: counter = 0
listSize = len(last)
##Return instance of a _objref_StdMeshers hypothesis for n in range(0,nbParams):
def GetAlgorithm(self): if n+1 != nbParam:
return self.hypo if counter < listSize:
strResult = strResult + last[counter]
##Return values of the notebook variables else:
def ParseParameters(self, params ,nbParams, nbParam, arg): strResult = strResult + ""
result = None
strResult = ""
isVar = False
if isinstance(arg, str):
if notebook.isVariable(arg):
result = notebook.get(arg)
isVar = True
else: else:
result = arg if isinstance(value, str) and notebook.isVariable(value):
result = notebook.get(value)
strResult=strResult+value
else:
strResult=strResult+str(value)
result = value
if nbParams - 1 != counter:
strResult=strResult+variable_separator #":"
counter = counter+1
return result, strResult
isEmpty = True class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
paramsList = []
if len(params) > 0:
paramsList = params.split(":")
isEmpty = False
for n in range(1,nbParams+1):
if n != nbParam and not isEmpty and len(paramsList[n-1])> 0:
strResult = paramsList[n-1] + ":"
pass
if isVar and n == nbParam:
if len(strResult) == 0 and nbParam != 1:
strResult = strResult + ":"
pass
strResult = strResult+arg
if n != nbParams:
strResult = strResult + ":"
return result, strResult
#Wrapper class for StdMeshers_LocalLength hypothesis
class LocalLength(BaseWrapper):
def __init__(self, hypo):
self.hypo = hypo
def SetLength(self, length): def SetLength(self, length):
length,parameters = self.ParseParameters(self.hypo.GetParameters(),2,1,length) length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
self.hypo.SetParameters(parameters) StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
self.hypo.SetLength(length) StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
def SetPrecision(self, precision): def SetPrecision(self, precision):
precision,parameters = self.ParseParameters(self.hypo.GetParameters(),2,2,precision) precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
self.hypo.SetParameters(parameters) StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
self.hypo.SetPrecision(precision) StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
def GetLength(self): #Registering the new proxy for LocalLength
return self.hypo.GetLength() omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
def GetPrecision(self):
return self.hypo.GetLength()

View File

@ -409,15 +409,11 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
{ {
StdMeshers::StdMeshers_LocalLength_var h = StdMeshers::StdMeshers_LocalLength_var h =
StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() ); StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
if(!aVariablesList.isEmpty()) {
QString aVariables = aVariablesList.join(":");
h->SetParameters(aVariables.toLatin1().constData());
}
else
h->SetParameters("");
h->SetLength( params[0].myValue.toDouble() ); h->SetLength( params[0].myValue.toDouble() );
h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
h->SetPrecision( params[1].myValue.toDouble() ); h->SetPrecision( params[1].myValue.toDouble() );
h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
} }
else if( hypType()=="SegmentLengthAroundVertex" ) else if( hypType()=="SegmentLengthAroundVertex" )
{ {
@ -561,28 +557,23 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
{ {
StdMeshers::StdMeshers_LocalLength_var h = StdMeshers::StdMeshers_LocalLength_var h =
StdMeshers::StdMeshers_LocalLength::_narrow( hyp ); StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
QString aParameters(h->GetParameters());
QStringList aParametersList;
if(aParameters.length())
aParametersList = aParameters.split(":");
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM"); item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
QVariant aVariable = parseParameter(aParametersList,0);
if(aVariable.type() != QVariant::Invalid) { QString aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
item.myValue = aVariable; item.isVariable = !aVaribaleName.isEmpty();
item.isVariable = true; if(item.isVariable)
} item.myValue = aVaribaleName;
else else
item.myValue = h->GetLength(); item.myValue = h->GetLength();
p.append( item ); p.append( item );
item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION"); item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
aVariable = parseParameter(aParametersList,1); aVaribaleName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString("");
if(aVariable.type() != QVariant::Invalid) { item.isVariable = !aVaribaleName.isEmpty();
item.myValue = aVariable; if(item.isVariable)
item.isVariable = true; item.myValue = aVaribaleName;
}
else else
item.myValue = h->GetPrecision(); item.myValue = h->GetPrecision();
p.append( item ); p.append( item );
@ -948,7 +939,7 @@ void StdMeshersGUI_StdHypothesisCreator::onReject()
* \brief * \brief
*/ */
//================================================================================ //================================================================================
QVariant StdMeshersGUI_StdHypothesisCreator:: /*QVariant StdMeshersGUI_StdHypothesisCreator::
parseParameter(const QStringList& theList, int theNbParam) const parseParameter(const QStringList& theList, int theNbParam) const
{ {
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
@ -974,3 +965,4 @@ parseParameter(const QStringList& theList, int theNbParam) const
} }
return aResult; return aResult;
} }
*/

View File

@ -58,7 +58,7 @@ protected:
virtual QWidget* getWidgetForParam( int paramIndex ) const; virtual QWidget* getWidgetForParam( int paramIndex ) const;
virtual ListOfWidgets* customWidgets() const; virtual ListOfWidgets* customWidgets() const;
virtual void onReject(); virtual void onReject();
virtual QVariant parseParameter(const QStringList& theList, int theNbParam) const; // virtual QVariant parseParameter(const QStringList& theList, int theNbParam) const;
template<class T> template<class T>
T* widget(int i) const { T* widget(int i) const {