Chemical Data Processing Library Python API - Version 1.2.0
|
Provides a container for painting operations, enabling arbitrary graphical shapes to be constructed and reused. More...
Classes | |
class | FillRule |
Specifies which method to use for filling closed shapes described by the Path2D object. More... | |
Public Member Functions | |
None | __init__ () |
Constructs an empty Path2D instance. | |
None | __init__ (Path2D path) |
Constructs a copy of the Path2D instance path. More... | |
int | getObjectID () |
Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
Path2D | assign (Path2D path) |
Assignment operator. More... | |
bool | isEmpty () |
Tells whether the Path2D instance does not contain any elements. More... | |
bool | hasDrawingElements () |
Tells whether the Path2D instance contains any elements representing drawing operations (lines and arcs). More... | |
None | clear () |
Deletes all path elements added so far and sets the fill rule to its default. More... | |
None | setFillRule (FillRule rule) |
Sets the fill rule of the path to the specified value. More... | |
FillRule | getFillRule () |
Returns the currently set fill rule. More... | |
None | moveTo (float x, float y) |
Sets the current position to (x, y) and starts a new subpath, implicitly closing the previous path. More... | |
None | moveTo (Math.Vector2D pos) |
Sets the current position to pos and starts a new subpath, implicitly closing the previous path. More... | |
None | arc (float cx, float cy, float rx, float ry, float start_ang, float sweep) |
Creates an elliptical arc centered at (cx, cy) with ellipse radii rx and ry beginning at the angle start_ang and extending sweep degrees clockwise. More... | |
None | arc (Math.Vector2D ctr, float rx, float ry, float start_ang, float sweep) |
Creates an elliptical arc centered at ctr with ellipse radii rx and ry beginning at the angle start_ang and extending sweep degrees clockwise. More... | |
None | arcTo (float cx, float cy, float rx, float ry, float start_ang, float sweep) |
Creates an elliptical arc centered at (cx, cy) with ellipse radii rx and ry beginning at the angle start_ang and extending sweep degrees clockwise. More... | |
None | arcTo (Math.Vector2D ctr, float rx, float ry, float start_ang, float sweep) |
Creates an elliptical arc centered at ctr with ellipse radii rx and ry beginning at the angle start_ang and extending sweep degrees clockwise. More... | |
None | lineTo (float x, float y) |
Adds a straight line from the current position to the point (x, y). More... | |
None | lineTo (Math.Vector2D pos) |
Adds a straight line from the current position to the point (x, y). More... | |
None | closePath () |
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting a new path. More... | |
None | getBounds (Rectangle2D bounds) |
Calculates the axis-aligned bounding box of the path. More... | |
None | convert (Path2DConverter conv) |
Iterates over the stored path elements and calls the corresponding method of conv for each visited element. More... | |
None | addEllipse (float x, float y, float width, float height) |
Creates an ellipse positioned at (x, y) with the specified width and height, and adds it to this path as a closed subpath. More... | |
None | addEllipse (Math.Vector2D pos, float width, float height) |
Creates an ellipse positioned at pos with the specified width and height, and adds it to this path as a closed subpath. More... | |
None | addRectangle (float x, float y, float width, float height) |
Creates a rectangle positioned at (x, y) with the specified width and height, and adds it to this path as a closed subpath. More... | |
None | addRectangle (Math.Vector2D pos, float width, float height) |
Creates a rectangle positioned at pos with the specified width and height, and adds it to this path as a closed subpath. More... | |
Path2D | __iadd__ (Path2D path) |
Performs the in-place addition operation self += path . More... | |
bool | __eq__ (Path2D path) |
Equality comparison operator. More... | |
bool | __ne__ (Path2D path) |
Non-equality comparison operator. More... | |
bool | __bool__ () |
Properties | |
objectID = property(getObjectID) | |
empty = property(getEmpty) | |
FIXME! | |
hasDrawingElem = property(getHasDrawingElem) | |
FIXME! | |
fillRule = property(getFillRule, setFillRule) | |
Provides a container for painting operations, enabling arbitrary graphical shapes to be constructed and reused.
A path consits of a number of graphical building blocks, such as rectangles, ellipses, lines and arcs. Building blocks can be joined to form closed subpaths, for example a rounded rectangle, or they can exist independently as unclosed subpaths, such as lines and curves. A closed path has coinciding start and end points.
Path2D
objects can be used for filling, outlining, and clipping. The main advantage over a sequence of basic drawing operations is that complex shapes need to be created only once and can be stored for repeated later uses.
A Path2D
object can be constructed as an empty path, or as a copy of another Path2D
instance. Once created, lines and curves can be added to the path using the lineTo(), arcTo() and arc() functions. The lines and curves stretch from the current position to the position passed as argument. The current position is always the end point of the last drawing operation. Use the moveTo() method to move the current position without adding a component. The moveTo() method implicitly starts a new subpath, and closes the previous one. Another way of starting a new subpath is to call the closePath() method which closes the current path by adding a line from the current position back to the path's start position. The Path2D
class also provides convenience methods for the generation of common shapes: addEllipse() and addRectangle(). The generation of these shapes is implemented by executing a sequence of appropriate moveTo(), lineTo() and arcTo() calls. The axis-aligned bounding box of a path constructed in this way can be calculated by the method getBounds().
Whether or not a Path2D
object contains any elements can be queried by the method isEmpty(). Whether the path also features visual elements (lines and arcs) can be queried by the method hasDrawingElements(). The method clear() deletes all elements added so far and sets the default fill rule (see setFillRule() and getFillRule()).
Elements added to a Path2D
object cannot inspected directly. For path analysis and rendering the method convert() is available which calls element type specific methods on a provided instance of a class implementing the Vis.Path2DConverter interface.
None CDPL.Vis.Path2D.__init__ | ( | Path2D | path | ) |
int CDPL.Vis.Path2D.getObjectID | ( | ) |
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python Path2D instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b
thus cannot tell reliably whether the two Path2D instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID()
.
bool CDPL.Vis.Path2D.isEmpty | ( | ) |
bool CDPL.Vis.Path2D.hasDrawingElements | ( | ) |
None CDPL.Vis.Path2D.clear | ( | ) |
Deletes all path elements added so far and sets the fill rule to its default.
None CDPL.Vis.Path2D.setFillRule | ( | FillRule | rule | ) |
Sets the fill rule of the path to the specified value.
rule | The new fill rule. |
FillRule CDPL.Vis.Path2D.getFillRule | ( | ) |
Returns the currently set fill rule.
None CDPL.Vis.Path2D.moveTo | ( | float | x, |
float | y | ||
) |
Sets the current position to (x, y) and starts a new subpath, implicitly closing the previous path.
x | Specifies the x-coordinate of the new position. |
y | Specifies the y-coordinate of the new position. |
None CDPL.Vis.Path2D.moveTo | ( | Math.Vector2D | pos | ) |
Sets the current position to pos and starts a new subpath, implicitly closing the previous path.
pos | A 2D vector specifying the new position. |
None CDPL.Vis.Path2D.arc | ( | float | cx, |
float | cy, | ||
float | rx, | ||
float | ry, | ||
float | start_ang, | ||
float | sweep | ||
) |
Creates an elliptical arc centered at (cx, cy) with ellipse radii rx and ry beginning at the angle start_ang and extending sweep degrees clockwise.
Angles are specified in degrees. Counter-clockwise arcs can be specified using negative angles. After the arc has been added, the current position is the end point of the arc. To draw a line back to the first point, use the closePath() method.
cx | The x-coordinate of the ellipse center. |
cy | The y-coordinate of the ellipse center. |
rx | The x-radius of the ellipse. |
ry | The y-radius of the ellipse. |
start_ang | The start angle of the arg in degrees. |
sweep | The length of the arg in degrees. |
None CDPL.Vis.Path2D.arc | ( | Math.Vector2D | ctr, |
float | rx, | ||
float | ry, | ||
float | start_ang, | ||
float | sweep | ||
) |
Creates an elliptical arc centered at ctr with ellipse radii rx and ry beginning at the angle start_ang and extending sweep degrees clockwise.
Angles are specified in degrees. Counter-clockwise arcs can be specified using negative angles. After the arc has been added, the current position is the end point of the arc. To draw a line back to the first point, use the closePath() method.
ctr | A 2D vector specifying the ellipse center. |
rx | The x-radius of the ellipse. |
ry | The y-radius of the ellipse. |
start_ang | The start angle of the arg in degrees. |
sweep | The length of the arg in degrees. |
None CDPL.Vis.Path2D.arcTo | ( | float | cx, |
float | cy, | ||
float | rx, | ||
float | ry, | ||
float | start_ang, | ||
float | sweep | ||
) |
Creates an elliptical arc centered at (cx, cy) with ellipse radii rx and ry beginning at the angle start_ang and extending sweep degrees clockwise.
Angles are specified in degrees. Counter-clockwise arcs can be specified using negative angles. After the arc has been added, the current position is the end point of the arc. To draw a line back to the first point, use the closePath() method.
cx | The x-coordinate of the ellipse center. |
cy | The y-coordinate of the ellipse center. |
rx | The x-radius of the ellipse. |
ry | The y-radius of the ellipse. |
start_ang | The start angle of the arg in degrees. |
sweep | The length of the arg in degrees. |
None CDPL.Vis.Path2D.arcTo | ( | Math.Vector2D | ctr, |
float | rx, | ||
float | ry, | ||
float | start_ang, | ||
float | sweep | ||
) |
Creates an elliptical arc centered at ctr with ellipse radii rx and ry beginning at the angle start_ang and extending sweep degrees clockwise.
Angles are specified in degrees. Counter-clockwise arcs can be specified using negative angles. After the arc has been added, the current position is the end point of the arc. To draw a line back to the first point, use the closePath() method.
ctr | A 2D vector specifying the ellipse center. |
rx | The x-radius of the ellipse. |
ry | The y-radius of the ellipse. |
start_ang | The start angle of the arg in degrees. |
sweep | The length of the arg in degrees. |
None CDPL.Vis.Path2D.lineTo | ( | float | x, |
float | y | ||
) |
Adds a straight line from the current position to the point (x, y).
After the line is drawn, the current position is updated to be at the end point of the line.
x | Specifies the x-coordinate of the line's end point. |
y | Specifies the y-coordinate of the line's end point. |
None CDPL.Vis.Path2D.lineTo | ( | Math.Vector2D | pos | ) |
Adds a straight line from the current position to the point (x, y).
After the line is drawn, the current position is updated to be at the end point of the line.
pos | A 2D vector specifying the line end point. |
None CDPL.Vis.Path2D.closePath | ( | ) |
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting a new path.
A call to this methods has no effect if the current subpath does not contain any elements.
None CDPL.Vis.Path2D.getBounds | ( | Rectangle2D | bounds | ) |
Calculates the axis-aligned bounding box of the path.
bounds | The Vis.Rectangle2D instance storing the calculated bounding box. |
None CDPL.Vis.Path2D.convert | ( | Path2DConverter | conv | ) |
Iterates over the stored path elements and calls the corresponding method of conv for each visited element.
conv | An instance of a class implementing the Vis.Path2DConverter interface. |
None CDPL.Vis.Path2D.addEllipse | ( | float | x, |
float | y, | ||
float | width, | ||
float | height | ||
) |
Creates an ellipse positioned at (x, y) with the specified width and height, and adds it to this path as a closed subpath.
x | The x-coordinate of the ellipse center. |
y | The y-coordinate of the ellipse center. |
width | The width of the ellipse. |
height | The height of the ellipse. |
None CDPL.Vis.Path2D.addEllipse | ( | Math.Vector2D | pos, |
float | width, | ||
float | height | ||
) |
Creates an ellipse positioned at pos with the specified width and height, and adds it to this path as a closed subpath.
pos | A 2D vector specifying the ellipse center. |
width | The width of the ellipse. |
height | The height of the ellipse. |
None CDPL.Vis.Path2D.addRectangle | ( | float | x, |
float | y, | ||
float | width, | ||
float | height | ||
) |
Creates a rectangle positioned at (x, y) with the specified width and height, and adds it to this path as a closed subpath.
x | The x-coordinate of the top-left corner. |
y | The y-coordinate of the top-left corner. |
width | The width of the rectangle. |
height | The height of the rectangle. |
None CDPL.Vis.Path2D.addRectangle | ( | Math.Vector2D | pos, |
float | width, | ||
float | height | ||
) |
Creates a rectangle positioned at pos with the specified width and height, and adds it to this path as a closed subpath.
pos | A 2D vector specifying the top-left corner. |
width | The width of the rectangle. |
height | The height of the rectangle. |
Performs the in-place addition operation self += path
.
path | Specifies the second addend. |
bool CDPL.Vis.Path2D.__eq__ | ( | Path2D | path | ) |
Equality comparison operator.
path | The Path2D instance to compare with. |
True
if this path is equal to path, and False
otherwise. bool CDPL.Vis.Path2D.__ne__ | ( | Path2D | path | ) |
Non-equality comparison operator.
path | The Path2D instance to compare with. |
True
if this path is not equal to path, and False
otherwise. bool CDPL.Vis.Path2D.__bool__ | ( | ) |