*/
ListOfParameters GetLastParameters();
+ /*!
+ * Set list of parameters
+ * \param theParameters is a string containing the last notebook variables separated by ":" symbol,
+ * used for Hypothesis creation
+ */
+ void SetLastParameters(in string theParameters);
+
+ /*!
+ * Clear parameters list
+ */
+ void ClearParameters();
+
/*!
* Verify whether hypothesis supports given entity type
*/
//=============================================================================
void SMESH_Hypothesis::SetParameters(const char *theParameters)
{
- _parameters = string(theParameters);
+ string aNewParameters(theParameters);
+ if(aNewParameters.size()==0 && _parameters.size()==0)
+ aNewParameters = " ";
+ if(_parameters.size()>0)
+ _parameters +="|";
+ _parameters +=aNewParameters;
+ SetLastParameters(theParameters);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis::ClearParameters()
+{
+ _parameters = string();
}
//=============================================================================
{
return (char*)_parameters.c_str();
}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+char* SMESH_Hypothesis::GetLastParameters() const
+{
+ return (char*)_lastParameters.c_str();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis::SetLastParameters(const char* theParameters)
+{
+ _lastParameters = string(theParameters);
+}
void SetLibName(const char* theLibName);
void SetParameters(const char *theParameters);
- char* GetParameters() const;
+ char* GetParameters() const;
+ void SetLastParameters(const char* theParameters);
+ char* GetLastParameters() const;
+ void ClearParameters();
+
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
private:
std::string _libName;
std::string _parameters;
+ std::string _lastParameters;
};
#endif
}
//=======================================================================
-//function : UpdateSObject
+//function : UpdateParameters
//purpose :
//=======================================================================
void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
}
//=======================================================================
-//function : GetParameters
+//function : ParseParameters
//purpose :
//=======================================================================
char* SMESH_Gen_i::ParseParameters(const char* theParameters)
SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
if( !aStudy->_is_nil() ) {
SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
- if(aSections->length() > 0) {
- SALOMEDS::ListOfStrings aVars= aSections[0];
+ for(int j=0;j<aSections->length();j++) {
+ SALOMEDS::ListOfStrings aVars= aSections[j];
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(j!=aSections->length()-1)
+ anInputParams+="|";
}
}
return CORBA::string_dup(anInputParams.ToCString());
SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters();
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
if(gen) {
- char *aParameters = GetParameters();
+ char *aParameters;
+ if(IsPublished())
+ aParameters = GetParameters();
+ else
+ aParameters = myBaseImpl->GetLastParameters();
+
SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy();
if(!aStudy->_is_nil()) {
SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
return aResult._retn();
}
+//=============================================================================
+/*!
+ * SMESH_Hypothesis_i::SetLastParameters()
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis_i::SetLastParameters(const char* theParameters)
+{
+ if(!IsPublished()) {
+ myBaseImpl->SetLastParameters(theParameters);
+ }
+}
+//=============================================================================
+/*!
+ * SMESH_Hypothesis_i::ClearParameters()
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis_i::ClearParameters()
+{
+ if(!IsPublished()) {
+ myBaseImpl->ClearParameters();
+ }
+}
+
//=============================================================================
/*!
* SMESH_Hypothesis_i::GetImpl
//Return list of last notebook variables used for Hypothesis creation.
SMESH::ListOfParameters* GetLastParameters();
+ //Set last parameters for not published hypothesis
+
+ void SetLastParameters(const char* theParameters);
+
+ // Clear parameters list
+ void ClearParameters();
+
//Return true if hypothesis was published in study
bool IsPublished();
using namespace std;
+void SetVariable(Handle(_pyCommand) theCommand,const ObjectStates* theStates, int position, int theArgNb);
//================================================================================
/*!
if(aMethod == "SetLayerDistribution"){
LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates);
aLDStates->AddDistribution(aCmd->GetArg(1));
+ if(MYDEBUG)
+ cout<<"Add Distribution :"<<aCmd->GetArg(1)<<endl;
}
}
cout<<"Command after: "<< aCmd->GetString()<<endl;
}
}
- // ProcessLayerDistribution();
+
+ ProcessLayerDistribution();
}
//================================================================================
/*!
if(MYDEBUG)
cout<<"The object Type : "<<anObjType<<endl;
ObjectStates *aState = NULL;
- if(anObjType == "LayerDistribution")
+ if(anObjType == "LayerDistribution") {
aState = new LayerDistributionStates();
+ }
else
aState = new ObjectStates(anObjType);
// 1) Find all LayerDistribution states
vector<LayerDistributionStates*> aLDS;
TVariablesMap::const_iterator it = _objectMap.begin();
- for(;it != _objectMap.end();it++)
- if(LayerDistributionStates* aLDStates = (LayerDistributionStates*)((*it).second)) {
+ for(;it != _objectMap.end();it++) {
+ LayerDistributionStates* aLDStates = dynamic_cast<LayerDistributionStates*>(((*it).second));
+ if(aLDStates!=NULL) {
aLDS.push_back(aLDStates);
}
+ }
+
+ if(!aLDS.size())
+ return;
// 2) Initialize all type of 1D Distribution hypothesis
for(int i=0;i<_commands.size();i++){
TCollection_AsciiString aMethod = _commands[i]->GetMethod();
if(aType == "LocalLength") {
if(aMethod == "SetLength") {
- if(!aLDS[j]->GetCurrectState().at(0).IsEmpty() )
- _commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(0));
+ SetVariable(_commands[i], aLDS[j],0,1);
aLDS[j]->IncrementState();
}
else if(aMethod == "SetPrecision") {
- if(!aLDS[j]->GetCurrectState().at(1).IsEmpty() )
- _commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(1));
+ SetVariable(_commands[i], aLDS[j],1,1);
+ aLDS[j]->IncrementState();
+ }
+ }
+
+ // Case for NumberOfSegments hypothesis
+ else if(aType == "NumberOfSegments"){
+ if(aMethod == "SetNumberOfSegments") {
+ SetVariable(_commands[i], aLDS[j],0,1);
+ if(aLDS[j]->GetCurrectState().size()==1)
+ aLDS[j]->IncrementState();
+ }
+ else if (aMethod == "SetScaleFactor") {
+ SetVariable(_commands[i], aLDS[j],1,1);
+ aLDS[j]->IncrementState();
+ }
+ }
+
+ else if( aType == "Deflection1D" ){
+ if(aMethod == "SetDeflection"){
+ SetVariable(_commands[i], aLDS[j],0,1);
+ aLDS[j]->IncrementState();
+ }
+ }
+ // Case for Arithmetic1D and StartEndLength hypothesis
+ else if(aType == "Arithmetic1D" || aType == "StartEndLength") {
+ if(aMethod == "SetLength") {
+ int anArgNb = (_commands[i]->GetArg(2) == "1") ? 0 : 1;
+ SetVariable(_commands[i], aLDS[j],anArgNb,1);
aLDS[j]->IncrementState();
}
}
return ok;
}
+
+
+/*!
+ * Set variable of the ObjectStates from position to the _pyCommand
+ * method as nbArg argument
+ */
+void SetVariable(Handle(_pyCommand) theCommand, const ObjectStates* theStates, int position, int theArgNb)
+{
+ if(theStates->GetCurrectState().size() > position)
+ if(!theStates->GetCurrectState().at(position).IsEmpty())
+ theCommand->SetArg(theArgNb,theStates->GetCurrectState().at(position));
+}
public:
ObjectStates(TCollection_AsciiString theType);
- ~ObjectStates();
+ virtual ~ObjectStates();
void AddState(const TState &theState);
public:
typedef std::map<TCollection_AsciiString,TCollection_AsciiString> TDistributionMap;
LayerDistributionStates();
- ~LayerDistributionStates();
+ virtual ~LayerDistributionStates();
void AddDistribution(const TCollection_AsciiString& theDistribution);
bool HasDistribution(const TCollection_AsciiString& theDistribution) const;
omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
+#Wrapper class for StdMeshers_LayerDistribution hypothesis
+class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
+
+ def SetLayerDistribution(self, hypo):
+ StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
+ hypo.ClearParameters();
+ StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
+
+#Registering the new proxy for LayerDistribution
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
+
#Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
## Set Length parameter value
- # @param length numerical value or name of variable from notebook
- # @param isStart true is length is Start Length, otherwise false
+ # @param length numerical value or name of variable from notebook
+ # @param isStart true is length is Start Length, otherwise false
def SetLength(self, length, isStart):
nb = 2
if isStart:
widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
h->SetLayerDistribution( w->GetHypothesis() );
- /* h->SetParameters(w->GetHypothesis()->GetParameters());
- if(QString(w->GetHypothesis()->GetName()) == "LocalLength")
- h->SetParameters(w->GetHypothesis()->GetParameters());
- */
+ h->SetParameters(w->GetHypothesis()->GetParameters());
+ w->GetHypothesis()->ClearParameters();
}
else if( hypType()=="ProjectionSource1D" )
{
item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
//Set into not published hypo last variables
- /* QStringList aLastVarsList;
+ QStringList aLastVarsList;
for(int i = 0;i<aParameters->length();i++)
aLastVarsList.append(QString(aParameters[i].in()));
if(!aLastVarsList.isEmpty())
- h->GetLayerDistribution()->SetParameters(SMESHGUI::JoinObjectParameters(aLastVarsList));
- */
+ h->GetLayerDistribution()->SetLastParameters(SMESHGUI::JoinObjectParameters(aLastVarsList));
+
customWidgets()->append
( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
}