diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-11-14 00:08:40 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-11-14 00:08:40 +0000 |
| commit | 87469d81799b58681b91800234f266ea8b19b30b (patch) | |
| tree | 41a689b06ec1649fe20f5c27487c7bebbb47b40c /src | |
| parent | Really add new text-decoration properties. (diff) | |
| download | inkscape-87469d81799b58681b91800234f266ea8b19b30b.tar.gz inkscape-87469d81799b58681b91800234f266ea8b19b30b.zip | |
Add inverse subdivision chamfer to fillet chamfer LPE, feature sugested by Ivan Louette.
(bzr r13708)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 76 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.h | 4 | ||||
| -rw-r--r-- | src/live_effects/parameter/filletchamferpointarray.cpp | 32 | ||||
| -rw-r--r-- | src/ui/dialog/lpe-fillet-chamfer-properties.cpp | 15 | ||||
| -rw-r--r-- | src/ui/dialog/lpe-fillet-chamfer-properties.h | 1 |
5 files changed, 99 insertions, 29 deletions
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index c89bfbd37..78e24f0b8 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -79,7 +79,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : radius.param_set_range(0., infinity()); radius.param_set_increments(1, 1); radius.param_set_digits(4); - chamfer_steps.param_set_range(0, infinity()); + chamfer_steps.param_set_range(0, 999); chamfer_steps.param_set_increments(1, 1); chamfer_steps.param_set_digits(0); helper_size.param_set_range(0, infinity()); @@ -116,7 +116,7 @@ Gtk::Widget *LPEFilletChamfer::newWidget() } } 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)); + widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::chamferSubdivisions)); widg = widgRegistered; if (widg) { Gtk::HBox *scalarParameter = dynamic_cast<Gtk::HBox *>(widg); @@ -153,21 +153,26 @@ Gtk::Widget *LPEFilletChamfer::newWidget() ++it; } - - Gtk::VBox *buttonsContainer = Gtk::manage(new Gtk::VBox(true, 0)); + Gtk::HBox *filletContainer = Gtk::manage(new Gtk::HBox(true, 0)); Gtk::Button *fillet = Gtk::manage(new Gtk::Button(Glib::ustring(_("Fillet")))); fillet->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::fillet)); - buttonsContainer->pack_start(*fillet, true, true, 2); - Gtk::Button *inverse = Gtk::manage(new Gtk::Button(Glib::ustring(_("Inverse fillet")))); - inverse->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::inverse)); - buttonsContainer->pack_start(*inverse, true, true, 2); - + filletContainer->pack_start(*fillet, true, true, 2); + Gtk::Button *inverseFillet = Gtk::manage(new Gtk::Button(Glib::ustring(_("Inverse fillet")))); + inverseFillet->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::inverseFillet)); + filletContainer->pack_start(*inverseFillet, true, true, 2); + + Gtk::HBox *chamferContainer = Gtk::manage(new Gtk::HBox(true, 0)); Gtk::Button *chamfer = Gtk::manage(new Gtk::Button(Glib::ustring(_("Chamfer")))); chamfer->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::chamfer)); - buttonsContainer->pack_start(*chamfer, true, true, 2); - vbox->pack_start(*buttonsContainer, true, true, 2); + chamferContainer->pack_start(*chamfer, true, true, 2); + Gtk::Button *inverseChamfer = Gtk::manage(new Gtk::Button(Glib::ustring(_("Inverse chamfer")))); + inverseChamfer->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::inverseChamfer)); + chamferContainer->pack_start(*inverseChamfer, true, true, 2); + + vbox->pack_start(*filletContainer, true, true, 2); + vbox->pack_start(*chamferContainer, true, true, 2); return vbox; } @@ -232,17 +237,31 @@ void LPEFilletChamfer::fillet() doChangeType(path_from_piecewise(pwd2, tolerance), 1); } -void LPEFilletChamfer::inverse() +void LPEFilletChamfer::inverseFillet() { Piecewise<D2<SBasis> > const &pwd2 = fillet_chamfer_values.get_pwd2(); doChangeType(path_from_piecewise(pwd2, tolerance), 2); } +void LPEFilletChamfer::chamferSubdivisions() +{ + fillet_chamfer_values.set_chamfer_steps(chamfer_steps); + Piecewise<D2<SBasis> > const &pwd2 = fillet_chamfer_values.get_pwd2(); + doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 5000); +} + void LPEFilletChamfer::chamfer() { - fillet_chamfer_values.set_chamfer_steps(chamfer_steps + 3); + fillet_chamfer_values.set_chamfer_steps(chamfer_steps); Piecewise<D2<SBasis> > const &pwd2 = fillet_chamfer_values.get_pwd2(); - doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 3); + doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 3000); +} + +void LPEFilletChamfer::inverseChamfer() +{ + fillet_chamfer_values.set_chamfer_steps(chamfer_steps); + Piecewise<D2<SBasis> > const &pwd2 = fillet_chamfer_values.get_pwd2(); + doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 4000); } void LPEFilletChamfer::refreshKnots() @@ -333,6 +352,13 @@ void LPEFilletChamfer::doChangeType(std::vector<Geom::Path> const& original_path toggle = false; } if (toggle) { + if(type >= 5000){ + if(filletChamferData[counter][Y] >= 3000 && filletChamferData[counter][Y] < 4000){ + type = type - 2000; + } else if (filletChamferData[counter][Y] >= 4000 && filletChamferData[counter][Y] < 5000){ + type = type - 1000; + } + } result.push_back(Point(filletChamferData[counter][X], type)); } else { result.push_back(filletChamferData[counter]); @@ -552,8 +578,8 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) } else { type = std::abs(filletChamferData[counter + 1][Y]); } - if (type >= 3) { - unsigned int chamferSubs = type-2; + if (type >= 3000 && type < 4000) { + unsigned int chamferSubs = type-2999; Geom::Path path_chamfer; path_chamfer.start(path_out.finalPoint()); if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ @@ -567,6 +593,22 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) path_out.appendNew<Geom::LineSegment>(chamferStep); } path_out.appendNew<Geom::LineSegment>(endArcPoint); + } else if (type >= 4000 && type < 5000) { + unsigned int chamferSubs = type-3999; + Geom::Path path_chamfer; + path_chamfer.start(path_out.finalPoint()); + if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ + ccwToggle = ccwToggle?0:1; + path_chamfer.appendNew<SVGEllipticalArc>(rx, ry, angleArc, 0, ccwToggle, endArcPoint); + }else{ + path_chamfer.appendNew<Geom::CubicBezier>(inverseHandle1, inverseHandle2, endArcPoint); + } + double chamfer_stepsTime = 1.0/chamferSubs; + for(unsigned int i = 1; i < chamferSubs; i++){ + Geom::Point chamferStep = path_chamfer.pointAt(chamfer_stepsTime * i); + path_out.appendNew<Geom::LineSegment>(chamferStep); + } + path_out.appendNew<Geom::LineSegment>(endArcPoint); } else if (type == 2) { if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ ccwToggle = ccwToggle?0:1; @@ -574,7 +616,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) }else{ path_out.appendNew<Geom::CubicBezier>(inverseHandle1, inverseHandle2, endArcPoint); } - } else { + } else if (type == 1){ if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ path_out.appendNew<SVGEllipticalArc>(rx, ry, angleArc, 0, ccwToggle, endArcPoint); } else { diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h index e3589197c..0d6a1ff17 100644 --- a/src/live_effects/lpe-fillet-chamfer.h +++ b/src/live_effects/lpe-fillet-chamfer.h @@ -56,8 +56,10 @@ public: void toggleHide(); void toggleFlexFixed(); void chamfer(); + void chamferSubdivisions(); + void inverseChamfer(); void fillet(); - void inverse(); + void inverseFillet(); void updateFillet(); void doUpdateFillet(std::vector<Geom::Path> const& original_pathv, double power); void doChangeType(std::vector<Geom::Path> const& original_pathv, int type); diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp index cf9ef3132..4e2be6e88 100644 --- a/src/live_effects/parameter/filletchamferpointarray.cpp +++ b/src/live_effects/parameter/filletchamferpointarray.cpp @@ -723,7 +723,7 @@ FilletChamferPointArrayParamKnotHolderEntity( void FilletChamferPointArrayParamKnotHolderEntity::knot_set(Point const &p, Point const &/*origin*/, - guint /*state*/) + guint state) { using namespace Geom; @@ -733,7 +733,7 @@ void FilletChamferPointArrayParamKnotHolderEntity::knot_set(Point const &p, /// @todo how about item transforms??? Piecewise<D2<SBasis> > const &pwd2 = _pparam->get_pwd2(); //todo: add snapping - //Geom::Point const s = snap_knot_position(p, state); + Geom::Point const s = snap_knot_position(p, state); double t = nearest_point(p, pwd2[_index]); if (t == 1) { t = 0.9999; @@ -777,13 +777,21 @@ void FilletChamferPointArrayParamKnotHolderEntity::knot_click(guint state) }else{ using namespace Geom; int type = (int)_pparam->_vector.at(_index)[Y]; - + if (type >=3000 && type < 4000){ + type = 3; + } + if (type >=4000 && type < 5000){ + type = 4; + } switch(type){ case 1: type = 2; break; case 2: - type = _pparam->chamfer_steps; + type = _pparam->chamfer_steps + 3000; + break; + case 3: + type = _pparam->chamfer_steps + 4000; break; default: type = 1; @@ -793,8 +801,12 @@ void FilletChamferPointArrayParamKnotHolderEntity::knot_click(guint state) _pparam->param_set_and_write_new_value(_pparam->_vector); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); const gchar *tip; - if (type >= 3) { - tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toogle type, " + if (type >=3000 && type < 4000){ + tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (type >=4000 && type < 5000) { + tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toogle type, " "<b>Shift+Click</b> open dialog, " "<b>Ctrl+Alt+Click</b> reset"); } else if (type == 2) { @@ -850,8 +862,12 @@ void FilletChamferPointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, continue; } const gchar *tip; - if (_vector[i][Y] >= 3) { - tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toogle type, " + if (_vector[i][Y] >=3000 && _vector[i][Y] < 4000){ + tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (_vector[i][Y] >=4000 && _vector[i][Y] < 5000) { + tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toogle type, " "<b>Shift+Click</b> open dialog, " "<b>Ctrl+Alt+Click</b> reset"); } else if (_vector[i][Y] == 2) { diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp index e55c9f8df..55a19fc51 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp @@ -79,12 +79,15 @@ FilletChamferPropertiesDialog::FilletChamferPropertiesDialog() _fillet_chamfer_type_inverse_fillet.set_group(_fillet_chamfer_type_group); _fillet_chamfer_type_chamfer.set_label(_("Chamfer")); _fillet_chamfer_type_chamfer.set_group(_fillet_chamfer_type_group); + _fillet_chamfer_type_inverse_chamfer.set_label(_("Inverse chamfer")); + _fillet_chamfer_type_inverse_chamfer.set_group(_fillet_chamfer_type_group); mainVBox->pack_start(_layout_table, true, true, 4); mainVBox->pack_start(_fillet_chamfer_type_fillet, true, true, 4); mainVBox->pack_start(_fillet_chamfer_type_inverse_fillet, true, true, 4); mainVBox->pack_start(_fillet_chamfer_type_chamfer, true, true, 4); + mainVBox->pack_start(_fillet_chamfer_type_inverse_chamfer, true, true, 4); // Buttons _close_button.set_use_stock(true); @@ -158,8 +161,10 @@ void FilletChamferPropertiesDialog::_apply() d_width = 1; } else if (_fillet_chamfer_type_inverse_fillet.get_active() == true) { d_width = 2; + } else if (_fillet_chamfer_type_inverse_chamfer.get_active() == true) { + d_width = _fillet_chamfer_chamfer_subdivisions.get_value() + 4000; } else { - d_width = _fillet_chamfer_chamfer_subdivisions.get_value() + 3; + d_width = _fillet_chamfer_chamfer_subdivisions.get_value() + 3000; } if (_flexible) { if (d_pos > 99.99999 || d_pos < 0) { @@ -229,8 +234,12 @@ void FilletChamferPropertiesDialog::_set_knot_point(Geom::Point knotpoint) _fillet_chamfer_type_fillet.set_active(true); } else if (knotpoint.y() == 2) { _fillet_chamfer_type_inverse_fillet.set_active(true); - } else if (knotpoint.y() >= 3) { - _fillet_chamfer_chamfer_subdivisions.set_value(knotpoint.y() - 3); + } else if (knotpoint.y() >= 3000 && knotpoint.y() < 4000) { + _fillet_chamfer_chamfer_subdivisions.set_value(knotpoint.y() - 3000); + _fillet_chamfer_type_chamfer.set_active(true); + } else if (knotpoint.y() >= 4000 && knotpoint.y() < 5000) { + _fillet_chamfer_chamfer_subdivisions.set_value(knotpoint.y() - 4000); + _fillet_chamfer_type_inverse_chamfer.set_active(true); } } diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h index ec87addc5..3807e98c8 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.h +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h @@ -47,6 +47,7 @@ protected: Gtk::RadioButton _fillet_chamfer_type_fillet; Gtk::RadioButton _fillet_chamfer_type_inverse_fillet; Gtk::RadioButton _fillet_chamfer_type_chamfer; + Gtk::RadioButton _fillet_chamfer_type_inverse_chamfer; Gtk::Label _fillet_chamfer_chamfer_subdivisions_label; Gtk::SpinButton _fillet_chamfer_chamfer_subdivisions; |
