plan for introducing new curve widget
Adam C.
nospam at xibo.at
Mon Aug 30 21:21:37 CEST 2010
I've investigated KisCurve a little bit more and I found out, that
KisCurve needs operator= and a copy ctor.
this is impossible on a pure virtual class afaik, so i thought of doing
the following:
create a class with copy ctor and operator = KisCurve
create a pure virtual base class KisCurveBase and corresponding derived
classes.
KisCurve holds instances of every derived class, so that it can copy and
assign.
it also holds KisCurveBase* currentCurve, which would be used to provide
the correct transfer function and friends.
i am not sure, if this is a good design and i am open for improvements :)
thanks,
adam
On Mon, 30 Aug 2010 18:40:47 +0200, <nospam at xibo.at> wrote:
> hi,
> boud asked me to imporve the curve widget, so that it is more versatile.
> i've implemented the gui for a spline, line and freehand curve, on
> xibo.at you can see screenshots. i plan to also add the current
> polynomial
> curve.
>
> now the problem is, that the KisCurveWidget returns a KisCubicCurve.
> KisCubicCurve contains the polynomial implementation. If we have four or
> more different Curves, then we need a new base class KisCurve and 4
> derived classes: KisPolynomialCurve, KisSplineCurve, KisLineCurve and
> KisFreehandCurve.
>
> It wouldn't be possible anymore to pass the curve by value, because
> the subclasses have to overwrite some methods (for instance the
> *transfer(..) ), that in turn means, that we can't keep api compatibility
> and we can't replace all curves in one step. So there won't be new curves
> in 2.3 most probably :(.
>
> so here is a proposition for a plan on how to move:
> o rename KisCubicCurve into KisPolynomialCurve (imo this fits better)
> o Create new classes: KisCurve and derived
> o Rename KisCurveWidget into KisOldCurveWidget (this would trigger
> changes
> in many files, but mostly .ui only)
> o move the new KisCurveWidget and friends to the parent dir
> o Search for KisOldCurveWidget in the code base and look, if something
> has
> to be done if replacing with KisCurveWidget
>
> The new curve base class (KisCurve) would look very much like the current
> KisCubicCurve, but some of the methods would be pure virtual.
> The public interface of KisCurveWidget would be also very similar. in
> fact
> only two methods have to be changed:
> /**
> * @return get a list with all defined points. If you want to know
> what
> * the
> * y value for a given x is on the curve defined by these points, use
> * KisCurve::getCurveValue().
> * you must not delete the object returned by this method
> * @see KisCurve::getCurveValue
> */
> KisCurve* curve();
>
> /**
> * Replace the current curve with a curve specified by the curve
> defined
> * by the control
> * points in @param inlist. The curve will be deleted by this class.
> */
> void setCurve(KisCurve *curve);
>
>
> This is only a proposition, I'm open to any comments, hints and
> criticism.
>
> thanks,
> adam
>
>
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the kimageshop
mailing list