Chemical Data Processing Library Python API - Version 1.1.1
Classes | Public Member Functions | Properties | List of all members
CDPL.Vis.Path2D Class Reference

Provides a container for painting operations, enabling arbitrary graphical shapes to be constructed and reused. More...

+ Inheritance diagram for CDPL.Vis.Path2D:

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)
 

Detailed Description

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.

Since
1.1

Constructor & Destructor Documentation

◆ __init__()

None CDPL.Vis.Path2D.__init__ ( Path2D  path)

Constructs a copy of the Path2D instance path.

Parameters
pathThe Path2D instance to copy.

Member Function Documentation

◆ getObjectID()

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().

Returns
The numeric ID of the internally referenced C++ class instance.

◆ assign()

Path2D CDPL.Vis.Path2D.assign ( Path2D  path)

Assignment operator.

Parameters
pathThe Path2D instance to copy.
Returns
self

◆ isEmpty()

bool CDPL.Vis.Path2D.isEmpty ( )

Tells whether the Path2D instance does not contain any elements.

Returns
True is no elements have been added to the Path2D instance so far, and False otherwise.

◆ hasDrawingElements()

bool CDPL.Vis.Path2D.hasDrawingElements ( )

Tells whether the Path2D instance contains any elements representing drawing operations (lines and arcs).

Returns
True if the Path2D instance contains any visual elements, and False otherwise.

◆ clear()

None CDPL.Vis.Path2D.clear ( )

Deletes all path elements added so far and sets the fill rule to its default.

See also
setFillRule()

◆ setFillRule()

None CDPL.Vis.Path2D.setFillRule ( FillRule  rule)

Sets the fill rule of the path to the specified value.

Parameters
ruleThe new fill rule.
Note
The default fill rule is Path2D.EVEN_ODD.

◆ getFillRule()

FillRule CDPL.Vis.Path2D.getFillRule ( )

Returns the currently set fill rule.

Returns
The currently set fill rule.

◆ moveTo() [1/2]

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.

Parameters
xSpecifies the x-coordinate of the new position.
ySpecifies the y-coordinate of the new position.

◆ moveTo() [2/2]

None CDPL.Vis.Path2D.moveTo ( Math.Vector2D  pos)

Sets the current position to pos and starts a new subpath, implicitly closing the previous path.

Parameters
posA 2D vector specifying the new position.

◆ arc() [1/2]

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.

Parameters
cxThe x-coordinate of the ellipse center.
cyThe y-coordinate of the ellipse center.
rxThe x-radius of the ellipse.
ryThe y-radius of the ellipse.
start_angThe start angle of the arg in degrees.
sweepThe length of the arg in degrees.
Note
The method first performs a moveTo() call with the starting point of the arc as argument and thus avoids an implicit line being drawn from the current position to the arc's starting position (see arcTo()).

◆ arc() [2/2]

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.

Parameters
ctrA 2D vector specifying the ellipse center.
rxThe x-radius of the ellipse.
ryThe y-radius of the ellipse.
start_angThe start angle of the arg in degrees.
sweepThe length of the arg in degrees.
Note
The method first performs a moveTo() call with the starting point of the arc as argument and thus avoids an implicit line being drawn from the current position to the arc's starting position (see arcTo()).

◆ arcTo() [1/2]

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.

Parameters
cxThe x-coordinate of the ellipse center.
cyThe y-coordinate of the ellipse center.
rxThe x-radius of the ellipse.
ryThe y-radius of the ellipse.
start_angThe start angle of the arg in degrees.
sweepThe length of the arg in degrees.
Note
The method implicitly connects the starting point of the arc to the current position if they are not already connected. The rendering result is undefined if no subpath starting point has been specified (see moveTo())!

◆ arcTo() [2/2]

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.

Parameters
ctrA 2D vector specifying the ellipse center.
rxThe x-radius of the ellipse.
ryThe y-radius of the ellipse.
start_angThe start angle of the arg in degrees.
sweepThe length of the arg in degrees.
Note
The method implicitly connects the starting point of the arc to the current position if they are not already connected. The rendering result is undefined if no subpath starting point has been specified (see moveTo())!

◆ lineTo() [1/2]

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.

Parameters
xSpecifies the x-coordinate of the line's end point.
ySpecifies the y-coordinate of the line's end point.
Note
The rendering result is undefined if no subpath starting point has been specified (see moveTo())!

◆ lineTo() [2/2]

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.

Parameters
posA 2D vector specifying the line end point.
Note
The rendering result is undefined if no subpath starting point has been specified (see moveTo())!

◆ closePath()

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.

Note
After closing the subpath the current point is undefined!

◆ getBounds()

None CDPL.Vis.Path2D.getBounds ( Rectangle2D  bounds)

Calculates the axis-aligned bounding box of the path.

Parameters
boundsThe Vis.Rectangle2D instance storing the calculated bounding box.

◆ convert()

None CDPL.Vis.Path2D.convert ( Path2DConverter  conv)

Iterates over the stored path elements and calls the corresponding method of conv for each visited element.

Parameters
convAn instance of a class implementing the Vis.Path2DConverter interface.

◆ addEllipse() [1/2]

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.

Parameters
xThe x-coordinate of the ellipse center.
yThe y-coordinate of the ellipse center.
widthThe width of the ellipse.
heightThe height of the ellipse.

◆ addEllipse() [2/2]

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.

Parameters
posA 2D vector specifying the ellipse center.
widthThe width of the ellipse.
heightThe height of the ellipse.

◆ addRectangle() [1/2]

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.

Parameters
xThe x-coordinate of the top-left corner.
yThe y-coordinate of the top-left corner.
widthThe width of the rectangle.
heightThe height of the rectangle.

◆ addRectangle() [2/2]

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.

Parameters
posA 2D vector specifying the top-left corner.
widthThe width of the rectangle.
heightThe height of the rectangle.

◆ __iadd__()

Path2D CDPL.Vis.Path2D.__iadd__ ( Path2D  path)

Performs the in-place addition operation self += path.

Parameters
pathSpecifies the second addend.
Returns
The updated Path2D instance self.

◆ __eq__()

bool CDPL.Vis.Path2D.__eq__ ( Path2D  path)

Equality comparison operator.

Parameters
pathThe Path2D instance to compare with.
Returns
True if this path is equal to path, and False otherwise.

◆ __ne__()

bool CDPL.Vis.Path2D.__ne__ ( Path2D  path)

Non-equality comparison operator.

Parameters
pathThe Path2D instance to compare with.
Returns
True if this path is not equal to path, and False otherwise.

◆ __bool__()

bool CDPL.Vis.Path2D.__bool__ ( )
Returns