summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 85cf3eb)
raw | patch | inline | side by side (parent: 85cf3eb)
author | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 18 Jul 2007 00:23:49 +0000 (00:23 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 18 Jul 2007 00:23:49 +0000 (00:23 +0000) |
src/box3d-face.cpp | patch | blob | history | |
src/box3d.cpp | patch | blob | history |
diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp
index 2cb510277da99f2a730d1fad357d4748f551192b..02a49b4e40ab5e920eb2334a5d5b163ae71642e7 100644 (file)
--- a/src/box3d-face.cpp
+++ b/src/box3d-face.cpp
{
NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM (this->parent_box3d)));
GString *pstring = g_string_new("");
- g_string_printf (pstring, "M %f,%f L %f,%f L %f,%f L %f,%f z",
- ((*corners[0]) * i2d)[NR::X], ((*corners[0]) * i2d)[NR::Y],
- ((*corners[1]) * i2d)[NR::X], ((*corners[1]) * i2d)[NR::Y],
- ((*corners[2]) * i2d)[NR::X], ((*corners[2]) * i2d)[NR::Y],
- ((*corners[3]) * i2d)[NR::X], ((*corners[3]) * i2d)[NR::Y]);
+ 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;
}
diff --git a/src/box3d.cpp b/src/box3d.cpp
index eb67269ce3975acec57e4340b3f6b0207ec9be81..1b467b178fd900cee5dbd62d28a38c33071a1ace 100644 (file)
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
sp_3dbox_get_corner_coords_string (SP3DBox *box, guint id)
{
id = id % 8;
- return g_strdup_printf ("%f,%f", box->corners[id][NR::X], box->corners[id][NR::Y]);
+ 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);
}
static std::pair<gdouble, gdouble>
sp_3dbox_get_coord_pair_from_string (const gchar *coords)
{
- gchar **coordlist = g_strsplit( coords, ",", 0);
- // We might as well rely on g_strtod to convert the NULL pointer to 0.0,
+ gchar **coordpair = g_strsplit( coords, ",", 0);
+ // We might as well rely on g_ascii_strtod to convert the NULL pointer to 0.0,
// but we include the following test anyway
- if (coordlist[0] == NULL || coordlist[1] == NULL) {
- g_strfreev (coordlist);
+ if (coordpair[0] == NULL || coordpair[1] == NULL) {
+ g_strfreev (coordpair);
g_warning ("Coordinate conversion failed.\n");
return std::make_pair(0.0, 0.0);
}
- gdouble coord1 = g_strtod(coordlist[0], NULL);
- gdouble coord2 = g_strtod(coordlist[1], NULL);
- g_strfreev (coordlist);
+ gdouble coord1 = g_ascii_strtod(coordpair[0], NULL);
+ gdouble coord2 = g_ascii_strtod(coordpair[1], NULL);
+ g_strfreev (coordpair);
return std::make_pair(coord1, coord2);
}