///
/// This file is part of ILNumerics Community Edition.
///
/// ILNumerics Community Edition - high performance computing for applications.
/// Copyright (C) 2006 - 2012 Haymo Kutschbach, http://ilnumerics.net
///
/// ILNumerics Community Edition is free software: you can redistribute it and/or modify
/// it under the terms of the GNU General Public License version 3 as published by
/// the Free Software Foundation.
///
/// ILNumerics Community Edition is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with ILNumerics Community Edition. See the file License.txt in the root
/// of your distribution package. If not, see .
///
/// In addition this software uses the following components and/or licenses:
///
/// =================================================================================
/// The Open Toolkit Library License
///
/// Copyright (c) 2006 - 2009 the Open Toolkit library.
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights to
/// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
/// the Software, and to permit persons to whom the Software is furnished to do
/// so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all
/// copies or substantial portions of the Software.
///
/// =================================================================================
///
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using ILNumerics.Drawing;
using ILNumerics.Exceptions;
using ILNumerics.Drawing.Misc;
using ILNumerics.Drawing.Labeling;
using ILNumerics.Drawing.Interfaces;
namespace ILNumerics.Drawing.Graphs {
///
/// graph for drawings into ILPanel
///
/// Use the ILGraphCollection returned from ILPanel.Graphs and its Add... functions to create new graphs.
public abstract class ILGraph : IDisposable {
#region events
public event ILGraphChangedEvent Changed;
protected virtual void OnChanged(string source) {
if (Changed != null)
Changed(this, new ILGraphChangedEventArgs(source));
}
#endregion
#region members / properties
protected bool m_isReady;
protected ILClippingData m_localClipping;
protected ILClippingData m_globalClipping;
protected GraphType m_graphType;
protected ILPanel m_panel;
protected ILLabel m_label;
///
/// the label of the graph (readonly)
///
public ILLabel Label {
get {
return m_label;
}
}
///
/// data limits of the graphs current data (readonly)
///
public ILClippingData Limits {
get {
return m_localClipping;
}
internal set {
m_localClipping = value;
}
}
///
/// The type of graph (Plot2D, Surf, ImageSC, ...)
///
public GraphType Type {
get {
return m_graphType;
}
}
///
/// The hosting panel
///
public ILPanel Panel {
get {
return m_panel;
}
}
#endregion
#region constructors
internal ILGraph(ILPanel panel, ILClippingData clippingContainer) {
m_panel = panel;
m_localClipping = new ILClippingData();
m_localClipping.Changed += new ILClippingDataChangedEvent(m_localClipping_Changed);
m_globalClipping = clippingContainer;
m_globalClipping.Changed += new ILClippingDataChangedEvent(m_globalClipping_Changed);
// store incoming data arrays as ILArray
//m_sourceArray = sourceArray.CreateReference();
m_label = new ILLabel(m_panel);
m_label.Color = Color.Black;
m_label.Changed += new EventHandler(m_label_Changed);
m_isReady = false;
}
#endregion
#region event handler
protected virtual void m_localClipping_Changed(object sender, ClippingChangedEventArgs e) {
// override this event in derived class, if neccessary
}
protected virtual void m_globalClipping_Changed(object sender, ClippingChangedEventArgs e) {
// override this event in derived class, if neccessary
}
protected virtual void m_label_Changed(object sender, EventArgs e) {
// override this event in derived class, if neccessary
}
#endregion
#region abstract / interface member
///
/// configures all parameters + cache, called before drawing
///
internal abstract void Configure();
///
/// invalidate and recalculate this graphs data, this must be called after changes to relevant graph properties
///
public virtual void Invalidate() {
m_isReady = false;
}
///
/// draws the graph into the panel
///
/// extended drawing properties
public abstract void Draw(ILRenderProperties p);
///
/// clear ressources of the graph
///
public virtual void Dispose() {
m_globalClipping.Changed -= new ILClippingDataChangedEvent(m_globalClipping_Changed);
if (m_label != null) {
m_label.Changed -= m_label_Changed;
m_label.Dispose();
}
}
///
/// determine general type of graph (2D/3D)
///
/// true for 3D graphs (e.g. surf, scene graph) and false for 2D graphs (plot2D)
public abstract bool Is3DGraph();
#endregion
}
}