16#include <gtkmm/adjustment.h>
17#include <gtkmm/spinbutton.h>
53Glib::ustring build_lines(
Geom::Rect bounding_area,
61 point_offset[axis] =
offset[axis];
64 start_point[axis] +
offset[axis] <= (bounding_area.
max())[axis];
65 start_point[axis] += spacing[axis]) {
67 end_point[1-axis] = (bounding_area.
max())[1-axis];
69 path_data.
moveTo(start_point + point_offset)
70 .
lineTo(end_point + point_offset);
102 bounding_area = temprec;
110 gdouble line_width =
scale *
module->get_param_float("lineWidth");
114 Glib::ustring path_data(
"");
116 path_data = build_lines(bounding_area, offsets, spacings);
125 std::ostringstream stringstream;
126 stringstream <<
"fill:none;stroke:#000000;stroke-width:" << line_width <<
"px";
134class PrefAdjustment :
public Gtk::Adjustment {
143 Gtk::Adjustment(0.0, 0.0, 10.0, 0.1), _ext(ext), _pref(pref) {
145 this->signal_value_changed().connect(sigc::mem_fun(*
this, &PrefAdjustment::val_changed));
159PrefAdjustment::val_changed ()
179 if (!selected.empty()) {
180 first_select = selected.front()->getRepr();
183 return module->autogui(current_document, first_select, changeSignal);
193 "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI
"\">\n"
194 "<name>" N_(
"Grid")
"</name>\n"
195 "<id>org.inkscape.effect.grid</id>\n"
196 "<param name=\"lineWidth\" gui-text=\"" N_(
"Line Width:")
"\" type=\"float\">1.0</param>\n"
197 "<param name=\"xspacing\" gui-text=\"" N_(
"Horizontal Spacing:")
"\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n"
198 "<param name=\"yspacing\" gui-text=\"" N_(
"Vertical Spacing:")
"\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n"
199 "<param name=\"xoffset\" gui-text=\"" N_(
"Horizontal Offset:")
"\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n"
200 "<param name=\"yoffset\" gui-text=\"" N_(
"Vertical Offset:")
"\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n"
202 "<object-type>all</object-type>\n"
204 "<submenu name=\"" N_(
"Render")
"\">\n"
205 "<submenu name=\"" N_(
"Grids")
"\" />\n"
208 "<menu-tip>" N_(
"Draw a path which is a grid")
"</menu-tip>\n"
210 "</inkscape-extension>\n", std::make_unique<Grid>());
Various geometrical calculations.
CPoint min() const
Get the corner of the rectangle with smallest coordinate values.
CPoint max() const
Get the corner of the rectangle with largest coordinate values.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
Effects are extensions that take a document and do something to it in place.
The object that is the basis for the Extension system.
double set_param_float(char const *name, double value)
Sets a parameter identified by name with the double in the parameter value.
double get_param_float(char const *name) const
Gets a float parameter identified by name with the double placed in value.
A cache for the document and this implementation.
void effect(Inkscape::Extension::Effect *module, ExecutionEnv *executionEnv, SPDesktop *desktop, Inkscape::Extension::Implementation::ImplementationDocumentCache *docCache) override
This actually draws the grid.
bool load(Inkscape::Extension::Extension *module) override
A function to allocated anything – just an example here.
Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, SPDesktop *desktop, sigc::signal< void()> *changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache *docCache) override
A function to get the preferences for the grid.
SPGroup * currentLayer() const
Returns current top layer.
SPItemRange items()
Returns a range of selected SPItems.
bool isEmpty()
Returns true if no items are selected.
Geom::OptRect visualBounds() const
Builder for SVG path strings.
PathString & moveTo(Geom::Coord x, Geom::Coord y)
PathString & lineTo(Geom::Coord x, Geom::Coord y)
The set of selected SPObjects for a given document and layer model.
Interface for refcounted XML nodes.
virtual void appendChild(Node *child)=0
Append a node as the last child of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
To do: update description of desktop.
Inkscape::Selection * getSelection() const
Inkscape::LayerManager & layerManager()
Geom::Affine const & doc2dt() const
Typed SVG document implementation.
Geom::OptRect preferredBounds() const
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
Geom::Scale getDocumentScale(bool computed=true) const
Returns document scale as defined by width/height (in pixels) and viewBox (real world to user-units).
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
A way to clear the N_ macro, which is defined as an inline function.
Editable view implementation.
void build_from_mem(gchar const *buffer, std::unique_ptr< Implementation::Implementation > in_imp)
Create a module from a buffer holding an XML description.
static R & release(R &r)
Decrements the reference count of a anchored object.
Helper class to stream background task notifications as a series of messages.
Inkscape::SVG::PathString - builder for SVG path strings.
Interface for XML documents.
virtual Node * createElement(char const *name)=0