2#ifndef SEEN_SP_DOCUMENT_H
3#define SEEN_SP_DOCUMENT_H
30#include <boost/ptr_container/ptr_list.hpp>
32#include <giomm/simpleactiongroup.h>
34#include <glibmm/refptr.h>
35#include <glibmm/timer.h>
36#include <glibmm/ustring.h>
37#include <sigc++/connection.h>
38#include <sigc++/signal.h>
89 class UndoStackObserver;
121 std::string
const &filename =
"");
128 std::unique_ptr<SPDocument>
copy()
const;
132 void rebase(
const gchar * file,
bool keep_namedview =
true);
134 void rebase(
bool keep_namedview =
true);
180 std::deque<SPItem*>
const &
get_flat_item_list(
unsigned int dkey,
bool into_groups,
bool active_only)
const;
328 std::vector<SPItem*>
getItemsInBox (
unsigned int dkey,
Geom::Rect const &box,
bool take_hidden =
false,
bool take_insensitive =
false,
bool take_groups =
true,
bool enter_groups =
false,
bool enter_layers =
true)
const;
329 std::vector<SPItem*>
getItemsPartiallyInBox(
unsigned int dkey,
Geom::Rect const &box,
bool take_hidden =
false,
bool take_insensitive =
false,
bool take_groups =
true,
bool enter_groups =
false,
bool enter_layers =
true)
const;
331 std::vector<SPItem*>
getItemsAtPoints(
unsigned const key, std::vector<Geom::Point> points,
bool all_layers =
true,
bool topmost_only =
true,
size_t limit = 0,
bool active_only =
true)
const;
353 std::vector<Persp3D*> list;
418 std::map<std::string, SPObject *>
iddef;
419 std::map<Inkscape::XML::Node *, SPObject *>
reprdef;
435 std::deque<Inkscape::Event *>
undo;
436 std::deque<Inkscape::Event *>
redo;
497 sigc::connection
connectDestroy(sigc::signal<
void ()>::slot_type slot);
500 sigc::connection
connectCommit(CommitSignal::slot_type slot);
502 sigc::connection
connectIdChanged(
const char *
id, IDChangedSignal::slot_type slot);
509 std::map<std::string, std::vector<SPObject *> >
resources;
3x3 affine transformation matrix.
The Router class represents a libavoid router instance.
3x3 matrix representing an affine transformation.
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
Aggregates UndoStackObservers for management and triggering in an SPDocument's undo/redo system.
Inkscape::ConsoleOutputUndoObserver - observer for tracing calls to SPDocumentUndo::undo,...
A simple log for maintaining a history of committed, undone and redone events along with their type.
The set of selected SPObjects for a given document and layer model.
Observes changes made to the undo and redo stacks.
Enumeration of all XML event types.
Interface for refcounted XML nodes.
Typed SVG document implementation.
bool get_origin_follows_page()
std::vector< SPObject * > _collection_queue
Orphans.
Inkscape::Selection * getSelection()
void scaleContentBy(Geom::Scale const &delta)
Scale the content, used by file-update and document properties when modifying the the document's view...
void setDocumentFilename(char const *filename)
A filename, or NULL.
CRCascade * style_cascade
Glib::RefPtr< Gio::SimpleActionGroup > getActionGroup()
void setCurrentPersp3DImpl(Persp3DImpl *const persp_impl)
Avoid::Router * getRouter() const
static std::unique_ptr< SPDocument > createDoc(Inkscape::XML::Document *rdoc, char const *filename, char const *base, char const *name, bool keepalive, SPDocument *parent=nullptr)
std::vector< SPObject * > getObjectsByClass(Glib::ustring const &klass) const
void prunePages(const std::string &page_nums, bool invert=false)
Remove pages in bulk using the integer range format "1,2,3-4" etc.
std::vector< std::unique_ptr< SPDocument > > _child_documents
void setCurrentPersp3D(Persp3D *const persp)
Inkscape::XML::Document * rdoc
Our Inkscape::XML::Document.
const Geom::Affine & doc2dt() const
Document to desktop coordinate transformation.
void importDefs(SPDocument *source)
Paste SVG defs from the document retrieved from the clipboard or imported document into the active do...
bool removeResource(char const *key, SPObject *object)
Inkscape::XML::Event * partial
void setModifiedSinceAutoSaveFalse()
SPDocument::ModifiedSignal modified_signal
std::map< GQuark, SPDocument::ResourcesChangedSignal > ResourcesChangedSignalMap
sigc::signal< void(unsigned)> ModifiedSignal
std::vector< SPItem * > getItemsAtPoints(unsigned const key, std::vector< Geom::Point > points, bool all_layers=true, bool topmost_only=true, size_t limit=0, bool active_only=true) const
Inkscape::XML::Document const * getReprDoc() const
Glib::RefPtr< Gio::SimpleActionGroup > action_group
std::map< std::string, std::vector< SPObject * > > resources
static int get_new_doc_number()
void _emitModified(unsigned int object_modified_tag=0)
static std::unique_ptr< SPDocument > createNewDocFromMem(std::span< char const > buffer, bool keepalive, std::string const &filename="")
sigc::signal< void()> BeforeCommitSignal
void setWidthAndHeight(const Inkscape::Util::Quantity &width, const Inkscape::Util::Quantity &height, bool changeSize=true)
SPRoot * getRoot()
Returns our SPRoot.
static SPItem * getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const std::vector< SPItem * > &list, Geom::Point const &p, bool take_insensitive=false)
Returns the bottommost item from the list which is at the point, or NULL if none.
SPDocument::CommitSignal commit_signal
char const * getDocumentBase() const
double update_desktop_affine()
Update desktop transform after Y-axis orientation change.
std::unique_ptr< SPDocument > copy() const
Create a copy of the document, useful for modifying during save & export.
SPDocument * get_reference_document()
sigc::connection connectResourcesChanged(char const *key, SPDocument::ResourcesChangedSignal::slot_type slot)
char const * getDocumentFilename() const
sigc::signal< void(char const *)> FilenameSetSignal
std::string generate_unique_id(char const *prefix)
Generate a document-wide unique id.
unsigned update_in_progress
For sanity check in SPObject::requestDisplayUpdate.
bool addResource(char const *key, SPObject *object)
bool idle_handler()
An idle handler to update the document.
std::unique_ptr< Inkscape::Colors::DocumentCMS > _cms_manager
void setXMLDialogSelectedObject(SPObject *activexmltree)
const Geom::Affine & dt2doc() const
Desktop to document coordinate transformation.
SPObject * getObjectById(std::string const &id) const
sigc::signal< void()> destroySignal
void setWidth(const Inkscape::Util::Quantity &width, bool changeSize=true)
void _importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, Inkscape::XML::Node *target_defs)
Glib::ustring const & action_key() const
char * document_base
To be used for resolving relative hrefs.
SPDocument * _parent_document
SPDocument::FilenameSetSignal filename_set_signal
bool isModifiedSinceSave() const
Inkscape::CompositeUndoStackObserver undoStackObservers
void setModifiedSinceSave(bool const modified=true)
Indicate to the user if the document has been modified since the last save by displaying a "*" in fro...
void setupViewport(SPItemCtx *ctx)
void fitToRect(Geom::Rect const &rect, bool with_margins=false)
Given a Geom::Rect that may, for example, correspond to the bbox of an object, this function fits the...
Inkscape::Util::Quantity getWidth() const
SPDocument const * getParent() const
void process_pending_resource_changes()
Inkscape::EventLog * get_event_log()
char const * getDocumentName() const
basename or other human-readable label for the document.
void addUndoObserver(Inkscape::UndoStackObserver &observer)
Add the observer to the document's undo listener The caller is in charge of freeing any memory alloca...
sigc::connection connectSavedOrModified(sigc::slot< void()> &&slot)
std::deque< SPItem * > const & get_flat_item_list(unsigned int dkey, bool into_groups, bool active_only) const
Turn the SVG DOM into a cached flat list of nodes that can be searched from top-down.
std::unique_ptr< Inkscape::PageManager > _page_manager
std::vector< SPObject * > const getResourceList(char const *key)
Geom::Point getDimensions() const
sigc::connection _desktop_activated_connection
bool rerouting_handler()
An idle handler to reroute connectors in the document.
Persp3D * current_persp3d
Currently 'active' perspective (to which, e.g., newly created boxes are attached)
sigc::connection connectBeforeCommit(BeforeCommitSignal::slot_type slot)
Persp3DImpl * getCurrentPersp3DImpl()
void reset_key(void *dummy)
Geom::Rect getViewBox() const
std::vector< SPItem * > getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool take_hidden=false, bool take_insensitive=false, bool take_groups=true, bool enter_groups=false, bool enter_layers=true) const
Get items whose bounding box overlaps with given area.
Inkscape::XML::Node * getReprRoot()
Geom::OptRect preferredBounds() const
std::unique_ptr< Inkscape::Selection > _selection
Geom::OptRect pageBounds()
Returns the position of the selected page or the preferredBounds()
sigc::signal< void(double)> get_y_axis_flipped()
CRCascade * getStyleCascade()
SPDocument::BeforeCommitSignal before_commit_signal
SPDocument::ReconstructionStart _reconstruction_start_signal
sigc::signal< void()> ReconstructionStart
unsigned long serial() const
sigc::connection connectModified(ModifiedSignal::slot_type slot)
sigc::signal< void(double)> _y_axis_flipped
unsigned int vacuumDocument()
Remove unused definitions etc.
unsigned int numPerspectivesInDefs() const
std::deque< Inkscape::Event * > redo
bool virgin
Has the document never been touched?
void setHeight(const Inkscape::Util::Quantity &height, bool changeSize=true)
sigc::connection modified_connection
void getPerspectivesInDefs(std::vector< Persp3D * > &list) const
Inkscape::PageManager & getPageManager()
void setDocumentBase(char const *document_base)
To be used for resolving relative hrefs.
ResourcesChangedSignalMap resources_changed_signals
const SPDocument * getOriginalDocument() const
sigc::signal< void()> CommitSignal
void emitReconstructionFinish()
bool has_yaxis_orientation_changed()
Detect Y-axis orientation change.
double yaxisdir() const
"1" if the desktop Y-axis points down, "-1" if it points up.
std::vector< SPItem * > getItemsInBox(unsigned int dkey, Geom::Rect const &box, bool take_hidden=false, bool take_insensitive=false, bool take_groups=true, bool enter_groups=false, bool enter_layers=true) const
Return list of items, contained in box.
void bindObjectToId(char const *id, SPObject *object)
SPDocument const * _original_document
std::queue< GQuark > pending_resource_changes
bool modified_since_autosave
std::deque< Inkscape::Event * > undo
void removeUndoObserver(Inkscape::UndoStackObserver &observer)
bool _updateDocument(int flags, unsigned int object_modified_tag=0)
Tries to update the document state based on the modified and "update required" flags,...
bool keepalive
false if temporary document (e.g. to generate a PNG for display in a dialog).
SPDefs * getDefs()
Return the main defs object for the document.
SPDocument * createChildDoc(std::string const &filename)
Fetches a document and attaches it to the current document as a child href.
bool isModifiedSinceAutoSave() const
std::map< unsigned long, std::deque< SPItem * > > _node_cache
const Inkscape::PageManager & getPageManager() const
sigc::signal< void(SPObject *)> IDChangedSignal
void set_origin_follows_page(bool on)
std::vector< SPObject * > getObjectsByElement(Glib::ustring const &element, bool custom=false) const
char * document_filename
A filename, or NULL.
SPObject * _activexmltree
sigc::signal< void(double, double)> ResizedSignal
static std::unique_ptr< SPDocument > createNewDoc(char const *filename, bool keepalive, bool make_new=false, SPDocument *parent=nullptr)
Fetches document from filename, or creates new, if NULL; public document appears in document list.
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
sigc::connection connectReconstructionFinish(ReconstructionFinish::slot_type slot)
SPDocument * _searchForChild(std::string const &filename, SPDocument const *avoid=nullptr)
sigc::signal< void()> _saved_or_modified_signal
std::map< GQuark, SPDocument::IDChangedSignal > IDChangedSignalMap
unsigned long object_id_counter
void rebase(Inkscape::XML::Document *new_xmldoc, bool keep_namedview=true)
SPDocument::ReconstructionFinish _reconstruction_finish_signal
Inkscape::ConsoleOutputUndoObserver console_output_undo_observer
sigc::signal< void()> ReconstructionFinish
void bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object)
void setDocumentScale(const double scaleX, const double scaleY)
Sets document scale (by changing viewBox)
char * document_name
basename or other human-readable label for the document.
void setVirgin(bool Virgin)
std::vector< Glib::ustring > getLanguages() const
Returns preferred document languages (from most to least preferred)
std::unique_ptr< Inkscape::EventLog > _event_log
void queueForOrphanCollection(SPObject *object)
sigc::connection connectFilenameSet(FilenameSetSignal::slot_type slot)
SPRoot const * getRoot() const
void do_change_filename(char const *const filename, bool const rebase)
int ensureUpToDate(unsigned int object_modified_tag=0)
Repeatedly works on getting the document updated, since sometimes it takes more than one pass to get ...
std::unique_ptr< Avoid::Router > _router
SPDocument * _ref_document
bool is_yaxisdown() const
True if the desktop Y-axis points down, false if it points up.
SPObject * getObjectByHref(std::string const &href) const
SPDocument(SPDocument const &)=delete
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
void set_reference_document(SPDocument *document)
Set the reference document object.
IDChangedSignalMap id_changed_signals
Dictionary of signals for id changes.
sigc::signal< void()> ResourcesChangedSignal
sigc::connection connectIdChanged(const char *id, IDChangedSignal::slot_type slot)
sigc::connection connectReconstructionStart(ReconstructionStart::slot_type slot, bool first=false)
SPObject * getXMLDialogSelectedObject()
SPNamedView * getNamedView()
Get the namedview for this document, creates it if it's not found.
void changeFilenameAndHrefs(char const *filename)
Changes the base, name and filename members of document, and updates any relative hrefs in the docume...
Persp3D * getCurrentPersp3D()
Geom::Scale getDocumentScale(bool computed=true) const
Returns document scale as defined by width/height (in pixels) and viewBox (real world to user-units).
void setViewBox()
Set default viewbox calculated from document properties.
SPItem * getGroupAtPoint(unsigned int key, Geom::Point const &p) const
Inkscape::Colors::DocumentCMS & getDocumentCMS()
Inkscape::Util::Quantity getHeight() const
void setPages(bool enabled)
void SPDocument::initialize_current_persp3d() { this->current_persp3d = Persp3D::document_first_persp...
void emitReconstructionStart()
std::map< std::string, SPObject * > iddef
sigc::connection connectCommit(CommitSignal::slot_type slot)
Inkscape::XML::Node * rroot
Root element of Inkscape::XML::Document.
sigc::connection connectDestroy(sigc::signal< void()>::slot_type slot)
SPDocument & operator=(SPDocument const &)=delete
Inkscape::XML::Node * getReprNamedView()
SPItem * getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto=nullptr) const
sigc::connection rerouting_connection
Inkscape::Util::Unit const * getDisplayUnit()
guaranteed not to return nullptr
Persp3DImpl * current_persp3d_impl
const Inkscape::Colors::DocumentCMS & getDocumentCMS() const
std::vector< SPObject * > getObjectsBySelector(Glib::ustring const &selector) const
std::map< Inkscape::XML::Node *, SPObject * > reprdef
Base class for visual SVG elements.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
NodeObserver const * observer
the declaration of the CRCascade class.
static char const *const parent
bool sp_do_not_fix_pre_92
bool sp_no_convert_text_baseline_spacing
libavoid: Object-avoiding orthogonal and polyline connector routing library.
Miscellaneous supporting code.
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
void invert(const double v[16], double alpha[16])
Interface for XML documents.
Object used to temporarily set and then automatically clear reference document.
~install_reference_document()
Contains transformations to document/viewport and the viewport size.