latest version v1.9 - last update 10 Apr 2010 |
Fill pattern class. More...
#include <ltiGraphicsPattern.h>
Public Types | |
enum | contourType |
typedef std::list< const basicObject * > | objectList |
Public Member Functions | |
fillPattern () | |
fillPattern (const fillPattern &other) | |
fillPattern (const basicObject &base, contourType type, float scale=1.0) | |
virtual | ~fillPattern () |
void | add (const basicObject &o) |
template<class T > | |
void | setMask (const matrix< T > &m) |
bool | isSet (int x, int y) |
bool | isSet (const point &p) |
const objectList & | getObjects () const |
virtual rectangle | getBoundingBox () const |
fillPattern & | copy (const fillPattern &other) |
fillPattern & | operator= (const fillPattern &other) |
virtual object * | clone () const |
virtual void | clear () |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
virtual bool | read (ioHandler &handler, const bool complete=true) |
Static Public Member Functions | |
static fillPattern * | createHatching (int dx, int dy, int w) |
Protected Member Functions | |
void | updateMask () |
template<class T > | |
void | drawObject (matrix< T > &pane, const internalObject &p) |
Fill pattern class.
A fill pattern is defined by a set of graphical primitives. At present, the only supported primitives are borderPoints, areaPoints, and polygonPoints.
typedef std::list<const basicObject*> lti::fillPattern::objectList |
The representation of a mask in vector form.
The list contains pointers to point list objects (maybe different subtypes of pointlist). Once added to the mask, the objects must not be modified.
The type of mask objects that should be used.
At present, only polygon is supported.
lti::fillPattern::fillPattern | ( | ) |
Default constructor.
This will create a homogeneous area.
lti::fillPattern::fillPattern | ( | const fillPattern & | other | ) |
Copy constructor.
lti::fillPattern::fillPattern | ( | const basicObject & | base, | |
contourType | type, | |||
float | scale = 1.0 | |||
) |
Constructor.
The given pointList is cast to the type given as argument.
base | the base object of the pattern. | |
type | the type of created contour. If you choose, e.g. Polygon, then all objects that are added get converted to polygons. | |
scale |
virtual lti::fillPattern::~fillPattern | ( | ) | [virtual] |
Destructor.
void lti::fillPattern::add | ( | const basicObject & | o | ) |
Adds a contour to the pattern.
The given contour gets converted to the type defined in the constructor.
virtual void lti::fillPattern::clear | ( | ) | [virtual] |
Resets this pattern to its default state.
Implements lti::graphicsPattern.
virtual object* lti::fillPattern::clone | ( | ) | const [virtual] |
create a clone of this basicObject
Implements lti::graphicsPattern.
fillPattern& lti::fillPattern::copy | ( | const fillPattern & | other | ) |
assigment operator.
copy the contents of other
in this object.
other | the source basicObject to be copied. |
Reimplemented from lti::graphicsPattern.
Referenced by operator=().
static fillPattern* lti::fillPattern::createHatching | ( | int | dx, | |
int | dy, | |||
int | w | |||
) | [static] |
Static method to create a hatch pattern.
dx and dy determine two things: The width and height of the returned pattern, and also the slope of the lines. There is only one line per pattern. Examples:
createHatching(2,2,1);
will create a hatching that looks about:
* *
whereas
createHatching(2,-2,1);
will create a hatching that looks like:
* *
A more complex example:
createHatching(16,4,2); ******** ******** ******** **** ****
void lti::fillPattern::drawObject | ( | matrix< T > & | pane, | |
const internalObject & | p | |||
) | [inline, protected] |
Draws a filled polygon into the given mask.
virtual rectangle lti::fillPattern::getBoundingBox | ( | ) | const [virtual] |
Returns the bounding box of this pattern.
Implements lti::graphicsPattern.
const objectList& lti::fillPattern::getObjects | ( | ) | const [inline] |
Returns the list of objects that constitute the pattern.
bool lti::fillPattern::isSet | ( | const point & | p | ) | [inline] |
Returns true if the given point is allowed by this pattern mask.
References isSet(), lti::tpoint< T >::x, and lti::tpoint< T >::y.
bool lti::fillPattern::isSet | ( | int | x, | |
int | y | |||
) | [inline] |
Returns true if the given point is allowed by this pattern mask.
References lti::genericMatrix< T >::at(), lti::tpoint< T >::x, and lti::tpoint< T >::y.
Referenced by isSet().
fillPattern& lti::fillPattern::operator= | ( | const fillPattern & | other | ) | [inline] |
assigment operator (alias for copy(other)).
other | the basicObject to be copied |
Reimplemented from lti::graphicsPattern.
References copy().
virtual bool lti::fillPattern::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
read the pattern from the given ioHandler
Reimplemented from lti::graphicsPattern.
void lti::fillPattern::setMask | ( | const matrix< T > & | m | ) | [inline] |
Sets the pattern mask explicitly.
The mask is only used for pixel-based drawing where the vector format usually yields crap.
References lti::matrix< T >::castFrom(), and lti::genericMatrix< T >::size().
void lti::fillPattern::updateMask | ( | ) | [protected] |
Updates the pixel mask from the list of mask objects.
Also recomputes the bounding box.
virtual bool lti::fillPattern::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
write the pattern to the given ioHandler
Reimplemented from lti::graphicsPattern.