Changeset 981 for trunk/sources
- Timestamp:
- 12/12/08 10:06:10 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r980 r981 9 9 public partial class LineChart : ViewBase { 10 10 private readonly IChartDataRowsModel model; 11 private int maxDataRowCount; 12 private Boolean zoomFullView; 13 private double minDataValue; 14 private double maxDataValue; 11 15 12 16 /// <summary> … … 27 31 28 32 //TODO: correct Rectangle to fit 29 RectangleD clientRectangle = new RectangleD(-1, -1, 1 1, 11);33 RectangleD clientRectangle = new RectangleD(-1, -1, 1, 1); 30 34 canvasUI1.MainCanvas.WorldShape = new WorldShape(clientRectangle, clientRectangle); 31 35 32 36 CreateMouseEventListeners(); 33 37 34 38 this.model = model; 35 39 Item = (IItem)model; 40 maxDataRowCount = 0; 41 //The whole data rows are shown per default 42 zoomFullView = true; 43 minDataValue = Double.PositiveInfinity; 44 maxDataValue = Double.NegativeInfinity; 45 36 46 } 37 47 … … 61 71 row.ValueChanged += OnRowValueChanged; 62 72 row.ValuesChanged += OnRowValuesChanged; 63 73 if (row.Count > maxDataRowCount) 74 maxDataRowCount = row.Count; 75 64 76 InitShapes(row); 65 77 } 66 78 79 private void ZoomToFullView() { 80 if(!zoomFullView) 81 return; 82 RectangleD newClippingArea = new RectangleD(-0.1, 83 minDataValue-((maxDataValue-minDataValue)*0.05), 84 maxDataRowCount-0.9, 85 maxDataValue + ((maxDataValue - minDataValue) * 0.05)); 86 canvasUI1.MainCanvas.WorldShape.ClippingArea = newClippingArea; 87 } 88 67 89 private void InitShapes(IDataRow row) { 90 91 68 92 List<LineShape> lineShapes = new List<LineShape>(); 69 93 if (row.Count > 0) { 94 maxDataValue = Max(row[0], this.maxDataValue); 95 minDataValue = Min(row[0], minDataValue); 96 } 70 97 for (int i = 1; i < row.Count; i++) { 71 98 LineShape lineShape = new LineShape(i - 1, row[i - 1], i, row[i], 0, row.Color, row.Thickness, row.Style); … … 73 100 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. 74 101 canvasUI1.MainCanvas.WorldShape.AddShape(lineShape); 102 maxDataValue = Max(row[i], maxDataValue); 103 minDataValue = Min(row[i], minDataValue); 75 104 } 76 105 77 106 rowToLineShapes[row] = lineShapes; 78 107 ZoomToFullView(); 79 108 canvasUI1.Invalidate(); 109 } 110 111 private double Min(double d, double value) { 112 return d < value ? d : value; 113 } 114 115 private double Max(double d, double value) { 116 return d>value ? d : value; 80 117 } 81 118 … … 90 127 private void OnRowValueChanged(IDataRow row, double value, int index, Action action) { 91 128 List<LineShape> lineShapes = rowToLineShapes[row]; 129 maxDataValue = Max(value, maxDataValue); 130 minDataValue = Min(value, minDataValue); 92 131 93 132 if (index > lineShapes.Count + 1) { … … 97 136 // new value was added 98 137 if (index > 0 && index == lineShapes.Count + 1) { 138 139 if (maxDataRowCount < row.Count) 140 maxDataRowCount = row.Count; 99 141 LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], 0, row.Color, row.Thickness, row.Style); 100 142 lineShapes.Add(lineShape); … … 112 154 lineShapes[index].Y1 = value; 113 155 } 114 156 ZoomToFullView(); 115 157 canvasUI1.Invalidate(); 116 158 } … … 189 231 panListener.StartPoint = startPoint; 190 232 233 this.zoomFullView = false; //user wants to pan => no full view 234 191 235 canvasUI1.Invalidate(); 192 236 }
Note: See TracChangeset
for help on using the changeset viewer.