diff --git a/CMakeScripts/InstallMSYS2.cmake b/CMakeScripts/InstallMSYS2.cmake index aac4fd6482333927978206c4df018a895a99aa00..c8c580fe4ecdd35e7c0985aa914a891d6f15b653 100644 --- a/CMakeScripts/InstallMSYS2.cmake +++ b/CMakeScripts/InstallMSYS2.cmake @@ -166,7 +166,20 @@ if(WIN32) install(DIRECTORY ${MINGW_PATH}/share/glib-2.0/schemas DESTINATION ${CMAKE_INSTALL_PREFIX}/share/glib-2.0) + # fontconfig install(DIRECTORY ${MINGW_PATH}/etc/fonts + DESTINATION ${CMAKE_INSTALL_PREFIX}/etc + FILES_MATCHING PATTERN "fonts.conf" EXCLUDE) + # adjust fonts.conf to store font cache in AppData + set(cachedir_default "\\t^/var/cache/fontconfig^") # the '^' are needed to escape angle brackets on Windows command shell + set(cachedir_appdata "\\t^LOCAL_APPDATA_FONTCONFIG_CACHE^") + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/etc/fonts/fonts.conf + COMMAND sed 's!${cachedir_default}!${cachedir_appdata}\\n${cachedir_default}!' ${MINGW_PATH}/etc/fonts/fonts.conf > ${CMAKE_BINARY_DIR}/etc/fonts/fonts.conf + MAIN_DEPENDENCY ${MINGW_PATH}/etc/fonts/fonts.conf + ) + add_custom_target(fonts_conf ALL DEPENDS ${CMAKE_BINARY_DIR}/etc/fonts/fonts.conf) + install(DIRECTORY ${CMAKE_BINARY_DIR}/etc/fonts DESTINATION ${CMAKE_INSTALL_PREFIX}/etc) # GTK 3.0 diff --git a/po/POTFILES.in b/po/POTFILES.in index b998cf29462a1afd63f2dc44af1e22281044161f..fce7e385e3837d5995497f74fe39ef02fef82883 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -153,7 +153,7 @@ src/live_effects/lpe-transform_2pts.cpp src/live_effects/lpe-vonkoch.cpp src/live_effects/parameter/bool.cpp src/live_effects/parameter/enum.h -src/live_effects/parameter/filletchamferpointarray.cpp +src/live_effects/parameter/satellitearray.cpp src/live_effects/parameter/fontbutton.cpp src/live_effects/parameter/originalpath.cpp src/live_effects/parameter/originalpatharray.cpp diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index ff4760c24715088c9ffdb4c049928669e8331d88..92709e4e94426327ee03bb479a208ec8bb181a9c 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -14,6 +14,8 @@ set(helper_SRC geom.cpp geom-nodetype.cpp geom-pathstroke.cpp + geom-pathvectorsatellites.cpp + geom-satellite.cpp gnome-utils.cpp pixbuf-ops.cpp png-write.cpp @@ -32,6 +34,8 @@ set(helper_SRC geom-curves.h geom-nodetype.h geom-pathstroke.h + geom-pathvectorsatellites.h + geom-satellite.h geom.h gnome-utils.h mathfns.h diff --git a/src/helper/geom-pathvectorsatellites.cpp b/src/helper/geom-pathvectorsatellites.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e995c0a9b47291507ea5f8e27ef0c6182ffe905f --- /dev/null +++ b/src/helper/geom-pathvectorsatellites.cpp @@ -0,0 +1,244 @@ +/** + * \file + * \brief PathVectorSatellites a class to manage satellites -per node extra data- in a pathvector + */ /* + * Authors: + * Jabiertxof + * Nathan Hurst + * Johan Engelen + * Josh Andler + * suv + * Mc- + * Liam P. White + * Krzysztof Kosiński + * This code is in public domain + */ + +#include +#include "util/units.h" + +Geom::PathVector PathVectorSatellites::getPathVector() const +{ + return _pathvector; +} + +void PathVectorSatellites::setPathVector(Geom::PathVector pathv) +{ + _pathvector = pathv; +} + +Satellites PathVectorSatellites::getSatellites() +{ + return _satellites; +} + +void PathVectorSatellites::setSatellites(Satellites satellites) +{ + _satellites = satellites; +} + +size_t PathVectorSatellites::getTotalSatellites() +{ + size_t counter = 0; + for (size_t i = 0; i < _satellites.size(); ++i) { + for (size_t j = 0; j < _satellites[i].size(); ++j) { + counter++; + } + } + return counter; +} + +std::pair PathVectorSatellites::getIndexData(size_t index) +{ + size_t counter = 0; + for (size_t i = 0; i < _satellites.size(); ++i) { + for (size_t j = 0; j < _satellites[i].size(); ++j) { + if (index == counter) { + return std::make_pair(i,j); + } + counter++; + } + } + return std::make_pair(0,0); +} + +void PathVectorSatellites::setSelected(std::vector selected) +{ + size_t counter = 0; + for (size_t i = 0; i < _satellites.size(); ++i) { + for (size_t j = 0; j < _satellites[i].size(); ++j) { + if (find (selected.begin(), selected.end(), counter) != selected.end()) { + _satellites[i][j].setSelected(true); + } else { + _satellites[i][j].setSelected(false); + } + counter++; + } + } +} + +void PathVectorSatellites::updateSteps(size_t steps, bool apply_no_radius, bool apply_with_radius, bool only_selected) +{ + for (size_t i = 0; i < _satellites.size(); ++i) { + for (size_t j = 0; j < _satellites[i].size(); ++j) { + if ((!apply_no_radius && _satellites[i][j].amount == 0) || + (!apply_with_radius && _satellites[i][j].amount != 0)) + { + continue; + } + if (only_selected) { + if (_satellites[i][j].selected) { + _satellites[i][j].steps = steps; + } + } else { + _satellites[i][j].steps = steps; + } + } + } +} + +void PathVectorSatellites::updateAmount(double radius, bool apply_no_radius, bool apply_with_radius, bool only_selected, + bool use_knot_distance, bool flexible) +{ + double power = 0; + if (!flexible) { + power = radius; + } else { + power = radius / 100; + } + for (size_t i = 0; i < _satellites.size(); ++i) { + for (size_t j = 0; j < _satellites[i].size(); ++j) { + boost::optional previous_index = boost::none; + if (j == 0 && _pathvector[i].closed()) { + previous_index = _pathvector[i].size() - 1; + } else if (!_pathvector[i].closed() || j != 0) { + previous_index = j - 1; + } + if (!_pathvector[i].closed() && j == 0) { + _satellites[i][j].amount = 0; + continue; + } + if (_pathvector[i].size() == j) { + continue; + } + if ((!apply_no_radius && _satellites[i][j].amount == 0) || + (!apply_with_radius && _satellites[i][j].amount != 0)) + { + continue; + } + + Geom::Point satellite_point = _pathvector[i].pointAt(j); + if (_satellites[i][j].selected || !only_selected) { + if (!use_knot_distance && !flexible) { + if (previous_index) { + _satellites[i][j].amount = _satellites[i][j].radToLen(power, _pathvector[i][*previous_index], _pathvector[i][j]); + if (power && !_satellites[i][j].amount) { + g_warning("Seems a too high radius value"); + } + } else { + _satellites[i][j].amount = 0.0; + } + } else { + _satellites[i][j].amount = power; + } + } + } + } +} + +void PathVectorSatellites::convertUnit(Glib::ustring in, Glib::ustring to, bool apply_no_radius, bool apply_with_radius) +{ + for (size_t i = 0; i < _satellites.size(); ++i) { + for (size_t j = 0; j < _satellites[i].size(); ++j) { + if (!_pathvector[i].closed() && j == 0) { + _satellites[i][j].amount = 0; + continue; + } + if (_pathvector[i].size() == j) { + continue; + } + if ((!apply_no_radius && _satellites[i][j].amount == 0) || + (!apply_with_radius && _satellites[i][j].amount != 0)) + { + continue; + } + _satellites[i][j].amount = Inkscape::Util::Quantity::convert(_satellites[i][j].amount, in.c_str(), to.c_str()); + } + } +} + +void PathVectorSatellites::updateSatelliteType(SatelliteType satellitetype, bool apply_no_radius, bool apply_with_radius, + bool only_selected) +{ + for (size_t i = 0; i < _satellites.size(); ++i) { + for (size_t j = 0; j < _satellites[i].size(); ++j) { + if ((!apply_no_radius && _satellites[i][j].amount == 0) || + (!apply_with_radius && _satellites[i][j].amount != 0)) + { + continue; + } + if (_pathvector[i].size() == j) { + if (!only_selected) { + _satellites[i][j].satellite_type = satellitetype; + } + continue; + } + if (only_selected) { + Geom::Point satellite_point = _pathvector[i].pointAt(j); + if (_satellites[i][j].selected) { + _satellites[i][j].satellite_type = satellitetype; + } + } else { + _satellites[i][j].satellite_type = satellitetype; + } + } + } +} + +void PathVectorSatellites::recalculateForNewPathVector(Geom::PathVector const pathv, Satellite const S) +{ + Satellites satellites; + bool found = false; + //TODO evaluate fix on nodes at same position + size_t number_nodes = pathv.nodes().size(); + size_t previous_number_nodes = _pathvector.nodes().size(); + for (size_t i = 0; i < pathv.size(); i++) { + std::vector path_satellites; + for (size_t j = 0; j < pathv[i].size_closed(); j++) { + found = false; + for (size_t k = 0; k < _pathvector.size(); k++) { + for (size_t l = 0; l < _pathvector[k].size_closed(); l++) { + if (Geom::are_near(_pathvector[k][l].initialPoint(), pathv[i][j].initialPoint())) + { + path_satellites.push_back(_satellites[k][l]); + found = true; + break; + } + } + if (found) { + break; + } + } + + if (!found && previous_number_nodes < number_nodes) { + path_satellites.push_back(S); + } + } + satellites.push_back(path_satellites); + } + setPathVector(pathv); + setSatellites(satellites); +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/helper/geom-pathvectorsatellites.h b/src/helper/geom-pathvectorsatellites.h new file mode 100644 index 0000000000000000000000000000000000000000..d86e6cb25bcfc36df5d934686d2b43d08c7531ff --- /dev/null +++ b/src/helper/geom-pathvectorsatellites.h @@ -0,0 +1,58 @@ +/** + * \file + * \brief PathVectorSatellites a class to manage satellites -per node extra data- in a pathvector + */ /* + * Authors: + * Jabiertxof + * Nathan Hurst + * Johan Engelen + * Josh Andler + * suv + * Mc- + * Liam P. White + * Krzysztof Kosiński + * This code is in public domain + */ + +#ifndef SEEN_PATHVECTORSATELLITES_H +#define SEEN_PATHVECTORSATELLITES_H + +#include +#include <2geom/path.h> +#include <2geom/pathvector.h> + +typedef std::vector > Satellites; +///@brief PathVectorSatellites a class to manage satellites in a pathvector +class PathVectorSatellites { +public: + Geom::PathVector getPathVector() const; + void setPathVector(Geom::PathVector pathv); + Satellites getSatellites(); + void setSatellites(Satellites satellites); + size_t getTotalSatellites(); + void setSelected(std::vector selected); + void updateSteps(size_t steps, bool apply_no_radius, bool apply_with_radius, bool only_selected); + void updateAmount(double radius, bool apply_no_radius, bool apply_with_radius, bool only_selected, + bool use_knot_distance, bool flexible); + void convertUnit(Glib::ustring in, Glib::ustring to, bool apply_no_radius, bool apply_with_radius); + void updateSatelliteType(SatelliteType satellitetype, bool apply_no_radius, bool apply_with_radius, bool only_selected); + std::pair getIndexData(size_t index); + void recalculateForNewPathVector(Geom::PathVector const pathv, Satellite const S); +private: + Geom::PathVector _pathvector; + Satellites _satellites; +}; + +#endif //SEEN_PATHVECTORSATELLITES_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8a92273d0d4acd0560861a6837e1fa27e03cca93 --- /dev/null +++ b/src/helper/geom-satellite.cpp @@ -0,0 +1,245 @@ +/** + * \file + * \brief Satellite a per node holder of data. + */ /* + * Authors: + * 2015 Jabier Arraiza Cenoz + * + * This code is in public domain + */ + +#include +#include <2geom/curve.h> +#include <2geom/nearest-time.h> +#include <2geom/path-intersection.h> +#include <2geom/sbasis-to-bezier.h> +#include <2geom/ray.h> +#include +//log cache +#ifdef _WIN32 +#include +#else +#include +#include +#endif + +///@brief Satellite a per node holder of data. +Satellite::Satellite() {} + + +Satellite::Satellite(SatelliteType satellite_type) + : satellite_type(satellite_type), + is_time(false), + selected(false), + has_mirror(false), + hidden(true), + amount(0.0), + angle(0.0), + steps(0) +{} + +Satellite::~Satellite() {} + +///Calculate the time in curve_in with a size of A +//TODO: find a better place to it +double timeAtArcLength(double const A, Geom::Curve const &curve_in) +{ + if ( A == 0 || curve_in.isDegenerate()) { + return 0; + } + + Geom::D2 d2_in = curve_in.toSBasis(); + double t = 0; + double length_part = curve_in.length(); + if (A >= length_part || curve_in.isLineSegment()) { + if (length_part != 0) { + t = A / length_part; + } + } else if (!curve_in.isLineSegment()) { + std::vector t_roots = roots(Geom::arcLengthSb(d2_in) - A); + if (!t_roots.empty()) { + t = t_roots[0]; + } + } + return t; +} + +///Calculate the size in curve_in with a point at A +//TODO: find a better place to it +double arcLengthAt(double const A, Geom::Curve const &curve_in) +{ + if ( A == 0 || curve_in.isDegenerate()) { + return 0; + } + + double s = 0; + double length_part = curve_in.length(); + if (A > length_part || curve_in.isLineSegment()) { + s = (A * length_part); + } else if (!curve_in.isLineSegment()) { + Geom::Curve *curve = curve_in.portion(0.0, A); + s = curve->length(); + delete curve; + } + return s; +} + +///Convert a arc radius of a fillet/chamfer to his satellite length -point position where fillet/chamfer knot be on original curve +double Satellite::radToLen( + double const A, Geom::Curve const &curve_in, + Geom::Curve const &curve_out) const +{ + double len = 0; + Geom::D2 d2_in = curve_in.toSBasis(); + Geom::D2 d2_out = curve_out.toSBasis(); + Geom::Piecewise > offset_curve0 = + Geom::Piecewise >(d2_in) + + rot90(unitVector(derivative(d2_in))) * (A); + Geom::Piecewise > offset_curve1 = + Geom::Piecewise >(d2_out) + + rot90(unitVector(derivative(d2_out))) * (A); + Geom::Path p0 = path_from_piecewise(offset_curve0, 0.1)[0]; + Geom::Path p1 = path_from_piecewise(offset_curve1, 0.1)[0]; + Geom::Crossings cs = Geom::crossings(p0, p1); + if (cs.size() > 0) { + Geom::Point cp = p0(cs[0].ta); + double p0pt = nearest_time(cp, curve_out); + len = arcLengthAt(p0pt, curve_out); + } else { + if (A > 0) { + len = radToLen(A * -1, curve_in, curve_out); + } + } + return len; +} + +///Convert a satelite length -point position where fillet/chamfer knot be on original curve- to a arc radius of fillet/chamfer +double Satellite::lenToRad( + double const A, Geom::Curve const &curve_in, + Geom::Curve const &curve_out, + Satellite const previousSatellite) const +{ + double time_in = (previousSatellite).time(A, true, curve_in); + double time_out = timeAtArcLength(A, curve_out); + Geom::Point start_arc_point = curve_in.pointAt(time_in); + Geom::Point end_arc_point = curve_out.pointAt(time_out); + Geom::Curve *knot_curve1 = curve_in.portion(0, time_in); + Geom::Curve *knot_curve2 = curve_out.portion(time_out, 1); + Geom::CubicBezier const *cubic1 = dynamic_cast(&*knot_curve1); + Geom::Ray ray1(start_arc_point, curve_in.pointAt(1)); + if (cubic1) { + ray1.setPoints((*cubic1)[2], start_arc_point); + } + Geom::CubicBezier const *cubic2 = dynamic_cast(&*knot_curve2); + Geom::Ray ray2(curve_out.pointAt(0), end_arc_point); + if (cubic2) { + ray2.setPoints(end_arc_point, (*cubic2)[1]); + } + bool ccw_toggle = cross(curve_in.pointAt(1) - start_arc_point, + end_arc_point - start_arc_point) < 0; + double distance_arc = + Geom::distance(start_arc_point, middle_point(start_arc_point, end_arc_point)); + double angle = angle_between(ray1, ray2, ccw_toggle); + double divisor = std::sin(angle / 2.0); + if (divisor > 0) { + return distance_arc / divisor; + } + return 0; +} + +///Get the time position of the satellite in curve_in +double Satellite::time(Geom::Curve const &curve_in, bool inverse) const +{ + double t = amount; + if (!is_time) { + t = time(t, inverse, curve_in); + } else if (inverse) { + t = 1-t; + } + if (t > 1) { + t = 1; + } + return t; +} + +///Get the time from a length A in other curve, a bolean inverse gived to reverse time +double Satellite::time(double A, bool inverse, + Geom::Curve const &curve_in) const +{ + if (A == 0 && inverse) { + return 1; + } + if (A == 0 && !inverse) { + return 0; + } + if (!inverse) { + return timeAtArcLength(A, curve_in); + } + double length_part = curve_in.length(); + A = length_part - A; + return timeAtArcLength(A, curve_in); +} + +///Get the length of the satellite in curve_in +double Satellite::arcDistance(Geom::Curve const &curve_in) const +{ + double s = amount; + if (is_time) { + s = arcLengthAt(s, curve_in); + } + return s; +} + +///Get the point position of the satellite +Geom::Point Satellite::getPosition(Geom::Curve const &curve_in, bool inverse) const +{ + double t = time(curve_in, inverse); + return curve_in.pointAt(t); +} + +///Set the position of the satellite from a gived point P +void Satellite::setPosition(Geom::Point const p, Geom::Curve const &curve_in, bool inverse) +{ + Geom::Curve * curve = const_cast(&curve_in); + if (inverse) { + curve = curve->reverse(); + } + double A = Geom::nearest_time(p, *curve); + if (!is_time) { + A = arcLengthAt(A, *curve); + } + amount = A; +} + + +///Map a satellite type with gchar +void Satellite::setSatelliteType(gchar const *A) +{ + std::map 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::iterator it = gchar_map_to_satellite_type.find(std::string(A)); + if (it != gchar_map_to_satellite_type.end()) { + satellite_type = it->second; + } +} + +///Map a gchar with satelliteType +gchar const *Satellite::getSatelliteTypeGchar() const +{ + std::map satellite_type_to_gchar_map = + boost::assign::map_list_of(FILLET, "F")(INVERSE_FILLET, "IF")(CHAMFER, "C")(INVERSE_CHAMFER, "IC")(INVALID_SATELLITE, "KO"); + return satellite_type_to_gchar_map.at(satellite_type); +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/helper/geom-satellite.h b/src/helper/geom-satellite.h new file mode 100644 index 0000000000000000000000000000000000000000..a4d63d66e6bb7849439596dd2384a5fcc19f6990 --- /dev/null +++ b/src/helper/geom-satellite.h @@ -0,0 +1,110 @@ +/** + * \file + * \brief Satellite a per node holder of data. + */ /* + * Authors: + * 2015 Jabier Arraiza Cenoz + * + * This code is in public domain + */ + +#ifndef SEEN_SATELLITE_H +#define SEEN_SATELLITE_H + +#include +#include +#include <2geom/sbasis-geometric.h> +#include "util/enums.h" + + +enum SatelliteType { + FILLET = 0, //Fillet + INVERSE_FILLET, //Inverse Fillet + CHAMFER, //Chamfer + INVERSE_CHAMFER, //Inverse Chamfer + INVALID_SATELLITE // Invalid Satellite +}; +/** + * @brief Satellite a per node holder of data. + */ + +class Satellite { +public: + + Satellite(); + Satellite(SatelliteType satellite_type); + + virtual ~Satellite(); + void setIsTime(bool set_is_time) + { + is_time = set_is_time; + } + void setSelected(bool set_selected) + { + selected = set_selected; + } + void setHasMirror(bool set_has_mirror) + { + has_mirror = set_has_mirror; + } + void setHidden(bool set_hidden) + { + hidden = set_hidden; + } + void setAmount(bool set_amount) + { + amount = set_amount; + } + void setAngle(bool set_angle) + { + angle = set_angle; + } + void setSteps(bool set_steps) + { + steps = set_steps; + } + double lenToRad(double const A, Geom::Curve const &curve_in, + Geom::Curve const &curve_out, + Satellite const previousSatellite) const; + double radToLen(double const A, Geom::Curve const &curve_in, + Geom::Curve const &curve_out) const; + + double time(Geom::Curve const &curve_in, bool inverse = false) const; + double time(double A, bool inverse, Geom::Curve const &curve_in) const; + double arcDistance(Geom::Curve const &curve_in) const; + + void setPosition(Geom::Point const p, Geom::Curve const &curve_in, bool inverse = false); + Geom::Point getPosition(Geom::Curve const &curve_in, bool inverse = false) const; + + void setSatelliteType(gchar const *A); + gchar const *getSatelliteTypeGchar() const; + SatelliteType satellite_type; + //The value stored could be a time value of the satellite in the curve or a lenght of distance to the node from the satellite + //"is_time" tell is if is a time or lenght value + bool is_time; + bool selected; + bool has_mirror; + bool hidden; + //in "amount" we store the time or distance used in the satellite + double amount; + double angle; + size_t steps; +}; + +double timeAtArcLength(double const A, Geom::Curve const &curve_in); +double arcLengthAt(double const A, Geom::Curve const &curve_in); + +#endif // SEEN_SATELLITE_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/knotholder.h b/src/knotholder.h index f1bacebe5cf377e7490d43998bbd3b51712cf585..c8136da3f60ab07333e76c870d02a1a80af28cc0 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -30,7 +30,8 @@ class Node; } namespace LivePathEffect { class PowerStrokePointArrayParamKnotHolderEntity; -class FilletPointArrayParamKnotHolderEntity; +class SatellitesArrayParam; +class FilletChamferKnotHolderEntity; } } @@ -63,7 +64,7 @@ public: friend class Inkscape::UI::ShapeEditor; // FIXME why? friend class Inkscape::LivePathEffect::PowerStrokePointArrayParamKnotHolderEntity; // why? - friend class Inkscape::LivePathEffect::FilletPointArrayParamKnotHolderEntity; // why? + friend class Inkscape::LivePathEffect::FilletChamferKnotHolderEntity; // why? protected: diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 5ffccc7c0f92285fb2b58c16d6dc31b1914f80e7..0e6f5bcb7135a9d0d4203a8099cd2c7be58479f2 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -18,7 +18,6 @@ set(live_effects_SRC lpe-extrude.cpp lpe-fill-between-many.cpp lpe-fill-between-strokes.cpp - lpe-fillet-chamfer.cpp lpe-gears.cpp lpe-interpolate.cpp lpe-interpolate_points.cpp @@ -59,7 +58,6 @@ set(live_effects_SRC parameter/array.cpp parameter/bool.cpp - parameter/filletchamferpointarray.cpp parameter/item-reference.cpp parameter/item.cpp parameter/originalitem.cpp @@ -70,7 +68,9 @@ set(live_effects_SRC parameter/path.cpp parameter/point.cpp parameter/powerstrokepointarray.cpp + parameter/satellitesarray.cpp parameter/random.cpp + parameter/scalar.cpp parameter/text.cpp parameter/fontbutton.cpp parameter/togglebutton.cpp @@ -101,7 +101,6 @@ set(live_effects_SRC lpe-extrude.h lpe-fill-between-many.h lpe-fill-between-strokes.h - lpe-fillet-chamfer.h lpe-gears.h lpe-interpolate.h lpe-interpolate_points.h @@ -144,7 +143,6 @@ set(live_effects_SRC parameter/array.h parameter/bool.h parameter/enum.h - parameter/filletchamferpointarray.h parameter/item.h parameter/item-reference.h parameter/originalitem.h @@ -155,7 +153,9 @@ set(live_effects_SRC parameter/path.h parameter/point.h parameter/powerstrokepointarray.h + parameter/satellitesarray.h parameter/random.h + parameter/scalar.h parameter/text.h parameter/fontbutton.h parameter/togglebutton.h diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 326225e0c6d2b8fc36dbf9eccae0d2928944e829..0bfefc207100aca42205a158adda455c8a7f8a4c 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -73,6 +73,7 @@ #include "path-chemistry.h" #include "xml/sp-css-attr.h" #include "live_effects/lpeobject.h" +#include #include "display/curve.h" #include #include @@ -80,7 +81,7 @@ namespace Inkscape { namespace LivePathEffect { -const Glib::ustring DEFAULT_PREF_VALUE = "--default"; + const Util::EnumData LPETypeData[] = { // {constant defined in effect-enum.h, N_("name of your effect"), "name of your effect in SVG"} #ifdef LPE_ENABLE_TEST_EFFECTS @@ -100,7 +101,6 @@ const Util::EnumData LPETypeData[] = { {RECURSIVE_SKELETON, N_("Recursive skeleton"), "recursive_skeleton"}, {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"}, {TEXT_LABEL, N_("Text label"), "text_label"}, - {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet_chamfer"}, #endif /* 0.46 */ {BEND_PATH, N_("Bend"), "bend_path"}, @@ -141,6 +141,7 @@ const Util::EnumData LPETypeData[] = { {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"}, /* 9.93 */ {MEASURE_LINE, N_("Measure Line"), "measure_line"}, + {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet_chamfer"}, }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -358,6 +359,7 @@ Effect::Effect(LivePathEffectObject *lpeobject) concatenate_before_pwd2(false), sp_lpe_item(NULL), current_zoom(1), + upd_params(true), sp_shape(NULL), sp_curve(NULL), provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden @@ -575,9 +577,10 @@ Effect::doAcceptPathPreparations(SPLPEItem *lpeitem) void Effect::writeParamsToSVG() { + upd_params = true; std::vector::iterator p; for (p = param_vector.begin(); p != param_vector.end(); ++p) { - (*p)->write_to_SVG(); + (*p)->writeToSVG(); } } @@ -644,6 +647,7 @@ void Effect::readallParameters(Inkscape::XML::Node const* repr) { std::vector::iterator it = param_vector.begin(); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); while (it != param_vector.end()) { Parameter * param = *it; const gchar * key = param->param_key.c_str(); @@ -654,10 +658,17 @@ Effect::readallParameters(Inkscape::XML::Node const* repr) g_warning("Effect::readallParameters - '%s' not accepted for %s", value, key); } } else { - // set default value - param->param_set_default(); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() + + (Glib::ustring)"/" + + (Glib::ustring)key; + bool valid = prefs->getEntry(pref_path).isValid(); + if(valid){ + param->param_updateDefault(prefs->getString(pref_path).c_str()); + } else { + param->param_valueFromDefault(); + } } - ++it; } } @@ -675,7 +686,7 @@ Effect::setParameter(const gchar * key, const gchar * new_value) } } else { // set default value - param->param_set_default(); + param->param_valueFromDefault(); } } } @@ -775,6 +786,93 @@ Effect::newWidget() return dynamic_cast(vbox); } +/** + * This *creates* a new widget, with default values setter + */ +Gtk::Widget * +Effect::defaultParamSet() +{ + // use manage here, because after deletion of Effect object, others might still be pointing to this widget. + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox() ); + Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); + Glib::ustring effectname = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_label(effectType()); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(effectType()); + std::vector::iterator it = param_vector.begin(); + Inkscape::UI::Widget::Registry * wr; + bool has_params = false; + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + has_params = true; + Parameter * param = *it; + Glib::ustring * tip = param->param_getTooltip(); + const gchar * key = param->param_key.c_str(); + const gchar * value = param->param_label.c_str(); + const gchar * tooltip_extra = _(". Change custom values for this parameter"); + Glib::ustring tooltip = param->param_tooltip + (Glib::ustring)tooltip_extra; + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)key; + bool valid = prefs->getEntry(pref_path).isValid(); + const gchar * set_or_upd; + if (valid) { + set_or_upd = _("Update"); + } else { + set_or_upd = _("Set"); + } + Gtk::HBox * vbox_param = Gtk::manage( new Gtk::HBox(true) ); + Gtk::Label *parameter_label = Gtk::manage(new Gtk::Label(value, Gtk::ALIGN_START)); + parameter_label->set_use_markup(true); + parameter_label->set_use_underline (true); + parameter_label->set_ellipsize(Pango::ELLIPSIZE_END); + vbox_param->pack_start(*parameter_label, true, true, 2); + Gtk::Button *set = Gtk::manage(new Gtk::Button((Glib::ustring)set_or_upd)); + Gtk::Button *unset = Gtk::manage(new Gtk::Button(Glib::ustring(_("Unset")))); + unset->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &Effect::unsetDefaultParam), pref_path, set, unset)); + set->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &Effect::setDefaultParam), pref_path, param->param_getSVGValue(), set, unset)); + if (!valid) { + unset->set_sensitive(false); + } + vbox_param->pack_start(*set, true, true, 2); + vbox_param->pack_start(*unset, true, true, 2); + + vbox_expander->pack_start(*vbox_param, true, true, 2); + } + ++it; + } + Glib::ustring tip = "" + effectname + (Glib::ustring)_(": Set default parameters"); + Gtk::Expander * expander = Gtk::manage(new Gtk::Expander(tip)); + expander->set_use_markup(true); + expander->add(*vbox_expander); + expander->set_expanded(false); + vbox->pack_start(*dynamic_cast (expander), true, true, 2); + if (has_params) { + return dynamic_cast(vbox); + } else { + return NULL; + } +} + +void +Effect::setDefaultParam(Glib::ustring pref_path, gchar * value, Gtk::Button *set , Gtk::Button *unset) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString(pref_path, (Glib::ustring)value); + gchar * label = _("Update"); + set->set_label((Glib::ustring)label); + unset->set_sensitive(true); +} + +void +Effect::unsetDefaultParam(Glib::ustring pref_path, Gtk::Button *set, Gtk::Button *unset) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->remove(pref_path); + gchar * label = _("Set"); + set->set_label((Glib::ustring)label); + unset->set_sensitive(false); +} Inkscape::XML::Node *Effect::getRepr() { @@ -842,7 +940,7 @@ Effect::editNextParamOncanvas(SPItem * item, SPDesktop * desktop) Parameter * param = getNextOncanvasEditableParam(); if (param) { - param->param_editOncanvas(item, desktop); + param->param_editOnCanvas(item, desktop); gchar *message = g_strdup_printf(_("Editing parameter %s."), param->param_label.c_str()); desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, message); g_free(message); @@ -860,8 +958,8 @@ Effect::resetDefaults(SPItem const* /*item*/) { std::vector::iterator p; for (p = param_vector.begin(); p != param_vector.end(); ++p) { - (*p)->param_set_default(); - (*p)->write_to_SVG(); + (*p)->param_valueFromDefault(); + (*p)->writeToSVG(); } } @@ -871,7 +969,7 @@ Effect::transform_multiply(Geom::Affine const& postmul, bool set) // cycle through all parameters. Most parameters will not need transformation, but path and point params do. for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { Parameter * param = *it; - param->param_transform_multiply(postmul, set); + param->param_transformMultiply(postmul, set); } } diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 973516133d62edf8bd1060756334176a2b2beae2..c34c391c0c39c2e22878ac0b6cbae6e95290a2b4 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -94,7 +94,7 @@ public: virtual void doEffect (SPCurve * curve); virtual Gtk::Widget * newWidget(); - + virtual Gtk::Widget * defaultParamSet(); /** * Sets all parameters to their default values and writes them to SVG. */ @@ -133,6 +133,7 @@ public: void editNextParamOncanvas(SPItem * item, SPDesktop * desktop); bool apply_to_clippath_and_mask; bool erase_extra_objects; // set this to false allow retain extra generated objects, see measure line LPE + bool upd_params; BoolParam is_visible; SPCurve * sp_curve; Geom::PathVector pathvector_before_effect; @@ -171,13 +172,15 @@ protected: // this boolean defaults to false, it concatenates the input path to one pwd2, // instead of normally 'splitting' the path into continuous pwd2 paths and calling doEffect_pwd2 for each. bool concatenate_before_pwd2; - SPLPEItem * sp_lpe_item; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them. SPShape * sp_shape; // these get stored in doBeforeEffect_impl before doEffect chain, or in performPathEffects on groups, and derived classes may do as they please with them. std::vector items; double current_zoom; std::vector selectedNodesPoints; + private: + void setDefaultParam(Glib::ustring pref_path, gchar * value, Gtk::Button *set , Gtk::Button *unset); + void unsetDefaultParam(Glib::ustring pref_path, Gtk::Button *set , Gtk::Button *unset); bool provides_own_flash_paths; // if true, the standard flash path is suppressed bool is_ready; diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index 56d33eb4b3ab6b769b929f9183a48b44b42b25ce..9cd270a7292b524d37dd5bf4309e555b6bedc97a 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -101,7 +101,7 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_time(s, lpe->ptA, lpe->dir); - lpe->length_left.param_set_value(-lambda); + lpe->length_left.param_setValue(-lambda); sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } @@ -114,7 +114,7 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_time(s, lpe->ptA, lpe->dir); - lpe->length_right.param_set_value(lambda); + lpe->length_right.param_setValue(lambda); sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } diff --git a/src/live_effects/lpe-attach-path.cpp b/src/live_effects/lpe-attach-path.cpp index 3021657191cc7e00da408fd87fae7fdae508f8b0..8759e6e2c1cdfa09e39dcdb69f9fcb77987b13e6 100644 --- a/src/live_effects/lpe-attach-path.cpp +++ b/src/live_effects/lpe-attach-path.cpp @@ -79,13 +79,13 @@ void LPEAttachPath::doEffect (SPCurve * curve) Geom::Coord length = derivs[deriv_n].length(); if ( ! Geom::are_near(length, 0) ) { if (set_start_end) { - start_path_position.param_set_value(transformedpath.nearestTime(start_path_curve_end.getOrigin()).asFlatTime()); + start_path_position.param_setValue(transformedpath.nearestTime(start_path_curve_end.getOrigin()).asFlatTime()); } if (start_path_position > transformedpath.size()) { - start_path_position.param_set_value(transformedpath.size()); + start_path_position.param_setValue(transformedpath.size()); } else if (start_path_position < 0) { - start_path_position.param_set_value(0); + start_path_position.param_setValue(0); } Geom::Curve const *c = start_path_position >= transformedpath.size() ? &transformedpath.back() : &transformedpath.at((int)start_path_position); @@ -134,13 +134,13 @@ void LPEAttachPath::doEffect (SPCurve * curve) Geom::Coord length = derivs[deriv_n].length(); if ( ! Geom::are_near(length, 0) ) { if (set_end_end) { - end_path_position.param_set_value(transformedpath.nearestTime(end_path_curve_end.getOrigin()).asFlatTime()); + end_path_position.param_setValue(transformedpath.nearestTime(end_path_curve_end.getOrigin()).asFlatTime()); } if (end_path_position > transformedpath.size()) { - end_path_position.param_set_value(transformedpath.size()); + end_path_position.param_setValue(transformedpath.size()); } else if (end_path_position < 0) { - end_path_position.param_set_value(0); + end_path_position.param_setValue(0); } const Geom::Curve *c = end_path_position >= transformedpath.size() ? &transformedpath.back() : &transformedpath.at((int)end_path_position); diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 363356cac936fdfc8034e2b6c3ff8ba99dadd3da..f076a56482238dc05270c90b962f151371edaab4 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -62,8 +62,8 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) : registerParameter( &scale_y_rel); registerParameter( &vertical_pattern); - prop_scale.param_set_digits(3); - prop_scale.param_set_increments(0.01, 0.10); + prop_scale.param_setDigits(3); + prop_scale.param_setIncrements(0.01, 0.10); _provides_knotholder_entities = true; apply_to_clippath_and_mask = true; @@ -185,9 +185,9 @@ KnotHolderEntityWidthBendPath::knot_set(Geom::Point const &p, Geom::Point const& Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse(); Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos); if(nearest_to_ray == 0){ - lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0)); + lpe->prop_scale.param_setValue(-Geom::distance(s , ptA)/(lpe->original_height/2.0)); } else { - lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + lpe->prop_scale.param_setValue(Geom::distance(s , ptA)/(lpe->original_height/2.0)); } sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 1423e670a2dd76512fd2c5104f252bca69f014dd..13be04629e1857213d5fc72647853a23ad90ae0c 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -41,19 +41,19 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) registerParameter(&apply_with_weight); registerParameter(&only_selected); - weight.param_set_range(NO_POWER, 100.0); - weight.param_set_increments(0.1, 0.1); - weight.param_set_digits(4); - weight.param_overwrite_widget(true); + weight.param_setRange(NO_POWER, 100.0); + weight.param_setIncrements(0.1, 0.1); + weight.param_setDigits(4); + weight.param_overwriteWidget(true); - steps.param_set_range(1, 10); - steps.param_set_increments(1, 1); - steps.param_set_digits(0); - steps.param_overwrite_widget(true); + steps.param_setRange(1, 10); + steps.param_setIncrements(1, 1); + steps.param_setDigits(0); + steps.param_overwriteWidget(true); - helper_size.param_set_range(0.0, 999.0); - helper_size.param_set_increments(1, 1); - helper_size.param_set_digits(2); + helper_size.param_setRange(0.0, 999.0); + helper_size.param_setIncrements(1, 1); + helper_size.param_setDigits(2); } LPEBSpline::~LPEBSpline() {} @@ -86,7 +86,7 @@ Gtk::Widget *LPEBSpline::newWidget() // use manage here, because after deletion of Effect object, others might // still be pointing to this widget. Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget())); - + vbox->set_homogeneous(false); vbox->set_border_width(5); std::vector::iterator it = param_vector.begin(); while (it != param_vector.end()) { diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index d97a990afd6a83763c8e65ca540cf59a2a8dbfe6..1453b5d1aeec701d2a3899881892216cbcdc92d0 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -57,9 +57,9 @@ LPECloneOriginal::LPECloneOriginal(LivePathEffectObject *lpeobject) : registerParameter(&paintorder); registerParameter(&opacity); registerParameter(&filter); - scale.param_set_range(0.01, 999999.0); - scale.param_set_increments(1, 1); - scale.param_set_digits(2); + scale.param_setRange(0.01, 999999.0); + scale.param_setIncrements(1, 1); + scale.param_setDigits(2); attributes.param_hide_canvas_text(); style_attributes.param_hide_canvas_text(); preserve_position_changed = preserve_position; diff --git a/src/live_effects/lpe-constructgrid.cpp b/src/live_effects/lpe-constructgrid.cpp index db620fa9564e5e84d9d543bfd72ce7cfcecc91fb..ec85d27b23d35ea2e563656bb311f3ad4e5851d8 100644 --- a/src/live_effects/lpe-constructgrid.cpp +++ b/src/live_effects/lpe-constructgrid.cpp @@ -27,10 +27,10 @@ LPEConstructGrid::LPEConstructGrid(LivePathEffectObject *lpeobject) : registerParameter(&nr_x); registerParameter(&nr_y); - nr_x.param_make_integer(); - nr_y.param_make_integer(); - nr_x.param_set_range(1, 1e10); - nr_y.param_set_range(1, 1e10); + nr_x.param_makeInteger(); + nr_y.param_makeInteger(); + nr_x.param_setRange(1, 1e10); + nr_y.param_setRange(1, 1e10); } LPEConstructGrid::~LPEConstructGrid() diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 900fc8b679af08d8ac2d3c81984222570b0992ad..0132ccc40f64b81ceb97b714570db67b8e2cd072 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -87,11 +87,11 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) : registerParameter(&mirror_copies); registerParameter(&split_items); - gap.param_set_range(-99999.0, 99999.0); - gap.param_set_increments(0.1, 0.1); - gap.param_set_digits(5); - num_copies.param_set_range(1, 999999); - num_copies.param_make_integer(true); + gap.param_setRange(-99999.0, 99999.0); + gap.param_setIncrements(0.1, 0.1); + gap.param_setDigits(5); + num_copies.param_setRange(1, 999999); + num_copies.param_makeInteger(true); apply_to_clippath_and_mask = true; previous_num_copies = num_copies; reset = false; @@ -339,8 +339,8 @@ LPECopyRotate::doOnApply(SPLPEItem const* lpeitem) A = Point(boundingbox_X.min(), boundingbox_Y.middle()); B = Point(boundingbox_X.middle(), boundingbox_Y.middle()); - origin.param_setValue(A, true); - origin.param_update_default(A); + origin.param_setValue(A); + origin.param_updateDefault(A); dist_angle_handle = L2(B - A); dir = unit_vector(B - A); } @@ -351,7 +351,7 @@ LPECopyRotate::transform_multiply(Geom::Affine const& postmul, bool set) // cycle through all parameters. Most parameters will not need transformation, but path and point params do. for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { Parameter * param = *it; - param->param_transform_multiply(postmul, set); + param->param_transformMultiply(postmul, set); } sp_lpe_item_update_patheffect(sp_lpe_item, false, false); } @@ -362,20 +362,20 @@ LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem) using namespace Geom; original_bbox(lpeitem); if (copies_to_360 && num_copies > 2) { - rotation_angle.param_set_value(360.0/(double)num_copies); + rotation_angle.param_setValue(360.0/(double)num_copies); } if ((method == RM_KALEIDOSCOPE || method == RM_FUSE) && rotation_angle * num_copies > 360.1 && rotation_angle > 0) { - num_copies.param_set_value(floor(360/rotation_angle)); + num_copies.param_setValue(floor(360/rotation_angle)); } if ((method == RM_KALEIDOSCOPE || method == RM_FUSE) && mirror_copies && copies_to_360) { - num_copies.param_set_increments(2.0,10.0); + num_copies.param_setIncrements(2.0,10.0); if ((int)num_copies%2 !=0) { - num_copies.param_set_value(num_copies+1); - rotation_angle.param_set_value(360.0/(double)num_copies); + num_copies.param_setValue(num_copies+1); + rotation_angle.param_setValue(360.0/(double)num_copies); } } else { - num_copies.param_set_increments(1.0, 10.0); + num_copies.param_setIncrements(1.0, 10.0); } A = Point(boundingbox_X.min(), boundingbox_Y.middle()); @@ -388,7 +388,7 @@ LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem) // likely due to SVG's choice of coordinate system orientation (max) bool near = Geom::are_near(previous_start_point, (Geom::Point)starting_point, 0.01); if (!near) { - starting_angle.param_set_value(deg_from_rad(-angle_between(dir, starting_point - origin))); + starting_angle.param_setValue(deg_from_rad(-angle_between(dir, starting_point - origin))); if (GDK_SHIFT_MASK) { dist_angle_handle = L2(B - A); } else { @@ -402,7 +402,7 @@ LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem) rot_pos = origin + dir * Rotate(-rad_from_deg(rotation_angle+starting_angle)) * dist_angle_handle; near = Geom::are_near(start_pos, (Geom::Point)starting_point, 0.01); if (!near) { - starting_point.param_setValue(start_pos, true); + starting_point.param_setValue(start_pos); } previous_start_point = (Geom::Point)starting_point; if ( method == RM_FUSE || copies_to_360 ) { diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index f8d2e56ca012e6f619767977bd63ed9082344852..965bf48325ec0e5acf8bce9ec965b47ecb4752f1 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -49,11 +49,11 @@ LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) : registerParameter(&prop_scale); registerParameter(&scale_y_rel); - nrofpaths.param_make_integer(); - nrofpaths.param_set_range(2, Geom::infinity()); + nrofpaths.param_makeInteger(); + nrofpaths.param_setRange(2, Geom::infinity()); - prop_scale.param_set_digits(3); - prop_scale.param_set_increments(0.01, 0.10); + prop_scale.param_setDigits(3); + prop_scale.param_setIncrements(0.01, 0.10); transformed = false; } @@ -174,11 +174,11 @@ LPECurveStitch::resetDefaults(SPItem const* item) strokepath.set_new_value( path.toPwSb(), true ); } else { // bounding box is too small to make decent path. set to default default. :-) - strokepath.param_set_and_write_default(); + strokepath.param_valueFromDefault( true ); } } else { // bounding box is non-existent. set to default default. :-) - strokepath.param_set_and_write_default(); + strokepath.param_valueFromDefault( true ); } } @@ -193,10 +193,10 @@ LPECurveStitch::transform_multiply(Geom::Affine const& postmul, bool set) { // only take translations into account if (postmul.isTranslation()) { - strokepath.param_transform_multiply(postmul, set); + strokepath.param_transformMultiply(postmul, set); } else if (!scale_y_rel.get_value()) { transformed = true; - strokepath.param_transform_multiply(postmul, set); + strokepath.param_transformMultiply(postmul, set); } } diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index 33e754a8ab0ca3e8edca23a81cd1eacbf760a072..e94c5153b6d81e0b84d4adb78664c49c1c459ac4 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -67,11 +67,11 @@ LPEDynastroke::LPEDynastroke(LivePathEffectObject *lpeobject) : registerParameter(&round_ends); registerParameter(&capping); - width.param_set_range(0, Geom::infinity()); - roundness.param_set_range(0.01, 1); - angle.param_set_range(-360, 360); - growfor.param_set_range(0, Geom::infinity()); - fadefor.param_set_range(0, Geom::infinity()); + width.param_setRange(0, Geom::infinity()); + roundness.param_setRange(0.01, 1); + angle.param_setRange(-360, 360); + growfor.param_setRange(0, Geom::infinity()); + fadefor.param_setRange(0, Geom::infinity()); show_orig_path = true; } diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp deleted file mode 100644 index 1e2df7dc8b2479d710495b1e165ce1a919444af0..0000000000000000000000000000000000000000 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ /dev/null @@ -1,668 +0,0 @@ -/* - * Author(s): - * Jabiertxo Arraiza Cenoz - * - * Copyright (C) 2014 Author(s) - * - * Special thanks to Johan Engelen for the base of the effect -powerstroke- - * Also to ScislaC for point me to the idea - * Also su_v for his construvtive feedback and time - * Also to Mc- (IRC nick) for his important contribution to find real time - * values based on - * and finaly to Liam P. White for his big help on coding, that save me a lot of hours - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -#include "live_effects/lpe-fillet-chamfer.h" - -#include <2geom/sbasis-to-bezier.h> -#include <2geom/elliptical-arc.h> - -#include "display/curve.h" -#include "helper/geom-nodetype.h" -#include "helper/geom-curves.h" -#include "helper/geom.h" - -// for programmatically updating knots -#include "ui/tools-switch.h" -// TODO due to internal breakage in glibmm headers, this must be last: -#include - -using namespace Geom; -namespace Inkscape { -namespace LivePathEffect { - -static const Util::EnumData FilletMethodData[FM_END] = { - { FM_AUTO, N_("Auto"), "auto" }, - { FM_ARC, N_("Force arc"), "arc" }, - { FM_BEZIER, N_("Force bezier"), "bezier" } -}; -static const Util::EnumDataConverter -FMConverter(FilletMethodData, FM_END); - -const double tolerance = 0.001; -const double gapHelper = 0.00001; - -LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : - Effect(lpeobject), - fillet_chamfer_values(_("Fillet point"), _("Fillet point"), "fillet_chamfer_values", &wr, this), - hide_knots(_("Hide knots"), _("Hide knots"), "hide_knots", &wr, this, false), - ignore_radius_0(_("Ignore 0 radius knots"), _("Ignore 0 radius knots"), "ignore_radius_0", &wr, this, false), - only_selected(_("Change only selected nodes"), _("Change only selected nodes"), "only_selected", &wr, this, false), - flexible(_("Flexible radius size (%)"), _("Flexible radius size (%)"), "flexible", &wr, this, false), - use_knot_distance(_("Use knots distance instead radius"), _("Use knots distance instead radius"), "use_knot_distance", &wr, this, false), - method(_("Method:"), _("Fillets methods"), "method", FMConverter, &wr, this, FM_AUTO), - radius(_("Radius (unit or %):"), _("Radius, in unit or %"), "radius", &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) -{ - registerParameter(&fillet_chamfer_values); - registerParameter(&method); - registerParameter(&radius); - registerParameter(&chamfer_steps); - registerParameter(&helper_size); - registerParameter(&flexible); - registerParameter(&use_knot_distance); - registerParameter(&ignore_radius_0); - registerParameter(&only_selected); - registerParameter(&hide_knots); - - radius.param_set_range(0., infinity()); - radius.param_set_increments(1, 1); - radius.param_set_digits(4); - radius.param_overwrite_widget(true); - chamfer_steps.param_set_range(1, 999); - chamfer_steps.param_set_increments(1, 1); - chamfer_steps.param_set_digits(0); - chamfer_steps.param_overwrite_widget(true); - helper_size.param_set_range(0, infinity()); - helper_size.param_set_increments(5, 5); - helper_size.param_set_digits(0); - helper_size.param_overwrite_widget(true); - fillet_chamfer_values.set_chamfer_steps(3); -} - -LPEFilletChamfer::~LPEFilletChamfer() {} - -Gtk::Widget *LPEFilletChamfer::newWidget() -{ - // use manage here, because after deletion of Effect object, others might - // still be pointing to this widget. - Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget())); - - vbox->set_border_width(5); - vbox->set_homogeneous(false); - vbox->set_spacing(2); - Gtk::HBox *advertaising = Gtk::manage(new Gtk::HBox(true, 0)); - Gtk::Button *advert = Gtk::manage(new Gtk::Button(Glib::ustring(_("IMPORTANT! New version soon...")))); - advertaising->pack_start(*advert, true, true, 2); - vbox->pack_start(*advertaising, true, true, 2); - Gtk::HBox *advertaising2 = Gtk::manage(new Gtk::HBox(true, 0)); - Gtk::Button *advert2 = Gtk::manage(new Gtk::Button(Glib::ustring(_("Not compatible. Convert to path after.")))); - advertaising2->pack_start(*advert2, true, true, 2); - vbox->pack_start(*advertaising2, true, true, 2); - std::vector::iterator it = param_vector.begin(); - while (it != param_vector.end()) { - if ((*it)->widget_is_visible) { - Parameter *param = *it; - Gtk::Widget *widg = param->param_newWidget(); - if (param->param_key == "radius") { - Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast(widg)); - widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::updateFillet)); - widg = widgRegistered; - if (widg) { - Gtk::HBox *scalarParameter = dynamic_cast(widg); - std::vector childList = scalarParameter->get_children(); - Gtk::Entry *entryWidg = dynamic_cast(childList[1]); - entryWidg->set_width_chars(6); - } - } else if (param->param_key == "chamfer_steps") { - Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast(widg)); - widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::chamferSubdivisions)); - widg = widgRegistered; - if (widg) { - Gtk::HBox *scalarParameter = dynamic_cast(widg); - std::vector childList = scalarParameter->get_children(); - Gtk::Entry *entryWidg = dynamic_cast(childList[1]); - entryWidg->set_width_chars(3); - } - } else if (param->param_key == "flexible") { - Gtk::CheckButton *widgRegistered = Gtk::manage(dynamic_cast(widg)); - widgRegistered->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::toggleFlexFixed)); - } else if (param->param_key == "helper_size") { - Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast(widg)); - widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::refreshKnots)); - } else if (param->param_key == "hide_knots") { - Gtk::CheckButton *widgRegistered = Gtk::manage(dynamic_cast(widg)); - widgRegistered->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::toggleHide)); - } else if (param->param_key == "only_selected") { - Gtk::manage(widg); - } else if (param->param_key == "ignore_radius_0") { - Gtk::manage(widg); - } - - Glib::ustring *tip = param->param_getTooltip(); - if (widg) { - vbox->pack_start(*widg, true, true, 2); - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } - } - } - - ++it; - } - 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)); - - 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)); - - 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; -} - -void LPEFilletChamfer::toggleHide() -{ - std::vector filletChamferData = fillet_chamfer_values.data(); - std::vector result; - for (std::vector::const_iterator point_it = filletChamferData.begin(); - point_it != filletChamferData.end(); ++point_it) { - if (hide_knots) { - result.push_back(Point((*point_it)[X], std::abs((*point_it)[Y]) * -1)); - } else { - result.push_back(Point((*point_it)[X], std::abs((*point_it)[Y]))); - } - } - fillet_chamfer_values.param_set_and_write_new_value(result); - refreshKnots(); -} - -void LPEFilletChamfer::toggleFlexFixed() -{ - std::vector filletChamferData = fillet_chamfer_values.data(); - std::vector result; - unsigned int i = 0; - for (std::vector::const_iterator point_it = filletChamferData.begin(); - point_it != filletChamferData.end(); ++point_it) { - if (flexible) { - result.push_back(Point(fillet_chamfer_values.to_time(i, (*point_it)[X]), - (*point_it)[Y])); - } else { - result.push_back(Point(fillet_chamfer_values.to_len(i, (*point_it)[X]), - (*point_it)[Y])); - } - i++; - } - if (flexible) { - radius.param_set_range(0., 100); - radius.param_set_value(0); - } else { - radius.param_set_range(0., infinity()); - radius.param_set_value(0); - } - fillet_chamfer_values.param_set_and_write_new_value(result); -} - -void LPEFilletChamfer::updateFillet() -{ - double power = 0; - if (!flexible) { - power = radius * -1; - } else { - power = radius; - } - Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); - doUpdateFillet(path_from_piecewise(pwd2, tolerance), power); - DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); -} - -void LPEFilletChamfer::fillet() -{ - Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); - doChangeType(path_from_piecewise(pwd2, tolerance), 1); - DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Convert to fillet")); -} - -void LPEFilletChamfer::inverseFillet() -{ - Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); - doChangeType(path_from_piecewise(pwd2, tolerance), 2); - DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Convert to inverse fillet")); -} - -void LPEFilletChamfer::chamferSubdivisions() -{ - fillet_chamfer_values.set_chamfer_steps(chamfer_steps); - Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); - doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 5000); - DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); -} - -void LPEFilletChamfer::chamfer() -{ - fillet_chamfer_values.set_chamfer_steps(chamfer_steps); - Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); - doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 3000); - DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Convert to chamfer")); -} - -void LPEFilletChamfer::inverseChamfer() -{ - fillet_chamfer_values.set_chamfer_steps(chamfer_steps); - Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); - doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 4000); - DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Convert to inverse fillet")); -} - -void LPEFilletChamfer::refreshKnots() -{ - Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); - fillet_chamfer_values.recalculate_knots(pwd2); - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (tools_isactive(desktop, TOOLS_NODES)) { - tools_switch(desktop, TOOLS_SELECT); - tools_switch(desktop, TOOLS_NODES); - } - DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Knots and helper paths refreshed")); -} - -void LPEFilletChamfer::doUpdateFillet(Geom::PathVector const &original_pathv, double power) -{ - std::vector filletChamferData = fillet_chamfer_values.data(); - std::vector result; - Geom::PathVector original_pathv_processed = pathv_to_linear_and_cubic_beziers(original_pathv); - int counter = 0; - for (PathVector::const_iterator path_it = original_pathv_processed.begin(); - path_it != original_pathv_processed.end(); ++path_it) { - if (path_it->empty()) - continue; - - 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(); - if (path_it->closed() && path_it->back_closed().isDegenerate()) { - const Curve &closingline = path_it->back_closed(); - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - curve_endit = path_it->end_open(); - } - } - double powerend = 0; - while (curve_it1 != curve_endit) { - powerend = power; - if (power < 0 && !use_knot_distance) { - powerend = fillet_chamfer_values.rad_to_len(counter,powerend); - } - if (power > 0) { - powerend = counter + (power / 100); - } - if (ignore_radius_0 && (filletChamferData[counter][X] == 0 || - filletChamferData[counter][X] == counter)) { - powerend = filletChamferData[counter][X]; - } - if (filletChamferData[counter][Y] == 0) { - powerend = filletChamferData[counter][X]; - } - if (only_selected && !isNodePointSelected(curve_it1->initialPoint())) { - powerend = filletChamferData[counter][X]; - } - result.push_back(Point(powerend, filletChamferData[counter][Y])); - ++curve_it1; - ++curve_it2; - counter++; - } - } - fillet_chamfer_values.param_set_and_write_new_value(result); -} - -void LPEFilletChamfer::doChangeType(Geom::PathVector const &original_pathv, int type) -{ - std::vector filletChamferData = fillet_chamfer_values.data(); - std::vector result; - Geom::PathVector original_pathv_processed = pathv_to_linear_and_cubic_beziers(original_pathv); - int counter = 0; - for (PathVector::const_iterator path_it = original_pathv_processed.begin(); path_it != original_pathv_processed.end(); ++path_it) { - int pathCounter = 0; - if (path_it->empty()) - continue; - - 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(); - if (path_it->closed() && path_it->back_closed().isDegenerate()) { - const Curve &closingline = path_it->back_closed(); - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - curve_endit = path_it->end_open(); - } - } - while (curve_it1 != curve_endit) { - bool toggle = true; - if (filletChamferData[counter][Y] == 0 || - (ignore_radius_0 && (filletChamferData[counter][X] == 0 || - filletChamferData[counter][X] == counter)) || - (only_selected && !isNodePointSelected(curve_it1->initialPoint()))) { - 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]); - } - ++curve_it1; - if (curve_it2 != curve_endit) { - ++curve_it2; - } - counter++; - pathCounter++; - } - } - fillet_chamfer_values.param_set_and_write_new_value(result); -} - -void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) -{ - if (SP_IS_SHAPE(lpeItem)) { - std::vector point; - PathVector const &original_pathv = pathv_to_linear_and_cubic_beziers(SP_SHAPE(lpeItem)->_curve->get_pathvector()); - Piecewise > pwd2_in = paths_to_pw(original_pathv); - for (PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - if (path_it->empty()) - continue; - - 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(); - if (path_it->closed()) { - 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(); - } - } - int counter = 0; - while (curve_it1 != curve_endit) { - std::pair positions = fillet_chamfer_values.get_positions(counter, original_pathv); - Geom::NodeType nodetype; - if (positions.second == 0) { - if (path_it->closed()) { - Piecewise > u; - u.push_cut(0); - u.push(pwd2_in[fillet_chamfer_values.last_index(counter, original_pathv)], 1); - Geom::Curve const * A = path_from_piecewise(u, 0.1)[0][0].duplicate(); - nodetype = get_nodetype(*A, *curve_it1); - } else { - nodetype = NODE_NONE; - } - } else { - nodetype = get_nodetype((*path_it)[counter - 1], *curve_it1); - } - if (nodetype == NODE_CUSP) { - point.push_back(Point(0, 1)); - } else { - point.push_back(Point(0, 0)); - } - ++curve_it1; - if (curve_it2 != curve_endit) { - ++curve_it2; - } - counter++; - } - } - fillet_chamfer_values.param_set_and_write_new_value(point); - } else { - g_warning("LPE Fillet can only be applied to shapes (not groups)."); - SPLPEItem * item = const_cast(lpeItem); - item->removeCurrentPathEffect(false); - } -} - -void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) -{ - if (SP_IS_SHAPE(lpeItem)) { - if(hide_knots){ - fillet_chamfer_values.set_helper_size(0); - } else { - fillet_chamfer_values.set_helper_size(helper_size); - } - fillet_chamfer_values.set_use_distance(use_knot_distance); - SPCurve *c = SP_IS_PATH(lpeItem) ? static_cast(lpeItem) - ->get_original_curve() - : SP_SHAPE(lpeItem)->getCurve(); - std::vector filletChamferData = fillet_chamfer_values.data(); - if (!filletChamferData.empty() && getKnotsNumber(c) != (int) - filletChamferData.size()) { - PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); - Piecewise > pwd2_in = paths_to_pw(original_pathv); - fillet_chamfer_values.recalculate_controlpoints_for_new_pwd2(pwd2_in); - } - } else { - g_warning("LPE Fillet can only be applied to shapes (not groups)."); - } -} - -int LPEFilletChamfer::getKnotsNumber(SPCurve const *c) -{ - int nKnots = c->nodes_in_path(); - PathVector const pv = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); - for (Geom::PathVector::const_iterator path_it = pv.begin(); - path_it != pv.end(); ++path_it) { - if (!(*path_it).closed()) { - nKnots--; - } - } - return nKnots; -} - -void -LPEFilletChamfer::adjustForNewPath(Geom::PathVector const &path_in) -{ - if (!path_in.empty()) { - fillet_chamfer_values.recalculate_controlpoints_for_new_pwd2(pathv_to_linear_and_cubic_beziers(path_in)[0].toPwSb()); - } -} - -Geom::PathVector -LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) -{ - Geom::PathVector pathvector_out; - Piecewise > pwd2_in = paths_to_pw(pathv_to_linear_and_cubic_beziers(path_in)); - pwd2_in = remove_short_cuts(pwd2_in, .01); - Piecewise > der = derivative(pwd2_in); - Piecewise > n = rot90(unitVector(der)); - fillet_chamfer_values.set_pwd2(pwd2_in, n); - std::vector filletChamferData = fillet_chamfer_values.data(); - unsigned int counter = 0; - const double K = (4.0 / 3.0) * (sqrt(2.0) - 1.0); - Geom::PathVector path_in_processed = pathv_to_linear_and_cubic_beziers(path_in); - for (PathVector::const_iterator path_it = path_in_processed.begin(); - path_it != path_in_processed.end(); ++path_it) { - if (path_it->empty()) - continue; - Geom::Path path_out; - 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(); - if (path_it->closed()) { - 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(); - } - } - unsigned int counterCurves = 0; - while (curve_it1 != curve_endit) { - Curve *curve_it2Fixed = (*path_it->begin()).duplicate(); - if(!path_it->closed() || curve_it2 != curve_endit){ - curve_it2Fixed = (*curve_it2).duplicate(); - } - bool last = curve_it2 == curve_endit; - std::vector times = fillet_chamfer_values.get_times(counter, path_in, last); - Curve *knotCurve1 = curve_it1->portion(times[0], times[1]); - if (counterCurves > 0) { - knotCurve1->setInitial(path_out.finalPoint()); - } else { - path_out.start((*curve_it1).pointAt(times[0])); - } - Curve *knotCurve2 = curve_it2Fixed->portion(times[2], 1); - Point startArcPoint = knotCurve1->finalPoint(); - Point endArcPoint = curve_it2Fixed->pointAt(times[2]); - double k1 = distance(startArcPoint, curve_it1->finalPoint()) * K; - double k2 = distance(endArcPoint, curve_it1->finalPoint()) * K; - Geom::CubicBezier const *cubic1 = dynamic_cast(&*knotCurve1); - Ray ray1(startArcPoint, curve_it1->finalPoint()); - if (cubic1) { - ray1.setPoints((*cubic1)[2], startArcPoint); - } - Point handle1 = Point::polar(ray1.angle(),k1) + startArcPoint; - Geom::CubicBezier const *cubic2 = - dynamic_cast(&*knotCurve2); - Ray ray2(curve_it1->finalPoint(), endArcPoint); - if (cubic2) { - ray2.setPoints(endArcPoint, (*cubic2)[1]); - } - Point handle2 = endArcPoint - Point::polar(ray2.angle(),k2); - bool ccwToggle = cross(curve_it1->finalPoint() - startArcPoint, endArcPoint - startArcPoint) > 0; - double angle = angle_between(ray1, ray2, ccwToggle); - double handleAngle = ray1.angle() - angle; - if (ccwToggle) { - handleAngle = ray1.angle() + angle; - } - Point inverseHandle1 = Point::polar(handleAngle,k1) + startArcPoint; - handleAngle = ray2.angle() + angle; - if (ccwToggle) { - handleAngle = ray2.angle() - angle; - } - Point inverseHandle2 = endArcPoint - Point::polar(handleAngle,k2); - //straigth lines arc based - Line const x_line(Geom::Point(0,0),Geom::Point(1,0)); - Line const angled_line(startArcPoint,endArcPoint); - double angleArc = Geom::angle_between( x_line,angled_line); - double radius = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint))/sin(angle/2.0); - Coord rx = radius; - Coord ry = rx; - - if (times[1] != 1) { - if (times[1] != gapHelper && times[1] != times[0] + gapHelper) { - path_out.append(*knotCurve1); - } - int type = 0; - if(path_it->closed() && last){ - type = std::abs(filletChamferData[counter - counterCurves][Y]); - } else if (!path_it->closed() && last){ - //0 - } else { - type = std::abs(filletChamferData[counter + 1][Y]); - } - if(are_near(middle_point(startArcPoint,endArcPoint),curve_it1->finalPoint(), 0.0001)){ - path_out.appendNew(endArcPoint); - } else if (type >= 3000 && type < 4000) { - unsigned int chamferSubs = type-3000; - 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){ - path_chamfer.appendNew(rx, ry, angleArc, 0, ccwToggle, endArcPoint); - } else { - path_chamfer.appendNew(handle1, handle2, 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(chamferStep); - } - path_out.appendNew(endArcPoint); - } else if (type >= 4000 && type < 5000) { - unsigned int chamferSubs = type-4000; - 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(rx, ry, angleArc, 0, ccwToggle, endArcPoint); - }else{ - path_chamfer.appendNew(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(chamferStep); - } - path_out.appendNew(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; - path_out.appendNew(rx, ry, angleArc, 0, ccwToggle, endArcPoint); - }else{ - path_out.appendNew(inverseHandle1, inverseHandle2, endArcPoint); - } - } else if (type == 1){ - if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ - path_out.appendNew(rx, ry, angleArc, 0, ccwToggle, endArcPoint); - } else { - path_out.appendNew(handle1, handle2, endArcPoint); - } - } - } else { - path_out.append(*knotCurve1); - } - if (path_it->closed() && last) { - path_out.close(); - } - ++curve_it1; - if (curve_it2 != curve_endit) { - ++curve_it2; - } - counter++; - counterCurves++; - } - pathvector_out.push_back(path_out); - } - return pathvector_out; -} - -}; //namespace LivePathEffect -}; /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offset:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h deleted file mode 100644 index 290a37f928979a1c254be1daf7b914c21a6436ef..0000000000000000000000000000000000000000 --- a/src/live_effects/lpe-fillet-chamfer.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef INKSCAPE_LPE_FILLET_CHAMFER_H -#define INKSCAPE_LPE_FILLET_CHAMFER_H - -/* - * Author(s): - * Jabiertxo Arraiza Cenoz - * - * Copyright (C) 2014 Author(s) - * - * Special thanks to Johan Engelen for the base of the effect -powerstroke- - * Also to ScislaC for point me to the idea - * Also su_v for his construvtive feedback and time - * and finaly to Liam P. White for his big help on coding, that save me a lot of hours - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "live_effects/parameter/enum.h" -#include "live_effects/parameter/bool.h" -#include "live_effects/parameter/unit.h" - -#include "live_effects/parameter/filletchamferpointarray.h" -#include "live_effects/effect.h" - -namespace Inkscape { -namespace LivePathEffect { - -enum FilletMethod { - FM_AUTO, - FM_ARC, - FM_BEZIER, - FM_END -}; - -class LPEFilletChamfer : public Effect { -public: - LPEFilletChamfer(LivePathEffectObject *lpeobject); - virtual ~LPEFilletChamfer(); - - virtual Geom::PathVector doEffect_path(Geom::PathVector const &path_in); - - virtual void doOnApply(SPLPEItem const *lpeItem); - virtual void doBeforeEffect(SPLPEItem const *lpeItem); - virtual void adjustForNewPath(Geom::PathVector const &path_in); - virtual Gtk::Widget* newWidget(); - - int getKnotsNumber(SPCurve const *c); - void toggleHide(); - void toggleFlexFixed(); - void chamfer(); - void chamferSubdivisions(); - void inverseChamfer(); - void fillet(); - void inverseFillet(); - void updateFillet(); - void doUpdateFillet(Geom::PathVector const& original_pathv, double power); - void doChangeType(Geom::PathVector const& original_pathv, int type); - void refreshKnots(); - - FilletChamferPointArrayParam fillet_chamfer_values; - -private: - - BoolParam hide_knots; - BoolParam ignore_radius_0; - BoolParam only_selected; - BoolParam flexible; - BoolParam use_knot_distance; - EnumParam method; - ScalarParam radius; - ScalarParam chamfer_steps; - ScalarParam helper_size; - - LPEFilletChamfer(const LPEFilletChamfer &); - LPEFilletChamfer &operator=(const LPEFilletChamfer &); - -}; - -} //namespace LivePathEffect -} //namespace Inkscape - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp index dad520041de3c9256f478abd033bc09bf0b93c2e..264647222913225e2329250ec786f8ac7148233c 100644 --- a/src/live_effects/lpe-gears.cpp +++ b/src/live_effects/lpe-gears.cpp @@ -216,9 +216,9 @@ LPEGears::LPEGears(LivePathEffectObject *lpeobject) : * allows the teeth to have higher capacity and also allows fewer teeth without undercutting. */ - teeth.param_make_integer(); - teeth.param_set_range(3, 1e10); - min_radius.param_set_range(0.01, 9999.0); + teeth.param_makeInteger(); + teeth.param_setRange(3, 1e10); + min_radius.param_setRange(0.01, 9999.0); registerParameter(&teeth); registerParameter(&phi); registerParameter(&min_radius); diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index db3faa307cd685a13a7eac885540d15f864540f2..cf7d539c71073389c560b12358451a70c3e1bc79 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -34,8 +34,8 @@ LPEInterpolate::LPEInterpolate(LivePathEffectObject *lpeobject) : registerParameter(&equidistant_spacing); registerParameter(&number_of_steps); - number_of_steps.param_make_integer(); - number_of_steps.param_set_range(2, Geom::infinity()); + number_of_steps.param_makeInteger(); + number_of_steps.param_setRange(2, Geom::infinity()); } LPEInterpolate::~LPEInterpolate() @@ -117,7 +117,7 @@ LPEInterpolate::resetDefaults(SPItem const* item) traj_pathv[0].appendNew( bounds_B->midpoint() ); trajectory_path.set_new_value( traj_pathv, true ); } else { - trajectory_path.param_set_and_write_default(); + trajectory_path.param_valueFromDefault( true ); } } diff --git a/src/live_effects/lpe-jointype.cpp b/src/live_effects/lpe-jointype.cpp index dacb87dd96b7191b4cb39be832c831300042bbff..6d2d6d10977a77d93d0fcc19ebef151f56d9782f 100644 --- a/src/live_effects/lpe-jointype.cpp +++ b/src/live_effects/lpe-jointype.cpp @@ -65,12 +65,12 @@ LPEJoinType::LPEJoinType(LivePathEffectObject *lpeobject) : //registerParameter(&end_lean); registerParameter(&miter_limit); registerParameter(&attempt_force_join); - //start_lean.param_set_range(-1,1); - //start_lean.param_set_increments(0.1, 0.1); - //start_lean.param_set_digits(4); - //end_lean.param_set_range(-1,1); - //end_lean.param_set_increments(0.1, 0.1); - //end_lean.param_set_digits(4); + //start_lean.param_setRange(-1,1); + //start_lean.param_setIncrements(0.1, 0.1); + //start_lean.param_setDigits(4); + //end_lean.param_setRange(-1,1); + //end_lean.param_setIncrements(0.1, 0.1); + //end_lean.param_setDigits(4); } LPEJoinType::~LPEJoinType() @@ -110,8 +110,8 @@ void LPEJoinType::doOnApply(SPLPEItem const* lpeitem) sp_desktop_apply_css_recursive(item, css, true); sp_repr_css_attr_unref (css); - line_width.param_set_value(width); - line_width.write_to_SVG(); + line_width.param_setValue(width); + line_width.writeToSVG(); } } diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 261612fdb35ad22648215b1b0bd0d634b296e2d7..1cc7d97881862a3ad0782cd3117103d82ac7fbd5 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -300,7 +300,7 @@ idx_of_nearest(CrossingPoints const &cpts, Geom::Point const &p) //TODO: Find a way to warn the user when the topology changes. //TODO: be smarter at guessing the signs when the topology changed? void -CrossingPoints::inherit_signs(CrossingPoints const &other, int default_value) +CrossingPoints::inherit_signs(CrossingPoints const &other, int defaultvalue) { bool topo_changed = false; for (unsigned n=0; n < size(); n++){ @@ -325,7 +325,7 @@ CrossingPoints::inherit_signs(CrossingPoints const &other, int default_value) if (idx < other.size()) { (*this)[n].sign = other[idx].sign; } else { - (*this)[n].sign = default_value; + (*this)[n].sign = defaultvalue; } } } @@ -655,7 +655,7 @@ KnotHolderEntityCrossingSwitcher::knot_click(guint state) lpe->crossing_points[s].sign = ((sign+2)%3)-1; //std::cout<<"crossing set to"<crossing_points[s].sign<<".\n"; } - lpe->crossing_points_vector.param_set_and_write_new_value(lpe->crossing_points.to_vector()); + lpe->crossing_points_vector.param_setAndWriteNewValue(lpe->crossing_points.to_vector()); DocumentUndo::done(lpe->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, /// @todo Is this the right verb? _("Change knot crossing")); diff --git a/src/live_effects/lpe-knot.h b/src/live_effects/lpe-knot.h index ac518b97c65a9a3342b0b9675c234262e8338855..54ecfceea3337db06febe103da04ab52de7ccb84 100644 --- a/src/live_effects/lpe-knot.h +++ b/src/live_effects/lpe-knot.h @@ -47,7 +47,7 @@ public: CrossingPoints(std::vector const &input); std::vector to_vector(); CrossingPoint get(unsigned const i, unsigned const ni); - void inherit_signs(CrossingPoints const &from_other, int default_value = 1); + void inherit_signs(CrossingPoints const &from_other, int defaultvalue = 1); }; } diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index 124a7a9c6a2c1f1ee717c6e3e0fd5f46cc40343a..aad63dc8a163d11ac2009b0cd94fa41b72ce65cf 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -222,21 +222,21 @@ LPELattice::resetDefaults(SPItem const* item) grid_point15[Geom::X] = 2.0/3*boundingbox_X.max()+1.0/3*boundingbox_X.min(); grid_point15[Geom::Y] = 2.0/3*boundingbox_Y.max()+1.0/3*boundingbox_Y.min(); - grid_point1.param_update_default(grid_point1); - grid_point2.param_update_default(grid_point2); - grid_point3.param_update_default(grid_point3); - grid_point4.param_update_default(grid_point4); - grid_point5.param_update_default(grid_point5); - grid_point6.param_update_default(grid_point6); - grid_point7.param_update_default(grid_point7); - grid_point8.param_update_default(grid_point8); - grid_point9.param_update_default(grid_point9); - grid_point10.param_update_default(grid_point10); - grid_point11.param_update_default(grid_point11); - grid_point12.param_update_default(grid_point12); - grid_point13.param_update_default(grid_point13); - grid_point14.param_update_default(grid_point14); - grid_point15.param_update_default(grid_point15); + grid_point1.param_updateDefault(grid_point1); + grid_point2.param_updateDefault(grid_point2); + grid_point3.param_updateDefault(grid_point3); + grid_point4.param_updateDefault(grid_point4); + grid_point5.param_updateDefault(grid_point5); + grid_point6.param_updateDefault(grid_point6); + grid_point7.param_updateDefault(grid_point7); + grid_point8.param_updateDefault(grid_point8); + grid_point9.param_updateDefault(grid_point9); + grid_point10.param_updateDefault(grid_point10); + grid_point11.param_updateDefault(grid_point11); + grid_point12.param_updateDefault(grid_point12); + grid_point13.param_updateDefault(grid_point13); + grid_point14.param_updateDefault(grid_point14); + grid_point15.param_updateDefault(grid_point15); } /** diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index e827491c04808602ec70e5483f13e15c7c096af5..6c5ce3014dec5b39cd58e928b207baf499e12fe8 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -322,8 +322,8 @@ LPELattice2::doBeforeEffect (SPLPEItem const* lpeitem) { original_bbox(lpeitem); setDefaults(); - Geom::Line vert(grid_point_8x9.param_get_default(),grid_point_10x11.param_get_default()); - Geom::Line horiz(grid_point_24x26.param_get_default(),grid_point_25x27.param_get_default()); + Geom::Line vert(grid_point_8x9.param_getDefault(),grid_point_10x11.param_getDefault()); + Geom::Line horiz(grid_point_24x26.param_getDefault(),grid_point_25x27.param_getDefault()); if(vertical_mirror) { vertical(grid_point_0, grid_point_1,vert); vertical(grid_point_2, grid_point_3,vert); @@ -428,86 +428,86 @@ LPELattice2::setDefaults() Geom::Point gp32x33x34x35((boundingbox_X.max()-boundingbox_X.min())/4*2+boundingbox_X.min(), (boundingbox_Y.max()-boundingbox_Y.min())/4*2+boundingbox_Y.min()); - grid_point_0.param_update_default(gp0); - grid_point_1.param_update_default(gp1); - grid_point_2.param_update_default(gp2); - grid_point_3.param_update_default(gp3); - grid_point_4.param_update_default(gp4); - grid_point_5.param_update_default(gp5); - grid_point_6.param_update_default(gp6); - grid_point_7.param_update_default(gp7); - grid_point_8x9.param_update_default(gp8x9); - grid_point_10x11.param_update_default(gp10x11); - grid_point_12.param_update_default(gp12); - grid_point_13.param_update_default(gp13); - grid_point_14.param_update_default(gp14); - grid_point_15.param_update_default(gp15); - grid_point_16.param_update_default(gp16); - grid_point_17.param_update_default(gp17); - grid_point_18.param_update_default(gp18); - grid_point_19.param_update_default(gp19); - grid_point_20x21.param_update_default(gp20x21); - grid_point_22x23.param_update_default(gp22x23); - grid_point_24x26.param_update_default(gp24x26); - grid_point_25x27.param_update_default(gp25x27); - grid_point_28x30.param_update_default(gp28x30); - grid_point_29x31.param_update_default(gp29x31); - grid_point_32x33x34x35.param_update_default(gp32x33x34x35); - grid_point_0.param_set_liveupdate(live_update); - grid_point_1.param_set_liveupdate(live_update); - grid_point_2.param_set_liveupdate(live_update); - grid_point_3.param_set_liveupdate(live_update); - grid_point_4.param_set_liveupdate(live_update); - grid_point_5.param_set_liveupdate(live_update); - grid_point_6.param_set_liveupdate(live_update); - grid_point_7.param_set_liveupdate(live_update); - grid_point_8x9.param_set_liveupdate(live_update); - grid_point_10x11.param_set_liveupdate(live_update); - grid_point_12.param_set_liveupdate(live_update); - grid_point_13.param_set_liveupdate(live_update); - grid_point_14.param_set_liveupdate(live_update); - grid_point_15.param_set_liveupdate(live_update); - grid_point_16.param_set_liveupdate(live_update); - grid_point_17.param_set_liveupdate(live_update); - grid_point_18.param_set_liveupdate(live_update); - grid_point_19.param_set_liveupdate(live_update); - grid_point_20x21.param_set_liveupdate(live_update); - grid_point_22x23.param_set_liveupdate(live_update); - grid_point_24x26.param_set_liveupdate(live_update); - grid_point_25x27.param_set_liveupdate(live_update); - grid_point_28x30.param_set_liveupdate(live_update); - grid_point_29x31.param_set_liveupdate(live_update); - grid_point_32x33x34x35.param_set_liveupdate(live_update); + grid_point_0.param_updateDefault(gp0); + grid_point_1.param_updateDefault(gp1); + grid_point_2.param_updateDefault(gp2); + grid_point_3.param_updateDefault(gp3); + grid_point_4.param_updateDefault(gp4); + grid_point_5.param_updateDefault(gp5); + grid_point_6.param_updateDefault(gp6); + grid_point_7.param_updateDefault(gp7); + grid_point_8x9.param_updateDefault(gp8x9); + grid_point_10x11.param_updateDefault(gp10x11); + grid_point_12.param_updateDefault(gp12); + grid_point_13.param_updateDefault(gp13); + grid_point_14.param_updateDefault(gp14); + grid_point_15.param_updateDefault(gp15); + grid_point_16.param_updateDefault(gp16); + grid_point_17.param_updateDefault(gp17); + grid_point_18.param_updateDefault(gp18); + grid_point_19.param_updateDefault(gp19); + grid_point_20x21.param_updateDefault(gp20x21); + grid_point_22x23.param_updateDefault(gp22x23); + grid_point_24x26.param_updateDefault(gp24x26); + grid_point_25x27.param_updateDefault(gp25x27); + grid_point_28x30.param_updateDefault(gp28x30); + grid_point_29x31.param_updateDefault(gp29x31); + grid_point_32x33x34x35.param_updateDefault(gp32x33x34x35); + grid_point_0.param_setLiveupdate(live_update); + grid_point_1.param_setLiveupdate(live_update); + grid_point_2.param_setLiveupdate(live_update); + grid_point_3.param_setLiveupdate(live_update); + grid_point_4.param_setLiveupdate(live_update); + grid_point_5.param_setLiveupdate(live_update); + grid_point_6.param_setLiveupdate(live_update); + grid_point_7.param_setLiveupdate(live_update); + grid_point_8x9.param_setLiveupdate(live_update); + grid_point_10x11.param_setLiveupdate(live_update); + grid_point_12.param_setLiveupdate(live_update); + grid_point_13.param_setLiveupdate(live_update); + grid_point_14.param_setLiveupdate(live_update); + grid_point_15.param_setLiveupdate(live_update); + grid_point_16.param_setLiveupdate(live_update); + grid_point_17.param_setLiveupdate(live_update); + grid_point_18.param_setLiveupdate(live_update); + grid_point_19.param_setLiveupdate(live_update); + grid_point_20x21.param_setLiveupdate(live_update); + grid_point_22x23.param_setLiveupdate(live_update); + grid_point_24x26.param_setLiveupdate(live_update); + grid_point_25x27.param_setLiveupdate(live_update); + grid_point_28x30.param_setLiveupdate(live_update); + grid_point_29x31.param_setLiveupdate(live_update); + grid_point_32x33x34x35.param_setLiveupdate(live_update); } void LPELattice2::resetGrid() { - grid_point_0.param_set_default(); - grid_point_1.param_set_default(); - grid_point_2.param_set_default(); - grid_point_3.param_set_default(); - grid_point_4.param_set_default(); - grid_point_5.param_set_default(); - grid_point_6.param_set_default(); - grid_point_7.param_set_default(); - grid_point_8x9.param_set_default(); - grid_point_10x11.param_set_default(); - grid_point_12.param_set_default(); - grid_point_13.param_set_default(); - grid_point_14.param_set_default(); - grid_point_15.param_set_default(); - grid_point_16.param_set_default(); - grid_point_17.param_set_default(); - grid_point_18.param_set_default(); - grid_point_19.param_set_default(); - grid_point_20x21.param_set_default(); - grid_point_22x23.param_set_default(); - grid_point_24x26.param_set_default(); - grid_point_25x27.param_set_default(); - grid_point_28x30.param_set_default(); - grid_point_29x31.param_set_default(); - grid_point_32x33x34x35.param_set_default(); + grid_point_0.param_valueFromDefault(); + grid_point_1.param_valueFromDefault(); + grid_point_2.param_valueFromDefault(); + grid_point_3.param_valueFromDefault(); + grid_point_4.param_valueFromDefault(); + grid_point_5.param_valueFromDefault(); + grid_point_6.param_valueFromDefault(); + grid_point_7.param_valueFromDefault(); + grid_point_8x9.param_valueFromDefault(); + grid_point_10x11.param_valueFromDefault(); + grid_point_12.param_valueFromDefault(); + grid_point_13.param_valueFromDefault(); + grid_point_14.param_valueFromDefault(); + grid_point_15.param_valueFromDefault(); + grid_point_16.param_valueFromDefault(); + grid_point_17.param_valueFromDefault(); + grid_point_18.param_valueFromDefault(); + grid_point_19.param_valueFromDefault(); + grid_point_20x21.param_valueFromDefault(); + grid_point_22x23.param_valueFromDefault(); + grid_point_24x26.param_valueFromDefault(); + grid_point_25x27.param_valueFromDefault(); + grid_point_28x30.param_valueFromDefault(); + grid_point_29x31.param_valueFromDefault(); + grid_point_32x33x34x35.param_valueFromDefault(); } void diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index 63d60da3f3bf9c689260680495cc010dfbc21846..d16ea609d17b0840fb7de962c11bfebbdd5ad331 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -49,32 +49,33 @@ static const Util::EnumDataConverter OMConverter(OrientationM LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : Effect(lpeobject), - unit(_("Unit*"), _("Unit"), "unit", &wr, this, "px"), - fontbutton(_("Font*"), _("Font Selector"), "fontbutton", &wr, this), + unit(_("Unit"), _("Unit"), "unit", &wr, this, "px"), + fontbutton(_("Font"), _("Font Selector"), "fontbutton", &wr, this), orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false), curve_linked(_("Curve on origin"), _("Curve on origin, set 0 to start/end"), "curve_linked", &wr, this, 1), - precision(_("Precision*"), _("Precision"), "precision", &wr, this, 2), - position(_("Position*"), _("Position"), "position", &wr, this, 5), - text_top_bottom(_("Text top/bottom*"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0), - text_right_left(_("Text right/left*"), _("Text right/left"), "text_right_left", &wr, this, 0), - helpline_distance(_("Helpline distance*"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0), - helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), - scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0), - format(_("Format*"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"), + precision(_("Precision"), _("Precision"), "precision", &wr, this, 2), + position(_("Position"), _("Position"), "position", &wr, this, 5), + text_top_bottom(_("Text top/bottom"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0), + text_right_left(_("Text right/left"), _("Text right/left"), "text_right_left", &wr, this, 0), + helpline_distance(_("Helpline distance"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0), + helpline_overlap(_("Helpline overlap"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), + scale(_("Scale"), _("Scaling factor"), "scale", &wr, this, 1.0), + format(_("Format"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"), id_origin("id_origin", "id_origin", "id_origin", &wr, this,""), arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false), - flip_side(_("Flip side*"), _("Flip side"), "flip_side", &wr, this, false), - scale_sensitive(_("Scale sensitive*"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true), - local_locale(_("Local Number Format*"), _("Local number format"), "local_locale", &wr, this, true), - line_group_05(_("Line Group 0.5*"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true), - rotate_anotation(_("Rotate Anotation*"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true), - hide_back(_("Hide if label over*"), _("Hide DIN line if label over"), "hide_back", &wr, this, true), - dimline_format(_("CSS DIN line*"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""), - helperlines_format(_("CSS helpers*"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""), - anotation_format(_("CSS anotation*"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""), - arrows_format(_("CSS arrows*"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""), + flip_side(_("Flip side"), _("Flip side"), "flip_side", &wr, this, false), + scale_sensitive(_("Scale sensitive"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true), + local_locale(_("Local Number Format"), _("Local number format"), "local_locale", &wr, this, true), + line_group_05(_("Line Group 0.5"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true), + rotate_anotation(_("Rotate Anotation"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true), + hide_back(_("Hide if label over"), _("Hide DIN line if label over"), "hide_back", &wr, this, true), + dimline_format(_("CSS DIN line"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""), + helperlines_format(_("CSS helpers"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""), + anotation_format(_("CSS anotation"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""), + arrows_format(_("CSS arrows"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""), expanded(false) { + //set to true the parameters you want to be changed his default values registerParameter(&unit); registerParameter(&fontbutton); registerParameter(&orientation); @@ -99,68 +100,44 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : registerParameter(&anotation_format); registerParameter(&arrows_format); registerParameter(&id_origin); + id_origin.param_hide_canvas_text(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring fontbutton_value = prefs->getString("/live_effects/measure-line/fontbutton"); - if(fontbutton_value.empty()){ - fontbutton_value = "Sans 10"; - } - fontbutton.param_update_default(fontbutton_value); - scale.param_update_default(prefs->getDouble("/live_effects/measure-line/scale", 1.0)); - precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2)); - position.param_update_default(prefs->getDouble("/live_effects/measure-line/position", 10.0)); - text_top_bottom.param_update_default(prefs->getDouble("/live_effects/measure-line/text_top_bottom", 5.0)); - helpline_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_distance", 0.0)); - helpline_overlap.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_overlap", 0.0)); - Glib::ustring unit_value = prefs->getString("/live_effects/measure-line/unit"); - if(unit_value.empty()){ - unit_value = "px"; - } - unit.param_update_default(unit_value); Glib::ustring format_value = prefs->getString("/live_effects/measure-line/format"); if(format_value.empty()){ format_value = "{measure}{unit}"; } - format.param_update_default(format_value); - dimline_format.param_update_default(prefs->getString("/live_effects/measure-line/dimline_format")); - helperlines_format.param_update_default(prefs->getString("/live_effects/measure-line/helperlines_format")); - anotation_format.param_update_default(prefs->getString("/live_effects/measure-line/anotation_format")); - arrows_format.param_update_default(prefs->getString("/live_effects/measure-line/arrows_format")); - flip_side.param_update_default(prefs->getBool("/live_effects/measure-line/flip_side")); - scale_sensitive.param_update_default(prefs->getBool("/live_effects/measure-line/scale_sensitive")); - local_locale.param_update_default(prefs->getBool("/live_effects/measure-line/local_locale")); - line_group_05.param_update_default(prefs->getBool("/live_effects/measure-line/line_group_05")); - rotate_anotation.param_update_default(prefs->getBool("/live_effects/measure-line/rotate_anotation")); - hide_back.param_update_default(prefs->getBool("/live_effects/measure-line/hide_back")); + format.param_update_default(format_value.c_str()); + format.param_hide_canvas_text(); dimline_format.param_hide_canvas_text(); helperlines_format.param_hide_canvas_text(); anotation_format.param_hide_canvas_text(); arrows_format.param_hide_canvas_text(); - precision.param_set_range(0, 100); - precision.param_set_increments(1, 1); - precision.param_set_digits(0); - precision.param_make_integer(true); - curve_linked.param_set_range(0, 999); - curve_linked.param_set_increments(1, 1); - curve_linked.param_set_digits(0); - curve_linked.param_make_integer(true); - precision.param_make_integer(true); - position.param_set_range(-999999.0, 999999.0); - position.param_set_increments(1, 1); - position.param_set_digits(2); - text_top_bottom.param_set_range(-999999.0, 999999.0); - text_top_bottom.param_set_increments(1, 1); - text_top_bottom.param_set_digits(2); - text_right_left.param_set_range(-999999.0, 999999.0); - text_right_left.param_set_increments(1, 1); - text_right_left.param_set_digits(2); - helpline_distance.param_set_range(-999999.0, 999999.0); - helpline_distance.param_set_increments(1, 1); - helpline_distance.param_set_digits(2); - helpline_overlap.param_set_range(-999999.0, 999999.0); - helpline_overlap.param_set_increments(1, 1); - helpline_overlap.param_set_digits(2); + precision.param_setRange(0, 100); + precision.param_setIncrements(1, 1); + precision.param_setDigits(0); + precision.param_makeInteger(true); + curve_linked.param_setRange(0, 999); + curve_linked.param_setIncrements(1, 1); + curve_linked.param_setDigits(0); + curve_linked.param_makeInteger(true); + precision.param_makeInteger(true); + position.param_setRange(-999999.0, 999999.0); + position.param_setIncrements(1, 1); + position.param_setDigits(2); + text_top_bottom.param_setRange(-999999.0, 999999.0); + text_top_bottom.param_setIncrements(1, 1); + text_top_bottom.param_setDigits(2); + text_right_left.param_setRange(-999999.0, 999999.0); + text_right_left.param_setIncrements(1, 1); + text_right_left.param_setDigits(2); + helpline_distance.param_setRange(-999999.0, 999999.0); + helpline_distance.param_setIncrements(1, 1); + helpline_distance.param_setDigits(2); + helpline_overlap.param_setRange(-999999.0, 999999.0); + helpline_overlap.param_setIncrements(1, 1); + helpline_overlap.param_setDigits(2); start_stored = Geom::Point(0,0); end_stored = Geom::Point(0,0); } @@ -375,7 +352,7 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl items.push_back(id); Geom::OptRect bounds = SP_ITEM(elemref)->bounds(SPItem::GEOMETRIC_BBOX); if (bounds) { - anotation_width = bounds->width() * 1.4; + anotation_width = bounds->width() * 1.15; } } @@ -405,8 +382,14 @@ LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, const char * id, b k = (Geom::distance(start,end)/2.0) - arrow_gap - (anotation_width/2.0); } if (Geom::distance(start,end) < anotation_width){ - return; + if ((elemref = document->getObjectById(id))) { + if (remove) { + elemref->deleteObject(); + } + return; + } } + //k = std::max(k , arrow_gap -1); Geom::Ray ray(end, start); Geom::Coord angle = ray.angle(); line_path.start(start); @@ -501,7 +484,7 @@ LPEMeasureLine::doOnApply(SPLPEItem const* lpeitem) item->removeCurrentPathEffect(false); } id_origin.param_setValue(Glib::ustring(lpeitem->getId())); - id_origin.write_to_SVG(); + id_origin.writeToSVG(); } void @@ -529,8 +512,8 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) format.param_setValue(Glib::ustring("{measure}{unit}")); } size_t ncurves = pathvector.curveCount(); - if (ncurves != (size_t)curve_linked.param_get_max()) { - curve_linked.param_set_range(0, ncurves); + if (ncurves != (size_t)curve_linked.param_getMax()) { + curve_linked.param_setRange(0, ncurves); } Geom::Point start = pathvector.initialPoint(); Geom::Point end = pathvector.finalPoint(); @@ -621,6 +604,9 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) } bool overflow = false; const char * downline = g_strdup(Glib::ustring("downline-").append(this->getRepr()->attribute("id")).c_str()); + //delete residual lines if exist + createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false); + //Create it if ((anotation_width/2) + std::abs(text_right_left) > Geom::distance(start,end)/2.0) { Geom::Point sstart = end - Point::polar(angle_cross, position); Geom::Point send = end - Point::polar(angle_cross, position); @@ -644,9 +630,6 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) } overflow = true; createLine(sstart, prog_end, downline, true, overflow, false, false); - } else { - //erase it - createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false); } //LINE arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str()); @@ -707,44 +690,41 @@ Gtk::Widget *LPEMeasureLine::newWidget() vbox->set_spacing(2); std::vector::iterator it = param_vector.begin(); - Gtk::HBox * button1 = Gtk::manage(new Gtk::HBox(true,0)); Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); vbox_expander->set_border_width(0); vbox_expander->set_spacing(2); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { Parameter *param = *it; - Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); - Glib::ustring *tip = param->param_getTooltip(); - if (widg) { - if (param->param_key != "dimline_format" && - param->param_key != "helperlines_format" && - param->param_key != "arrows_format" && - param->param_key != "anotation_format") { - vbox->pack_start(*widg, true, true, 2); - } else { - vbox_expander->pack_start(*widg, true, true, 2); - } - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); + if (param->param_key != "id_origin") { + Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + Glib::ustring *tip = param->param_getTooltip(); + if (widg) { + if (param->param_key != "dimline_format" && + param->param_key != "helperlines_format" && + param->param_key != "arrows_format" && + param->param_key != "anotation_format") { + vbox->pack_start(*widg, true, true, 2); + } else { + vbox_expander->pack_start(*widg, true, true, 2); + } + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } } } } ++it; } - Gtk::Button *save_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Save '*' as default")))); - save_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::saveDefault)); - button1->pack_start(*save_default, true, true, 2); expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show DIM CSS style override")))); expander->add(*vbox_expander); expander->set_expanded(expanded); expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPEMeasureLine::onExpanderChanged) ); vbox->pack_start(*expander, true, true, 2); - vbox->pack_start(*button1, true, true, 2); return dynamic_cast(vbox); } @@ -765,31 +745,6 @@ LPEMeasureLine::doEffect_path(Geom::PathVector const &path_in) return path_in; } -void -LPEMeasureLine::saveDefault() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setString("/live_effects/measure-line/fontbutton", Glib::ustring(fontbutton.param_getSVGValue())); - prefs->setDouble("/live_effects/measure-line/scale", scale); - prefs->setInt("/live_effects/measure-line/precision", precision); - prefs->setDouble("/live_effects/measure-line/position", position); - prefs->setDouble("/live_effects/measure-line/text_top_bottom", text_top_bottom); - prefs->setDouble("/live_effects/measure-line/helpline_distance", helpline_distance); - prefs->setDouble("/live_effects/measure-line/helpline_overlap", helpline_overlap); - prefs->setString("/live_effects/measure-line/unit", Glib::ustring(unit.get_abbreviation())); - prefs->setString("/live_effects/measure-line/format", Glib::ustring(format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/dimline_format", Glib::ustring(dimline_format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/helperlines_format", Glib::ustring(helperlines_format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/anotation_format", Glib::ustring(anotation_format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/arrows_format", Glib::ustring(arrows_format.param_getSVGValue())); - prefs->setBool("/live_effects/measure-line/flip_side", flip_side); - prefs->setBool("/live_effects/measure-line/scale_sensitive", scale_sensitive); - prefs->setBool("/live_effects/measure-line/local_locale", local_locale); - prefs->setBool("/live_effects/measure-line/line_group_05", line_group_05); - prefs->setBool("/live_effects/measure-line/rotate_anotation", rotate_anotation); - prefs->setBool("/live_effects/measure-line/hide_back", hide_back); -} - }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-measure-line.h b/src/live_effects/lpe-measure-line.h index 724c0d9248ba1334ca2192a21653279ccdc8026b..b42f7cfd52c40edc8ce7ee3349865de85081d5ca 100644 --- a/src/live_effects/lpe-measure-line.h +++ b/src/live_effects/lpe-measure-line.h @@ -49,7 +49,6 @@ public: void createTextLabel(Geom::Point pos, double length, Geom::Coord angle, bool remove, bool valid); void onExpanderChanged(); void createArrowMarker(const char * mode); - void saveDefault(); virtual Gtk::Widget *newWidget(); private: UnitParam unit; diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index b411bd699dbad3e656f790ed6e29740972d9d0dd..4272751b1e479ec9c13082eb6607768716186af8 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -73,9 +73,9 @@ LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) : registerParameter(¢er_point); registerParameter(&id_origin); id_origin.param_hide_canvas_text(); - split_gap.param_set_range(-999999.0, 999999.0); - split_gap.param_set_increments(0.1, 0.1); - split_gap.param_set_digits(5); + split_gap.param_setRange(-999999.0, 999999.0); + split_gap.param_setIncrements(0.1, 0.1); + split_gap.param_setDigits(5); apply_to_clippath_and_mask = true; previous_center = Geom::Point(0,0); } @@ -114,7 +114,7 @@ LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) using namespace Geom; original_bbox(lpeitem); - //center_point->param_set_liveupdate(false); + //center_point->param_setLiveupdate(false); Point point_a(boundingbox_X.max(), boundingbox_Y.min()); Point point_b(boundingbox_X.max(), boundingbox_Y.max()); if (mode == MT_Y) { @@ -126,61 +126,61 @@ LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) point_b = Geom::Point(center_point[X],boundingbox_Y.max()); } if ((Geom::Point)start_point == (Geom::Point)end_point) { - start_point.param_setValue(point_a, true); - end_point.param_setValue(point_b, true); + start_point.param_setValue(point_a); + end_point.param_setValue(point_b); previous_center = Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point); - center_point.param_setValue(previous_center, true); + center_point.param_setValue(previous_center); return; } if ( mode == MT_X || mode == MT_Y ) { if (!are_near(previous_center, (Geom::Point)center_point, 0.01)) { center_point.param_setValue(Geom::middle_point(point_a, point_b), true); - end_point.param_setValue(point_b, true); - start_point.param_setValue(point_a, true); + end_point.param_setValue(point_b); + start_point.param_setValue(point_a); } else { if ( mode == MT_X ) { if (!are_near(start_point[X], point_a[X], 0.01)) { - start_point.param_setValue(point_a, true); + start_point.param_setValue(point_a); } if (!are_near(end_point[X], point_b[X], 0.01)) { - end_point.param_setValue(point_b, true); + end_point.param_setValue(point_b); } } else { //MT_Y if (!are_near(start_point[Y], point_a[Y], 0.01)) { - start_point.param_setValue(point_a, true); + start_point.param_setValue(point_a); } if (!are_near(end_point[Y], point_b[Y], 0.01)) { - end_point.param_setValue(point_b, true); + end_point.param_setValue(point_b); } } } } else if ( mode == MT_FREE) { if (are_near(previous_center, (Geom::Point)center_point, 0.01)) { - center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true); + center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point)); } else { Geom::Point trans = center_point - Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point); - start_point.param_setValue(start_point * trans, true); - end_point.param_setValue(end_point * trans, true); + start_point.param_setValue(start_point * trans); + end_point.param_setValue(end_point * trans); } } else if ( mode == MT_V){ SPDocument * document = SP_ACTIVE_DOCUMENT; if (document) { Geom::Affine transform = i2anc_affine(SP_OBJECT(lpeitem), NULL).inverse(); Geom::Point sp = Geom::Point(document->getWidth().value("px")/2.0, 0) * transform; - start_point.param_setValue(sp, true); + start_point.param_setValue(sp); Geom::Point ep = Geom::Point(document->getWidth().value("px")/2.0, document->getHeight().value("px")) * transform; - end_point.param_setValue(ep, true); - center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true); + end_point.param_setValue(ep); + center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point)); } } else { //horizontal page SPDocument * document = SP_ACTIVE_DOCUMENT; if (document) { Geom::Affine transform = i2anc_affine(SP_OBJECT(lpeitem), NULL).inverse(); Geom::Point sp = Geom::Point(0, document->getHeight().value("px")/2.0) * transform; - start_point.param_setValue(sp, true); + start_point.param_setValue(sp); Geom::Point ep = Geom::Point(document->getWidth().value("px"), document->getHeight().value("px")/2.0) * transform; - end_point.param_setValue(ep, true); - center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true); + end_point.param_setValue(ep); + center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point)); } } previous_center = center_point; @@ -362,7 +362,7 @@ LPEMirrorSymmetry::transform_multiply(Geom::Affine const& postmul, bool set) // cycle through all parameters. Most parameters will not need transformation, but path and point params do. for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { Parameter * param = *it; - param->param_transform_multiply(postmul, set); + param->param_transformMultiply(postmul, set); } previous_center = Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point); } @@ -378,15 +378,16 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem const* lpeitem) Point point_b(boundingbox_X.max(), boundingbox_Y.max()); Point point_c(boundingbox_X.max(), boundingbox_Y.middle()); start_point.param_setValue(point_a); - start_point.param_update_default(point_a); + start_point.param_updateDefault(point_a); end_point.param_setValue(point_b); - end_point.param_update_default(point_b); - center_point.param_setValue(point_c, true); + end_point.param_updateDefault(point_b); + center_point.param_setValue(point_c); + previous_center = center_point; SPLPEItem * splpeitem = const_cast(lpeitem); if (!lpeitem->hasPathEffectOfType(this->effectType(), false) ){ //first applied not ready yet id_origin.param_setValue(lpeitem->getRepr()->attribute("id")); - id_origin.write_to_SVG(); + id_origin.writeToSVG(); } } diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp index c853e4afa8227cdd36dbb6df726ac3644d6e4522..0ce729c0c84328f8d1adfc5226aca5887e5446bc 100644 --- a/src/live_effects/lpe-offset.cpp +++ b/src/live_effects/lpe-offset.cpp @@ -38,8 +38,8 @@ void LPEOffset::doOnApply(SPLPEItem const* lpeitem) { Geom::Point offset = *(SP_SHAPE(lpeitem)->_curve->first_point()); - offset_pt.param_update_default(offset); - offset_pt.param_setValue(offset,true); + offset_pt.param_updateDefault(offset); + offset_pt.param_setValue(offset); } static void append_half_circle(Geom::Piecewise > &pwd2, diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index 271442c7d441a775b33dc9a7beb4d6261d9b3be8..41f64e58e52b3af16497e0eea598340c3b945c85 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -70,7 +70,7 @@ LPEParallel::doOnApply (SPLPEItem const* lpeitem) B = *(curve->last_point()); dir = unit_vector(B - A); Geom::Point offset = (A + B)/2 + dir.ccw() * 100; - offset_pt.param_update_default(offset); + offset_pt.param_updateDefault(offset); offset_pt.param_setValue(offset, true); } @@ -120,7 +120,7 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori Geom::Point const s = snap_knot_position(p, state); double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir)); - lpe->length_left.param_set_value(-lambda); + lpe->length_left.param_setValue(-lambda); sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } @@ -135,7 +135,7 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or Geom::Point const s = snap_knot_position(p, state); double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir)); - lpe->length_right.param_set_value(lambda); + lpe->length_right.param_setValue(lambda); sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index b026bbc22ea867d59bb5b87eb6b1a9ed0223b589..62f71df5d6dd06f6ceabb2e33f52047f702d3aee 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -95,8 +95,8 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : registerParameter(&prop_units); registerParameter(&vertical_pattern); registerParameter(&fuse_tolerance); - prop_scale.param_set_digits(3); - prop_scale.param_set_increments(0.01, 0.10); + prop_scale.param_setDigits(3); + prop_scale.param_setIncrements(0.01, 0.10); _provides_knotholder_entities = true; @@ -157,9 +157,9 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise > con } //TODO: dynamical update of parameter ranges? //if (prop_units.get_value()){ - // spacing.param_set_range(-.9, Geom::infinity()); + // spacing.param_setRange(-.9, Geom::infinity()); // }else{ - // spacing.param_set_range(-pattBndsX.extent()*.9, Geom::infinity()); + // spacing.param_setRange(-pattBndsX.extent()*.9, Geom::infinity()); // } y0 += noffset; @@ -260,12 +260,12 @@ LPEPatternAlongPath::transform_multiply(Geom::Affine const& postmul, bool set) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool transform_stroke = prefs ? prefs->getBool("/options/transform/stroke", true) : true; if (transform_stroke && !scale_y_rel) { - prop_scale.param_set_value(prop_scale * ((postmul.expansionX() + postmul.expansionY()) / 2)); - prop_scale.write_to_SVG(); + prop_scale.param_setValue(prop_scale * ((postmul.expansionX() + postmul.expansionY()) / 2)); + prop_scale.writeToSVG(); } if (postmul.isTranslation()) { - pattern.param_transform_multiply(postmul, set); - pattern.write_to_SVG(); + pattern.param_transformMultiply(postmul, set); + pattern.writeToSVG(); } } @@ -307,9 +307,9 @@ KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Poin Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse(); Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos); if(nearest_to_ray == 0){ - lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0)); + lpe->prop_scale.param_setValue(-Geom::distance(s , ptA)/(lpe->original_height/2.0)); } else { - lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + lpe->prop_scale.param_setValue(Geom::distance(s , ptA)/(lpe->original_height/2.0)); } } diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index dab169cfe8d0532d6a02f94f892f3a8b757a1a0b..5f666d53834ee5014a54eae55e9b7966d7af083c 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -67,10 +67,10 @@ KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, guint state, bool le double lambda = Geom::nearest_time(s, lpe->M, lpe->perp_dir); if (left) { lpe->C = lpe->M + lpe->perp_dir * lambda; - lpe->length_left.param_set_value(lambda); + lpe->length_left.param_setValue(lambda); } else { lpe->D = lpe->M + lpe->perp_dir * lambda; - lpe->length_right.param_set_value(-lambda); + lpe->length_right.param_setValue(-lambda); } // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index 365ff538963b1f3a4de43d360d82f792b7bb2fd0..fc650dadcf227924c42fe504395c8404f74ab5b7 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -110,15 +110,15 @@ void LPEPerspectiveEnvelope::doEffect(SPCurve *curve) int position_c = Geom::sgn(Geom::cross(handles[2] - handles[3], handles[0] - handles[3])); if (position_a != 1 && move0) { Geom::Point point_a = line_a.pointAt(line_a.nearestTime(handles[0])); - down_left_point.param_setValue(point_a, true); + down_left_point.param_setValue(point_a); } if (position_b == 1 && move0) { Geom::Point point_b = line_b.pointAt(line_b.nearestTime(handles[0])); - down_left_point.param_setValue(point_b, true); + down_left_point.param_setValue(point_b); } if (position_c == 1 && move0) { Geom::Point point_c = line_c.pointAt(line_c.nearestTime(handles[0])); - down_left_point.param_setValue(point_c, true); + down_left_point.param_setValue(point_c); } line_a.setPoints(handles[0],handles[2]); line_b.setPoints(handles[2],handles[3]); @@ -128,15 +128,15 @@ void LPEPerspectiveEnvelope::doEffect(SPCurve *curve) position_c = Geom::sgn(Geom::cross(handles[3] - handles[0], handles[1] - handles[0])); if (position_a != 1 && move1) { Geom::Point point_a = line_a.pointAt(line_a.nearestTime(handles[1])); - up_left_point.param_setValue(point_a, true); + up_left_point.param_setValue(point_a); } if (position_b == 1 && move1) { Geom::Point point_b = line_b.pointAt(line_b.nearestTime(handles[1])); - up_left_point.param_setValue(point_b, true); + up_left_point.param_setValue(point_b); } if (position_c == 1 && move1) { Geom::Point point_c = line_c.pointAt(line_c.nearestTime(handles[1])); - up_left_point.param_setValue(point_c, true); + up_left_point.param_setValue(point_c); } line_a.setPoints(handles[1],handles[3]); line_b.setPoints(handles[3],handles[0]); @@ -146,15 +146,15 @@ void LPEPerspectiveEnvelope::doEffect(SPCurve *curve) position_c = Geom::sgn(Geom::cross(handles[0] - handles[1], handles[2] - handles[1])); if (position_a != 1 && move2) { Geom::Point point_a = line_a.pointAt(line_a.nearestTime(handles[2])); - up_right_point.param_setValue(point_a, true); + up_right_point.param_setValue(point_a); } if (position_b == 1 && move2) { Geom::Point point_b = line_b.pointAt(line_b.nearestTime(handles[2])); - up_right_point.param_setValue(point_b, true); + up_right_point.param_setValue(point_b); } if (position_c == 1 && move2) { Geom::Point point_c = line_c.pointAt(line_c.nearestTime(handles[2])); - up_right_point.param_setValue(point_c, true); + up_right_point.param_setValue(point_c); } line_a.setPoints(handles[2],handles[0]); line_b.setPoints(handles[0],handles[1]); @@ -164,15 +164,15 @@ void LPEPerspectiveEnvelope::doEffect(SPCurve *curve) position_c = Geom::sgn(Geom::cross(handles[1] - handles[2], handles[3] - handles[2])); if (position_a != 1 && move3) { Geom::Point point_a = line_a.pointAt(line_a.nearestTime(handles[3])); - down_right_point.param_setValue(point_a, true); + down_right_point.param_setValue(point_a); } if (position_b == 1 && move3) { Geom::Point point_b = line_b.pointAt(line_b.nearestTime(handles[3])); - down_right_point.param_setValue(point_b, true); + down_right_point.param_setValue(point_b); } if (position_c == 1 && move3) { Geom::Point point_c = line_c.pointAt(line_c.nearestTime(handles[3])); - down_right_point.param_setValue(point_c, true); + down_right_point.param_setValue(point_c); } } else { handles.resize(4); @@ -434,8 +434,8 @@ LPEPerspectiveEnvelope::vertical(PointParam ¶m_one, PointParam ¶m_two, G } A[Geom::X] = nearest[Geom::X] - distance_middle; B[Geom::X] = nearest[Geom::X] + distance_middle; - param_one.param_setValue(A, true); - param_two.param_setValue(B, true); + param_one.param_setValue(A); + param_two.param_setValue(B); } void @@ -455,8 +455,8 @@ LPEPerspectiveEnvelope::horizontal(PointParam ¶m_one, PointParam ¶m_two, } A[Geom::Y] = nearest[Geom::Y] - distance_middle; B[Geom::Y] = nearest[Geom::Y] + distance_middle; - param_one.param_setValue(A, true); - param_two.param_setValue(B, true); + param_one.param_setValue(A); + param_two.param_setValue(B); } void @@ -484,19 +484,19 @@ LPEPerspectiveEnvelope::setDefaults() Geom::Point down_left(boundingbox_X.min(), boundingbox_Y.max()); Geom::Point down_right(boundingbox_X.max(), boundingbox_Y.max()); - up_left_point.param_update_default(up_left); - up_right_point.param_update_default(up_right); - down_right_point.param_update_default(down_right); - down_left_point.param_update_default(down_left); + up_left_point.param_updateDefault(up_left); + up_right_point.param_updateDefault(up_right); + down_right_point.param_updateDefault(down_right); + down_left_point.param_updateDefault(down_left); } void LPEPerspectiveEnvelope::resetGrid() { - up_left_point.param_set_default(); - up_right_point.param_set_default(); - down_right_point.param_set_default(); - down_left_point.param_set_default(); + up_left_point.param_valueFromDefault(); + up_right_point.param_valueFromDefault(); + down_right_point.param_valueFromDefault(); + down_left_point.param_valueFromDefault(); } void diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index 435c91c2d70b8203082147de2ce3db394e253dd5..460d96156ebdcfcdedc7e98beef1157561c6a7c7 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -273,8 +273,8 @@ KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin Geom::Point const s = snap_knot_position(p, state); - lpe->offsetx.param_set_value((s - origin)[Geom::X]); - lpe->offsety.param_set_value(-(s - origin)[Geom::Y]); // additional minus sign is due to coordinate system flipping + lpe->offsetx.param_setValue((s - origin)[Geom::X]); + lpe->offsety.param_setValue(-(s - origin)[Geom::Y]); // additional minus sign is due to coordinate system flipping // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index d87f92fccf67ac92124b6a209a4659d9952a56ff..2c1edbaaa71c0ae8a81be9268d25299031fe5e68 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -177,7 +177,7 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : /// @todo offset_points are initialized with empty path, is that bug-save? interpolator_beta.addSlider(true); - interpolator_beta.param_set_range(0.,1.); + interpolator_beta.param_setRange(0.,1.); registerParameter(&offset_points); registerParameter(&sort_points); @@ -247,7 +247,7 @@ LPEPowerStroke::doOnApply(SPLPEItem const* lpeitem) points.push_back( Geom::Point(size - 0.2,width) ); } } - offset_points.param_set_and_write_new_value(points); + offset_points.param_setAndWriteNewValue(points); } else { g_warning("LPE Powerstroke can only be applied to shapes (not groups)."); } diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index 47613f58edfc9747ab3c085bc4b51ac26c0593ff..62d4539de0897749e258bffc3b039f0bf39aabce 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -26,8 +26,8 @@ LPERecursiveSkeleton::LPERecursiveSkeleton(LivePathEffectObject *lpeobject) : { show_orig_path = true; concatenate_before_pwd2 = true; - iterations.param_make_integer(true); - iterations.param_set_range(1, 15); + iterations.param_makeInteger(true); + iterations.param_setRange(1, 15); registerParameter(&iterations); } diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index d832b361500053467efbad7e6a7836e80916b2a9..0504ffbf2d69730d55331471446c113923d72daf 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -262,13 +262,13 @@ LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) : registerParameter(&front_thickness); registerParameter(&back_thickness); - //hatch_dist.param_set_range(0.1, Geom::infinity()); - growth.param_set_range(0, Geom::infinity()); - dist_rdm.param_set_range(0, 99.); - stroke_width_top.param_set_range(0, Geom::infinity()); - stroke_width_bot.param_set_range(0, Geom::infinity()); - front_thickness.param_set_range(0, Geom::infinity()); - back_thickness.param_set_range(0, Geom::infinity()); + //hatch_dist.param_setRange(0.1, Geom::infinity()); + growth.param_setRange(0, Geom::infinity()); + dist_rdm.param_setRange(0, 99.); + stroke_width_top.param_setRange(0, Geom::infinity()); + stroke_width_bot.param_setRange(0, Geom::infinity()); + front_thickness.param_setRange(0, Geom::infinity()); + back_thickness.param_setRange(0, Geom::infinity()); // hide the widgets for direction and bender vectorparams direction.widget_is_visible = false; @@ -558,13 +558,13 @@ LPERoughHatches::resetDefaults(SPItem const* item) if (bbox) { origin = bbox->midpoint(); vector = Geom::Point((*bbox)[X].extent()/4, 0.); - top_edge_variation.param_set_value( (*bbox)[Y].extent()/10, 0 ); - bot_edge_variation.param_set_value( (*bbox)[Y].extent()/10, 0 ); - top_edge_variation.write_to_SVG(); - bot_edge_variation.write_to_SVG(); + top_edge_variation.param_setValue( (*bbox)[Y].extent()/10, 0 ); + bot_edge_variation.param_setValue( (*bbox)[Y].extent()/10, 0 ); + top_edge_variation.writeToSVG(); + bot_edge_variation.writeToSVG(); } //direction.set_and_write_new_values(origin, vector); - //bender.param_set_and_write_new_value( origin + Geom::Point(5,0) ); + //bender.param_setAndWriteNewValue( origin + Geom::Point(5,0) ); direction.set_and_write_new_values(origin + Geom::Point(0,-5), vector); bender.set_and_write_new_values( origin, Geom::Point(5,0) ); hatch_dist = Geom::L2(vector)/2; diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index e847494a2f43d62bd94f004346f7d1417db21108..9987da046460b0927a9a42817523330eb99cf7d0 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -75,15 +75,15 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) registerParameter(&shift_nodes); registerParameter(&fixed_displacement); registerParameter(&spray_tool_friendly); - displace_x.param_set_range(0., Geom::infinity()); - displace_y.param_set_range(0., Geom::infinity()); - global_randomize.param_set_range(0., Geom::infinity()); - max_segment_size.param_set_range(0., Geom::infinity()); - max_segment_size.param_set_increments(1, 1); - max_segment_size.param_set_digits(1); - segments.param_set_range(1, Geom::infinity()); - segments.param_set_increments(1, 1); - segments.param_set_digits(0); + displace_x.param_setRange(0., Geom::infinity()); + displace_y.param_setRange(0., Geom::infinity()); + global_randomize.param_setRange(0., Geom::infinity()); + max_segment_size.param_setRange(0., Geom::infinity()); + max_segment_size.param_setIncrements(1, 1); + max_segment_size.param_setDigits(1); + segments.param_setRange(1, Geom::infinity()); + segments.param_setIncrements(1, 1); + segments.param_setDigits(0); seed = 0; apply_to_clippath_and_mask = true; } @@ -95,7 +95,7 @@ void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) if(spray_tool_friendly && seed == 0 && SP_OBJECT(lpeitem)->getId()){ std::string id_item(SP_OBJECT(lpeitem)->getId()); long seed = static_cast(boost::hash_value(id_item)); - global_randomize.param_set_value(global_randomize.get_value(), seed); + global_randomize.param_setValue(global_randomize.get_value(), seed); } displace_x.resetRandomizer(); displace_y.resetRandomizer(); diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 852592219ae5a4afbb1f196a897a50c3de1ca664..453142571f3db8039e60911a4605e759718eb417 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -55,13 +55,13 @@ LPERuler::LPERuler(LivePathEffectObject *lpeobject) : registerParameter(&mark_dir); registerParameter(&border_marks); - major_mark_steps.param_make_integer(); - major_mark_steps.param_set_range(1, 1000); - shift.param_make_integer(); + major_mark_steps.param_makeInteger(); + major_mark_steps.param_setRange(1, 1000); + shift.param_makeInteger(); - mark_length.param_set_increments(1.0, 10.0); - minor_mark_length.param_set_increments(1.0, 10.0); - offset.param_set_increments(1.0, 10.0); + mark_length.param_setIncrements(1.0, 10.0); + minor_mark_length.param_setIncrements(1.0, 10.0); + offset.param_setIncrements(1.0, 10.0); } LPERuler::~LPERuler() diff --git a/src/live_effects/lpe-show_handles.cpp b/src/live_effects/lpe-show_handles.cpp index 7c298d0e7fba42b8056a8e012f22f42d76b014c1..f7f9b2b181fa0fbea9c1cdb4a203ca71487f0725 100644 --- a/src/live_effects/lpe-show_handles.cpp +++ b/src/live_effects/lpe-show_handles.cpp @@ -34,9 +34,9 @@ LPEShowHandles::LPEShowHandles(LivePathEffectObject *lpeobject) registerParameter(&original_path); registerParameter(&show_center_node); registerParameter(&scale_nodes_and_handles); - scale_nodes_and_handles.param_set_range(0, 500.); - scale_nodes_and_handles.param_set_increments(1, 1); - scale_nodes_and_handles.param_set_digits(2); + scale_nodes_and_handles.param_setRange(0, 500.); + scale_nodes_and_handles.param_setIncrements(1, 1); + scale_nodes_and_handles.param_setDigits(2); stroke_width = 1.0; } diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 5de9816bb9609814e8b4a6dee5b3026252568a3b..8bc61969bb6f11d415f591180967a40ea24934da 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -35,21 +35,21 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) registerParameter(&simplify_individual_paths); registerParameter(&simplify_just_coalesce); - threshold.param_set_range(0.0001, Geom::infinity()); - threshold.param_set_increments(0.0001, 0.0001); - threshold.param_set_digits(6); + threshold.param_setRange(0.0001, Geom::infinity()); + threshold.param_setIncrements(0.0001, 0.0001); + threshold.param_setDigits(6); - steps.param_set_range(0, 100); - steps.param_set_increments(1, 1); - steps.param_set_digits(0); + steps.param_setRange(0, 100); + steps.param_setIncrements(1, 1); + steps.param_setDigits(0); - smooth_angles.param_set_range(0.0, 360.0); - smooth_angles.param_set_increments(10, 10); - smooth_angles.param_set_digits(2); + smooth_angles.param_setRange(0.0, 360.0); + smooth_angles.param_setIncrements(10, 10); + smooth_angles.param_setDigits(2); - helper_size.param_set_range(0.0, 999.0); - helper_size.param_set_increments(5, 5); - helper_size.param_set_digits(2); + helper_size.param_setRange(0.0, 999.0); + helper_size.param_setIncrements(5, 5); + helper_size.param_setDigits(2); radius_helper_nodes = 6.0; apply_to_clippath_and_mask = true; diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index e3376b7e569a2b4f89b33d0587f5e4a8d43e00e3..7b34c3747a2c4e042012f644218fdb8a786d190b 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -84,28 +84,28 @@ LPESketch::LPESketch(LivePathEffectObject *lpeobject) : #endif #endif - nbiter_approxstrokes.param_make_integer(); - nbiter_approxstrokes.param_set_range(0, Geom::infinity()); - strokelength.param_set_range(1, Geom::infinity()); - strokelength.param_set_increments(1., 5.); - strokelength_rdm.param_set_range(0, 1.); - strokeoverlap.param_set_range(0, 1.); - strokeoverlap.param_set_increments(0.1, 0.30); - ends_tolerance.param_set_range(0., 1.); - parallel_offset.param_set_range(0, Geom::infinity()); - tremble_frequency.param_set_range(0.01, 100.); - tremble_frequency.param_set_increments(.5, 1.5); - strokeoverlap_rdm.param_set_range(0, 1.); + nbiter_approxstrokes.param_makeInteger(); + nbiter_approxstrokes.param_setRange(0, Geom::infinity()); + strokelength.param_setRange(1, Geom::infinity()); + strokelength.param_setIncrements(1., 5.); + strokelength_rdm.param_setRange(0, 1.); + strokeoverlap.param_setRange(0, 1.); + strokeoverlap.param_setIncrements(0.1, 0.30); + ends_tolerance.param_setRange(0., 1.); + parallel_offset.param_setRange(0, Geom::infinity()); + tremble_frequency.param_setRange(0.01, 100.); + tremble_frequency.param_setIncrements(.5, 1.5); + strokeoverlap_rdm.param_setRange(0, 1.); #ifdef LPE_SKETCH_USE_CONSTRUCTION_LINES - nbtangents.param_make_integer(); - nbtangents.param_set_range(0, Geom::infinity()); - tgtscale.param_set_range(0, Geom::infinity()); - tgtscale.param_set_increments(.1, .5); - tgtlength.param_set_range(0, Geom::infinity()); - tgtlength.param_set_increments(1., 5.); - tgtlength_rdm.param_set_range(0, 1.); - tgt_places_rdmness.param_set_range(0, 1.); + nbtangents.param_makeInteger(); + nbtangents.param_setRange(0, Geom::infinity()); + tgtscale.param_setRange(0, Geom::infinity()); + tgtscale.param_setIncrements(.1, .5); + tgtlength.param_setRange(0, Geom::infinity()); + tgtlength.param_setIncrements(1., 5.); + tgtlength_rdm.param_setRange(0, 1.); + tgt_places_rdmness.param_setRange(0, 1.); //this is not very smart, but required to avoid having lot of tangents stacked on short components. //Nota: we could specify a density instead of an absolute number, but this would be scale dependant. concatenate_before_pwd2 = true; diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index 69a4dfad9c31225d98717d6032b496d9b9590ba1..e21e416e6b74e1f2364405c4567b9c86bcbfa371 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -125,14 +125,14 @@ KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*or Geom::Point const s = snap_knot_position(p, state); if ( !SP_IS_SHAPE(lpe->sp_lpe_item) ) { - //lpe->t_attach.param_set_value(0); + //lpe->t_attach.param_setValue(0); g_warning("LPEItem is not a path! %s:%d\n", __FILE__, __LINE__); return; } Piecewise > pwd2 = paths_to_pw( lpe->pathvector_before_effect ); double t0 = nearest_time(s, pwd2); - lpe->t_attach.param_set_value(t0); + lpe->t_attach.param_setValue(t0); // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); @@ -146,7 +146,7 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_time(s, lpe->ptA, lpe->derivA); - lpe->length_left.param_set_value(-lambda); + lpe->length_left.param_setValue(-lambda); sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } @@ -159,7 +159,7 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_time(s, lpe->ptA, lpe->derivA); - lpe->length_right.param_set_value(lambda); + lpe->length_right.param_setValue(lambda); sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } diff --git a/src/live_effects/lpe-taperstroke.cpp b/src/live_effects/lpe-taperstroke.cpp index f4a81aa9006694b3ef5df57c355ba0ba59b5ec9f..a743cd09bc309b94e232a84ba6ccac1d7b6544e0 100644 --- a/src/live_effects/lpe-taperstroke.cpp +++ b/src/live_effects/lpe-taperstroke.cpp @@ -74,8 +74,8 @@ LPETaperStroke::LPETaperStroke(LivePathEffectObject *lpeobject) : show_orig_path = true; _provides_knotholder_entities = true; - attach_start.param_set_digits(3); - attach_end.param_set_digits(3); + attach_start.param_setDigits(3); + attach_end.param_setDigits(3); registerParameter(&line_width); registerParameter(&attach_start); @@ -118,8 +118,8 @@ void LPETaperStroke::doOnApply(SPLPEItem const* lpeitem) sp_desktop_apply_css_recursive(item, css, true); sp_repr_css_attr_unref (css); - line_width.param_set_value(width); - line_width.write_to_SVG(); + line_width.param_setValue(width); + line_width.writeToSVG(); } else { printf("WARNING: It only makes sense to apply Taper stroke to paths (not groups).\n"); } @@ -201,7 +201,7 @@ Geom::PathVector LPETaperStroke::doEffect_path(Geom::PathVector const& path_in) // check to see if the knots were dragged over each other // if so, reset the end offset, but still allow the start offset. if ( attach_start >= (size - attach_end) ) { - attach_end.param_set_value( size - attach_start ); + attach_end.param_setValue( size - attach_start ); metInMiddle = true; } } @@ -216,10 +216,10 @@ Geom::PathVector LPETaperStroke::doEffect_path(Geom::PathVector const& path_in) // don't let it be integer (TODO this is stupid!) { if (double(unsigned(attach_start)) == attach_start) { - attach_start.param_set_value(attach_start - 0.00001); + attach_start.param_setValue(attach_start - 0.00001); } if (double(unsigned(attach_end)) == attach_end) { - attach_end.param_set_value(attach_end - 0.00001); + attach_end.param_setValue(attach_end - 0.00001); } } @@ -229,20 +229,20 @@ Geom::PathVector LPETaperStroke::doEffect_path(Geom::PathVector const& path_in) // don't let the knots be farther than they are allowed to be { if ((unsigned)attach_start >= allowed_start) { - attach_start.param_set_value((double)allowed_start - 0.00001); + attach_start.param_setValue((double)allowed_start - 0.00001); } if ((unsigned)attach_end >= allowed_end) { - attach_end.param_set_value((double)allowed_end - 0.00001); + attach_end.param_setValue((double)allowed_end - 0.00001); } } // don't let it be zero (this is stupid too!) if (attach_start < 0.0000001 || withinRange(double(attach_start), 0.00000001, 0.000001)) { - attach_start.param_set_value( 0.0000001 ); + attach_start.param_setValue( 0.0000001 ); zeroStart = true; } if (attach_end < 0.0000001 || withinRange(double(attach_end), 0.00000001, 0.000001)) { - attach_end.param_set_value( 0.0000001 ); + attach_end.param_setValue( 0.0000001 ); zeroEnd = true; } @@ -476,7 +476,7 @@ void KnotHolderEntityAttachBegin::knot_set(Geom::Point const &p, Geom::Point con pwd2.concat(p_in.toPwSb()); double t0 = nearest_time(s, pwd2); - lpe->attach_start.param_set_value(t0); + lpe->attach_start.param_setValue(t0); // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, true); @@ -504,7 +504,7 @@ void KnotHolderEntityAttachEnd::knot_set(Geom::Point const &p, Geom::Point const Piecewise > pwd2 = p_in.toPwSb(); double t0 = nearest_time(s, pwd2); - lpe->attach_end.param_set_value(t0); + lpe->attach_end.param_setValue(t0); sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp index c484c88a20fd28f8d44eac084f8af645d2ba3597..275a2e996985d56c131c8fe83a49da468cca5978 100644 --- a/src/live_effects/lpe-test-doEffect-stack.cpp +++ b/src/live_effects/lpe-test-doEffect-stack.cpp @@ -25,7 +25,7 @@ LPEdoEffectStackTest::LPEdoEffectStackTest(LivePathEffectObject *lpeobject) : registerParameter(&point); registerParameter(&path); - point.set_oncanvas_looks(SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR, 0x00ff0000); + point.set_onCanvasLooks(SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR, 0x00ff0000); point.param_setValue(point); } diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index ef29007750fb4f3514496aefa63d24eb87801992..9db8605da298aef6e64ff407616fe280ee6c0416 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -63,19 +63,19 @@ LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) : registerParameter(&lock_lenght); registerParameter(&lock_angle); - first_knot.param_make_integer(true); - first_knot.param_overwrite_widget(true); - last_knot.param_make_integer(true); - last_knot.param_overwrite_widget(true); - helper_size.param_set_range(0, 999); - helper_size.param_set_increments(1, 1); - helper_size.param_set_digits(0); - offset.param_set_range(-999999.0, 999999.0); - offset.param_set_increments(1, 1); - offset.param_set_digits(2); - stretch.param_set_range(0, 999.0); - stretch.param_set_increments(0.01, 0.01); - stretch.param_set_digits(4); + first_knot.param_makeInteger(true); + first_knot.param_overwriteWidget(true); + last_knot.param_makeInteger(true); + last_knot.param_overwriteWidget(true); + helper_size.param_setRange(0, 999); + helper_size.param_setIncrements(1, 1); + helper_size.param_setDigits(0); + offset.param_setRange(-999999.0, 999999.0); + offset.param_setIncrements(1, 1); + offset.param_setDigits(2); + stretch.param_setRange(0, 999.0); + stretch.param_setIncrements(0.01, 0.01); + stretch.param_setDigits(4); apply_to_clippath_and_mask = true; } @@ -102,16 +102,16 @@ LPETransform2Pts::doOnApply(SPLPEItem const* lpeitem) point_b = pathvector.back().finalCurve().initialPoint(); } size_t nnodes = nodeCount(pathvector); - last_knot.param_set_value(nnodes); + last_knot.param_setValue(nnodes); } previous_lenght = Geom::distance(point_a,point_b); Geom::Ray transformed(point_a,point_b); previous_angle = transformed.angle(); - start.param_update_default(point_a); - start.param_set_default(); - end.param_update_default(point_b); - end.param_set_default(); + start.param_updateDefault(point_a); + start.param_valueFromDefault(); + end.param_updateDefault(point_b); + end.param_valueFromDefault(); } void @@ -136,16 +136,24 @@ LPETransform2Pts::doBeforeEffect (SPLPEItem const* lpeitem) point_a = pointAtNodeIndex(pathvector,(size_t)first_knot-1); point_b = pointAtNodeIndex(pathvector,(size_t)last_knot-1); size_t nnodes = nodeCount(pathvector); - first_knot.param_set_range(1, last_knot-1); - last_knot.param_set_range(first_knot+1, nnodes); - from_original_width.param_setValue(false); + first_knot.param_setRange(1, last_knot-1); + last_knot.param_setRange(first_knot+1, nnodes); + if (from_original_width){ + from_original_width.param_setValue(false); + } } else { - first_knot.param_set_value(1); - last_knot.param_set_value(2); - first_knot.param_set_range(1,1); - last_knot.param_set_range(2,2); - from_original_width.param_setValue(true); + if (first_knot != 1){ + first_knot.param_setValue(1); + } + if (last_knot != 2){ + last_knot.param_setValue(2); + } + first_knot.param_setRange(1,1); + last_knot.param_setRange(2,2); append_path = false; + if (!from_original_width){ + from_original_width.param_setValue(true); + } } if(lock_lenght && !lock_angle && previous_lenght != -1) { Geom::Ray transformed((Geom::Point)start,(Geom::Point)end); @@ -181,14 +189,14 @@ LPETransform2Pts::updateIndex() if(!from_original_width) { point_a = pointAtNodeIndex(pathvector,(size_t)first_knot-1); point_b = pointAtNodeIndex(pathvector,(size_t)last_knot-1); - start.param_update_default(point_a); - start.param_set_default(); - end.param_update_default(point_b); - end.param_set_default(); - start.param_update_default(point_a); - end.param_update_default(point_b); - start.param_set_default(); - end.param_set_default(); + start.param_updateDefault(point_a); + start.param_valueFromDefault(); + end.param_updateDefault(point_b); + end.param_valueFromDefault(); + start.param_updateDefault(point_a); + end.param_updateDefault(point_b); + start.param_valueFromDefault(); + end.param_valueFromDefault(); } DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change index of knot")); } @@ -241,23 +249,25 @@ LPETransform2Pts::reset() point_b = Geom::Point(boundingbox_X.max(), boundingbox_Y.middle()); if(!pathvector.empty() && !from_original_width) { size_t nnodes = nodeCount(pathvector); - first_knot.param_set_range(1, last_knot-1); - last_knot.param_set_range(first_knot+1, nnodes); - first_knot.param_set_value(1); - last_knot.param_set_value(nnodes); + first_knot.param_setRange(1, last_knot-1); + last_knot.param_setRange(first_knot+1, nnodes); + first_knot.param_setValue(1); + last_knot.param_setValue(nnodes); point_a = pathvector.initialPoint(); point_b = pathvector.finalPoint(); } else { - first_knot.param_set_value(1); - last_knot.param_set_value(2); + first_knot.param_setValue(1); + last_knot.param_setValue(2); } + offset.param_set_value(0.0); + stretch.param_set_value(1.0); Geom::Ray transformed(point_a, point_b); previous_angle = transformed.angle(); previous_lenght = Geom::distance(point_a, point_b); - start.param_update_default(point_a); - end.param_update_default(point_b); - start.param_set_default(); - end.param_set_default(); + start.param_updateDefault(point_a); + end.param_updateDefault(point_b); + start.param_valueFromDefault(); + end.param_valueFromDefault(); } Gtk::Widget *LPETransform2Pts::newWidget() diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index b9fd8908a6d7ee7844e443edea96b8abc7704c46..e5ec33601c412721fd29840c1b48613b97a340a8 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -13,17 +13,17 @@ namespace Inkscape { namespace LivePathEffect { void -VonKochPathParam::param_setup_nodepath(Inkscape::NodePath::Path *np) +VonKochPathParam::param_setupNodepath(Inkscape::NodePath::Path *np) { - PathParam::param_setup_nodepath(np); + PathParam::param_setupNodepath(np); //sp_nodepath_make_straight_path(np); } //FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug. void -VonKochRefPathParam::param_setup_nodepath(Inkscape::NodePath::Path *np) +VonKochRefPathParam::param_setupNodepath(Inkscape::NodePath::Path *np) { - PathParam::param_setup_nodepath(np); + PathParam::param_setupNodepath(np); //sp_nodepath_make_straight_path(np); } bool @@ -63,10 +63,10 @@ LPEVonKoch::LPEVonKoch(LivePathEffectObject *lpeobject) : registerParameter(&maxComplexity); //registerParameter(&draw_boxes) ); apply_to_clippath_and_mask = true; - nbgenerations.param_make_integer(); - nbgenerations.param_set_range(0, Geom::infinity()); - maxComplexity.param_make_integer(); - maxComplexity.param_set_range(0, Geom::infinity()); + nbgenerations.param_makeInteger(); + nbgenerations.param_setRange(0, Geom::infinity()); + maxComplexity.param_makeInteger(); + maxComplexity.param_setRange(0, Geom::infinity()); } LPEVonKoch::~LPEVonKoch() diff --git a/src/live_effects/lpe-vonkoch.h b/src/live_effects/lpe-vonkoch.h index bffbebd544393b7eedbe29fda4903dd9ef260e26..bda4b6c1f74eafed73e450fd37d2a6bf8753f332 100644 --- a/src/live_effects/lpe-vonkoch.h +++ b/src/live_effects/lpe-vonkoch.h @@ -25,9 +25,9 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const gchar * default_value = "M0,0 L1,1"):PathParam(label,tip,key,wr,effect,default_value){} + const gchar * defaultvalue = "M0,0 L1,1"):PathParam(label,tip,key,wr,effect,defaultvalue){} virtual ~VonKochPathParam(){} - virtual void param_setup_nodepath(Inkscape::NodePath::Path *np); + virtual void param_setupNodepath(Inkscape::NodePath::Path *np); }; //FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug. @@ -38,9 +38,9 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const gchar * default_value = "M0,0 L1,1"):PathParam(label,tip,key,wr,effect,default_value){} + const gchar * defaultvalue = "M0,0 L1,1"):PathParam(label,tip,key,wr,effect,defaultvalue){} virtual ~VonKochRefPathParam(){} - virtual void param_setup_nodepath(Inkscape::NodePath::Path *np); + virtual void param_setupNodepath(Inkscape::NodePath::Path *np); virtual bool param_readSVGValue(const gchar * strvalue); }; diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp index 1b8f742da0e26b8ead6eb436269fee8cc4cafc57..e0d3d6e793c67b457d027f88d3f69b7c2c945d33 100644 --- a/src/live_effects/parameter/array.cpp +++ b/src/live_effects/parameter/array.cpp @@ -5,10 +5,7 @@ */ #include "live_effects/parameter/array.h" - -#include "svg/svg.h" -#include "svg/stringstream.h" - +#include "helper-fns.h" #include <2geom/coord.h> #include <2geom/point.h> @@ -18,7 +15,7 @@ namespace LivePathEffect { template <> double -ArrayParam::readsvg(const gchar * str) +ArrayParam::readSVG(const gchar * str) { double newx = Geom::infinity(); sp_svg_number_read_d(str, &newx); @@ -27,7 +24,7 @@ ArrayParam::readsvg(const gchar * str) template <> float -ArrayParam::readsvg(const gchar * str) +ArrayParam::readSVG(const gchar * str) { float newx = Geom::infinity(); sp_svg_number_read_f(str, &newx); @@ -36,7 +33,7 @@ ArrayParam::readsvg(const gchar * str) template <> Geom::Point -ArrayParam::readsvg(const gchar * str) +ArrayParam::readSVG(const gchar * str) { gchar ** strarray = g_strsplit(str, ",", 2); double newx, newy; @@ -49,6 +46,45 @@ ArrayParam::readsvg(const gchar * str) return Geom::Point(Geom::infinity(),Geom::infinity()); } + +template <> +std::vector +ArrayParam >::readsvg(const gchar * str) +{ + std::vector subpath_satellites; + if (!str) { + return subpath_satellites; + } + gchar ** strarray = g_strsplit(str, "@", 0); + gchar ** iter = strarray; + while (*iter != NULL) { + gchar ** strsubarray = g_strsplit(*iter, ",", 8); + if (*strsubarray[7]) {//steps always > 0 + Satellite *satellite = new Satellite(); + satellite->setSatelliteType(g_strstrip(strsubarray[0])); + satellite->is_time = strncmp(strsubarray[1],"1",1) == 0; + satellite->selected = strncmp(strsubarray[2],"1",1) == 0; + satellite->has_mirror = strncmp(strsubarray[3],"1",1) == 0; + satellite->hidden = strncmp(strsubarray[4],"1",1) == 0; + double amount,angle; + float stepsTmp; + sp_svg_number_read_d(strsubarray[5], &amount); + sp_svg_number_read_d(strsubarray[6], &angle); + sp_svg_number_read_f(g_strstrip(strsubarray[7]), &stepsTmp); + unsigned int steps = (unsigned int)stepsTmp; + satellite->amount = amount; + satellite->angle = angle; + satellite->steps = steps; + subpath_satellites.push_back(*satellite); + } + g_strfreev (strsubarray); + iter++; + } + g_strfreev (strarray); + return subpath_satellites; +} + + } /* namespace LivePathEffect */ } /* namespace Inkscape */ diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h index a600f0257351b6e7ea936c01e0624f9dc2a0c5c5..a0d15f36c5121b77fef4d85a6b3a934ebfde1d52 100644 --- a/src/live_effects/parameter/array.h +++ b/src/live_effects/parameter/array.h @@ -15,6 +15,7 @@ #include "live_effects/parameter/parameter.h" +#include "helper/geom-satellite.h" #include "svg/svg.h" #include "svg/stringstream.h" @@ -53,16 +54,16 @@ public: gchar ** strarray = g_strsplit(strvalue, "|", 0); gchar ** iter = strarray; while (*iter != NULL) { - _vector.push_back( readsvg(*iter) ); + _vector.push_back( readSVG(*iter) ); iter++; } g_strfreev (strarray); return true; } - + virtual void param_update_default(const gchar * default_value){}; virtual gchar * param_getSVGValue() const { Inkscape::SVGOStringStream os; - writesvg(os, _vector); + writeSVG(os, _vector); gchar * str = g_strdup(os.str().c_str()); return str; } @@ -71,15 +72,15 @@ public: _vector = new_vector; } - void param_set_default() { + void param_valueFromDefault() { param_setValue( std::vector(_default_size) ); } - void param_set_and_write_new_value(std::vector const &new_vector) { + void param_setAndWriteNewValue(std::vector const &new_vector) { Inkscape::SVGOStringStream os; - writesvg(os, new_vector); + writeSVG(os, new_vector); gchar * str = g_strdup(os.str().c_str()); - param_write_to_repr(str); + param_writeToRepr(str); g_free(str); } @@ -87,17 +88,53 @@ protected: std::vector _vector; size_t _default_size; - void writesvg(SVGOStringStream &str, std::vector const &vector) const { + void writeSVG(SVGOStringStream &str, std::vector const &vector) const { for (unsigned int i = 0; i < vector.size(); ++i) { if (i != 0) { // separate items with pipe symbol str << " | "; } - str << vector[i]; + writesvgData(str,vector[i]); + } + } + + void writesvgData(SVGOStringStream &str, float const &vector_data) const { + str << vector_data; + } + + void writesvgData(SVGOStringStream &str, double const &vector_data) const { + str << vector_data; + } + + void writesvgData(SVGOStringStream &str, Geom::Point const &vector_data) const { + str << vector_data; + } + + void writesvgData(SVGOStringStream &str, std::vector const &vector_data) const { + for (size_t i = 0; i < vector_data.size(); ++i) { + if (i != 0) { + // separate items with @ symbol ¿Any other? + str << " @ "; + } + str << vector_data[i].getSatelliteTypeGchar(); + str << ","; + str << vector_data[i].is_time; + str << ","; + str << vector_data[i].selected; + str << ","; + str << vector_data[i].has_mirror; + str << ","; + str << vector_data[i].hidden; + str << ","; + str << vector_data[i].amount; + str << ","; + str << vector_data[i].angle; + str << ","; + str << vector_data[i].steps; } } - StorageType readsvg(const gchar * str); + StorageType readSVG(const gchar * str); private: ArrayParam(const ArrayParam&); diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index 1bd5f96ad80566fe5733e1ea503b2d62bc5b066d..5058ec096dab2801926981ec2726c261c17271ca 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -21,25 +21,33 @@ namespace LivePathEffect { BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, bool default_value , bool no_widget) - : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value), hide_widget(no_widget) + Effect* effect, bool defaultvalue) + : Parameter(label, tip, key, wr, effect), value(defaultvalue), defvalue(defaultvalue) { } -BoolParam::~BoolParam() +Gtk::Widget * +BoolParam::param_newWidget() { -} + Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( + new Inkscape::UI::Widget::RegisteredCheckButton( param_label, + param_tooltip, + param_key, + *param_wr, + false, + param_effect->getRepr(), + param_effect->getSPDoc()) ); -void -BoolParam::param_set_default() -{ - param_setValue(defvalue); + checkwdg->setActive(value); + checkwdg->setProgrammatically = false; + checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter")); + return dynamic_cast (checkwdg); } void -BoolParam::param_update_default(bool const default_value) +BoolParam::param_update_default(const gchar * default_value) { - defvalue = default_value; + param_update_default(helperfns_read_bool(default_value, defvalue)); } bool @@ -56,31 +64,30 @@ BoolParam::param_getSVGValue() const return str; } -Gtk::Widget * -BoolParam::param_newWidget() +void +BoolParam::param_valueFromDefault() { - if(!hide_widget){ - Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredCheckButton( param_label, - param_tooltip, - param_key, - *param_wr, - false, - param_effect->getRepr(), - param_effect->getSPDoc()) ); - - checkwdg->setActive(value); - checkwdg->setProgrammatically = false; - checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter")); - return dynamic_cast (checkwdg); - } else { - return NULL; - } + param_setValue(defvalue); +} + +void +BoolParam::param_updateDefault(bool const defaultvalue) +{ + defvalue = defaultvalue; +} + +void +BoolParam::param_update_default(const gchar * default_value) +{ + param_update_default(helperfns_read_bool(default_value, defvalue)); } void BoolParam::param_setValue(bool newvalue) { + if (value != newvalue) { + param_effect->upd_params = true; + } value = newvalue; } diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index 7ad8a9368a7b4d8081770f7e9a539e2343f81a27..3908c17f33d07ea62da33afe0a788fee540bcaa1 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -25,21 +25,18 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - bool default_value = false, + bool defaultvalue = false, bool no_widget = false); virtual ~BoolParam(); - virtual Gtk::Widget * param_newWidget(); - virtual bool param_readSVGValue(const gchar * strvalue); - virtual gchar * param_getSVGValue() const; - - void param_setValue(bool newvalue); - virtual void param_set_default(); - void param_update_default(bool const default_value); - bool get_value() const { return value; }; - - inline operator bool() const { return value; }; + virtual bool param_readSVGValue(const gchar * strvalue); + virtual gchar * param_getSVGValue() const; + virtual void param_valueFromDefault(); + virtual void param_updateDefault(bool const defaultvalue); + virtual void param_updateDefault(const gchar * default_value); + void param_setValue(bool newvalue); + bool param_getValue() const { return value; }; private: BoolParam(const BoolParam&); @@ -47,7 +44,6 @@ private: bool value; bool defvalue; - bool hide_widget; }; diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index dbfc6862372a27134caa091e68534136cbee78d4..0cf4edeeba75529e306bee8dbea2c64158f52951 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -27,12 +27,12 @@ public: const Util::EnumDataConverter& c, Inkscape::UI::Widget::Registry* wr, Effect* effect, - E default_value, + E defaultvalue, bool sort = true) : Parameter(label, tip, key, wr, effect) { enumdataconv = &c; - defvalue = default_value; + defvalue = defaultvalue; value = defvalue; sorted = sort; }; @@ -41,8 +41,14 @@ public: virtual Gtk::Widget * param_newWidget() { Inkscape::UI::Widget::RegisteredEnum *regenum = Gtk::manage ( - new Inkscape::UI::Widget::RegisteredEnum( param_label, param_tooltip, - param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc(), sorted ) ); + new Inkscape::UI::Widget::RegisteredEnum(param_label, + param_tooltip, + param_key, + *enumdataconv, + *param_wr, + param_effect->getRepr(), + param_effect->getSPDoc(), + sorted) ); regenum->set_active_by_id(value); regenum->combobox()->setProgrammatically = false; @@ -52,33 +58,40 @@ public: bool param_readSVGValue(const gchar * strvalue) { if (!strvalue) { - param_set_default(); + param_valueFromDefault(); return true; } - - param_set_value( enumdataconv->get_id_from_key(Glib::ustring(strvalue)) ); - + param_setValue( enumdataconv->get_id_from_key(Glib::ustring(strvalue)) ); return true; }; + gchar * param_getSVGValue() const { gchar * str = g_strdup( enumdataconv->get_key(value).c_str() ); return str; }; - E get_value() const { + E param_getValue() const { return value; } - inline operator E() const { - return value; - }; - void param_set_default() { - param_set_value(defvalue); + void param_setValue(E val) { + if (value != val) { + param_effect->upd_params = true; + } + value = val; + } + + void param_valueFromDefault(bool /*write*/) { + param_setValue(defvalue); } - void param_set_value(E val) { - value = val; + virtual void param_updateDefault(E defaultvalue) { + defvalue = defaultvalue; + } + + virtual void param_updateDefault(const gchar * defaultvalue) { + param_updateDefault(enumdataconv->get_id_from_key(Glib::ustring(defaultvalue))); } private: diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp deleted file mode 100644 index 7696288b0d35c475c668e4b7eddf19a2feaa49cb..0000000000000000000000000000000000000000 --- a/src/live_effects/parameter/filletchamferpointarray.cpp +++ /dev/null @@ -1,873 +0,0 @@ -/* - * Copyright (C) Jabiertxo Arraiza Cenoz - * Special thanks to Johan Engelen for the base of the effect -powerstroke- - * Also to ScislaC for point me to the idea - * Also su_v for his construvtive feedback and time - * and finaly to Liam P. White for his big help on coding, that save me a lot of - * hours - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <2geom/piecewise.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/sbasis-geometric.h> -#include <2geom/line.h> -#include <2geom/path-intersection.h> - -#include "ui/dialog/lpe-fillet-chamfer-properties.h" -#include "live_effects/parameter/filletchamferpointarray.h" -#include "live_effects/effect.h" -#include "svg/svg.h" -#include "svg/stringstream.h" -#include "knotholder.h" -#include "sp-lpe-item.h" -#include "selection.h" - -// needed for on-canvas editting: -#include "live_effects/lpeobject.h" -#include "helper/geom-nodetype.h" -#include "helper/geom-curves.h" -#include "ui/tools/node-tool.h" - -// TODO due to internal breakage in glibmm headers, -// this has to be included last. -#include - - -using namespace Geom; - -namespace Inkscape { - -namespace LivePathEffect { - -FilletChamferPointArrayParam::FilletChamferPointArrayParam( - const Glib::ustring &label, const Glib::ustring &tip, - const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, - Effect *effect) - : ArrayParam(label, tip, key, wr, effect, 0) -{ - knot_shape = SP_KNOT_SHAPE_DIAMOND; - knot_mode = SP_KNOT_MODE_XOR; - knot_color = 0x00ff0000; -} - -FilletChamferPointArrayParam::~FilletChamferPointArrayParam() {} - -Gtk::Widget *FilletChamferPointArrayParam::param_newWidget() -{ - return NULL; - /* - Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = - Gtk::manage( - new Inkscape::UI::Widget::RegisteredTransformedPoint( - param_label, - param_tooltip, - param_key, - *param_wr, - param_effect->getRepr(), - param_effect->getSPDoc() - ) ); - // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP) - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - Affine transf = desktop->doc2dt(); - pointwdg->setTransform(transf); - pointwdg->setValue( *this ); - pointwdg->clearProgrammatically(); - pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, - _("Change point parameter")); - - Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() ); - static_cast(hbox)->pack_start(*pointwdg, true, true); - static_cast(hbox)->show_all_children(); - - return dynamic_cast (hbox); - */ -} - -void -FilletChamferPointArrayParam::param_transform_multiply(Affine const &postmul, - bool /*set*/) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - if (prefs->getBool("/options/transform/rectcorners", true) && - _vector[1][X] <= 0) { - std::vector result; - for (std::vector::const_iterator point_it = _vector.begin(); - point_it != _vector.end(); ++point_it) { - Coord A = - (*point_it)[X] * ((postmul.expansionX() + postmul.expansionY()) / 2); - result.push_back(Point(A, (*point_it)[Y])); - } - param_set_and_write_new_value(result); - } - - // param_set_and_write_new_value( (*this) * postmul ); -} - -/** call this method to recalculate the controlpoints such that they stay at the - * same location relative to the new path. Useful after adding/deleting nodes to - * the path.*/ -void FilletChamferPointArrayParam::recalculate_controlpoints_for_new_pwd2( - Piecewise > const &pwd2_in) -{ - if (!last_pwd2.empty()) { - PathVector const pathv = - path_from_piecewise(remove_short_cuts(pwd2_in, 0.1), 0.001); - PathVector last_pathv = - path_from_piecewise(remove_short_cuts(last_pwd2, 0.1), 0.001); - std::vector result; - unsigned long counter = 0; - unsigned long counterPaths = 0; - unsigned long counterCurves = 0; - long offset = 0; - long offsetPaths = 0; - Geom::NodeType nodetype; - for (PathVector::const_iterator path_it = pathv.begin(); - path_it != pathv.end(); ++path_it) { - if (path_it->empty()) { - counterPaths++; - counter++; - continue; - } - 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(); - if (path_it->closed() && path_it->back_closed().isDegenerate()) { - const Curve &closingline = path_it->back_closed(); - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - curve_endit = path_it->end_open(); - } - } - counterCurves = 0; - while (curve_it1 != curve_endit) { - //if start a path get node type - if (counterCurves == 0) { - if (path_it->closed()) { - if (path_it->back_closed().isDegenerate()) { - nodetype = get_nodetype(path_it->back_open(), *curve_it1); - } else { - nodetype = get_nodetype(path_it->back_closed(), *curve_it1); - } - } else { - nodetype = NODE_NONE; - } - } else { - //check node type also whith straight lines because get_nodetype - //return non cusp node in a node inserted inside a straight line - //todo: if the path remove some nodes whith the result of a straight - //line but with handles, the node inserted into dont fire the knot - // because is not handle as cusp node by get_nodetype function - bool next_is_line = is_straight_curve(*curve_it1); - bool this_is_line = is_straight_curve((*path_it)[counterCurves - 1]); - nodetype = get_nodetype((*path_it)[counterCurves - 1], *curve_it1); - if (this_is_line || next_is_line) { - nodetype = NODE_CUSP; - } - } - if (last_pathv.size() > pathv.size() || - (last_pathv.size() > counterPaths && - last_pathv[counterPaths].size() > counter - offset && - !are_near(curve_it1->initialPoint(), - last_pathv[counterPaths][counter - offset].initialPoint(), - 0.1))) { - if ( curve_it2 == curve_endit) { - if (last_pathv[counterPaths].size() != pathv[counterPaths].size()) { - offset = (last_pathv[counterPaths].size() - pathv[counterPaths].size()) * -1; - } else { - offset = 0; - } - offsetPaths += offset; - offset = offsetPaths; - } else if (counterCurves == 0 && last_pathv.size() <= pathv.size() && - counter - offset <= last_pathv[counterPaths].size() && - are_near(curve_it1->initialPoint(), - last_pathv[counterPaths].finalPoint(), 0.1) && - !last_pathv[counterPaths].closed()) { - long e = counter - offset + 1; - std::vector tmp = _vector; - for (unsigned long i = - last_pathv[counterPaths].size() + counter - offset; - i > counterCurves - offset + 1; i--) { - - if (tmp[i - 1][X] > 0) { - double fractpart, intpart; - fractpart = modf(tmp[i - 1][X], &intpart); - _vector[e] = Point(e + fractpart, tmp[i - 1][Y]); - } else { - _vector[e] = Point(tmp[i - 1][X], tmp[i - 1][Y]); - } - e++; - } - //delete temp vector - std::vector().swap(tmp); - if (last_pathv.size() > counterPaths) { - last_pathv[counterPaths] = last_pathv[counterPaths].reversed(); - } - } else { - if (last_pathv.size() > counterPaths) { - if (last_pathv[counterPaths].size() < - pathv[counterPaths].size()) { - offset++; - } else if (last_pathv[counterPaths].size() > - pathv[counterPaths].size()) { - offset--; - continue; - } - } else { - offset++; - } - } - double xPos = 0; - if (_vector[1][X] > 0) { - xPos = nearest_time(curve_it1->initialPoint(), pwd2_in); - } - if (nodetype == NODE_CUSP) { - result.push_back(Point(xPos, 1)); - } else { - result.push_back(Point(xPos, 0)); - } - } else { - double xPos = _vector[counter - offset][X]; - if (_vector.size() <= (unsigned)(counter - offset)) { - if (_vector[1][X] > 0) { - xPos = nearest_time(curve_it1->initialPoint(), pwd2_in); - } else { - xPos = 0; - } - } - if (nodetype == NODE_CUSP) { - double vectorY = _vector[counter - offset][Y]; - if (_vector.size() <= (unsigned)(counter - offset) || vectorY == 0) { - vectorY = 1; - } - result.push_back(Point(xPos, vectorY)); - } else { - if (_vector[1][X] < 0) { - xPos = 0; - } - result.push_back(Point(floor(xPos), 0)); - } - } - ++curve_it1; - if (curve_it2 != curve_endit) { - ++curve_it2; - } - counter++; - counterCurves++; - } - counterPaths++; - } - _vector = result; - write_to_SVG(); - } -} - -void FilletChamferPointArrayParam::recalculate_knots( - Piecewise > const &pwd2_in) -{ - bool change = false; - if(_vector.size() == 0){ - return; - } - PathVector pathv = path_from_piecewise(pwd2_in, 0.001); - if (!pathv.empty()) { - std::vector result; - int counter = 0; - int counterCurves = 0; - Geom::NodeType nodetype; - for (PathVector::const_iterator path_it = pathv.begin(); - path_it != pathv.end(); ++path_it) { - if (path_it->empty()) { - counter++; - continue; - } - 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(); - if (path_it->closed() && path_it->back_closed().isDegenerate()) { - const Curve &closingline = path_it->back_closed(); - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - curve_endit = path_it->end_open(); - } - } - counterCurves = 0; - while (curve_it1 != curve_endit) { - //if start a path get node type - if (counterCurves == 0) { - if (path_it->closed()) { - if (path_it->back_closed().isDegenerate()) { - nodetype = get_nodetype(path_it->back_open(), *curve_it1); - } else { - nodetype = get_nodetype(path_it->back_closed(), *curve_it1); - } - } else { - nodetype = NODE_NONE; - } - } else { - bool next_is_line = is_straight_curve(*curve_it1); - bool this_is_line = is_straight_curve((*path_it)[counterCurves - 1]); - nodetype = get_nodetype((*path_it)[counterCurves - 1], *curve_it1); - if (this_is_line || next_is_line) { - nodetype = NODE_CUSP; - } - } - if (nodetype == NODE_CUSP) { - double vectorY = _vector[counter][Y]; - if (vectorY == 0) { - vectorY = 1; - change = true; - } - result.push_back(Point(_vector[counter][X], vectorY)); - } else { - double xPos = floor(_vector[counter][X]); - if (_vector[1][X] < 0) { - xPos = 0; - } - double vectorY = _vector[counter][Y]; - if (vectorY != 0) { - change = true; - } - result.push_back(Point(xPos, 0)); - } - ++curve_it1; - counter++; - if (curve_it2 != curve_endit) { - ++curve_it2; - } - counterCurves++; - } - } - if (change) { - _vector = result; - write_to_SVG(); - } - } -} - -void FilletChamferPointArrayParam::set_pwd2( - Piecewise > const &pwd2_in, - Piecewise > const &pwd2_normal_in) -{ - last_pwd2 = pwd2_in; - last_pwd2_normal = pwd2_normal_in; -} - -void FilletChamferPointArrayParam::set_helper_size(int hs) -{ - helper_size = hs; -} - -void FilletChamferPointArrayParam::set_chamfer_steps(int value_chamfer_steps) -{ - chamfer_steps = value_chamfer_steps; -} - -void FilletChamferPointArrayParam::set_use_distance(bool use_knot_distance ) -{ - use_distance = use_knot_distance; -} - -void FilletChamferPointArrayParam::updateCanvasIndicators() -{ - std::vector ts = data(); - hp.clear(); - unsigned int i = 0; - for (std::vector::const_iterator point_it = ts.begin(); - point_it != ts.end(); ++point_it) { - double Xvalue = to_time(i, (*point_it)[X]) -i; - if (Xvalue == 0) { - i++; - continue; - } - Geom::Point ptA = last_pwd2[i].valueAt(Xvalue); - Geom::Point derivA = unit_vector(derivative(last_pwd2[i]).valueAt(Xvalue)); - Geom::Rotate rot(Geom::Rotate::from_degrees(-90)); - derivA = derivA * rot; - Geom::Point C = ptA - derivA * helper_size; - Geom::Point D = ptA + derivA * helper_size; - Geom::Ray ray1(C, D); - char const * svgd = "M 1,0.25 0.5,0 1,-0.25 M 1,0.5 0,0 1,-0.5"; - Geom::PathVector pathv = sp_svg_read_pathv(svgd); - Geom::Affine aff = Geom::Affine(); - aff *= Geom::Scale(helper_size); - aff *= Geom::Rotate(ray1.angle() - rad_from_deg(270)); - aff *= Geom::Translate(last_pwd2[i].valueAt(Xvalue)); - pathv *= aff; - hp.push_back(pathv[0]); - hp.push_back(pathv[1]); - i++; - } -} - -void FilletChamferPointArrayParam::addCanvasIndicators( - SPLPEItem const */*lpeitem*/, std::vector &hp_vec) -{ - hp_vec.push_back(hp); -} - -double FilletChamferPointArrayParam::rad_to_len(int index, double rad) -{ - double len = 0; - Geom::PathVector subpaths = path_from_piecewise(last_pwd2, 0.1); - std::pair positions = get_positions(index, subpaths); - D2 A = last_pwd2[last_index(index, subpaths)]; - if(positions.second != 0){ - A = last_pwd2[index-1]; - }else{ - if(!subpaths[positions.first].closed()){ - return len; - } - } - D2 B = last_pwd2[index]; - Piecewise > offset_curve0 = Piecewise >(A)+rot90(unitVector(derivative(A)))*(rad); - Piecewise > offset_curve1 = Piecewise >(B)+rot90(unitVector(derivative(B)))*(rad); - Geom::Path p0 = path_from_piecewise(offset_curve0, 0.1)[0]; - Geom::Path p1 = path_from_piecewise(offset_curve1, 0.1)[0]; - Geom::Crossings cs = Geom::crossings(p0, p1); - if(cs.size() > 0){ - Point cp =p0(cs[0].ta); - double p0pt = nearest_time(cp, B); - len = time_to_len(index,p0pt); - } else { - if(rad < 0){ - len = rad_to_len(index, rad * -1); - } - } - return len; -} - -double FilletChamferPointArrayParam::len_to_rad(int index, double len) -{ - double rad = 0; - double tmp_len = _vector[index][X]; - _vector[index] = Geom::Point(len,_vector[index][Y]); - Geom::PathVector subpaths = path_from_piecewise(last_pwd2, 0.1); - std::pair positions = get_positions(index, subpaths); - Piecewise > u; - u.push_cut(0); - u.push(last_pwd2[last_index(index, subpaths)], 1); - Geom::Curve * A = path_from_piecewise(u, 0.1)[0][0].duplicate(); - Geom::Curve * B = subpaths[positions.first][positions.second].duplicate(); - std::vector times; - if(positions.second != 0){ - A = subpaths[positions.first][positions.second-1].duplicate(); - times = get_times(index-1, subpaths, false); - }else{ - if(!subpaths[positions.first].closed()){ - return rad; - } - times = get_times(last_index(index, subpaths), subpaths, true); - } - _vector[index] = Geom::Point(tmp_len,_vector[index][Y]); - Geom::Point startArcPoint = A->toSBasis().valueAt(times[1]); - Geom::Point endArcPoint = B->toSBasis().valueAt(times[2]); - Curve *knotCurve1 = A->portion(times[0], times[1]); - Curve *knotCurve2 = B->portion(times[2], 1); - Geom::CubicBezier const *cubic1 = dynamic_cast(knotCurve1); - Ray ray1(startArcPoint, A->finalPoint()); - if (cubic1) { - ray1.setPoints((*cubic1)[2], startArcPoint); - } - Geom::CubicBezier const *cubic2 = dynamic_cast(knotCurve2); - Ray ray2(B->initialPoint(), endArcPoint); - if (cubic2) { - ray2.setPoints(endArcPoint, (*cubic2)[1]); - } - bool ccwToggle = cross(A->finalPoint() - startArcPoint, endArcPoint - startArcPoint) > 0; - double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint)); - double angleBetween = angle_between(ray1, ray2, ccwToggle); - rad = distanceArc/sin(angleBetween/2.0); - return rad * -1; -} - -std::vector FilletChamferPointArrayParam::get_times(int index, Geom::PathVector subpaths, bool last) -{ - const double tolerance = 0.001; - const double gapHelper = 0.00001; - std::pair positions = get_positions(index, subpaths); - Curve *curve_it1; - curve_it1 = subpaths[positions.first][positions.second].duplicate(); - Coord it1_length = (*curve_it1).length(tolerance); - double time_it1, time_it2, time_it1_B, intpart; - if (static_cast(_vector.size()) <= index){ - std::vector out; - out.push_back(0); - out.push_back(1); - out.push_back(0); - return out; - } - time_it1 = modf(to_time(index, _vector[index][X]), &intpart); - if (_vector[index][Y] == 0) { - time_it1 = 0; - } - double resultLenght = 0; - if (subpaths[positions.first].closed() && last) { - time_it2 = modf(to_time(index - positions.second , _vector[index - positions.second ][X]), &intpart); - resultLenght = it1_length + to_len(index - positions.second, _vector[index - positions.second ][X]); - } else if (!subpaths[positions.first].closed() && last){ - time_it2 = 0; - resultLenght = 0; - } else { - time_it2 = modf(to_time(index + 1, _vector[index + 1][X]), &intpart); - resultLenght = it1_length + to_len( index + 1, _vector[index + 1][X]); - } - if (resultLenght > 0 && time_it2 != 0) { - time_it1_B = modf(to_time(index, -resultLenght), &intpart); - } else { - if (time_it2 == 0) { - time_it1_B = 1; - } else { - time_it1_B = gapHelper; - } - } - - if ((subpaths[positions.first].closed() && last && _vector[index - positions.second][Y] == 0) || (subpaths[positions.first].size() > positions.second + 1 && _vector[index + 1][Y] == 0)) { - time_it1_B = 1; - time_it2 = 0; - } - if (time_it1_B < time_it1) { - time_it1_B = time_it1 + gapHelper; - } - std::vector out; - out.push_back(time_it1); - out.push_back(time_it1_B); - out.push_back(time_it2); - return out; -} - -std::pair FilletChamferPointArrayParam::get_positions(int index, Geom::PathVector subpaths) -{ - int counter = -1; - std::size_t first = 0; - std::size_t second = 0; - for (PathVector::const_iterator path_it = subpaths.begin(); path_it != subpaths.end(); ++path_it) { - if (path_it->empty()) - continue; - Geom::Path::const_iterator curve_it1 = path_it->begin(); - Geom::Path::const_iterator curve_endit = path_it->end_default(); - if (path_it->closed()) { - 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(); - } - } - first++; - second = 0; - while (curve_it1 != curve_endit) { - counter++; - second++; - if(counter == index){ - break; - } - ++curve_it1; - } - if(counter == index){ - break; - } - } - first--; - second--; - std::pair out(first, second); - return out; -} - -int FilletChamferPointArrayParam::last_index(int index, Geom::PathVector subpaths) -{ - int counter = -1; - bool inSubpath = false; - for (PathVector::const_iterator path_it = subpaths.begin(); path_it != subpaths.end(); ++path_it) { - if (path_it->empty()) - continue; - Geom::Path::const_iterator curve_it1 = path_it->begin(); - Geom::Path::const_iterator curve_endit = path_it->end_default(); - if (path_it->closed()) { - const Geom::Curve &closingline = path_it->back_closed(); - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - curve_endit = path_it->end_open(); - } - } - while (curve_it1 != curve_endit) { - counter++; - if(counter == index){ - inSubpath = true; - } - ++curve_it1; - } - if(inSubpath){ - break; - } - } - if(!inSubpath){ - counter = -1; - } - return counter; -} - - -double FilletChamferPointArrayParam::len_to_time(int index, double len) -{ - double t = 0; - if (last_pwd2.size() > (unsigned) index) { - if (len != 0) { - if (last_pwd2[index][0].degreesOfFreedom() != 2) { - Piecewise > u; - u.push_cut(0); - u.push(last_pwd2[index], 1); - std::vector t_roots = roots(arcLengthSb(u) - std::abs(len)); - if (t_roots.size() > 0) { - t = t_roots[0]; - } - } else { - double lenghtPart = 0; - if (last_pwd2.size() > (unsigned) index) { - lenghtPart = length(last_pwd2[index], EPSILON); - } - if (std::abs(len) < lenghtPart && lenghtPart != 0) { - t = std::abs(len) / lenghtPart; - } - } - } - t = double(index) + t; - } else { - t = double(last_pwd2.size() - 1); - } - - return t; -} - -double FilletChamferPointArrayParam::time_to_len(int index, double time) -{ - double intpart; - double len = 0; - time = modf(time, &intpart); - double lenghtPart = 0; - if (last_pwd2.size() <= (unsigned) index || time == 0) { - return len; - } - if (last_pwd2[index][0].degreesOfFreedom() != 2) { - Piecewise > u; - u.push_cut(0); - u.push(last_pwd2[index], 1); - u = portion(u, 0, time); - return length(u, 0.001) * -1; - } - lenghtPart = length(last_pwd2[index], EPSILON); - return (time * lenghtPart) * -1; -} - -double FilletChamferPointArrayParam::to_time(int index, double A) -{ - if (A > 0) { - return A; - } else { - return len_to_time(index, A); - } -} - -double FilletChamferPointArrayParam::to_len(int index, double A) -{ - if (A > 0) { - return time_to_len(index, A); - } else { - return A; - } -} - -void FilletChamferPointArrayParam::set_oncanvas_looks(SPKnotShapeType shape, - SPKnotModeType mode, - guint32 color) -{ - knot_shape = shape; - knot_mode = mode; - knot_color = color; -} - -FilletChamferPointArrayParamKnotHolderEntity:: -FilletChamferPointArrayParamKnotHolderEntity( - FilletChamferPointArrayParam *p, unsigned int index) - : _pparam(p), _index(index) {} - -void FilletChamferPointArrayParamKnotHolderEntity::knot_set(Point const &p, - Point const &/*origin*/, - guint state) -{ - using namespace Geom; - - if (!valid_index(_index)) { - return; - } - Piecewise > const &pwd2 = _pparam->get_pwd2(); - double t = nearest_time(p, pwd2[_index]); - Geom::Point const s = snap_knot_position(pwd2[_index].valueAt(t), state); - t = nearest_time(s, pwd2[_index]); - if (t == 1) { - t = 0.9999; - } - t += _index; - - if (_pparam->_vector.at(_index)[X] <= 0) { - _pparam->_vector.at(_index) = - Point(_pparam->time_to_len(_index, t), _pparam->_vector.at(_index)[Y]); - } else { - _pparam->_vector.at(_index) = Point(t, _pparam->_vector.at(_index)[Y]); - } - sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); -} - -Point FilletChamferPointArrayParamKnotHolderEntity::knot_get() const -{ - using namespace Geom; - - if (!valid_index(_index)) { - return Point(infinity(), infinity()); - } - - Piecewise > const &pwd2 = _pparam->get_pwd2(); - - double time_it = _pparam->to_time(_index, _pparam->_vector.at(_index)[X]); - Point canvas_point = pwd2.valueAt(time_it); - - _pparam->updateCanvasIndicators(); - return canvas_point; - -} - -void FilletChamferPointArrayParamKnotHolderEntity::knot_click(guint state) -{ - if (state & GDK_CONTROL_MASK) { - if (state & GDK_MOD1_MASK) { - _pparam->_vector.at(_index) = Point(_index, _pparam->_vector.at(_index)[Y]); - _pparam->param_set_and_write_new_value(_pparam->_vector); - sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); - }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 + 3000; - break; - case 3: - type = _pparam->chamfer_steps + 4000; - break; - default: - type = 1; - break; - } - _pparam->_vector.at(_index) = Point(_pparam->_vector.at(_index)[X], (double)type); - _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 >=3000 && type < 4000){ - tip = _("Chamfer: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else if (type >=4000 && type < 5000) { - tip = _("Inverse Chamfer: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else if (type == 2) { - tip = _("Inverse Fillet: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else { - tip = _("Fillet: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } - this->knot->tip = g_strdup(tip); - this->knot->show(); - } - } else if (state & GDK_SHIFT_MASK) { - double xModified = _pparam->_vector.at(_index).x(); - if(xModified < 0 && !_pparam->use_distance){ - xModified = _pparam->len_to_rad(_index, _pparam->_vector.at(_index).x()); - } - Geom::PathVector subpaths = path_from_piecewise(_pparam->last_pwd2, 0.1); - std::pair positions = _pparam->get_positions(_index, subpaths); - D2 A = _pparam->last_pwd2[_pparam->last_index(_index, subpaths)]; - if(positions.second != 0){ - A = _pparam->last_pwd2[_index-1]; - } - D2 B = _pparam->last_pwd2[_index]; - bool aprox = (A[0].degreesOfFreedom() != 2 || B[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false; - Geom::Point offset = Geom::Point(xModified, _pparam->_vector.at(_index).y()); - Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog( - this->desktop, offset, this, _pparam->use_distance, aprox); - } - -} - -void FilletChamferPointArrayParamKnotHolderEntity::knot_set_offset( - Geom::Point offset) -{ - double xModified = offset.x(); - if(xModified < 0 && !_pparam->use_distance){ - xModified = _pparam->rad_to_len(_index, offset.x()); - } - _pparam->_vector.at(_index) = Geom::Point(xModified, offset.y()); - this->parent_holder->knot_ungrabbed_handler(this->knot, 0); -} - -void FilletChamferPointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPItem *item) { - recalculate_knots(get_pwd2()); - for (unsigned int i = 0; i < _vector.size(); ++i) { - if (_vector[i][Y] <= 0) { - continue; - } - const gchar *tip; - if (_vector[i][Y] >=3000 && _vector[i][Y] < 4000){ - tip = _("Chamfer: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else if (_vector[i][Y] >=4000 && _vector[i][Y] < 5000) { - tip = _("Inverse Chamfer: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else if (_vector[i][Y] == 2) { - tip = _("Inverse Fillet: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else { - tip = _("Fillet: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } - FilletChamferPointArrayParamKnotHolderEntity *e = - new FilletChamferPointArrayParamKnotHolderEntity(this, i); - e->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), - knot_shape, knot_mode, knot_color); - knotholder->add(e); - } - updateCanvasIndicators(); -} - -} /* namespace LivePathEffect */ - -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/parameter/filletchamferpointarray.h b/src/live_effects/parameter/filletchamferpointarray.h deleted file mode 100644 index b81339a69c3df37dbf45da04e3f55dba546be360..0000000000000000000000000000000000000000 --- a/src/live_effects/parameter/filletchamferpointarray.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef INKSCAPE_LIVEPATHEFFECT_FILLET_CHAMFER_POINT_ARRAY_H -#define INKSCAPE_LIVEPATHEFFECT_FILLET_CHAMFER_POINT_ARRAY_H - -/* - * Inkscape::LivePathEffectParameters - * Copyright (C) Jabiertxo Arraiza Cenoz - * Special thanks to Johan Engelen for the base of the effect -powerstroke- - * Also to ScislaC for point me to the idea - * Also su_v for his construvtive feedback and time - * and finaly to Liam P. White for his big help on coding, that save me a lot of - * hours - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include <2geom/point.h> - -#include "live_effects/parameter/array.h" - -#include "knot-holder-entity.h" - -namespace Inkscape { - -namespace LivePathEffect { - -class FilletChamferPointArrayParamKnotHolderEntity; - -class FilletChamferPointArrayParam : public ArrayParam { -public: - FilletChamferPointArrayParam(const Glib::ustring &label, - const Glib::ustring &tip, - const Glib::ustring &key, - Inkscape::UI::Widget::Registry *wr, - Effect *effect); - virtual ~FilletChamferPointArrayParam(); - - virtual Gtk::Widget *param_newWidget(); - - virtual void param_transform_multiply(Geom::Affine const &postmul, - bool /*set*/); - - void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, - guint32 color); - virtual double to_time(int index, double A); - virtual double to_len(int index, double A); - virtual double rad_to_len(int index, double rad); - virtual double len_to_rad(int index, double len); - virtual double len_to_time(int index, double len); - virtual double time_to_len(int index, double time); - virtual std::pair get_positions(int index, Geom::PathVector subpaths); - virtual int last_index(int index, Geom::PathVector subpaths); - std::vector get_times(int index, Geom::PathVector subpaths, bool last); - virtual void set_helper_size(int hs); - virtual void set_use_distance(bool use_knot_distance); - virtual void set_chamfer_steps(int value_chamfer_steps); - virtual void addCanvasIndicators(SPLPEItem const *lpeitem, - std::vector &hp_vec); - virtual bool providesKnotHolderEntities() const { - return true; - } - virtual void updateCanvasIndicators(); - virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); - - void set_pwd2(Geom::Piecewise > const &pwd2_in, - Geom::Piecewise > const &pwd2_normal_in); - Geom::Piecewise > const &get_pwd2() const { - return last_pwd2; - } - Geom::Piecewise > const &get_pwd2_normal() const { - return last_pwd2_normal; - } - - void recalculate_controlpoints_for_new_pwd2( - Geom::Piecewise > const &pwd2_in); - void recalculate_knots( - Geom::Piecewise > const &pwd2_in); - friend class FilletChamferPointArrayParamKnotHolderEntity; - -private: - FilletChamferPointArrayParam(const FilletChamferPointArrayParam &); - FilletChamferPointArrayParam &operator=(const FilletChamferPointArrayParam &); - - SPKnotShapeType knot_shape; - SPKnotModeType knot_mode; - guint32 knot_color; - int helper_size; - int chamfer_steps; - bool use_distance; - Geom::PathVector hp; - - Geom::Piecewise > last_pwd2; - Geom::Piecewise > last_pwd2_normal; -}; - -class FilletChamferPointArrayParamKnotHolderEntity : public KnotHolderEntity { -public: - FilletChamferPointArrayParamKnotHolderEntity(FilletChamferPointArrayParam *p, - unsigned int index); - virtual ~FilletChamferPointArrayParamKnotHolderEntity() {} - - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, - guint state); - virtual Geom::Point knot_get() const; - virtual void knot_click(guint state); - virtual void knot_set_offset(Geom::Point offset); - - /*Checks whether the index falls within the size of the parameter's vector*/ - bool valid_index(unsigned int index) const { - return (_pparam->_vector.size() > index); - } - ; - -private: - FilletChamferPointArrayParam *_pparam; - unsigned int _index; -}; - -} //namespace LivePathEffect - -} //namespace Inkscape - -#endif diff --git a/src/live_effects/parameter/fontbutton.cpp b/src/live_effects/parameter/fontbutton.cpp index baf24d77c4839949e4d0c2933f472372c527e9d6..64af2a17bbb874add86a405bbbebcbcc1e7cd37d 100644 --- a/src/live_effects/parameter/fontbutton.cpp +++ b/src/live_effects/parameter/fontbutton.cpp @@ -21,11 +21,10 @@ namespace LivePathEffect { FontButtonParam::FontButtonParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const Glib::ustring default_value ) + Effect* effect, const Glib::ustring defaultvalue ) : Parameter(label, tip, key, wr, effect), - value(default_value), - defvalue(default_value) -{ + value(defaultvalue), + defvalue(defaultvalue) } void @@ -33,9 +32,21 @@ FontButtonParam::param_set_default() { param_setValue(defvalue); } -void -FontButtonParam::param_update_default(const Glib::ustring default_value){ - defvalue = default_value; + +Gtk::Widget * +FontButtonParam::param_newWidget() +{ + Inkscape::UI::Widget::RegisteredFontButton * fontbuttonwdg = Gtk::manage( + new Inkscape::UI::Widget::RegisteredFontButton( param_label, + param_tooltip, + param_key, + *param_wr, + param_effect->getRepr(), + param_effect->getSPDoc() ) ); + Glib::ustring fontspec = param_getSVGValue(); + fontbuttonwdg->setValue( fontspec); + fontbuttonwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font button parameter")); + return dynamic_cast (fontbuttonwdg); } bool @@ -53,28 +64,30 @@ FontButtonParam::param_getSVGValue() const return g_strdup(value.c_str()); } -Gtk::Widget * -FontButtonParam::param_newWidget() +void +FontButtonParam::param_valueFromDefault( bool write ) { - Inkscape::UI::Widget::RegisteredFontButton * fontbuttonwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredFontButton( param_label, - param_tooltip, - param_key, - *param_wr, - param_effect->getRepr(), - param_effect->getSPDoc() ) ); - Glib::ustring fontspec = param_getSVGValue(); - fontbuttonwdg->setValue( fontspec); - fontbuttonwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font button parameter")); - return dynamic_cast (fontbuttonwdg); + param_setValue(defvalue); + if (write) { + param_writeToRepr(defvalue); + } +} + +void +FontButtonParam::param_updateDefault(const Glib::ustring defaultvalue){ + defvalue = defaultvalue; } void FontButtonParam::param_setValue(const Glib::ustring newvalue) { + if (value != newvalue) { + param_effect->upd_params = true; + } value = newvalue; } + } /* namespace LivePathEffect */ } /* namespace Inkscape */ diff --git a/src/live_effects/parameter/fontbutton.h b/src/live_effects/parameter/fontbutton.h index df47251a2aa5d429a6fe0321280e1bce24cefa3f..d3980628d442e389d4a82bfc9cf59c25a55fc8a8 100644 --- a/src/live_effects/parameter/fontbutton.h +++ b/src/live_effects/parameter/fontbutton.h @@ -21,19 +21,17 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const Glib::ustring default_value = ""); - virtual ~FontButtonParam() {} - - virtual Gtk::Widget * param_newWidget(); - virtual bool param_readSVGValue(const gchar * strvalue); - void param_update_default(const Glib::ustring defvalue); - virtual gchar * param_getSVGValue() const; - void param_setValue(const Glib::ustring newvalue); - - virtual void param_set_default(); + const Glib::ustring defaultvalue = "Sans 10"); + virtual ~FontButtonParam() {} - const Glib::ustring get_value() const { return defvalue; }; + virtual Gtk::Widget * param_newWidget(); + virtual bool param_readSVGValue(const gchar * strvalue); + virtual gchar * param_getSVGValue() const; + virtual void param_valueFromDefault(); + virtual void param_updateDefault(const gchar * default_value); + void param_setValue(Glib::ustring newvalue); + const Glib::ustring param_getValue() const { return value; }; private: FontButtonParam(const FontButtonParam&); diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index 93cf2b15f074945f7a06798133aa0ce622e8c573..181daf56db3a3578fed28dad086306e3d8c6c721 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -38,13 +38,13 @@ namespace LivePathEffect { ItemParam::ItemParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const gchar * default_value) + Effect* effect, const gchar * defaultvalue) : Parameter(label, tip, key, wr, effect), changed(true), href(NULL), ref( (SPObject*)effect->getLPEObj() ) { - defvalue = g_strdup(default_value); + defvalue = g_strdup(defaultvalue); ref_changed_connection = ref.changedSignal().connect(sigc::mem_fun(*this, &ItemParam::ref_changed)); } @@ -55,16 +55,23 @@ ItemParam::~ItemParam() } void -ItemParam::param_set_default() +ItemParam::param_valueFromDefault() { param_readSVGValue(defvalue); } +void +ItemParam::param_update_default(const gchar * default_value){ + defvalue = strdup(default_value); +} void -ItemParam::param_set_and_write_default() +ItemParam::param_valueFromDefault(bool write) { - param_write_to_repr(defvalue); + param_setValue(defvalue); + if (write) { + param_writeToRepr(defvalue); + } } bool @@ -227,7 +234,7 @@ ItemParam::on_link_button_click() // check if id really exists in document, or only in clipboard document: if only in clipboard then invalid // check if linking to object to which LPE is applied (maybe delegated to PathReference - param_write_to_repr(itemid.c_str()); + param_writeToRepr(itemid.c_str()); DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Link item parameter to path")); } diff --git a/src/live_effects/parameter/item.h b/src/live_effects/parameter/item.h index 6c719d4510f3717db021b6515fdbe0f6b2c4fcfc..b28b5706e6ace3044b2c5a0e727c7e0773c860c8 100644 --- a/src/live_effects/parameter/item.h +++ b/src/live_effects/parameter/item.h @@ -28,14 +28,18 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const gchar * default_value = ""); + const gchar * defaultvalue = ""); virtual ~ItemParam(); virtual Gtk::Widget * param_newWidget(); - virtual bool param_readSVGValue(const gchar * strvalue); - virtual gchar * param_getSVGValue() const; + virtual bool param_readSVGValue(const gchar * strvalue); + virtual gchar * param_getSVGValue() const; + virtual void param_valueFromDefault( bool write ); - virtual void param_set_default(); + + + virtual void param_setDefault(); + virtual void param_updateDefault(const gchar * default_value); void param_set_and_write_default(); virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector &hp_vec); diff --git a/src/live_effects/parameter/originalpath.h b/src/live_effects/parameter/originalpath.h index b3feec41f4fe1467273f13c9f82a98dc1fa73bad..5a62a3f561485c9441e374a65265005f4a2445a8 100644 --- a/src/live_effects/parameter/originalpath.h +++ b/src/live_effects/parameter/originalpath.h @@ -29,7 +29,7 @@ public: virtual Gtk::Widget * param_newWidget(); /** Disable the canvas indicators of parent class by overriding this method */ - virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; + virtual void param_editOnCanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; /** Disable the canvas indicators of parent class by overriding this method */ virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector & /*hp_vec*/) {}; diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 693821ed25b0564f3c37e3a321e98fe4c6f7f031..3072d075f9b475e1d3fa2661c3c600aceaae53e0 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -124,13 +124,13 @@ void OriginalPathArrayParam::on_reverse_toggled(const Glib::ustring& path) w->reversed = row[_model->_colReverse]; gchar * full = param_getSVGValue(); - param_write_to_repr(full); + param_writeToRepr(full); g_free(full); DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Link path parameter to path")); } -void OriginalPathArrayParam::param_set_default() +void OriginalPathArrayParam::param_valueFromDefault(bool /*write*/) { } @@ -224,7 +224,7 @@ void OriginalPathArrayParam::on_up_button_click() } gchar * full = param_getSVGValue(); - param_write_to_repr(full); + param_writeToRepr(full); g_free(full); DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, @@ -254,7 +254,7 @@ void OriginalPathArrayParam::on_down_button_click() } gchar * full = param_getSVGValue(); - param_write_to_repr(full); + param_writeToRepr(full); g_free(full); DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, @@ -272,7 +272,7 @@ void OriginalPathArrayParam::on_remove_button_click() remove_link(row[_model->_colObject]); gchar * full = param_getSVGValue(); - param_write_to_repr(full); + param_writeToRepr(full); g_free(full); DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, @@ -310,7 +310,7 @@ OriginalPathArrayParam::on_link_button_click() os << pathid.c_str() << ",0"; - param_write_to_repr(os.str().c_str()); + param_writeToRepr(os.str().c_str()); DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Link path parameter to path")); } @@ -345,7 +345,7 @@ void OriginalPathArrayParam::linked_delete(SPObject */*deleted*/, PathAndDirecti //remove_link(to); gchar * full = param_getSVGValue(); - param_write_to_repr(full); + param_writeToRepr(full); g_free(full); } diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h index 296c0f7f77117c64a44ce5956c5bfe0355cbe7ca..9f9fd91b5c6e73e6e4ffd95156b91d6d5e6e859a 100644 --- a/src/live_effects/parameter/originalpatharray.h +++ b/src/live_effects/parameter/originalpatharray.h @@ -61,16 +61,16 @@ public: virtual ~OriginalPathArrayParam(); - virtual Gtk::Widget * param_newWidget(); - virtual bool param_readSVGValue(const gchar * strvalue); - virtual gchar * param_getSVGValue() const; - virtual void param_set_default(); - + virtual Gtk::Widget * param_newWidget(); + virtual bool param_readSVGValue(const gchar * strvalue); + virtual gchar * param_getSVGValue() const; + virtual void param_valueFromDefault(bool write); + virtual void param_update_default(const gchar * default_value){}; + /** Disable the canvas indicators of parent class by overriding this method */ - virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; + virtual void param_editOnCanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; /** Disable the canvas indicators of parent class by overriding this method */ virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector & /*hp_vec*/) {}; - std::vector _vector; protected: diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 26a563909bf5f06187dbdaae909169d1c891b610..e1f48af03517929f4c4a9f6f6d80814ee33ad229 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -37,164 +37,19 @@ Parameter::Parameter( const Glib::ustring& label, const Glib::ustring& tip, } void -Parameter::param_write_to_repr(const char * svgd) +Parameter::param_writeToRepr(const char * svgd) { + param_effect->upd_params = true; param_effect->getRepr()->setAttribute(param_key.c_str(), svgd); } -void Parameter::write_to_SVG(void) +void Parameter::writeToSVG(void) { gchar * str = param_getSVGValue(); - param_write_to_repr(str); + param_writeToRepr(str); g_free(str); } -/*########################################### - * REAL PARAM - */ -ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, - const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, gdouble default_value, bool no_widget) - : Parameter(label, tip, key, wr, effect), - value(default_value), - min(-SCALARPARAM_G_MAXDOUBLE), - max(SCALARPARAM_G_MAXDOUBLE), - integer(false), - defvalue(default_value), - digits(2), - inc_step(0.1), - inc_page(1), - add_slider(false), - overwrite_widget(false), - hide_widget(no_widget) -{ -} - -ScalarParam::~ScalarParam() -{ -} - -bool -ScalarParam::param_readSVGValue(const gchar * strvalue) -{ - double newval; - unsigned int success = sp_svg_number_read_d(strvalue, &newval); - if (success == 1) { - param_set_value(newval); - return true; - } - return false; -} - -gchar * -ScalarParam::param_getSVGValue() const -{ - Inkscape::SVGOStringStream os; - os << value; - gchar * str = g_strdup(os.str().c_str()); - return str; -} - -void -ScalarParam::param_set_default() -{ - param_set_value(defvalue); -} - -void -ScalarParam::param_update_default(gdouble default_value) -{ - defvalue = default_value; -} - -void -ScalarParam::param_set_value(gdouble val) -{ - value = val; - if (integer) - value = round(value); - if (value > max) - value = max; - if (value < min) - value = min; -} - -void -ScalarParam::param_set_range(gdouble min, gdouble max) -{ - // if you look at client code, you'll see that many effects - // has a tendency to set an upper range of Geom::infinity(). - // Once again, in gtk2, this is not a problem. But in gtk3, - // widgets get allocated the amount of size they ask for, - // leading to excessively long widgets. - if (min >= -SCALARPARAM_G_MAXDOUBLE) { - this->min = min; - } else { - this->min = -SCALARPARAM_G_MAXDOUBLE; - } - if (max <= SCALARPARAM_G_MAXDOUBLE) { - this->max = max; - } else { - this->max = SCALARPARAM_G_MAXDOUBLE; - } - param_set_value(value); // reset value to see whether it is in ranges -} - -void -ScalarParam::param_make_integer(bool yes) -{ - integer = yes; - digits = 0; - inc_step = 1; - inc_page = 10; -} - -void -ScalarParam::param_overwrite_widget(bool overwrite_widget) -{ - this->overwrite_widget = overwrite_widget; -} - -Gtk::Widget * -ScalarParam::param_newWidget() -{ - if(!hide_widget){ - Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( - param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); - - rsu->setValue(value); - rsu->setDigits(digits); - rsu->setIncrements(inc_step, inc_page); - rsu->setRange(min, max); - rsu->setProgrammatically = false; - if (add_slider) { - rsu->addSlider(); - } - if(!overwrite_widget){ - rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); - } - return dynamic_cast (rsu); - } else { - return NULL; - } -} - -void -ScalarParam::param_set_digits(unsigned digits) -{ - this->digits = digits; -} - -void -ScalarParam::param_set_increments(double step, double page) -{ - inc_step = step; - inc_page = page; -} - - - - } /* namespace LivePathEffect */ } /* namespace Inkscape */ diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 6cf10710c5cbadb94b19c04439b4c523003e3c04..0da28a1f6a5d74d2d44247d8903bb84bb154fd58 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -14,13 +14,6 @@ #include <2geom/pathvector.h> #include "ui/widget/registered-widget.h" -// In gtk2, this wasn't an issue; we could toss around -// G_MAXDOUBLE and not worry about size allocations. But -// in gtk3, it is an issue: it allocates widget size for the maxmium -// value you pass to it, leading to some insane lengths. -// If you need this to be more, please be conservative about it. -const double SCALARPARAM_G_MAXDOUBLE = 10000000000.0; // TODO fixme: using an arbitrary large number as a magic value seems fragile. - class KnotHolder; class SPLPEItem; class SPDesktop; @@ -55,31 +48,30 @@ public: Effect* effect); virtual ~Parameter() {}; - virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted. - virtual gchar * param_getSVGValue() const = 0; - void write_to_SVG(); - - virtual void param_set_default() = 0; + void writeToSVG(); + virtual Gtk::Widget * param_newWidget() = 0; + // Returns true if new value is valid / accepted. + virtual bool param_readSVGValue(const gchar * strvalue) = 0; + virtual gchar * param_getSVGValue() const = 0; + virtual void param_valueFromDefault(bool write = false) = 0; + virtual void param_updateDefault(bool const defaultvalue) = 0; + virtual void param_updateDefault(const gchar * default_value) = 0; // This creates a new widget (newed with Gtk::manage(new ...);) - virtual Gtk::Widget * param_newWidget() = 0; - - virtual Glib::ustring * param_getTooltip() { return ¶m_tooltip; }; + virtual Glib::ustring * param_getTooltip() { return ¶m_tooltip; }; + virtual void param_transformMultiply(Geom::Affine const& /*postmul*/, bool /*set*/) {}; - // overload these for your particular parameter to make it provide knotholder handles or canvas helperpaths + // Overload these for your particular parameter to make it provide knotholder handles or canvas helperpaths virtual bool providesKnotHolderEntities() const { return false; } virtual void addKnotHolderEntities(KnotHolder */*knotholder*/, SPItem */*item*/) {}; virtual void addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector &/*hp_vec*/) {}; - - virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; - virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {}; - - virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/) {}; + virtual void param_editOnCanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; + virtual void param_setupNodepath(Inkscape::NodePath::Path */*np*/) {}; Glib::ustring param_key; + Glib::ustring param_tooltip; Inkscape::UI::Widget::Registry * param_wr; Glib::ustring param_label; - bool oncanvas_editable; bool widget_is_visible; @@ -87,63 +79,13 @@ protected: Glib::ustring param_tooltip; Effect* param_effect; - - void param_write_to_repr(const char * svgd); + void param_writeToRepr(const char * svgd); private: Parameter(const Parameter&); Parameter& operator=(const Parameter&); }; - -class ScalarParam : public Parameter { -public: - ScalarParam( const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, - Inkscape::UI::Widget::Registry* wr, - Effect* effect, - gdouble default_value = 1.0, - bool no_widget = false); - virtual ~ScalarParam(); - - virtual bool param_readSVGValue(const gchar * strvalue); - virtual gchar * param_getSVGValue() const; - - virtual void param_set_default(); - void param_update_default(gdouble default_value); - void param_set_value(gdouble val); - void param_make_integer(bool yes = true); - void param_set_range(gdouble min, gdouble max); - void param_set_digits(unsigned digits); - void param_set_increments(double step, double page); - void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; }; - double param_get_max() { return max; }; - double param_get_min() { return min; }; - - void param_overwrite_widget(bool overwrite_widget); - virtual Gtk::Widget * param_newWidget(); - - inline operator gdouble() const { return value; }; - -protected: - gdouble value; - gdouble min; - gdouble max; - bool integer; - gdouble defvalue; - unsigned digits; - double inc_step; - double inc_page; - bool add_slider; - bool overwrite_widget; - bool hide_widget; - -private: - ScalarParam(const ScalarParam&); - ScalarParam& operator=(const ScalarParam&); -}; - } //namespace LivePathEffect } //namespace Inkscape diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index dafc6d406e67806908af0dd2d7e8b779990cb5b2..167534e6f893fe010050247326067a0dfec61e3b 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -57,7 +57,7 @@ namespace LivePathEffect { PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const gchar * default_value) + Effect* effect, const gchar * defaultvalue) : Parameter(label, tip, key, wr, effect), changed(true), _pathvector(), @@ -66,7 +66,7 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip, href(NULL), ref( (SPObject*)effect->getLPEObj() ) { - defvalue = g_strdup(default_value); + defvalue = g_strdup(defaultvalue); param_readSVGValue(defvalue); oncanvas_editable = true; @@ -108,15 +108,15 @@ PathParam::get_pwd2() } void -PathParam::param_set_default() +PathParam::param_valueFromDefault() { param_readSVGValue(defvalue); } void -PathParam::param_set_and_write_default() +PathParam::param_valueFromDefault( true ) { - param_write_to_repr(defvalue); + param_writeToRepr(defvalue); } bool @@ -222,7 +222,7 @@ PathParam::param_newWidget() } void -PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt) +PathParam::param_editOnCanvas(SPItem *item, SPDesktop * dt) { SPDocument *document = dt->getDocument(); bool saved = DocumentUndo::getUndoSensitive(document); @@ -244,9 +244,9 @@ PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt) r.item = reinterpret_cast(param_effect->getLPEObj()); r.lpe_key = param_key; Geom::PathVector stored_pv = _pathvector; - param_write_to_repr("M0,0 L1,0"); + param_writeToRepr("M0,0 L1,0"); const char *svgd = sp_svg_write_path(stored_pv); - param_write_to_repr(svgd); + param_writeToRepr(svgd); } else { r.item = ref.getObject(); } @@ -256,7 +256,7 @@ PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt) } void -PathParam::param_setup_nodepath(Inkscape::NodePath::Path *) +PathParam::param_setupNodepath(Inkscape::NodePath::Path *) { // TODO this method should not exist at all! } @@ -271,7 +271,7 @@ PathParam::addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector > const & newpa if (write_to_svg) { gchar * svgd = sp_svg_write_path( _pathvector ); - param_write_to_repr(svgd); + param_writeToRepr(svgd); g_free(svgd); // After the whole "writing to svg avalanche of function calling": force value upon pwd2 and don't recalculate. @@ -320,7 +320,7 @@ PathParam::set_new_value (Geom::PathVector const &newpath, bool write_to_svg) { remove_link(); if (newpath.empty()) { - param_set_and_write_default(); + param_valueFromDefault( true ); return; } else { _pathvector = newpath; @@ -329,7 +329,7 @@ PathParam::set_new_value (Geom::PathVector const &newpath, bool write_to_svg) if (write_to_svg) { gchar * svgd = sp_svg_write_path( _pathvector ); - param_write_to_repr(svgd); + param_writeToRepr(svgd); g_free(svgd); } else { emit_changed(); @@ -439,6 +439,10 @@ PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/) SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG); } +void +PathParam::param_update_default(const gchar * default_value){ + defvalue = strdup(default_value); +} /* CALLBACK FUNCTIONS FOR THE BUTTONS */ void @@ -446,7 +450,7 @@ PathParam::on_edit_button_click() { SPItem * item = SP_ACTIVE_DESKTOP->getSelection()->singleItem(); if (item != NULL) { - param_editOncanvas(item, SP_ACTIVE_DESKTOP); + param_editOnCanvas(item, SP_ACTIVE_DESKTOP); } } @@ -464,7 +468,7 @@ PathParam::paste_param_path(const char *svgd) svgd = sp_svg_write_path( path_clipboard ); } - param_write_to_repr(svgd); + param_writeToRepr(svgd); signal_path_pasted.emit(); } } @@ -506,7 +510,7 @@ PathParam::on_link_button_click() // check if id really exists in document, or only in clipboard document: if only in clipboard then invalid // check if linking to object to which LPE is applied (maybe delegated to PathReference - param_write_to_repr(pathid.c_str()); + param_writeToRepr(pathid.c_str()); DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Link path parameter to path")); } diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index d2dddbe97cc1bdf200976e86fc2fda80ae74c323..49a5fca1f28551e5b84392fd96599ecbe3450a4e 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -28,7 +28,7 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const gchar * default_value = "M0,0 L1,1"); + const gchar * defaultvalue = "M0,0 L1,1"); virtual ~PathParam(); Geom::PathVector const & get_pathvector() const; @@ -39,16 +39,19 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; - virtual void param_set_default(); + + virtual void param_valueFromDefault(); + void param_valueFromDefault( true ); + virtual void param_updateDefault(const gchar * default_value); void param_set_and_write_default(); void set_new_value (Geom::PathVector const &newpath, bool write_to_svg); void set_new_value (Geom::Piecewise > const &newpath, bool write_to_svg); - virtual void param_editOncanvas(SPItem * item, SPDesktop * dt); - virtual void param_setup_nodepath(Inkscape::NodePath::Path *np); + virtual void param_editOnCanvas(SPItem * item, SPDesktop * dt); + virtual void param_setupNodepath(Inkscape::NodePath::Path *np); virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector &hp_vec); - virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); + virtual void param_transformMultiply(Geom::Affine const& /*postmul*/, bool /*set*/); sigc::signal signal_path_pasted; sigc::signal signal_path_changed; diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index 55dc79fe8ed519a090ebe427b505ab010c85308c..5d50bd21c5ceafacfbff30e88306e435316672f3 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -21,10 +21,10 @@ namespace LivePathEffect { PointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const gchar *htip, Geom::Point default_value, + Effect* effect, const gchar *htip, Geom::Point defaultvalue, bool live_update ) : Parameter(label, tip, key, wr, effect), - defvalue(default_value), + defvalue(defaultvalue), liveupdate(live_update), knoth(NULL) { @@ -41,28 +41,41 @@ PointParam::~PointParam() } void -PointParam::param_set_default() +PointParam::param_valueFromDefault() { param_setValue(defvalue,true); } void -PointParam::param_set_liveupdate( bool live_update) +PointParam::param_setLiveupdate( bool live_update) { liveupdate = live_update; } Geom::Point -PointParam::param_get_default() const{ +PointParam::param_getDefault() const{ return defvalue; } void -PointParam::param_update_default(Geom::Point default_point) +PointParam::param_updateDefault(Geom::Point default_point) { defvalue = default_point; } +void +PointParam::param_update_default(const gchar * default_point) +{ + gchar ** strarray = g_strsplit(default_point, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + param_update_default( Geom::Point(newx, newy) ); + } +} + void PointParam::param_setValue(Geom::Point newpoint, bool write) { @@ -71,7 +84,7 @@ PointParam::param_setValue(Geom::Point newpoint, bool write) Inkscape::SVGOStringStream os; os << newpoint; gchar * str = g_strdup(os.str().c_str()); - param_write_to_repr(str); + param_writeToRepr(str); g_free(str); } if(knoth && liveupdate){ @@ -104,7 +117,7 @@ PointParam::param_getSVGValue() const } void -PointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) +PointParam::param_transformMultiply(Geom::Affine const& postmul, bool /*set*/) { param_setValue( (*this) * postmul, true); } @@ -112,7 +125,7 @@ PointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) Gtk::Widget * PointParam::param_newWidget() { - Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage( + pointwdg = Gtk::manage( new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label, param_tooltip, param_key, @@ -133,7 +146,7 @@ PointParam::param_newWidget() } void -PointParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) +PointParam::set_onCanvasLooks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) { knot_shape = shape; knot_mode = mode; @@ -168,7 +181,7 @@ PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &or s = A; } } - pparam->param_setValue(s, this->pparam->liveupdate); + pparam->param_setValue(s); SPLPEItem * splpeitem = dynamic_cast(item); if(splpeitem && this->pparam->liveupdate){ sp_lpe_item_update_patheffect(splpeitem, false, false); @@ -186,7 +199,7 @@ PointParamKnotHolderEntity::knot_click(guint state) { if (state & GDK_CONTROL_MASK) { if (state & GDK_MOD1_MASK) { - this->pparam->param_set_default(); + this->pparam->param_valueFromDefault(); SPLPEItem * splpeitem = dynamic_cast(item); if(splpeitem){ sp_lpe_item_update_patheffect(splpeitem, false, false); diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index 5d145a81aa2d28adff8212b9f0cbbbb7298de5fd..d5d8af24f6732aff9a0cc2404c2232f05a38b6a4 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -30,7 +30,7 @@ public: Inkscape::UI::Widget::Registry* wr, Effect* effect, const gchar *handle_tip = NULL,// tip for automatically associated on-canvas handle - Geom::Point default_value = Geom::Point(0,0), + Geom::Point defaultvalue = Geom::Point(0,0), bool live_update = true ); virtual ~PointParam(); @@ -40,13 +40,15 @@ public: gchar * param_getSVGValue() const; inline const gchar *handleTip() const { return handle_tip ? handle_tip : param_tooltip.c_str(); } void param_setValue(Geom::Point newpoint, bool write = false); - void param_set_default(); - Geom::Point param_get_default() const; - void param_set_liveupdate(bool live_update); - void param_update_default(Geom::Point default_point); - virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); + void param_setDefault(); + Geom::Point param_getDefault() const; + void param_setLiveupdate(bool live_update); + void param_updateDefault(Geom::Point default_point); - void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); + virtual void param_updateDefault(const gchar * default_point); + virtual void param_transformMultiply(Geom::Affine const& /*postmul*/, bool /*set*/); + + void set_onCanvasLooks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 7753d819d47b5ff512b04db4a88a89b6870c53de..e14cdc774bc4127737b7c576d43b61c2930dbb43 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -42,7 +42,7 @@ PowerStrokePointArrayParam::param_newWidget() return NULL; } -void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const &postmul, bool /*set*/) +void PowerStrokePointArrayParam::param_transformMultiply(Geom::Affine const &postmul, bool /*set*/) { // Check if proportional stroke-width scaling is on Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -57,7 +57,7 @@ void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const &po Geom::Coord const A = (*point_it)[Geom::Y] * ((postmul.expansionX() + postmul.expansionY()) / 2); result.push_back(Geom::Point((*point_it)[Geom::X], A)); } - param_set_and_write_new_value(result); + param_setAndWriteNewValue(result); } } @@ -85,7 +85,7 @@ PowerStrokePointArrayParam::recalculate_controlpoints_for_new_pwd2(Geom::Piecewi } } - write_to_SVG(); + writeToSVG(); } } @@ -115,7 +115,7 @@ PowerStrokePointArrayParam::set_pwd2(Geom::Piecewise > co void -PowerStrokePointArrayParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) +PowerStrokePointArrayParam::set_onCanvasLooks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) { knot_shape = shape; knot_mode = mode; @@ -202,7 +202,7 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) // delete the clicked knot std::vector & vec = _pparam->_vector; vec.erase(vec.begin() + _index); - _pparam->param_set_and_write_new_value(vec); + _pparam->param_setAndWriteNewValue(vec); // remove knot from knotholder parent_holder->entity.remove(this); @@ -222,7 +222,7 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) // add a knot to XML std::vector & vec = _pparam->_vector; vec.insert(vec.begin() + _index, 1, vec.at(_index)); // this clicked knot is duplicated - _pparam->param_set_and_write_new_value(vec); + _pparam->param_setAndWriteNewValue(vec); // shift knots up one index for(std::list::iterator ent = parent_holder->entity.begin(); ent != parent_holder->entity.end(); ++ent) { diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h index 56a609fa87d43cc3e3285477087f7ef3f0f6031f..433a050ff3e351f4d1e5d41830786b84cbc38b40 100644 --- a/src/live_effects/parameter/powerstrokepointarray.h +++ b/src/live_effects/parameter/powerstrokepointarray.h @@ -31,21 +31,21 @@ public: virtual Gtk::Widget * param_newWidget(); - virtual void param_transform_multiply(Geom::Affine const& postmul, bool /*set*/); + virtual void param_transformMultiply(Geom::Affine const& postmul, bool /*set*/); - void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); + void set_onCanvasLooks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); float median_width(); virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); + virtual void param_update_default(const gchar * default_value){}; void set_pwd2(Geom::Piecewise > const & pwd2_in, Geom::Piecewise > const & pwd2_normal_in); Geom::Piecewise > const & get_pwd2() const { return last_pwd2; } Geom::Piecewise > const & get_pwd2_normal() const { return last_pwd2_normal; } void recalculate_controlpoints_for_new_pwd2(Geom::Piecewise > const & pwd2_in); - friend class PowerStrokePointArrayParamKnotHolderEntity; private: diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index 075e85ee1d67de35abf46f3d1d8260dc101cf40d..b48d50a410b71213085a87a54451ef2491ab5155 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -24,10 +24,10 @@ namespace LivePathEffect { RandomParam::RandomParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, gdouble default_value, long default_seed) + Effect* effect, gdouble defaultvalue, long default_seed) : Parameter(label, tip, key, wr, effect) { - defvalue = default_value; + defvalue = defaultvalue; value = defvalue; min = -Geom::infinity(); max = Geom::infinity(); @@ -51,9 +51,9 @@ RandomParam::param_readSVGValue(const gchar * strvalue) if (success == 1) { success += sp_svg_number_read_d(stringarray[1], &newstartseed); if (success == 2) { - param_set_value(newval, static_cast(newstartseed)); + param_setValue(newval, static_cast(newstartseed)); } else { - param_set_value(newval, defseed); + param_setValue(newval, defseed); } g_strfreev(stringarray); return true; @@ -72,14 +72,15 @@ RandomParam::param_getSVGValue() const } void -RandomParam::param_set_default() +RandomParam::param_valueFromDefault() { - param_set_value(defvalue, defseed); + param_setValue(defvalue, defseed); } void RandomParam::param_set_value(gdouble val, long newseed) { + param_effect->upd_params = true; value = val; if (integer) value = round(value); @@ -93,14 +94,14 @@ RandomParam::param_set_value(gdouble val, long newseed) } void -RandomParam::param_set_range(gdouble min, gdouble max) +RandomParam::param_setRange(gdouble min, gdouble max) { this->min = min; this->max = max; } void -RandomParam::param_make_integer(bool yes) +RandomParam::param_makeInteger(bool yes) { integer = yes; } diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h index ca4440336ec8ed8a908bf066f87225049b6ff976..69854e0fb420ab9952dd4c8eb688fdc3d5808a0d 100644 --- a/src/live_effects/parameter/random.h +++ b/src/live_effects/parameter/random.h @@ -25,22 +25,23 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - gdouble default_value = 1.0, + gdouble defaultvalue = 1.0, long default_seed = 0); virtual ~RandomParam(); virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; - virtual void param_set_default(); + virtual void param_valueFromDefault(); virtual Gtk::Widget * param_newWidget(); - void param_set_value(gdouble val, long newseed); - void param_make_integer(bool yes = true); - void param_set_range(gdouble min, gdouble max); + void param_setValue(gdouble val, long newseed); + void param_makeInteger(bool yes = true); + void param_setRange(gdouble min, gdouble max); - void resetRandomizer(); + virtual void param_update_default(const gchar * default_value); + void resetRandomizer(); operator gdouble(); inline gdouble get_value() { return value; } ; diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7626317a170c0183b1859d7abe9e2f2f89a0a591 --- /dev/null +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -0,0 +1,583 @@ +/* + * Author(s): + * Jabiertxo Arraiza Cenoz + * + * Copyright (C) 2014 Author(s) + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "knotholder.h" +#include "ui/dialog/lpe-fillet-chamfer-properties.h" +#include "live_effects/parameter/satellitesarray.h" +#include "live_effects/effect.h" +#include "sp-lpe-item.h" +#include "inkscape.h" +#include +// TODO due to internal breakage in glibmm headers, +// this has to be included last. +#include + +namespace Inkscape { + +namespace LivePathEffect { + +SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, + const Glib::ustring &tip, + const Glib::ustring &key, + Inkscape::UI::Widget::Registry *wr, + Effect *effect) + : ArrayParam >(label, tip, key, wr, effect, 0), _knoth(NULL) +{ + _knot_shape = SP_KNOT_SHAPE_DIAMOND; + _knot_mode = SP_KNOT_MODE_XOR; + _knot_color = 0xAAFF8800; + _helper_size = 0; + _use_distance = false; + _global_knot_hide = false; + _current_zoom = 0; + _effectType = FILLET_CHAMFER; + _last_pathvector_satellites = NULL; +} + + +void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, + SPKnotModeType mode, + guint32 color) +{ + _knot_shape = shape; + _knot_mode = mode; + _knot_color = color; +} + +void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write) +{ + _last_pathvector_satellites = pathVectorSatellites; + if (write) { + param_set_and_write_new_value(_last_pathvector_satellites->getSatellites()); + } else { + param_setValue(_last_pathvector_satellites->getSatellites()); + } +} + +void SatellitesArrayParam::setUseDistance(bool use_knot_distance) +{ + _use_distance = use_knot_distance; +} + +void SatellitesArrayParam::setCurrentZoom(double current_zoom) +{ + _current_zoom = current_zoom; +} + +void SatellitesArrayParam::setGlobalKnotHide(bool global_knot_hide) +{ + _global_knot_hide = global_knot_hide; +} +void SatellitesArrayParam::setEffectType(EffectType et) +{ + _effectType = et; +} + +void SatellitesArrayParam::setHelperSize(int hs) +{ + _helper_size = hs; + updateCanvasIndicators(); +} + +void SatellitesArrayParam::updateCanvasIndicators(bool mirror) +{ + if (!_last_pathvector_satellites) { + return; + } + + if (!_hp.empty()) { + _hp.clear(); + } + Geom::PathVector pathv = _last_pathvector_satellites->getPathVector(); + if (pathv.empty()) { + return; + } + if (mirror == true) { + _hp.clear(); + } + if (_effectType == FILLET_CHAMFER) { + for (size_t i = 0; i < _vector.size(); ++i) { + for (size_t j = 0; j < _vector[i].size(); ++j) { + if (_vector[i][j].hidden || //Ignore if hidden + (!_vector[i][j].has_mirror && mirror == true) || //Ignore if not have mirror and we are in mirror loop + _vector[i][j].amount == 0 || //no helper in 0 value + pathv[i].size() == j || //ignore last satellite in open paths with fillet chamfer effect + (!pathv[i].closed() && j == 0)) //ignore first satellites on open paths + { + continue; + } + Geom::Curve *curve_in = pathv[i][j].duplicate(); + double pos = 0; + bool overflow = false; + double size_out = _vector[i][j].arcDistance(*curve_in); + double lenght_out = curve_in->length(); + gint previous_index = j - 1; //Always are previous index because we skip first satellite on open paths + if (j == 0 && pathv[i].closed()) { + previous_index = pathv[i].size() - 1; + } + if ( previous_index < 0 ) { + return; + } + double lenght_in = pathv.curveAt(previous_index).length(); + if (mirror) { + curve_in = const_cast(&pathv.curveAt(previous_index)); + pos = _vector[i][j].time(size_out, true, *curve_in); + if (lenght_out < size_out) { + overflow = true; + } + } else { + pos = _vector[i][j].time(*curve_in); + if (lenght_in < size_out) { + overflow = true; + } + } + if (pos <= 0 || pos >= 1) { + continue; + } + Geom::Point point_a = curve_in->pointAt(pos); + Geom::Point deriv_a = unit_vector(derivative(curve_in->toSBasis()).pointAt(pos)); + Geom::Rotate rot(Geom::Rotate::from_degrees(-90)); + deriv_a = deriv_a * rot; + Geom::Point point_c = point_a - deriv_a * _helper_size; + Geom::Point point_d = point_a + deriv_a * _helper_size; + Geom::Ray ray_1(point_c, point_d); + char const *svgd = "M 1,0.25 0.5,0 1,-0.25 M 1,0.5 0,0 1,-0.5"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + Geom::Affine aff = Geom::Affine(); + aff *= Geom::Scale(_helper_size); + if (mirror) { + aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(90)); + } else { + aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(270)); + } + aff *= Geom::Translate(curve_in->pointAt(pos)); + pathv *= aff; + _hp.push_back(pathv[0]); + _hp.push_back(pathv[1]); + if (overflow) { + double diameter = _helper_size; + if (_helper_size == 0) { + diameter = 15; + char const *svgd; + svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 " + "0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + aff = Geom::Affine(); + aff *= Geom::Scale(diameter); + aff *= Geom::Translate(point_a - Geom::Point(diameter * 0.35, diameter * 0.35)); + pathv *= aff; + _hp.push_back(pathv[0]); + } else { + char const *svgd; + svgd = "M 0 -1.32 A 1.32 1.32 0 0 0 -1.32 0 A 1.32 1.32 0 0 0 0 1.32 A " + "1.32 1.32 0 0 0 1.18 0.59 L 0 0 L 1.18 -0.59 A 1.32 1.32 0 0 0 " + "0 -1.32 z"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + aff = Geom::Affine(); + aff *= Geom::Scale(_helper_size / 2.0); + if (mirror) { + aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(90)); + } else { + aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(270)); + } + aff *= Geom::Translate(curve_in->pointAt(pos)); + pathv *= aff; + _hp.push_back(pathv[0]); + } + } + } + } + } + if (!_knot_reset_helper.empty()) { + _hp.insert(_hp.end(), _knot_reset_helper.begin(), _knot_reset_helper.end() ); + } + if (mirror) { + updateCanvasIndicators(false); + } +} +void SatellitesArrayParam::updateCanvasIndicators() +{ + updateCanvasIndicators(true); +} + +void SatellitesArrayParam::addCanvasIndicators( + SPLPEItem const */*lpeitem*/, std::vector &hp_vec) +{ + hp_vec.push_back(_hp); +} + +void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, bool /*set*/) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + if (prefs->getBool("/options/transform/rectcorners", true)) { + for (size_t i = 0; i < _vector.size(); ++i) { + for (size_t j = 0; j < _vector[i].size(); ++j) { + if (!_vector[i][j].is_time && _vector[i][j].amount > 0) { + _vector[i][j].amount = _vector[i][j].amount * ((postmul.expansionX() + postmul.expansionY()) / 2); + } + } + } + param_set_and_write_new_value(_vector); + } +} + +void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, + SPItem *item, + bool mirror) +{ + if (!_last_pathvector_satellites) { + return; + } + Geom::PathVector pathv = _last_pathvector_satellites->getPathVector(); + size_t index = 0; + for (size_t i = 0; i < _vector.size(); ++i) { + for (size_t j = 0; j < _vector[i].size(); ++j) { + if (!_vector[i][j].has_mirror && mirror) { + continue; + } + SatelliteType type = _vector[i][j].satellite_type; + if (mirror && i == 0 && j == 0) { + index = index + _last_pathvector_satellites->getTotalSatellites(); + } + using namespace Geom; + //If is for filletChamfer effect... + if (_effectType == FILLET_CHAMFER) { + const gchar *tip; + if (type == CHAMFER) { + tip = _("Chamfer: Ctrl+Click toggles type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == INVERSE_CHAMFER) { + tip = _("Inverse Chamfer: Ctrl+Click toggles type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == INVERSE_FILLET) { + tip = _("Inverse Fillet: Ctrl+Click toggles type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else { + tip = _("Fillet: Ctrl+Click toggles type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } + FilletChamferKnotHolderEntity *e = new FilletChamferKnotHolderEntity(this, index); + e->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),_knot_shape, _knot_mode, _knot_color); + knotholder->add(e); + } + index++; + } + } + if (mirror) { + addKnotHolderEntities(knotholder, item, false); + } +} + +void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, + SPItem *item) +{ + _knoth = knotholder; + addKnotHolderEntities(knotholder, item, true); +} + +FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity( + SatellitesArrayParam *p, size_t index) + : _pparam(p), _index(index) {} + +void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, + Geom::Point const &/*origin*/, + guint state) +{ + if (!_pparam->_last_pathvector_satellites) { + return; + } + size_t total_satellites = _pparam->_last_pathvector_satellites->getTotalSatellites(); + bool is_mirror = false; + size_t index = _index; + if (_index >= total_satellites) { + index = _index - total_satellites; + is_mirror = true; + } + std::pair index_data = _pparam->_last_pathvector_satellites->getIndexData(index); + size_t path_index = index_data.first; + size_t curve_index = index_data.second; + + Geom::Point s = snap_knot_position(p, state); + if (!valid_index(path_index, curve_index)) { + return; + } + Satellite satellite = _pparam->_vector[path_index][curve_index]; + Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector(); + if (satellite.hidden || + (!pathv[path_index].closed() && curve_index == 0) ||//ignore first satellites on open paths + pathv[path_index].size() == curve_index) //ignore last satellite in open paths with fillet chamfer effect + { + return; + } + gint previous_index = curve_index - 1; + if (curve_index == 0 && pathv[path_index].closed()) { + previous_index = pathv[path_index].size() - 1; + } + if ( previous_index < 0 ) { + return; + } + Geom::Curve const &curve_in = pathv[path_index][previous_index]; + double mirror_time = Geom::nearest_time(s, curve_in); + Geom::Point mirror = curve_in.pointAt(mirror_time); + double normal_time = Geom::nearest_time(s, pathv[path_index][curve_index]); + Geom::Point normal = pathv[path_index][curve_index].pointAt(normal_time); + double distance_mirror = Geom::distance(mirror,s); + double distance_normal = Geom::distance(normal,s); + if (Geom::are_near(s, pathv[path_index][curve_index].initialPoint(), 1.5 / _pparam->_current_zoom)) { + satellite.amount = 0; + } else if (distance_mirror < distance_normal) { + double time_start = 0; + Satellites satellites = _pparam->_last_pathvector_satellites->getSatellites(); + time_start = satellites[path_index][previous_index].time(curve_in); + if (time_start > mirror_time) { + mirror_time = time_start; + } + double size = arcLengthAt(mirror_time, curve_in); + double amount = curve_in.length() - size; + if (satellite.is_time) { + amount = timeAtArcLength(amount, pathv[path_index][curve_index]); + } + satellite.amount = amount; + } else { + satellite.setPosition(s, pathv[path_index][curve_index]); + } + _pparam->_knot_reset_helper.clear(); + if (satellite.amount == 0) { + char const *svgd; + svgd = "M -5.39,8.78 -9.13,5.29 -10.38,10.28 Z M -7.22,7.07 -3.43,3.37 m -1.95,-12.16 -3.74,3.5 -1.26,-5 z " + "m -1.83,1.71 3.78,3.7 M 5.24,8.78 8.98,5.29 10.24,10.28 Z " + "M 7.07,7.07 3.29,3.37 M 5.24,-8.78 l 3.74,3.5 1.26,-5 z M 7.07,-7.07 3.29,-3.37"; + _pparam->_knot_reset_helper = sp_svg_read_pathv(svgd); + _pparam->_knot_reset_helper *= Geom::Affine(_pparam->_helper_size * 0.1,0,0,_pparam->_helper_size * 0.1,0,0) * Geom::Translate(pathv[path_index][curve_index].initialPoint()); + } + _pparam->_vector[path_index][curve_index] = satellite; + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); +} + +Geom::Point FilletChamferKnotHolderEntity::knot_get() const +{ + if (!_pparam->_last_pathvector_satellites || _pparam->_global_knot_hide) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + Geom::Point tmp_point; + size_t total_satellites = _pparam->_last_pathvector_satellites->getTotalSatellites(); + bool is_mirror = false; + size_t index = _index; + if (_index >= total_satellites) { + index = _index - total_satellites; + is_mirror = true; + } + std::pair index_data = _pparam->_last_pathvector_satellites->getIndexData(index); + size_t path_index = index_data.first; + size_t curve_index = index_data.second; + if (!valid_index(path_index, curve_index)) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + Satellite satellite = _pparam->_vector[path_index][curve_index]; + Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector(); + if (satellite.hidden || + (!pathv[path_index].closed() && curve_index == 0) ||//ignore first satellites on open paths + pathv[path_index].size() == curve_index) //ignore last satellite in open paths with fillet chamfer effect + { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + this->knot->show(); + if (is_mirror) { + gint previous_index = curve_index - 1; + if (curve_index == 0 && pathv[path_index].closed()) { + previous_index = pathv[path_index].size() - 1; + } + if ( previous_index < 0 ) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + Geom::Curve const &curve_in = pathv[path_index][previous_index]; + double s = satellite.arcDistance(pathv[path_index][curve_index]); + double t = satellite.time(s, true, curve_in); + if (t > 1) { + t = 1; + } + if (t < 0) { + t = 0; + } + double time_start = 0; + time_start = _pparam->_last_pathvector_satellites->getSatellites()[path_index][previous_index].time(curve_in); + if (time_start > t) { + t = time_start; + } + tmp_point = (curve_in).pointAt(t); + } else { + tmp_point = satellite.getPosition(pathv[path_index][curve_index]); + } + Geom::Point const canvas_point = tmp_point; + _pparam->updateCanvasIndicators(); + return canvas_point; +} + +void FilletChamferKnotHolderEntity::knot_click(guint state) +{ + if (!_pparam->_last_pathvector_satellites) { + return; + } + size_t total_satellites = _pparam->_last_pathvector_satellites->getTotalSatellites(); + bool is_mirror = false; + size_t index = _index; + if (_index >= total_satellites) { + index = _index - total_satellites; + is_mirror = true; + } + std::pair index_data = _pparam->_last_pathvector_satellites->getIndexData(index); + size_t path_index = index_data.first; + size_t curve_index = index_data.second; + if (!valid_index(path_index, curve_index)) { + return; + } + Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector(); + if ((!pathv[path_index].closed() && curve_index == 0) ||//ignore first satellites on open paths + pathv[path_index].size() == curve_index) //ignore last satellite in open paths with fillet chamfer effect + { + return; + } + if (state & GDK_CONTROL_MASK) { + if (state & GDK_MOD1_MASK) { + _pparam->_vector[path_index][curve_index].amount = 0.0; + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); + } else { + using namespace Geom; + SatelliteType type = _pparam->_vector[path_index][curve_index].satellite_type; + switch (type) { + case FILLET: + type = INVERSE_FILLET; + break; + case INVERSE_FILLET: + type = CHAMFER; + break; + case CHAMFER: + type = INVERSE_CHAMFER; + break; + default: + type = FILLET; + break; + } + _pparam->_vector[path_index][curve_index].satellite_type = type; + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); + const gchar *tip; + if (type == CHAMFER) { + tip = _("Chamfer: Ctrl+Click toggles type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click resets"); + } else if (type == INVERSE_CHAMFER) { + tip = _("Inverse Chamfer: Ctrl+Click toggles type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click resets"); + } else if (type == INVERSE_FILLET) { + tip = _("Inverse Fillet: Ctrl+Click toggles type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click resets"); + } else { + tip = _("Fillet: Ctrl+Click toggles type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click resets"); + } + this->knot->tip = g_strdup(tip); + this->knot->show(); + } + } else if (state & GDK_SHIFT_MASK) { + double amount = _pparam->_vector[path_index][curve_index].amount; + gint previous_index = curve_index - 1; + if (curve_index == 0 && pathv[path_index].closed()) { + previous_index = pathv[path_index].size() - 1; + } + if ( previous_index < 0 ) { + return; + } + if (!_pparam->_use_distance && !_pparam->_vector[path_index][curve_index].is_time) { + amount = _pparam->_vector[path_index][curve_index].lenToRad(amount, pathv[path_index][previous_index], pathv[path_index][curve_index], _pparam->_vector[path_index][previous_index]); + } + bool aprox = false; + Geom::D2 d2_out = pathv[path_index][curve_index].toSBasis(); + Geom::D2 d2_in = pathv[path_index][previous_index].toSBasis(); + aprox = ((d2_in)[0].degreesOfFreedom() != 2 || + d2_out[0].degreesOfFreedom() != 2) && + !_pparam->_use_distance + ? true + : false; + Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog( + this->desktop, amount, this, _pparam->_use_distance, + aprox, _pparam->_vector[path_index][curve_index]); + + } +} + +void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) +{ + if (!_pparam->_last_pathvector_satellites) { + return; + } + size_t total_satellites = _pparam->_last_pathvector_satellites->getTotalSatellites(); + bool is_mirror = false; + size_t index = _index; + if (_index >= total_satellites) { + index = _index - total_satellites; + is_mirror = true; + } + std::pair index_data = _pparam->_last_pathvector_satellites->getIndexData(index); + size_t path_index = index_data.first; + size_t curve_index = index_data.second; + if (!valid_index(path_index, curve_index)) { + return; + } + Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector(); + if (satellite.hidden || + (!pathv[path_index].closed() && curve_index == 0) ||//ignore first satellites on open paths + pathv[path_index].size() == curve_index) //ignore last satellite in open paths with fillet chamfer effect + { + return; + } + double amount = satellite.amount; + double max_amount = amount; + if (!_pparam->_use_distance && !satellite.is_time) { + gint previous_index = curve_index - 1; + if (curve_index == 0 && pathv[path_index].closed()) { + previous_index = pathv[path_index].size() - 1; + } + if ( previous_index < 0 ) { + return; + } + amount = _pparam->_vector[path_index][curve_index].radToLen(amount, pathv[path_index][previous_index], pathv[path_index][curve_index]); + if (max_amount > 0 && amount == 0) { + amount = _pparam->_vector[path_index][curve_index].amount; + } + } + satellite.amount = amount; + _pparam->_vector[path_index][curve_index] = satellite; + this->parent_holder->knot_ungrabbed_handler(this->knot, 0); + SPLPEItem *splpeitem = dynamic_cast(item); + if (splpeitem) { + sp_lpe_item_update_patheffect(splpeitem, false, false); + } +} + +} /* namespace LivePathEffect */ + +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h new file mode 100644 index 0000000000000000000000000000000000000000..5ae372ac2bdce90c742de728f62734e73c3bf55c --- /dev/null +++ b/src/live_effects/parameter/satellitesarray.h @@ -0,0 +1,114 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_SATELLITES_ARRAY_H +#define INKSCAPE_LIVEPATHEFFECT_SATELLITES_ARRAY_H + +/* + * Inkscape::LivePathEffectParameters + * Copyright (C) Jabiertxo Arraiza Cenoz + * Special thanks to Johan Engelen for the base of the effect -powerstroke- + * Also to ScislaC for point me to the idea + * Also su_v for his construvtive feedback and time + * To Nathan Hurst for his review and help on refactor + * and finaly to Liam P. White for his big help on coding, that save me a lot of + * hours + * + * + * This parameter act as bridge from pathVectorSatellites class to serialize it as a LPE + * parameter + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/parameter/array.h" +#include "live_effects/effect-enum.h" +#include "helper/geom-pathvectorsatellites.h" +#include "knot-holder-entity.h" +#include + +namespace Inkscape { + +namespace LivePathEffect { + +class FilletChamferKnotHolderEntity; + +class SatellitesArrayParam : public ArrayParam > { +public: + SatellitesArrayParam(const Glib::ustring &label, const Glib::ustring &tip, + const Glib::ustring &key, + Inkscape::UI::Widget::Registry *wr, Effect *effect); + + virtual Gtk::Widget *param_newWidget() + { + return NULL; + } + virtual void setHelperSize(int hs); + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item, bool mirror); + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); + virtual void updateCanvasIndicators(); + virtual void updateCanvasIndicators(bool mirror); + virtual bool providesKnotHolderEntities() const + { + return true; + } + void param_transform_multiply(Geom::Affine const &postmul, bool /*set*/); + void setUseDistance(bool use_knot_distance); + void setCurrentZoom(double current_zoom); + void setGlobalKnotHide(bool global_knot_hide); + void setEffectType(EffectType et); + void setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write = true); + void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); + + friend class FilletChamferKnotHolderEntity; + friend class LPEFilletChamfer; + +protected: + KnotHolder *_knoth; + +private: + SatellitesArrayParam(const SatellitesArrayParam &); + SatellitesArrayParam &operator=(const SatellitesArrayParam &); + + SPKnotShapeType _knot_shape; + SPKnotModeType _knot_mode; + guint32 _knot_color; + Geom::PathVector _hp; + Geom::PathVector _knot_reset_helper; + int _helper_size; + bool _use_distance; + bool _global_knot_hide; + double _current_zoom; + EffectType _effectType; + PathVectorSatellites *_last_pathvector_satellites; + +}; + +class FilletChamferKnotHolderEntity : public KnotHolderEntity { +public: + FilletChamferKnotHolderEntity(SatellitesArrayParam *p, size_t index); + virtual ~FilletChamferKnotHolderEntity() + { + _pparam->_knoth = NULL; + } + + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, + guint state); + virtual Geom::Point knot_get() const; + virtual void knot_click(guint state); + void knot_set_offset(Satellite); + /** Checks whether the index falls within the size of the parameter's vector + */ + bool valid_index(size_t index,size_t subindex) const + { + return (_pparam->_vector.size() > index && _pparam->_vector[index].size() > subindex); + }; + +private: + SatellitesArrayParam *_pparam; + size_t _index; +}; + +} //namespace LivePathEffect + +} //namespace Inkscape + +#endif diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 47fbd39af98c00cdb722ca1df852eda63bde8524..94ab46f247785d8b92e2324565e66cc2b9867540 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -28,15 +28,15 @@ namespace LivePathEffect { TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const Glib::ustring default_value ) + Effect* effect, const Glib::ustring defaultvalue ) : Parameter(label, tip, key, wr, effect), - value(default_value), - defvalue(default_value), + value(defaultvalue), + defvalue(defaultvalue), _hide_canvas_text(false) { if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { // FIXME: we shouldn't use this! canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), ""); - sp_canvastext_set_text (canvas_text, default_value.c_str()); + sp_canvastext_set_text (canvas_text, defaultvalue.c_str()); sp_canvastext_set_coords (canvas_text, 0, 0); } else { _hide_canvas_text = true; @@ -44,15 +44,16 @@ TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip, } void -TextParam::param_set_default() +TextParam::param_valueFromDefault() { param_setValue(defvalue); } void -TextParam::param_update_default(Glib::ustring default_value) + +TextParam::param_update_default(const gchar * default_value) { - defvalue = default_value; + defvalue = (Glib::ustring)default_value; } void @@ -131,6 +132,9 @@ TextParam::param_newWidget() void TextParam::param_setValue(const Glib::ustring newvalue) { + if (value != newvalue) { + param_effect->upd_params = true; + } value = newvalue; if (!_hide_canvas_text) { sp_canvastext_set_text (canvas_text, newvalue.c_str()); diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 553c84c0abd04f466274a76a6a45a7476df60092..48681ae50de45f4c74c3578e23ede976618edf53 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -31,7 +31,7 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const Glib::ustring default_value = ""); + const Glib::ustring defaultvalue = ""); virtual ~TextParam() {} virtual Gtk::Widget * param_newWidget(); @@ -39,16 +39,16 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; - void param_setValue(const Glib::ustring newvalue); + void param_setValue(Glib::ustring newvalue); void param_hide_canvas_text(); - virtual void param_set_default(); - void param_update_default(Glib::ustring default_value); + virtual void param_valueFromDefault(); + void param_updateDefault(const gchar * default_value); void setPos(Geom::Point pos); void setPosAndAnchor(const Geom::Piecewise > &pwd2, - const double t, const double length, bool use_curvature = false); + const double t, const double length, bool use_curvature = false); void setAnchor(double x_value, double y_value); - const Glib::ustring get_value() const { return defvalue; }; + const Glib::ustring get_value() const { return value; }; private: TextParam(const TextParam&); diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index f7042b6d1a0336f1de00c1fb62d8ef988d0ba6dc..c895aff38ce22223ff99fea47b886613cf929261 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -24,10 +24,10 @@ namespace LivePathEffect { ToggleButtonParam::ToggleButtonParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, bool default_value, const Glib::ustring& inactive_label, + Effect* effect, bool defaultvalue, const Glib::ustring& inactive_label, char const * _icon_active, char const * _icon_inactive, Inkscape::IconSize _icon_size) - : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value), + : Parameter(label, tip, key, wr, effect), value(defaultvalue), defvalue(defaultvalue), inactive_label(inactive_label), _icon_active(_icon_active), _icon_inactive(_icon_inactive), _icon_size(_icon_size) { checkwdg = NULL; @@ -41,7 +41,7 @@ ToggleButtonParam::~ToggleButtonParam() } void -ToggleButtonParam::param_set_default() +ToggleButtonParam::param_valueFromDefault() { param_setValue(defvalue); } @@ -60,6 +60,18 @@ ToggleButtonParam::param_getSVGValue() const return str; } +void +ToggleButtonParam::param_update_default(bool default_value) +{ + defvalue = default_value; +} + +void +ToggleButtonParam::param_update_default(const gchar * default_value) +{ + param_update_default(helperfns_read_bool(default_value, defvalue)); +} + Gtk::Widget * ToggleButtonParam::param_newWidget() { @@ -68,7 +80,7 @@ ToggleButtonParam::param_newWidget() } checkwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredToggleButton( param_label, + new Inkscape::UI::Widget::RegisteredToggleButton(param_label, param_tooltip, param_key, *param_wr, @@ -152,6 +164,9 @@ ToggleButtonParam::refresh_button() void ToggleButtonParam::param_setValue(bool newvalue) { + if (value != newvalue) { + param_effect->upd_params = true; + } value = newvalue; refresh_button(); } diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h index 8390fec8663fb7edc39d63e9b90a8c1fe52b1001..930c9f105f0232356503fc467aaf82c6ea5331d4 100644 --- a/src/live_effects/parameter/togglebutton.h +++ b/src/live_effects/parameter/togglebutton.h @@ -30,7 +30,7 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - bool default_value = false, + bool defaultvalue = false, const Glib::ustring& inactive_label = "", char const * icon_active = NULL, char const * icon_inactive = NULL, @@ -43,7 +43,7 @@ public: virtual gchar * param_getSVGValue() const; void param_setValue(bool newvalue); - virtual void param_set_default(); + virtual void param_valueFromDefault(); bool get_value() const { return value; }; @@ -51,6 +51,8 @@ public: sigc::signal& signal_toggled() { return _signal_toggled; } virtual void toggled(); + void param_update_default(bool default_value); + virtual void param_update_default(const gchar * default_value); private: ToggleButtonParam(const ToggleButtonParam&); diff --git a/src/live_effects/parameter/transformedpoint.cpp b/src/live_effects/parameter/transformedpoint.cpp index 0d03432c351040208645f29b722ca1ef8bce9fb8..1dc1f26128f7e168274307666ea430a1fe7dc01b 100644 --- a/src/live_effects/parameter/transformedpoint.cpp +++ b/src/live_effects/parameter/transformedpoint.cpp @@ -42,7 +42,7 @@ TransformedPointParam::~TransformedPointParam() } void -TransformedPointParam::param_set_default() +TransformedPointParam::param_valueFromDefault() { setOrigin(Geom::Point(0.,0.)); setVector(defvalue); @@ -82,6 +82,25 @@ TransformedPointParam::param_getSVGValue() const return str; } +void +TransformedPointParam::param_update_default(Geom::Point default_point) +{ + defvalue = default_point; +} + +void +TransformedPointParam::param_update_default(const gchar * default_point) +{ + gchar ** strarray = g_strsplit(default_point, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + param_update_default( Geom::Point(newx, newy) ); + } +} + Gtk::Widget * TransformedPointParam::param_newWidget() { @@ -109,12 +128,12 @@ TransformedPointParam::set_and_write_new_values(Geom::Point const &new_origin, G { setValues(new_origin, new_vector); gchar * str = param_getSVGValue(); - param_write_to_repr(str); + param_writeToRepr(str); g_free(str); } void -TransformedPointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) +TransformedPointParam::param_transformMultiply(Geom::Affine const& postmul, bool /*set*/) { if (!noTransform) { set_and_write_new_values( origin * postmul, vector * postmul.withoutTranslation() ); diff --git a/src/live_effects/parameter/transformedpoint.h b/src/live_effects/parameter/transformedpoint.h index c96bedb539427f0ad39e853c72b3e96dcf2913bd..ff33498570e024c3bb722ae7fef384bf7c063bbd 100644 --- a/src/live_effects/parameter/transformedpoint.h +++ b/src/live_effects/parameter/transformedpoint.h @@ -43,15 +43,17 @@ public: void setValues(Geom::Point const &new_origin, Geom::Point const &new_vector) { setVector(new_vector); setOrigin(new_origin); }; void setVector(Geom::Point const &new_vector) { vector = new_vector; }; void setOrigin(Geom::Point const &new_origin) { origin = new_origin; }; - virtual void param_set_default(); + virtual void param_valueFromDefault(); void set_and_write_new_values(Geom::Point const &new_origin, Geom::Point const &new_vector); - virtual void param_transform_multiply(Geom::Affine const &postmul, bool set); + virtual void param_transformMultiply(Geom::Affine const &postmul, bool set); void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_oncanvas_color(guint32 color); - + Geom::Point param_get_default() { return defvalue; } + void param_update_default(Geom::Point default_point); + virtual void param_update_default(const gchar * default_point); virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index b6ea99bfe05c90a0851a2fb86a8f2fbcab19f969..80748a26a78cafc2011d2fdb38ce9ce1a6afff81 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -36,7 +36,7 @@ bool UnitParam::param_readSVGValue(const gchar * strvalue) { if (strvalue) { - param_set_value(*unit_table.getUnit(strvalue)); + param_setValue(*unit_table.getUnit(strvalue)); return true; } return false; @@ -49,20 +49,21 @@ UnitParam::param_getSVGValue() const } void -UnitParam::param_set_default() +UnitParam::param_valueFromDefault() { - param_set_value(*defunit); + param_setValue(*defunit); } void -UnitParam::param_update_default(const Glib::ustring default_unit) +UnitParam::param_update_default(const gchar * default_unit) { - defunit = unit_table.getUnit(default_unit); + defunit = unit_table.getUnit((Glib::ustring)default_unit); } void -UnitParam::param_set_value(Inkscape::Util::Unit const &val) +UnitParam::param_setValue(Inkscape::Util::Unit const &val) { + param_effect->upd_params = true; unit = new Inkscape::Util::Unit(val); } diff --git a/src/live_effects/parameter/unit.h b/src/live_effects/parameter/unit.h index ae58cf9569d34c0df58e11bb16308fc42efd882b..d3e25367b10ca7861b34254258117de8995ab0bc 100644 --- a/src/live_effects/parameter/unit.h +++ b/src/live_effects/parameter/unit.h @@ -31,13 +31,13 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; - virtual void param_set_default(); - void param_set_value(Inkscape::Util::Unit const &val); - void param_update_default(const Glib::ustring default_unit); - const gchar *get_abbreviation() const; + virtual void param_valueFromDefault(); + void param_setValue(Inkscape::Util::Unit const &val); + void param_updateDefault(const gchar * default_unit); + const gchar *get_abbreviation() const; virtual Gtk::Widget * param_newWidget(); - + operator Inkscape::Util::Unit const *() const { return unit; } private: diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index 55b4d4b3287ff905b792b4bf903950f126c63921..da560f09731834eea0784b63d0c7be6b67715df5 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -42,12 +42,31 @@ VectorParam::~VectorParam() } void -VectorParam::param_set_default() +VectorParam::param_valueFromDefault() { setOrigin(Geom::Point(0.,0.)); setVector(defvalue); } +void +VectorParam::param_update_default(Geom::Point default_point) +{ + defvalue = default_point; +} + +void +VectorParam::param_update_default(const gchar * default_point) +{ + gchar ** strarray = g_strsplit(default_point, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + param_update_default( Geom::Point(newx, newy) ); + } +} + bool VectorParam::param_readSVGValue(const gchar * strvalue) { @@ -109,12 +128,12 @@ VectorParam::set_and_write_new_values(Geom::Point const &new_origin, Geom::Point { setValues(new_origin, new_vector); gchar * str = param_getSVGValue(); - param_write_to_repr(str); + param_writeToRepr(str); g_free(str); } void -VectorParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) +VectorParam::param_transformMultiply(Geom::Affine const& postmul, bool /*set*/) { set_and_write_new_values( origin * postmul, vector * postmul.withoutTranslation() ); } diff --git a/src/live_effects/parameter/vector.h b/src/live_effects/parameter/vector.h index edee4ff4d4c1a3828296373ae0526192704a289b..d15e65dcd3b6c7fd70a4ce6fd8d7f887e8736466 100644 --- a/src/live_effects/parameter/vector.h +++ b/src/live_effects/parameter/vector.h @@ -42,16 +42,17 @@ public: void setValues(Geom::Point const &new_origin, Geom::Point const &new_vector) { setVector(new_vector); setOrigin(new_origin); }; void setVector(Geom::Point const &new_vector) { vector = new_vector; }; void setOrigin(Geom::Point const &new_origin) { origin = new_origin; }; - virtual void param_set_default(); + virtual void param_valueFromDefault(); void set_and_write_new_values(Geom::Point const &new_origin, Geom::Point const &new_vector); - virtual void param_transform_multiply(Geom::Affine const &postmul, bool set); + virtual void param_transformMultiply(Geom::Affine const &postmul, bool set); void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_origin_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_oncanvas_color(guint32 color); - + void param_update_default(Geom::Point default_point); + virtual void param_update_default(const gchar * default_point); virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); diff --git a/src/preferences.cpp b/src/preferences.cpp index 4d522a1d88f7c491813cc15b1f3080b009ed5b27..2849fe068a84e477290ceda80a22c43bb86b0443 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -512,6 +512,35 @@ void Preferences::remove(Glib::ustring const &pref_path) Inkscape::XML::Node *node = _getNode(pref_path, false); if (node && node->parent()) { node->parent()->removeChild(node); + } else { //Handle to remove also attributes in path not only the container node + // verify path + g_assert( pref_path.at(0) == '/' ); + if (_prefs_doc == NULL){ + return; + } + node = _prefs_doc->root(); + Inkscape::XML::Node *child = NULL; + gchar **splits = g_strsplit(pref_path.c_str(), "/", 0); + if ( splits ) { + for (int part_i = 0; splits[part_i]; ++part_i) { + // skip empty path segments + if (!splits[part_i][0]) { + continue; + } + if (!node->firstChild()) { + node->setAttribute(splits[part_i], NULL); + g_strfreev(splits); + return; + } + for (child = node->firstChild(); child; child = child->next()) { + if (!strcmp(splits[part_i], child->attribute("id"))) { + break; + } + } + node = child; + } + } + g_strfreev(splits); } } diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 389e8902a68d9fc72fff14a96087d4033323bb9b..e98b14699785087fa9778bf5b10745404633a786 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -86,7 +86,6 @@ set(ui_SRC dialog/layers.cpp 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 @@ -229,7 +228,6 @@ set(ui_SRC dialog/layers.h dialog/livepatheffect-add.h dialog/livepatheffect-editor.h - dialog/lpe-fillet-chamfer-properties.h dialog/lpe-powerstroke-properties.h dialog/memory.h dialog/messages.h diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 45fde909632a507805711a87d0916f9b3ee2589c..ff0999890c5e19969c46d705b5754bbd2911c370 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -19,7 +19,7 @@ #include "livepatheffect-editor.h" #include "desktop.h" - +#include #include "document.h" #include "document-undo.h" #include "helper/action.h" @@ -53,12 +53,16 @@ void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data { LivePathEffectEditor *lpeeditor = static_cast(data); lpeeditor->lpe_list_locked = false; + lpeeditor->lpe_changed = true; lpeeditor->onSelectionChanged(selection); } void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data) { - lpeeditor_selection_changed (selection, data); + + LivePathEffectEditor *lpeeditor = static_cast(data); + lpeeditor->lpe_list_locked = false; + lpeeditor->onSelectionChanged(selection); } static void lpe_style_button(Gtk::Button& btn, char const* iconName) @@ -81,6 +85,7 @@ LivePathEffectEditor::LivePathEffectEditor() : UI::Widget::Panel("", "/dialogs/livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT), deskTrack(), lpe_list_locked(false), + lpe_changed(true), effectwidget(NULL), status_label("", Gtk::ALIGN_CENTER), effectcontrol_frame(""), @@ -191,7 +196,22 @@ LivePathEffectEditor::~LivePathEffectEditor() void LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) { + + if (!effect.upd_params && !lpe_changed) { + lpe_changed = false; + return; + } + bool expanderopen = false; + Gtk::Widget * defaultswidget = effect.defaultParamSet(); if (effectwidget) { + if (defaultswidget) { + Gtk::Expander * expander = NULL; + std::vector childs = dynamic_cast (effectwidget)->get_children(); + std::vector childs_default = dynamic_cast (childs[childs.size()-1])->get_children(); + if ((expander = dynamic_cast(childs_default[childs_default.size()-1]))){ + expanderopen = expander->get_expanded(); + } + } effectcontrol_vbox.remove(*effectwidget); delete effectwidget; effectwidget = NULL; @@ -201,6 +221,15 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) effectwidget = effect.newWidget(); if (effectwidget) { + + if (defaultswidget) { + Gtk::Expander * expander = NULL; + std::vector childs_default = dynamic_cast (defaultswidget)->get_children(); + if ((expander = dynamic_cast(childs_default[childs_default.size()-1]))){ + expander->set_expanded(expanderopen); + } + dynamic_cast (effectwidget)->pack_start(*defaultswidget, true, true); + } effectcontrol_vbox.pack_start(*effectwidget, true, true); } button_remove.show(); @@ -208,7 +237,10 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) status_label.hide(); effectcontrol_frame.show(); effectcontrol_vbox.show_all_children(); + effect.upd_params = false; // fixme: add resizing of dialog + effect.upd_params = false; + lpe_changed = false; } void @@ -540,6 +572,7 @@ void LivePathEffectEditor::on_effect_selection_changed() current_lperef = lperef; LivePathEffect::Effect * effect = lperef->lpeobject->get_lpe(); if (effect) { + lpe_changed = true; showParams(*effect); } } diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index b18d434c5f412027eae69f16f68db18dff312858..7f6f56fd2b945f3703538685de50d21a7c129054 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -96,7 +96,7 @@ private: }; bool lpe_list_locked; - + bool lpe_changed; //Inkscape::UI::Widget::ComboBoxEnum combo_effecttype; Gtk::Widget * effectwidget; diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp deleted file mode 100644 index 0baf15e6b676813ffb29c3739394a1ec45144c4e..0000000000000000000000000000000000000000 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/** - * From the code of Liam P.White from his Power Stroke Knot dialog - * - * Released under GNU GPL. Read the file 'COPYING' for more information - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "lpe-fillet-chamfer-properties.h" -#include -#include -#include "inkscape.h" -#include "desktop.h" -#include "document-undo.h" -#include "layer-manager.h" -#include "message-stack.h" - -#include "selection-chemistry.h" - -//#include "event-context.h" - -namespace Inkscape { -namespace UI { -namespace Dialogs { - -FilletChamferPropertiesDialog::FilletChamferPropertiesDialog() - : _desktop(NULL), - _knotpoint(NULL), - _position_visible(false), - _close_button(_("_Cancel"), true) -{ - Gtk::Box *mainVBox = get_vbox(); - mainVBox->set_homogeneous(false); - _layout_table.set_row_spacing(4); - _layout_table.set_column_spacing(4); - - // Layer name widgets - _fillet_chamfer_position_numeric.set_digits(4); - _fillet_chamfer_position_numeric.set_increments(1,1); - //todo: get tha max aloable infinity freeze the widget - _fillet_chamfer_position_numeric.set_range(0., SCALARPARAM_G_MAXDOUBLE); - _fillet_chamfer_position_numeric.set_hexpand(); - - _fillet_chamfer_position_label.set_label(_("Radius (pixels):")); - _fillet_chamfer_position_label.set_alignment(1.0, 0.5); - - _layout_table.attach(_fillet_chamfer_position_label, 0, 0, 1, 1); - _layout_table.attach(_fillet_chamfer_position_numeric, 1, 0, 1, 1); - _fillet_chamfer_chamfer_subdivisions.set_digits(0); - _fillet_chamfer_chamfer_subdivisions.set_increments(1,1); - //todo: get tha max aloable infinity freeze the widget - _fillet_chamfer_chamfer_subdivisions.set_range(0, SCALARPARAM_G_MAXDOUBLE); - _fillet_chamfer_chamfer_subdivisions.set_hexpand(); - - _fillet_chamfer_chamfer_subdivisions_label.set_label(_("Chamfer subdivisions:")); - _fillet_chamfer_chamfer_subdivisions_label.set_alignment(1.0, 0.5); - - _layout_table.attach(_fillet_chamfer_chamfer_subdivisions_label, 0, 1, 1, 1); - _layout_table.attach(_fillet_chamfer_chamfer_subdivisions, 1, 1, 1, 1); - _fillet_chamfer_type_fillet.set_label(_("Fillet")); - _fillet_chamfer_type_fillet.set_group(_fillet_chamfer_type_group); - _fillet_chamfer_type_inverse_fillet.set_label(_("Inverse fillet")); - _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_can_default(); - - _apply_button.set_use_underline(true); - _apply_button.set_can_default(); - - _close_button.signal_clicked() - .connect(sigc::mem_fun(*this, &FilletChamferPropertiesDialog::_close)); - _apply_button.signal_clicked() - .connect(sigc::mem_fun(*this, &FilletChamferPropertiesDialog::_apply)); - - signal_delete_event().connect(sigc::bind_return( - sigc::hide(sigc::mem_fun(*this, &FilletChamferPropertiesDialog::_close)), - true)); - - add_action_widget(_close_button, Gtk::RESPONSE_CLOSE); - add_action_widget(_apply_button, Gtk::RESPONSE_APPLY); - - _apply_button.grab_default(); - - show_all_children(); - - set_focus(_fillet_chamfer_position_numeric); -} - -FilletChamferPropertiesDialog::~FilletChamferPropertiesDialog() -{ - - _set_desktop(NULL); -} - -void FilletChamferPropertiesDialog::showDialog( - SPDesktop *desktop, Geom::Point knotpoint, - const Inkscape::LivePathEffect:: - FilletChamferPointArrayParamKnotHolderEntity *pt, - bool use_distance, - bool aprox_radius) -{ - FilletChamferPropertiesDialog *dialog = new FilletChamferPropertiesDialog(); - - dialog->_set_desktop(desktop); - dialog->_set_use_distance(use_distance); - dialog->_set_aprox(aprox_radius); - dialog->_set_knot_point(knotpoint); - dialog->_set_pt(pt); - - dialog->set_title(_("Modify Fillet-Chamfer")); - dialog->_apply_button.set_label(_("_Modify")); - - dialog->set_modal(true); - desktop->setWindowTransient(dialog->gobj()); - dialog->property_destroy_with_parent() = true; - - dialog->show(); - dialog->present(); -} - -void FilletChamferPropertiesDialog::_apply() -{ - double d_width; - double d_pos = _fillet_chamfer_position_numeric.get_value(); - if (d_pos) { - if (_fillet_chamfer_type_fillet.get_active() == true) { - 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() + 3000; - } - if (_flexible) { - if (d_pos > 99.99999 || d_pos < 0) { - d_pos = 0; - } - d_pos = _index + (d_pos / 100); - } else { - d_pos = d_pos * -1; - } - _knotpoint->knot_set_offset(Geom::Point(d_pos, d_width)); - } - _close(); -} - -void FilletChamferPropertiesDialog::_close() -{ - _set_desktop(NULL); - destroy_(); - Glib::signal_idle().connect( - sigc::bind_return( - sigc::bind(sigc::ptr_fun(&::operator delete), this), - false - ) - ); -} - -bool FilletChamferPropertiesDialog::_handleKeyEvent(GdkEventKey * /*event*/) -{ - return false; -} - -void FilletChamferPropertiesDialog::_handleButtonEvent(GdkEventButton *event) -{ - if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1)) { - _apply(); - } -} - -void FilletChamferPropertiesDialog::_set_knot_point(Geom::Point knotpoint) -{ - double position; - std::string distance_or_radius = std::string(_("Radius")); - if(aprox){ - distance_or_radius = std::string(_("Radius approximated")); - } - if(use_distance){ - distance_or_radius = std::string(_("Knot distance")); - } - if (knotpoint.x() > 0) { - double intpart; - position = modf(knotpoint[Geom::X], &intpart) * 100; - _flexible = true; - _index = intpart; - _fillet_chamfer_position_label.set_label(_("Position (%):")); - } else { - _flexible = false; - std::string posConcat = Glib::ustring::compose (_("%1:"), distance_or_radius); - _fillet_chamfer_position_label.set_label(_(posConcat.c_str())); - position = knotpoint[Geom::X] * -1; - } - _fillet_chamfer_position_numeric.set_value(position); - if (knotpoint.y() == 1) { - _fillet_chamfer_type_fillet.set_active(true); - } else if (knotpoint.y() == 2) { - _fillet_chamfer_type_inverse_fillet.set_active(true); - } 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); - } -} - -void FilletChamferPropertiesDialog::_set_pt( - const Inkscape::LivePathEffect:: - FilletChamferPointArrayParamKnotHolderEntity *pt) -{ - _knotpoint = const_cast< - Inkscape::LivePathEffect::FilletChamferPointArrayParamKnotHolderEntity *>( - pt); -} - -void FilletChamferPropertiesDialog::_set_use_distance(bool use_knot_distance) -{ - use_distance = use_knot_distance; -} - -void FilletChamferPropertiesDialog::_set_aprox(bool aprox_radius) -{ - aprox = aprox_radius; -} - -void FilletChamferPropertiesDialog::_set_desktop(SPDesktop *desktop) -{ - if (desktop) { - Inkscape::GC::anchor(desktop); - } - if (_desktop) { - Inkscape::GC::release(_desktop); - } - _desktop = desktop; -} - -} // namespace -} // namespace -} // namespace - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h deleted file mode 100644 index c74e3f0116676657c328619347fe477e3750ae0a..0000000000000000000000000000000000000000 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.h +++ /dev/null @@ -1,109 +0,0 @@ -/** - * - * From the code of Liam P.White from his Power Stroke Knot dialog - * - * Released under GNU GPL. Read the file 'COPYING' for more information - */ - -#ifndef INKSCAPE_DIALOG_FILLET_CHAMFER_PROPERTIES_H -#define INKSCAPE_DIALOG_FILLET_CHAMFER_PROPERTIES_H - -#include <2geom/point.h> -#include -#include "live_effects/parameter/filletchamferpointarray.h" - -class SPDesktop; - -namespace Inkscape { -namespace UI { -namespace Dialogs { - -class FilletChamferPropertiesDialog : public Gtk::Dialog { -public: - FilletChamferPropertiesDialog(); - virtual ~FilletChamferPropertiesDialog(); - - Glib::ustring getName() const { - return "LayerPropertiesDialog"; - } - - static void showDialog(SPDesktop *desktop, Geom::Point knotpoint, - const Inkscape::LivePathEffect:: - FilletChamferPointArrayParamKnotHolderEntity *pt, - bool use_distance, - bool aprox_radius); - -protected: - - SPDesktop *_desktop; - Inkscape::LivePathEffect::FilletChamferPointArrayParamKnotHolderEntity * - _knotpoint; - - Gtk::Label _fillet_chamfer_position_label; - Gtk::SpinButton _fillet_chamfer_position_numeric; - Gtk::RadioButton::Group _fillet_chamfer_type_group; - 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; - - Gtk::Grid _layout_table; - bool _position_visible; - double _index; - - Gtk::Button _close_button; - Gtk::Button _apply_button; - - sigc::connection _destroy_connection; - - static FilletChamferPropertiesDialog &_instance() { - static FilletChamferPropertiesDialog instance; - return instance; - } - - void _set_desktop(SPDesktop *desktop); - void _set_pt(const Inkscape::LivePathEffect:: - FilletChamferPointArrayParamKnotHolderEntity *pt); - void _set_use_distance(bool use_knot_distance); - void _set_aprox(bool aprox_radius); - void _apply(); - void _close(); - bool _flexible; - bool use_distance; - bool aprox; - void _set_knot_point(Geom::Point knotpoint); - void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row); - - bool _handleKeyEvent(GdkEventKey *event); - void _handleButtonEvent(GdkEventButton *event); - - friend class Inkscape::LivePathEffect:: - FilletChamferPointArrayParamKnotHolderEntity; - -private: - FilletChamferPropertiesDialog( - FilletChamferPropertiesDialog const &); // no copy - FilletChamferPropertiesDialog &operator=( - FilletChamferPropertiesDialog const &); // no assign -}; - -} // namespace -} // namespace -} // namespace - -#endif //INKSCAPE_DIALOG_LAYER_PROPERTIES_H - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: -// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 -// : diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 5746a8f8680e5801000e78c8536fc46e7070a208..f2899dd01a56edb621d9b46401aa563523666c92 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -12,7 +12,6 @@ #include "live_effects/lpe-powerstroke.h" #include "live_effects/lpe-bspline.h" -#include "live_effects/lpe-fillet-chamfer.h" #include <2geom/bezier-utils.h> #include <2geom/path-sink.h> #include "ui/tool/path-manipulator.h" @@ -1364,13 +1363,6 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) lpe_pwr->adjustForNewPath(pathv); } } - this_effect = _path->getPathEffectOfType(Inkscape::LivePathEffect::FILLET_CHAMFER); - if(this_effect){ - LivePathEffect::LPEFilletChamfer *lpe_fll = dynamic_cast(this_effect->getLPEObj()->get_lpe()); - if (lpe_fll) { - lpe_fll->adjustForNewPath(pathv); - } - } } }