Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Plotter2D.cs @ 13231

Last change on this file since 13231 was 12503, checked in by aballeit, 10 years ago

#2283 added GUI and charts; fixed MCTS

File size: 4.9 KB
Line 
1using System;
2using System.Windows.Controls;
3using System.Windows.Media;
4using Microsoft.Research.DynamicDataDisplay.DataSources;
5using Microsoft.Research.DynamicDataDisplay.Filters;
6using Microsoft.Research.DynamicDataDisplay.PointMarkers;
7using System.ComponentModel.Design.Serialization;
8using System.ComponentModel;
9using System.Windows;
10using Microsoft.Research.DynamicDataDisplay.Common;
11using System.Collections.Generic;
12using Microsoft.Research.DynamicDataDisplay.ViewportConstraints;
13using System.Diagnostics;
14
15namespace Microsoft.Research.DynamicDataDisplay
16{
17  /// <summary>Control for plotting 2d images</summary>
18  public class Plotter2D : Plotter
19  {
20    /// <summary>
21    /// Initializes a new instance of the <see cref="Plotter2D"/> class.
22    /// </summary>
23    public Plotter2D()
24      : base(PlotterLoadMode.Normal)
25    {
26      InitViewport();
27    }
28
29    private void InitViewport()
30    {
31      viewportPanel = new Canvas();
32      Grid.SetColumn(viewportPanel, 1);
33      Grid.SetRow(viewportPanel, 1);
34
35      viewport = new Viewport2D(viewportPanel, this);
36      if (LoadMode != PlotterLoadMode.Empty)
37      {
38        MainGrid.Children.Add(viewportPanel);
39      }
40    }
41
42    protected Plotter2D(PlotterLoadMode loadMode)
43      : base(loadMode)
44    {
45      if (loadMode != PlotterLoadMode.Empty)
46      {
47        InitViewport();
48      }
49    }
50
51    private Panel viewportPanel;
52    /// <summary>
53    /// Gets or sets the panel, which contains viewport.
54    /// </summary>
55    /// <value>The viewport panel.</value>
56    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
57    public Panel ViewportPanel
58    {
59      get { return viewportPanel; }
60      protected set { viewportPanel = value; }
61    }
62
63    private Viewport2D viewport;
64    private Viewport2dDeferredPanningProxy deferredPanningProxy;
65
66    protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
67    {
68      base.OnRenderSizeChanged(sizeInfo);
69    }
70
71    /// <summary>
72    /// Gets the viewport.
73    /// </summary>
74    /// <value>The viewport.</value>
75    [NotNull]
76    public Viewport2D Viewport
77    {
78      get
79      {
80        bool useDeferredPanning = false;
81        if (CurrentChild != null)
82        {
83          DependencyObject dependencyChild = CurrentChild as DependencyObject;
84          if (dependencyChild != null)
85          {
86            useDeferredPanning = Viewport2D.GetUseDeferredPanning(dependencyChild);
87          }
88        }
89
90        if (useDeferredPanning)
91        {
92          if (deferredPanningProxy == null)
93          {
94            deferredPanningProxy = new Viewport2dDeferredPanningProxy(viewport);
95          }
96          return deferredPanningProxy;
97        }
98
99        return viewport;
100      }
101      protected set { viewport = value; }
102    }
103
104    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
105    public double ViewportClipToBoundsEnlargeFactor
106    {
107      get { return viewport.ClipToBoundsEnlargeFactor; }
108      set { viewport.ClipToBoundsEnlargeFactor = value; }
109    }
110
111    /// <summary>
112    /// Gets or sets the data transform.
113    /// </summary>
114    /// <value>The data transform.</value>
115    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
116    public DataTransform DataTransform
117    {
118      get { return viewport.Transform.DataTransform; }
119      set { viewport.Transform = viewport.Transform.WithDataTransform(value); }
120    }
121
122    /// <summary>
123    /// Gets or sets the transform.
124    /// </summary>
125    /// <value>The transform.</value>
126    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
127    public CoordinateTransform Transform
128    {
129      get { return viewport.Transform; }
130      set { viewport.Transform = value; }
131    }
132
133    /// <summary>
134    /// Fits to view.
135    /// </summary>
136    public void FitToView()
137    {
138      viewport.FitToView();
139    }
140
141    /// <summary>
142    /// Gets or sets the visible area rectangle.
143    /// </summary>
144    /// <value>The visible.</value>
145    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
146    public DataRect Visible
147    {
148      get { return viewport.Visible; }
149      set { viewport.Visible = value; }
150    }
151
152    /// <summary>
153    /// Gets or sets the domain - maximal value of visible area.
154    /// </summary>
155    /// <value>The domain.</value>
156    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
157    public DataRect Domain
158    {
159      get { return viewport.Domain; }
160      set { viewport.Domain = value; }
161    }
162
163    /// <summary>
164    /// Gets the constraints being applied to viewport.
165    /// </summary>
166    /// <value>The constraints.</value>
167    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
168    public ConstraintCollection Constraints
169    {
170      get { return viewport.Constraints; }
171    }
172
173    /// <summary>
174    /// Gets the fit to view constraints being applied to viewport in 'fit to view' state.
175    /// </summary>
176    /// <value>The fit to view constraints.</value>
177    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
178    public ConstraintCollection FitToViewConstraints
179    {
180      get { return viewport.FitToViewConstraints; }
181    }
182  }
183}
Note: See TracBrowser for help on using the repository browser.