summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/grid.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
committerMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
commit5a4fb2325f60d292b47330f540b26a3279341c90 (patch)
treed2aa7967be25450b83e625025366c618101ae49f /src/extension/internal/grid.cpp
parentThe Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff)
parentRemove Snap menu item and improve grid menu item text (diff)
downloadinkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz
inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/extension/internal/grid.cpp')
-rw-r--r--src/extension/internal/grid.cpp51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp
index 56bce2fe8..0059bbec2 100644
--- a/src/extension/internal/grid.cpp
+++ b/src/extension/internal/grid.cpp
@@ -11,6 +11,14 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
+#include <glibmm/threads.h>
+#endif
+
#include <gtkmm/box.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/spinbutton.h>
@@ -21,12 +29,14 @@
#include "selection.h"
#include "sp-object.h"
#include "util/glib-list-iterators.h"
+#include "2geom/geom.h"
#include "svg/path-string.h"
#include "extension/effect.h"
#include "extension/system.h"
+#include "util/units.h"
#include "grid.h"
@@ -49,31 +59,31 @@ Grid::load (Inkscape::Extension::Extension */*module*/)
namespace {
Glib::ustring build_lines(Geom::Rect bounding_area,
- float offset[], float spacing[])
+ Geom::Point const &offset, Geom::Point const &spacing)
{
Geom::Point point_offset(0.0, 0.0);
SVG::PathString path_data;
- for ( int axis = 0 ; axis < 2 ; ++axis ) {
+ for ( int axis = Geom::X ; axis <= Geom::Y ; ++axis ) {
point_offset[axis] = offset[axis];
for (Geom::Point start_point = bounding_area.min();
- start_point[axis] + offset[axis] <= (bounding_area.max())[axis];
- start_point[axis] += spacing[axis]) {
+ start_point[axis] + offset[axis] <= (bounding_area.max())[axis];
+ start_point[axis] += spacing[axis]) {
Geom::Point end_point = start_point;
end_point[1-axis] = (bounding_area.max())[1-axis];
path_data.moveTo(start_point + point_offset)
- .lineTo(end_point + point_offset);
+ .lineTo(end_point + point_offset);
}
}
- // std::cout << "Path data:" << path_data.c_str() << std::endl;
- return path_data;
- }
-
+ // std::cout << "Path data:" << path_data.c_str() << std::endl;
+ return path_data;
}
+} // namespace
+
/**
\brief This actually draws the grid.
\param module The effect that was called (unused)
@@ -89,30 +99,31 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
/* get page size */
SPDocument * doc = document->doc();
bounding_area = Geom::Rect( Geom::Point(0,0),
- Geom::Point(doc->getWidth(), doc->getHeight()) );
+ Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")) );
} else {
Geom::OptRect bounds = selection->visualBounds();
if (bounds) {
bounding_area = *bounds;
}
- gdouble doc_height = (document->doc())->getHeight();
+ gdouble doc_height = (document->doc())->getHeight().value("px");
Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
bounding_area = temprec;
}
- float spacings[2] = { module->get_param_float("xspacing"),
- module->get_param_float("yspacing") };
- float line_width = module->get_param_float("lineWidth");
- float offsets[2] = { module->get_param_float("xoffset"),
- module->get_param_float("yoffset") };
+ gdouble scale = Inkscape::Util::Quantity::convert(1, "px", (document->doc())->getDefaultUnit());
+ bounding_area *= Geom::Scale(scale);
+ Geom::Point spacings( scale * module->get_param_float("xspacing"),
+ scale * module->get_param_float("yspacing") );
+ gdouble line_width = scale * module->get_param_float("lineWidth");
+ Geom::Point offsets( scale * module->get_param_float("xoffset"),
+ scale * module->get_param_float("yoffset") );
Glib::ustring path_data("");
- path_data = build_lines(bounding_area,
- offsets, spacings);
+ path_data = build_lines(bounding_area, offsets, spacings);
Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc();
//XML Tree being used directly here while it shouldn't be.
@@ -132,9 +143,7 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
path->setAttribute("style", style.c_str());
current_layer->appendChild(path);
- Inkscape::GC::release(path);
-
- return;
+ Inkscape::GC::release(path);
}
/** \brief A class to make an adjustment that uses Extension params */