Ipelib: ipe::Page Class Reference

Ipelib

- Main Page
- Related Pages
- Modules
- Classes

- Class List
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Static Public Member Functions | List of all members
ipe::Page Class Reference
Ipe Document

`#include <ipepage.h>`

## Classes
struct | SLayer
struct | SObject
struct | SView

## Public Member Functions
| Page ()
void | saveAsXml (Stream &stream) const
void | saveAsIpePage (Stream &stream) const
void | saveSelection (Stream &stream) const
int | countLayers () const
String | layer (int index) const
bool | isLocked (int i) const
bool | hasSnapping (int i) const
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 ()
bool | visible (int view, int layer) const
bool | objectVisible (int view, int objno) const
void | setVisible (int view, String layer, bool vis)
Rect | textBox (const Cascade *sheet) const
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
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 | 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, Attribute stroke, Attribute fill)
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 | ( |  | ) |
| explicit

The default constructor creates a new empty page.

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

## Member Function Documentation

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

Create a new empty page with standard settings.

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

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

save page in XML format.

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

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

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

Copy selected objects as <ipeselection> into the stream.

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

Return number of layers.

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

Return name of layer index.

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

Is layer i locked?

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

Does layer i have active snapping?

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

Set locking of layer i.

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

Set snapping of layer i.

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

Moves the position of a layer in the layer list.

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

Find layer with given name.

Returns -1 if not found.

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

Add a new layer.

void Page::addLayer | ( |  | ) |

Add a new layer with unique name.

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.

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

Rename a layer.

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

Return number of views.

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

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

Return effect of view.

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

Set effect of view.

Panics if sym is not symbolic.

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

Return active layer of view.

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

Set active layer of view.

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

Return if view is marked.

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

Set if view is marked.

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

Insert a new view at index i.

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

Remove the view at index i.

void Page::clearViews | ( |  | ) |

Remove all views of this page.

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

Is layer visible in view?

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

Is object at index objno visible in view?

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

Set visibility of layer layer in view view.

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

Computes text box.

Takes into account frame size and text objects already on the page .

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

Return title of this page.

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

Set the title of this page.

An empty title is not displayed.

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

Return section title at level.

Level 0 is the section, level 1 the subsection.

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

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

Does this section title reflect the page title?

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.

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

Apply styling to title text object.

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

Return if page is marked for printing.

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

Set if page is marked for printing.

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

Return notes for this page.

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

Set the notes of this page.

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

Return number of objects on the page.

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

Return object at index i.

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

Return object at index i (const version).

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

Return selection status of object at index i.

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

Return layer of object at index i.

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

Set selection status of object at index i.

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

Set layer of object at index i.

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 and EPS 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.

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.

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.

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.

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.

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.

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.

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

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

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

Insert a new object at index i.

Takes ownership of the object.

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

Append a new object.

Takes ownership of the object.

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

Remove the object at index i.

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

Replace the object at index i.

Takes ownership of obj.

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

Set attribute prop of object at index i to value.

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

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

Return index of primary selection.

Returns -1 if there is no primary selection.

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

Returns true iff any object on the page is selected.

void Page::deselectAll | ( |  | ) |

Deselect all objects.

void Page::ensurePrimarySelection | ( |  | ) |

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

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

- ipepage.h
- ipepage.cpp