From: rnv Date: Mon, 17 Nov 2008 15:40:53 +0000 (+0000) Subject: Dump Python extension. X-Git-Tag: TG_DumpPython_Extension_3~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=feb865d3817c7b463ccae3bf38a3435e39278f33;p=modules%2Fgeom.git Dump Python extension. --- diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index ba8cdd6d2..ada27151d 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -687,19 +687,36 @@ GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation() // function : isValid // purpose : //================================================================================= -bool BasicGUI_PointDlg::isValid( QString& /*msg*/ ) +bool BasicGUI_PointDlg::isValid( QString& msg ) { const int id = getConstructorId(); - if ( id == 0 ) - return true; - else if ( id == 1 ) - return !myRefPoint->_is_nil(); - else if ( id == 2 ) - return !myEdge->_is_nil(); + if ( id == 0 ) { + bool ok = true; + ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; + ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; + return ok; + } + else if ( id == 1 ) { + bool ok = true; + ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; + ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; + + return !myRefPoint->_is_nil() && ok; + } + else if ( id == 2 ) { + return !myEdge->_is_nil() && GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() ); + } else if ( id == 3 ) return ( !myLine1->_is_nil() && !myLine2->_is_nil() ); - else if ( id == 4 ) - return !myFace->_is_nil(); + else if ( id == 4 ) { + bool ok = true; + ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; + ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + return !myFace->_is_nil() && ok; + + } return false; } @@ -712,6 +729,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) bool res = false; GEOM::GEOM_Object_var anObj; + QStringList aParameters; switch ( getConstructorId() ) { case 0 : @@ -719,6 +737,10 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) double x = GroupXYZ->SpinBox_DX->value(); double y = GroupXYZ->SpinBox_DY->value(); double z = GroupXYZ->SpinBox_DZ->value(); + + aParameters << GroupXYZ->SpinBox_DX->text(); + aParameters << GroupXYZ->SpinBox_DY->text(); + aParameters << GroupXYZ->SpinBox_DZ->text(); anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x, y, z ); res = true; @@ -729,6 +751,10 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) double dx = GroupRefPoint->SpinBox_DX->value(); double dy = GroupRefPoint->SpinBox_DY->value(); double dz = GroupRefPoint->SpinBox_DZ->value(); + + aParameters << GroupRefPoint->SpinBox_DX->text(); + aParameters << GroupRefPoint->SpinBox_DY->text(); + aParameters << GroupRefPoint->SpinBox_DZ->text(); anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> MakePointWithReference( myRefPoint, dx, dy, dz ); @@ -738,6 +764,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) case 2 : anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> MakePointOnCurve( myEdge, getParameter() ); + aParameters<SpinBox_DX->text(); res = true; break; case 3 : @@ -748,10 +775,20 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) case 4 : anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )-> MakePointOnSurface( myFace, getUParameter(), getVParameter() ); + aParameters<SpinBox_DX->text(); + aParameters<SpinBox_DY->text(); res = true; break; } + if(!anObj->_is_nil() && (getConstructorId()==0 || + getConstructorId() == 1 || + getConstructorId() == 2 || + getConstructorId() == 4) ) { + anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + } + + if ( getConstructorId() == 1 || getConstructorId() == 2 || getConstructorId() == 4 ) { TopoDS_Shape aShape; diff --git a/src/DlgRef/DlgRef_1Sel1Spin_QTD.ui b/src/DlgRef/DlgRef_1Sel1Spin_QTD.ui index 4df5a4e6d..06d9d7c13 100644 --- a/src/DlgRef/DlgRef_1Sel1Spin_QTD.ui +++ b/src/DlgRef/DlgRef_1Sel1Spin_QTD.ui @@ -104,7 +104,7 @@ - + @@ -115,9 +115,9 @@ qPixmapFromMimeSource - QtxDoubleSpinBox + SalomeApp_DoubleSpinBox QDoubleSpinBox -
QtxDoubleSpinBox.h
+
SalomeApp_DoubleSpinBox.h
diff --git a/src/DlgRef/DlgRef_1Sel2Spin_QTD.ui b/src/DlgRef/DlgRef_1Sel2Spin_QTD.ui index 25d1a9baf..432160bea 100644 --- a/src/DlgRef/DlgRef_1Sel2Spin_QTD.ui +++ b/src/DlgRef/DlgRef_1Sel2Spin_QTD.ui @@ -56,10 +56,10 @@ 6 - + - + @@ -134,9 +134,9 @@ qPixmapFromMimeSource - QtxDoubleSpinBox + SalomeApp_DoubleSpinBox QDoubleSpinBox -
QtxDoubleSpinBox.h
+
SalomeApp_DoubleSpinBox.h
diff --git a/src/DlgRef/DlgRef_1Sel3Spin_QTD.ui b/src/DlgRef/DlgRef_1Sel3Spin_QTD.ui index 9cabaf01d..6ec567c6e 100644 --- a/src/DlgRef/DlgRef_1Sel3Spin_QTD.ui +++ b/src/DlgRef/DlgRef_1Sel3Spin_QTD.ui @@ -56,13 +56,13 @@ 6 - + - + - + @@ -153,9 +153,9 @@ qPixmapFromMimeSource - QtxDoubleSpinBox + SalomeApp_DoubleSpinBox QDoubleSpinBox -
QtxDoubleSpinBox.h
+
SalomeApp_DoubleSpinBox.h
diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index 73b315414..2d01a5719 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -55,6 +55,7 @@ #include #include +#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -71,6 +72,8 @@ static int MYDEBUG = 0; static GEOM_Engine* TheEngine = NULL; +using namespace std; + static TCollection_AsciiString BuildIDFromObject(Handle(GEOM_Object)& theObject) { TCollection_AsciiString anID(theObject->GetDocID()), anEntry; @@ -95,13 +98,11 @@ static Standard_Integer ExtractDocID(TCollection_AsciiString& theID) void ProcessFunction(Handle(GEOM_Function)& theFunction, TCollection_AsciiString& theScript, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames, - TColStd_HSequenceOfAsciiString& theStudyVariables, + TVariablesList theVariables, TColStd_MapOfTransient& theProcessed); void ReplaceVariables(TCollection_AsciiString& theCommand, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames, - TColStd_HSequenceOfAsciiString& theStudyVariables); + TVariablesList theVariables); @@ -441,8 +442,7 @@ void GEOM_Engine::Close(int theDocID) //============================================================================= TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, Resource_DataMapOfAsciiStringAsciiString& theObjectNames, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames, - TColStd_HSequenceOfAsciiString& theStudyVariables, + TVariablesList theVariables, bool isPublished, bool& aValidScript) { @@ -472,7 +472,7 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, MESSAGE ( "Null function !!!!" ); continue; } - ProcessFunction(aFunction, aScript, theVariableNames, theStudyVariables ,aMap); + ProcessFunction(aFunction, aScript, theVariables,aMap); } } @@ -697,8 +697,7 @@ Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const //=========================================================================== void ProcessFunction(Handle(GEOM_Function)& theFunction, TCollection_AsciiString& theScript, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames, - TColStd_HSequenceOfAsciiString& theStudyVariables, + TVariablesList theVariables, TColStd_MapOfTransient& theProcessed) { if(theFunction.IsNull() || theProcessed.Contains(theFunction)) return; @@ -723,7 +722,7 @@ void ProcessFunction(Handle(GEOM_Function)& theFunction, if(aDescr == "None") return; //Replace parameter by notebook variables - ReplaceVariables(aDescr,theVariableNames,theStudyVariables); + ReplaceVariables(aDescr,theVariables); theScript += "\n\t"; theScript += aDescr; @@ -776,12 +775,18 @@ Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theStrin */ //============================================================================= void ReplaceVariables(TCollection_AsciiString& theCommand, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames, - TColStd_HSequenceOfAsciiString& theStudyVariables) + TVariablesList theVariables) { //Get Entry of the result object TCollection_AsciiString anEntry = theCommand.Token("=",1); + if (MYDEBUG) { + cout<<"All Entries:"< aVariables; + TVariablesList::const_iterator it = theVariables.find(anEntry); + if( it != theVariables.end() ) + aVariables = (*it).second; - if(aVariables.IsEmpty()) { + if(aVariables.empty()) { if(MYDEBUG) cout<<"Valiables list empty!!!"< #include +#include +#include + +struct TVariable{ + TCollection_AsciiString myVariable; + bool isVariable; + + TVariable(const TCollection_AsciiString& theVariable, bool theFlag = true): + myVariable(theVariable), + isVariable(theFlag){} +}; + +typedef std::map > TVariablesList; + class GEOM_Engine { public: @@ -84,8 +98,7 @@ class GEOM_Engine Standard_EXPORT TCollection_AsciiString DumpPython(int theDocID, Resource_DataMapOfAsciiStringAsciiString& theObjectNames, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames, - TColStd_HSequenceOfAsciiString& theStudyVariables, + TVariablesList theVariables, bool isPublished, bool& aValidScript); diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 3fdf39984..33f200502 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -146,6 +146,14 @@ SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy) return aDSStudy._retn(); } +//======================================================================= +// function : JoinObjectParameters +// purpose : +//======================================================================= +char* GeometryGUI::JoinObjectParameters(const QStringList& theParametersList) +{ + return (char*)theParametersList.join(":").toLatin1().constData(); +} //======================================================================= // function : GeometryGUI::GeometryGUI() // purpose : Constructor diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index cf9d7079d..45e42e248 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -81,6 +81,8 @@ public: static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject); static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy); + static char* JoinObjectParameters(const QStringList& theParametersList); + GEOM_Client& GetShapeReader() { return myShapeReader; } Standard_CString& GetFatherior() { return myFatherior; } //void SetState( const int state ) { myState = state; } diff --git a/src/GEOM_I/GEOM_DumpPython.cc b/src/GEOM_I/GEOM_DumpPython.cc index 1bf477109..c3f7b5da9 100644 --- a/src/GEOM_I/GEOM_DumpPython.cc +++ b/src/GEOM_I/GEOM_DumpPython.cc @@ -24,11 +24,16 @@ #include #include "GEOM_Gen_i.hh" + +//#include #include #include #include #include +#include +#include + //======================================================================= //function : DumpPython //purpose : @@ -46,7 +51,9 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy, if(CORBA::is_nil(aSO)) return new Engines::TMPFile(0); - Resource_DataMapOfAsciiStringAsciiString aMap, aVariableMap; + Resource_DataMapOfAsciiStringAsciiString aMap; + + TVariablesList aVariableMap; SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO); for(Itr->InitEx(true); Itr->More(); Itr->Next()) { @@ -63,28 +70,25 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy, //Find attribute with list of used notebook variables SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeString_var anAttrStr; - TCollection_AsciiString aParameters; + vector aVariables; if(aValue->FindAttribute(anAttr,"AttributeString")){ anAttrStr = SALOMEDS::AttributeString::_narrow(anAttr); - aParameters = TCollection_AsciiString(anAttrStr->Value()); + SALOMEDS::ListOfStrings_var aListOfVars = aStudy->ParseVariables(anAttrStr->Value()); + for(int i = 0;i < aListOfVars->length();i++) { + bool isVar = aStudy->IsVariable(aListOfVars[i].in()); + TVariable aVar = TVariable( (char*)aListOfVars[i].in(), isVar ); + aVariables.push_back(aVar); + } } - aVariableMap.Bind((char*)anEntry.in(),aParameters); + aVariableMap.insert(pair >((char*)anEntry,aVariables)); } } } - - //Get Study variables - SALOMEDS::ListOfStrings_var aListOfVars = aStudy->GetVariableNames(); - TColStd_HSequenceOfAsciiString aStudyVariables; - for(int i = 0;i < aListOfVars->length();i++) - { - aStudyVariables.Append(aListOfVars[i].in()); - } TCollection_AsciiString aScript = "### This file is generated by SALOME automatically by dump python functionality\n" "### of GEOM component\n\n"; - aScript += _impl->DumpPython(aStudy->StudyId(), aMap, aVariableMap, aStudyVariables, isPublished, isValidScript); + aScript += _impl->DumpPython(aStudy->StudyId(), aMap, aVariableMap, isPublished, isValidScript); if (isPublished) { diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 2a883e425..6050ac582 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -280,8 +280,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @ref tui_creation_point "Example" def MakeVertex(self,theX, theY, theZ): # Example: see GEOM_TestAll.py + theX,theY,theZ,Parameters = ParseParameters(theX, theY, theZ) anObj = self.BasicOp.MakePointXYZ(theX, theY, theZ) RaiseIfFailed("MakePointXYZ", self.BasicOp) + anObj.SetParameters(Parameters) return anObj ## Create a point, distant from the referenced point @@ -295,8 +297,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @ref tui_creation_point "Example" def MakeVertexWithRef(self,theReference, theX, theY, theZ): # Example: see GEOM_TestAll.py + theX,theY,theZ,Parameters = ParseParameters(theX, theY, theZ) anObj = self.BasicOp.MakePointWithReference(theReference, theX, theY, theZ) RaiseIfFailed("MakePointWithReference", self.BasicOp) + anObj.SetParameters(Parameters) return anObj ## Create a point, corresponding to the given parameter on the given curve. @@ -307,8 +311,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @ref tui_creation_point "Example" def MakeVertexOnCurve(self,theRefCurve, theParameter): # Example: see GEOM_TestAll.py + theParameter, Parameters = ParseParameters(theParameter) anObj = self.BasicOp.MakePointOnCurve(theRefCurve, theParameter) RaiseIfFailed("MakePointOnCurve", self.BasicOp) + anObj.SetParameters(Parameters) return anObj ## Create a point, corresponding to the given parameters on the @@ -320,9 +326,11 @@ class geompyDC(GEOM._objref_GEOM_Gen): # # @ref swig_MakeVertexOnSurface "Example" def MakeVertexOnSurface(self, theRefSurf, theUParameter, theVParameter): + theUParameter, theVParameter, Parameters = ParseParameters(theParameter) # Example: see GEOM_TestAll.py anObj = self.BasicOp.MakePointOnSurface(theRefSurf, theUParameter, theVParameter) RaiseIfFailed("MakePointOnSurface", self.BasicOp) + anObj.SetParameters(Parameters); return anObj ## Create a point on intersection of two lines.