算法在绘图仪GUI组件的自标定尺 [英] Algorithm for self-scaling ruler in plotter GUI component
问题描述
我设计(而不是编程)的医疗数据的数据系列浏览器程序,使用C#/ WPF。有一个主面板,显示数据,与普通鼠标的平移/缩放功能(平移左拖,水平缩放与滚动,垂直自动调整与双击,选择右拖)。
I am designing (not programming) a data-series viewer program for medical data, using C#/WPF. There is one main panel which shows the data, with the common mouse pan/zoom functionality (pan with left drag, horizontal zoom with scroll, vertical auto-fit with double click, selection with right drag).
现在的问题是:我需要在顶部/左,相似,看到在音频编辑(GOLDWAVE,大言不惭),制图(gpsTrackmaker)和ilustration统治者(Photoshop中,Inkscape的)程序垂直和水平网格。此外,这些统治者甚至可配置在大多数绘制的API(MATLAB,GNUPLOT,Matplotlib),甚至办公软件(Excel中,计算器)。
The problem is: I need vertical and horizontal grid with rulers on the top/left, similar to those seen in audio-editing (goldwave, audacity), cartography (gpsTrackmaker) and ilustration (photoshop, inkscape) programs. Besides, these rulers are even configurable in most plotting APIs (Matlab, GNUPlot, Matplotlib) and even office programs (Excel, Calc).
主要的必要,除了被始终是对齐,并调整为内容,是有一个抗杂波算法只绘制刻度标记的最大粒度可能无标签打或隐藏彼此。
The main requisite, besides being always aligned and scaled to content, is to have an "anti-clutter" algorithm which only draws tick labels with the maximum granularity possible without the labels "hitting" or hiding one another.
下面是一个图像显示在Inkscape的同一图形两个缩放级别。第一行显示每百标签。第二行显示的每个十年的标签。
Below is an image showing two zoom levels of the same drawing on Inkscape. The first row shows each hundred labels. The second row shows each decade labels.
现在的问题是:因为这(自动分辨率观看统治者)似乎是在许多方案解决的问题,我应该怎么找/什么是可用的resouces /教程,所以我可以明确规定和实施这样的控制一个适合我的需要?
The question is: "Since this (the auto-resolution of viewing rulers) seems to be a solved problem in many programs, how should I look for / what are the available resouces/tutorials so I can specify and implement such a control that suits my needs?"
我会AP preciate任何建议或例子,pferrably $ P $在C#中,但可以用任何一种语言。
I would appreciate any suggestion or example, preferrably in C#, but could be in any language.
推荐答案
- W =标尺可见protion
- X =范围为W psented(右 - 左)再$ P $
- W =标签宽度
N = w / w的
(标签可以显示的最大数量)
n = W/w
(maximum number of labels you can display)
X = X * w / w
(两个标签之间的最小范围)
x = X*w/W
(minimal range between two labels)
然后,你必须要舍x可在任何幅度更大一些,更酷值1,2或5。
Then you have to round x to some larger, cooler value 1, 2 or 5 in any magnitude.
例如
-
X = 18.4
=>X1 = 20
-
X = 539
=>X1 = 1000
x=18.4
=>x1=20
x=539
=>x1=1000
W1 = X1 / X *宽
(刻度之间的标签宽度,或空格)
w1 = x1/X*W
(label width, or space between ticks)
N1 = W / W1
(滴答数)
这篇关于算法在绘图仪GUI组件的自标定尺的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!