From: rnv Date: Fri, 28 Nov 2008 15:44:49 +0000 (+0000) Subject: Implementation NoteBook in SMESH module. X-Git-Tag: TG_DumpPython_Extension_3~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=17fdea7a8c011245bb07f6c7cf51fbae85a893ac;p=modules%2Fsmesh.git Implementation NoteBook in SMESH module. --- diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index 556d7e7c1..039330044 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -43,10 +43,15 @@ #ifdef _DEBUG_ static int MYDEBUG = 0; +static int VARIABLE_DEBUG = 1; #else static int MYDEBUG = 0; +static int VARIABLE_DEBUG = 1; #endif + + + //============================================================================= /*! * Get...Tag [ static ] @@ -869,15 +874,24 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy //======================================================================= void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters) { + + if(VARIABLE_DEBUG) + cout<<"UpdateParameters : "<_is_nil() || CORBA::is_nil(theObject)) return; SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject); - if(aSObj->_is_nil()) + if(aSObj->_is_nil()) return; SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + + SALOMEDS::GenericAttribute_var aFindAttr; + bool hasAttr = aSObj->FindAttribute(aFindAttr, "AttributeString"); + if(VARIABLE_DEBUG) + cout<<"Find Attribute "<FindOrCreateAttribute( aSObj, "AttributeString"); SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr); @@ -886,10 +900,18 @@ void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theP TCollection_AsciiString aOldParameters(aStringAttr->Value()); TCollection_AsciiString anInputParams(ParseParameters(theParameters)); - if(!aOldParameters.Length()) + if(!hasAttr) aNewParams = anInputParams; else aNewParams = aOldParameters+"|"+anInputParams; + + if(VARIABLE_DEBUG) + { + cout<<"Input Parameters : "<SetValue( aNewParams.ToCString() ); } diff --git a/src/SMESH_I/SMESH_NoteBook.cxx b/src/SMESH_I/SMESH_NoteBook.cxx index b143f63b4..57dd307c6 100644 --- a/src/SMESH_I/SMESH_NoteBook.cxx +++ b/src/SMESH_I/SMESH_NoteBook.cxx @@ -81,7 +81,10 @@ void ObjectStates::AddState(const TState &theState) //================================================================================ TState ObjectStates::GetCurrectState() const { - return _states[_dumpstate]; + if(_states.size() > _dumpstate) + return _states[_dumpstate]; + TState empty; + return empty; } @@ -243,7 +246,7 @@ void SMESH_NoteBook::ReplaceVariables() if(it != _objectMap.end() && !aMethod.IsEmpty()) { ObjectStates *aStates = (*it).second; // Case for LocalLength hypothesis - if(aStates->GetObjectType().IsEqual("LocalLength")) { + if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) { if(aMethod.IsEqual("SetLength")) { if(!aStates->GetCurrectState().at(0).IsEmpty() ) aCmd->SetArg(1,aStates->GetCurrectState().at(0)); @@ -257,13 +260,25 @@ void SMESH_NoteBook::ReplaceVariables() } // Case for SegmentLengthAroundVertex hypothesis - else if(aStates->GetObjectType().IsEqual("SegmentLengthAroundVertex")) { + else if(aStates->GetObjectType().IsEqual("SegmentLengthAroundVertex") + && aStates->GetCurrectState().size() >= 1) { if(aMethod == "SetLength") { if(!aStates->GetCurrectState().at(0).IsEmpty() ) aCmd->SetArg(1,aStates->GetCurrectState().at(0)); aStates->IncrementState(); } } + + else if(aStates->GetObjectType().IsEqual("Arithmetic1D")) { + if(aMethod == "SetLength" && + aStates->GetCurrectState().size() >= 2) { + if(aCmd->GetArg(2) == "1" && !aStates->GetCurrectState().at(0).IsEmpty()) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + else if(!aStates->GetCurrectState().at(1).IsEmpty()) + aCmd->SetArg(1,aStates->GetCurrectState().at(1)); + aStates->IncrementState(); + } + } // Case for LayerDistribution hypothesis (not finished yet) else if(aStates->GetObjectType() == "LayerDistribution") { if(aMethod == "SetLayerDistribution"){ diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index 6df514bbf..0684cecc4 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -4116,14 +4116,31 @@ omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryI #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex): - parent = StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex ## Set length parameter value # @param length numerical value or name of variable from notebook def SetLength(self, length): - length,parameters = ParseParameters(parent.GetLastParameters(self),1,1,length) - parent.SetParameters(self,parameters) - parent.SetLength(self,length) + length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length) + StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length) +#Registering the new proxy for SegmentLengthAroundVertex +omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex) + + +#Wrapper class for StdMeshers_Arithmetic1D hypothesis +class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D): + + ## Set length parameter value + # @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: + nb = 1 + length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length) + StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart) + #Registering the new proxy for LocalLength -omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, LocalLength) +omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D) diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index 177950406..b7bf0f6e5 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -429,7 +429,9 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() ); h->SetLength( params[0].myValue.toDouble(), true ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); h->SetLength( params[1].myValue.toDouble(), false ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } else if( hypType()=="MaxElementArea" ) { @@ -605,11 +607,25 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const StdMeshers::StdMeshers_Arithmetic1D_var h = StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp ); + aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString(""); + + item.isVariable = !aVaribaleName.isEmpty(); + item.myName = tr( "SMESH_START_LENGTH_PARAM" ); - item.myValue = h->GetLength( true ); + if(item.isVariable) + item.myValue = aVaribaleName; + else + item.myValue = h->GetLength( true ); p.append( item ); + + aVaribaleName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString(""); + item.myName = tr( "SMESH_END_LENGTH_PARAM" ); - item.myValue = h->GetLength( false ); + + if(item.isVariable) + item.myValue = aVaribaleName; + else + item.myValue = h->GetLength( false ); p.append( item ); } else if( hypType()=="MaxElementArea" )