Implementing Magnetic Lasso for Krita

Dmitry Kazakov dimula73 at gmail.com
Mon Mar 25 12:29:00 GMT 2019


Hi, Kuntal!


Path selection tool rather follows a different implementation, starts
> the same by creating a local tool which inherits the KoCreatePathTool,
> which is then passed down to the KisDelegatedTool with local tool as
> delgate, then there is a wrapper around the delegated tool. The wrapper
> gets inherited by KisSelectToolBase, used to implement the corresponding
> selection tool just like the previous one.
>

Yes, there is a tricky way to inherit from the tools. Ideally, we should
have used something like "strategy" design pattern [0] for these tools, but
something went wrong :) And in the end we use another tool as a strategy.
It is done to avoid duplicating bezier curves functionality.

Whether or not to use this "third" way is actually depends on whether you
tool will generate  bezier curves. If you are going to have bezier curves,
then you should reuse the code from KoCreatePathTool. How to use it? This
decision is up to you. You can either reuse it in the current (not very
pretty approach) or just refactor the base tool into some kind of strategy
that will be reused by both KisToolPath and your tool.

[0] - https://en.wikipedia.org/wiki/Strategy_pattern


> The previous attempt to restore the Magnetic Lasso followed the third
> approach, which I don't think _if_ broken should be followed. So taking
> the fact the tool will work the following way,
>

Well, the requirement is not "use this way like here", but "ensure that the
code from KoCreatePathTool is not duplicated" :)


-- 
Dmitry Kazakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20190325/2a8825b1/attachment.html>


More information about the kimageshop mailing list