API reference - Class Path

Notation used in Ruby API documentation

Description: A path class

A path consists of an sequence of line segments forming the 'spine' of the path and a width. In addition, the starting point can be drawn back by a certain extent (the 'begin extension') and the end point can be pulled forward somewhat (by the 'end extension').

A path may have round ends for special purposes. In particular, a round-ended path with a single point can represent a circle. Round-ended paths should have being and end extensions equal to half the width. Non-round-ended paths with a single point are allowed but the definition of the resulting shape in not well defined and may differ in other tools.

See The Database API for more details about the database objects.

Public constructors

new Path ptrnewDefault constructor: creates an empty (invalid) path with width 0
new Path ptrnew(Point[] pts,
int width)
Constructor given the points of the path's spine and the width
new Path ptrnew(Point[] pts,
int width,
int bgn_ext,
int end_ext)
Constructor given the points of the path's spine, the width and the extensions
new Path ptrnew(Point[] pts,
int width,
int bgn_ext,
int end_ext,
bool round)
Constructor given the points of the path's spine, the width, the extensions and the round end flag

Public methods

[const]bool!=(const Path p)Inequality test
[const]Path*(double f)Scaling by some factor
[const]bool<(const Path p)Less operator
[const]bool==(const Path p)Equality test
void_createEnsures the C++ object is created
void_destroyExplicitly destroys the object
[const]bool_destroyed?Returns a value indicating whether the object was already destroyed
[const]bool_is_const_object?Returns a value indicating whether the reference is a const reference
void_manageMarks the object as managed by the script side.
void_unmanageMarks the object as no longer owned by the script side.
[const]longareaReturns the approximate area of the path
voidassign(const Path other)Assigns another object to self
[const]BoxbboxReturns the bounding box of the path
[const]intbgn_extGet the begin extension
voidbgn_ext=(int ext)Set the begin extension
[const]new Path ptrdupCreates a copy of self
[const,iter]Pointeach_pointGet the points that make up the path's spine
[const]intend_extGet the end extension
voidend_ext=(int ext)Set the end extension
[const]boolis_round?Returns true, if the path has round ends
[const]unsigned intlengthReturns the length of the path
Pathmove(const Point p)Moves the path.
Pathmove(int dx,
int dy)
Moves the path.
[const]Pathmoved(const Point p)Returns the moved path (does not change self)
[const]Pathmoved(int dx,
int dy)
Returns the moved path (does not change self)
[const]unsigned longnum_pointsGet the number of points
voidpoints=(Point[] p)Set the points of the path
[const]PolygonpolygonConvert the path to a polygon
voidround=(bool round_ends_flag)Set the 'round ends' flag
[const]SimplePolygonsimple_polygonConvert the path to a simple polygon
[const]stringto_sConvert to a string
[const]Pathtransformed(const Trans t)Transform the path.
[const]DPathtransformed(const CplxTrans t)Transform the path.
[const]Pathtransformed(const ICplxTrans t)Transform the path.
[const]intwidthGet the width
voidwidth=(int w)Set the width

Public static methods and constants

Pathfrom_dpath(const DPath double_path)Construct an integer-coordinate path from a floating-point coordinate one
new Path ptrfrom_s(string s)Creates an object from a string

Deprecated methods (protected, public, static, non-static and constructors)

voidcreateUse of this method is deprecated. Use _create instead
voiddestroyUse of this method is deprecated. Use _destroy instead
[const]booldestroyed?Use of this method is deprecated. Use _destroyed? instead
[const]boolis_const_object?Use of this method is deprecated. Use _is_const_object? instead
[static]new Path ptrnew_pw(Point[] pts,
int width)
Use of this method is deprecated. Use new instead
[static]new Path ptrnew_pwx(Point[] pts,
int width,
int bgn_ext,
int end_ext)
Use of this method is deprecated. Use new instead
[static]new Path ptrnew_pwxr(Point[] pts,
int width,
int bgn_ext,
int end_ext,
bool round)
Use of this method is deprecated. Use new instead
[const]unsigned longpointsUse of this method is deprecated. Use num_points instead
[const]DPathtransformed_cplx(const CplxTrans t)Use of this method is deprecated. Use transformed instead
[const]Pathtransformed_cplx(const ICplxTrans t)Use of this method is deprecated. Use transformed instead

Detailed description

[const] bool !=(const Path p)

Description: Inequality test

p:The object to compare against

[const] Path *(double f)

Description: Scaling by some factor

Returns the scaled object. All coordinates are multiplied with the given factor and if necessary rounded.

[const] bool <(const Path p)

Description: Less operator

p:The object to compare against

This operator is provided to establish some, not necessarily a certain sorting order

[const] bool ==(const Path p)

Description: Equality test

p:The object to compare against

void _create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

void _destroy

Description: Explicitly destroys the object

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

[const] bool _destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

[const] bool _is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

void _manage

Description: Marks the object as managed by the script side.

After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required.

Usually it's not required to call this method. It has been introduced in version 0.24.

void _unmanage

Description: Marks the object as no longer owned by the script side.

Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur.

Usually it's not required to call this method. It has been introduced in version 0.24.

[const] long area

Description: Returns the approximate area of the path

This method returns the approximate value of the area. It is computed from the length times the width. end extensions are taken into account correctly, but not effects of the corner interpolation. This method was added in version 0.22.

void assign(const Path other)

Description: Assigns another object to self

[const] Box bbox

Description: Returns the bounding box of the path

[const] int bgn_ext

Description: Get the begin extension

Python specific notes:

The object exposes a readable attribute 'bgn_ext'. This is the getter.

void bgn_ext=(int ext)

Description: Set the begin extension

Python specific notes:

The object exposes a writable attribute 'bgn_ext'. This is the setter.

void create

Description: Ensures the C++ object is created

Use of this method is deprecated. Use _create instead

void destroy

Description: Explicitly destroys the object

Use of this method is deprecated. Use _destroy instead

[const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

Use of this method is deprecated. Use _destroyed? instead

[const] new Path ptr dup

Description: Creates a copy of self

[const,iter] Point each_point

Description: Get the points that make up the path's spine

[const] int end_ext

Description: Get the end extension

Python specific notes:

The object exposes a readable attribute 'end_ext'. This is the getter.

void end_ext=(int ext)

Description: Set the end extension

Python specific notes:

The object exposes a writable attribute 'end_ext'. This is the setter.

[static] Path from_dpath(const DPath double_path)

Description: Construct an integer-coordinate path from a floating-point coordinate one

This method has been added in version 0.15.

[static] new Path ptr from_s(string s)

Description: Creates an object from a string

Creates the object from a string representation (as returned by to_s)

This method has been added in version 0.23.

[const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

Use of this method is deprecated. Use _is_const_object? instead

[const] bool is_round?

Description: Returns true, if the path has round ends

[const] unsigned int length

Description: Returns the length of the path

the length of the path is determined by summing the lengths of the segments and adding begin and end extensions. For round-ended paths the length of the paths between the tips of the ends.

This method was added in version 0.23.

Path move(const Point p)

Description: Moves the path.

p:The distance to move the path.
Returns:The moved path.

Moves the path by the given offset and returns the moved path. The path is overwritten.

Path move(int dx,int dy)

Description: Moves the path.

dx:The x distance to move the path.
dy:The y distance to move the path.
Returns:The moved path.

Moves the path by the given offset and returns the moved path. The path is overwritten.

This version has been added in version 0.23.

[const] Path moved(const Point p)

Description: Returns the moved path (does not change self)

p:The distance to move the path.
Returns:The moved path.

Moves the path by the given offset and returns the moved path. The path is not modified.

[const] Path moved(int dx,int dy)

Description: Returns the moved path (does not change self)

dx:The x distance to move the path.
dy:The y distance to move the path.
Returns:The moved path.

Moves the path by the given offset and returns the moved path. The path is not modified.

This version has been added in version 0.23.

[static] new Path ptr new

Description: Default constructor: creates an empty (invalid) path with width 0

Python specific notes:

This method is the default initializer of the object

[static] new Path ptr new(Point[] pts,int width)

Description: Constructor given the points of the path's spine and the width

pts:The points forming the spine of the path
width:The width of the path

Python specific notes:

This method is the default initializer of the object

[static] new Path ptr new(Point[] pts,int width,int bgn_ext,int end_ext)

Description: Constructor given the points of the path's spine, the width and the extensions

pts:The points forming the spine of the path
width:The width of the path
bgn_ext:The begin extension of the path
end_ext:The end extension of the path

Python specific notes:

This method is the default initializer of the object

[static] new Path ptr new(Point[] pts,int width,int bgn_ext,int end_ext,bool round)

Description: Constructor given the points of the path's spine, the width, the extensions and the round end flag

pts:The points forming the spine of the path
width:The width of the path
bgn_ext:The begin extension of the path
end_ext:The end extension of the path
round:If this flag is true, the path will get rounded ends

Python specific notes:

This method is the default initializer of the object

[static] new Path ptr new_pw(Point[] pts,int width)

Description: Constructor given the points of the path's spine and the width

pts:The points forming the spine of the path
width:The width of the path

Use of this method is deprecated. Use new instead

[static] new Path ptr new_pwx(Point[] pts,int width,int bgn_ext,int end_ext)

Description: Constructor given the points of the path's spine, the width and the extensions

pts:The points forming the spine of the path
width:The width of the path
bgn_ext:The begin extension of the path
end_ext:The end extension of the path

Use of this method is deprecated. Use new instead

[static] new Path ptr new_pwxr(Point[] pts,int width,int bgn_ext,int end_ext,bool round)

Description: Constructor given the points of the path's spine, the width, the extensions and the round end flag

pts:The points forming the spine of the path
width:The width of the path
bgn_ext:The begin extension of the path
end_ext:The end extension of the path
round:If this flag is true, the path will get rounded ends

Use of this method is deprecated. Use new instead

[const] unsigned long num_points

Description: Get the number of points

Python specific notes:

The object exposes a readable attribute 'points'. This is the getter.

[const] unsigned long points

Description: Get the number of points

Use of this method is deprecated. Use num_points instead

void points=(Point[] p)

Description: Set the points of the path

p:An array of points to assign to the path's spine

Python specific notes:

The object exposes a writable attribute 'points'. This is the setter.

[const] Polygon polygon

Description: Convert the path to a polygon

The returned polygon is not guaranteed to be non-self overlapping. This may happen if the path overlaps itself or contains very short segments.

void round=(bool round_ends_flag)

Description: Set the 'round ends' flag

A path with round ends show half circles at the ends, instead of square or rectangular ends. Paths with this flag set should use a begin and end extension of half the width (see bgn_ext and end_ext). The interpretation of such paths in other tools may differ otherwise.

Python specific notes:

The object exposes a writable attribute 'round'. This is the setter.

[const] SimplePolygon simple_polygon

Description: Convert the path to a simple polygon

The returned polygon is not guaranteed to be non-selfoverlapping. This may happen if the path overlaps itself or contains very short segments.

[const] string to_s

Description: Convert to a string

Python specific notes:

This method is also available as 'str(object)'

[const] Path transformed(const Trans t)

Description: Transform the path.

t:The transformation to apply.
Returns:The transformed path.

Transforms the path with the given transformation. Does not modify the path but returns the transformed path.

[const] DPath transformed(const CplxTrans t)

Description: Transform the path.

t:The transformation to apply.
Returns:The transformed path.

Transforms the path with the given complex transformation. Does not modify the path but returns the transformed path.

[const] Path transformed(const ICplxTrans t)

Description: Transform the path.

t:The transformation to apply.
Returns:The transformed path (in this case an integer coordinate path).

Transforms the path with the given complex transformation. Does not modify the path but returns the transformed path.

This method has been introduced in version 0.18.

[const] DPath transformed_cplx(const CplxTrans t)

Description: Transform the path.

t:The transformation to apply.
Returns:The transformed path.

Use of this method is deprecated. Use transformed instead

[const] Path transformed_cplx(const ICplxTrans t)

Description: Transform the path.

t:The transformation to apply.
Returns:The transformed path (in this case an integer coordinate path).

Use of this method is deprecated. Use transformed instead

[const] int width

Description: Get the width

Python specific notes:

The object exposes a readable attribute 'width'. This is the getter.

void width=(int w)

Description: Set the width

Python specific notes:

The object exposes a writable attribute 'width'. This is the setter.