Ipelib
|
#include <ipepage.h>
Public Types | |
enum | SnapMode { SnapMode::Never, SnapMode::Visible, SnapMode::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(), Visible, 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(), clearLayerMatrices(), findLayer(), insert(), moveLayer(), objSnapsInView(), pageBBox(), ipe::ImlParser::parseObject(), ipe::ImlParser::parsePage(), saveAsXml(), saveSelection(), setActive(), setLayerMatrix(), setLayerOf(), 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?
References addLayer(), findLayer(), moveLayer(), objSnapsInView(), removeLayer(), renameLayer(), setLayerData(), setLocked(), and setSnapping().
Referenced by objSnapsInView().
|
noexcept |
Snapping occurs if the layer is visible and has snapping enabled.
References Always, layer(), layerOf(), Never, snapping(), Visible, and visible().
Referenced by ipe::Snap::simpleSnap(), and snapping().
void Page::setLocked | ( | int | i, |
bool | flag | ||
) |
Set locking of layer i.
Referenced by ipe::ImlParser::parsePage(), and snapping().
void Page::setSnapping | ( | int | i, |
SnapMode | mode | ||
) |
Set snapping of layer i.
Referenced by ipe::ImlParser::parsePage(), and snapping().
void Page::moveLayer | ( | int | index, |
int | newIndex | ||
) |
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(), layerMatrices(), ipe::ImlParser::parseView(), removeLayer(), renameLayer(), ipe::Thumbnail::saveRender(), setActive(), setVisible(), snapping(), and ipe::PdfWriter::~PdfWriter().
void Page::addLayer | ( | String | name | ) |
void Page::addLayer | ( | ) |
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 snapping().
void Page::setLayerData | ( | int | index, |
String | data | ||
) |
Set free data field of the layer.
Referenced by ipe::ImlParser::parsePage(), and snapping().
|
inline |
Return layer data.
|
inline |
Return number of views.
References countMarkedViews().
Referenced by addLayer(), countMarkedViews(), ipe::Document::countTotalViews(), ipe::PageSelector::fill(), findView(), pageBBox(), ipe::ImlParser::parsePage(), ipe::ImlParser::parseView(), ipe::Document::runLatex(), and saveAsXml().
int Page::countMarkedViews | ( | ) | const |
References count(), countViews(), and markedView().
Referenced by countViews().
|
inline |
Return effect of view.
References setEffect().
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 effect(), and ipe::ImlParser::parsePage().
|
inline |
Return active layer of view.
References setActive().
Referenced by insertView(), markedView(), and saveAsXml().
void Page::setActive | ( | int | index, |
String | name | ||
) |
Set active layer of view.
References findLayer(), and layer().
Referenced by active(), and ipe::ImlParser::parsePage().
|
inlinenoexcept |
Return name of view.
Referenced by ipe::PageSelector::fill(), findView(), and saveAsXml().
|
inlinenoexcept |
Set name of view.
Referenced by ipe::ImlParser::parsePage().
|
inline |
Return if view is marked.
References active(), clearViews(), findView(), insertView(), marked(), removeView(), and setMarkedView().
Referenced by countMarkedViews(), and saveAsXml().
void Page::setMarkedView | ( | int | index, |
bool | marked | ||
) |
Set if view is marked.
References marked().
Referenced by markedView(), and ipe::ImlParser::parsePage().
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().
void Page::removeView | ( | int | i | ) |
void Page::clearViews | ( | ) |
Remove all views of this page.
Referenced by markedView().
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().
Referenced by markedView().
|
inline |
References setViewMap().
Referenced by ipe::Thumbnail::render(), saveAsXml(), ipe::Thumbnail::saveRender(), and ipe::PdfWriter::~PdfWriter().
void Page::setViewMap | ( | int | index, |
const AttributeMap & | map | ||
) |
Set the attribute mapping for the view.
References ipe::ENotSelected.
Referenced by ipe::ImlParser::parsePage(), and viewMap().
|
inline |
Is layer visible in view?
References layer().
Referenced by ipe::PdfWriter::createPageView(), objSnapsInView(), pageBBox(), and saveAsXml().
|
inline |
Is object at index objno visible in view?
References layerMatrices(), and layerOf().
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().
std::vector< Matrix > Page::layerMatrices | ( | int | view | ) | const |
Return matrices for all layers.
References countLayers(), findLayer(), and ipe::size().
Referenced by objectVisible(), ipe::Thumbnail::render(), ipe::Thumbnail::saveRender(), and ipe::PdfWriter::~PdfWriter().
|
inline |
References layer(), section(), setLayerMatrix(), setSection(), setTitle(), setVisible(), and title().
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 clearLayerMatrices(), and ipe::ImlParser::parseView().
void Page::setVisible | ( | int | view, |
String | layer, | ||
bool | vis | ||
) |
Set visibility of layer layer in view view.
References findLayer().
Referenced by basic(), clearLayerMatrices(), and ipe::ImlParser::parsePage().
String Page::title | ( | ) | const |
Return title of this page.
Referenced by applyTitleStyle(), clearLayerMatrices(), ipe::PageSelector::fill(), 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 clearLayerMatrices(), and 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 clearLayerMatrices(), 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 clearLayerMatrices(), and ipe::ImlParser::parsePage().
|
inline |
Does this section title reflect the page title?
References applyTitleStyle(), and 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::Thumbnail::saveRender(), ipe::Latex::scanPage(), sectionUsesTitle(), and ipe::PdfWriter::~PdfWriter().
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().
|
inline |
Return if page is marked for printing.
References setMarked().
Referenced by markedView(), setMarked(), and setMarkedView().
void Page::setMarked | ( | bool | marked | ) |
Set if page is marked for printing.
References marked().
Referenced by marked(), and ipe::ImlParser::parsePage().
|
inline |
Return notes for this page.
References setNotes().
Referenced by ipe::PdfWriter::createPageView(), and setNotes().
void Page::setNotes | ( | String | notes | ) |
Set the notes of this page.
References notes().
Referenced by notes(), and ipe::ImlParser::parsePage().
|
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().
void Page::objectsPerLayer | ( | std::vector< int > & | objcounts | ) | const |
|
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().
|
inline |
Return object at index i (const version).
|
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().
|
inline |
Return layer of object at index i.
Referenced by ipe::SelectTool::mouseButton(), objectVisible(), objSnapsInView(), pageBBox(), ipe::Thumbnail::render(), ipe::Thumbnail::saveRender(), saveSelection(), ipe::SelectTool::SelectTool(), and ipe::PdfWriter::~PdfWriter().
|
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 append(), bbox(), deselectAll(), distance(), ensurePrimarySelection(), hasSelection(), insert(), invalidateBBox(), layer(), ipe::Attribute::NORMAL(), pageBBox(), primarySelection(), replace(), setAttribute(), snapBnd(), snapCtl(), snapVtx(), transform(), and viewBBox().
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().
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().
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().
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().
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().
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().
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().
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().
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 a new object at index i.
Takes ownership of the object.
References layer(), and select().
Referenced by ipe::ImlParser::parsePage(), and setLayerOf().
Append a new object.
Takes ownership of the object.
References layer(), and select().
Referenced by setLayerOf().
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.
References invalidateBBox().
Referenced by setLayerOf().
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().
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().
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().
void Page::deselectAll | ( | ) |
Deselect all objects.
References count(), ipe::ENotSelected, and setSelect().
Referenced by ipe::SelectTool::mouseButton(), and setLayerOf().
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().