简体   繁体   English

WxPython缩放技术

[英]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, 到目前为止,我还以为

  • There are lines, rectangles and texts inside rectangles within this diagram. 在此图中,矩形内有线条,矩形和文本。 So maybe I could increase/decrease their length/size with the chosen mouse event. 因此,也许可以通过选择鼠标事件来增加/减少它们的长度/大小。 But it is hard to keep it balanced because rectangles are connected with lines their angles should not change, and texts inside the rectanges should stay in the middle of them. 但是很难保持平衡,因为矩形是用直线连接的,其角度不应改变,矩形内部的文本应保留在矩形的中间。
  • Other method I thought of doing is to search for a built-in zoom method. 我想到的另一种方法是搜索内置的缩放方法。 Which I heard about something like 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM