mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-03-12 19:04:33 +05:00
Dump python extension.
This commit is contained in:
parent
c6d77cd8ea
commit
0443165620
@ -76,6 +76,18 @@ module SMESH
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
@ -159,7 +159,23 @@ void SMESH_Hypothesis::SetLibName(const char* theLibName)
|
||||
//=============================================================================
|
||||
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();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -171,3 +187,23 @@ char* SMESH_Hypothesis::GetParameters() const
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -71,8 +71,12 @@ public:
|
||||
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
|
||||
@ -101,6 +105,7 @@ protected:
|
||||
private:
|
||||
std::string _libName;
|
||||
std::string _parameters;
|
||||
std::string _lastParameters;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -866,7 +866,7 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateSObject
|
||||
//function : UpdateParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
|
||||
@ -914,7 +914,7 @@ void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theP
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetParameters
|
||||
//function : ParseParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
char* SMESH_Gen_i::ParseParameters(const char* theParameters)
|
||||
@ -924,14 +924,16 @@ 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());
|
||||
|
@ -191,7 +191,12 @@ 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();
|
||||
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);
|
||||
@ -206,6 +211,31 @@ SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters()
|
||||
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
|
||||
|
@ -75,6 +75,13 @@ public:
|
||||
//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();
|
||||
|
||||
|
@ -41,6 +41,7 @@ static int MYDEBUG = 0;
|
||||
using namespace std;
|
||||
|
||||
|
||||
void SetVariable(Handle(_pyCommand) theCommand,const ObjectStates* theStates, int position, int theArgNb);
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
@ -295,6 +296,8 @@ void SMESH_NoteBook::ReplaceVariables()
|
||||
if(aMethod == "SetLayerDistribution"){
|
||||
LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates);
|
||||
aLDStates->AddDistribution(aCmd->GetArg(1));
|
||||
if(MYDEBUG)
|
||||
cout<<"Add Distribution :"<<aCmd->GetArg(1)<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -573,7 +576,8 @@ void SMESH_NoteBook::ReplaceVariables()
|
||||
cout<<"Command after: "<< aCmd->GetString()<<endl;
|
||||
}
|
||||
}
|
||||
// ProcessLayerDistribution();
|
||||
|
||||
ProcessLayerDistribution();
|
||||
}
|
||||
//================================================================================
|
||||
/*!
|
||||
@ -618,8 +622,9 @@ void SMESH_NoteBook::InitObjectMap()
|
||||
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);
|
||||
|
||||
@ -672,10 +677,15 @@ void SMESH_NoteBook::ProcessLayerDistribution()
|
||||
// 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++){
|
||||
@ -700,13 +710,39 @@ void SMESH_NoteBook::ProcessLayerDistribution()
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -758,3 +794,15 @@ bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double&
|
||||
|
||||
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));
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class ObjectStates{
|
||||
public:
|
||||
|
||||
ObjectStates(TCollection_AsciiString theType);
|
||||
~ObjectStates();
|
||||
virtual ~ObjectStates();
|
||||
|
||||
void AddState(const TState &theState);
|
||||
|
||||
@ -63,7 +63,7 @@ class LayerDistributionStates : public ObjectStates
|
||||
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;
|
||||
|
@ -4350,6 +4350,17 @@ class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
|
||||
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):
|
||||
|
||||
@ -4398,8 +4409,8 @@ omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_Repository
|
||||
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:
|
||||
|
@ -488,10 +488,8 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
|
||||
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" )
|
||||
{
|
||||
@ -684,13 +682,13 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
|
||||
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()));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user