Ipelib
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
ipe::Page Class Reference

#include <ipepage.h>

Public Types

enum class  SnapMode { Never , Visible , Always }
 

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
 
SnapMode snapping (int i) const noexcept
 
bool objSnapsInView (int objNo, int view) const noexcept
 
void setLocked (int i, bool flag)
 
void setSnapping (int i, SnapMode mode)
 
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)
 
void setLayerData (int index, String data)
 
String layerData (int index) const
 
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)
 
String viewName (int index) const noexcept
 
void setViewName (int index, String name) noexcept
 
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
 
const AttributeMapviewMap (int index) const
 
void setViewMap (int index, const AttributeMap &map)
 
bool visible (int view, int layer) const
 
bool objectVisible (int view, int objno) const
 
std::vector< MatrixlayerMatrices (int view) const
 
void clearLayerMatrices (int view)
 
void setLayerMatrix (int view, int layer, const Matrix &m)
 
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 TexttitleText () 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
 
Objectobject (int i)
 
const Objectobject (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 Pagebasic ()
 

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.

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.

Member Enumeration Documentation

◆ SnapMode

enum ipe::Page::SnapMode
strong
Enumerator
Never 
Visible 
Always 

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

◆ 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, layer(), layerOf(), ipe::Bitmap::saveAsXml(), select(), and ipe::Bitmap::setObjNum().

◆ countLayers()

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

◆ layer()

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

◆ isLocked()

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

◆ snapping()

SnapMode ipe::Page::snapping ( int  i) const
inlinenoexcept

Does layer i have snapping?

◆ objSnapsInView()

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

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

Referenced by ipe::Snap::simpleSnap().

◆ setLocked()

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

Set locking of layer i.

Referenced by ipe::ImlParser::parsePage().

◆ setSnapping()

void Page::setSnapping ( int  i,
SnapMode  mode 
)

Set snapping of layer i.

Referenced by ipe::ImlParser::parsePage().

◆ moveLayer()

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

Moves the position of a layer in the layer list.

References layer().

◆ findLayer()

int Page::findLayer ( String  name) const

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

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

◆ renameLayer()

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

Rename a layer.

References findLayer().

◆ setLayerData()

void Page::setLayerData ( int  index,
String  data 
)

Set free data field of the layer.

Referenced by ipe::ImlParser::parsePage().

◆ layerData()

String ipe::Page::layerData ( int  index) const
inline

Return layer data.

◆ countViews()

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

◆ countMarkedViews()

int Page::countMarkedViews ( ) const

◆ effect()

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

Return effect of view.

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 ipe::ImlParser::parsePage().

◆ active()

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

Return active layer of view.

Referenced by insertView(), and saveAsXml().

◆ setActive()

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

Set active layer of view.

References findLayer(), and layer().

Referenced by ipe::ImlParser::parsePage().

◆ viewName()

String ipe::Page::viewName ( int  index) const
inlinenoexcept

Return name of view.

Referenced by findView(), and saveAsXml().

◆ setViewName()

void ipe::Page::setViewName ( int  index,
String  name 
)
inlinenoexcept

Set name of view.

Referenced by ipe::ImlParser::parsePage().

◆ markedView()

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

Return if view is marked.

Referenced by countMarkedViews(), ipe::PdfWriter::createPages(), and saveAsXml().

◆ setMarkedView()

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

Set if view is marked.

References marked().

Referenced by 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(), and ipe::ImlParser::parsePage().

◆ removeView()

void Page::removeView ( int  i)

Remove the view at index i.

References countLayers().

◆ clearViews()

void Page::clearViews ( )

Remove all views of this page.

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

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

◆ viewMap()

const AttributeMap& ipe::Page::viewMap ( int  index) const
inline

◆ setViewMap()

void Page::setViewMap ( int  index,
const AttributeMap map 
)

Set the attribute mapping for the view.

Referenced by ipe::ImlParser::parsePage().

◆ visible()

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

Is layer visible in view?

References layer().

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

◆ objectVisible()

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

◆ layerMatrices()

std::vector< Matrix > Page::layerMatrices ( int  view) const

Return matrices for all layers.

References countLayers(), findLayer(), and ipe::size().

Referenced by ipe::CanvasBase::drawObjects(), ipe::Thumbnail::render(), and ipe::Thumbnail::saveRender().

◆ clearLayerMatrices()

void ipe::Page::clearLayerMatrices ( int  view)
inline

◆ setLayerMatrix()

void Page::setLayerMatrix ( int  view,
int  layer,
const Matrix m 
)

Set matrix for the given layer in this view.

References ipe::Matrix::isIdentity(), and layer().

Referenced by ipe::ImlParser::parseView().

◆ setVisible()

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

Set visibility of layer layer in view view.

References findLayer(), and layer().

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

◆ title()

String Page::title ( ) const

Return title of this page.

Referenced by applyTitleStyle(), 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 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::PdfWriter::createBookmarks(), ipe::PdfWriter::createNamedDests(), and ipe::Document::findPage().

◆ 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 ipe::ImlParser::parsePage().

◆ sectionUsesTitle()

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

Does this section title reflect the page title?

◆ 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::CanvasBase::drawObjects(), ipe::Thumbnail::saveRender(), and ipe::Latex::scanPage().

◆ applyTitleStyle()

void Page::applyTitleStyle ( const Cascade sheet)

◆ marked()

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

◆ setMarked()

void Page::setMarked ( bool  marked)

Set if page is marked for printing.

References marked().

Referenced by ipe::ImlParser::parsePage().

◆ notes()

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

Return notes for this page.

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

◆ setNotes()

void Page::setNotes ( String  notes)

Set the notes of this page.

References notes().

Referenced by ipe::ImlParser::parsePage().

◆ count()

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

◆ objectsPerLayer()

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

Return number of objects in each layer.

References countLayers().

◆ object() [1/2]

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

◆ 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

◆ layerOf()

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

◆ 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 layer().

◆ 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(), and ipe::Thumbnail::saveRender().

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

◆ 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(), 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().

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

◆ 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 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 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 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(), 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().

◆ append()

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

Append a new object.

Takes ownership of the object.

References layer(), and select().

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

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

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

◆ hasSelection()

bool Page::hasSelection ( ) const

Returns true iff any object on the page is selected.

References count(), and select().

Referenced by ipe::SelectTool::mouseButton().

◆ deselectAll()

void Page::deselectAll ( )

Deselect all objects.

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

Referenced by ipe::SelectTool::mouseButton().

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


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