summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2015-04-26 09:46:39 +0000
committerMarc Jeanmougin <mc@M0nst3r.bouyguesbox.fr>2015-04-26 09:46:39 +0000
commitac6617a55b9f7c05db084eeaa5684fb42d5e1406 (patch)
tree1fc8e668890618463d48298074559c7fe6bc5040 /src/ui
parentmerge (diff)
parentextensions. ink2canvas.py - do not parse html comments. (Bug 1446204) (diff)
downloadinkscape-ac6617a55b9f7c05db084eeaa5684fb42d5e1406.tar.gz
inkscape-ac6617a55b9f7c05db084eeaa5684fb42d5e1406.zip
merging
(bzr r13922.1.13)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/CMakeLists.txt29
-rw-r--r--src/ui/dialog/document-properties.cpp5
-rw-r--r--src/ui/dialog/filedialogimpl-win32.cpp8
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp2
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp4
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.cpp8
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.h6
-rw-r--r--src/ui/dialog/print.cpp21
-rw-r--r--src/ui/object-edit.cpp96
-rw-r--r--src/ui/tool/curve-drag-point.cpp4
-rw-r--r--src/ui/tool/multi-path-manipulator.h2
-rw-r--r--src/ui/tool/node.cpp103
-rw-r--r--src/ui/tool/path-manipulator.cpp142
-rw-r--r--src/ui/tool/path-manipulator.h12
-rw-r--r--src/ui/tools/box3d-tool.h2
-rw-r--r--src/ui/tools/connector-tool.cpp2
-rw-r--r--src/ui/tools/dynamic-base.h2
-rw-r--r--src/ui/tools/flood-tool.cpp54
-rw-r--r--src/ui/tools/flood-tool.h6
-rw-r--r--src/ui/tools/freehand-base.cpp12
-rw-r--r--src/ui/tools/freehand-base.h2
-rw-r--r--src/ui/tools/gradient-tool.cpp2
-rw-r--r--src/ui/tools/mesh-tool.cpp16
-rw-r--r--src/ui/tools/node-tool.cpp2
-rw-r--r--src/ui/tools/pen-tool.cpp411
-rw-r--r--src/ui/tools/pen-tool.h28
-rw-r--r--src/ui/tools/pencil-tool.cpp22
-rw-r--r--src/ui/tools/spray-tool.cpp68
-rw-r--r--src/ui/widget/page-sizer.cpp242
-rw-r--r--src/ui/widget/page-sizer.h40
-rw-r--r--src/ui/widget/selected-style.cpp4
31 files changed, 818 insertions, 539 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 674254686..991d11feb 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -1,11 +1,10 @@
-
set(ui_SRC
clipboard.cpp
control-manager.cpp
dialog-events.cpp
draw-anchor.cpp
- interface.cpp
- object-edit.cpp
+ interface.cpp
+ object-edit.cpp
previewholder.cpp
shape-editor.cpp
tool-factory.cpp
@@ -56,8 +55,8 @@ set(ui_SRC
dialog/aboutbox.cpp
dialog/align-and-distribute.cpp
dialog/calligraphic-profile-rename.cpp
- dialog/color-item.cpp
dialog/clonetiler.cpp
+ dialog/color-item.cpp
dialog/debug.cpp
dialog/desktop-tracker.cpp
dialog/dialog-manager.cpp
@@ -86,31 +85,36 @@ set(ui_SRC
dialog/livepatheffect-add.cpp
dialog/livepatheffect-editor.cpp
dialog/lpe-fillet-chamfer-properties.cpp
+ dialog/lpe-powerstroke-properties.cpp
dialog/memory.cpp
dialog/messages.cpp
dialog/new-from-template.cpp
dialog/object-attributes.cpp
dialog/object-properties.cpp
+ dialog/objects.cpp
dialog/ocaldialogs.cpp
+ dialog/pixelartdialog.cpp
dialog/polar-arrange-tab.cpp
dialog/print-colors-preview-dialog.cpp
dialog/print.cpp
- dialog/symbols.cpp
- dialog/xml-tree.cpp
dialog/spellcheck.cpp
dialog/svg-fonts-dialog.cpp
dialog/swatches.cpp
+ dialog/symbols.cpp
+ dialog/tags.cpp
dialog/template-load-tab.cpp
dialog/template-widget.cpp
dialog/text-edit.cpp
dialog/tile.cpp
dialog/tracedialog.cpp
- dialog/pixelartdialog.cpp
dialog/transformation.cpp
dialog/undo-history.cpp
+ dialog/xml-tree.cpp
+ widget/addtoicon.cpp
widget/anchor-selector.cpp
widget/button.cpp
+ widget/clipmaskicon.cpp
widget/color-picker.cpp
widget/color-preview.cpp
widget/dock-item.cpp
@@ -121,10 +125,13 @@ set(ui_SRC
widget/frame.cpp
widget/gimpcolorwheel.c
widget/gimpspinscale.c
+ widget/highlight-picker.cpp
widget/imageicon.cpp
widget/imagetoggler.cpp
+ widget/insertordericon.cpp
widget/labelled.cpp
widget/layer-selector.cpp
+ widget/layertypeicon.cpp
widget/licensor.cpp
widget/notebook-page.cpp
widget/object-composite-settings.cpp
@@ -179,8 +186,8 @@ set(ui_SRC
dialog/arrange-tab.h
dialog/behavior.h
dialog/calligraphic-profile-rename.h
- dialog/color-item.h
dialog/clonetiler.h
+ dialog/color-item.h
dialog/debug.h
dialog/desktop-tracker.h
dialog/dialog-manager.h
@@ -200,8 +207,8 @@ set(ui_SRC
dialog/floating-behavior.h
dialog/font-substitution.h
dialog/glyphs.h
- dialog/guides.h
dialog/grid-arrange-tab.h
+ dialog/guides.h
dialog/icon-preview.h
dialog/inkscape-preferences.h
dialog/input.h
@@ -215,13 +222,13 @@ set(ui_SRC
dialog/new-from-template.h
dialog/object-attributes.h
dialog/object-properties.h
+ dialog/objects.h
dialog/ocaldialogs.h
dialog/panel-dialog.h
- dialog/polar-arrange-tab.h
dialog/pixelartdialog.h
+ dialog/polar-arrange-tab.h
dialog/print-colors-preview-dialog.h
dialog/print.h
-
dialog/spellcheck.h
dialog/svg-fonts-dialog.h
dialog/swatches.h
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index f324f285d..c381ed755 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -1473,6 +1473,7 @@ void DocumentProperties::update()
}
_page_sizer.setDim(Inkscape::Util::Quantity(doc_w, doc_w_unit), Inkscape::Util::Quantity(doc_h, doc_h_unit));
_page_sizer.updateFitMarginsUI(nv->getRepr());
+ _page_sizer.updateScaleUI();
//-----------------------------------------------------------guide page
@@ -1655,6 +1656,8 @@ void DocumentProperties::onRemoveGrid()
}
/** Callback for document unit change. */
+/* This should not effect anything in the SVG tree (other than "inkscape:document-units").
+ This should only effect values displayed in the GUI. */
void DocumentProperties::onDocUnitChange()
{
SPDocument *doc = SP_ACTIVE_DOCUMENT;
@@ -1680,6 +1683,8 @@ void DocumentProperties::onDocUnitChange()
os << doc_unit->abbr;
repr->setAttribute("inkscape:document-units", os.str().c_str());
+ _page_sizer.updateScaleUI();
+
// Disable changing of SVG Units. The intent here is to change the units in the UI, not the units in SVG.
// This code should be moved (and fixed) once we have an "SVG Units" setting that sets what units are used in SVG data.
#if 0
diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp
index 34339dab2..cafc3be4f 100644
--- a/src/ui/dialog/filedialogimpl-win32.cpp
+++ b/src/ui/dialog/filedialogimpl-win32.cpp
@@ -44,6 +44,7 @@
#include "filedialog.h"
#include "sp-root.h"
+#include "preferences.h"
#include <zlib.h>
#include <cairomm/win32_surface.h>
@@ -272,6 +273,9 @@ void FileOpenDialogImplWin32::createFilterMenu()
}
if (dialogType != EXE_TYPES) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _show_preview = prefs->getBool("/dialogs/open/enable_preview", true);
+
// Compose the filter string
Inkscape::Extension::DB::InputList extension_list;
Inkscape::Extension::db.get_input_list(extension_list);
@@ -842,6 +846,10 @@ LRESULT CALLBACK FileOpenDialogImplWin32::preview_wnd_proc(HWND hwnd, UINT uMsg,
void FileOpenDialogImplWin32::enable_preview(bool enable)
{
+ if (_show_preview != enable) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/dialogs/open/enable_preview", enable);
+ }
_show_preview = enable;
// Relayout the dialog
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index cb2771503..f81519ed1 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -211,7 +211,7 @@ private:
ComboBoxEnum<T>* combo;
};
-// Contains an arbitrary number of spin buttons that use seperate attributes
+// Contains an arbitrary number of spin buttons that use separate attributes
class MultiSpinButton : public Gtk::HBox
{
public:
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 9f86158aa..3b0731953 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -529,14 +529,14 @@ void InkscapePreferences::initPageUI()
_("English/Canada (en_CA)"), _("English/Great Britain (en_GB)"), _("Pig Latin (en_US@piglatin)"),
_("Esperanto (eo)"), _("Estonian (et)"), _("Farsi (fa)"), _("Finnish (fi)"),
_("French (fr)"), _("Irish (ga)"), _("Galician (gl)"), _("Hebrew (he)"), _("Hungarian (hu)"),
- _("Indonesian (id)"), _("Italian (it)"), _("Japanese (ja)"), _("Khmer (km)"), _("Kinyarwanda (rw)"), _("Korean (ko)"), _("Lithuanian (lt)"), _("Latvian (lv)"), _("Macedonian (mk)"),
+ _("Indonesian (id)"), _("Icelandic (is)"), _("Italian (it)"), _("Japanese (ja)"), _("Khmer (km)"), _("Kinyarwanda (rw)"), _("Korean (ko)"), _("Lithuanian (lt)"), _("Latvian (lv)"), _("Macedonian (mk)"),
_("Mongolian (mn)"), _("Nepali (ne)"), _("Norwegian Bokmål (nb)"), _("Norwegian Nynorsk (nn)"), _("Panjabi (pa)"),
_("Polish (pl)"), _("Portuguese (pt)"), _("Portuguese/Brazil (pt_BR)"), _("Romanian (ro)"), _("Russian (ru)"),
_("Serbian (sr)"), _("Serbian in Latin script (sr@latin)"), _("Slovak (sk)"), _("Slovenian (sl)"), _("Spanish (es)"), _("Spanish/Mexico (es_MX)"),
_("Swedish (sv)"),_("Telugu (te)"), _("Thai (th)"), _("Turkish (tr)"), _("Ukrainian (uk)"), _("Vietnamese (vi)")};
Glib::ustring langValues[] = {"", "sq", "am", "ar", "hy", "az", "eu", "be", "bg", "bn", "bn_BD", "br", "ca", "ca@valencia", "zh_CN", "zh_TW", "hr", "cs", "da", "nl",
"dz", "de", "el", "en", "en_AU", "en_CA", "en_GB", "en_US@piglatin", "eo", "et", "fa", "fi", "fr", "ga",
- "gl", "he", "hu", "id", "it", "ja", "km", "rw", "ko", "lt", "lv", "mk", "mn", "ne", "nb", "nn", "pa",
+ "gl", "he", "hu", "id", "is", "it", "ja", "km", "rw", "ko", "lt", "lv", "mk", "mn", "ne", "nb", "nn", "pa",
"pl", "pt", "pt_BR", "ro", "ru", "sr", "sr@latin", "sk", "sl", "es", "es_MX", "sv", "te", "th", "tr", "uk", "vi" };
{
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
index b318933a7..7e5c17133 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
@@ -129,7 +129,7 @@ void FilletChamferPropertiesDialog::showDialog(
const gchar *unit,
bool use_distance,
bool aprox_radius,
- Glib::ustring const * documentUnit)
+ Glib::ustring documentUnit)
{
FilletChamferPropertiesDialog *dialog = new FilletChamferPropertiesDialog();
@@ -172,7 +172,7 @@ void FilletChamferPropertiesDialog::_apply()
}
d_pos = _index + (d_pos / 100);
} else {
- d_pos = Inkscape::Util::Quantity::convert(d_pos, unit, *document_unit);
+ d_pos = Inkscape::Util::Quantity::convert(d_pos, unit, document_unit);
d_pos = d_pos * -1;
}
_knotpoint->knot_set_offset(Geom::Point(d_pos, d_width));
@@ -226,7 +226,7 @@ void FilletChamferPropertiesDialog::_set_knot_point(Geom::Point knotpoint)
_fillet_chamfer_position_label.set_label(_(posConcat.c_str()));
position = knotpoint[Geom::X] * -1;
- position = Inkscape::Util::Quantity::convert(position, *document_unit, unit);
+ position = Inkscape::Util::Quantity::convert(position, document_unit, unit);
}
_fillet_chamfer_position_numeric.set_value(position);
if (knotpoint.y() == 1) {
@@ -256,7 +256,7 @@ void FilletChamferPropertiesDialog::_set_unit(const gchar *abbr)
unit = abbr;
}
-void FilletChamferPropertiesDialog::_set_document_unit(Glib::ustring const *abbr)
+void FilletChamferPropertiesDialog::_set_document_unit(Glib::ustring abbr)
{
document_unit = abbr;
}
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h
index 3807e98c8..870a1734f 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.h
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h
@@ -33,7 +33,7 @@ public:
const gchar *unit,
bool use_distance,
bool aprox_radius,
- Glib::ustring const * documentUnit);
+ Glib::ustring documentUnit);
protected:
@@ -69,14 +69,14 @@ protected:
void _set_pt(const Inkscape::LivePathEffect::
FilletChamferPointArrayParamKnotHolderEntity *pt);
void _set_unit(const gchar *abbr);
- void _set_document_unit(Glib::ustring const * abbr);
+ void _set_document_unit(Glib::ustring abbr);
void _set_use_distance(bool use_knot_distance);
void _set_aprox(bool aprox_radius);
void _apply();
void _close();
bool _flexible;
const gchar *unit;
- Glib::ustring const * document_unit;
+ Glib::ustring document_unit;
bool use_distance;
bool aprox;
void _set_knot_point(Geom::Point knotpoint);
diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp
index 351971294..c44d645a5 100644
--- a/src/ui/dialog/print.cpp
+++ b/src/ui/dialog/print.cpp
@@ -126,30 +126,13 @@ static void draw_page(
cairo_surface_t *surface = cairo_get_target(cr);
cairo_matrix_t ctm;
cairo_get_matrix(cr, &ctm);
-#ifdef WIN32
- //Gtk+ does not take the non printable area into account
- //http://bugzilla.gnome.org/show_bug.cgi?id=381371
- //
- // This workaround translates the origin from the top left of the
- // printable area to the top left of the page.
- GtkPrintSettings *settings = gtk_print_operation_get_print_settings(operation);
- const gchar *printerName = gtk_print_settings_get_printer(settings);
- HDC hdc = CreateDC("WINSPOOL", printerName, NULL, NULL);
- if (hdc) {
- cairo_matrix_t mat;
- int x_off = GetDeviceCaps (hdc, PHYSICALOFFSETX);
- int y_off = GetDeviceCaps (hdc, PHYSICALOFFSETY);
- cairo_matrix_init_translate(&mat, -x_off, -y_off);
- cairo_matrix_multiply (&ctm, &ctm, &mat);
- DeleteDC(hdc);
- }
-#endif
+
bool ret = ctx->setSurfaceTarget (surface, true, &ctm);
if (ret) {
ret = renderer.setupDocument (ctx, junk->_doc, TRUE, 0., NULL);
if (ret) {
renderer.renderItem(ctx, junk->_base);
- ret = ctx->finish();
+ ctx->finish();
}
else {
g_warning("%s", _("Could not set up Document"));
diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp
index c3bc2d52c..0a6c792dc 100644
--- a/src/ui/object-edit.cpp
+++ b/src/ui/object-edit.cpp
@@ -154,12 +154,9 @@ RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*orig
if (state & GDK_CONTROL_MASK) {
gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
- rect->rx.computed = rect->ry.computed = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, temp);
- rect->rx._set = rect->ry._set = true;
-
+ rect->rx = rect->ry = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, temp);
} else {
- rect->rx.computed = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, rect->width.computed / 2.0);
- rect->rx._set = true;
+ rect->rx = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, rect->width.computed / 2.0);
}
update_knot();
@@ -207,20 +204,17 @@ RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*orig
if (state & GDK_CONTROL_MASK) { // When holding control then rx will be kept equal to ry,
// resulting in a perfect circle (and not an ellipse)
gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
- rect->rx.computed = rect->ry.computed = CLAMP(s[Geom::Y] - rect->y.computed, 0.0, temp);
- rect->ry._set = rect->rx._set = true;
+ rect->rx = rect->ry = CLAMP(s[Geom::Y] - rect->y.computed, 0.0, temp);
} else {
if (!rect->rx._set || rect->rx.computed == 0) {
- rect->ry.computed = CLAMP(s[Geom::Y] - rect->y.computed,
- 0.0,
- MIN(rect->height.computed / 2.0, rect->width.computed / 2.0));
+ rect->ry = CLAMP(s[Geom::Y] - rect->y.computed,
+ 0.0,
+ MIN(rect->height.computed / 2.0, rect->width.computed / 2.0));
} else {
- rect->ry.computed = CLAMP(s[Geom::Y] - rect->y.computed,
- 0.0,
- rect->height.computed / 2.0);
+ rect->ry = CLAMP(s[Geom::Y] - rect->y.computed,
+ 0.0,
+ rect->height.computed / 2.0);
}
-
- rect->ry._set = true;
}
update_knot();
@@ -250,12 +244,10 @@ static void sp_rect_clamp_radii(SPRect *rect)
{
// clamp rounding radii so that they do not exceed width/height
if (2 * rect->rx.computed > rect->width.computed) {
- rect->rx.computed = 0.5 * rect->width.computed;
- rect->rx._set = true;
+ rect->rx = 0.5 * rect->width.computed;
}
if (2 * rect->ry.computed > rect->height.computed) {
- rect->ry.computed = 0.5 * rect->height.computed;
- rect->ry._set = true;
+ rect->ry = 0.5 * rect->height.computed;
}
}
@@ -298,16 +290,16 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or
minx = s[Geom::X] - origin[Geom::X];
// Dead assignment: Value stored to 'miny' is never read
//miny = s[Geom::Y] - origin[Geom::Y];
- rect->height.computed = MAX(h_orig + minx / ratio, 0);
+ rect->height = MAX(h_orig + minx / ratio, 0);
} else {
// closer to the horizontal, change only width, height is h_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state);
minx = s[Geom::X] - origin[Geom::X];
// Dead assignment: Value stored to 'miny' is never read
//miny = s[Geom::Y] - origin[Geom::Y];
- rect->height.computed = MAX(h_orig, 0);
+ rect->height = MAX(h_orig, 0);
}
- rect->width.computed = MAX(w_orig + minx, 0);
+ rect->width = MAX(w_orig + minx, 0);
} else {
// snap to vertical or diagonal
@@ -317,27 +309,24 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or
// Dead assignment: Value stored to 'minx' is never read
//minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->width.computed = MAX(w_orig + miny * ratio, 0);
+ rect->width = MAX(w_orig + miny * ratio, 0);
} else {
// closer to the vertical, change only height, width is w_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state);
// Dead assignment: Value stored to 'minx' is never read
//minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->width.computed = MAX(w_orig, 0);
+ rect->width = MAX(w_orig, 0);
}
- rect->height.computed = MAX(h_orig + miny, 0);
+ rect->height = MAX(h_orig + miny, 0);
}
- rect->width._set = rect->height._set = true;
-
} else {
// move freely
s = snap_knot_position(p, state);
- rect->width.computed = MAX(s[Geom::X] - rect->x.computed, 0);
- rect->height.computed = MAX(s[Geom::Y] - rect->y.computed, 0);
- rect->width._set = rect->height._set = true;
+ rect->width = MAX(s[Geom::X] - rect->x.computed, 0);
+ rect->height = MAX(s[Geom::Y] - rect->y.computed, 0);
}
sp_rect_clamp_radii(rect);
@@ -394,19 +383,19 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
minx = s[Geom::X] - origin[Geom::X];
// Dead assignment: Value stored to 'miny' is never read
//miny = s[Geom::Y] - origin[Geom::Y];
- rect->y.computed = MIN(origin[Geom::Y] + minx / ratio, opposite_y);
- rect->height.computed = MAX(h_orig - minx / ratio, 0);
+ rect->y = MIN(origin[Geom::Y] + minx / ratio, opposite_y);
+ rect->height = MAX(h_orig - minx / ratio, 0);
} else {
// closer to the horizontal, change only width, height is h_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state);
minx = s[Geom::X] - origin[Geom::X];
// Dead assignment: Value stored to 'miny' is never read
//miny = s[Geom::Y] - origin[Geom::Y];
- rect->y.computed = MIN(origin[Geom::Y], opposite_y);
- rect->height.computed = MAX(h_orig, 0);
+ rect->y = MIN(origin[Geom::Y], opposite_y);
+ rect->height = MAX(h_orig, 0);
}
- rect->x.computed = MIN(s[Geom::X], opposite_x);
- rect->width.computed = MAX(w_orig - minx, 0);
+ rect->x = MIN(s[Geom::X], opposite_x);
+ rect->width = MAX(w_orig - minx, 0);
} else {
// snap to vertical or diagonal
if (miny != 0 && fabs(minx/miny) > 0.5 *ratio && (SGN(minx) == SGN(miny))) {
@@ -415,34 +404,31 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
// Dead assignment: Value stored to 'minx' is never read
//minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->x.computed = MIN(origin[Geom::X] + miny * ratio, opposite_x);
- rect->width.computed = MAX(w_orig - miny * ratio, 0);
+ rect->x = MIN(origin[Geom::X] + miny * ratio, opposite_x);
+ rect->width = MAX(w_orig - miny * ratio, 0);
} else {
// closer to the vertical, change only height, width is w_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state);
// Dead assignment: Value stored to 'minx' is never read
//minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->x.computed = MIN(origin[Geom::X], opposite_x);
- rect->width.computed = MAX(w_orig, 0);
+ rect->x = MIN(origin[Geom::X], opposite_x);
+ rect->width = MAX(w_orig, 0);
}
- rect->y.computed = MIN(s[Geom::Y], opposite_y);
- rect->height.computed = MAX(h_orig - miny, 0);
+ rect->y = MIN(s[Geom::Y], opposite_y);
+ rect->height = MAX(h_orig - miny, 0);
}
- rect->width._set = rect->height._set = rect->x._set = rect->y._set = true;
-
} else {
// move freely
s = snap_knot_position(p, state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->x.computed = MIN(s[Geom::X], opposite_x);
- rect->width.computed = MAX(w_orig - minx, 0);
- rect->y.computed = MIN(s[Geom::Y], opposite_y);
- rect->height.computed = MAX(h_orig - miny, 0);
- rect->width._set = rect->height._set = rect->x._set = rect->y._set = true;
+ rect->x = MIN(s[Geom::X], opposite_x);
+ rect->y = MIN(s[Geom::Y], opposite_y);
+ rect->width = MAX(w_orig - minx, 0);
+ rect->height = MAX(h_orig - miny, 0);
}
sp_rect_clamp_radii(rect);
@@ -917,10 +903,10 @@ ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origi
Geom::Point const s = snap_knot_position(p, state);
- ge->rx.computed = fabs( ge->cx.computed - s[Geom::X] );
+ ge->rx = fabs( ge->cx.computed - s[Geom::X] );
if ( state & GDK_CONTROL_MASK ) {
- ge->ry.computed = ge->rx.computed;
+ ge->ry = ge->rx.computed;
}
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -942,7 +928,7 @@ ArcKnotHolderEntityRX::knot_click(unsigned int state)
g_assert(ge != NULL);
if (state & GDK_CONTROL_MASK) {
- ge->ry.computed = ge->rx.computed;
+ ge->ry = ge->rx.computed;
ge->updateRepr();
}
}
@@ -955,10 +941,10 @@ ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origi
Geom::Point const s = snap_knot_position(p, state);
- ge->ry.computed = fabs( ge->cy.computed - s[Geom::Y] );
+ ge->ry = fabs( ge->cy.computed - s[Geom::Y] );
if ( state & GDK_CONTROL_MASK ) {
- ge->rx.computed = ge->ry.computed;
+ ge->rx = ge->ry.computed;
}
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -980,7 +966,7 @@ ArcKnotHolderEntityRY::knot_click(unsigned int state)
g_assert(ge != NULL);
if (state & GDK_CONTROL_MASK) {
- ge->rx.computed = ge->ry.computed;
+ ge->rx = ge->ry.computed;
ge->updateRepr();
}
}
diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp
index 49c949107..23640456e 100644
--- a/src/ui/tool/curve-drag-point.cpp
+++ b/src/ui/tool/curve-drag-point.cpp
@@ -54,7 +54,7 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/)
// delta is a vector equal 1/3 of distance from first to second
Geom::Point delta = (second->position() - first->position()) / 3.0;
// only update the nodes if the mode is bspline
- if(!_pm.isBSpline(false)){
+ if(!_pm._isBSpline()){
first->front()->move(first->front()->position() + delta);
second->back()->move(second->back()->position() - delta);
}
@@ -91,7 +91,7 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event)
Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta;
//modified so that, if the trace is bspline, it only acts if the SHIFT key is pressed
- if(!_pm.isBSpline(false)){
+ if(!_pm._isBSpline()){
first->front()->move(first->front()->position() + offset0);
second->back()->move(second->back()->position() + offset1);
}else if(weight>=0.8){
diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h
index cdbf34e9d..1bbcdd7ec 100644
--- a/src/ui/tool/multi-path-manipulator.h
+++ b/src/ui/tool/multi-path-manipulator.h
@@ -39,7 +39,7 @@ public:
virtual bool event(Inkscape::UI::Tools::ToolBase *, GdkEvent *event);
bool empty() { return _mmap.empty(); }
- unsigned size() { return _mmap.empty(); }
+ unsigned size() { return _mmap.size(); }
void setItems(std::set<ShapeRecord> const &);
void clear() { _mmap.clear(); }
void cleanup();
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index eeea47e4d..aa5365265 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -175,9 +175,9 @@ void Handle::move(Geom::Point const &new_pos)
setPosition(new_pos);
//move the handler and its oposite the same proportion
- if(_pm().isBSpline()){
- setPosition(_pm().BSplineHandleReposition(this,this));
- this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this));
+ if(_pm()._isBSpline()){
+ setPosition(_pm()._bsplineHandleReposition(this,this));
+ this->other()->setPosition(_pm()._bsplineHandleReposition(this->other(),this));
}
return;
}
@@ -192,9 +192,9 @@ void Handle::move(Geom::Point const &new_pos)
setRelativePos(new_delta);
//move the handler and its oposite the same proportion
- if(_pm().isBSpline()){
- setPosition(_pm().BSplineHandleReposition(this,this));
- this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this));
+ if(_pm()._isBSpline()){
+ setPosition(_pm()._bsplineHandleReposition(this,this));
+ this->other()->setPosition(_pm()._bsplineHandleReposition(this->other(),this));
}
return;
@@ -218,11 +218,10 @@ void Handle::move(Geom::Point const &new_pos)
setPosition(new_pos);
// moves the handler and its oposite the same proportion
- if(_pm().isBSpline()){
- setPosition(_pm().BSplineHandleReposition(this,this));
- this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this));
+ if(_pm()._isBSpline()){
+ setPosition(_pm()._bsplineHandleReposition(this,this));
+ this->other()->setPosition(_pm()._bsplineHandleReposition(this->other(),this));
}
-
}
void Handle::setPosition(Geom::Point const &p)
@@ -313,9 +312,9 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven
//this function moves the handler and its oposite to the default proportion of defaultStartPower
void Handle::handle_2button_press(){
- if(_pm().isBSpline()){
- setPosition(_pm().BSplineHandleReposition(this,defaultStartPower));
- this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),defaultStartPower));
+ if(_pm()._isBSpline()){
+ setPosition(_pm()._bsplineHandleReposition(this,defaultStartPower));
+ this->other()->setPosition(_pm()._bsplineHandleReposition(this->other(),defaultStartPower));
_pm().update();
}
}
@@ -373,16 +372,16 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
new_pos = result;
// moves the handler and its oposite in X fixed positions depending on parameter "steps with control"
// by default in live BSpline
- if(_pm().isBSpline()){
+ if(_pm()._isBSpline()){
setPosition(new_pos);
- int steps = _pm().BSplineGetSteps();
- new_pos=_pm().BSplineHandleReposition(this,ceilf(_pm().BSplineHandlePosition(this,this)*steps)/steps);
+ int steps = _pm()._bsplineGetSteps();
+ new_pos=_pm()._bsplineHandleReposition(this,ceilf(_pm()._bsplineHandlePosition(this,this)*steps)/steps);
}
}
std::vector<Inkscape::SnapCandidatePoint> unselected;
//if the snap adjustment is activated and it is not bspline
- if (snap && !_pm().isBSpline(false)) {
+ if (snap && !_pm()._isBSpline()) {
ControlPointSelection::Set &nodes = _parent->_selection.allPoints();
for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) {
Node *n = static_cast<Node*>(*i);
@@ -423,7 +422,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
}
}
//if it is bspline but SHIFT or CONTROL are not pressed it fixes it in the original position
- if(_pm().isBSpline() && !held_shift(*event) && !held_control(*event)){
+ if(_pm()._isBSpline() && !held_shift(*event) && !held_control(*event)){
new_pos=_last_drag_origin();
}
move(new_pos); // needed for correct update, even though it's redundant
@@ -486,8 +485,8 @@ Glib::ustring Handle::_getTip(unsigned state) const
char const *more;
// a trick to mark as bspline if the node has no strength, we are going to use it later
// to show the appropiate messages. We cannot do it in any different way becasue the function is constant
-
- bool isBSpline = _pm().isBSpline();
+ Handle *h = const_cast<Handle *>(this);
+ bool isBSpline = _pm()._isBSpline();
bool can_shift_rotate = _parent->type() == NODE_CUSP && !other()->isDegenerate();
if (can_shift_rotate && !isBSpline) {
more = C_("Path handle tip", "more: Shift, Ctrl, Alt");
@@ -550,7 +549,7 @@ Glib::ustring Handle::_getTip(unsigned state) const
"<b>Auto node handle</b>: drag to convert to smooth node (%s)"), more);
}else{
return format_tip(C_("Path handle tip",
- "<b>BSpline node handle</b>: Shift to drag, double click to reset (%s)"), more);
+ "<b>BSpline node handle</b>: Shift to drag, double click to reset (%s). %g power"),more,_pm()._bsplineHandlePosition(h,NULL));
}
}
}
@@ -634,15 +633,15 @@ void Node::move(Geom::Point const &new_pos)
Node *n = this;
Node * nextNode = n->nodeToward(n->front());
Node * prevNode = n->nodeToward(n->back());
- nodeWeight = fmax(_pm().BSplineHandlePosition(n->front()),_pm().BSplineHandlePosition(n->back()));
+ nodeWeight = fmax(_pm()._bsplineHandlePosition(n->front()),_pm()._bsplineHandlePosition(n->back()));
if(prevNode){
if(prevNode->isEndNode()){
- prevNodeWeight = _pm().BSplineHandlePosition(prevNode->front(),prevNode->front());
+ prevNodeWeight = _pm()._bsplineHandlePosition(prevNode->front(),prevNode->front());
}
}
if(nextNode){
if(nextNode->isEndNode()){
- nextNodeWeight = _pm().BSplineHandlePosition(nextNode->back(),nextNode->back());
+ nextNodeWeight = _pm()._bsplineHandlePosition(nextNode->back(),nextNode->back());
}
}
@@ -656,21 +655,21 @@ void Node::move(Geom::Point const &new_pos)
_fixNeighbors(old_pos, new_pos);
// move the affected handlers. First the node ones, later the adjoining ones.
- if(_pm().isBSpline()){
- _front.setPosition(_pm().BSplineHandleReposition(this->front(),nodeWeight));
- _back.setPosition(_pm().BSplineHandleReposition(this->back(),nodeWeight));
+ if(_pm()._isBSpline()){
+ _front.setPosition(_pm()._bsplineHandleReposition(this->front(),nodeWeight));
+ _back.setPosition(_pm()._bsplineHandleReposition(this->back(),nodeWeight));
if(prevNode){
if(prevNode->isEndNode()){
- prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNodeWeight));
+ prevNode->front()->setPosition(_pm()._bsplineHandleReposition(prevNode->front(),prevNodeWeight));
}else{
- prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNode->back()));
+ prevNode->front()->setPosition(_pm()._bsplineHandleReposition(prevNode->front(),prevNode->back()));
}
}
if(nextNode){
if(nextNode->isEndNode()){
- nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNodeWeight));
+ nextNode->back()->setPosition(_pm()._bsplineHandleReposition(nextNode->back(),nextNodeWeight));
}else{
- nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNode->front()));
+ nextNode->back()->setPosition(_pm()._bsplineHandleReposition(nextNode->back(),nextNode->front()));
}
}
}
@@ -688,15 +687,15 @@ void Node::transform(Geom::Affine const &m)
Node *n = this;
Node * nextNode = n->nodeToward(n->front());
Node * prevNode = n->nodeToward(n->back());
- nodeWeight = _pm().BSplineHandlePosition(n->front());
+ nodeWeight = _pm()._bsplineHandlePosition(n->front());
if(prevNode){
if(prevNode->isEndNode()){
- prevNodeWeight = _pm().BSplineHandlePosition(prevNode->front(),prevNode->front());
+ prevNodeWeight = _pm()._bsplineHandlePosition(prevNode->front(),prevNode->front());
}
}
if(nextNode){
if(nextNode->isEndNode()){
- nextNodeWeight = _pm().BSplineHandlePosition(nextNode->back(),nextNode->back());
+ nextNodeWeight = _pm()._bsplineHandlePosition(nextNode->back(),nextNode->back());
}
}
@@ -709,21 +708,21 @@ void Node::transform(Geom::Affine const &m)
_fixNeighbors(old_pos, position());
// move the involved handlers, first the node ones, later the adjoining ones
- if(_pm().isBSpline()){
- _front.setPosition(_pm().BSplineHandleReposition(this->front(),nodeWeight));
- _back.setPosition(_pm().BSplineHandleReposition(this->back(),nodeWeight));
+ if(_pm()._isBSpline()){
+ _front.setPosition(_pm()._bsplineHandleReposition(this->front(),nodeWeight));
+ _back.setPosition(_pm()._bsplineHandleReposition(this->back(),nodeWeight));
if(prevNode){
if(prevNode->isEndNode()){
- prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNodeWeight));
+ prevNode->front()->setPosition(_pm()._bsplineHandleReposition(prevNode->front(),prevNodeWeight));
}else{
- prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNode->back()));
+ prevNode->front()->setPosition(_pm()._bsplineHandleReposition(prevNode->front(),prevNode->back()));
}
}
if(nextNode){
if(nextNode->isEndNode()){
- nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNodeWeight));
+ nextNode->back()->setPosition(_pm()._bsplineHandleReposition(nextNode->back(),nextNodeWeight));
}else{
- nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNode->front()));
+ nextNode->back()->setPosition(_pm()._bsplineHandleReposition(nextNode->back(),nextNode->front()));
}
}
}
@@ -916,13 +915,13 @@ void Node::setType(NodeType type, bool update_handles)
}
/* in node type changes, about bspline traces, we can mantain them with noPower power in border mode,
or we give them the default power in curve mode */
- if(_pm().isBSpline()){
+ if(_pm()._isBSpline()){
double weight = noPower;
- if(_pm().BSplineHandlePosition(this->front()) != noPower ){
+ if(_pm()._bsplineHandlePosition(this->front()) != noPower ){
weight = defaultStartPower;
}
- _front.setPosition(_pm().BSplineHandleReposition(this->front(),weight));
- _back.setPosition(_pm().BSplineHandleReposition(this->back(),weight));
+ _front.setPosition(_pm()._bsplineHandleReposition(this->front(),weight));
+ _back.setPosition(_pm()._bsplineHandleReposition(this->back(),weight));
}
}
_type = type;
@@ -1172,9 +1171,9 @@ void Node::_setState(State state)
mgr.setActive(_canvas_item, true);
mgr.setPrelight(_canvas_item, false);
//this shows the handlers when selecting the nodes
- if(_pm().isBSpline()){
- this->front()->setPosition(_pm().BSplineHandleReposition(this->front()));
- this->back()->setPosition(_pm().BSplineHandleReposition(this->back()));
+ if(_pm()._isBSpline()){
+ this->front()->setPosition(_pm()._bsplineHandleReposition(this->front()));
+ this->back()->setPosition(_pm()._bsplineHandleReposition(this->back()));
}
break;
}
@@ -1434,7 +1433,9 @@ Node *Node::nodeAwayFrom(Handle *h)
Glib::ustring Node::_getTip(unsigned state) const
{
- bool isBSpline = _pm().isBSpline();
+ bool isBSpline = _pm()._isBSpline();
+ Handle *h = const_cast<Handle *>(&_front);
+ Handle *h2 = const_cast<Handle *>(&_back);
if (state_held_shift(state)) {
bool can_drag_out = (_next() && _front.isDegenerate()) || (_prev() && _back.isDegenerate());
if (can_drag_out) {
@@ -1469,7 +1470,7 @@ Glib::ustring Node::_getTip(unsigned state) const
"<b>%s</b>: drag to shape the path (more: Shift, Ctrl, Alt)"), nodetype);
}else if(_selection.size() == 1){
return format_tip(C_("Path node tip",
- "<b>BSpline node</b>: %g weight, drag to shape the path (more: Shift, Ctrl, Alt)"),noPower/*this->bsplineWeight*/);
+ "<b>BSpline node</b>: drag to shape the path (more: Shift, Ctrl, Alt). %g power"),_pm()._bsplineHandlePosition(h,h2));
}
return format_tip(C_("Path node tip",
"<b>%s</b>: drag to shape the path, click to toggle scale/rotation handles (more: Shift, Ctrl, Alt)"), nodetype);
@@ -1479,7 +1480,7 @@ Glib::ustring Node::_getTip(unsigned state) const
"<b>%s</b>: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)"), nodetype);
}else{
return format_tip(C_("Path node tip",
- "<b>BSpline node</b>: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)"));
+ "<b>BSpline node</b>: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt). %g power"),_pm()._bsplineHandlePosition(h,h2));
}
}
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index c8b986824..6b0c95f68 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -11,6 +11,7 @@
*/
#include "live_effects/lpe-powerstroke.h"
+#include "live_effects/lpe-bspline.h"
#include "live_effects/lpe-fillet-chamfer.h"
#include <string>
#include <sstream>
@@ -43,7 +44,6 @@
#include "ui/tool/multi-path-manipulator.h"
#include "xml/node.h"
#include "xml/node-observer.h"
-#include "live_effects/lpe-bspline.h"
namespace Inkscape {
namespace UI {
@@ -56,8 +56,8 @@ enum PathChange {
};
} // anonymous namespace
-const double handleCubicGap = 0.01;
-const double noPower = 0.0;
+const double HANDLE_CUBIC_GAP = 0.01;
+const double NO_POWER = 0.0;
const double defaultStartPower = 0.3334;
@@ -124,6 +124,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path,
, _show_path_direction(false)
, _live_outline(true)
, _live_objects(true)
+ , _is_bspline(false)
, _lpe_key(lpe_key)
{
if (_lpe_key.empty()) {
@@ -151,7 +152,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path,
_createControlPointsFromGeometry();
//Define if the path is BSpline on construction
- isBSpline(true);
+ _recalculateIsBSpline();
}
PathManipulator::~PathManipulator()
@@ -670,12 +671,12 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite
start = next;
}
// if we are removing, we readjust the handlers
- if(isBSpline()){
+ if(_isBSpline()){
if(start.prev()){
- start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front(),start.prev()->back()));
+ start.prev()->front()->setPosition(_bsplineHandleReposition(start.prev()->front(),start.prev()->back()));
}
if(end){
- end->back()->setPosition(BSplineHandleReposition(end->back(),end->front()));
+ end->back()->setPosition(_bsplineHandleReposition(end->back(),end->front()));
}
}
@@ -999,30 +1000,30 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d
// set new handle positions
Node *n = new Node(_multi_path_manipulator._path_data.node_data, seg2[0]);
- if(!isBSpline()){
+ if(!_isBSpline()){
n->back()->setPosition(seg1[2]);
n->front()->setPosition(seg2[1]);
n->setType(NODE_SMOOTH, false);
} else {
- Geom::D2< Geom::SBasis > SBasisInsideNodes;
- SPCurve *lineInsideNodes = new SPCurve();
+ Geom::D2< Geom::SBasis > sbasis_inside_nodes;
+ SPCurve *line_inside_nodes = new SPCurve();
if(second->back()->isDegenerate()){
- lineInsideNodes->moveto(n->position());
- lineInsideNodes->lineto(second->position());
- SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis();
- Geom::Point next = SBasisInsideNodes.valueAt(defaultStartPower);
- next = Geom::Point(next[Geom::X] + handleCubicGap,next[Geom::Y] + handleCubicGap);
- lineInsideNodes->reset();
+ line_inside_nodes->moveto(n->position());
+ line_inside_nodes->lineto(second->position());
+ sbasis_inside_nodes = line_inside_nodes->first_segment()->toSBasis();
+ Geom::Point next = sbasis_inside_nodes.valueAt(defaultStartPower);
+ next = Geom::Point(next[Geom::X] + HANDLE_CUBIC_GAP,next[Geom::Y] + HANDLE_CUBIC_GAP);
+ line_inside_nodes->reset();
n->front()->setPosition(next);
}else{
n->front()->setPosition(seg2[1]);
}
if(first->front()->isDegenerate()){
- lineInsideNodes->moveto(n->position());
- lineInsideNodes->lineto(first->position());
- SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis();
- Geom::Point previous = SBasisInsideNodes.valueAt(defaultStartPower);
- previous = Geom::Point(previous[Geom::X] + handleCubicGap,previous[Geom::Y] + handleCubicGap);
+ line_inside_nodes->moveto(n->position());
+ line_inside_nodes->lineto(first->position());
+ sbasis_inside_nodes = line_inside_nodes->first_segment()->toSBasis();
+ Geom::Point previous = sbasis_inside_nodes.valueAt(defaultStartPower);
+ previous = Geom::Point(previous[Geom::X] + HANDLE_CUBIC_GAP,previous[Geom::Y] + HANDLE_CUBIC_GAP);
n->back()->setPosition(previous);
}else{
n->back()->setPosition(seg1[2]);
@@ -1217,14 +1218,17 @@ void PathManipulator::_createControlPointsFromGeometry()
}
//determines if the trace has a bspline effect and the number of steps that it takes
-int PathManipulator::BSplineGetSteps() const {
+int PathManipulator::_bsplineGetSteps() const {
LivePathEffect::LPEBSpline const *lpe_bsp = NULL;
- if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()){
- Inkscape::LivePathEffect::Effect const *thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE);
- if(thisEffect){
- lpe_bsp = dynamic_cast<LivePathEffect::LPEBSpline const*>(thisEffect->getLPEObj()->get_lpe());
+ SPLPEItem * path = dynamic_cast<SPLPEItem *>(_path);
+ if (path){
+ if(path->hasPathEffect()){
+ Inkscape::LivePathEffect::Effect const *this_effect = path->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE);
+ if(this_effect){
+ lpe_bsp = dynamic_cast<LivePathEffect::LPEBSpline const*>(this_effect->getLPEObj()->get_lpe());
+ }
}
}
int steps = 0;
@@ -1235,66 +1239,72 @@ int PathManipulator::BSplineGetSteps() const {
}
// determines if the trace has bspline effect
-bool PathManipulator::isBSpline(bool recalculate){
- if(recalculate){
- _is_bspline = this->BSplineGetSteps() > 0;
+void PathManipulator::_recalculateIsBSpline(){
+ if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()) {
+ Inkscape::LivePathEffect::Effect const *this_effect = _path->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE);
+ if(this_effect){
+ _is_bspline = true;
+ return;
+ }
}
- return _is_bspline;
+ _is_bspline = false;
}
-bool PathManipulator::isBSpline() const {
- return BSplineGetSteps() > 0;
+bool PathManipulator::_isBSpline() const {
+ return _is_bspline;
}
// returns the corresponding strength to the position of the handlers
-double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){
+double PathManipulator::_bsplineHandlePosition(Handle *h, Handle *h2)
+{
using Geom::X;
using Geom::Y;
if(h2){
h = h2;
}
- double pos = noPower;
+ double pos = NO_POWER;
Node *n = h->parent();
- Node * nextNode = NULL;
- nextNode = n->nodeToward(h);
- if(nextNode){
- SPCurve *lineInsideNodes = new SPCurve();
- lineInsideNodes->moveto(n->position());
- lineInsideNodes->lineto(nextNode->position());
+ Node * next_node = NULL;
+ next_node = n->nodeToward(h);
+ if(next_node){
+ SPCurve *line_inside_nodes = new SPCurve();
+ line_inside_nodes->moveto(n->position());
+ line_inside_nodes->lineto(next_node->position());
if(!are_near(h->position(), n->position())){
- pos = Geom::nearest_point(Geom::Point(h->position()[X] - handleCubicGap, h->position()[Y] - handleCubicGap), *lineInsideNodes->first_segment());
+ pos = Geom::nearest_point(Geom::Point(h->position()[X] - HANDLE_CUBIC_GAP, h->position()[Y] - HANDLE_CUBIC_GAP), *line_inside_nodes->first_segment());
}
}
- if (pos == noPower && !h2){
- return BSplineHandlePosition(h, h->other());
+ if (pos == NO_POWER && !h2){
+ return _bsplineHandlePosition(h, h->other());
}
return pos;
}
// give the location for the handler in the corresponding position
-Geom::Point PathManipulator::BSplineHandleReposition(Handle *h, Handle *h2){
- double pos = this->BSplineHandlePosition(h, h2);
- return BSplineHandleReposition(h,pos);
+Geom::Point PathManipulator::_bsplineHandleReposition(Handle *h, Handle *h2)
+{
+ double pos = this->_bsplineHandlePosition(h, h2);
+ return _bsplineHandleReposition(h,pos);
}
// give the location for the handler to the specified position
-Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){
+Geom::Point PathManipulator::_bsplineHandleReposition(Handle *h,double pos){
using Geom::X;
using Geom::Y;
Geom::Point ret = h->position();
Node *n = h->parent();
- Geom::D2< Geom::SBasis > SBasisInsideNodes;
- SPCurve *lineInsideNodes = new SPCurve();
- Node * nextNode = NULL;
- nextNode = n->nodeToward(h);
- if(nextNode && pos != noPower){
- lineInsideNodes->moveto(n->position());
- lineInsideNodes->lineto(nextNode->position());
- SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis();
- ret = SBasisInsideNodes.valueAt(pos);
- ret = Geom::Point(ret[X] + handleCubicGap,ret[Y] + handleCubicGap);
+ Geom::D2< Geom::SBasis > sbasis_inside_nodes;
+ SPCurve *line_inside_nodes = new SPCurve();
+ Node * next_node = NULL;
+ next_node = n->nodeToward(h);
+ if(next_node && pos != NO_POWER){
+ line_inside_nodes->moveto(n->position());
+ line_inside_nodes->lineto(next_node->position());
+ sbasis_inside_nodes = line_inside_nodes->first_segment()->toSBasis();
+ ret = sbasis_inside_nodes.valueAt(pos);
+ ret = Geom::Point(ret[X] + HANDLE_CUBIC_GAP, ret[Y] + HANDLE_CUBIC_GAP);
}else{
- if(pos == noPower){
+ if(pos == NO_POWER){
ret = n->position();
}
}
@@ -1309,7 +1319,7 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE)
{
Geom::PathBuilder builder;
//Refresh if is bspline some times -think on path change selection, this value get lost
- isBSpline(true);
+ _recalculateIsBSpline();
for (std::list<SubpathPtr>::iterator spi = _subpaths.begin(); spi != _subpaths.end(); ) {
SubpathPtr subpath = *spi;
if (subpath->empty()) {
@@ -1338,17 +1348,17 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE)
_spcurve->set_pathvector(pathv);
if (alert_LPE) {
/// \todo note that _path can be an Inkscape::LivePathEffect::Effect* too, kind of confusing, rework member naming?
- if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()){
- Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::POWERSTROKE);
- if(thisEffect){
- LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast<LivePathEffect::LPEPowerStroke*>(thisEffect->getLPEObj()->get_lpe());
+ if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()) {
+ Inkscape::LivePathEffect::Effect* this_effect = _path->getPathEffectOfType(Inkscape::LivePathEffect::POWERSTROKE);
+ if(this_effect){
+ LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast<LivePathEffect::LPEPowerStroke*>(this_effect->getLPEObj()->get_lpe());
if (lpe_pwr) {
lpe_pwr->adjustForNewPath(pathv);
}
}
- thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::FILLET_CHAMFER);
- if(thisEffect){
- LivePathEffect::LPEFilletChamfer *lpe_fll = dynamic_cast<LivePathEffect::LPEFilletChamfer*>(thisEffect->getLPEObj()->get_lpe());
+ this_effect = _path->getPathEffectOfType(Inkscape::LivePathEffect::FILLET_CHAMFER);
+ if(this_effect){
+ LivePathEffect::LPEFilletChamfer *lpe_fll = dynamic_cast<LivePathEffect::LPEFilletChamfer*>(this_effect->getLPEObj()->get_lpe());
if (lpe_fll) {
lpe_fll->adjustForNewPath(pathv);
}
diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h
index 4d2bf4300..2219af849 100644
--- a/src/ui/tool/path-manipulator.h
+++ b/src/ui/tool/path-manipulator.h
@@ -96,7 +96,7 @@ public:
NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected,
bool search_unselected, bool closest);
- int BSplineGetSteps() const;
+ int _bsplineGetSteps() const;
// this is necessary for Tab-selection in MultiPathManipulator
SubpathList &subpathList() { return _subpaths; }
@@ -107,11 +107,11 @@ private:
void _createControlPointsFromGeometry();
- bool isBSpline(bool recalculate = false);
- bool isBSpline() const;
- double BSplineHandlePosition(Handle *h, Handle *h2 = NULL);
- Geom::Point BSplineHandleReposition(Handle *h, Handle *h2 = NULL);
- Geom::Point BSplineHandleReposition(Handle *h, double pos);
+ void _recalculateIsBSpline();
+ bool _isBSpline() const;
+ double _bsplineHandlePosition(Handle *h, Handle *h2 = NULL);
+ Geom::Point _bsplineHandleReposition(Handle *h, Handle *h2 = NULL);
+ Geom::Point _bsplineHandleReposition(Handle *h, double pos);
void _createGeometryFromControlPoints(bool alert_LPE = false);
unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape);
std::string _createTypeString();
diff --git a/src/ui/tools/box3d-tool.h b/src/ui/tools/box3d-tool.h
index 1dd6bb5f8..33ae6d8e7 100644
--- a/src/ui/tools/box3d-tool.h
+++ b/src/ui/tools/box3d-tool.h
@@ -80,7 +80,7 @@ private:
Proj::Pt3 drag_ptC_proj;
bool ctrl_dragged; /* whether we are ctrl-dragging */
- bool extruded; /* whether shift-dragging already occured (i.e. the box is already extruded) */
+ bool extruded; /* whether shift-dragging already occurred (i.e. the box is already extruded) */
sigc::connection sel_changed_connection;
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 19094e3f7..0a36877ff 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -49,7 +49,7 @@
* Much of the way connectors work for user-defined points has been
* changed so that it no longer defines special attributes to record
* the points. Instead it uses single node paths to define points
- * who are then seperate objects that can be fixed on the canvas,
+ * who are then separate objects that can be fixed on the canvas,
* grouped into objects and take full advantage of all transform, snap
* and align functionality of all other objects.
*
diff --git a/src/ui/tools/dynamic-base.h b/src/ui/tools/dynamic-base.h
index c948fa286..095af8f88 100644
--- a/src/ui/tools/dynamic-base.h
+++ b/src/ui/tools/dynamic-base.h
@@ -47,7 +47,7 @@ protected:
/** accumulated shape which ultimately goes in svg:path */
SPCurve *accumulated;
- /** canvas items for "comitted" segments */
+ /** canvas items for "committed" segments */
GSList *segments;
/** canvas item for red "leading" segment */
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index bb8782dfa..ffd41d97d 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -84,6 +84,28 @@ const std::string& FloodTool::getPrefsPath() {
const std::string FloodTool::prefsPath = "/tools/paintbucket";
+// TODO: Replace by C++11 initialization
+// Must match PaintBucketChannels enum
+Glib::ustring ch_init[8] = {
+ _("Visible Colors"),
+ _("Red"),
+ _("Green"),
+ _("Blue"),
+ _("Hue"),
+ _("Saturation"),
+ _("Lightness"),
+ _("Alpha"),
+};
+const std::vector<Glib::ustring> FloodTool::channel_list( ch_init, ch_init+8 );
+
+Glib::ustring gap_init[4] = {
+ C_("Flood autogap", "None"),
+ C_("Flood autogap", "Small"),
+ C_("Flood autogap", "Medium"),
+ C_("Flood autogap", "Large")
+};
+const std::vector<Glib::ustring> FloodTool::gap_list( gap_init, gap_init+4 );
+
FloodTool::FloodTool()
: ToolBase(cursor_paintbucket_xpm, 11, 30)
, item(NULL)
@@ -174,38 +196,6 @@ inline unsigned char * get_trace_pixel(guchar *trace_px, int x, int y, int width
}
/**
- * Generate the list of trace channel selection entries.
- */
-GList * flood_channels_dropdown_items_list() {
- GList *glist = NULL;
-
- glist = g_list_append (glist, _("Visible Colors"));
- glist = g_list_append (glist, _("Red"));
- glist = g_list_append (glist, _("Green"));
- glist = g_list_append (glist, _("Blue"));
- glist = g_list_append (glist, _("Hue"));
- glist = g_list_append (glist, _("Saturation"));
- glist = g_list_append (glist, _("Lightness"));
- glist = g_list_append (glist, _("Alpha"));
-
- return glist;
-}
-
-/**
- * Generate the list of autogap selection entries.
- */
-GList * flood_autogap_dropdown_items_list() {
- GList *glist = NULL;
-
- glist = g_list_append (glist, (void*) C_("Flood autogap", "None"));
- glist = g_list_append (glist, (void*) C_("Flood autogap", "Small"));
- glist = g_list_append (glist, (void*) C_("Flood autogap", "Medium"));
- glist = g_list_append (glist, (void*) C_("Flood autogap", "Large"));
-
- return glist;
-}
-
-/**
* Compare a pixel in a pixel buffer with another pixel to determine if a point should be included in the fill operation.
* @param check The pixel in the pixel buffer to check.
* @param orig The original selected pixel to use as the fill target color.
diff --git a/src/ui/tools/flood-tool.h b/src/ui/tools/flood-tool.h
index 5104a42e9..100875f22 100644
--- a/src/ui/tools/flood-tool.h
+++ b/src/ui/tools/flood-tool.h
@@ -13,6 +13,7 @@
#include <sigc++/connection.h>
#include "ui/tools/tool-base.h"
+#include <vector>
#define SP_FLOOD_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::FloodTool*>((Inkscape::UI::Tools::ToolBase*)obj))
#define SP_IS_FLOOD_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::FloodTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
@@ -39,15 +40,14 @@ public:
virtual const std::string& getPrefsPath();
static void set_channels(gint channels);
+ static const std::vector<Glib::ustring> channel_list;
+ static const std::vector<Glib::ustring> gap_list;
private:
void selection_changed(Inkscape::Selection* selection);
void finishItem();
};
-GList* flood_channels_dropdown_items_list (void);
-GList* flood_autogap_dropdown_items_list (void);
-
enum PaintBucketChannels {
FLOOD_CHANNELS_RGB,
FLOOD_CHANNELS_R,
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 0f14d7534..e8cbfcdbf 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -92,7 +92,7 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint ho
, white_item(NULL)
, white_curves(NULL)
, white_anchors(NULL)
- , overwriteCurve(NULL)
+ , overwrite_curve(NULL)
, sa(NULL)
, ea(NULL)
, waiting_LPE_type(Inkscape::LivePathEffect::INVALID_LPE)
@@ -149,7 +149,7 @@ void FreehandBase::setup() {
this->green_closed = FALSE;
// Create start anchor alternative curve
- this->overwriteCurve = new SPCurve();
+ this->overwrite_curve = new SPCurve();
this->attach = TRUE;
spdc_attach_selection(this, this->selection);
@@ -575,12 +575,12 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
}
if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
- dc->overwriteCurve->append_continuous(c, 0.0625);
+ dc->overwrite_curve->append_continuous(c, 0.0625);
c->unref();
- dc->overwriteCurve->closepath_current();
+ dc->overwrite_curve->closepath_current();
if(dc->sa){
dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve);
- dc->white_curves = g_slist_append(dc->white_curves, dc->overwriteCurve);
+ dc->white_curves = g_slist_append(dc->white_curves, dc->overwrite_curve);
}
}else{
dc->sa->curve->append_continuous(c, 0.0625);
@@ -597,7 +597,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
dc->white_curves = g_slist_remove(dc->white_curves, s);
if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
- s = dc->overwriteCurve;
+ s = dc->overwrite_curve;
}
if (dc->sa->start) {
s = reverse_then_unref(s);
diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h
index 6b4265215..a3e7b42f9 100644
--- a/src/ui/tools/freehand-base.h
+++ b/src/ui/tools/freehand-base.h
@@ -78,7 +78,7 @@ public:
//ALternative curve to use on continuing exisiting curve in case of bspline or spirolive
//because usigh anchor curves give memory and random bugs, - and obscure code- in some plataform reported by su_v in mac
- SPCurve *overwriteCurve;
+ SPCurve *overwrite_curve;
// Start anchor
SPDrawAnchor *sa;
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index cae525bfb..bf38b5ca5 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -321,7 +321,7 @@ sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc)
if (d->point_type == POINT_RG_FOCUS) {
/*
* There are 2 draggables at the center (start) of a radial gradient
- * To avoid creating 2 seperate stops, ignore this draggable point type
+ * To avoid creating 2 separate stops, ignore this draggable point type
*/
continue;
}
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index af341a9aa..0e68af601 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -48,7 +48,7 @@
// Mesh specific
#include "ui/tools/mesh-tool.h"
-#include "sp-mesh-gradient.h"
+#include "sp-mesh.h"
#include "display/sp-ctrlcurve.h"
using Inkscape::DocumentUndo;
@@ -162,9 +162,9 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
// if (style && (style->fill.isPaintserver())) {
// SPPaintServer *server = item->style->getFillPaintServer();
- // if ( SP_IS_MESHGRADIENT(server) ) {
+ // if ( SP_IS_MESH(server) ) {
- // SPMeshGradient *mg = SP_MESHGRADIENT(server);
+ // SPMesh *mg = SP_MESH(server);
// guint rows = 0;//mg->array.patches.size();
// for ( guint i = 0; i < rows; ++i ) {
@@ -327,8 +327,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
SPDocument *doc = NULL;
GrDrag *drag = rc->_grdrag;
- std::map<SPMeshGradient*, std::vector<guint> > points;
- std::map<SPMeshGradient*, SPItem*> items;
+ std::map<SPMesh*, std::vector<guint> > points;
+ std::map<SPMesh*, SPItem*> items;
// Get list of selected draggers for each mesh.
// For all selected draggers
@@ -342,7 +342,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
if( d->point_type != POINT_MG_CORNER ) continue;
// Find the gradient
- SPMeshGradient *gradient = SP_MESHGRADIENT( getGradient (d->item, d->fill_or_stroke) );
+ SPMesh *gradient = SP_MESH( getGradient (d->item, d->fill_or_stroke) );
// Collect points together for same gradient
points[gradient].push_back( d->point_i );
@@ -351,8 +351,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
}
// Loop over meshes.
- for( std::map<SPMeshGradient*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
- SPMeshGradient *mg = SP_MESHGRADIENT( iter->first );
+ for( std::map<SPMesh*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
+ SPMesh *mg = SP_MESH( iter->first );
if( iter->second.size() > 0 ) {
guint noperation = 0;
switch (operation) {
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 40d54af6e..ef00eaa40 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -75,7 +75,7 @@
* - ControlPointSelection: keeps track of node selection and a set of nodes that can potentially
* be selected. There can be more than one selection. Performs actions that require no
* knowledge about the path, only about the nodes, like dragging and transforms. It is not
- * specific to nodes and can accomodate any control point derived from SelectableControlPoint.
+ * specific to nodes and can accommodate any control point derived from SelectableControlPoint.
* Transforms nodes in response to transform handle events.
* - TransformHandleSet: displays nodeset transform handles and emits transform events. The aim
* is to eventually use a common class for object and control point transforms.
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index d28b7c27a..daffc7032 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -85,7 +85,7 @@ namespace Tools {
static Geom::Point pen_drag_origin_w(0, 0);
static bool pen_within_tolerance = false;
static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical
-const double handleCubicGap = 0.01;
+const double HANDLE_CUBIC_GAP = 0.01;
const std::string& PenTool::getPrefsPath() {
return PenTool::prefsPath;
@@ -165,17 +165,17 @@ void PenTool::setPolylineMode() {
this->polylines_paraxial = (mode == 4);
//we call the function which defines the Spiro modes and the BSpline
//todo: merge to one function only
- this->_pen_context_set_mode(mode);
+ this->_penContextSetMode(mode);
}
/*
*.Set the mode of draw spiro, and bsplines
*/
-void PenTool::_pen_context_set_mode(guint mode) {
+void PenTool::_penContextSetMode(guint mode) {
// define the nodes
this->spiro = (mode == 1);
this->bspline = (mode == 2);
- this->_bspline_spiro_color();
+ this->_bsplineSpiroColor();
}
/**
@@ -429,7 +429,7 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) {
// This is allowed, if we just canceled curve
case PenTool::POINT:
if (this->npoints == 0) {
- this->_bspline_spiro_color();
+ this->_bsplineSpiroColor();
Geom::Point p;
if ((bevent.state & GDK_CONTROL_MASK) && (this->polylines_only || this->polylines_paraxial)) {
p = event_dt;
@@ -451,7 +451,7 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) {
this->sa = anchor;
if(anchor){
- this->_bspline_spiro_start_anchor(bevent.state & GDK_SHIFT_MASK);
+ this->_bsplineSpiroStartAnchor(bevent.state & GDK_SHIFT_MASK);
}
if (anchor && (!this->hasWaitingLPE()|| this->bspline || this->spiro)) {
// Adjust point to anchor if needed; if we have a waiting LPE, we need
@@ -700,10 +700,10 @@ bool PenTool::_handleMotionNotify(GdkEventMotion const &mevent) {
}
// calls the function "bspline_spiro_motion" when the mouse starts or stops moving
if(this->bspline){
- this->_bspline_spiro_motion(mevent.state & GDK_SHIFT_MASK);
+ this->_bsplineSpiroMotion(mevent.state & GDK_SHIFT_MASK);
}else{
if ( Geom::LInfty( event_w - pen_drag_origin_w ) > (tolerance/2) || mevent.time == 0) {
- this->_bspline_spiro_motion(mevent.state & GDK_SHIFT_MASK);
+ this->_bsplineSpiroMotion(mevent.state & GDK_SHIFT_MASK);
pen_drag_origin_w = event_w;
}
}
@@ -742,7 +742,7 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) {
case PenTool::POINT:
if ( this->npoints == 0 ) {
// Start new thread only with button release
- this->_bspline_spiro_color();
+ this->_bsplineSpiroColor();
if (anchor) {
p = anchor->dp;
}
@@ -750,7 +750,7 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) {
// continue the existing curve
if (anchor) {
if(this->bspline || this->spiro){
- this->_bspline_spiro_start_anchor(revent.state & GDK_SHIFT_MASK);;
+ this->_bsplineSpiroStartAnchor(revent.state & GDK_SHIFT_MASK);;
}
}
this->_setInitialPoint(p);
@@ -879,11 +879,11 @@ void PenTool::_redrawAll() {
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
// one canvas bpath for all of green_curve
- SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve);
- sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
- sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO);
+ SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve);
+ sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
+ sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO);
- this->green_bpaths = g_slist_prepend(this->green_bpaths, cshape);
+ this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape);
}
if (this->green_anchor)
SP_CTRL(this->green_anchor->ctrl)->moveto(this->green_anchor->dp);
@@ -925,7 +925,7 @@ void PenTool::_redrawAll() {
// simply redraw the spiro. because its a redrawing, we don't call the global function,
// but we call the redrawing at the ending.
- this->_bspline_spiro_build();
+ this->_bsplineSpiroBuild();
}
void PenTool::_lastpointMove(gdouble x, gdouble y) {
@@ -1001,7 +1001,7 @@ void PenTool::_lastpointToCurve() {
}
//if the last node is an union with another curve
if (this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()) {
- this->_bspline_spiro_start_anchor(false);
+ this->_bsplineSpiroStartAnchor(false);
}
}
@@ -1048,7 +1048,7 @@ void PenTool::_lastpointToLine() {
}
// if the last node is an union with another curve
if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){
- this->_bspline_spiro_start_anchor(true);
+ this->_bsplineSpiroStartAnchor(true);
}
}
@@ -1312,7 +1312,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t
}
// this function changes the colors red, green and blue making them transparent or not, depending on if spiro is being used.
-void PenTool::_bspline_spiro_color()
+void PenTool::_bsplineSpiroColor()
{
static Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if(this->spiro){
@@ -1346,25 +1346,25 @@ void PenTool::_bspline_spiro_color()
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
// one canvas bpath for all of green_curve
- SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve);
- sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
- sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO);
- this->green_bpaths = g_slist_prepend(this->green_bpaths, cshape);
+ SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve);
+ sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
+ sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO);
+ this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape);
}
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->red_bpath), this->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
}
-void PenTool::_bspline_spiro(bool shift)
+void PenTool::_bsplineSpiro(bool shift)
{
if(!this->spiro && !this->bspline)
return;
- shift?this->_bspline_spiro_off():this->_bspline_spiro_on();
- this->_bspline_spiro_build();
+ shift?this->_bsplineSpiroOff():this->_bsplineSpiroOn();
+ this->_bsplineSpiroBuild();
}
-void PenTool::_bspline_spiro_on()
+void PenTool::_bsplineSpiroOn()
{
if(!this->red_curve->is_empty()){
using Geom::X;
@@ -1373,11 +1373,11 @@ void PenTool::_bspline_spiro_on()
this->p[0] = this->red_curve->first_segment()->initialPoint();
this->p[3] = this->red_curve->first_segment()->finalPoint();
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
- this->p[2] = Geom::Point(this->p[2][X] + handleCubicGap,this->p[2][Y] + handleCubicGap);
+ this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP);
}
}
-void PenTool::_bspline_spiro_off()
+void PenTool::_bsplineSpiroOff()
{
if(!this->red_curve->is_empty()){
this->npoints = 5;
@@ -1387,7 +1387,7 @@ void PenTool::_bspline_spiro_off()
}
}
-void PenTool::_bspline_spiro_start_anchor(bool shift)
+void PenTool::_bsplineSpiroStartAnchor(bool shift)
{
if(this->sa->curve->is_empty()){
return;
@@ -1423,73 +1423,73 @@ void PenTool::_bspline_spiro_start_anchor(bool shift)
return;
if(shift)
- this->_bspline_spiro_start_anchor_off();
+ this->_bsplineSpiroStartAnchorOff();
else
- this->_bspline_spiro_start_anchor_on();
+ this->_bsplineSpiroStartAnchorOn();
}
-void PenTool::_bspline_spiro_start_anchor_on()
+void PenTool::_bsplineSpiroStartAnchorOn()
{
using Geom::X;
using Geom::Y;
- SPCurve *tmpCurve = new SPCurve();
- tmpCurve = this->sa->curve->copy();
+ SPCurve *tmp_curve = new SPCurve();
+ tmp_curve = this->sa->curve->copy();
if(this->sa->start)
- tmpCurve = tmpCurve->create_reverse();
- Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
- SPCurve *lastSeg = new SPCurve();
- Geom::Point A = tmpCurve->last_segment()->initialPoint();
- Geom::Point D = tmpCurve->last_segment()->finalPoint();
- Geom::Point C = D + (1./3)*(A - D);
- C = Geom::Point(C[X] + handleCubicGap,C[Y] + handleCubicGap);
+ tmp_curve = tmp_curve ->create_reverse();
+ Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
+ SPCurve *last_segment = new SPCurve();
+ Geom::Point point_a = tmp_curve ->last_segment()->initialPoint();
+ Geom::Point point_d = tmp_curve ->last_segment()->finalPoint();
+ Geom::Point point_c = point_d + (1./3)*(point_a - point_d);
+ point_c = Geom::Point(point_c[X] + HANDLE_CUBIC_GAP, point_c[Y] + HANDLE_CUBIC_GAP);
if(cubic){
- lastSeg->moveto(A);
- lastSeg->curveto((*cubic)[1],C,D);
+ last_segment->moveto(point_a);
+ last_segment->curveto((*cubic)[1],point_c,point_d);
}else{
- lastSeg->moveto(A);
- lastSeg->curveto(A,C,D);
+ last_segment->moveto(point_a);
+ last_segment->curveto(point_a,point_c,point_d);
}
- if( tmpCurve->get_segment_count() == 1){
- tmpCurve = lastSeg;
+ if( tmp_curve ->get_segment_count() == 1){
+ tmp_curve = last_segment;
}else{
//we eliminate the last segment
- tmpCurve->backspace();
+ tmp_curve ->backspace();
//and we add it again with the recreation
- tmpCurve->append_continuous(lastSeg, 0.0625);
+ tmp_curve ->append_continuous(last_segment, 0.0625);
}
if (this->sa->start) {
- tmpCurve = tmpCurve->create_reverse();
+ tmp_curve = tmp_curve ->create_reverse();
}
- this->overwriteCurve = tmpCurve;
+ this->overwrite_curve = tmp_curve ;
}
-void PenTool::_bspline_spiro_start_anchor_off()
+void PenTool::_bsplineSpiroStartAnchorOff()
{
- SPCurve *tmpCurve = new SPCurve();
- tmpCurve = this->sa->curve->copy();
+ SPCurve *tmp_curve = new SPCurve();
+ tmp_curve = this->sa->curve->copy();
if(this->sa->start)
- tmpCurve = tmpCurve->create_reverse();
- Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
+ tmp_curve = tmp_curve ->create_reverse();
+ Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
if(cubic){
- SPCurve *lastSeg = new SPCurve();
- lastSeg->moveto((*cubic)[0]);
- lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]);
- if( tmpCurve->get_segment_count() == 1){
- tmpCurve = lastSeg;
+ SPCurve *last_segment = new SPCurve();
+ last_segment->moveto((*cubic)[0]);
+ last_segment->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]);
+ if( tmp_curve ->get_segment_count() == 1){
+ tmp_curve = last_segment;
}else{
//we eliminate the last segment
- tmpCurve->backspace();
+ tmp_curve ->backspace();
//and we add it again with the recreation
- tmpCurve->append_continuous(lastSeg, 0.0625);
+ tmp_curve ->append_continuous(last_segment, 0.0625);
}
}
if (this->sa->start) {
- tmpCurve = tmpCurve->create_reverse();
+ tmp_curve = tmp_curve ->create_reverse();
}
- this->overwriteCurve = tmpCurve;
+ this->overwrite_curve = tmp_curve ;
}
-void PenTool::_bspline_spiro_motion(bool shift){
+void PenTool::_bsplineSpiroMotion(bool shift){
if(!this->spiro && !this->bspline)
return;
@@ -1497,40 +1497,40 @@ void PenTool::_bspline_spiro_motion(bool shift){
using Geom::Y;
if(this->red_curve->is_empty()) return;
this->npoints = 5;
- SPCurve *tmpCurve = new SPCurve();
+ SPCurve *tmp_curve = new SPCurve();
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
- this->p[2] = Geom::Point(this->p[2][X] + handleCubicGap,this->p[2][Y] + handleCubicGap);
+ this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP);
if(this->green_curve->is_empty() && !this->sa){
this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]);
- this->p[1] = Geom::Point(this->p[1][X] + handleCubicGap,this->p[1][Y] + handleCubicGap);
+ this->p[1] = Geom::Point(this->p[1][X] + HANDLE_CUBIC_GAP,this->p[1][Y] + HANDLE_CUBIC_GAP);
if(shift){
this->p[2] = this->p[3];
}
}else if(!this->green_curve->is_empty()){
- tmpCurve = this->green_curve->copy();
+ tmp_curve = this->green_curve->copy();
}else{
- tmpCurve = this->overwriteCurve->copy();
+ tmp_curve = this->overwrite_curve->copy();
if(this->sa->start)
- tmpCurve = tmpCurve->create_reverse();
+ tmp_curve = tmp_curve ->create_reverse();
}
- if(!tmpCurve->is_empty()){
- Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
+ if(!tmp_curve ->is_empty()){
+ Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
if(cubic){
if(this->bspline){
- SPCurve * WPower = new SPCurve();
- Geom::D2< Geom::SBasis > SBasisWPower;
- WPower->moveto(tmpCurve->last_segment()->finalPoint());
- WPower->lineto(tmpCurve->last_segment()->initialPoint());
- float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment());
- WPower->reset();
- WPower->moveto(this->red_curve->last_segment()->initialPoint());
- WPower->lineto(this->red_curve->last_segment()->finalPoint());
- SBasisWPower = WPower->first_segment()->toSBasis();
- WPower->reset();
- this->p[1] = SBasisWPower.valueAt(WP);
+ SPCurve * weight_power = new SPCurve();
+ Geom::D2< Geom::SBasis > SBasisweight_power;
+ weight_power->moveto(tmp_curve ->last_segment()->finalPoint());
+ weight_power->lineto(tmp_curve ->last_segment()->initialPoint());
+ float WP = Geom::nearest_point((*cubic)[2],*weight_power->first_segment());
+ weight_power->reset();
+ weight_power->moveto(this->red_curve->last_segment()->initialPoint());
+ weight_power->lineto(this->red_curve->last_segment()->finalPoint());
+ SBasisweight_power = weight_power->first_segment()->toSBasis();
+ weight_power->reset();
+ this->p[1] = SBasisweight_power.valueAt(WP);
if(!Geom::are_near(this->p[1],this->p[0])){
- this->p[1] = Geom::Point(this->p[1][X] + handleCubicGap,this->p[1][Y] + handleCubicGap);
+ this->p[1] = Geom::Point(this->p[1][X] + HANDLE_CUBIC_GAP,this->p[1][Y] + HANDLE_CUBIC_GAP);
} else {
this->p[1] = this->p[0];
}
@@ -1548,129 +1548,129 @@ void PenTool::_bspline_spiro_motion(bool shift){
if(this->anchor_statusbar && !this->red_curve->is_empty()){
if(shift){
- this->_bspline_spiro_end_anchor_off();
+ this->_bsplineSpiroEndAnchorOff();
}else{
- this->_bspline_spiro_end_anchor_on();
+ this->_bsplineSpiroEndAnchorOn();
}
}
- this->_bspline_spiro_build();
+ this->_bsplineSpiroBuild();
}
-void PenTool::_bspline_spiro_end_anchor_on()
+void PenTool::_bsplineSpiroEndAnchorOn()
{
using Geom::X;
using Geom::Y;
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
- this->p[2] = Geom::Point(this->p[2][X] + handleCubicGap,this->p[2][Y] + handleCubicGap);
- SPCurve *tmpCurve = new SPCurve();
- SPCurve *lastSeg = new SPCurve();
- Geom::Point C(0,0);
+ this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP);
+ SPCurve *tmp_curve = new SPCurve();
+ SPCurve *last_segment = new SPCurve();
+ Geom::Point point_c(0,0);
bool reverse = false;
if( this->green_anchor && this->green_anchor->active ){
- tmpCurve = this->green_curve->create_reverse();
+ tmp_curve = this->green_curve->create_reverse();
if(this->green_curve->get_segment_count()==0){
return;
}
reverse = true;
} else if(this->sa){
- tmpCurve = this->overwriteCurve->copy();
+ tmp_curve = this->overwrite_curve->copy();
if(!this->sa->start){
- tmpCurve = tmpCurve->create_reverse();
+ tmp_curve = tmp_curve ->create_reverse();
reverse = true;
}
}else{
return;
}
- Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
+ Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
if(this->bspline){
- C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint());
- C = Geom::Point(C[X] + handleCubicGap,C[Y] + handleCubicGap);
+ point_c = tmp_curve ->last_segment()->finalPoint() + (1./3)*(tmp_curve ->last_segment()->initialPoint() - tmp_curve ->last_segment()->finalPoint());
+ point_c = Geom::Point(point_c[X] + HANDLE_CUBIC_GAP, point_c[Y] + HANDLE_CUBIC_GAP);
}else{
- C = this->p[3] + this->p[3] - this->p[2];
+ point_c = this->p[3] + this->p[3] - this->p[2];
}
if(cubic){
- lastSeg->moveto((*cubic)[0]);
- lastSeg->curveto((*cubic)[1],C,(*cubic)[3]);
+ last_segment->moveto((*cubic)[0]);
+ last_segment->curveto((*cubic)[1],point_c,(*cubic)[3]);
}else{
- lastSeg->moveto(tmpCurve->last_segment()->initialPoint());
- lastSeg->lineto(tmpCurve->last_segment()->finalPoint());
+ last_segment->moveto(tmp_curve ->last_segment()->initialPoint());
+ last_segment->lineto(tmp_curve ->last_segment()->finalPoint());
}
- if( tmpCurve->get_segment_count() == 1){
- tmpCurve = lastSeg;
+ if( tmp_curve ->get_segment_count() == 1){
+ tmp_curve = last_segment;
}else{
//we eliminate the last segment
- tmpCurve->backspace();
+ tmp_curve ->backspace();
//and we add it again with the recreation
- tmpCurve->append_continuous(lastSeg, 0.0625);
+ tmp_curve ->append_continuous(last_segment, 0.0625);
}
if (reverse) {
- tmpCurve = tmpCurve->create_reverse();
+ tmp_curve = tmp_curve ->create_reverse();
}
if( this->green_anchor && this->green_anchor->active )
{
this->green_curve->reset();
- this->green_curve = tmpCurve;
+ this->green_curve = tmp_curve ;
}else{
- this->overwriteCurve->reset();
- this->overwriteCurve = tmpCurve;
+ this->overwrite_curve->reset();
+ this->overwrite_curve = tmp_curve ;
}
}
-void PenTool::_bspline_spiro_end_anchor_off()
+void PenTool::_bsplineSpiroEndAnchorOff()
{
- SPCurve *tmpCurve = new SPCurve();
- SPCurve *lastSeg = new SPCurve();
+ SPCurve *tmp_curve = new SPCurve();
+ SPCurve *last_segment = new SPCurve();
bool reverse = false;
this->p[2] = this->p[3];
if( this->green_anchor && this->green_anchor->active ){
- tmpCurve = this->green_curve->create_reverse();
+ tmp_curve = this->green_curve->create_reverse();
if(this->green_curve->get_segment_count()==0){
return;
}
reverse = true;
} else if(this->sa){
- tmpCurve = this->overwriteCurve->copy();
+ tmp_curve = this->overwrite_curve->copy();
if(!this->sa->start){
- tmpCurve = tmpCurve->create_reverse();
+ tmp_curve = tmp_curve ->create_reverse();
reverse = true;
}
}else{
return;
}
- Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
+ Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
if(cubic){
- lastSeg->moveto((*cubic)[0]);
- lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]);
+ last_segment->moveto((*cubic)[0]);
+ last_segment->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]);
}else{
- lastSeg->moveto(tmpCurve->last_segment()->initialPoint());
- lastSeg->lineto(tmpCurve->last_segment()->finalPoint());
+ last_segment->moveto(tmp_curve ->last_segment()->initialPoint());
+ last_segment->lineto(tmp_curve ->last_segment()->finalPoint());
}
- if( tmpCurve->get_segment_count() == 1){
- tmpCurve = lastSeg;
+ if( tmp_curve ->get_segment_count() == 1){
+ tmp_curve = last_segment;
}else{
//we eliminate the last segment
- tmpCurve->backspace();
+ tmp_curve ->backspace();
//and we add it again with the recreation
- tmpCurve->append_continuous(lastSeg, 0.0625);
+ tmp_curve ->append_continuous(last_segment, 0.0625);
}
if (reverse) {
- tmpCurve = tmpCurve->create_reverse();
+ tmp_curve = tmp_curve ->create_reverse();
}
if( this->green_anchor && this->green_anchor->active )
{
this->green_curve->reset();
- this->green_curve = tmpCurve;
+ this->green_curve = tmp_curve ;
}else{
- this->overwriteCurve->reset();
- this->overwriteCurve = tmpCurve;
+ this->overwrite_curve->reset();
+ this->overwrite_curve = tmp_curve ;
}
}
//prepares the curves for its transformation into BSpline curve.
-void PenTool::_bspline_spiro_build()
+void PenTool::_bsplineSpiroBuild()
{
if(!this->spiro && !this->bspline){
return;
@@ -1680,7 +1680,7 @@ void PenTool::_bspline_spiro_build()
SPCurve *curve = new SPCurve();
//If we continuate the existing curve we add it at the start
if(this->sa && !this->sa->curve->is_empty()){
- curve = this->overwriteCurve->copy();
+ curve = this->overwrite_curve->copy();
if (this->sa->start) {
curve = curve->create_reverse();
}
@@ -1715,9 +1715,9 @@ void PenTool::_bspline_spiro_build()
//Effect *spr = static_cast<Effect*> ( new LPEbspline(lpeobj) );
//spr->doEffect(curve);
if(this->bspline){
- this->_bspline_doEffect(curve);
+ this->_bsplineDoEffect(curve);
}else{
- this->_spiro_doEffect(curve);
+ this->_spiroDoEffect(curve);
}
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), curve);
@@ -1741,66 +1741,73 @@ void PenTool::_bspline_spiro_build()
}
}
-void PenTool::_bspline_doEffect(SPCurve * curve)
+//from LPE BSPLINE:
+void PenTool::_bsplineDoEffect(SPCurve * curve)
{
- // commenting the function doEffect in src/live_effects/lpe-bspline.cpp
- if (curve->get_segment_count() < 1){
+ const double NO_POWER = 0.0;
+ const double DEFAULT_START_POWER = 0.3334;
+ const double DEFAULT_END_POWER = 0.6667;
+ if (curve->get_segment_count() < 1) {
return;
}
// Make copy of old path as it is changed during processing
Geom::PathVector const original_pathv = curve->get_pathvector();
+
curve->reset();
- //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el
- //penúltimo
for (Geom::PathVector::const_iterator path_it = original_pathv.begin();
path_it != original_pathv.end(); ++path_it) {
- //Si está vacío...
- if (path_it->empty())
+ if (path_it->empty()) {
continue;
- //Itreadores
-
+ }
Geom::Path::const_iterator curve_it1 = path_it->begin();
Geom::Path::const_iterator curve_it2 = ++(path_it->begin());
- Geom::Path::const_iterator curve_endit = path_it->end_default();
- SPCurve *nCurve = new SPCurve();
+ Geom::Path::const_iterator curve_endit = path_it->end_default();
+ SPCurve *curve_n = new SPCurve();
Geom::Point previousNode(0, 0);
Geom::Point node(0, 0);
- Geom::Point pointAt1(0, 0);
- Geom::Point pointAt2(0, 0);
- Geom::Point nextPointAt1(0, 0);
- Geom::D2<Geom::SBasis> SBasisIn;
- Geom::D2<Geom::SBasis> SBasisOut;
- Geom::D2<Geom::SBasis> SBasisHelper;
+ Geom::Point point_at1(0, 0);
+ Geom::Point point_at2(0, 0);
+ Geom::Point next_point_at1(0, 0);
+ Geom::D2<Geom::SBasis> sbasis_in;
+ Geom::D2<Geom::SBasis> sbasis_out;
+ Geom::D2<Geom::SBasis> sbasis_helper;
Geom::CubicBezier const *cubic = NULL;
if (path_it->closed()) {
+ // if the path is closed, maybe we have to stop a bit earlier because the
+ // closing line segment has zerolength.
const Geom::Curve &closingline =
path_it->back_closed(); // the closing line segment is always of type
+ // Geom::LineSegment.
if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
+ // closingline.isDegenerate() did not work, because it only checks for
+ // *exact* zero length, which goes wrong for relative coordinates and
+ // rounding errors...
+ // the closing line segment has zero-length. So stop before that one!
curve_endit = path_it->end_open();
}
}
- nCurve->moveto(curve_it1->initialPoint());
+ curve_n->moveto(curve_it1->initialPoint());
while (curve_it1 != curve_endit) {
SPCurve *in = new SPCurve();
in->moveto(curve_it1->initialPoint());
in->lineto(curve_it1->finalPoint());
cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1);
if (cubic) {
- SBasisIn = in->first_segment()->toSBasis();
+ sbasis_in = in->first_segment()->toSBasis();
if(are_near((*cubic)[1],(*cubic)[0]) && !are_near((*cubic)[2],(*cubic)[3])) {
- pointAt1 = SBasisIn.valueAt(0.3334);
+ point_at1 = sbasis_in.valueAt(DEFAULT_START_POWER);
} else {
- pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1], *in->first_segment()));
+ point_at1 = sbasis_in.valueAt(Geom::nearest_point((*cubic)[1], *in->first_segment()));
}
if(are_near((*cubic)[2],(*cubic)[3]) && !are_near((*cubic)[1],(*cubic)[0])) {
- pointAt2 = SBasisIn.valueAt(0.6667);
+ point_at2 = sbasis_in.valueAt(DEFAULT_END_POWER);
} else {
- pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2], *in->first_segment()));
+ point_at2 = sbasis_in.valueAt(Geom::nearest_point((*cubic)[2], *in->first_segment()));
}
} else {
- pointAt1 = in->first_segment()->initialPoint();
- pointAt2 = in->first_segment()->finalPoint();
+ point_at1 = in->first_segment()->initialPoint();
+ point_at2 = in->first_segment()->finalPoint();
}
in->reset();
delete in;
@@ -1810,31 +1817,30 @@ void PenTool::_bspline_doEffect(SPCurve * curve)
out->lineto(curve_it2->finalPoint());
cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it2);
if (cubic) {
- SBasisOut = out->first_segment()->toSBasis();
+ sbasis_out = out->first_segment()->toSBasis();
if(are_near((*cubic)[1],(*cubic)[0]) && !are_near((*cubic)[2],(*cubic)[3])) {
- nextPointAt1 = SBasisIn.valueAt(0.3334);
+ next_point_at1 = sbasis_in.valueAt(DEFAULT_START_POWER);
} else {
- nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1], *out->first_segment()));
+ next_point_at1 = sbasis_out.valueAt(Geom::nearest_point((*cubic)[1], *out->first_segment()));
}
} else {
- nextPointAt1 = out->first_segment()->initialPoint();
+ next_point_at1 = out->first_segment()->initialPoint();
}
out->reset();
delete out;
}
- Geom::Point startNode = path_it->begin()->initialPoint();
if (path_it->closed() && curve_it2 == curve_endit) {
SPCurve *start = new SPCurve();
start->moveto(path_it->begin()->initialPoint());
start->lineto(path_it->begin()->finalPoint());
- Geom::D2<Geom::SBasis> SBasisStart = start->first_segment()->toSBasis();
- SPCurve *lineHelper = new SPCurve();
+ Geom::D2<Geom::SBasis> sbasis_start = start->first_segment()->toSBasis();
+ SPCurve *line_helper = new SPCurve();
cubic = dynamic_cast<Geom::CubicBezier const *>(&*path_it->begin());
if (cubic) {
- lineHelper->moveto(SBasisStart.valueAt(
+ line_helper->moveto(sbasis_start.valueAt(
Geom::nearest_point((*cubic)[1], *start->first_segment())));
} else {
- lineHelper->moveto(start->first_segment()->initialPoint());
+ line_helper->moveto(start->first_segment()->initialPoint());
}
start->reset();
delete start;
@@ -1842,55 +1848,56 @@ void PenTool::_bspline_doEffect(SPCurve * curve)
SPCurve *end = new SPCurve();
end->moveto(curve_it1->initialPoint());
end->lineto(curve_it1->finalPoint());
- Geom::D2<Geom::SBasis> SBasisEnd = end->first_segment()->toSBasis();
+ Geom::D2<Geom::SBasis> sbasis_end = end->first_segment()->toSBasis();
cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1);
if (cubic) {
- lineHelper->lineto(SBasisEnd.valueAt(
+ line_helper->lineto(sbasis_end.valueAt(
Geom::nearest_point((*cubic)[2], *end->first_segment())));
} else {
- lineHelper->lineto(end->first_segment()->finalPoint());
+ line_helper->lineto(end->first_segment()->finalPoint());
}
end->reset();
delete end;
- SBasisHelper = lineHelper->first_segment()->toSBasis();
- lineHelper->reset();
- delete lineHelper;
- startNode = SBasisHelper.valueAt(0.5);
- nCurve->curveto(pointAt1, pointAt2, startNode);
- nCurve->move_endpoints(startNode, startNode);
+ sbasis_helper = line_helper->first_segment()->toSBasis();
+ line_helper->reset();
+ delete line_helper;
+ node = sbasis_helper.valueAt(0.5);
+ curve_n->curveto(point_at1, point_at2, node);
+ curve_n->move_endpoints(node, node);
} else if ( curve_it2 == curve_endit) {
- nCurve->curveto(pointAt1, pointAt2, curve_it1->finalPoint());
- nCurve->move_endpoints(path_it->begin()->initialPoint(), curve_it1->finalPoint());
+ curve_n->curveto(point_at1, point_at2, curve_it1->finalPoint());
+ curve_n->move_endpoints(path_it->begin()->initialPoint(), curve_it1->finalPoint());
} else {
- SPCurve *lineHelper = new SPCurve();
- lineHelper->moveto(pointAt2);
- lineHelper->lineto(nextPointAt1);
- SBasisHelper = lineHelper->first_segment()->toSBasis();
- lineHelper->reset();
- delete lineHelper;
+ SPCurve *line_helper = new SPCurve();
+ line_helper->moveto(point_at2);
+ line_helper->lineto(next_point_at1);
+ sbasis_helper = line_helper->first_segment()->toSBasis();
+ line_helper->reset();
+ delete line_helper;
previousNode = node;
- node = SBasisHelper.valueAt(0.5);
+ node = sbasis_helper.valueAt(0.5);
Geom::CubicBezier const *cubic2 = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1);
if((cubic && are_near((*cubic)[0],(*cubic)[1])) || (cubic2 && are_near((*cubic2)[2],(*cubic2)[3]))) {
node = curve_it1->finalPoint();
}
- nCurve->curveto(pointAt1, pointAt2, node);
+ curve_n->curveto(point_at1, point_at2, node);
}
++curve_it1;
++curve_it2;
}
+ //y cerramos la curva
if (path_it->closed()) {
- nCurve->closepath_current();
+ curve_n->closepath_current();
}
- curve->append(nCurve, false);
- nCurve->reset();
- delete nCurve;
+ curve->append(curve_n, false);
+ curve_n->reset();
+ delete curve_n;
}
}
//Spiro function cloned from lpe-spiro.cpp
// commenting the function "doEffect" from src/live_effects/lpe-spiro.cpp
-void PenTool::_spiro_doEffect(SPCurve * curve)
+void PenTool::_spiroDoEffect(SPCurve * curve)
{
using Geom::X;
using Geom::Y;
@@ -2087,16 +2094,16 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) {
if (!this->red_curve->is_empty()) {
- this->_bspline_spiro(state & GDK_SHIFT_MASK);
+ this->_bsplineSpiro(state & GDK_SHIFT_MASK);
this->green_curve->append_continuous(this->red_curve, 0.0625);
SPCurve *curve = this->red_curve->copy();
/// \todo fixme:
- SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), curve);
+ SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), curve);
curve->unref();
- sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
+ sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
- this->green_bpaths = g_slist_prepend(this->green_bpaths, cshape);
+ this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape);
this->p[0] = this->p[3];
this->p[1] = this->p[4];
@@ -2143,7 +2150,7 @@ bool PenTool::_undoLastPoint() {
this->p[1] = this->p[0];
}
- // asign the value in a third of the distance of the last segment.
+ // assign the value in a third of the distance of the last segment.
if (this->bspline){
this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]);
}
@@ -2165,7 +2172,7 @@ bool PenTool::_undoLastPoint() {
this->green_curve->backspace();
}
- // assign the value of this->p[1] to the oposite of the green line last segment
+ // assign the value of this->p[1] to the opposite of the green line last segment
if (this->spiro){
Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(this->green_curve->last_segment());
if ( cubic ) {
@@ -2185,7 +2192,7 @@ bool PenTool::_undoLastPoint() {
pen_last_paraxial_dir = !pen_last_paraxial_dir;
//redraw
- this->_bspline_spiro_build();
+ this->_bsplineSpiroBuild();
ret = true;
}
@@ -2210,7 +2217,7 @@ void PenTool::_finish(gboolean const closed) {
// cancelate line without a created segment
this->red_curve->reset();
spdc_concat_colors_and_flush(this, closed);
- this->overwriteCurve = NULL;
+ this->overwrite_curve = NULL;
this->sa = NULL;
this->ea = NULL;
diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h
index 2208005c5..0ae16caf0 100644
--- a/src/ui/tools/pen-tool.h
+++ b/src/ui/tools/pen-tool.h
@@ -89,33 +89,33 @@ private:
bool _handle2ButtonPress(GdkEventButton const &bevent);
bool _handleKeyPress(GdkEvent *event);
//adds spiro & bspline modes
- void _pen_context_set_mode(guint mode);
+ void _penContextSetMode(guint mode);
//this function changes the colors red, green and blue making them transparent or not depending on if the function uses spiro
- void _bspline_spiro_color();
+ void _bsplineSpiroColor();
//creates a node in bspline or spiro modes
- void _bspline_spiro(bool shift);
+ void _bsplineSpiro(bool shift);
//creates a node in bspline or spiro modes
- void _bspline_spiro_on();
+ void _bsplineSpiroOn();
//creates a CUSP node
- void _bspline_spiro_off();
+ void _bsplineSpiroOff();
//continues the existing curve in bspline or spiro mode
- void _bspline_spiro_start_anchor(bool shift);
+ void _bsplineSpiroStartAnchor(bool shift);
//continues the existing curve with the union node in bspline or spiro modes
- void _bspline_spiro_start_anchor_on();
+ void _bsplineSpiroStartAnchorOn();
//continues an existing curve with the union node in CUSP mode
- void _bspline_spiro_start_anchor_off();
+ void _bsplineSpiroStartAnchorOff();
//modifies the "red_curve" when it detects movement
- void _bspline_spiro_motion(bool shift);
+ void _bsplineSpiroMotion(bool shift);
//closes the curve with the last node in bspline or spiro mode
- void _bspline_spiro_end_anchor_on();
+ void _bsplineSpiroEndAnchorOn();
//closes the curve with the last node in CUSP mode
- void _bspline_spiro_end_anchor_off();
+ void _bsplineSpiroEndAnchorOff();
//CHECK: join all the curves "in game" and we call doEffect function
- void _bspline_spiro_build();
+ void _bsplineSpiroBuild();
//function bspline cloned from lpe-bspline.cpp
- void _bspline_doEffect(SPCurve * curve);
+ void _bsplineDoEffect(SPCurve * curve);
//function spiro cloned from lpe-spiro.cpp
- void _spiro_doEffect(SPCurve * curve);
+ void _spiroDoEffect(SPCurve * curve);
void _setInitialPoint(Geom::Point const p);
void _setSubsequentPoint(Geom::Point const p, bool statusbar, guint status = 0);
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index db24c7432..008804162 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -191,7 +191,7 @@ bool PencilTool::_handleButtonPress(GdkEventButton const &bevent) {
}
if (anchor) {
p = anchor->dp;
- this->overwriteCurve = anchor->curve;
+ this->overwrite_curve = anchor->curve;
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Continuing selected path"));
} else {
m.setup(desktop);
@@ -663,11 +663,11 @@ void PencilTool::_interpolate() {
for (int c = 0; c < n_segs; c++) {
// if we are in BSpline we modify the trace to create adhoc nodes
if(mode == 2){
- Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]);
- BP = Geom::Point(BP[X] + 0.0001,BP[Y] + 0.0001);
- Geom::Point CP = b[4*c+3] + (1./3)*(b[4*c+0] - b[4*c+3]);
- CP = Geom::Point(CP[X] + 0.0001,CP[Y] + 0.0001);
- this->green_curve->curveto(BP,CP,b[4*c+3]);
+ Geom::Point point_at1 = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]);
+ point_at1 = Geom::Point(point_at1[X] + 0.0001,point_at1[Y] + 0.0001);
+ Geom::Point point_at2 = b[4*c+3] + (1./3)*(b[4*c+0] - b[4*c+3]);
+ point_at2 = Geom::Point(point_at2[X] + 0.0001,point_at2[Y] + 0.0001);
+ this->green_curve->curveto(point_at1,point_at2,b[4*c+3]);
}else{
this->green_curve->curveto(b[4 * c + 1], b[4 * c + 2], b[4 * c + 3]);
}
@@ -810,11 +810,11 @@ void PencilTool::_fitAndSplit() {
// if we are in BSpline we modify the trace to create adhoc nodes
guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0);
if(mode == 2){
- Geom::Point B = b[0] + (1./3)*(b[3] - b[0]);
- B = Geom::Point(B[X] + 0.0001,B[Y] + 0.0001);
- Geom::Point C = b[3] + (1./3)*(b[0] - b[3]);
- C = Geom::Point(C[X] + 0.0001,C[Y] + 0.0001);
- this->red_curve->curveto(B,C,b[3]);
+ Geom::Point point_at1 = b[0] + (1./3)*(b[3] - b[0]);
+ point_at1 = Geom::Point(point_at1[X] + 0.0001,point_at1[Y] + 0.0001);
+ Geom::Point point_at2 = b[3] + (1./3)*(b[0] - b[3]);
+ point_at2 = Geom::Point(point_at2[X] + 0.0001,point_at2[Y] + 0.0001);
+ this->red_curve->curveto(point_at1,point_at2,b[3]);
}else{
this->red_curve->curveto(b[1], b[2], b[3]);
}
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index 39321ff21..26d74733a 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -406,7 +406,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
parent->appendChild(copy);
SPObject *new_obj = doc->getObjectByRepr(copy);
- item_copied = dynamic_cast<SPItem *>(new_obj); // Convertion object->item
+ item_copied = dynamic_cast<SPItem *>(new_obj); // Conversion object->item
Geom::Point center=item->getCenter();
sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(_scale,_scale));
sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale,scale));
@@ -437,39 +437,41 @@ static bool sp_spray_recursive(SPDesktop *desktop,
}
i++;
}
- SPDocument *doc = parent_item->document;
- Inkscape::XML::Document* xml_doc = doc->getReprDoc();
- Inkscape::XML::Node *old_repr = parent_item->getRepr();
- Inkscape::XML::Node *parent = old_repr->parent();
-
- Geom::OptRect a = parent_item->documentVisualBounds();
- if (a) {
- if (_fid <= population) { // Rules the population of objects sprayed
- // Duplicates the parent item
- Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
- parent->appendChild(copy);
- SPObject *new_obj = doc->getObjectByRepr(copy);
- item_copied = dynamic_cast<SPItem *>(new_obj);
-
- // Move around the cursor
- Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());
-
- Geom::Point center = parent_item->getCenter();
- sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
- sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
- sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));
- sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
-
- // Union and duplication
- selection->clear();
- selection->add(item_copied);
- if (unionResult) { // No need to add the very first item (initialized with NULL).
- selection->add(unionResult);
+ if (parent_item) {
+ SPDocument *doc = parent_item->document;
+ Inkscape::XML::Document* xml_doc = doc->getReprDoc();
+ Inkscape::XML::Node *old_repr = parent_item->getRepr();
+ Inkscape::XML::Node *parent = old_repr->parent();
+
+ Geom::OptRect a = parent_item->documentVisualBounds();
+ if (a) {
+ if (_fid <= population) { // Rules the population of objects sprayed
+ // Duplicates the parent item
+ Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
+ parent->appendChild(copy);
+ SPObject *new_obj = doc->getObjectByRepr(copy);
+ item_copied = dynamic_cast<SPItem *>(new_obj);
+
+ // Move around the cursor
+ Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());
+
+ Geom::Point center = parent_item->getCenter();
+ sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
+ sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
+ sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));
+ sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
+
+ // Union and duplication
+ selection->clear();
+ selection->add(item_copied);
+ if (unionResult) { // No need to add the very first item (initialized with NULL).
+ selection->add(unionResult);
+ }
+ sp_selected_path_union_skip_undo(selection, selection->desktop());
+ selection->add(parent_item);
+ Inkscape::GC::release(copy);
+ did = true;
}
- sp_selected_path_union_skip_undo(selection, selection->desktop());
- selection->add(parent_item);
- Inkscape::GC::release(copy);
- did = true;
}
}
#endif
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp
index 8c3b44bf5..0a5697661 100644
--- a/src/ui/widget/page-sizer.cpp
+++ b/src/ui/widget/page-sizer.cpp
@@ -26,6 +26,7 @@
#include <cmath>
#include <string>
#include <string.h>
+#include <sstream>
#include <vector>
#include <glibmm/i18n.h>
@@ -240,6 +241,14 @@ PageSizer::PageSizer(Registry & _wr)
_marginRight( _("Ri_ght:"), _("Right margin"), "fit-margin-right", _wr),
_marginBottom( _("Botto_m:"), _("Bottom margin"), "fit-margin-bottom", _wr),
_lockMarginUpdate(false),
+ _scaleX(_("Scale _x:"), _("Scale X"), "scale-x", _wr),
+ _scaleY(_("Scale _y:"), _("Scale Y"), "scale-y", _wr),
+ _lockScaleUpdate(false),
+ _viewboxX(_("X:"), _("X"), "viewbox-x", _wr),
+ _viewboxY(_("Y:"), _("Y"), "viewbox-y", _wr),
+ _viewboxW(_("Width:"), _("Width"), "viewbox-width", _wr),
+ _viewboxH(_("Height:"), _("Height"), "viewbox-height", _wr),
+ _lockViewboxUpdate(false),
_widgetRegistry(&_wr)
{
// set precision of scalar entry boxes
@@ -250,6 +259,22 @@ PageSizer::PageSizer(Registry & _wr)
_marginLeft.setDigits(5);
_marginRight.setDigits(5);
_marginBottom.setDigits(5);
+ _scaleX.setDigits(5);
+ _scaleY.setDigits(5);
+ _viewboxX.setDigits(2);
+ _viewboxY.setDigits(2);
+ _viewboxW.setDigits(2);
+ _viewboxH.setDigits(2);
+
+ _scaleX.setRange( 0.00001, 100000 );
+ _scaleY.setRange( 0.00001, 100000 );
+ _viewboxX.setRange( -100000, 100000 );
+ _viewboxY.setRange( -100000, 100000 );
+ _viewboxW.setRange( 0, 200000 );
+ _viewboxH.setRange( 0, 200000 );
+
+ _scaleY.set_sensitive (false); // We only want to display Y scale.
+
_wr.setUpdating (false);
//# Set up the Paper Size combo box
@@ -318,6 +343,7 @@ PageSizer::PageSizer(Registry & _wr)
}
_wr.setUpdating (false);
+
//## Set up custom size frame
_customFrame.set_label(_("Custom size"));
pack_start (_customFrame, false, false, 0);
@@ -419,6 +445,75 @@ PageSizer::PageSizer(Registry & _wr)
_fitPageButton.set_label(_("_Resize page to drawing or selection"));
_fitPageButton.set_tooltip_text(_("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
+ _scaleFrame.set_label(_("Scale"));
+ pack_start (_scaleFrame, false, false, 0);
+ _scaleFrame.add(_scaleTable);
+
+ _scaleTable.set_border_width(4);
+
+#if WITH_GTKMM_3_0
+ _scaleTable.set_row_spacing(4);
+ _scaleTable.set_column_spacing(4);
+
+ _scaleTable.attach(_scaleX, 0, 0, 1, 1);
+ _scaleTable.attach(_scaleY, 1, 0, 1, 1);
+
+ _scaleTable.attach(_scaleLabel, 2, 0, 1, 1);
+ _scaleTable.attach(_scaleWarning, 0, 1, 2, 1);
+ _viewboxExpander.set_hexpand();
+ _viewboxExpander.set_vexpand();
+ _scaleTable.attach(_viewboxExpander, 0, 2, 2, 1);
+#else
+ _scaleTable.resize(3, 2);
+ _scaleTable.set_row_spacings(4);
+ _scaleTable.set_col_spacings(4);
+ _scaleTable.attach(_scaleX, 0,1, 0,1);
+ _scaleTable.attach(_scaleY, 1,2, 0,1);
+ _scaleTable.attach(_scaleLabel, 2,3, 0,1);
+ _scaleTable.attach(_scaleWarning, 0,3, 1,2, Gtk::FILL);
+ _scaleTable.attach(_viewboxExpander, 0,3, 2,3);
+#endif
+
+ _scaleWarning.set_label(_("While SVG allows non-uniform scaling it is recommended to use only uniform scaling in Inkscape. To set a non-uniform scaling, set the 'viewBox' directly."));
+ _scaleWarning.set_line_wrap( true );
+
+ _viewboxExpander.set_use_underline();
+ _viewboxExpander.set_label(_("_Viewbox..."));
+ _viewboxExpander.add(_viewboxTable);
+
+#if WITH_GTKMM_3_0
+ _viewboxTable.set_row_spacing(2);
+ _viewboxTable.set_column_spacing(2);
+
+ _viewboxX.set_hexpand();
+ _viewboxX.set_vexpand();
+ _viewboxTable.attach(_viewboxX, 0, 0, 1, 1);
+
+ _viewboxY.set_hexpand();
+ _viewboxY.set_vexpand();
+ _viewboxTable.attach(_viewboxY, 1, 0, 1, 1);
+
+ _viewboxW.set_hexpand();
+ _viewboxW.set_vexpand();
+ _viewboxTable.attach(_viewboxW, 0, 1, 1, 1);
+
+ _viewboxH.set_hexpand();
+ _viewboxH.set_vexpand();
+ _viewboxTable.attach(_viewboxH, 1, 1, 1, 1);
+
+#else
+ _viewboxTable.set_border_width(4);
+ _viewboxTable.set_row_spacings(2);
+ _viewboxTable.set_col_spacings(2);
+ _viewboxTable.attach(_viewboxX, 0,1, 0,1);
+ _viewboxTable.attach(_viewboxY, 1,2, 0,1);
+ _viewboxTable.attach(_viewboxW, 0,1, 1,2);
+ _viewboxTable.attach(_viewboxH, 1,2, 1,2);
+#endif
+
+ _wr.setUpdating (true);
+ updateScaleUI();
+ _wr.setUpdating (false);
}
@@ -444,7 +539,11 @@ PageSizer::init ()
_changedh_connection = _dimensionHeight.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed));
_changedu_connection = _dimensionUnits.getUnitMenu()->signal_changed().connect (sigc::mem_fun (*this, &PageSizer::on_units_changed));
_fitPageButton.signal_clicked().connect(sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing));
-
+ _changeds_connection = _scaleX.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_scale_changed));
+ _changedvx_connection = _viewboxX.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed));
+ _changedvy_connection = _viewboxY.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed));
+ _changedvw_connection = _viewboxW.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed));
+ _changedvh_connection = _viewboxH.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed));
show_all_children();
}
@@ -512,6 +611,7 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool
_dimensionHeight.setUnit(h.unit->abbr);
_dimensionHeight.setValue (h.quantity);
+
_paper_size_list_connection.unblock();
_landscape_connection.unblock();
_portrait_connection.unblock();
@@ -701,6 +801,88 @@ PageSizer::on_landscape()
}
}
+
+/**
+ * Update scale widgets
+ */
+void
+PageSizer::updateScaleUI()
+{
+
+ static bool _called = false;
+ if (_called) {
+ return;
+ }
+
+ _called = true;
+
+ _changeds_connection.block();
+ _changedvx_connection.block();
+ _changedvy_connection.block();
+ _changedvw_connection.block();
+ _changedvh_connection.block();
+
+ SPDesktop *dt = SP_ACTIVE_DESKTOP;
+ if (dt) {
+ SPDocument *doc = dt->getDocument();
+
+ // Update scale
+ Geom::Scale scale = doc->getDocumentScale();
+ SPNamedView *nv = dt->getNamedView();
+
+ std::stringstream ss;
+ ss << _("User units per ") << nv->display_units->abbr << "." ;
+ _scaleLabel.set_text( ss.str() );
+
+ if( !_lockScaleUpdate ) {
+
+ double scaleX_inv =
+ Inkscape::Util::Quantity::convert( scale[Geom::X], "px", nv->display_units );
+ if( scaleX_inv > 0 ) {
+ _scaleX.setValue(1.0/scaleX_inv);
+ } else {
+ // Should never happen
+ std::cerr << "PageSizer::updateScaleUI(): Invalid scale value: " << scaleX_inv << std::endl;
+ _scaleX.setValue(1.0);
+ }
+ }
+
+ { // Don't need to lock as scaleY widget not linked to callback.
+ double scaleY_inv =
+ Inkscape::Util::Quantity::convert( scale[Geom::Y], "px", nv->display_units );
+ if( scaleY_inv > 0 ) {
+ _scaleY.setValue(1.0/scaleY_inv);
+ } else {
+ // Should never happen
+ std::cerr << "PageSizer::updateScaleUI(): Invalid scale value: " << scaleY_inv << std::endl;
+ _scaleY.setValue(1.0);
+ }
+ }
+
+ if( !_lockViewboxUpdate ) {
+ Geom::Rect viewBox = doc->getViewBox();
+ _viewboxX.setValue( viewBox.min()[Geom::X] );
+ _viewboxY.setValue( viewBox.min()[Geom::Y] );
+ _viewboxW.setValue( viewBox.width() );
+ _viewboxH.setValue( viewBox.height() );
+ }
+
+ } else {
+ // Should never happen
+ std::cerr << "PageSizer::updateScaleUI(): No active desktop." << std::endl;
+ _scaleLabel.set_text( "Unknown scale" );
+ }
+
+ _changeds_connection.unblock();
+ _changedvx_connection.unblock();
+ _changedvy_connection.unblock();
+ _changedvw_connection.unblock();
+ _changedvh_connection.unblock();
+
+ _called = false;
+}
+
+
/**
* Callback for the dimension widgets
*/
@@ -712,6 +894,7 @@ PageSizer::on_value_changed()
setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()),
Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit()));
}
+
void
PageSizer::on_units_changed()
{
@@ -722,6 +905,63 @@ PageSizer::on_units_changed()
true, false);
}
+/**
+ * Callback for scale widgets
+ */
+void
+PageSizer::on_scale_changed()
+{
+ if (_widgetRegistry->isUpdating()) return;
+
+ double value = _scaleX.getValue();
+ if( value > 0 ) {
+
+ SPDesktop *dt = SP_ACTIVE_DESKTOP;
+ if (dt) {
+ SPDocument *doc = dt->getDocument();
+ SPNamedView *nv = dt->getNamedView();
+
+ double scaleX_inv = Inkscape::Util::Quantity(1.0/value, nv->display_units ).value("px");
+
+ _lockScaleUpdate = true;
+ doc->setDocumentScale( 1.0/scaleX_inv );
+ updateScaleUI();
+ _lockScaleUpdate = false;
+ DocumentUndo::done(doc, SP_VERB_NONE, _("Set page scale"));
+ }
+ }
+}
+
+/**
+ * Callback for viewbox widgets
+ */
+void
+PageSizer::on_viewbox_changed()
+{
+ if (_widgetRegistry->isUpdating()) return;
+
+ double viewboxX = _viewboxX.getValue();
+ double viewboxY = _viewboxY.getValue();
+ double viewboxW = _viewboxW.getValue();
+ double viewboxH = _viewboxH.getValue();
+
+ if( viewboxW > 0 && viewboxH > 0) {
+ SPDesktop *dt = SP_ACTIVE_DESKTOP;
+ if (dt) {
+ SPDocument *doc = dt->getDocument();
+ _lockViewboxUpdate = true;
+ doc->setViewBox( Geom::Rect::from_xywh( viewboxX, viewboxY, viewboxW, viewboxH ) );
+ updateScaleUI();
+ _lockViewboxUpdate = false;
+ DocumentUndo::done(doc, SP_VERB_NONE, _("Set 'viewBox'"));
+ }
+ } else {
+ std::cerr
+ << "PageSizer::on_viewbox_changed(): width and height must both be greater than zero."
+ << std::endl;
+ }
+}
+
} // namespace Widget
} // namespace UI
} // namespace Inkscape
diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h
index bed117e5a..0eea28e61 100644
--- a/src/ui/widget/page-sizer.h
+++ b/src/ui/widget/page-sizer.h
@@ -169,6 +169,11 @@ public:
*/
void updateFitMarginsUI(Inkscape::XML::Node *nv_repr);
+ /**
+ * Updates the scale widgets. (Just changes the values of the ui widgets.)
+ */
+ void updateScaleUI();
+
protected:
/**
@@ -250,12 +255,47 @@ protected:
Gtk::Button _fitPageButton;
bool _lockMarginUpdate;
+ // Document scale
+ Gtk::Frame _scaleFrame;
+#if WITH_GTKMM_3_0
+ Gtk::Grid _scaleTable;
+#else
+ Gtk::Table _scaleTable;
+#endif
+
+ Gtk::Label _scaleLabel;
+ Gtk::Label _scaleWarning;
+ RegisteredScalar _scaleX;
+ RegisteredScalar _scaleY;
+ bool _lockScaleUpdate;
+
+ // Viewbox
+ Gtk::Expander _viewboxExpander;
+#if WITH_GTKMM_3_0
+ Gtk::Grid _viewboxTable;
+#else
+ Gtk::Table _viewboxTable;
+#endif
+
+ RegisteredScalar _viewboxX;
+ RegisteredScalar _viewboxY;
+ RegisteredScalar _viewboxW;
+ RegisteredScalar _viewboxH;
+ bool _lockViewboxUpdate;
+
//callback
void on_value_changed();
void on_units_changed();
+ void on_scale_changed();
+ void on_viewbox_changed();
sigc::connection _changedw_connection;
sigc::connection _changedh_connection;
sigc::connection _changedu_connection;
+ sigc::connection _changeds_connection;
+ sigc::connection _changedvx_connection;
+ sigc::connection _changedvy_connection;
+ sigc::connection _changedvw_connection;
+ sigc::connection _changedvh_connection;
Registry *_widgetRegistry;
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index 1fc67dcef..9e283fc64 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -25,8 +25,8 @@
#include "desktop-style.h"
#include "sp-namedview.h"
#include "sp-linear-gradient.h"
-#include "sp-mesh-gradient.h"
#include "sp-radial-gradient.h"
+#include "sp-mesh.h"
#include "sp-pattern.h"
#include "ui/dialog/dialog-manager.h"
#include "ui/dialog/fill-and-stroke.h"
@@ -1045,7 +1045,7 @@ SelectedStyle::update()
place->set_tooltip_text(__rgradient[i]);
_mode[i] = SS_RGRADIENT;
#ifdef WITH_MESH
- } else if (SP_IS_MESHGRADIENT(server)) {
+ } else if (SP_IS_MESH(server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), vector);
place->add(_gradient_box_m[i]);