- Timestamp:
- 01/29/09 21:36:46 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj
r1182 r1187 83 83 <Compile Include="DefaultLabelProvider.cs" /> 84 84 <Compile Include="Grid.cs" /> 85 <Compile Include="HorizontalLineShape.cs" /> 85 86 <Compile Include="ILabelProvider.cs" /> 86 87 <Compile Include="IMouseEventListener.cs" /> 88 <Compile Include="OptionsDialog.cs"> 89 <SubType>Form</SubType> 90 </Compile> 91 <Compile Include="OptionsDialog.Designer.cs"> 92 <DependentUpon>OptionsDialog.cs</DependentUpon> 93 </Compile> 87 94 <Compile Include="PanListener.cs" /> 88 95 <Compile Include="TextShape.cs" /> … … 138 145 <SubType>Designer</SubType> 139 146 </EmbeddedResource> 147 <EmbeddedResource Include="OptionsDialog.resx"> 148 <DependentUpon>OptionsDialog.cs</DependentUpon> 149 </EmbeddedResource> 140 150 </ItemGroup> 141 151 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs
r1059 r1187 31 31 private void InitializeComponent() 32 32 { 33 this.components = new System.ComponentModel.Container(); 33 34 this.canvas = new HeuristicLab.Visualization.CanvasUI(); 35 this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); 36 this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 37 this.contextMenuStrip1.SuspendLayout(); 34 38 this.SuspendLayout(); 35 39 // … … 43 47 this.canvas.TabIndex = 0; 44 48 this.canvas.Text = "canvas"; 49 this.canvas.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseWheel); 50 this.canvas.ContextMenuStripChanged += new System.EventHandler(this.optionsToolStripMenuItem_Click); 45 51 this.canvas.MouseDown += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseDown); 46 this.canvas.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseWheel);47 52 this.canvas.KeyDown += new System.Windows.Forms.KeyEventHandler(this.canvasUI1_KeyDown); 53 // 54 // contextMenuStrip1 55 // 56 this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 57 this.optionsToolStripMenuItem}); 58 this.contextMenuStrip1.Name = "contextMenuStrip1"; 59 this.contextMenuStrip1.Size = new System.Drawing.Size(112, 26); 60 61 // 62 // optionsToolStripMenuItem 63 // 64 this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; 65 this.optionsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 66 this.optionsToolStripMenuItem.Text = "Options"; 67 this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click); 48 68 // 49 69 // LineChart … … 54 74 this.Name = "LineChart"; 55 75 this.Size = new System.Drawing.Size(552, 390); 76 this.contextMenuStrip1.ResumeLayout(false); 56 77 this.ResumeLayout(false); 57 78 … … 61 82 62 83 private CanvasUI canvas; 84 private ContextMenuStrip contextMenuStrip1; 85 private ToolStripMenuItem optionsToolStripMenuItem; 63 86 } 64 87 } -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r1182 r1187 2 2 using System.Collections.Generic; 3 3 using System.Drawing; 4 using System.Drawing.Drawing2D; 4 5 using System.Windows.Forms; 5 6 using HeuristicLab.Core; 6 7 7 8 namespace HeuristicLab.Visualization { 8 public class LinesShape : WorldShape { }9 10 9 public partial class LineChart : ViewBase { 10 internal class LinesShape : WorldShape {} 11 11 12 private readonly IChartDataRowsModel model; 12 13 private int maxDataRowCount; … … 14 15 private double minDataValue; 15 16 private double maxDataValue; 17 private bool minMaxLineEnabled; 18 private MinMaxLineShape minMaxLineShape; 19 private IShape minLineShape; 16 20 17 21 private readonly WorldShape root; … … 45 49 46 50 grid = new Grid(); 51 minMaxLineEnabled = true; 47 52 root.AddShape(grid); 48 53 … … 65 70 root.AddShape(titleShape); 66 71 67 72 minMaxLineShape = new MinMaxLineShape(this.minDataValue, this.maxDataValue, 0, Color.Yellow, 4, DrawingStyle.Solid); 73 root.AddShape(minMaxLineShape); 68 74 canvas.MainCanvas.WorldShape = root; 69 75 canvas.Resize += delegate { UpdateLayout(); }; 70 76 71 77 UpdateLayout(); 72 78 maxDataRowCount = 0; 73 79 this.model = model; 74 80 Item = model; 75 81 76 maxDataRowCount = 0; 82 77 83 //The whole data rows are shown per default 78 zoomFullView = true; 79 minDataValue = Double.PositiveInfinity; 80 maxDataValue = Double.NegativeInfinity; 84 ResetView(); 81 85 } 82 86 … … 97 101 canvas.Width, 98 102 canvas.Height); 99 103 100 104 grid.BoundingBox = linesShape.BoundingBox; 105 106 minMaxLineShape.BoundingBox = linesShape.BoundingBox; 101 107 102 108 yAxis.BoundingBox = new RectangleD(0, … … 173 179 private void SetLineClippingArea(RectangleD clippingArea) { 174 180 linesShape.ClippingArea = clippingArea; 175 181 176 182 grid.ClippingArea = linesShape.ClippingArea; 183 184 minMaxLineShape.ClippingArea = linesShape.ClippingArea; 177 185 178 186 xAxis.ClippingArea = new RectangleD(linesShape.ClippingArea.X1, … … 180 188 linesShape.ClippingArea.X2, 181 189 xAxis.BoundingBox.Y2); 182 190 183 191 yAxis.ClippingArea = new RectangleD(yAxis.BoundingBox.X1, 184 192 linesShape.ClippingArea.Y1, … … 189 197 private void InitLineShapes(IDataRow row) { 190 198 List<LineShape> lineShapes = new List<LineShape>(); 199 if (rowToLineShapes.Count == 0) { 200 minDataValue = Double.PositiveInfinity; 201 maxDataValue = Double.NegativeInfinity; 202 } 191 203 if (row.Count > 0) { 192 204 maxDataValue = Math.Max(row[0], maxDataValue); … … 201 213 minDataValue = Math.Min(row[i], minDataValue); 202 214 } 203 215 minMaxLineShape.YMax = maxDataValue; 216 minMaxLineShape.YMin = minDataValue; 204 217 rowToLineShapes[row] = lineShapes; 205 218 ZoomToFullView(); … … 213 226 } 214 227 215 private readonly IDictionary<IDataRow, List<LineShape>> rowToLineShapes = new Dictionary<IDataRow, List<LineShape>>(); 228 private readonly IDictionary<IDataRow, List<LineShape>> rowToLineShapes = 229 new Dictionary<IDataRow, List<LineShape>>(); 216 230 217 231 // TODO use action parameter … … 220 234 maxDataValue = Math.Max(value, maxDataValue); 221 235 minDataValue = Math.Min(value, minDataValue); 222 236 minMaxLineShape.YMax = maxDataValue; 237 minMaxLineShape.YMin = minDataValue; 223 238 if (index > lineShapes.Count + 1) { 224 239 throw new NotImplementedException(); … … 230 245 maxDataRowCount = row.Count; 231 246 } 232 LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], 0, row.Color, row.Thickness, row.Style); 247 LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], 0, row.Color, row.Thickness, 248 row.Style); 233 249 lineShapes.Add(lineShape); 234 250 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. … … 249 265 canvas.Invalidate(); 250 266 } 267 268 269 public IList<IDataRow> GetRows() { 270 return model.Rows; 271 } 272 251 273 252 274 // TODO use action parameter … … 293 315 294 316 private void canvasUI1_KeyDown(object sender, KeyEventArgs e) { 295 if (e.KeyCode == Keys.Back && historyStack.Count > 1) {317 if (e.KeyCode == Keys.Back && historyStack.Count > 1) { 296 318 historyStack.Pop(); 297 319 298 320 RectangleD clippingArea = historyStack.Peek(); 299 321 300 322 SetNewClippingArea(clippingArea); 301 323 canvas.Invalidate(); … … 305 327 private void canvasUI1_MouseDown(object sender, MouseEventArgs e) { 306 328 Focus(); 307 308 if (ModifierKeys == Keys.Control) { 309 CreateZoomListener(e); 310 } else { 311 CreatePanListener(e); 329 if (e.Button == System.Windows.Forms.MouseButtons.Right) { 330 if (this.ParentForm != null) 331 this.contextMenuStrip1.Show(e.Location.X + this.ParentForm.Location.X, 332 e.Location.Y + this.ParentForm.Location.Y + 50); 333 else { 334 this.contextMenuStrip1.Show(e.Location.X, e.Location.Y); 335 } 336 } 337 else { 338 if (ModifierKeys == Keys.Control) { 339 CreateZoomListener(e); 340 } 341 else { 342 CreatePanListener(e); 343 } 312 344 } 313 345 } … … 362 394 panListener.SetNewClippingArea += SetNewClippingArea; 363 395 panListener.OnMouseUp += delegate { 364 historyStack.Push(linesShape.ClippingArea);365 canvas.MouseEventListener = null;366 };396 historyStack.Push(linesShape.ClippingArea); 397 canvas.MouseEventListener = null; 398 }; 367 399 368 400 canvas.MouseEventListener = panListener; … … 377 409 378 410 #endregion 411 412 private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { 413 var optionsdlg = new OptionsDialog(this); 414 optionsdlg.Show(); 415 } 416 417 public void ApplyChangesToRow(IDataRow row) { 418 foreach (var ls in rowToLineShapes[row]) { 419 ls.LSColor = row.Color; 420 ls.LSThickness = row.Thickness; 421 if (row.Style == DrawingStyle.Dashed) { 422 ls.LSDashStyle = DashStyle.Dash; 423 } 424 else { 425 ls.LSDashStyle = DashStyle.Solid; //default 426 } 427 } 428 canvas.Invalidate(); 429 } 379 430 } 380 431 } -
trunk/sources/HeuristicLab.Visualization/LineChart.resx
r684 r1187 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </resheader> 120 <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 121 <value>17, 17</value> 122 </metadata> 120 123 </root> -
trunk/sources/HeuristicLab.Visualization/LineShape.cs
r980 r1187 21 21 this.boundingBox = new RectangleD(x1, y1, x2, y2); 22 22 this.z = z; 23 this. color = color;24 this. thickness = thickness;23 this.LSColor = color; 24 this.LSThickness = thickness; 25 25 if (style==DrawingStyle.Dashed) { 26 this. dashStyle = DashStyle.Dash;26 this.LSDashStyle = DashStyle.Dash; 27 27 } 28 28 else { 29 this. dashStyle = DashStyle.Solid; //default29 this.LSDashStyle = DashStyle.Solid; //default 30 30 } 31 31 } … … 62 62 /// <param name="clippingArea">rectangle in screen-coordinates to draw</param> 63 63 public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 64 using (Pen pen = new Pen( color, thickness)){65 pen.DashStyle = this. dashStyle;64 using (Pen pen = new Pen(LSColor, LSThickness)){ 65 pen.DashStyle = this.LSDashStyle; 66 66 Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea); 67 67 graphics.DrawLine(pen,screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top); … … 73 73 set { z = value; } 74 74 } 75 76 public Color LSColor { 77 get { return color; } 78 set { color = value; } 79 } 80 81 public int LSThickness { 82 get { return thickness; } 83 set { thickness = value; } 84 } 85 86 public DashStyle LSDashStyle { 87 get { return dashStyle; } 88 set { dashStyle = value; } 89 } 75 90 } 76 91 }
Note: See TracChangeset
for help on using the changeset viewer.