vectortools (lx_vectortools.hpp)

From The Foundry MODO SDK wiki
Jump to: navigation, search
There are security restrictions on this page


Contents

Vector Tools

Introduction

This module defines an extensible vector tools system, used for creating and editing vector images. This system is not implemented here, but could be implemented in a plugin or external server.

Vector Canvas

Interface

The Vector Canvas interface is used to store all the vector data associated with a vector item. It is usually stored in a channel, and can contain multiple shapes, paths and knots. The server implementing the vector canvas interface will also present a ILxVectorShape interface representing a single shape that contains all of the vector data and any sub-shapes.

(1) SDK: LXu_VECTORCANVAS, etc. defines
 #define LXu_VECTORCANVAS                "7A7915F0-E496-40D3-BD22-733D73885652"
 #define LXa_VECTORCANVAS                "vectorcanvas"

The GetItem function returns the item that the vector canvas server is stored on. If the canvas is not associated with an item, the function will return NOTAVAILABLE.

(2) SDK: VectorCanvas::GetItem
         LXxMETHOD( LxResult,
 GetItem) (
         LXtObjectID               self,
         void                    **ppvObj);

Editing canvas data can be expensive, as any change to the data can trigger events that other systems react to. The edit batch allows a group of similar changes to be combined, so the events will not be triggered until the edit is finished and the batch is closed.

(3) SDK: VectorCanvas::BeginEditBatch, etc.
         LXxMETHOD( LxResult,
 BeginEditBatch) (
         LXtObjectID               self);
 
         LXxMETHOD( LxResult,
 EndEditBatch) (
         LXtObjectID               self);

(4) SDK: empty VectorCanvas User Class

Empty Vector Canvas Python user class.

(5) PY: empty VectorCanvas user class
 pass

Channel

Items declare that they can provide a vector canvas with a package tag giving the name of the vector canvas channel. Read in an evaluated context, this will be a ValueReference object channel holding the vector canvas object.

(6) SDK: LXsPKG_CANVAS_CHANNEL define
 #define LXsPKG_CANVAS_CHANNEL   "vectorCanvas.channel"

Vector Shape

Interface

The Vector Shape interface represents a single shape in the canvas. Each shape has some basic properties, a collection of paths that make up the shape, as well as any number of sub-shapes. The server can be queried for an ILxAttributes interface, allowing the style properties of the shape to be accessed and potentially manipulated.

(7) SDK: LXu_VECTORSHAPE, etc. defines
 #define LXu_VECTORSHAPE                 "2B56643A-9697-42F4-99F9-04F96038D45E"
 #define LXa_VECTORSHAPE                 "vectorshape"

Shapes can contain multiple sub-shapes. This function returns the number of child shapes that a shape contains.

(8) SDK: VectorShape::ShapeCount
         LXxMETHOD( LxResult,
 ShapeCount) (
         LXtObjectID               self,
         unsigned int             *count);

This allows a child shape to be accessed by index. The object returned can be queried for an ILxVectorShape interface.

(9) SDK: VectorShape::ShapeByIndex
         LXxMETHOD( LxResult,
 ShapeByIndex) (
         LXtObjectID               self,
         unsigned int              index,
         void                    **ppvObj);

A shape can be queried for it's parent using the following function. If this shape is the top-most shape, the function will return NOTFOUND, however this shape can be queried for an ILxVectorCanvas interface.

(10) SDK: VectorShape::Parent
         LXxMETHOD( LxResult,
 Parent) (
         LXtObjectID               self,
         void                    **ppvObj);

A shape can contain multiple paths. This function returns the number of paths stored on a shape.

(11) SDK: VectorShape::PathCount
         LXxMETHOD( LxResult,
 PathCount) (
         LXtObjectID               self,
         unsigned int             *count);

This allows a path to be accessed by index. The object returned can be queried for an ILxVectorPath interface.

(12) SDK: VectorShape::PathByIndex
         LXxMETHOD( LxResult,
 PathByIndex) (
         LXtObjectID               self,
         unsigned int              index,
         void                    **ppvObj);

A shape can be transformed by passing a 3x3 matrix that encodes a 2D rotation, 2D transform, and 2D scale to be applied to the shape.

(13) SDK: VectorShape::Transform
         LXxMETHOD( LxResult,
 Transform) (
         LXtObjectID               self,
         const LXtMatrix           matrix);

(14) SDK: empty VectorShape User Class

Empty Vector Shape Python user class.

(15) PY: empty VectorShape user class
 pass

Vector Path

Interface

The Vector Path interface provides access to some basic properties, such as if the path is closed or not, as well as providing an accessor to access path knots.

(16) SDK: LXu_VECTORPATH, etc. defines
 #define LXu_VECTORPATH                  "13C5B133-4AE3-4934-B748-E2B1D3904874"
 #define LXa_VECTORPATH                  "vectorpath"

Paths can either be open or closed. This state can be queried and modified using the following functions.

(17) SDK: VectorPath::IsPathClosed, etc.
         LXxMETHOD( LxResult,
 IsPathClosed) (
         LXtObjectID               self);
 
         LXxMETHOD( LxResult,
 SetPathClosed) (
         LXtObjectID               self,
         LxResult                  closed);

This function returns the number of knots that make up the path.

(18) SDK: VectorPath::KnotCount
         LXxMETHOD( LxResult,
 KnotCount) (
         LXtObjectID               self,
         unsigned int             *count);

Knots can be "selected" by index. When a knot is selected, querying the properties of the knot will return information about this knot.

(19) SDK: VectorPath::SelectKnotByIndex
         LXxMETHOD( LxResult,
 SelectKnotByIndex) (
         LXtObjectID               self,
         unsigned int              index);

Knots can be "selected" directly. When a knot is selected, querying the properties of the knot will return information about this knot.

(20) SDK: VectorPath::SelectKnot
         LXxMETHOD( LxResult,
 SelectKnot) (
         LXtObjectID               self,
         LXtVectorKnotID           knot);

Knots can be enumerated using a visitor. For each knot, the visitor evaluate function will be called, and the path accessor will be updated to point at the new knot.

(21) SDK: VectorPath::KnotEnumerate
         LXxMETHOD( LxResult,
 KnotEnumerate) (
         LXtObjectID               self,
         LXtObjectID               visitor);

This methods returns the ID of the curent knot or null if none.

(22) SDK: VectorPath::ID
         LXxMETHOD( LXtVectorKnotID,
 ID) (
         LXtObjectID               self);

This methods returns the position of the curent knot.

(23) SDK: VectorPath::Pos
         LXxMETHOD( LxResult,
 Pos) (
         LXtObjectID               self,
         double                   *x,
         double                   *y);

(24) SDK: empty VectorPath User Class

Empty Vector Path Python user class.

(25) PY: empty VectorPath user class
 pass

(26) SDK: LXtVectorKnotID typedef (types)
 typedef void *   LXtVectorKnotID;

Vector Listener

Interface

The Vector Listener allows clients to be signalled whenever the canvas state changes. Clients can attach to a ListenerPort interface on the Canvas object, and be signaled about changes through the ILxVectorListener interface that they implement.

(27) SDK: LXu_VECTORLISTENER, etc. defines
 #define LXu_VECTORLISTENER              "90310E7B-85DB-4E5D-839B-25562FF50713"
 #define LXa_VECTORLISTENER              "vectorlistener"

This event is sent when the canvas is destroyed.

(28) SDK: VectorListener::Destroy
         LXxMETHOD( LxResult,
 Destroy) (
         LXtObjectID               self);

After a shape is added, this event will be called. The shape is passed as an argument.

(29) SDK: VectorListener::ShapeAdd
         LXxMETHOD( LxResult,
 ShapeAdd) (
         LXtObjectID               self,
         LXtObjectID               shape);

Before a shape is removed, this event will be called. The shape is passed as an argument.

(30) SDK: VectorListener::ShapeRemove
         LXxMETHOD( LxResult,
 ShapeRemove) (
         LXtObjectID               self,
         LXtObjectID               shape);

This event is used to mark a shape style change. The shape and name of the style are passed as arguments.

(31) SDK: VectorListener::ShapeStyle
         LXxMETHOD( LxResult,
 ShapeStyle) (
         LXtObjectID               self,
         LXtObjectID               shape,
         const char               *name);

After a path is added, this event will be called. The shape and path are passed as arguments.

(32) SDK: VectorListener::PathAdd
         LXxMETHOD( LxResult,
 PathAdd) (
         LXtObjectID               self,
         LXtObjectID               shape,
         LXtObjectID               path);

Before a path is removed, this event will be called. The shape and path are passed as arguments.

(33) SDK: VectorListener::PathRemove
         LXxMETHOD( LxResult,
 PathRemove) (
         LXtObjectID               self,
         LXtObjectID               shape,
         LXtObjectID               path);

When a knot changes position, this event will be called. The shape and path are provided as arguments, and the path accessor is pointing at the knot that has changed.

(34) SDK: VectorListener::KnotPosition
         LXxMETHOD( LxResult,
 KnotPosition) (
         LXtObjectID               self,
         LXtObjectID               shape,
         LXtObjectID               path);

(35) SDK: empty VectorListener User Class

Empty Vector Listener Python user class.

(36) PY: empty VectorListener user class
 pass