summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2007-07-18 02:23:47 +0000
committercilix42 <cilix42@users.sourceforge.net>2007-07-18 02:23:47 +0000
commitd0471e4de5ff9d31434c15b8036ce828041a238c (patch)
treee8be16696803ca9394ab7904561986a252bcb862 /src
parentMake string conversion of box coordinates locale-independent (fixes bug with ... (diff)
downloadinkscape-d0471e4de5ff9d31434c15b8036ce828041a238c.tar.gz
inkscape-d0471e4de5ff9d31434c15b8036ce828041a238c.zip
Use Inkscape's own code to write coordinates to svg (much nicer fix than commit #15449)
(bzr r3265)
Diffstat (limited to 'src')
-rw-r--r--src/box3d-face.cpp42
-rw-r--r--src/box3d.cpp9
2 files changed, 13 insertions, 38 deletions
diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp
index 02a49b4e4..287e5e205 100644
--- a/src/box3d-face.cpp
+++ b/src/box3d-face.cpp
@@ -11,8 +11,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include "svg/svg.h"
#include "box3d-face.h"
-#include <iostream>
// FIXME: It's quite redundant to pass the box plus the corners plus the axes. At least the corners can
// theoretically be reconstructed from the box and the axes, but in order to do this we need
@@ -191,7 +191,14 @@ void Box3DFace::hook_path_to_3dbox(SPPath * existing_path)
*/
void Box3DFace::set_path_repr()
{
- SP_OBJECT(this->path)->repr->setAttribute("d", svg_repr_string());
+ NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM (this->parent_box3d)));
+ SPCurve * curve = sp_curve_new();
+ sp_curve_moveto (curve, ((*corners[0]) * i2d)[NR::X], ((*corners[0]) * i2d)[NR::Y]);
+ sp_curve_lineto (curve, ((*corners[1]) * i2d)[NR::X], ((*corners[1]) * i2d)[NR::Y]);
+ sp_curve_lineto (curve, ((*corners[2]) * i2d)[NR::X], ((*corners[2]) * i2d)[NR::Y]);
+ sp_curve_lineto (curve, ((*corners[3]) * i2d)[NR::X], ((*corners[3]) * i2d)[NR::Y]);
+ sp_curve_closepath (curve);
+ SP_OBJECT(this->path)->repr->setAttribute("d", sp_svg_write_path (SP_CURVE_BPATH(curve)));
}
void Box3DFace::set_curve()
@@ -231,37 +238,6 @@ gchar * Box3DFace::axes_string()
return pstring->str;
}
-gchar * Box3DFace::svg_repr_string()
-{
- NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM (this->parent_box3d)));
- GString *pstring = g_string_new("");
- gchar str[G_ASCII_DTOSTR_BUF_SIZE];
-
- g_string_append_printf (pstring, "M ");
- g_string_append_printf (pstring, "%s", g_ascii_dtostr (str, sizeof (str), ((*corners[0]) * i2d)[NR::X]));
- g_string_append_printf (pstring, ",");
- g_string_append_printf (pstring, "%s", g_ascii_dtostr (str, sizeof (str), ((*corners[0]) * i2d)[NR::Y]));
-
- g_string_append_printf (pstring, " L ");
- g_string_append_printf (pstring, "%s", g_ascii_dtostr (str, sizeof (str), ((*corners[1]) * i2d)[NR::X]));
- g_string_append_printf (pstring, ",");
- g_string_append_printf (pstring, "%s", g_ascii_dtostr (str, sizeof (str), ((*corners[1]) * i2d)[NR::Y]));
-
- g_string_append_printf (pstring, " L ");
- g_string_append_printf (pstring, "%s", g_ascii_dtostr (str, sizeof (str), ((*corners[2]) * i2d)[NR::X]));
- g_string_append_printf (pstring, ",");
- g_string_append_printf (pstring, "%s", g_ascii_dtostr (str, sizeof (str), ((*corners[2]) * i2d)[NR::Y]));
-
- g_string_append_printf (pstring, " L ");
- g_string_append_printf (pstring, "%s", g_ascii_dtostr (str, sizeof (str), ((*corners[3]) * i2d)[NR::X]));
- g_string_append_printf (pstring, ",");
- g_string_append_printf (pstring, "%s", g_ascii_dtostr (str, sizeof (str), ((*corners[3]) * i2d)[NR::Y]));
-
- g_string_append_printf (pstring, " z");
-
- return pstring->str;
-}
-
/*
Local Variables:
mode:c++
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 1b467b178..dec5e9d17 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -17,6 +17,7 @@
#include <glibmm/i18n.h>
#include "attributes.h"
+#include "svg/stringstream.h"
#include "box3d.h"
static void sp_3dbox_class_init(SP3DBoxClass *klass);
@@ -422,11 +423,9 @@ static gchar *
sp_3dbox_get_corner_coords_string (SP3DBox *box, guint id)
{
id = id % 8;
- gchar str1[G_ASCII_DTOSTR_BUF_SIZE];
- gchar str2[G_ASCII_DTOSTR_BUF_SIZE];
- g_ascii_dtostr (str2, sizeof (str2), box->corners[id][NR::X]);
- return g_strjoin (",", g_ascii_dtostr (str1, sizeof (str1), box->corners[id][NR::X]),
- g_ascii_dtostr (str2, sizeof (str2), box->corners[id][NR::Y]), NULL);
+ Inkscape::SVGOStringStream os;
+ os << box->corners[id][NR::X] << "," << box->corners[id][NR::Y];
+ return g_strdup(os.str().c_str());
}
static std::pair<gdouble, gdouble>