Ipelib
|
#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 AttributeMap & | viewMap (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< Matrix > | layerMatrices (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 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 () |
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.
|
strong |
|
explicit |
The default constructor creates a new empty page.
This page still needs a layer and a view to be usable!
Referenced by 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().
void Page::saveAsXml | ( | Stream & | stream | ) | const |
save page in XML format.
References active(), Always, ipe::AttributeMap::count(), countLayers(), countViews(), effect(), ipe::String::empty(), layer(), markedView(), Never, ipe::Stream::putXmlString(), ipe::AttributeMap::saveAsXml(), ipe::Attribute::string(), title(), viewMap(), viewName(), and visible().
Referenced by saveAsIpePage(), and ipe::Document::saveAsXml().
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().
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().
|
inlinenoexcept |
Return number of layers.
Referenced by findLayer(), insertView(), layerMatrices(), objectsPerLayer(), pageBBox(), ipe::ImlParser::parseObject(), ipe::ImlParser::parsePage(), removeView(), and saveAsXml().
|
inlinenoexcept |
Return name of layer index.
Referenced by append(), findLayer(), insert(), moveLayer(), pageBBox(), ipe::ImlParser::parseObject(), ipe::ImlParser::parsePage(), saveAsXml(), saveSelection(), setActive(), setLayerMatrix(), setLayerOf(), setVisible(), and visible().
|
inlinenoexcept |
Is layer i locked?
Referenced by ipe::SelectTool::mouseButton(), ipe::ImlParser::parsePage(), and ipe::SelectTool::SelectTool().
|
inlinenoexcept |
Does layer i have snapping?
|
noexcept |
Snapping occurs if the layer is visible and has snapping enabled.
Referenced by ipe::Snap::simpleSnap().
void Page::setLocked | ( | int | i, |
bool | flag | ||
) |
Set locking of layer i.
Referenced by ipe::ImlParser::parsePage().
void Page::setSnapping | ( | int | i, |
SnapMode | mode | ||
) |
Set snapping of layer i.
Referenced by ipe::ImlParser::parsePage().
void Page::moveLayer | ( | int | index, |
int | newIndex | ||
) |
Moves the position of a layer in the layer list.
References layer().
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::createBookmarks(), ipe::PdfWriter::createNamedDests(), ipe::PdfWriter::createPageView(), ipe::CanvasBase::drawObjects(), layerMatrices(), ipe::ImlParser::parseView(), removeLayer(), renameLayer(), ipe::Thumbnail::saveRender(), setActive(), and setVisible().
void Page::addLayer | ( | String | name | ) |
void Page::addLayer | ( | ) |
Add a new layer with unique name.
References findLayer().
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().
Rename a layer.
References findLayer().
void Page::setLayerData | ( | int | index, |
String | data | ||
) |
Set free data field of the layer.
Referenced by ipe::ImlParser::parsePage().
|
inline |
Return layer data.
|
inline |
Return number of views.
Referenced by addLayer(), countMarkedViews(), ipe::Document::countTotalViews(), ipe::PdfWriter::createPages(), ipe::PdfWriter::createTrailer(), findView(), pageBBox(), ipe::ImlParser::parsePage(), ipe::ImlParser::parseView(), ipe::Document::runLatexAsync(), and saveAsXml().
int Page::countMarkedViews | ( | ) | const |
References count(), countViews(), and markedView().
Referenced by ipe::PdfWriter::createTrailer().
|
inline |
Return effect of view.
Referenced by ipe::PdfWriter::createPageView(), and saveAsXml().
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().
|
inline |
Return active layer of view.
Referenced by insertView(), and saveAsXml().
void Page::setActive | ( | int | index, |
String | name | ||
) |
Set active layer of view.
References findLayer(), and layer().
Referenced by ipe::ImlParser::parsePage().
|
inlinenoexcept |
Return name of view.
Referenced by findView(), and saveAsXml().
|
inlinenoexcept |
Set name of view.
Referenced by ipe::ImlParser::parsePage().
|
inline |
Return if view is marked.
Referenced by countMarkedViews(), ipe::PdfWriter::createPages(), and saveAsXml().
void Page::setMarkedView | ( | int | index, |
bool | marked | ||
) |
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().
void Page::removeView | ( | int | i | ) |
Remove the view at index i.
References countLayers().
void Page::clearViews | ( | ) |
Remove all views of this page.
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().
|
inline |
Referenced by ipe::CanvasBase::drawObjects(), ipe::Thumbnail::render(), saveAsXml(), and ipe::Thumbnail::saveRender().
void Page::setViewMap | ( | int | index, |
const AttributeMap & | map | ||
) |
Set the attribute mapping for the view.
Referenced by ipe::ImlParser::parsePage().
|
inline |
Is layer visible in view?
References layer().
Referenced by ipe::PdfWriter::createPageView(), pageBBox(), and saveAsXml().
|
inline |
Is object at index objno visible in view?
References layerOf().
Referenced by ipe::PdfWriter::createPageView(), ipe::PanTool::draw(), ipe::CanvasBase::drawObjects(), ipe::CanvasBase::drawTool(), ipe::SelectTool::mouseButton(), ipe::Thumbnail::render(), ipe::Thumbnail::saveRender(), ipe::SelectTool::SelectTool(), and viewBBox().
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().
|
inline |
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().
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().
String Page::title | ( | ) | const |
Return title of this page.
Referenced by applyTitleStyle(), saveAsXml(), section(), setTitle(), and titleText().
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().
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().
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().
|
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.
References title().
Referenced by ipe::CanvasBase::drawObjects(), ipe::Thumbnail::saveRender(), and ipe::Latex::scanPage().
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().
|
inline |
Return if page is marked for printing.
Referenced by ipe::PdfWriter::createBookmarks(), ipe::PdfWriter::createNamedDests(), ipe::PdfWriter::createPages(), ipe::PdfWriter::createTrailer(), setMarked(), and setMarkedView().
void Page::setMarked | ( | bool | marked | ) |
|
inline |
Return notes for this page.
Referenced by ipe::PdfWriter::createPageView(), and setNotes().
void Page::setNotes | ( | String | notes | ) |
|
inline |
Return number of objects on the page.
Referenced by ipe::Document::checkStyle(), countMarkedViews(), ipe::PdfWriter::createPageView(), deselectAll(), ipe::PanTool::draw(), ipe::TransformTool::draw(), ipe::CanvasBase::drawObjects(), ipe::CanvasBase::drawTool(), 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(), and viewBBox().
void Page::objectsPerLayer | ( | std::vector< int > & | objcounts | ) | const |
Return number of objects in each layer.
References countLayers().
|
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::CanvasBase::drawObjects(), ipe::CanvasBase::drawTool(), ipe::SelectTool::mouseButton(), ipe::Thumbnail::render(), ipe::Thumbnail::saveRender(), ipe::BitmapFinder::scanPage(), ipe::Latex::scanPage(), setAttribute(), snapBnd(), snapCtl(), snapVtx(), transform(), and ipe::TransformTool::TransformTool().
|
inline |
Return object at index i (const version).
|
inline |
Return selection status of object at index i.
Referenced by append(), ipe::TransformTool::draw(), ipe::CanvasBase::drawTool(), ensurePrimarySelection(), hasSelection(), insert(), ipe::SelectTool::mouseButton(), primarySelection(), saveSelection(), and ipe::TransformTool::TransformTool().
|
inline |
Return layer of object at index i.
Referenced by ipe::CanvasBase::drawObjects(), ipe::SelectTool::mouseButton(), objectVisible(), pageBBox(), ipe::Thumbnail::render(), ipe::Thumbnail::saveRender(), saveSelection(), and ipe::SelectTool::SelectTool().
|
inline |
Set selection status of object at index i.
Referenced by deselectAll(), ensurePrimarySelection(), and ipe::SelectTool::mouseButton().
|
inline |
Set layer of object at index i.
References layer().
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().
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().
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().
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().
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().
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().
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().
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().
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 a new object at index i.
Takes ownership of the object.
References layer(), and select().
Referenced by ipe::ImlParser::parsePage().
void Page::remove | ( | int | i | ) |
Remove the object at index i.
void Page::replace | ( | int | i, |
Object * | obj | ||
) |
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().
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().
bool Page::hasSelection | ( | ) | const |
Returns true iff any object on the page is selected.
References count(), and select().
Referenced by ipe::SelectTool::mouseButton().
void Page::deselectAll | ( | ) |
Deselect all objects.
References count(), ipe::ENotSelected, and setSelect().
Referenced by ipe::SelectTool::mouseButton().
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().