summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4a211c5)
raw | patch | inline | side by side (parent: 4a211c5)
author | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 1 Sep 2008 15:45:39 +0000 (15:45 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 1 Sep 2008 15:45:39 +0000 (15:45 +0000) |
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index 6b98c17e5ece6fe3c51ab1890f2f4d663f2e882b..266c6a961e1cb76ab3dd16d36bfa371cf820e7f6 100644 (file)
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
}
}
+/* Create a single dot represented by a circle */
+void spdc_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state) {
+ g_return_if_fail(!strcmp(tool, "tools.freehand.pen") || !strcmp(tool, "tools.freehand.pencil"));
+
+ SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+ Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
+ repr->setAttribute("sodipodi:type", "arc");
+ SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
+ Inkscape::GC::release(repr);
+
+ /* apply the tool's current style */
+ sp_desktop_apply_style_tool(desktop, repr, tool, false);
+
+ /* find out stroke width (TODO: is there an easier way??) */
+ double stroke_width = 3.0;
+ gchar const *style_str = NULL;
+ style_str = repr->attribute("style");
+ if (style_str) {
+ SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT);
+ sp_style_merge_from_style_string(style, style_str);
+ stroke_width = style->stroke_width.computed;
+ style->stroke_width.computed = 0;
+ sp_style_unref(style);
+ }
+ /* unset stroke and set fill color to former stroke color */
+ gchar * str;
+ str = g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8);
+ repr->setAttribute("style", str);
+ g_free(str);
+
+ /* put the circle where the mouse click occurred and set the diameter to the
+ current stroke width, multiplied by the amount specified in the preferences */
+ NR::Matrix const i2d (sp_item_i2d_affine (item));
+ NR::Point pp = pt * i2d;
+ double rad = 0.5 * prefs_get_double_attribute(tool, "dot-size", 3.0);
+ if (event_state & GDK_MOD1_MASK) {
+ /* TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size
+ as specified in prefs. Very simple, but it might be sufficient in practice. If not,
+ we need to devise something more sophisticated. */
+ double s = g_random_double_range(-0.5, 0.5);
+ rad *= (1 + s);
+ }
+ if (event_state & GDK_SHIFT_MASK) {
+ // double the point size
+ rad *= 2;
+ }
+
+ sp_repr_set_svg_double (repr, "sodipodi:cx", pp[NR::X]);
+ sp_repr_set_svg_double (repr, "sodipodi:cy", pp[NR::Y]);
+ sp_repr_set_svg_double (repr, "sodipodi:rx", rad * stroke_width);
+ sp_repr_set_svg_double (repr, "sodipodi:ry", rad * stroke_width);
+ item->updateRepr();
+
+ sp_desktop_selection(desktop)->set(item);
+
+ desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating single dot"));
+ sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot"));
+}
/*
Local Variables:
diff --git a/src/draw-context.h b/src/draw-context.h
index 35f7659deddf2daf6ab1709922e7fca105d36ee8..42b270b823d2f1151b832cf88da81e25b94f52ce 100644 (file)
--- a/src/draw-context.h
+++ b/src/draw-context.h
void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, NR::Point const &o, guint state);
void spdc_endpoint_snap_free(SPEventContext const *ec, NR::Point &p, guint state);
void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item);
+void spdc_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state);
#endif
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 2d1a48d3aefdf388f5060cbfaac9031294878d19..12253632d450ccc10276d249de82fd5b7b7b795d 100644 (file)
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -465,7 +465,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
if (pc->npoints == 0) {
if (bevent.state & GDK_CONTROL_MASK) {
- freehand_create_single_dot(event_context, event_dt, "tools.freehand.pen", bevent.state);
+ spdc_create_single_dot(event_context, event_dt, "tools.freehand.pen", bevent.state);
ret = TRUE;
break;
}
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index cb1039119006983f3b3669cf02bced150d1c1f87..b6231f7cb16c9be9ef3a77eee2978dc20c3efb06 100644 (file)
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -241,7 +241,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
default:
/* Set first point of sequence */
if (bevent.state & GDK_CONTROL_MASK) {
- freehand_create_single_dot(event_context, from_2geom(p), "tools.freehand.pencil", bevent.state);
+ spdc_create_single_dot(event_context, from_2geom(p), "tools.freehand.pencil", bevent.state);
ret = true;
break;
}
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index 427a7d6cf14c89a45d1aeb54503417895cfcdd50..731ecce647e0004134198db006d511abf4115398 100644 (file)
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
}
}
-/* Create a single dot represented by a circle */
-void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state) {
- g_return_if_fail(!strcmp(tool, "tools.freehand.pen") || !strcmp(tool, "tools.freehand.pencil"));
-
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec);
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
- Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
- repr->setAttribute("sodipodi:type", "arc");
- SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
- Inkscape::GC::release(repr);
-
- /* apply the tool's current style */
- sp_desktop_apply_style_tool(desktop, repr, tool, false);
-
- /* find out stroke width (TODO: is there an easier way??) */
- double stroke_width = 3.0;
- gchar const *style_str = NULL;
- style_str = repr->attribute("style");
- if (style_str) {
- SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT);
- sp_style_merge_from_style_string(style, style_str);
- stroke_width = style->stroke_width.computed;
- style->stroke_width.computed = 0;
- sp_style_unref(style);
- }
- /* unset stroke and set fill color to former stroke color */
- gchar * str;
- str = g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8);
- repr->setAttribute("style", str);
- g_free(str);
-
- /* put the circle where the mouse click occurred and set the diameter to the
- current stroke width, multiplied by the amount specified in the preferences */
- NR::Matrix const i2d (sp_item_i2d_affine (item));
- NR::Point pp = pt * i2d;
- double rad = 0.5 * prefs_get_double_attribute(tool, "dot-size", 3.0);
- if (event_state & GDK_MOD1_MASK) {
- /* TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size
- as specified in prefs. Very simple, but it might be sufficient in practice. If not,
- we need to devise something more sophisticated. */
- double s = g_random_double_range(-0.5, 0.5);
- rad *= (1 + s);
- }
- if (event_state & GDK_SHIFT_MASK) {
- // double the point size
- rad *= 2;
- }
-
- sp_repr_set_svg_double (repr, "sodipodi:cx", pp[NR::X]);
- sp_repr_set_svg_double (repr, "sodipodi:cy", pp[NR::Y]);
- sp_repr_set_svg_double (repr, "sodipodi:rx", rad * stroke_width);
- sp_repr_set_svg_double (repr, "sodipodi:ry", rad * stroke_width);
- item->updateRepr();
-
- sp_desktop_selection(desktop)->set(item);
-
- desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating single dot"));
- sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot"));
-}
-
/*
Local Variables:
mode:c++
diff --git a/src/sp-path.h b/src/sp-path.h
index 27e09c704d50e8681a760883c30e5e19846b9aec..bf294c37ceebedf980d5af97eae31be309292e27 100644 (file)
--- a/src/sp-path.h
+++ b/src/sp-path.h
SPCurve* sp_path_get_curve_for_edit (SPPath *path);
const SPCurve* sp_path_get_curve_reference (SPPath *path);
-void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state);
-
#endif
/*