24#include <glibmm/i18n.h>
58 for (
auto &view :
views) {
59 view->set_stroke(
color);
92 if (
auto c = Inkscape::Colors::Color::parse(value)) {
102 this->
label = g_strdup(value);
104 this->
label =
nullptr;
116 if (value && !strcmp(value,
"horizontal")) {
119 }
else if (value && !strcmp(value,
"vertical")) {
122 gchar ** strarray = g_strsplit(value,
",", 2);
126 g_strfreev (strarray);
127 if (success == 2 && (fabs(newx) > 1e-6 || fabs(newy) > 1e-6)) {
151 gchar ** strarray = g_strsplit(value,
",", 2);
155 g_strfreev (strarray);
162 double vbunit2px = (
root->width.computed /
root->viewBox.width() +
root->height.computed /
root->viewBox.height())/2.0;
163 newx = newx * vbunit2px;
164 newy = newy * vbunit2px;
167 newy = newy *
root->height.computed /
root->viewBox.height();
171 }
else if (success == 1) {
174 if (attr && !strcmp(attr,
"horizontal")) {
218 double newx = pt1.
x();
219 double newy = pt1.
y();
229 if(
root->viewBox_set ) {
232 double px2vbunit = (
root->viewBox.width()/
root->width.computed +
root->viewBox.height()/
root->height.computed)/2.0;
233 newx = newx * px2vbunit;
234 newy = newy * px2vbunit;
236 newx = newx *
root->viewBox.width() /
root->width.computed;
237 newy = newy *
root->viewBox.height() /
root->height.computed;
270 for (
auto & pt : pts) {
277 std::list<std::pair<Geom::Point, Geom::Point> > pts;
294 auto guide = cast<SPGuide>(*(
current.begin()));
315 dot->connect_event(dot_handler);
322 for (
auto &view :
views) {
323 view->set_visible(
true);
330 g_assert(canvas !=
nullptr);
331 for (
auto it =
views.begin(); it !=
views.end(); ++it) {
332 if (canvas == (*it)->get_canvas()) {
343 for (
auto &view :
views) {
344 view->set_visible(
false);
350 g_assert(canvas !=
nullptr);
352 for (
auto &view :
views) {
353 if (canvas == view->get_canvas()) {
354 view->set_pickable(sensitive);
373 for (
auto &view :
views) {
390 if(
root->viewBox_set ) {
393 double px2vbunit = (
root->viewBox.width()/
root->width.computed +
root->viewBox.height()/
root->height.computed)/2.0;
394 newx = newx * px2vbunit;
395 newy = newy * px2vbunit;
398 newy = newy *
root->viewBox.height() /
root->height.computed;
417 for (
auto &view :
views) {
438 this->
color = (r << 24) | (g << 16) | (b << 8) | 0x7f;
440 if (!
views.empty()) {
445 std::ostringstream os;
446 os <<
"rgb(" << r <<
"," << g <<
"," << b <<
")";
455 if ( !
views.empty() ) {
466 if (!
views.empty()) {
487 char *descr =
nullptr;
490 descr = g_strdup(_(
"Deleted"));
500 g_strdup_printf(
"; %s", _(
"<b>Shift+drag</b> to rotate, <b>Ctrl+drag</b> to move origin, <b>Del</b> to "
501 "delete; <b>double-click</b> to edit this guide's properties"));
505 descr = g_strdup_printf(_(
"vertical, at %s"), position_string_x.c_str());
508 descr = g_strdup_printf(_(
"horizontal, at %s"), position_string_y.c_str());
510 double const radians = this->
angle();
511 double const degrees = Geom::deg_from_rad(radians);
512 int const degrees_int = (int) round(degrees);
513 descr = g_strdup_printf(_(
"at %d degrees, through (%s,%s)"),
514 degrees_int, position_string_x.c_str(), position_string_y.c_str());
518 gchar *oldDescr = descr;
519 descr = g_strconcat(oldDescr, shortcuts,
nullptr);
531 if (this->
locked && !force)
pair< double, double > Point
Lookup dictionary for attributes/properties.
C width() const
Get the horizontal extent of the rectangle.
CPoint corner(unsigned i) const
Return the n-th corner of the rectangle.
Two-dimensional point that doubles as a vector.
void normalize()
Normalize the vector representing the point.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
Axis aligned, non-empty rectangle.
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
Geom::Rect getSelectedPageRect() const
Returns the selected page rect, OR the viewbox rect.
Glib::ustring string(Unit const *u) const
Return a printable string of the value in the specified unit.
double value(Unit const *u) const
Return the quantity's value in the specified unit.
Interface for refcounted XML nodes.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
bool setAttributePoint(Util::const_char_ptr key, Geom::Point const &val)
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
Typed SVG document implementation.
bool removeResource(char const *key, SPObject *object)
SPRoot * getRoot()
Returns our SPRoot.
bool addResource(char const *key, SPObject *object)
std::vector< SPObject * > const getResourceList(char const *key)
Inkscape::PageManager & getPageManager()
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
bool is_yaxisdown() const
True if the desktop Y-axis points down, false if it points up.
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
SPNamedView * getNamedView()
Get the namedview for this document, creates it if it's not found.
Inkscape::Util::Quantity getHeight() const
void set_locked(const bool locked, bool const commit)
char * description(bool const verbose=true) const
Returns a human-readable description of the guideline for use in dialog boxes and status bar.
void sensitize(Inkscape::UI::Widget::Canvas *canvas, bool sensitive)
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
void set_color(const unsigned r, const unsigned g, const unsigned b, bool const commit)
void set(SPAttr key, const char *value) override
void moveto(Geom::Point const point_on_line, bool const commit)
Geom::Point point_on_line
Geom::Point normal_to_line
std::vector< CanvasItemPtr< Inkscape::CanvasItemGuideLine > > views
void set_normal(Geom::Point const normal_to_line, bool const commit)
static SPGuide * createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2)
bool remove(bool force=false)
void set_label(const char *label, bool const commit)
Inkscape::Util::Unit const * display_units
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * repr
void appendChild(Inkscape::XML::Node *child)
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
virtual void set(SPAttr key, const char *value)
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.
virtual void build(SPDocument *doc, Inkscape::XML::Node *repr)
Utility functions to convert ascii representations to numbers.
bool sp_dt_guide_event(Inkscape::CanvasEvent const &event, Inkscape::CanvasItemGuideLine *guide_item, SPGuide *guide)
static char const *const current
TODO: insert short description here.
constexpr Coord EPSILON
Default "acceptably small" value.
Various utility functions.
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)
D2< T > rot90(D2< T > const &a)
static R & release(R &r)
Decrements the reference count of a anchored object.
bool read_bool(gchar const *value, bool default_value)
static cairo_user_data_key_t key
C facade to Inkscape::XML::Node.
void sp_repr_unparent(Inkscape::XML::Node *repr)
Remove repr from children of its parent node.
void sp_guide_create_guides_around_page(SPDocument *doc)
void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list< std::pair< Geom::Point, Geom::Point > > &pts)
void sp_guide_delete_all_guides(SPDocument *doc)
SPRoot: SVG <svg> implementation.
Abstract base class for events.
Interface for XML documents.
virtual Node * createElement(char const *name)=0
unsigned int sp_svg_number_read_d(gchar const *str, double *val)
void dot(Cairo::RefPtr< Cairo::Context > &cr, double x, double y)