2012-07-18 19 views
4

我正在测量实验室工作,我需要在c#中为圆度仪设备开发一个软件,我已经开始了,而且我发现了一个问题,我需要软件来显示实时图形正在做的测量,因为我需要使用像Mscharts或Zedgraph这样的库,这对于刷新信息非常快,并且支持像Polar或雷达这样的圆图,尤其是极坐标图。 我在大多数图书馆看到的问题是,他们都缺乏对圆图的支持,并且相对较慢。 有没有人有我可以使用lybrary的消化?c#用于圆度仪软件图形的库是什么?

谢谢你的帮助。 PS:软件应该显示的图形像这样的: enter image description here

enter image description here The final software should be like this one

+0

我认为你要找的是算法。您需要的软件似乎已经可以从ABTech,Inc.获得 – 2012-07-18 18:29:05

+0

实时垃圾收集语言是不可能的。也许你只是在寻找真正快速的东西?AND:如果它应该完全类似于该软件,那么为什么该软件不是解决方案? – 2012-07-18 18:30:20

+1

它可能成本> $ 0 – 2012-07-18 18:32:09

回答

1

我会用GDI(+)渲染它们(在winforms应用程序中)。

是的,这是基本的线条画,但它会足够强大,你给的例子。你需要刷新你的高中数学,但它会给你很多的输出控制,它会很快。

+0

但它没有给出绘制图形的圆度的估计。 – 2012-07-18 18:34:14

+0

@Mare:这个问题在哪里问? – 2012-07-18 19:09:29

+0

也许标题误导 – 2012-07-18 19:13:34

1

不知道这将有助于与否。 Xceed Charts在他们的高级部分谈到做极地图表。不幸的是,他们没有提供任何图片,所以你应该与他们的销售人员交谈,看看你是否可以得到评估版本。

1

考虑使用roguewave IMSL数字NET库

homepage of the IMSL numerical .NET library

Examples of graph, resembling what you have posted above

特别是极地的情节好像是什么您这里需要。

+0

这可能是我的解决方案,你有什么想法,花费多少钱?我在他们的主页上找不到这些信息 – WillKraemer 2012-07-18 19:40:25

+0

@WillKraemer - 您需要创建一个账户并要求报价。查看右侧的“开始”菜单。 – 2012-07-18 19:45:59

+0

对不起,我不知道他们的价格。 – 2012-07-18 19:46:12

1

我很惊讶ZedGraph不支持开箱即用的极坐标图,而且在线的例子很少。使用this guildline,我用C#中的ZedGraph创建了我自己的极坐标图。我希望WillKraemer已经解决了他的问题(4年过去了),并且其他人发现我的实现有用。

首先是ZedGraphControl初始化:

 myZg = new ZedGraphControl(); 
     GraphPane myPane = myZg.GraphPane; 

     // Init lists 
     RadarPointList dseries1 = new RadarPointList(); 
     RadarPointList dseries2 = new RadarPointList(); 

     // Maximize available space in pane 
     myPane.Legend.Position = LegendPos.InsideTopLeft; 
     myPane.Title.IsVisible = false; 
     myPane.XAxis.IsVisible = false; 
     myPane.YAxis.IsVisible = false; 
     myPane.Border.IsVisible = false; 
     myPane.Chart.Border.IsVisible = false; 
     myPane.Margin.All = 0; 

     // Create concentric grid with 30 degrees spacing & add corresponding labels 
     for (double i = 0; i < 36; i+=3.0) 
     { 
      TextObj gridlbs = new TextObj((i * 10.0).ToString("0°"), (radius + 10.0) * Math.Cos((i * 10.0 * Math.PI)/180.0), (radius + 10.0) * Math.Sin((i * 10.0 * Math.PI)/180.0)); 
      gridlbs.FontSpec.Border.IsVisible = false; 
      LineObj gridlns = new LineObj(0, 0, radius * Math.Cos((i * 10.0 * Math.PI)/180.0), radius * Math.Sin((i * 10.0 * Math.PI)/180.0)); 

      myPane.GraphObjList.Add(gridlbs); 
      myPane.GraphObjList.Add(gridlns); 
     } 

     // Draw circular grid, 5 should look okay 
     for (double i = (radius/5.0); i <= radius; i += (radius/5.0)) 
     { 
      EllipseObj gridcrl = new EllipseObj(-i, i, 2.0 * i, 2.0 * i); 
      gridcrl.ZOrder = ZOrder.E_BehindCurves; 
      myPane.GraphObjList.Add(gridcrl); 
     } 

     // Make sure the pane is big enough to fit the labels around the polar plot 
     myPane.XAxis.Scale.Min = -(radius + 20.0); 
     myPane.XAxis.Scale.Max = (radius + 20.0); 
     myPane.YAxis.Scale.Min = -(radius + 20.0); 
     myPane.YAxis.Scale.Max = (radius + 20.0); 

     _selectedRadius = radius; 
     // Keep X & Y axis in the correct ratio to avoid distorting polar circle 
     myZg_Resize((object)"Startup", EventArgs.Empty); 
     myZg.Resize += new EventHandler(myZg_Resize); 
     myZg.ZoomEvent += new ZedGraphControl.ZoomEventHandler(myZg_ZoomEvent2); 

     // Draw snailly curves (example) 
     for (int i = 0; i < 360; i++) 
     { 
      double r = (double)i/360.0 * radius; 
      PointPair pt = new PointPair(PointPair.Missing, r, null); 
      dseries1.Add(pt); 
      PointPair pt2 = new PointPair(PointPair.Missing, radius - r, null); 
      dseries2.Add(pt2); 
     } 

     // Curves are somple LineItem 
     FirstCurve = myPane.AddCurve("Snail", dseries1, Color.Blue, SymbolType.None); 
     SecondCurve = myPane.AddCurve("antiSnail", dseries2, Color.Red, SymbolType.None); 

     // Rotate the lists to aling with labels 
     dseries1.Rotation = 0; 
     dseries2.Rotation = 0; 

我必须确保当窗体/控件调整大小的图形不失真,所以我说这Resize事件:

protected void myZg_Resize(object sender, EventArgs e) 
    { 
     GraphPane pane = myZg.GraphPane; 
     myZg.AxisChange(); 
     bool IsXMin = (pane.Rect.Width < pane.Rect.Height) ? true : false; 
     if (IsXMin) 
     { 
      // Scale based on X (width) 
      pane.XAxis.Scale.Max = (radius + 20.0); pane.XAxis.Scale.Min = -(radius + 20.0); 
      double xPixPerUnit = (double)pane.Chart.Rect.Width/(pane.XAxis.Scale.Max - pane.XAxis.Scale.Min); 
      pane.YAxis.Scale.Max = (double)pane.Chart.Rect.Height/xPixPerUnit/2.0; 
      pane.YAxis.Scale.Min = -pane.YAxis.Scale.Max; 
      myZg.AxisChange(); 
     } 
     else 
     { 
      // Scale based on Y (height) 
      pane.YAxis.Scale.Max = (radius + 20.0); pane.YAxis.Scale.Min = -(radius + 20.0); 
      double yPixPerUnit = (double)pane.Chart.Rect.Height/(pane.YAxis.Scale.Max - pane.YAxis.Scale.Min); 
      pane.XAxis.Scale.Max = (double)pane.Chart.Rect.Width/yPixPerUnit/2.0; 
      pane.XAxis.Scale.Min = -pane.XAxis.Scale.Max; 
      myZg.AxisChange(); 
     } 
    } 

此外,我决定阻止任何缩放动作的用户:

protected void myZg_ZoomEvent2(ZedGraphControl sender, ZoomState oldState, ZoomState newState) 
    { 
     myZg_Resize("zoomevent", EventArgs.Empty); 
    } 

输出看起来像下面的图片:

enter image description here

建议随时欢迎!