ipe::Page Class Reference
Ipe Document

`#include <ipepage.h>`

## Public Member Functions

| Page ()
void | saveAsXml (Stream &stream) const
void | saveAsIpePage (Stream &stream) const
void | saveSelection (Stream &stream) const
int | countLayers () const noexcept
String | layer (int index) const noexcept
bool | isLocked (int i) const noexcept
bool | hasSnapping (int i) const noexcept
bool | objSnapsInView (int objNo, int view) const noexcept
void | setLocked (int i, bool flag)
void | setSnapping (int i, bool flag)
void | moveLayer (int index, int newIndex)
int | findLayer (String name) const
void | addLayer (String name)
void | addLayer ()
void | removeLayer (String name)
void | renameLayer (String oldName, String newName)
int | countViews () const
int | countMarkedViews () const
Attribute | effect (int index) const
void | setEffect (int index, Attribute sym)
String | active (int index) const
void | setActive (int index, String name)
bool | markedView (int index) const
void | setMarkedView (int index, bool marked)
void | insertView (int i, String active)
void | removeView (int i)
void | clearViews ()
int | findView (String viewNumberOrName) const
bool | visible (int view, int layer) const
bool | objectVisible (int view, int objno) const
void | setVisible (int view, String layer, bool vis)
String | title () const
void | setTitle (String title)
String | section (int level) const
void | setSection (int level, bool useTitle, String name)
bool | sectionUsesTitle (int level) const
const Text * | titleText () const
void | applyTitleStyle (const Cascade *sheet)
bool | marked () const
void | setMarked (bool marked)
String | notes () const
void | setNotes (String notes)
int | count () const
void | objectsPerLayer (std::vector< int > &objcounts) const
Object * | object (int i)
const Object * | object (int i) const
TSelect | select (int i) const
int | layerOf (int i) const
void | setSelect (int i, TSelect sel)
void | setLayerOf (int i, int layer)
Rect | pageBBox (const Cascade *sheet) const
Rect | viewBBox (const Cascade *sheet, int view) const
Rect | bbox (int i) const
void | transform (int i, const Matrix &m)
double | distance (int i, const Vector &v, double bound) const
void | snapVtx (int i, const Vector &mouse, Vector &pos, double &bound) const
void | snapCtl (int i, const Vector &mouse, Vector &pos, double &bound) const
void | snapBnd (int i, const Vector &mouse, Vector &pos, double &bound) const
void | invalidateBBox (int i) const
void | insert (int i, TSelect sel, int layer, Object *obj)
void | append (TSelect sel, int layer, Object *obj)
void | remove (int i)
void | replace (int i, Object *obj)
bool | setAttribute (int i, Property prop, Attribute value)
int | primarySelection () const
bool | hasSelection () const
void | deselectAll ()
void | ensurePrimarySelection ()

## Static Public Member Functions

static Page * | basic ()

## Detailed Description

An Ipe document page.

Its main ingredients are a sequence of Objects (with selection state, layer, and a cached bounding box), a set of Layers, and a sequence of Views.

Each object on a Page belongs to one of the layers of the page. Layers are orthogonal to the back-to-front ordering of objects (in particular, they are not "layered" - the word is a misnomer). The "layer" is really just another attribute of the object.

- Layers are either editable or locked. Objects in a locked layer cannot be selected, and a locked layer cannot be made active in the UI. This more or less means that the contents of such a layer cannot be modified—but that's a consequence of the UI, Ipelib contains no special handling of locked layers.
- A layer may have snapping on or off—objects will behave magnetically only if their layer has snapping on.

A Page is presented in a number of views. Each view presents some of the layers of the page. In addition, each view has an active layer (where objects are added when this view is shown in the UI), and possibly a transition effect (Acrobat Reader eye candy).

A Page can be copied and assigned. The operation takes time linear in the number of top-level object on the page.

## Constructor & Destructor Documentation

## Page()

Page::Page | ( |  | ) |

explicit

The default constructor creates a new empty page.

This page still needs a layer and a view to be usable!

Referenced by basic().

## Member Function Documentation

## basic()

Page * Page::basic | ( |  | ) |

static

Create a new empty page with standard settings.

This is an empty page with layer 'alpha' and a single view.

References addLayer(), insertView(), Page(), and setVisible().

## saveAsXml()

void Page::saveAsXml | ( | Stream & | stream | ) | const

save page in XML format.

References active(), countLayers(), countViews(), effect(), ipe::String::empty(), layer(), markedView(), ipe::Stream::putXmlString(), ipe::Attribute::string(), title(), and visible().

Referenced by saveAsIpePage(), and ipe::Document::saveAsXml().

## saveAsIpePage()

void Page::saveAsIpePage | ( | Stream & | stream | ) | const

Copy whole page with bitmaps as <ipepage> into the stream.

References ipe::BitmapFinder::iBitmaps, saveAsXml(), ipe::Bitmap::saveAsXml(), ipe::BitmapFinder::scanPage(), and ipe::Bitmap::setObjNum().

## saveSelection()

void Page::saveSelection | ( | Stream & | stream | ) | const

Copy selected objects as <ipeselection> into the stream.

References count(), ipe::BitmapFinder::iBitmaps, ipe::Bitmap::saveAsXml(), select(), and ipe::Bitmap::setObjNum().

## countLayers()

int ipe::Page::countLayers | ( |  | ) | const

inline noexcept

Return number of layers.

Referenced by findLayer(), insertView(), objectsPerLayer(), pageBBox(), ipe::ImlParser::parseObject(), ipe::ImlParser::parsePage(), removeView(), and saveAsXml().

## layer()

String ipe::Page::layer | ( | int | index | ) | const

inline noexcept

Return name of layer index.

Referenced by append(), findLayer(), insert(), moveLayer(), objectVisible(), objSnapsInView(), pageBBox(), ipe::ImlParser::parseObject(), ipe::ImlParser::parsePage(), saveAsXml(), setActive(), setLayerOf(), and visible().

## isLocked()

bool ipe::Page::isLocked | ( | int | i | ) | const

inline noexcept

Is layer i locked?

Referenced by ipe::SelectTool::mouseButton(), ipe::ImlParser::parsePage(), and ipe::SelectTool::SelectTool().

## hasSnapping()

bool ipe::Page::hasSnapping | ( | int | i | ) | const

inline noexcept

Does layer i have active snapping?

References addLayer(), findLayer(), moveLayer(), objSnapsInView(), removeLayer(), renameLayer(), setLocked(), and setSnapping().

Referenced by objSnapsInView().

## objSnapsInView()

bool Page::objSnapsInView | ( | int | objNo,
|  | int | view
| ) |  | const

noexcept

Snapping occurs if the layer is visible and has snapping enabled.

References hasSnapping(), layer(), layerOf(), and visible().

Referenced by hasSnapping(), and ipe::Snap::simpleSnap().

## setLocked()

void Page::setLocked | ( | int | i,
|  | bool | flag
| ) |  |

Set locking of layer i.

Referenced by hasSnapping(), and ipe::ImlParser::parsePage().

## setSnapping()

void Page::setSnapping | ( | int | i,
|  | bool | flag
| ) |  |

Set snapping of layer i.

Referenced by hasSnapping().

## moveLayer()

void Page::moveLayer | ( | int | index,
|  | int | newIndex
| ) |  |

Moves the position of a layer in the layer list.

References layer().

Referenced by hasSnapping().

## findLayer()

int Page::findLayer | ( | String | name | ) | const

Find layer with given name.

Returns -1 if not found.

References countLayers(), and layer().

Referenced by addLayer(), ipe::PdfWriter::createPageView(), hasSnapping(), removeLayer(), renameLayer(), ipe::Thumbnail::saveRender(), setActive(), setVisible(), and ipe::PdfWriter::~PdfWriter().

## addLayer() [1/2]

void Page::addLayer | ( | String | name | ) |

Add a new layer.

References countViews().

Referenced by basic(), and ipe::ImlParser::parsePage().

## addLayer() [2/2]

void Page::addLayer | ( |  | ) |

Add a new layer with unique name.

References findLayer().

Referenced by hasSnapping().

## removeLayer()

void Page::removeLayer | ( | String | name | ) |

Removes an empty layer from the page.

All objects are adjusted. Panics if there are objects in the deleted layer, of if it is the only layer.

References findLayer().

Referenced by hasSnapping().

## renameLayer()

void Page::renameLayer | ( | String | oldName,
|  | String | newName
| ) |  |

Rename a layer.

References findLayer().

Referenced by hasSnapping().

## countViews()

int ipe::Page::countViews | ( |  | ) | const

inline

Return number of views.

References countMarkedViews().

Referenced by addLayer(), countMarkedViews(), ipe::Document::countTotalViews(), ipe::PageSelector::fill(), findView(), pageBBox(), ipe::ImlParser::parsePage(), ipe::Document::runLatex(), and saveAsXml().

## countMarkedViews()

int Page::countMarkedViews | ( |  | ) | const

References count(), countViews(), and markedView().

Referenced by countViews().

## effect()

Attribute ipe::Page::effect | ( | int | index | ) | const

inline

Return effect of view.

References setEffect().

Referenced by ipe::PdfWriter::createPageView(), and saveAsXml().

## setEffect()

void Page::setEffect | ( | int | index,
|  | Attribute | sym
| ) |  |

Set effect of view.

Panics if sym is not symbolic.

References ipe::Attribute::isSymbolic().

Referenced by effect(), and ipe::ImlParser::parsePage().

## active()

String ipe::Page::active | ( | int | index | ) | const

inline

Return active layer of view.

References setActive().

Referenced by insertView(), markedView(), and saveAsXml().

## setActive()

void Page::setActive | ( | int | index,
|  | String | name
| ) |  |

Set active layer of view.

References findLayer(), and layer().

Referenced by active(), and ipe::ImlParser::parsePage().

## markedView()

bool ipe::Page::markedView | ( | int | index | ) | const

inline

Return if view is marked.

References active(), clearViews(), findView(), insertView(), marked(), removeView(), and setMarkedView().

Referenced by countMarkedViews(), and saveAsXml().

## setMarkedView()

void Page::setMarkedView | ( | int | index,
|  | bool | marked
| ) |  |

Set if view is marked.

References marked().

Referenced by markedView(), and ipe::ImlParser::parsePage().

## insertView()

void Page::insertView | ( | int | i,
|  | String | active
| ) |  |

Insert a new view at index i.

References active(), and countLayers().

Referenced by basic(), markedView(), and ipe::ImlParser::parsePage().

## removeView()

void Page::removeView | ( | int | i | ) |

Remove the view at index i.

References countLayers().

Referenced by markedView().

## clearViews()

void Page::clearViews | ( |  | ) |

Remove all views of this page.

Referenced by markedView().

## findView()

int Page::findView | ( | String | s | ) | const

Return index of view with given number or name.

Input numbers are one-based. Returns -1 if no such view exists. View names are not yet implemented!!!

References countViews(), ipe::String::empty(), ipe::ENotSelected, and ipe::Lex::getInt().

Referenced by markedView().

## visible()

bool ipe::Page::visible | ( | int | view,
|  | int | layer
| ) |  | const

inline

Is layer visible in view?

References layer().

Referenced by ipe::PdfWriter::createPageView(), objSnapsInView(), pageBBox(), and saveAsXml().

## objectVisible()

bool ipe::Page::objectVisible | ( | int | view,
|  | int | objno
| ) |  | const

inline

Is object at index objno visible in view?

References layer(), layerOf(), section(), setSection(), setTitle(), setVisible(), and title().

Referenced by ipe::PdfWriter::createPageView(), ipe::PanTool::draw(), ipe::SelectTool::mouseButton(), ipe::Thumbnail::render(), ipe::Thumbnail::saveRender(), ipe::SelectTool::SelectTool(), viewBBox(), and ipe::PdfWriter::~PdfWriter().

## setVisible()

void Page::setVisible | ( | int | view,
|  | String | layer,
|  | bool | vis
| ) |  |

Set visibility of layer layer in view view.

References findLayer().

Referenced by basic(), objectVisible(), and ipe::ImlParser::parsePage().

## title()

String Page::title | ( |  | ) | const

Return title of this page.

Referenced by applyTitleStyle(), ipe::PageSelector::fill(), objectVisible(), saveAsXml(), section(), setTitle(), and titleText().

## setTitle()

void Page::setTitle | ( | String | title | ) |

Set the title of this page.

An empty title is not displayed.

References ipe::Text::setText(), and title().

Referenced by objectVisible(), and ipe::ImlParser::parsePage().

## section()

String Page::section | ( | int | level | ) | const

Return section title at level.

Level 0 is the section, level 1 the subsection.

References title().

Referenced by ipe::Document::findPage(), and objectVisible().

## setSection()

void Page::setSection | ( | int | level,
|  | bool | useTitle,
|  | String | name
| ) |  |

Set the section title at level.

Level 0 is the section, level 1 the subsection.

If useTitle is `true`, then name is ignored, and the section title will be copied from the page title (and further changes to the page title are automatically reflected).

Referenced by objectVisible(), and ipe::ImlParser::parsePage().

## sectionUsesTitle()

bool ipe::Page::sectionUsesTitle | ( | int | level | ) | const

inline

Does this section title reflect the page title?

References applyTitleStyle(), and titleText().

## titleText()

const Text * Page::titleText | ( |  | ) | const

Return Text object representing the title text.

Return 0 if no title is set. Ownership of object remains with Page.

References title().

Referenced by ipe::Latex::scanPage(), sectionUsesTitle(), and ipe::PdfWriter::~PdfWriter().

## applyTitleStyle()

void Page::applyTitleStyle | ( | const Cascade * | sheet | ) |

Apply styling to title text object.

References ipe::Cascade::findTitleStyle(), ipe::StyleSheet::TitleStyle::iColor, ipe::StyleSheet::TitleStyle::iHorizontalAlignment, ipe::StyleSheet::TitleStyle::iPos, ipe::StyleSheet::TitleStyle::iSize, ipe::StyleSheet::TitleStyle::iVerticalAlignment, ipe::Text::setHorizontalAlignment(), ipe::Object::setMatrix(), ipe::Text::setSize(), ipe::Text::setStroke(), ipe::Text::setVerticalAlignment(), and title().

Referenced by ipe::Latex::scanPage(), and sectionUsesTitle().

## marked()

bool ipe::Page::marked | ( |  | ) | const

inline

Return if page is marked for printing.

References setMarked().

Referenced by markedView(), setMarked(), and setMarkedView().

## setMarked()

void Page::setMarked | ( | bool | marked | ) |

Set if page is marked for printing.

References marked().

Referenced by marked(), and ipe::ImlParser::parsePage().

## notes()

String ipe::Page::notes | ( |  | ) | const

inline

Return notes for this page.

References setNotes().

Referenced by ipe::PdfWriter::createPageView(), and setNotes().

## setNotes()

void Page::setNotes | ( | String | notes | ) |

Set the notes of this page.

References notes().

Referenced by notes(), and ipe::ImlParser::parsePage().

## count()

int ipe::Page::count | ( |  | ) | const

inline

Return number of objects on the page.

References objectsPerLayer().

Referenced by ipe::Document::checkStyle(), countMarkedViews(), ipe::PdfWriter::createPageView(), deselectAll(), ipe::PanTool::draw(), ipe::TransformTool::draw(), ensurePrimarySelection(), hasSelection(), ipe::SelectTool::mouseButton(), pageBBox(), ipe::ImlParser::parsePage(), primarySelection(), ipe::Thumbnail::render(), ipe::Thumbnail::saveRender(), saveSelection(), ipe::BitmapFinder::scanPage(), ipe::Latex::scanPage(), ipe::SelectTool::SelectTool(), ipe::Snap::simpleSnap(), ipe::TransformTool::TransformTool(), viewBBox(), and ipe::PdfWriter::~PdfWriter().

## objectsPerLayer()

void Page::objectsPerLayer | ( | std::vector< int > & | objcounts | ) | const

Return number of objects in each layer.

References countLayers().

Referenced by count().

## object() [1/2]

Object* ipe::Page::object | ( | int | i | ) |

inline

Return object at index i.

Referenced by ipe::Document::checkStyle(), ipe::PdfWriter::createPageView(), distance(), ipe::PanTool::draw(), ipe::SelectTool::draw(), ipe::TransformTool::draw(), ipe::SelectTool::mouseButton(), ipe::Thumbnail::render(), ipe::Thumbnail::saveRender(), ipe::BitmapFinder::scanPage(), ipe::Latex::scanPage(), setAttribute(), snapBnd(), snapCtl(), snapVtx(), transform(), ipe::TransformTool::TransformTool(), and ipe::PdfWriter::~PdfWriter().

## object() [2/2]

const Object* ipe::Page::object | ( | int | i | ) | const

inline

Return object at index i (const version).

## select()

TSelect ipe::Page::select | ( | int | i | ) | const

inline

Return selection status of object at index i.

Referenced by append(), ipe::TransformTool::draw(), ensurePrimarySelection(), hasSelection(), insert(), ipe::SelectTool::mouseButton(), primarySelection(), saveSelection(), and ipe::TransformTool::TransformTool().

## layerOf()

int ipe::Page::layerOf | ( | int | i | ) | const

inline

Return layer of object at index i.

Referenced by ipe::SelectTool::mouseButton(), objectVisible(), objSnapsInView(), pageBBox(), and ipe::SelectTool::SelectTool().

## setSelect()

void ipe::Page::setSelect | ( | int | i,
|  | TSelect | sel
| ) |  |

inline

Set selection status of object at index i.

Referenced by deselectAll(), ensurePrimarySelection(), and ipe::SelectTool::mouseButton().

## setLayerOf()

void ipe::Page::setLayerOf | ( | int | i,
|  | int | layer
| ) |  |

inline

Set layer of object at index i.

References append(), bbox(), deselectAll(), distance(), ensurePrimarySelection(), hasSelection(), insert(), invalidateBBox(), layer(), ipe::Attribute::NORMAL(), pageBBox(), primarySelection(), replace(), setAttribute(), snapBnd(), snapCtl(), snapVtx(), transform(), and viewBBox().

## pageBBox()

Rect Page::pageBBox | ( | const Cascade * | sheet | ) | const

Returns a precise bounding box for the artwork on the page.

This is meant to be used as the bounding box in PDF output. It is computed by rendering all objects on the page that are visible in at least one view, plus all objects in a layer named "BBOX" (even if that is not visible), using a BBoxPainter.

References ipe::BBoxPainter::bbox(), count(), countLayers(), countViews(), layer(), layerOf(), and visible().

Referenced by ipe::PdfWriter::createPageView(), ipe::Thumbnail::saveRender(), and setLayerOf().

## viewBBox()

Rect Page::viewBBox | ( | const Cascade * | sheet,
|  | int | view
| ) |  | const

Returns a precise bounding box for the artwork in the view.

This is meant to be used as the bounding box in PDF and EPS output. It is computed by rendering all objects in the page using a BBoxPainter.

References ipe::BBoxPainter::bbox(), count(), and objectVisible().

Referenced by ipe::PdfWriter::createPageView(), and setLayerOf().

## bbox()

Rect Page::bbox | ( | int | i | ) | const

Return a bounding box for the object at index i.

This is a bounding box including the control points of the object. If you need a tight bounding box, you'll need to use the Object directly.

The Page caches the box the first time it is computed.

Make sure you call Page::transform instead of Object::setMatrix, as the latter would not invalidate the bounding box.

Referenced by ipe::PdfWriter::createPageView(), distance(), setLayerOf(), snapBnd(), snapCtl(), snapVtx(), and ipe::TransformTool::TransformTool().

## transform()

void Page::transform | ( | int | i,
|  | const Matrix & | m
| ) |  |

Transform the object at index i.

Use this function instead of calling Object::setMatrix directly, as the latter doesn't invalidate the cached bounding box.

References invalidateBBox(), object(), and ipe::Object::setMatrix().

Referenced by setLayerOf().

## distance()

double Page::distance | ( | int | i,
|  | const Vector & | v,
|  | double | bound
| ) |  | const

Return distance between object at index i and v.

But may just return bound if the distance is larger. This function uses the cached bounded box, and is faster than calling Object::distance directly.

References bbox(), ipe::Object::distance(), and object().

Referenced by ipe::SelectTool::SelectTool(), and setLayerOf().

## snapVtx()

void Page::snapVtx | ( | int | i,
|  | const Vector & | mouse,
|  | Vector & | pos,
|  | double & | bound
| ) |  | const

Compute possible vertex snapping position for object at index i.

Looks only for positions closer than bound. If successful, modifies pos and bound.

References bbox(), object(), and ipe::Object::snapVtx().

Referenced by setLayerOf(), and ipe::Snap::simpleSnap().

## snapCtl()

void Page::snapCtl | ( | int | i,
|  | const Vector & | mouse,
|  | Vector & | pos,
|  | double & | bound
| ) |  | const

Compute possible control point snapping position for object at index i.

Looks only for positions closer than bound. If successful, modifies pos and bound.

References bbox(), object(), and ipe::Object::snapCtl().

Referenced by setLayerOf(), and ipe::Snap::simpleSnap().

## snapBnd()

void Page::snapBnd | ( | int | i,
|  | const Vector & | mouse,
|  | Vector & | pos,
|  | double & | bound
| ) |  | const

Compute possible boundary snapping position for object at index i.

Looks only for positions closer than bound. If successful, modifies pos and bound.

References bbox(), object(), and ipe::Object::snapBnd().

Referenced by setLayerOf(), and ipe::Snap::simpleSnap().

## invalidateBBox()

void Page::invalidateBBox | ( | int | i | ) | const

Invalidate the bounding box at index i (the object is somehow changed).

Referenced by replace(), ipe::Latex::scanPage(), setAttribute(), setLayerOf(), and transform().

## insert()

void Page::insert | ( | int | i,
|  | TSelect | select,
|  | int | layer,
|  | Object * | obj
| ) |  |

Insert a new object at index i.

Takes ownership of the object.

References layer(), and select().

Referenced by ipe::ImlParser::parsePage(), and setLayerOf().

## append()

void Page::append | ( | TSelect | select,
|  | int | layer,
|  | Object * | obj
| ) |  |

Append a new object.

Takes ownership of the object.

References layer(), and select().

Referenced by setLayerOf().

## remove()

void Page::remove | ( | int | i | ) |

Remove the object at index i.

## replace()

void Page::replace | ( | int | i,
|  | Object * | obj
| ) |  |

Replace the object at index i.

Takes ownership of obj.

References invalidateBBox().

Referenced by setLayerOf().

## setAttribute()

bool Page::setAttribute | ( | int | i,
|  | Property | prop,
|  | Attribute | value
| ) |  |

Set attribute prop of object at index i to value.

This method automatically invalidates the bounding box if a ETextSize property is actually changed.

References ipe::EPropTextSize, ipe::EPropTransformations, invalidateBBox(), object(), and ipe::Object::setAttribute().

Referenced by setLayerOf().

## primarySelection()

int Page::primarySelection | ( |  | ) | const

Return index of primary selection.

Returns -1 if there is no primary selection.

References count(), ipe::EPrimarySelected, and select().

Referenced by ipe::SelectTool::mouseButton(), and setLayerOf().

## hasSelection()

bool Page::hasSelection | ( |  | ) | const

Returns true iff any object on the page is selected.

References count(), and select().

Referenced by ipe::SelectTool::mouseButton(), and setLayerOf().

## deselectAll()

void Page::deselectAll | ( |  | ) |

Deselect all objects.

References count(), ipe::ENotSelected, and setSelect().

Referenced by ipe::SelectTool::mouseButton(), and setLayerOf().

## ensurePrimarySelection()

void Page::ensurePrimarySelection | ( |  | ) |

If no object is the primary selection, make the topmost secondary selection the primary one.

References count(), ipe::EPrimarySelected, ipe::ESecondarySelected, select(), and setSelect().

Referenced by ipe::SelectTool::mouseButton(), and setLayerOf().

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

- ipepage.h
- ipepage.cpp