Code

Pot and Dutch translation update
[inkscape.git] / src / sp-offset.cpp
index 8f4dead0ad84d715fdcd2aab986e86b4d6c0b826..a43bc873d0084e6376ae1383ddce561f224bed5f 100644 (file)
 #include "livarot/Shape.h"
 
 #include "enums.h"
-#include "prefs-utils.h"
+#include "preferences.h"
 #include "sp-text.h"
 #include "sp-offset.h"
 #include "sp-use-reference.h"
 #include "uri.h"
 
-#include "libnr/n-art-bpath.h"
 #include <libnr/nr-matrix-fns.h>
 #include <2geom/pathvector.h>
 
@@ -84,7 +83,7 @@ static void sp_offset_update (SPObject * object, SPCtx * ctx, guint flags);
 static void sp_offset_release (SPObject * object);
 
 static gchar *sp_offset_description (SPItem * item);
-static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_offset_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
 static void sp_offset_set_shape (SPShape * shape);
 
 static void refresh_offset_source(SPOffset* offset);
@@ -92,7 +91,7 @@ static void refresh_offset_source(SPOffset* offset);
 static void sp_offset_start_listening(SPOffset *offset,SPObject* to);
 static void sp_offset_quit_listening(SPOffset *offset);
 static void sp_offset_href_changed(SPObject *old_ref, SPObject *ref, SPOffset *offset);
-static void sp_offset_move_compensate(NR::Matrix const *mp, SPItem *original, SPOffset *self);
+static void sp_offset_move_compensate(Geom::Matrix const *mp, SPItem *original, SPOffset *self);
 static void sp_offset_delete_self(SPObject *deleted, SPOffset *self);
 static void sp_offset_source_modified (SPObject *iSource, guint flags, SPItem *item);
 
@@ -242,7 +241,7 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
         gchar const *oldA = object->repr->attribute("inkscape:href");
         if (oldA) {
             size_t lA = strlen(oldA);
-            char *nA=(char*)malloc((lA+1)*sizeof(char));
+            char *nA=(char*)malloc((1+lA+1)*sizeof(char));
             memcpy(nA+1,oldA,lA*sizeof(char));
             nA[0]='#';
             nA[lA+1]=0;
@@ -511,10 +510,10 @@ sp_offset_set_shape(SPShape *shape)
         theRes->ConvertToForme (orig, 1, originaux);
 
         SPItem *item = shape;
-        NR::Maybe<NR::Rect> bbox = sp_item_bbox_desktop (item);
-        if ( bbox && !bbox->isEmpty() ) {
+        Geom::OptRect bbox = sp_item_bbox_desktop (item);
+        if ( bbox ) {
             gdouble size = L2(bbox->dimensions());
-            gdouble const exp = NR::expansion(item->transform);
+            gdouble const exp = item->transform.descrim();
             if (exp != 0)
                 size /= exp;
             orig->Coalesce (size * 0.001);
@@ -719,10 +718,10 @@ sp_offset_set_shape(SPShape *shape)
 /**
  * Virtual snappoints function.
  */
-static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_offset_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs)
 {
     if (((SPItemClass *) parent_class)->snappoints) {
-        ((SPItemClass *) parent_class)->snappoints (item, p);
+        ((SPItemClass *) parent_class)->snappoints (item, p, snapprefs);
     }
 }
 
@@ -747,9 +746,9 @@ static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p)
  *    -- njh
  */
 bool
-vectors_are_clockwise (NR::Point A, NR::Point B, NR::Point C)
+vectors_are_clockwise (Geom::Point A, Geom::Point B, Geom::Point C)
 {
-    using NR::rot90;
+    using Geom::rot90;
     double ab_s = dot(A, rot90(B));
     double ab_c = dot(A, B);
     double bc_s = dot(B, rot90(C));
@@ -795,7 +794,7 @@ vectors_are_clockwise (NR::Point A, NR::Point B, NR::Point C)
  * 'px inside source'.
  */
 double
-sp_offset_distance_to_original (SPOffset * offset, NR::Point px)
+sp_offset_distance_to_original (SPOffset * offset, Geom::Point px)
 {
     if (offset == NULL || offset->originalPath == NULL
         || ((Path *) offset->originalPath)->descr_cmd.size() <= 1)
@@ -833,14 +832,14 @@ sp_offset_distance_to_original (SPOffset * offset, NR::Point px)
         {
             if (theRes->getPoint(i).totalDegree() > 0)
            {
-                NR::Point nx = theRes->getPoint(i).x;
-                NR::Point nxpx = px-nx;
+                Geom::Point nx = theRes->getPoint(i).x;
+                Geom::Point nxpx = px-nx;
                 double ndist = sqrt (dot(nxpx,nxpx));
                 if (ptSet == false || fabs (ndist) < fabs (ptDist))
                 {
                     // we have a new minimum distance
                     // now we need to wheck if px is inside or outside (for the sign)
-                    nx = px - theRes->getPoint(i).x;
+                    nx = px - to_2geom(theRes->getPoint(i).x);
                     double nlen = sqrt (dot(nx , nx));
                     nx /= nlen;
                     int pb, cb, fb;
@@ -850,7 +849,7 @@ sp_offset_distance_to_original (SPOffset * offset, NR::Point px)
                     do
                     {
                         // one angle
-                        NR::Point prx, nex;
+                        Geom::Point prx, nex;
                         prx = theRes->getEdge(pb).dx;
                         nlen = sqrt (dot(prx, prx));
                         prx /= nlen;
@@ -886,18 +885,18 @@ sp_offset_distance_to_original (SPOffset * offset, NR::Point px)
                     }
                     while (cb >= 0 && pb >= 0 && pb != fb);
                 }
-           }
+            }
         }
         // loop over the edges to try to improve the distance
         for (int i = 0; i < theRes->numberOfEdges(); i++)
         {
-            NR::Point sx = theRes->getPoint(theRes->getEdge(i).st).x;
-            NR::Point ex = theRes->getPoint(theRes->getEdge(i).en).x;
-            NR::Point nx = ex - sx;
+            Geom::Point sx = theRes->getPoint(theRes->getEdge(i).st).x;
+            Geom::Point ex = theRes->getPoint(theRes->getEdge(i).en).x;
+            Geom::Point nx = ex - sx;
             double len = sqrt (dot(nx,nx));
             if (len > 0.0001)
-           {
-                NR::Point   pxsx=px-sx;
+            {
+                Geom::Point   pxsx=px-sx;
                 double ab = dot(nx,pxsx);
                 if (ab > 0 && ab < len * len)
                 {
@@ -909,7 +908,7 @@ sp_offset_distance_to_original (SPOffset * offset, NR::Point px)
                         arSet = true;
                     }
                 }
-           }
+            }
         }
         if (arSet || ptSet)
         {
@@ -1022,23 +1021,24 @@ sp_offset_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPOffset *offse
 }
 
 static void
-sp_offset_move_compensate(NR::Matrix const *mp, SPItem */*original*/, SPOffset *self)
+sp_offset_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPOffset *self)
 {
-    guint mode = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_PARALLEL);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    guint mode = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_PARALLEL);
     if (mode == SP_CLONE_COMPENSATION_NONE) return;
 
-    NR::Matrix m(*mp);
-    if (!(m.is_translation())) return;
+    Geom::Matrix m(*mp);
+    if (!(m.isTranslation())) return;
 
     // calculate the compensation matrix and the advertized movement matrix
     SPItem *item = SP_ITEM(self);
 
-    NR::Matrix compensate;
-    NR::Matrix advertized_move;
+    Geom::Matrix compensate;
+    Geom::Matrix advertized_move;
 
     if (mode == SP_CLONE_COMPENSATION_UNMOVED) {
-        compensate = NR::identity();
-        advertized_move.set_identity();
+        compensate = Geom::identity();
+        advertized_move.setIdentity();
     } else if (mode == SP_CLONE_COMPENSATION_PARALLEL) {
         compensate = m;
         advertized_move = m;
@@ -1056,7 +1056,8 @@ sp_offset_move_compensate(NR::Matrix const *mp, SPItem */*original*/, SPOffset *
 static void
 sp_offset_delete_self(SPObject */*deleted*/, SPOffset *offset)
 {
-    guint const mode = prefs_get_int_attribute("options.cloneorphans", "value", SP_CLONE_ORPHANS_UNLINK);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    guint const mode = prefs->getInt("/options/cloneorphans/value", SP_CLONE_ORPHANS_UNLINK);
 
     if (mode == SP_CLONE_ORPHANS_UNLINK) {
         // leave it be. just forget about the source
@@ -1171,4 +1172,4 @@ sp_offset_get_source (SPOffset *offset)
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :