Python API: Canvas `zoomLevel()` returns different value than set by `setZoomLevel()`?

Just noticed in version 4.3.5, when I do setZoomLevel(1.0) on a canvas instance it zooms to 100% in Krita, just like expected and documented, but when I retrieve the value I just set, zoomLevel() returns 3.3333333333336 instead (value seems to depends on the document dimensions), I had expected it to be 1.0 again.

I wonder if this is a bug or a feature I don’t understand and is this already known? A quick google search didn’t indicate that this is known issue or issue at all.

Can anyone confirm?

Hi

Yes, problem is known :upside_down_face:

But I didn’t yet created a bug for this, and didn’t check if one has been created :sweat_smile:

Grum999

1 Like

Good, I thought it’s just me being stupid.

1 Like

Can either of you make a bug report now and add a link here? I could probably add it to the Beginner Tasks, too.

Was about to but it someone else already reported it :3

https://bugs.kde.org/show_bug.cgi?id=437068

I think we can now safely set it from Reported to Confirmed.

2 Likes

I just took a quick look at the code and from what I can tell, the issue is that the Canvas::zoomLevel() method uses KisZoomManager to get a zoom value via KoZoomHandler that apparently is for a different purpose than KoZoomControler which is used by Canvas::setZoomLevel(qreal) and takes resolution into account internaly.

KoZoomHandler seems to take the zoomed in resolution for X and Y wich includes dpi, multipling it with 100 than dividing it by 100 again when it’s returnd (which looks strange) and again returns this to KoZoomManager which then only takes the X part and returns this as zoom level.

Edit: I just noticed both use KoZoomHandler internally but KoZoomHandler::zoom(), still looks strange to me.

1 Like

Yeah I did the report for the zoom thing.

I do think the values comming in and out should be in the same scale and metric regardless of how it is processed inside.

I tried to expose the case the best I could.

There is also other cases like this around on the API if I recall I reported the ones I found while making tela.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.