diff options
| author | Jabiertxof <jtx@jtx> | 2017-05-06 21:00:45 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx> | 2017-05-06 21:00:45 +0000 |
| commit | 5b4c7fc7fbd532673473fd47b781bfc740cc5a07 (patch) | |
| tree | ba25e272b103ac38c7bc719cd565d81243d8de44 /src | |
| parent | Fix a compiling bug found by Ede_123 on IRC (diff) | |
| download | inkscape-5b4c7fc7fbd532673473fd47b781bfc740cc5a07.tar.gz inkscape-5b4c7fc7fbd532673473fd47b781bfc740cc5a07.zip | |
Add improvement pointed in IRC by Ede_123 to allow defaultables parametes on fillet chamfer
(bzr r15668)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/geom-satellite.h | 6 | ||||
| -rw-r--r-- | src/live_effects/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 54 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.h | 2 |
4 files changed, 58 insertions, 6 deletions
diff --git a/src/helper/geom-satellite.h b/src/helper/geom-satellite.h index a4d63d66e..b8ca2a490 100644 --- a/src/helper/geom-satellite.h +++ b/src/helper/geom-satellite.h @@ -51,15 +51,15 @@ public: { hidden = set_hidden; } - void setAmount(bool set_amount) + void setAmount(double set_amount) { amount = set_amount; } - void setAngle(bool set_angle) + void setAngle(double set_angle) { angle = set_angle; } - void setSteps(bool set_steps) + void setSteps(size_t set_steps) { steps = set_steps; } diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index f67c43db0..c2f434f50 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -59,6 +59,7 @@ set(live_effects_SRC parameter/array.cpp parameter/bool.cpp + parameter/hidden.cpp parameter/item-reference.cpp parameter/item.cpp parameter/originalitem.cpp @@ -143,6 +144,7 @@ set(live_effects_SRC parameter/array.h parameter/bool.h + parameter/hidden.h parameter/enum.h parameter/item.h parameter/item-reference.h diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index e968a7822..08ceab3c3 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -37,6 +37,8 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) "satellites_param", &wr, this), method(_("Method:"), _("Methods to calculate the fillet or chamfer"), "method", FMConverter, &wr, this, FM_AUTO), + mode(_("Mode:"), _("Mode, fillet or chamfer"), + "mode", &wr, this, "F"), radius(_("Radius (unit or %):"), _("Radius, in unit or %"), "radius", &wr, this, 0.0), chamfer_steps(_("Chamfer steps:"), _("Chamfer steps"), "chamfer_steps", @@ -63,6 +65,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) registerParameter(&satellites_param); registerParameter(&unit); registerParameter(&method); + registerParameter(&mode); registerParameter(&radius); registerParameter(&chamfer_steps); registerParameter(&helper_size); @@ -94,6 +97,22 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) if (shape) { Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(shape->getCurve()->get_pathvector()); Satellites satellites; + double power = radius; + std::cout << power << "power\n"; + if (!flexible) { + SPDocument * document = SP_ACTIVE_DOCUMENT; + SPNamedView *nv = sp_document_namedview(document, NULL); + Glib::ustring display_unit = nv->display_units->abbr; + power = Inkscape::Util::Quantity::convert(power, unit.get_abbreviation(), display_unit.c_str()); + } + std::cout << power << "power22222222\n"; + SatelliteType satellite_type = FILLET; + std::map<std::string, SatelliteType> gchar_map_to_satellite_type = + boost::assign::map_list_of("F", FILLET)("IF", INVERSE_FILLET)("C", CHAMFER)("IC", INVERSE_CHAMFER)("KO", INVALID_SATELLITE); + std::map<std::string, SatelliteType>::iterator it = gchar_map_to_satellite_type.find(std::string(mode.param_getSVGValue())); + if (it != gchar_map_to_satellite_type.end()) { + satellite_type = it->second; + } for (Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { if (path_it->empty()) { continue; @@ -104,8 +123,12 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) //if (curve_it->isDegenerate()) { // continue //} - Satellite satellite(FILLET); + Satellite satellite(satellite_type); satellite.setSteps(chamfer_steps); + satellite.setAmount(power); + satellite.setIsTime(flexible); + satellite.setHasMirror(mirror_knots); + satellite.setHidden(hide_knots); subpath_satellites.push_back(satellite); } //we add the last satellite on open path because _pathvector_satellites is related to nodes, not curves @@ -113,8 +136,12 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) //dont remove for this effect because _pathvector_satellites class has methods when the path is modiffied //and we want one method for all uses if (!path_it->closed()) { - Satellite satellite(FILLET); + Satellite satellite(satellite_type); satellite.setSteps(chamfer_steps); + satellite.setAmount(power); + satellite.setIsTime(flexible); + satellite.setHasMirror(mirror_knots); + satellite.setHidden(hide_knots); subpath_satellites.push_back(satellite); } satellites.push_back(subpath_satellites); @@ -265,6 +292,9 @@ void LPEFilletChamfer::updateChamferSteps() void LPEFilletChamfer::updateSatelliteType(SatelliteType satellitetype) { + std::map<SatelliteType, gchar const *> satellite_type_to_gchar_map = + boost::assign::map_list_of(FILLET, "F")(INVERSE_FILLET, "IF")(CHAMFER, "C")(INVERSE_CHAMFER, "IC")(INVALID_SATELLITE, "KO"); + mode.param_setValue((Glib::ustring)satellite_type_to_gchar_map.at(satellitetype)); setSelected(_pathvector_satellites); _pathvector_satellites->updateSatelliteType(satellitetype, apply_no_radius, apply_with_radius, only_selected); satellites_param.setPathVectorSatellites(_pathvector_satellites); @@ -306,7 +336,25 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) size_t number_nodes = pathv.nodes().size(); size_t previous_number_nodes = _pathvector_satellites->getTotalSatellites(); if (number_nodes != previous_number_nodes) { - Satellite satellite(FILLET); + Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(sp_curve->get_pathvector()); + Satellites satellites; + double power = radius; + if (!flexible) { + SPDocument * document = SP_ACTIVE_DOCUMENT; + SPNamedView *nv = sp_document_namedview(document, NULL); + Glib::ustring display_unit = nv->display_units->abbr; + power = Inkscape::Util::Quantity::convert(power, unit.get_abbreviation(), display_unit.c_str()); + } + SatelliteType satellite_type = FILLET; + std::map<std::string, SatelliteType> gchar_map_to_satellite_type = + boost::assign::map_list_of("F", FILLET)("IF", INVERSE_FILLET)("C", CHAMFER)("IC", INVERSE_CHAMFER)("KO", INVALID_SATELLITE); + std::map<std::string, SatelliteType>::iterator it = gchar_map_to_satellite_type.find(std::string(mode.param_getSVGValue())); + if (it != gchar_map_to_satellite_type.end()) { + satellite_type = it->second; + } + Satellite satellite(satellite_type); + satellite.setSteps(chamfer_steps); + satellite.setAmount(power); satellite.setIsTime(flexible); satellite.setHasMirror(mirror_knots); satellite.setHidden(hide_knots); diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h index 7f5dd7d4c..c628added 100644 --- a/src/live_effects/lpe-fillet-chamfer.h +++ b/src/live_effects/lpe-fillet-chamfer.h @@ -16,6 +16,7 @@ #include "live_effects/parameter/satellitesarray.h" #include "live_effects/effect.h" #include "live_effects/parameter/unit.h" +#include "live_effects/parameter/hidden.h" #include "helper/geom-pathvectorsatellites.h" #include "helper/geom-satellite.h" @@ -54,6 +55,7 @@ private: ScalarParam radius; ScalarParam chamfer_steps; BoolParam flexible; + HiddenParam mode; BoolParam mirror_knots; BoolParam only_selected; BoolParam use_knot_distance; |
