Code

new command: relink clone to copied object
[inkscape.git] / src / sp-guide.cpp
index 9af5f9f021fd4a294d77b505daa970082080bde3..2f91a17cfedeb6375f3e265c03541f36edfab279 100644 (file)
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
+
+#include <algorithm>
+#include <cstring>
+#include <string>
 #include "display/guideline.h"
 #include "svg/svg.h"
 #include "svg/stringstream.h"
@@ -262,6 +266,25 @@ sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Ge
     }
 }
 
+void
+sp_guide_create_guides_around_page(SPDocument *doc) {
+    std::list<std::pair<Geom::Point, Geom::Point> > pts;
+
+    Geom::Point A(0, 0);
+    Geom::Point C(sp_document_width(doc), sp_document_height(doc));
+    Geom::Point B(C[Geom::X], 0);
+    Geom::Point D(0, C[Geom::Y]);
+
+    pts.push_back(std::make_pair<Geom::Point, Geom::Point>(A, B));
+    pts.push_back(std::make_pair<Geom::Point, Geom::Point>(B, C));
+    pts.push_back(std::make_pair<Geom::Point, Geom::Point>(C, D));
+    pts.push_back(std::make_pair<Geom::Point, Geom::Point>(D, A));
+
+    sp_guide_pt_pairs_to_guides(doc, pts);
+
+    sp_document_done (doc, SP_VERB_NONE, _("Guides around page"));
+}
+
 void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler)
 {
     SPCanvasItem *item = sp_guideline_new(group, guide->point_on_line, guide->normal_to_line.to_2geom());
@@ -390,15 +413,17 @@ char *sp_guide_description(SPGuide const *guide)
     GString *position_string_x = SP_PX_TO_METRIC_STRING(guide->point_on_line[X], SP_ACTIVE_DESKTOP->namedview->getDefaultMetric());
     GString *position_string_y = SP_PX_TO_METRIC_STRING(guide->point_on_line[Y], SP_ACTIVE_DESKTOP->namedview->getDefaultMetric());
 
-    if ( guide->normal_to_line == component_vectors[X] ) {
+    if ( guide->normal_to_line ==  component_vectors[X] ||
+         guide->normal_to_line == -component_vectors[X]) {
         return g_strdup_printf(_("vertical, at %s"), position_string_x->str);
-    } else if ( guide->normal_to_line == component_vectors[Y] ) {
+    } else if ( guide->normal_to_line == component_vectors[Y] ||
+                guide->normal_to_line == -component_vectors[Y]) {
         return g_strdup_printf(_("horizontal, at %s"), position_string_y->str);
     } else {
         double const radians = guide->angle();
         double const degrees = Geom::rad_to_deg(radians);
         int const degrees_int = (int) round(degrees);
-        return g_strdup_printf(_("at %d degrees, through (%s,%s)"), degrees_int, position_string_x->str, position_string_y->str);
+        return g_strdup_printf(_("at %d degrees, through (%s,%s); <b>Ctrl</b>+click to delete"), degrees_int, position_string_x->str, position_string_y->str);
     }
 
     g_string_free(position_string_x, TRUE);