FreeMat

- Main Page
- Related Pages

vtkSplineWidget

Section: Visualization Toolkit Widget Classes

# Usage

This 3D widget defines a spline that can be interactively placed in a scene. The spline has handles, the number of which can be changed, plus it can be picked on the spline itself to translate or rotate it in the scene. A nice feature of the object is that the vtkSplineWidget, like any 3D widget, will work with the current interactor style. That is, if vtkSplineWidget does not handle an event, then all other registered observers (including the interactor style) have an opportunity to process the event. Otherwise, the vtkSplineWidget will terminate the processing of the event that it handles.

To use this object, just invoke SetInteractor() with the argument of the method a vtkRenderWindowInteractor. You may also wish to invoke "PlaceWidget()" to initially position the widget. The interactor will act normally until the "i" key (for "interactor") is pressed, at which point the vtkSplineWidget will appear. (See superclass documentation for information about changing this behavior.) Events that occur outside of the widget (i.e., no part of the widget is picked) are propagated to any other registered obsevers (such as the interaction style). Turn off the widget by pressing the "i" key again (or invoke the Off() method).

The button actions and key modifiers are as follows for controlling the widget: 1) left button down on and drag one of the spherical handles to change the shape of the spline: the handles act as "control points". 2) left button or middle button down on a line segment forming the spline allows uniform translation of the widget. 3) ctrl + middle button down on the widget enables spinning of the widget about its center. 4) right button down on the widget enables scaling of the widget. By moving the mouse "up" the render window the spline will be made bigger; by moving "down" the render window the widget will be made smaller. 5) ctrl key + right button down on any handle will erase it providing there will be two or more points remaining to form a spline. 6) shift key + right button down on any line segment will insert a handle onto the spline at the cursor position.

The vtkSplineWidget has several methods that can be used in conjunction with other VTK objects. The Set/GetResolution() methods control the number of subdivisions of the spline; the GetPolyData() method can be used to get the polygonal representation and can be used for things like seeding streamlines or probing other data sets. Typical usage of the widget is to make use of the StartInteractionEvent, InteractionEvent, and EndInteractionEvent events. The InteractionEvent is called on mouse motion; the other two events are called on button down and button up (either left or right button).

Some additional features of this class include the ability to control the properties of the widget. You can set the properties of the selected and unselected representations of the spline. For example, you can set the property for the handles and spline. In addition there are methods to constrain the spline so that it is aligned with a plane. Note that a simple ruler widget can be derived by setting the resolution to 1, the number of handles to 2, and calling the GetSummedLength method!

To create an instance of class vtkSplineWidget, simply invoke its constructor as follows

      obj = vtkSplineWidget

# Methods

The class vtkSplineWidget has several methods that can be used. They are listed below. Note that the documentation is translated automatically from the VTK sources, and may not be completely intelligible. When in doubt, consult the VTK website. In the methods listed below, `obj` is an instance of the vtkSplineWidget class.

- `string = obj.GetClassName ()`
- `int = obj.IsA (string name)`
- `vtkSplineWidget = obj.NewInstance ()`
- `vtkSplineWidget = obj.SafeDownCast (vtkObject o)`
- `obj.SetEnabled (int )` - Methods that satisfy the superclass' API.
- `obj.PlaceWidget (double bounds[6])` - Methods that satisfy the superclass' API.
- `obj.PlaceWidget ()` - Methods that satisfy the superclass' API.
- `obj.PlaceWidget (double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)` - Force the spline widget to be projected onto one of the orthogonal planes. Remember that when the state changes, a ModifiedEvent is invoked. This can be used to snap the spline to the plane if it is orginally not aligned. The normal in SetProjectionNormal is 0,1,2 for YZ,XZ,XY planes respectively and 3 for arbitrary oblique planes when the widget is tied to a vtkPlaneSource.
- `obj.SetProjectToPlane (int )` - Force the spline widget to be projected onto one of the orthogonal planes. Remember that when the state changes, a ModifiedEvent is invoked. This can be used to snap the spline to the plane if it is orginally not aligned. The normal in SetProjectionNormal is 0,1,2 for YZ,XZ,XY planes respectively and 3 for arbitrary oblique planes when the widget is tied to a vtkPlaneSource.
- `int = obj.GetProjectToPlane ()` - Force the spline widget to be projected onto one of the orthogonal planes. Remember that when the state changes, a ModifiedEvent is invoked. This can be used to snap the spline to the plane if it is orginally not aligned. The normal in SetProjectionNormal is 0,1,2 for YZ,XZ,XY planes respectively and 3 for arbitrary oblique planes when the widget is tied to a vtkPlaneSource.
- `obj.ProjectToPlaneOn ()` - Force the spline widget to be projected onto one of the orthogonal planes. Remember that when the state changes, a ModifiedEvent is invoked. This can be used to snap the spline to the plane if it is orginally not aligned. The normal in SetProjectionNormal is 0,1,2 for YZ,XZ,XY planes respectively and 3 for arbitrary oblique planes when the widget is tied to a vtkPlaneSource.
- `obj.ProjectToPlaneOff ()` - Force the spline widget to be projected onto one of the orthogonal planes. Remember that when the state changes, a ModifiedEvent is invoked. This can be used to snap the spline to the plane if it is orginally not aligned. The normal in SetProjectionNormal is 0,1,2 for YZ,XZ,XY planes respectively and 3 for arbitrary oblique planes when the widget is tied to a vtkPlaneSource.
- `obj.SetPlaneSource (vtkPlaneSource plane)` - Set up a reference to a vtkPlaneSource that could be from another widget object, e.g. a vtkPolyDataSourceWidget.
- `obj.SetProjectionNormal (int )`
- `int = obj.GetProjectionNormalMinValue ()`
- `int = obj.GetProjectionNormalMaxValue ()`
- `int = obj.GetProjectionNormal ()`
- `obj.SetProjectionNormalToXAxes ()`
- `obj.SetProjectionNormalToYAxes ()`
- `obj.SetProjectionNormalToZAxes ()`
- `obj.SetProjectionNormalToOblique ()` - Set the position of spline handles and points in terms of a plane's position. i.e., if ProjectionNormal is 0, all of the x-coordinate values of the points are set to position. Any value can be passed (and is ignored) to update the spline points when Projection normal is set to 3 for arbritrary plane orientations.
- `obj.SetProjectionPosition (double position)` - Set the position of spline handles and points in terms of a plane's position. i.e., if ProjectionNormal is 0, all of the x-coordinate values of the points are set to position. Any value can be passed (and is ignored) to update the spline points when Projection normal is set to 3 for arbritrary plane orientations.
- `double = obj.GetProjectionPosition ()` - Set the position of spline handles and points in terms of a plane's position. i.e., if ProjectionNormal is 0, all of the x-coordinate values of the points are set to position. Any value can be passed (and is ignored) to update the spline points when Projection normal is set to 3 for arbritrary plane orientations.
- `obj.GetPolyData (vtkPolyData pd)` - Grab the polydata (including points) that defines the spline. The polydata consists of points and line segments numbering Resolution + 1 and Resoltuion, respectively. Points are guaranteed to be up-to-date when either the InteractionEvent or EndInteraction events are invoked. The user provides the vtkPolyData and the points and polyline are added to it.
- `obj.SetHandleProperty (vtkProperty )` - Set/Get the handle properties (the spheres are the handles). The properties of the handles when selected and unselected can be manipulated.
- `vtkProperty = obj.GetHandleProperty ()` - Set/Get the handle properties (the spheres are the handles). The properties of the handles when selected and unselected can be manipulated.
- `obj.SetSelectedHandleProperty (vtkProperty )` - Set/Get the handle properties (the spheres are the handles). The properties of the handles when selected and unselected can be manipulated.
- `vtkProperty = obj.GetSelectedHandleProperty ()` - Set/Get the handle properties (the spheres are the handles). The properties of the handles when selected and unselected can be manipulated.
- `obj.SetLineProperty (vtkProperty )` - Set/Get the line properties. The properties of the line when selected and unselected can be manipulated.
- `vtkProperty = obj.GetLineProperty ()` - Set/Get the line properties. The properties of the line when selected and unselected can be manipulated.
- `obj.SetSelectedLineProperty (vtkProperty )` - Set/Get the line properties. The properties of the line when selected and unselected can be manipulated.
- `vtkProperty = obj.GetSelectedLineProperty ()` - Set/Get the line properties. The properties of the line when selected and unselected can be manipulated.
- `obj.SetNumberOfHandles (int npts)` - Set/Get the number of handles for this widget.
- `int = obj.GetNumberOfHandles ()` - Set/Get the number of handles for this widget.
- `obj.SetResolution (int resolution)` - Set/Get the number of line segments representing the spline for this widget.
- `int = obj.GetResolution ()` - Set/Get the number of line segments representing the spline for this widget.
- `obj.SetParametricSpline (vtkParametricSpline )` - Set the parametric spline object. Through vtkParametricSpline's API, the user can supply and configure one of currently two types of spline: vtkCardinalSpline, vtkKochanekSpline. The widget controls the open or closed configuration of the spline. WARNING: The widget does not enforce internal consistency so that all three are of the same type.
- `vtkParametricSpline = obj.GetParametricSpline ()` - Set the parametric spline object. Through vtkParametricSpline's API, the user can supply and configure one of currently two types of spline: vtkCardinalSpline, vtkKochanekSpline. The widget controls the open or closed configuration of the spline. WARNING: The widget does not enforce internal consistency so that all three are of the same type.
- `obj.SetHandlePosition (int handle, double x, double y, double z)` - Set/Get the position of the spline handles. Call GetNumberOfHandles to determine the valid range of handle indices.
- `obj.SetHandlePosition (int handle, double xyz[3])` - Set/Get the position of the spline handles. Call GetNumberOfHandles to determine the valid range of handle indices.
- `obj.GetHandlePosition (int handle, double xyz[3])` - Set/Get the position of the spline handles. Call GetNumberOfHandles to determine the valid range of handle indices.
- `double = obj.GetHandlePosition (int handle)` - Set/Get the position of the spline handles. Call GetNumberOfHandles to determine the valid range of handle indices.
- `obj.SetClosed (int closed)` - Control whether the spline is open or closed. A closed spline forms a continuous loop: the first and last points are the same, and derivatives are continuous. A minimum of 3 handles are required to form a closed loop. This method enforces consistency with user supplied subclasses of vtkSpline.
- `int = obj.GetClosed ()` - Control whether the spline is open or closed. A closed spline forms a continuous loop: the first and last points are the same, and derivatives are continuous. A minimum of 3 handles are required to form a closed loop. This method enforces consistency with user supplied subclasses of vtkSpline.
- `obj.ClosedOn ()` - Control whether the spline is open or closed. A closed spline forms a continuous loop: the first and last points are the same, and derivatives are continuous. A minimum of 3 handles are required to form a closed loop. This method enforces consistency with user supplied subclasses of vtkSpline.
- `obj.ClosedOff ()` - Control whether the spline is open or closed. A closed spline forms a continuous loop: the first and last points are the same, and derivatives are continuous. A minimum of 3 handles are required to form a closed loop. This method enforces consistency with user supplied subclasses of vtkSpline.
- `int = obj.IsClosed ()` - Convenience method to determine whether the spline is closed in a geometric sense. The widget may be set "closed" but still be geometrically open (e.g., a straight line).
- `double = obj.GetSummedLength ()` - Get the approximate vs. the true arc length of the spline. Calculated as the summed lengths of the individual straight line segments. Use SetResolution to control the accuracy.
- `obj.InitializeHandles (vtkPoints points)` - Convenience method to allocate and set the handles from a vtkPoints instance. If the first and last points are the same, the spline sets Closed to the on state and disregards the last point, otherwise Closed remains unchanged.