using System;
using System.Windows.Controls;
using System.Windows.Media;
using Microsoft.Research.DynamicDataDisplay.DataSources;
using Microsoft.Research.DynamicDataDisplay.Filters;
using Microsoft.Research.DynamicDataDisplay.PointMarkers;
using System.ComponentModel.Design.Serialization;
using System.ComponentModel;
using System.Windows;
using Microsoft.Research.DynamicDataDisplay.Common;
using System.Collections.Generic;
using Microsoft.Research.DynamicDataDisplay.ViewportConstraints;
using System.Diagnostics;
namespace Microsoft.Research.DynamicDataDisplay
{
/// Control for plotting 2d images
public class Plotter2D : Plotter
{
///
/// Initializes a new instance of the class.
///
public Plotter2D()
: base(PlotterLoadMode.Normal)
{
InitViewport();
}
private void InitViewport()
{
viewportPanel = new Canvas();
Grid.SetColumn(viewportPanel, 1);
Grid.SetRow(viewportPanel, 1);
viewport = new Viewport2D(viewportPanel, this);
if (LoadMode != PlotterLoadMode.Empty)
{
MainGrid.Children.Add(viewportPanel);
}
}
protected Plotter2D(PlotterLoadMode loadMode)
: base(loadMode)
{
if (loadMode != PlotterLoadMode.Empty)
{
InitViewport();
}
}
private Panel viewportPanel;
///
/// Gets or sets the panel, which contains viewport.
///
/// The viewport panel.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Panel ViewportPanel
{
get { return viewportPanel; }
protected set { viewportPanel = value; }
}
private Viewport2D viewport;
private Viewport2dDeferredPanningProxy deferredPanningProxy;
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
}
///
/// Gets the viewport.
///
/// The viewport.
[NotNull]
public Viewport2D Viewport
{
get
{
bool useDeferredPanning = false;
if (CurrentChild != null)
{
DependencyObject dependencyChild = CurrentChild as DependencyObject;
if (dependencyChild != null)
{
useDeferredPanning = Viewport2D.GetUseDeferredPanning(dependencyChild);
}
}
if (useDeferredPanning)
{
if (deferredPanningProxy == null)
{
deferredPanningProxy = new Viewport2dDeferredPanningProxy(viewport);
}
return deferredPanningProxy;
}
return viewport;
}
protected set { viewport = value; }
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public double ViewportClipToBoundsEnlargeFactor
{
get { return viewport.ClipToBoundsEnlargeFactor; }
set { viewport.ClipToBoundsEnlargeFactor = value; }
}
///
/// Gets or sets the data transform.
///
/// The data transform.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public DataTransform DataTransform
{
get { return viewport.Transform.DataTransform; }
set { viewport.Transform = viewport.Transform.WithDataTransform(value); }
}
///
/// Gets or sets the transform.
///
/// The transform.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public CoordinateTransform Transform
{
get { return viewport.Transform; }
set { viewport.Transform = value; }
}
///
/// Fits to view.
///
public void FitToView()
{
viewport.FitToView();
}
///
/// Gets or sets the visible area rectangle.
///
/// The visible.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public DataRect Visible
{
get { return viewport.Visible; }
set { viewport.Visible = value; }
}
///
/// Gets or sets the domain - maximal value of visible area.
///
/// The domain.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public DataRect Domain
{
get { return viewport.Domain; }
set { viewport.Domain = value; }
}
///
/// Gets the constraints being applied to viewport.
///
/// The constraints.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ConstraintCollection Constraints
{
get { return viewport.Constraints; }
}
///
/// Gets the fit to view constraints being applied to viewport in 'fit to view' state.
///
/// The fit to view constraints.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ConstraintCollection FitToViewConstraints
{
get { return viewport.FitToViewConstraints; }
}
}
}