Where to store data between strokes
cberger at cberger.net
Tue Jun 29 00:08:10 CEST 2010
On Monday 28 June 2010, LukasT.dev at gmail.com wrote:
> I would like to ask you for advice and your opinion about where to store
> data related to strokes so that paintOps can access them.
> E.g. harmony brush engine stores list of nodes between strokes so that new
> stroke can be connected with old stroke. I need to store QVector<QPointF>
> somewhere and I need to be able to add and read points from it.Not just per
> stroke in paintop but for some longer moment as in Harmony e.g. til the
> user changes the tool or paintop - KisPaintOpSettings::activate() method
Why if the user change the tool, would that reset the paintop ? Most common
use case: changing to zoom and pan tool. And I am not sure that selecting the
eraser should reset the paintop.
In other word, we would need some kind of "reset" button (that could be used
for the ink depletion of the hairy brush too... but here I am digressing :) )
> One problem for this solution is undo. If the user do undo, the data,
> should be undone too. But let's say this is nice to have feature. First we
> need to be able to store data somewhere.
I don't think it is nice to have, I think it is *must* have and therefor needs
to be taken into account in the design of that storage.
> Also Pentalis needs to store some bitmap between strokes to avoid its
> recreation for scratch off algorithm.
> I was thinking about using KisPaintOpSettings but we pass it as const
> 1. Can we change the API and make it writable? or
> 2 We create new API with one other object which would be used to store
> between strokes data?
> 3. Do you think that tool could be responsible for this? If so, how?
I think we need a new API. And the tool would need to know about it to put it
in the undo information. I see KisPaintOpSettings as permanent settings that
the user save on the disk.
One solution could be to extend KisDistanceInformation (and rename it) to
allow paintop to save custom information (either by inheritance or use of
QVariant). And we could add a new function, called
KisDistanceInformation::startNewStroke() to reset distance and spacing.
Main drawback is that I wanted KisDistanceInformation to be as lightweight as
possible, and making the suggested change would make it much more heavyweight.
An other possibility is to add to paintAt/paintLine/paintBezierCurve an other
parameter that would be the class with the storage.
More information about the kimageshop