diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-11-05 18:30:49 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-11-05 18:30:49 +0000 |
| commit | f51e8d7c6b4e2caa9e470af674949f3cd1695bf5 (patch) | |
| tree | 2a733dbe915ff764ee9df8ac5840fa084c3f2ffc /src/live_effects/lpe-fillet-chamfer.cpp | |
| parent | Symbols. Fix for bug #1388910 (There is an unnecessary character in MapSymbol... (diff) | |
| download | inkscape-f51e8d7c6b4e2caa9e470af674949f3cd1695bf5.tar.gz inkscape-f51e8d7c6b4e2caa9e470af674949f3cd1695bf5.zip | |
Refactor to remove references to Desktop/Ui in Effect, bspline and fillet-chamfer.
Also fixed the selected node problem in units not px.
Also fixed two var to not allow NULL pointed by Johan Engelen.
(bzr r13672)
Diffstat (limited to 'src/live_effects/lpe-fillet-chamfer.cpp')
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 81 |
1 files changed, 15 insertions, 66 deletions
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index da6819120..c491ea858 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -28,12 +28,7 @@ #include "live_effects/parameter/filletchamferpointarray.h" // for programmatically updating knots -#include "selection.h" #include "ui/tools-switch.h" -#include "ui/tool/control-point-selection.h" -#include "ui/tool/selectable-control-point.h" -#include "ui/tool/node.h" -#include "ui/tools/node-tool.h" #include <util/units.h> // TODO due to internal breakage in glibmm headers, this must be last: @@ -65,7 +60,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : unit(_("Unit"), _("Unit"), "unit", &wr, this), method(_("Method"), _("Fillets methods"), "method", FMConverter, &wr, this, FM_AUTO), radius(_("Radius (unit or %)"), _("Radius, in unit or %"), "radius", &wr, this, 0.), - chamferSteps(_("Chamfer steps"), _("Chamfer steps"), "chamferSteps", &wr, this, 0), + chamfer_steps(_("Chamfer steps"), _("Chamfer steps"), "chamfer_steps", &wr, this, 0), helper_size(_("Helper size with direction"), _("Helper size with direction"), "helper_size", &wr, this, 0) { @@ -73,7 +68,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : registerParameter(&unit); registerParameter(&method); registerParameter(&radius); - registerParameter(&chamferSteps); + registerParameter(&chamfer_steps); registerParameter(&helper_size); registerParameter(&flexible); registerParameter(&use_knot_distance); @@ -84,12 +79,13 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : radius.param_set_range(0., infinity()); radius.param_set_increments(1, 1); radius.param_set_digits(4); - chamferSteps.param_set_range(0, infinity()); - chamferSteps.param_set_increments(1, 1); - chamferSteps.param_set_digits(0); + chamfer_steps.param_set_range(0, infinity()); + chamfer_steps.param_set_increments(1, 1); + chamfer_steps.param_set_digits(0); helper_size.param_set_range(0, infinity()); helper_size.param_set_increments(5, 5); helper_size.param_set_digits(0); + fillet_chamfer_values.set_chamfer_steps(3); } LPEFilletChamfer::~LPEFilletChamfer() {} @@ -118,7 +114,7 @@ Gtk::Widget *LPEFilletChamfer::newWidget() Gtk::Entry *entryWidg = dynamic_cast<Gtk::Entry *>(childList[1]); entryWidg->set_width_chars(6); } - } else if (param->param_key == "chamferSteps") { + } else if (param->param_key == "chamfer_steps") { Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::chamfer)); widg = widgRegistered; @@ -222,8 +218,7 @@ void LPEFilletChamfer::updateFillet() { double power = 0; if (!flexible) { - Inkscape::Util::Unit const *doc_units = SP_ACTIVE_DESKTOP->namedview->doc_units; - power = Inkscape::Util::Quantity::convert(radius, unit.get_abbreviation(), doc_units->abbr) * -1; + power = Inkscape::Util::Quantity::convert(radius, unit.get_abbreviation(), *defaultUnit) * -1; } else { power = radius; } @@ -245,9 +240,9 @@ void LPEFilletChamfer::inverse() void LPEFilletChamfer::chamfer() { + fillet_chamfer_values.set_chamfer_steps(chamfer_steps + 3); Piecewise<D2<SBasis> > const &pwd2 = fillet_chamfer_values.get_pwd2(); - doChangeType(path_from_piecewise(pwd2, tolerance), chamferSteps + 3); - fillet_chamfer_values.set_chamferSteps(chamferSteps + 3); + doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 3); } void LPEFilletChamfer::refreshKnots() @@ -261,35 +256,8 @@ void LPEFilletChamfer::refreshKnots() } } -bool LPEFilletChamfer::nodeIsSelected(Geom::Point nodePoint, std::vector<Geom::Point> selectedPoints) -{ - if (selectedPoints.size() > 0) { - for (std::vector<Geom::Point>::iterator i = selectedPoints.begin(); i != selectedPoints.end(); - ++i) { - Geom::Point p = *i; - if (Geom::are_near(p, nodePoint, 2)) { - return true; - } - } - } - return false; -} void LPEFilletChamfer::doUpdateFillet(std::vector<Geom::Path> const& original_pathv, double power) { - std::vector<Geom::Point> selectedPoints; - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (INK_IS_NODE_TOOL(desktop->event_context)) { - Inkscape::UI::Tools::NodeTool *nodeTool = INK_NODE_TOOL(desktop->event_context); - Inkscape::UI::ControlPointSelection::Set &selection = nodeTool->_selected_nodes->allPoints(); - std::vector<Geom::Point>::iterator pBegin; - for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i) { - if ((*i)->selected()) { - Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); - pBegin = selectedPoints.begin(); - selectedPoints.insert(pBegin, desktop->doc2dt(n->position())); - } - } - } std::vector<Point> filletChamferData = fillet_chamfer_values.data(); std::vector<Geom::Point> result; std::vector<Geom::Path> original_pathv_processed = pathv_to_linear_and_cubic_beziers(original_pathv); @@ -324,7 +292,7 @@ void LPEFilletChamfer::doUpdateFillet(std::vector<Geom::Path> const& original_pa if (filletChamferData[counter][Y] == 0) { powerend = filletChamferData[counter][X]; } - if (only_selected && !nodeIsSelected(curve_it1->initialPoint(), selectedPoints)) { + if (only_selected && !isNodePointSelected(curve_it1->initialPoint())) { powerend = filletChamferData[counter][X]; } result.push_back(Point(powerend, filletChamferData[counter][Y])); @@ -338,24 +306,6 @@ void LPEFilletChamfer::doUpdateFillet(std::vector<Geom::Path> const& original_pa void LPEFilletChamfer::doChangeType(std::vector<Geom::Path> const& original_pathv, int type) { - std::vector<Geom::Point> selectedPoints; - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (INK_IS_NODE_TOOL(desktop->event_context)) { - Inkscape::UI::Tools::NodeTool *nodeTool = - INK_NODE_TOOL(desktop->event_context); - Inkscape::UI::ControlPointSelection::Set &selection = - nodeTool->_selected_nodes->allPoints(); - std::vector<Geom::Point>::iterator pBegin; - for (Inkscape::UI::ControlPointSelection::Set::iterator i = - selection.begin(); - i != selection.end(); ++i) { - if ((*i)->selected()) { - Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); - pBegin = selectedPoints.begin(); - selectedPoints.insert(pBegin, desktop->doc2dt(n->position())); - } - } - } std::vector<Point> filletChamferData = fillet_chamfer_values.data(); std::vector<Geom::Point> result; std::vector<Geom::Path> original_pathv_processed = pathv_to_linear_and_cubic_beziers(original_pathv); @@ -378,9 +328,8 @@ void LPEFilletChamfer::doChangeType(std::vector<Geom::Path> const& original_path bool toggle = true; if (filletChamferData[counter][Y] == 0 || (ignore_radius_0 && (filletChamferData[counter][X] == 0 || - filletChamferData[counter][X] == counter)) || - (only_selected && - !nodeIsSelected(curve_it1->initialPoint(), selectedPoints))) { + filletChamferData[counter][X] == counter)) || + (only_selected && !isNodePointSelected(curve_it1->initialPoint()))) { toggle = false; } if (toggle) { @@ -611,9 +560,9 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) } else { path_chamfer.appendNew<Geom::CubicBezier>(handle1, handle2, endArcPoint); } - double chamferStepsTime = 1.0/chamferSubs; + double chamfer_stepsTime = 1.0/chamferSubs; for(unsigned int i = 1; i < chamferSubs; i++){ - Geom::Point chamferStep = path_chamfer.pointAt(chamferStepsTime * i); + Geom::Point chamferStep = path_chamfer.pointAt(chamfer_stepsTime * i); path_out.appendNew<Geom::LineSegment>(chamferStep); } path_out.appendNew<Geom::LineSegment>(endArcPoint); |
