diff --git a/AUTHORS b/AUTHORS index 55f154b9ff2cf512c931385019d5e004d8b0c2b5..a0dd0b5608f7133091ec5a968cbe70893b161088 100644 --- a/AUTHORS +++ b/AUTHORS @@ -143,6 +143,7 @@ Felipe Corrêa da Silva Sanches Christian Schaller Marco Scholten Tom von Schwerdtner +Markus Schwienbacher Danilo Šegan Abhishek Sharma Tim Sheridan diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 63895ed619ee7b5e9afef64f0f9b4e66ddffa433..0c027a57ffccba3f097212be304215e1009a3be3 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -1488,6 +1488,11 @@ Effect::newWidget() if ((*it)->widget_is_visible) { Parameter * param = *it; Gtk::Widget * widg = param->param_newWidget(); + if (param->widget_is_enabled) { + widg->set_sensitive(true); + } else { + widg->set_sensitive(false); + } Glib::ustring * tip = param->param_getTooltip(); if (widg) { vbox->pack_start(*widg, true, true, 2); diff --git a/src/live_effects/lpe-pts2ellipse.cpp b/src/live_effects/lpe-pts2ellipse.cpp index 48655b25ae31820483d04cd4744fd20c5d01ab28..8fb6c89f7cd601d57d0885f116118cd6835355ab 100644 --- a/src/live_effects/lpe-pts2ellipse.cpp +++ b/src/live_effects/lpe-pts2ellipse.cpp @@ -14,45 +14,46 @@ #include "live_effects/lpe-pts2ellipse.h" -#include +#include #include #include -#include +#include #include -#include -#include <2geom/path.h> #include <2geom/circle.h> #include <2geom/ellipse.h> -#include <2geom/pathvector.h> #include <2geom/elliptical-arc.h> +#include <2geom/path.h> +#include <2geom/pathvector.h> #include -using namespace Geom; - namespace Inkscape { namespace LivePathEffect { static const Util::EnumData EllipseMethodData[] = { - { EM_AUTO, N_("Auto ellipse"), "auto" }, //!< (2..4 points: circle, from 5 points: ellipse) - { EM_CIRCLE, N_("Force circle"), "circle" }, - { EM_ISONOMETRIC_CIRCLE, N_("Isometric circle"), "iso_circle" } + { EM_AUTO, N_("Auto ellipse"), "auto" }, //!< (2..4 points: circle, from 5 points: ellipse) + { EM_CIRCLE, N_("Force circle"), "circle" }, //!< always fit a circle + { EM_ISOMETRIC_CIRCLE, N_("Isometric circle"), "iso_circle" }, //!< use first two edges to generate a sheared + //!< ellipse + { EM_STEINER_ELLIPSE, N_("Steiner ellipse"), "steiner_ellipse" }, //!< generate a steiner ellipse from the first + //!< three points + { EM_STEINER_INELLIPSE, N_("Steiner inellipse"), "steiner_inellipse" } //!< generate a steiner inellipse from the + //!< first three points }; static const Util::EnumDataConverter EMConverter(EllipseMethodData, EM_END); -LPEPts2Ellipse::LPEPts2Ellipse(LivePathEffectObject *lpeobject) : - Effect(lpeobject), - method(_("Method:"), _("Methods to generate the ellipse"), - "method", EMConverter, &wr, this, EM_AUTO), - gen_isometric_frame(_("_Frame (isometric rectangle)"), _("Draw Parallelogram around the ellipse"), - "gen_isometric_frame", &wr, this, false), - gen_arc(_("_Arc"), _("Generate open arc (open ellipse)"), "gen_arc", &wr, this, false), - other_arc(_("_Other Arc side"), _("switch sides of the arc"), "arc_other", &wr, this, false), - slice_arc(_("_Slice Arc"), _("slice the arc"), "slice_arc", &wr, this, false), - draw_axes(_("A_xes"), _("Draw both semi-major and semi-minor axes"), "draw_axes", &wr, this, false), - rot_axes(_("Axes Rotation"), _("Axes rotation angle [deg]"), "rot_axes", &wr, this, 0), - draw_ori_path(_("Source _Path"), _("Show the original source path"), "draw_ori_path", &wr, this, false) +LPEPts2Ellipse::LPEPts2Ellipse(LivePathEffectObject *lpeobject) + : Effect(lpeobject) + , method(_("Method:"), _("Methods to generate the ellipse"), "method", EMConverter, &wr, this, EM_AUTO) + , gen_isometric_frame(_("_Frame (isometric rectangle)"), _("Draw parallelogram around the ellipse"), + "gen_isometric_frame", &wr, this, false) + , gen_arc(_("_Arc"), _("Generate open arc (open ellipse)"), "gen_arc", &wr, this, false) + , other_arc(_("_Other arc side"), _("Switch sides of the arc"), "arc_other", &wr, this, false) + , slice_arc(_("_Slice arc"), _("Slice the arc"), "slice_arc", &wr, this, false) + , draw_axes(_("A_xes"), _("Draw both semi-major and semi-minor axes"), "draw_axes", &wr, this, false) + , rot_axes(_("Axes rotation"), _("Axes rotation angle [deg]"), "rot_axes", &wr, this, 0) + , draw_ori_path(_("Source _path"), _("Show the original source path"), "draw_ori_path", &wr, this, false) { registerParameter(&method); registerParameter(&gen_arc); @@ -63,182 +64,166 @@ LPEPts2Ellipse::LPEPts2Ellipse(LivePathEffectObject *lpeobject) : registerParameter(&rot_axes); registerParameter(&draw_ori_path); - rot_axes.param_set_range(-360,360); - rot_axes.param_set_increments(1,10); + rot_axes.param_set_range(-360, 360); + rot_axes.param_set_increments(1, 10); - show_orig_path=true; + show_orig_path = true; } -LPEPts2Ellipse::~LPEPts2Ellipse() -= default; +LPEPts2Ellipse::~LPEPts2Ellipse() = default; // helper function, transforms a given value into range [0, 2pi] -inline double -range2pi(double a) +inline double range2pi(double a) { - a = fmod(a, 2*M_PI); - if(a<0) a+=2*M_PI; + a = fmod(a, 2 * M_PI); + if (a < 0) { + a += 2 * M_PI; + } return a; } -inline double -deg2rad(double a) -{ - return a*M_PI/180.0; -} +inline double deg2rad(double a) { return a * M_PI / 180.0; } -inline double -rad2deg(double a) -{ - return a*180.0/M_PI; -} +inline double rad2deg(double a) { return a * 180.0 / M_PI; } // helper function, calculates the angle between a0 and a1 in ccw sense // examples: 0..1->1, -1..1->2, pi/4..-pi/4->1.5pi // full rotations: 0..2pi->2pi, -pi..pi->2pi, pi..-pi->0, 2pi..0->0 -inline double -calc_delta_angle(const double a0, const double a1) +inline double calc_delta_angle(const double a0, const double a1) { - double da=range2pi(a1-a0); - if((fabs(da)<1e-9) && (a0moveto(cos(start), sin(start)); - double s = start; - for (int i=0; i < nda; s = (++i)*da+start) { + double x0 = cos(s); + double y0 = sin(s); + // construct the path + Geom::Path path(Geom::Point(x0, y0)); + path.setStitching(true); + for (int i = 0; i < nda;) { double e = s + da; - if (e > end) + if (e > end) { e = end; - const double len = 4*tan((e - s)/4)/3; - const double x0 = cos(s); - const double y0 = sin(s); + } + const double len = 4 * tan((e - s) / 4) / 3; const double x1 = x0 + len * cos(s + M_PI_2); const double y1 = y0 + len * sin(s + M_PI_2); const double x3 = cos(e); const double y3 = sin(e); const double x2 = x3 + len * cos(e - M_PI_2); const double y2 = y3 + len * sin(e - M_PI_2); - curve->curveto(x1,y1, x2,y2, x3,y3); + path.appendNew(Geom::Point(x1, y1), Geom::Point(x2, y2), Geom::Point(x3, y3)); + s = (++i) * da + start; + x0 = cos(s); + y0 = sin(s); } if (slice && !closed) { - curve->lineto(0., 0.); + path.appendNew(Geom::Point(0.0, 0.0)); } - curve->transform(affine); + path *= affine; - path.append(*curve->first_path()); + path_in.append(path); if ((slice && !closed) || closed) { - path.close(true); + path_in.close(true); } - // give to GC - curve->unref(); return 0; } -void -gen_iso_frame_paths(Geom::PathVector &path_out, const Geom::Affine &affine) +void gen_iso_frame_paths(Geom::PathVector &path_out, const Geom::Affine &affine) { - Geom::Path rect; - SPCurve curve; - // unit rectangle - curve.moveto(-1, -1); - curve.lineto(1, -1); - curve.lineto(1, 1); - curve.lineto(-1, 1); - //curve.transform(Rotate(-rot_angle)*affine); - curve.transform(affine); - rect.append(*curve.first_path()); + Geom::Path rect(Geom::Point(-1, -1)); + rect.setStitching(true); + rect.appendNew(Geom::Point(+1, -1)); + rect.appendNew(Geom::Point(+1, +1)); + rect.appendNew(Geom::Point(-1, +1)); + rect *= affine; rect.close(true); path_out.push_back(rect); } -void -gen_axes_paths(Geom::PathVector &path_out, const Geom::Affine &affine) +void gen_axes_paths(Geom::PathVector &path_out, const Geom::Affine &affine) { - LineSegment clx(Point(-1,0),Point(1,0)); - LineSegment cly(Point(0,-1),Point(0,1)); + Geom::LineSegment clx(Geom::Point(-1, 0), Geom::Point(1, 0)); + Geom::LineSegment cly(Geom::Point(0, -1), Geom::Point(0, 1)); Geom::Path plx, ply; plx.append(clx); ply.append(cly); - plx*=affine; - ply*=affine; + plx *= affine; + ply *= affine; path_out.push_back(plx); path_out.push_back(ply); } -bool -is_ccw(const std::vector & pts) +bool is_ccw(const std::vector &pts) { // method: sum up the angles between edges - size_t n=pts.size(); + size_t n = pts.size(); // edges about vertex 0 - Point e0=pts.front()-pts.back(); - Point e1=pts[1]-pts[0]; - Coord sum=cross(e0,e1); + Geom::Point e0(pts.front() - pts.back()); + Geom::Point e1(pts[1] - pts[0]); + Geom::Coord sum = cross(e0, e1); // the rest - for(size_t i=1;i pts; - for(const auto & pit : path_in) { + std::vector pts; + for (const auto &pit : path_in) { // extract first point of this path pts.push_back(pit.initialPoint()); // iterate over all curves - for (const auto & cit : pit) { + for (const auto &cit : pit) { pts.push_back(cit.finalPoint()); } } // avoid identical start-point and end-point - if(pts.front() == pts.back()) { + if (pts.front() == pts.back()) { pts.pop_back(); } - // special mode: Use first two edges, interpret them as two sides of a parallelogram and - // generate an ellipse residing inside the parallelogram. This effect is quite useful when - // generating isometric views. Hence, the name. - //if(gen_isometric.get_value()) - if(method == EM_ISONOMETRIC_CIRCLE) { - if(0!=genIsometricEllipse (pts, path_out)) - return path_in; - } else { - if(0!=genFitEllipse(pts, path_out)) - return path_in; + // modify GUI based on selected method + switch (method) { + case EM_ISOMETRIC_CIRCLE: + case EM_STEINER_ELLIPSE: + case EM_STEINER_INELLIPSE: + gen_arc.param_widget_is_enabled(false); + other_arc.param_widget_is_enabled(false); + slice_arc.param_widget_is_enabled(false); + break; + default: + gen_arc.param_widget_is_enabled(true); + if (gen_arc.get_value()) { + slice_arc.param_widget_is_enabled(true); + other_arc.param_widget_is_enabled(true); + } else { + other_arc.param_widget_is_enabled(false); + slice_arc.param_widget_is_enabled(false); + } + } + + // call method specific code + switch (method) { + case EM_ISOMETRIC_CIRCLE: + // special mode: Use first two edges, interpret them as two sides of a parallelogram and + // generate an ellipse residing inside the parallelogram. This effect is quite useful when + // generating isometric views. Hence, the name. + if (0 != genIsometricEllipse(pts, path_out)) { + return path_in; + } + break; + case EM_STEINER_ELLIPSE: + if (0 != genSteinerEllipse(pts, false, path_out)) { + return path_in; + } + break; + case EM_STEINER_INELLIPSE: + if (0 != genSteinerEllipse(pts, true, path_out)) { + return path_in; + } + break; + default: + if (0 != genFitEllipse(pts, path_out)) { + return path_in; + } } return path_out; } @@ -295,165 +313,247 @@ LPEPts2Ellipse::doEffect_path (Geom::PathVector const & path_in) * slice, circle etc. the final result will be different. We need at least 5 points to fit an * ellipse. With 5 points each point is on the ellipse. For less points we get a circle. */ -int -LPEPts2Ellipse::genFitEllipse (std::vector const & pts, - Geom::PathVector & path_out) +int LPEPts2Ellipse::genFitEllipse(std::vector const &pts, Geom::PathVector &path_out) { // rotation angle based on user provided rot_axes to position the vertices const double rot_angle = -deg2rad(rot_axes); // negative for ccw rotation - Affine affine; - affine*=Rotate(rot_angle); - Coord a0=0; - Coord a1=2*M_PI; - - if(pts.size()<2) { + Geom::Affine affine; + affine *= Geom::Rotate(rot_angle); + Geom::Coord a0 = 0; + Geom::Coord a1 = 2 * M_PI; + + if (pts.size() < 2) { return -1; - } else if(pts.size()==2) { + } else if (pts.size() == 2) { // simple line: circle in the middle of the line to the vertices - Point line=pts.front()-pts.back(); - double radius=line.length()*0.5; - if(radius<1e-9) + Geom::Point line = pts.front() - pts.back(); + double radius = line.length() * 0.5; + if (radius < 1e-9) { return -1; - Point center=middle_point(pts.front(),pts.back()); - Circle circle(center[0],center[1],radius); - affine*=Scale(circle.radius()); - affine*=Translate(circle.center()); + } + Geom::Point center = middle_point(pts.front(), pts.back()); + Geom::Circle circle(center[0], center[1], radius); + affine *= Geom::Scale(circle.radius()); + affine *= Geom::Translate(circle.center()); Geom::Path path; - unit_arc_path(path,affine); + unit_arc_path(path, affine); path_out.push_back(path); - } else if(pts.size()>=5 && EM_AUTO == method) { //!only_circle.get_value()) { + } else if (pts.size() >= 5 && EM_AUTO == method) { //! only_circle.get_value()) { // do ellipse try { - Ellipse ellipse; + Geom::Ellipse ellipse; ellipse.fit(pts); - affine*=Scale(ellipse.ray(X),ellipse.ray(Y)); - affine*=Rotate(ellipse.rotationAngle()); - affine*=Translate(ellipse.center()); - if(gen_arc.get_value()) { - Affine inv_affine=affine.inverse(); - Point p0=pts.front()*inv_affine; - Point p1=pts.back()*inv_affine; - const bool ccw_wind=is_ccw(pts); - endpoints2angles(ccw_wind,other_arc.get_value(),p0,p1,a0,a1); + affine *= Geom::Scale(ellipse.ray(Geom::X), ellipse.ray(Geom::Y)); + affine *= Geom::Rotate(ellipse.rotationAngle()); + affine *= Geom::Translate(ellipse.center()); + if (gen_arc.get_value()) { + Geom::Affine inv_affine = affine.inverse(); + Geom::Point p0 = pts.front() * inv_affine; + Geom::Point p1 = pts.back() * inv_affine; + const bool ccw_wind = is_ccw(pts); + endpoints2angles(ccw_wind, other_arc.get_value(), p0, p1, a0, a1); } Geom::Path path; - unit_arc_path(path,affine,a0,a1,slice_arc.get_value()); + unit_arc_path(path, affine, a0, a1, slice_arc.get_value()); path_out.push_back(path); - if(draw_axes.get_value()) { - gen_axes_paths(path_out,affine); + if (draw_axes.get_value()) { + gen_axes_paths(path_out, affine); } - } catch(...) { + } catch (...) { return -1; } } else { // do a circle (3,4 points, or only_circle set) try { - Circle circle; + Geom::Circle circle; circle.fit(pts); - affine*=Scale(circle.radius()); - affine*=Translate(circle.center()); - - if(gen_arc.get_value()) - { - Point p0=pts.front()-circle.center(); - Point p1=pts.back()-circle.center(); - const bool ccw_wind=is_ccw(pts); - endpoints2angles(ccw_wind,other_arc.get_value(),p0,p1,a0,a1); + affine *= Geom::Scale(circle.radius()); + affine *= Geom::Translate(circle.center()); + + if (gen_arc.get_value()) { + Geom::Point p0 = pts.front() - circle.center(); + Geom::Point p1 = pts.back() - circle.center(); + const bool ccw_wind = is_ccw(pts); + endpoints2angles(ccw_wind, other_arc.get_value(), p0, p1, a0, a1); } Geom::Path path; - unit_arc_path(path,affine,a0,a1,slice_arc.get_value()); + unit_arc_path(path, affine, a0, a1, slice_arc.get_value()); path_out.push_back(path); - } catch(...) { + } catch (...) { return -1; } } // draw frame? - if(gen_isometric_frame.get_value()) { - gen_iso_frame_paths(path_out,affine); + if (gen_isometric_frame.get_value()) { + gen_iso_frame_paths(path_out, affine); } // draw axes? - if(draw_axes.get_value()) { - gen_axes_paths(path_out,affine); + if (draw_axes.get_value()) { + gen_axes_paths(path_out, affine); } return 0; } -int -LPEPts2Ellipse::genIsometricEllipse (std::vector const & pts, - Geom::PathVector & path_out) +int LPEPts2Ellipse::genIsometricEllipse(std::vector const &pts, Geom::PathVector &path_out) { // take the first 3 vertices for the edges - if(pts.size() < 3) return -1; + if (pts.size() < 3) { + return -1; + } // calc edges - Point e0=pts[0]-pts[1]; - Point e1=pts[2]-pts[1]; + Geom::Point e0 = pts[0] - pts[1]; + Geom::Point e1 = pts[2] - pts[1]; - Coord ce=cross(e0,e1); + Geom::Coord ce = cross(e0, e1); // parallel or one is zero? - if(fabs(ce)<1e-9) return -1; + if (fabs(ce) < 1e-9) { + return -1; + } // unit vectors along edges - Point u0=unit_vector(e0); - Point u1=unit_vector(e1); + Geom::Point u0 = unit_vector(e0); + Geom::Point u1 = unit_vector(e1); // calc angles - Coord a0=atan2(e0); + Geom::Coord a0 = atan2(e0); // Coord a1=M_PI_2-atan2(e1)-a0; - Coord a1=acos(dot(u0,u1))-M_PI_2; + Geom::Coord a1 = acos(dot(u0, u1)) - M_PI_2; // if(fabs(a1)<1e-9) return -1; - if(ce<0) a1=-a1; + if (ce < 0) { + a1 = -a1; + } // lengths: l0= length of edge 0; l1= height of parallelogram - Coord l0=e0.length()*0.5; - Point e0n=e1-dot(u0,e1)*u0; - Coord l1=e0n.length()*0.5; + Geom::Coord l0 = e0.length() * 0.5; + Geom::Point e0n = e1 - dot(u0, e1) * u0; + Geom::Coord l1 = e0n.length() * 0.5; // center of the ellipse - Point pos=pts[1]+0.5*(e0+e1); + Geom::Point pos = pts[1] + 0.5 * (e0 + e1); + + // rotation angle based on user provided rot_axes to position the vertices + const double rot_angle = -deg2rad(rot_axes); // negative for ccw rotation + + // build up the affine transformation + Geom::Affine affine; + affine *= Geom::Rotate(rot_angle); + affine *= Geom::Scale(l0, l1); + affine *= Geom::HShear(-tan(a1)); + affine *= Geom::Rotate(a0); + affine *= Geom::Translate(pos); + + Geom::Path path; + unit_arc_path(path, affine); + path_out.push_back(path); + + // draw frame? + if (gen_isometric_frame.get_value()) { + gen_iso_frame_paths(path_out, affine); + } + + // draw axes? + if (draw_axes.get_value()) { + gen_axes_paths(path_out, affine); + } + + return 0; +} + +void evalSteinerEllipse(Geom::Point const &pCenter, Geom::Point const &pCenter_Pt2, Geom::Point const &pPt0_Pt1, + const double &angle, Geom::Point &pRes) +{ + // formula for the evaluation of points on the steiner ellipse using parameter angle + pRes = pCenter + pCenter_Pt2 * cos(angle) + pPt0_Pt1 * sin(angle) / sqrt(3); +} + +int LPEPts2Ellipse::genSteinerEllipse(std::vector const &pts, bool gen_inellipse, + Geom::PathVector &path_out) +{ + // take the first 3 vertices for the edges + if (pts.size() < 3) { + return -1; + } + // calc center + Geom::Point pCenter = (pts[0] + pts[1] + pts[2]) / 3; + // calc main directions of affine triangle + Geom::Point f1 = pts[2] - pCenter; + Geom::Point f2 = (pts[1] - pts[0]) / sqrt(3); + + // calc zero angle t0 + const double denominator = dot(f1, f1) - dot(f2, f2); + double t0 = 0; + if (fabs(denominator) > 1e-12) { + const double cot2t0 = 2.0 * dot(f1, f2) / denominator; + t0 = atan(cot2t0) / 2.0; + } + + // calc relative points of main axes (for axis directions) + Geom::Point p0(0, 0), pRel0, pRel1; + evalSteinerEllipse(p0, pts[2] - pCenter, pts[1] - pts[0], t0, pRel0); + evalSteinerEllipse(p0, pts[2] - pCenter, pts[1] - pts[0], t0 + M_PI_2, pRel1); + Geom::Coord l0 = pRel0.length(); + Geom::Coord l1 = pRel1.length(); + + // basic rotation + double a0 = atan2(pRel0); + + bool swapped = false; + + if (l1 > l0) { + std::swap(l0, l1); + a0 += M_PI_2; + swapped = true; + } + + // the steiner inellipse is just scaled down by 2 + if (gen_inellipse) { + l0 /= 2; + l1 /= 2; + } // rotation angle based on user provided rot_axes to position the vertices const double rot_angle = -deg2rad(rot_axes); // negative for ccw rotation // build up the affine transformation - Affine affine; - affine*=Rotate(rot_angle); - affine*=Scale(l0,l1); - affine*=HShear(-tan(a1)); - affine*=Rotate(a0); - affine*=Translate(pos); + Geom::Affine affine; + affine *= Geom::Rotate(rot_angle); + affine *= Geom::Scale(l0, l1); + affine *= Geom::Rotate(a0); + affine *= Geom::Translate(pCenter); Geom::Path path; - unit_arc_path(path,affine); + unit_arc_path(path, affine); path_out.push_back(path); // draw frame? - if(gen_isometric_frame.get_value()) { - gen_iso_frame_paths(path_out,affine); + if (gen_isometric_frame.get_value()) { + gen_iso_frame_paths(path_out, affine); } // draw axes? - if(draw_axes.get_value()) { - gen_axes_paths(path_out,affine); + if (draw_axes.get_value()) { + gen_axes_paths(path_out, affine); } return 0; } + /* ######################## */ -} //namespace LivePathEffect +} // 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 : +/* + 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-pts2ellipse.h b/src/live_effects/lpe-pts2ellipse.h index f9fd90109c97d3ad0ff98dd46fa144a9ae0f2fe2..46722aa8678ecd0728934d9c9b75e7b82d80e066 100644 --- a/src/live_effects/lpe-pts2ellipse.h +++ b/src/live_effects/lpe-pts2ellipse.h @@ -24,30 +24,25 @@ namespace Inkscape { namespace LivePathEffect { -enum EllipseMethod { - EM_AUTO, - EM_CIRCLE, - EM_ISONOMETRIC_CIRCLE, - EM_END -}; +enum EllipseMethod { EM_AUTO, EM_CIRCLE, EM_ISOMETRIC_CIRCLE, EM_STEINER_ELLIPSE, EM_STEINER_INELLIPSE, EM_END }; class LPEPts2Ellipse : public Effect { -public: + public: LPEPts2Ellipse(LivePathEffectObject *lpeobject); ~LPEPts2Ellipse() override; - Geom::PathVector doEffect_path (Geom::PathVector const & path_in) override; + Geom::PathVector doEffect_path(Geom::PathVector const &path_in) override; + + private: + LPEPts2Ellipse(const LPEPts2Ellipse &) = delete; + LPEPts2Ellipse &operator=(const LPEPts2Ellipse &) = delete; -private: - LPEPts2Ellipse(const LPEPts2Ellipse&) = delete; - LPEPts2Ellipse& operator=(const LPEPts2Ellipse&) = delete; + int genIsometricEllipse(std::vector const &points_in, Geom::PathVector &path_out); - int genIsometricEllipse (std::vector const & points_in, - Geom::PathVector & path_out); + int genFitEllipse(std::vector const &points_in, Geom::PathVector &path_out); - int genFitEllipse (std::vector const & points_in, - Geom::PathVector & path_out); + int genSteinerEllipse(std::vector const &points_in, bool gen_inellipse, Geom::PathVector &path_out); EnumParam method; BoolParam gen_isometric_frame; @@ -61,8 +56,8 @@ private: std::vector points; }; -} //namespace LivePathEffect -} //namespace Inkscape +} // namespace LivePathEffect +} // namespace Inkscape #endif diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index a6f8021b3cd3db039c08d80e41bb90e3737076e9..a235e60765f7b340e429f4042a985b95cd64f3b1 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -34,6 +34,7 @@ Parameter::Parameter( Glib::ustring label, Glib::ustring tip, param_label(std::move(label)), oncanvas_editable(false), widget_is_visible(true), + widget_is_enabled(true), param_tooltip(std::move(tip)), param_effect(effect) { diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 4ef31427ecac1c11d76cddf7f246718a2cac2843..62684b730848930cf86755412dfe03b2e908f52c 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -63,6 +63,7 @@ public: virtual gchar * param_getSVGValue() const = 0; virtual gchar * param_getDefaultSVGValue() const = 0; virtual void param_widget_is_visible(bool is_visible) {widget_is_visible = is_visible;} + virtual void param_widget_is_enabled(bool is_enabled) {widget_is_enabled = is_enabled;} void write_to_SVG(); virtual void param_set_default() = 0; @@ -89,6 +90,7 @@ public: bool oncanvas_editable; bool widget_is_visible; + bool widget_is_enabled; protected: