simulton / QSchematic

A library that allows creating diagrams such as flowcharts or even proper engineering schematics within a Qt application.
https://simulton.com
MIT License
231 stars 60 forks source link

Fix initial scale factor of View #67

Closed ztywyj closed 4 months ago

ztywyj commented 5 months ago

The default value of _scaleFactor is 1, and the calculated initial zoom is 10. This causes issues with the initial scaling. The default zoom should be 1, and then calculate the initial value of _scaleFactor from there. The result is 0.375804.

ztywyj commented 5 months ago

I'm not sure if this is my issue, but my demo indeed has problems with the initial scaling due to this issue.

Tectu commented 4 months ago

Thanks! I'll be having a look at this over the weekend :)

Tectu commented 4 months ago

I don't seem to be able to reproduce this. Could you provide detailed information on your environment, platform etc. as well as the steps necessary to demonstrate the issue?

ztywyj commented 4 months ago

My Qt version is Qt 5.15.2 MSVC 2019 64-bit. In the compiled demo, when you open it and hold down the Ctrl key while scrolling the mouse wheel, the initial zoom level is unusually large, but it returns to normal after that.

Tectu commented 4 months ago

I... have no idea how we've never noticed this. We can certainly reproduce it. Most likely our consuming applications are initializing the zoom level themselves.

Tectu commented 4 months ago

Had a look at this and you're (obviously) correct. However, I do think that the correct thing to do is to call setZoomValue(1.0) at the end of the View constructor to prevent "code duplication".

Do you want to update your accordingly or should I just commit the fix myself?

ztywyj commented 4 months ago

Sure. Updated.

Tectu commented 4 months ago

Merged - Thanks!