22#include <glib/gi18n.h>
46 std::vector<DrawingItemPtr<Inkscape::DrawingItem>>
items;
124 if (!strcmp (value,
"strokeWidth")) {
126 }
else if (!strcmp (value,
"userSpaceOnUse")) {
161 if (!strcmp (value,
"auto")) {
164 }
else if (!strcmp (value,
"auto-start-reverse")) {
220 for (
auto &
item : it.second.items) {
222 auto g = cast<Inkscape::DrawingGroup>(
item.get());
223 g->setChildTransform(
c2p);
230 if ((flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
332 if (!doc || !sp_marker)
return;
340 for (
auto *i :
items) {
341 auto item = cast<SPItem>(i);
366 xScale = (existingXScale >= 0? existingXScale: 1);
372 yScale = (existingYScale >= 0? existingYScale: 1);
378 if(xScale > yScale) {
396 sp_marker->
setAttribute(
"preserveAspectRatio",
"xMidYMid");
423 if (it->second.items.size() !=
size ) {
426 it->second.items.clear();
427 for (
unsigned int i = 0; i <
size; ++i) {
428 it->second.items.push_back(
nullptr);
433 for (
unsigned int i = 0; i <
size; ++i) {
445 unsigned int loc,
unsigned int pos,
unsigned int z_order,
462 SPMarkerView *view = &it->second;
463 if (pos >= view->items.size() ) {
469 if (!view->items[pos]) {
474 if (view->items[pos]) {
475 parent->appendChild(view->items[pos].get());
476 if (
auto g = cast<Inkscape::DrawingGroup>(view->items[pos].get())) {
477 g->setChildTransform(marker->
c2p);
482 if (view->items[pos]) {
483 view->items[pos]->setTransform(marker_transform);
484 view->items[pos]->setZOrder(z_order);
487 return view->items[pos].get();
523 const gchar *mark_id = repr->
attribute(
"id");
526 for (
auto node : reprs){
532 dup_transform *= move;
534 copy->doWriteTransform(dup_transform);
548 gboolean colorStock = prefs->
getBool(
"/options/markers/colorStockMarkers",
true);
549 gboolean colorCustom = prefs->
getBool(
"/options/markers/colorCustomMarkers",
false);
551 gboolean isStock = (!stock || !strcmp(stock,
"true"));
553 if (isStock ? !colorStock : !colorCustom) {
563 if (!mark_repr->
attribute(
"inkscape:stockid")) {
574 if (!marker || !value)
return;
597 marker->
setAttribute(
"markerUnits", scale_with_stroke ?
"strokeWidth" :
"userSpaceOnUse");
3x3 affine transformation matrix.
Lookup dictionary for attributes/properties.
3x3 matrix representing an affine transformation.
Point translation() const
Gets the translation imparted by the Affine.
void unionWith(CRect const &b)
Enlarge the rectangle to contain the argument.
static CRect from_xywh(Coord x, Coord y, Coord w, Coord h)
Create rectangle from origin and dimensions.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
CPoint dimensions() const
Get rectangle's width and height as a point.
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
static Rotate from_degrees(Coord deg)
Construct a rotation from its angle in degrees.
A thin wrapper around std::ostringstream, but writing floating point numbers in the format required b...
static void maybeDone(SPDocument *document, const gchar *keyconst, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
SVG drawing item for display.
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
Interface for refcounted XML nodes.
virtual void addChild(Node *child, Node *after)=0
Insert another node as a child of this node.
virtual void appendChild(Node *child)=0
Append a node as the last child of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual Node * duplicate(Document *doc) const =0
Create a duplicate of this node.
bool setAttributeCssDouble(Util::const_char_ptr key, double val)
Set a property attribute to val [slightly rounded], in the format required for CSS properties: in par...
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
Typed SVG document implementation.
const Geom::Affine & dt2doc() const
Desktop to document coordinate transformation.
SPObject * getObjectById(std::string const &id) const
SPDefs * getDefs()
Return the main defs object for the document.
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
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 ...
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void set(SPAttr key, char const *value) override
void build(SPDocument *document, Inkscape::XML::Node *repr) override
std::vector< SPItem * > item_list()
void hide(unsigned int key) override
void update(SPCtx *ctx, unsigned int flags) override
Geom::OptRect desktopVisualBounds() const
Get item's visual bbox in desktop coordinate system.
void release() override
Removes, releases and unrefs all children of object.
std::map< unsigned int, SPMarkerView > views_map
unsigned int markerUnits_set
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override
virtual Inkscape::DrawingItem * private_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags)
void hide(unsigned int key) override
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) override
void print(SPPrintContext *ctx) override
void set(SPAttr key, gchar const *value) override
Geom::Affine get_marker_transform(Geom::Affine const &base, double linewidth, bool for_display=false) const
Calculate the transformation for this marker.
~SPMarker() override
Initializes an SPMarker object.
void update(SPCtx *ctx, guint flags) override
void build(SPDocument *document, Inkscape::XML::Node *repr) override
Virtual build callback for SPMarker.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * repr
void setAttributeDouble(Inkscape::Util::const_char_ptr key, double value)
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
void removeAttribute(char const *key)
void readAttr(char const *key)
Read value of key attribute from XML node into object.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
SPObject * appendChildRepr(Inkscape::XML::Node *repr)
Append repr as child of this object.
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
void set_viewBox(const gchar *value)
unsigned int aspect_align
void set_preserveAspectRatio(const gchar *value)
void write_preserveAspectRatio(Inkscape::XML::Node *repr) const
Write preserveAspectRatio attribute to XML, if set.
SPItemCtx get_rctx(const SPItemCtx *ictx, double scale_none=1.0)
void write_viewBox(Inkscape::XML::Node *repr) const
Write viewBox attribute to XML, if set.
void readOrUnset(gchar const *str, Unit u=Unit::NONE, double v=0, double c=0)
void readOrUnset(char const *str, Unit u=NONE, float v=0, float c=0)
TODO: insert short description here.
static char const *const parent
TODO: insert short description here.
Group belonging to an SVG drawing element.
@ SP_MARKER_UNITS_USERSPACEONUSE
@ SP_MARKER_UNITS_STROKEWIDTH
Macro for icon names used in Inkscape.
Inkscape::XML::Node * node
Affine identity()
Create an identity matrix.
static R & release(R &r)
Decrements the reference count of a anchored object.
static cairo_user_data_key_t key
Singleton class to access the preferences file in a convenient way.
const gchar * generate_marker(std::vector< Inkscape::XML::Node * > &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move)
void sp_marker_set_orient(SPMarker *marker, const char *value)
void sp_marker_hide(SPMarker *marker, unsigned int key)
Hides/removes all views of the given marker that have key 'key'.
void sp_marker_scale_with_stroke(SPMarker *marker, bool scale_with_stroke)
void sp_validate_marker(SPMarker *sp_marker, SPDocument *doc)
SPObject * sp_marker_fork_if_necessary(SPObject *marker)
Inkscape::DrawingItem * sp_marker_show_instance(SPMarker *marker, Inkscape::DrawingItem *parent, unsigned int loc, unsigned int pos, unsigned int z_order, Geom::Affine const &marker_transform, float linewidth)
Shows an instance of a marker.
void sp_marker_set_offset(SPMarker *marker, double dx, double dy)
void sp_marker_set_uniform_scale(SPMarker *marker, bool uniform)
void sp_marker_set_size(SPMarker *marker, double sx, double sy)
void sp_marker_show_dimension(SPMarker *marker, unsigned int key, unsigned int size)
Removes any SPMarkerViews that a marker has with a specific key.
void sp_marker_flip_horizontally(SPMarker *marker)
@ MARKER_ORIENT_AUTO_START_REVERSE
Interface for XML documents.
virtual Node * createElement(char const *name)=0
Contains transformations to document/viewport and the viewport size.
Geom::Affine i2doc
Item to document transformation.
Geom::Affine i2vp
Item to viewport transformation.
Geom::Rect viewport
Viewport size.
bool sp_svg_transform_read(gchar const *str, Geom::Affine *transform)
Interface for XML documents.