Ipelib: ipe::Reference Class Reference

Ipelib

Public Types | Public Member Functions | Static Public Member Functions | List of all members
ipe::Reference Class Reference
Ipe Objects

`#include <ipereference.h>`

Inherits ipe::Object.

## Public Types
enum | { EHasStroke = 0x001, EHasFill = 0x002, EHasPen = 0x004, EHasSize = 0x008, EIsMark = 0x010, EIsArrow = 0x020 }
Public Types inherited from ipe::Object
enum | Type { EGroup, EPath, EText, EImage, EReference }

## Public Member Functions
| Reference (const AllAttributes &attr, Attribute name, Vector pos)
| Reference (const XmlAttributes &attr, String data)
virtual Object * | clone () const
virtual Reference * | asReference ()
virtual Type | type () const
virtual void | accept (Visitor &visitor) const
virtual void | saveAsXml (Stream &stream, String layer) const
virtual void | draw (Painter &painter) const
virtual void | drawSimple (Painter &painter) const
virtual void | addToBBox (Rect &box, const Matrix &m, bool cp) const
virtual double | distance (const Vector &v, const Matrix &m, double bound) const
virtual void | snapVtx (const Vector &mouse, const Matrix &m, Vector &pos, double &bound) const
virtual void | snapBnd (const Vector &mouse, const Matrix &m, Vector &pos, double &bound) const
virtual void | checkStyle (const Cascade *sheet, AttributeSeq &seq) const
void | setName (Attribute name)
Attribute | name () const
void | setStroke (Attribute color)
Attribute | stroke () const
void | setFill (Attribute color)
Attribute | fill () const
Attribute | pen () const
void | setPen (Attribute pen)
void | setSize (Attribute size)
Attribute | size () const
Vector | position () const
virtual bool | setAttribute (Property prop, Attribute value)
virtual Attribute | getAttribute (Property prop) const noexcept
uint | flags () const
Public Member Functions inherited from ipe::Object
virtual | ~Object ()=0
virtual Group * | asGroup ()
virtual const Group * | asGroup () const
virtual Text * | asText ()
virtual Path * | asPath ()
virtual Image * | asImage ()
virtual TPinned | pinned () const
void | setPinned (TPinned pin)
TTransformations | transformations () const
void | setTransformations (TTransformations trans)
void | setMatrix (const Matrix &matrix)
const Matrix & | matrix () const
virtual void | snapCtl (const Vector &mouse, const Matrix &m, Vector &pos, double &bound) const

## Static Public Member Functions
static uint | flagsFromName (String name)

## Additional Inherited Members
Protected Member Functions inherited from ipe::Object
| Object ()
| Object (const AllAttributes &attr)
| Object (const Object &rhs)
| Object (const XmlAttributes &attr)
void | saveAttributesAsXml (Stream &stream, String layer) const
Static Protected Member Functions inherited from ipe::Object
static void | checkSymbol (Kind kind, Attribute attr, const Cascade *sheet, AttributeSeq &seq)
Protected Attributes inherited from ipe::Object
Matrix | iMatrix
TPinned | iPinned: 8
TTransformations | iTransformations: 8

## Detailed Description

The reference object.

A Reference uses a symbol, that is, an object defined in an Ipe StyleSheet. The object is defined as a named symbol in the style sheet, and can be reused arbitrarily often in the document. This can, for instance, be used for backgrounds on multi-page documents.

It is admissible to refer to an undefined object (that is, the current style sheet cascade does not define a symbol with the given name). Nothing will be drawn in this case.

The Reference has a stroke, fill, and pen attribute. When drawing a symbol, these attributes are made available to the symbol through the names "sym-stroke", "sym-fill", and "sym-pen". These are not defined by the style sheet, but resolved by the Painter when the symbol sets its attributes.

Note that it is not possible to determine whether a symbol is filled from the Reference object.

The size attribute is of type ESymbolSize, and indicates a magnification factor applied to the symbol. This magnification is applied after the untransformation indicated in the Reference and in the Symbol has been performed, so that symbols are magnified even if they specify ETransformationsTranslations.

The size is meant for symbols such as marks, that can be shown in different sizes. Another application of symbols is for backgrounds and logos. Their size should not be changed when the user changes the symbolsize for the entire page. For such symbols, the size attribute of the Reference should be set to the absolute value zero. This means that no magnification is applied to the object, and it also stops setAttribute() from modifying the size. (The size can still be changed using setSize(), but this is not available from Lua.)

## Member Enumeration Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
EHasStroke |
EHasFill |
EHasPen |
EHasSize |
EIsMark |
EIsArrow |

## Constructor & Destructor Documentation

## ◆ Reference() [1/2]

Reference::Reference | ( | const AllAttributes & | attr,
|  | Attribute | name,
|  | Vector | pos
| ) |  |
| explicit

Create a reference to the named object in stylesheet.

Referenced by clone().

## ◆ Reference() [2/2]

Reference::Reference | ( | const XmlAttributes & | attr,
|  | String | data
| ) |  |
| explicit

Create from XML stream.

References ipe::Attribute::BLACK(), flagsFromName(), ipe::XmlAttributes::has(), ipe::Attribute::makeColor(), ipe::Attribute::makeScalar(), ipe::Attribute::NORMAL(), ipe::Attribute::ONE(), ipe::Attribute::WHITE(), ipe::Vector::x, ipe::Vector::y, and ipe::Vector::ZERO.

## Member Function Documentation

## ◆ clone()

Object * Reference::clone | ( |  | ) | const
| virtual

Clone object.

Implements ipe::Object.

References Reference().

## ◆ asReference()

Reference * Reference::asReference | ( |  | ) |
| virtual

Return pointer to this object.

Reimplemented from ipe::Object.

## ◆ type()

Object::Type Reference::type | ( |  | ) | const
| virtual

Implements ipe::Object.

References ipe::Object::EReference.

## ◆ accept()

void Reference::accept | ( | Visitor & | visitor | ) | const
| virtual

Call visitReference of visitor.

Implements ipe::Object.

References ipe::Visitor::visitReference().

## ◆ saveAsXml()

void Reference::saveAsXml | ( | Stream & | stream,
|  | String | layer
| ) |  | const
| virtual

Save in XML format.

Implements ipe::Object.

References ipe::Attribute::BLACK(), EHasFill, ipe::Attribute::isNormal(), ipe::Attribute::ONE(), ipe::Object::saveAttributesAsXml(), ipe::Attribute::string(), ipe::Attribute::WHITE(), and ipe::Vector::ZERO.

## ◆ draw()

void Reference::draw | ( | Painter & | painter | ) | const
| virtual

Draw reference.

If the symbolic attribute is not defined in the current style sheet, nothing is drawn at all.

Implements ipe::Object.

References ipe::Painter::cascade(), ipe::Painter::drawSymbol(), EHasFill, ipe::ESymbolSize, ipe::Cascade::find(), ipe::Cascade::findSymbol(), ipe::Symbol::iTransformations, ipe::Object::matrix(), ipe::Attribute::number(), ipe::Painter::pop(), ipe::Painter::popMatrix(), ipe::Painter::push(), ipe::Painter::pushMatrix(), ipe::Painter::setSymFill(), ipe::Painter::setSymPen(), ipe::Painter::setSymStroke(), ipe::Fixed::toDouble(), ipe::Painter::transform(), ipe::Object::transformations(), ipe::Painter::translate(), and ipe::Painter::untransform().

## ◆ drawSimple()

void Reference::drawSimple | ( | Painter & | painter | ) | const
| virtual

Draw simple version for selecting and transforming.

Implements ipe::Object.

References ipe::Painter::drawPath(), ipe::EStrokedOnly, ipe::ETransformationsTranslations, ipe::Painter::lineTo(), ipe::Object::matrix(), ipe::Painter::moveTo(), ipe::Painter::newPath(), ipe::Painter::popMatrix(), ipe::Painter::pushMatrix(), size(), ipe::Painter::transform(), ipe::Painter::translate(), and ipe::Painter::untransform().

## ◆ addToBBox()

void Reference::addToBBox | ( | Rect & | box,
|  | const Matrix & | m,
|  | bool | cp
| ) |  | const
| virtual

Extend box to include the object transformed by m.

For objects in a page, don't call this directly. The Page caches the bounding box of each object, so it is far more efficient to call Page::bbox.

Control points that lie outside the visual object are included if cp is true.

If called with an empty box and cp == `false`, the result of this function is a tight bounding box for the object, with a little leeway in case the boundary is determined by a spline (it has to be approximated to perform this operation).

This only adds the position to the box.

Implements ipe::Object.

References ipe::Rect::addPoint(), and ipe::Object::matrix().

## ◆ distance()

double Reference::distance | ( | const Vector & | v,
|  | const Matrix & | m,
|  | double | bound
| ) |  | const
| virtual

Return distance of transformed object to point v. If larger than bound, can just return bound.

Implements ipe::Object.

References ipe::Object::matrix().

## ◆ snapVtx()

void Reference::snapVtx | ( | const Vector & | mouse,
|  | const Matrix & | m,
|  | Vector & | pos,
|  | double & | bound
| ) |  | const
| virtual

Compute vertex snapping position for transformed object.

Looks only for positions closer than bound. If successful, modify pos and bound. The default implementation does nothing.

Reimplemented from ipe::Object.

References ipe::Object::matrix().

## ◆ snapBnd()

void Reference::snapBnd | ( | const Vector & | mouse,
|  | const Matrix & | m,
|  | Vector & | pos,
|  | double & | bound
| ) |  | const
| virtual

Compute boundary snapping position for transformed object.

Looks only for positions closer than bound. If successful, modify pos and bound. The default implementation does nothing.

Reimplemented from ipe::Object.

## ◆ checkStyle()

void Reference::checkStyle | ( | const Cascade * | sheet,
|  | AttributeSeq & | seq
| ) |  | const
| virtual

Check all symbolic attributes.

Reimplemented from ipe::Object.

References ipe::Object::checkSymbol(), ipe::EColor, EHasFill, ipe::EPen, ipe::ESymbolSize, and ipe::Cascade::findSymbol().

## ◆ setName()

void Reference::setName | ( | Attribute | name | ) |

Set name of symbol referenced.

References flagsFromName(), name(), and ipe::Attribute::string().

Referenced by setAttribute().

## ◆ name()

Attribute ipe::Reference::name | ( |  | ) | const
| inline

Return symbolic name.

References setStroke().

Referenced by flags(), getAttribute(), setAttribute(), and setName().

## ◆ setStroke()

void Reference::setStroke | ( | Attribute | color | ) |

Set stroke color.

Referenced by name(), and setAttribute().

## ◆ stroke()

Attribute ipe::Reference::stroke | ( |  | ) | const
| inline

Return stroke color.

References setFill().

Referenced by getAttribute(), and setAttribute().

## ◆ setFill()

void Reference::setFill | ( | Attribute | color | ) |

Set fill color.

Referenced by setAttribute(), and stroke().

## ◆ fill()

Attribute ipe::Reference::fill | ( |  | ) | const
| inline

Return fill color.

Referenced by getAttribute(), and setAttribute().

## ◆ pen()

Attribute ipe::Reference::pen | ( |  | ) | const
| inline

Return pen.

References setPen(), setSize(), and size().

Referenced by getAttribute(), setAttribute(), and setPen().

## ◆ setPen()

void Reference::setPen | ( | Attribute | pen | ) |

Set pen.

References pen().

Referenced by pen(), and setAttribute().

## ◆ setSize()

void Reference::setSize | ( | Attribute | size | ) |

Set size (magnification) of symbol.

References size().

Referenced by pen(), and setAttribute().

## ◆ size()

Attribute ipe::Reference::size | ( |  | ) | const
| inline

Return symbol size.

Referenced by drawSimple(), getAttribute(), pen(), setAttribute(), and setSize().

## ◆ position()

Vector ipe::Reference::position | ( |  | ) | const
| inline

Return position of symbol on page.

References getAttribute(), and setAttribute().

## ◆ setAttribute()

bool Reference::setAttribute | ( | Property | prop,
|  | Attribute | value
| ) |  |
| virtual

Set an attribute on this object.

Returns true if an attribute was actually changed.

Reimplemented from ipe::Object.

References EHasFill, EIsMark, ipe::EPropFillColor, ipe::EPropMarkShape, ipe::EPropPen, ipe::EPropStrokeColor, ipe::EPropSymbolSize, fill(), name(), pen(), ipe::Object::setAttribute(), setFill(), setName(), setPen(), setSize(), setStroke(), size(), and stroke().

Referenced by position().

## ◆ getAttribute()

Attribute Reference::getAttribute | ( | Property | prop | ) | const
| virtualnoexcept

Get setting of an attribute of this object.

If object does not have this attribute, returnes "undefined" attribute.

Reimplemented from ipe::Object.

References EHasFill, EIsMark, ipe::EPropFillColor, ipe::EPropMarkShape, ipe::EPropPen, ipe::EPropStrokeColor, ipe::EPropSymbolSize, fill(), ipe::Object::getAttribute(), name(), pen(), size(), and stroke().

Referenced by position().

## ◆ flags()

uint ipe::Reference::flags | ( |  | ) | const
| inline

References flagsFromName(), and name().

Referenced by flagsFromName().

## ◆ flagsFromName()

uint Reference::flagsFromName | ( | String | name | ) |
| static

References EHasFill, EIsArrow, EIsMark, ipe::String::find(), flags(), ipe::String::left(), ipe::String::rfind(), ipe::String::size(), and ipe::String::substr().

Referenced by flags(), ipe::ImlParser::parseStyle(), Reference(), and setName().

The documentation for this class was generated from the following files:

- ipereference.h
- ipereference.cpp