Mirroring of the canvas
Dmitry Kazakov
dimula73 at gmail.com
Wed Mar 24 22:16:30 CET 2010
We have four coordinate systems:
1) image
2) viewport - scaled image coordinates (takes into account zoom-level and
image resolution)
3) widget ~ viewport transalted on "origin"
4) canvas ~ widget translated on "offset"
I'm very unsure about 3 and 4. What do they do actually? And why can't we
join both translations?
As for mirroring, i think all the translation between 1<->2 should be moved
into KisCanvas2, then you need to change only two functions and a flip flag
to get mirroring.
On Wed, Mar 24, 2010 at 10:30 PM, LukasT.dev at gmail.com <lukast.dev at gmail.com
> wrote:
> Hello,
>
> I'm trying to implement the mirroring of the canvas. It is a feature where
> we
> mirror the projection of the canvas instead of the mirroring the device
> when
> you want to see mirrored image of your paint. Similar feature is in
> mypaint.
>
> I started with mirroring the events. There are some coordinate systems in
> canvas. First one is widget space, it is possition of the input device in
> widget pixels. Then there is document space, so when you paint, the event
> from
> the widget is converted by few function calls to document coordinates.
>
> First the coordinates are translated by scrolling offset (when you move
> with
> slider in bigger zoom ) and by document origin (it is the distance from the
> canvas top left corner to image top left corner). Then the coordinates
> are transformed to document coordinates with zoom.
>
> I mirror the coordinates on document level, that means that when you draw
> stroke, the document is updated in the mirrored part. Document adds the
> "dirty
> rects on document level" so the projection is computed properly because so
> far
> projection does not know about mirroring.
>
> Next step was to mirror the canvas. I mirrored the projection by QPainter
> as Cyrille suggested using transformation like scale(-1,1) and
> translate(width,0)
>
> Now the problems started to show up. The projection with mirrored canvas
> is
> not updated properly. So I started to investigate.
> In KisCanvas2::updateCanvasProjection I tried to mirror the vRect
> rectangle.
> The rc rectangle update the projection and the vRect is responsible to for
> proper updates calls.
>
> So far I have these problems:
> the canvas is not updated properly, I mirrored the vRect like this
> vRect = QRect(image()->width() - vRect.x()
> vRect.width(),vRect.top(),vRect.width(), vRect.height());
>
> but that is not correct. The canvas is erased in QRect
> KisPrescaledProjection::preScale(const QRect & rc)
>
>
> If I call just update(), when the whole canvas is updated, it is correct.
> What I miss there?
>
> Question: how to solve it? I don't know much about projection even I spent
> a
> lot of time looking at the code. Dmitry, what do you think I need to do?
> Is it correct to mirror the QPainter or should we mirror on the projection
> level? If so, what has to be mirrored?
>
> Another problem. When we zoom and scroll vertically, part of the image is
> erased. It seems that when we mirror the image, the hidden part because
> actually visible and in the projection it is represented by transparent
> pixel.
> Is that what is happening? Any hints where and how to fix it?
>
> Here is the patch I have for now
> http://valdyas.org/~lukast/mirroring.patch<http://valdyas.org/%7Elukast/mirroring.patch>
> _______________________________________________
> kimageshop mailing list
> kimageshop at kde.org
> https://mail.kde.org/mailman/listinfo/kimageshop
>
--
Dmitry Kazakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kimageshop/attachments/20100325/04fbaf8b/attachment.htm
More information about the kimageshop
mailing list