[英]WxPython zooming technique
I am developing a wxpython project where I am drawing a diagram on to a panel that I need to be able to zoom in/out to this diagram(a directed acyclic graph in my case). 我正在开发一个wxpython项目,在其中将图绘制到面板上,我需要能够放大/缩小该图(在我的情况下为有向无环图)。 I will achieve this by mouse scroll when the cursor is on the panel, however that is not a part of my question. 当光标位于面板上时,我将通过鼠标滚动来实现此目的,但这不是我的问题。 I need an advice from an experienced person about the method I am using for zooming. 我需要有经验的人对我正在使用的缩放方法的建议。 So far I thought as doing, 到目前为止,我还以为
Scale
. 我听说过Scale
东西。 However I have some questions about this method. 但是我对此方法有一些疑问。 Will this work on vector drawings(like mine) rather than images. 这将适用于矢量绘图(例如我的绘图)而不是图像。 And will it be scaling only the panel I chose and not the whole screen ? 它将仅缩放我选择的面板而不缩放整个屏幕吗? After I hear your advice about this, I will look deeper into this, but now I am a bit clueless. 在听到您对此的建议之后,我将对此进行更深入的研究,但是现在我有点头绪。 Sorry if my question is too theoretical . 对不起,如果我的问题过于理论化 。 But I felt I needed help in the area. 但是我觉得我需要该地区的帮助。 Thanks in advance. 提前致谢。
Note: Zooming not necessarily applied by scrolling. 注意:缩放不一定适用于滚动。
Note2: My research also led me to FloatCanvas
. 注意2:我的研究也使我进入了FloatCanvas
。 Is this suitable to my needs ? 这适合我的需求吗?
Yes, from your description FloatCanvas
would certainly meet your needs. 是的,根据您的描述, FloatCanvas
当然可以满足您的需求。
Another possibility to consider would be the wx.GraphicsContext
and related classes. 考虑的另一种可能性是wx.GraphicsContext
和相关类。 It is vector-based (instead of raster) and supports the use of a transformation matrix which would make zooming, rotating, etc. very easy. 它是基于矢量的(而不是栅格),并支持使用转换矩阵,这将使缩放,旋转等非常容易。 However, the actual drawing and management of the shapes and such would probably require more work for you than using FloatCanvas
. 但是,与使用FloatCanvas
相比,实际的图形绘制和形状管理可能需要更多的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.