Consider the following reflected model defined in C++
// C++ code
namespace shapes
{
$model+ TPoint
{
float32 X;
float32 Y;
};
$model+ TLine
{
TPoint P1;
TPoint P2;
};
$model+ TRect
{
TPoint P1;
TPoint P2;
};
$model+ TCircle
{
TPoint C;
float32 R;
};
$model+ TPolygon
{
xvector<TPoint> V;
};
$variant+ TShape
{
default TCircle(TPoint(0,0),1);
TPoint Point;
TLine Line;
TRect Rect;
TCircle Circle;
TPolygon Polygon;
};
}
The following Python code illustrates various ways of creating an instance of a TShape object which is associated with a python object referenced by a python variable:
# python code
p = shapes.TPolygon( [ shapes.TPoint(X=1,Y=2), shapes.TPoint(X=7,Y=-2) ] )
p.V.append( shapes.TPoint(X=5,Y=1) )
p.V[0].X = 1000
p.V.append( p.V[1] )
c = shapes.TCircle( Radius = 100 )
r = shapes.TRectangle( Width=200, Height=300 )
s = shapes.TShape()
s.Polygon = p