#include <GEOM_Object_i.hh>
#include <GEOM_ISubShape.hxx>
+#include <GEOM_Engine.hxx>
#include <GEOMImpl_Types.hxx>
#include "utilities.h"
#include <TDF_Tool.hxx>
#include <TDF_Label.hxx>
#include <TCollection_AsciiString.hxx>
+#include <TColStd_Array1OfAsciiString.hxx>
#include <BRepTools_ShapeSet.hxx>
#include <BRepTools.hxx>
return !_impl->GetValue().IsNull() && _impl->GetType() != GEOM_MARKER;
}
-void GEOM_Object_i::SetParameters(const char* theParameters)
+void GEOM_Object_i::SetParameters( SALOME::Notebook_ptr theNotebook, const GEOM::string_array& theParameters )
{
- _impl->SetParameters((char*)theParameters);
+ printf( "set parameters\n" );
+ int n = theParameters.length();
+ if ( n <= 0 )
+ return;
+
+ theNotebook->ClearDependencies( _this() );
+
+ Handle( GEOM_Function ) aFunc = _impl->GetLastFunction();
+ TColStd_Array1OfAsciiString aParams( 1, n );
+ char* aStr;
+ for( int i = 0; i < n; i++ )
+ {
+ aStr = CORBA::string_dup( theParameters[i] );
+ printf( "\tparam = %s\n", aStr );
+ SALOME::Parameter_ptr aParam = theNotebook->Param( aStr );
+ TCollection_AsciiString anAsciiName;
+ if( !CORBA::is_nil( aParam ) )
+ {
+ printf( "add dep\n" );
+ theNotebook->AddDependency( _this(), aParam );
+ anAsciiName = aStr;
+ }
+ aFunc->SetParam( i+1, anAsciiName );
+ }
+}
+
+char* GEOM_Object_i::GetComponent()
+{
+ return CORBA::string_dup( "GEOM" );
}
-char* GEOM_Object_i::GetParameters()
+CORBA::Boolean GEOM_Object_i::IsValid()
{
- return CORBA::string_dup(_impl->GetParameters().ToCString());
+ return true;
}
+void GEOM_Object_i::Update( SALOME::Notebook_ptr theNotebook )
+{
+ printf( "GEOM_Object_i::Update:\n" );
+ Handle( GEOM_Function ) aFunc = _impl->GetLastFunction();
+
+ //1. Update parameter values
+ int n = aFunc->GetArgsCount();
+ printf( "args count = %i\n", n );
+ for( int i = 1; i <= n; i++ )
+ {
+ TCollection_AsciiString aParamName = aFunc->GetParam( i );
+ printf( "arg = %s\n", aParamName.ToCString() );
+ SALOME::Parameter_ptr aParam = theNotebook->Param( aParamName.ToCString() );
+ if( CORBA::is_nil( aParam ) )
+ continue;
+
+ switch( aParam->GetType() )
+ {
+ case SALOME::TInteger:
+ aFunc->SetInteger( i, aParam->AsInteger() );
+ break;
+
+ case SALOME::TReal:
+ printf( "real: %i-th = %lf\n", i, aParam->AsReal() );
+ aFunc->SetReal( i, aParam->AsReal() );
+ break;
+
+ case SALOME::TString:
+ aFunc->SetString( i, aParam->AsString() );
+ break;
+
+ default:
+ return;
+ }
+ }
+
+ //2. Recompute object
+ GEOM_Solver aSolver( GEOM_Engine::GetEngine() );
+ aSolver.ComputeFunction( aFunc );
+}
virtual bool IsShape();
- virtual void SetParameters(const char* theParameters);
+ virtual void SetParameters( SALOME::Notebook_ptr theNotebook, const GEOM::string_array& theParameters );
- virtual char* GetParameters();
+ virtual char* GetComponent();
+
+ virtual CORBA::Boolean IsValid();
+
+ virtual void Update( SALOME::Notebook_ptr theNotebook );
Handle(GEOM_Object) GetImpl() { return _impl; }
import salome
salome.salome_init()
-from salome import *
+from salome import *
from salome_notebook import *
import GEOM
## @ingroup l1_geompy_auxiliary
def ParseParameters(*parameters):
Result = []
- StringResult = ""
+ Params = []
for parameter in parameters:
- if isinstance(parameter,str):
- if notebook.isVariable(parameter):
- Result.append(notebook.get(parameter))
- else:
- raise RuntimeError, "Variable with name '" + parameter + "' doesn't exist!!!"
+ if isinstance(parameter, str):
+ Result.append(notebook.get(parameter))
+ Params.append(parameter)
else:
Result.append(parameter)
+ Params.append("")
pass
- StringResult = StringResult + str(parameter)
- StringResult = StringResult + ":"
- pass
- StringResult = StringResult[:len(StringResult)-1]
- Result.append(StringResult)
+ Result.append( Params )
return Result
+
+def SetParameters( obj, params ):
+ obj.SetParameters( notebook.getNotebook(), params )
+
+
## Return list of variables value from salome notebook
## @ingroup l1_geompy_auxiliary
def ParseList(list):
# @return New GEOM_Object, containing the created point.
#
# @ref tui_creation_point "Example"
- def MakeVertex(self,theX, theY, theZ):
+ 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)
# @return New GEOM_Object, containing the created box.
#
# @ref tui_creation_box "Example"
- def MakeBoxDXDYDZ(self,theDX, theDY, theDZ):
+ def MakeBoxDXDYDZ(self, theDX, theDY, theDZ):
# Example: see GEOM_TestAll.py
theDX,theDY,theDZ,Parameters = ParseParameters(theDX, theDY, theDZ)
+ print theDX
+ print theDY
+ print theDZ
anObj = self.PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ)
RaiseIfFailed("MakeBoxDXDYDZ", self.PrimOp)
- anObj.SetParameters(Parameters)
+ SetParameters( anObj, Parameters )
return anObj
## Create a box with two specified opposite vertices,