Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GaussianProcessTuning/ILNumerics.2.14.4735.573/Drawing/Graphs/ILGraph.cs @ 10102

Last change on this file since 10102 was 9102, checked in by gkronber, 12 years ago

#1967: ILNumerics source for experimentation

File size: 6.7 KB
Line 
1///
2///    This file is part of ILNumerics Community Edition.
3///
4///    ILNumerics Community Edition - high performance computing for applications.
5///    Copyright (C) 2006 - 2012 Haymo Kutschbach, http://ilnumerics.net
6///
7///    ILNumerics Community Edition is free software: you can redistribute it and/or modify
8///    it under the terms of the GNU General Public License version 3 as published by
9///    the Free Software Foundation.
10///
11///    ILNumerics Community Edition is distributed in the hope that it will be useful,
12///    but WITHOUT ANY WARRANTY; without even the implied warranty of
13///    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14///    GNU General Public License for more details.
15///
16///    You should have received a copy of the GNU General Public License
17///    along with ILNumerics Community Edition. See the file License.txt in the root
18///    of your distribution package. If not, see <http://www.gnu.org/licenses/>.
19///
20///    In addition this software uses the following components and/or licenses:
21///
22///    =================================================================================
23///    The Open Toolkit Library License
24///   
25///    Copyright (c) 2006 - 2009 the Open Toolkit library.
26///   
27///    Permission is hereby granted, free of charge, to any person obtaining a copy
28///    of this software and associated documentation files (the "Software"), to deal
29///    in the Software without restriction, including without limitation the rights to
30///    use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
31///    the Software, and to permit persons to whom the Software is furnished to do
32///    so, subject to the following conditions:
33///
34///    The above copyright notice and this permission notice shall be included in all
35///    copies or substantial portions of the Software.
36///
37///    =================================================================================
38///   
39
40using System;
41using System.Collections.Generic;
42using System.Text;
43using System.Drawing;
44using ILNumerics.Drawing;
45using ILNumerics.Exceptions;
46using ILNumerics.Drawing.Misc;
47using ILNumerics.Drawing.Labeling;
48using ILNumerics.Drawing.Interfaces;
49
50namespace ILNumerics.Drawing.Graphs {
51    /// <summary>
52    /// graph for drawings into ILPanel
53    /// </summary>
54    /// <remarks>Use the ILGraphCollection returned from ILPanel.Graphs and its Add... functions to create new graphs.</remarks>
55    public abstract class ILGraph : IDisposable {
56
57        #region events
58       
59        public event ILGraphChangedEvent Changed;
60        protected virtual void OnChanged(string source) {
61            if (Changed != null)
62                Changed(this, new ILGraphChangedEventArgs(source));
63        }
64
65        #endregion
66
67        #region members / properties
68        protected bool m_isReady;
69        protected ILClippingData m_localClipping;
70        protected ILClippingData m_globalClipping;
71        protected GraphType m_graphType;
72        protected ILPanel m_panel;
73        protected ILLabel m_label;
74
75        /// <summary>
76        ///  the label of the graph (readonly)
77        /// </summary>
78        public ILLabel Label {
79            get {
80                return m_label;
81            }
82        }
83        /// <summary>
84        /// data limits of the graphs current data (readonly)
85        /// </summary>
86        public ILClippingData Limits {
87            get {
88                return m_localClipping;
89            }
90            internal set {
91                m_localClipping = value;
92            }
93        }
94        /// <summary>
95        /// The type of graph (Plot2D, Surf, ImageSC, ...)
96        /// </summary>
97        public GraphType Type {
98            get {
99                return m_graphType;
100            }
101        }
102        /// <summary>
103        /// The hosting panel
104        /// </summary>
105        public ILPanel Panel {
106            get {
107                return m_panel;
108            }
109        }
110        #endregion
111
112        #region constructors
113       
114        internal ILGraph(ILPanel panel, ILClippingData clippingContainer) {
115            m_panel = panel;
116            m_localClipping = new ILClippingData();
117            m_localClipping.Changed += new ILClippingDataChangedEvent(m_localClipping_Changed);
118            m_globalClipping = clippingContainer;
119            m_globalClipping.Changed += new ILClippingDataChangedEvent(m_globalClipping_Changed);
120            // store incoming data arrays as ILArray<float>
121            //m_sourceArray = sourceArray.CreateReference();
122            m_label = new ILLabel(m_panel);
123            m_label.Color = Color.Black;
124            m_label.Changed += new EventHandler(m_label_Changed);
125            m_isReady = false;
126        }
127
128
129        #endregion
130
131        #region event handler
132       
133        protected virtual void m_localClipping_Changed(object sender, ClippingChangedEventArgs e) {
134            // override this event in derived class, if neccessary
135        }
136        protected virtual void m_globalClipping_Changed(object sender, ClippingChangedEventArgs e) {
137            // override this event in derived class, if neccessary
138        }
139        protected virtual void m_label_Changed(object sender, EventArgs e) {
140            // override this event in derived class, if neccessary
141        }
142
143        #endregion
144
145        #region abstract / interface member
146        /// <summary>
147        /// configures all parameters + cache, called before drawing
148        /// </summary>
149        internal abstract void Configure();
150        /// <summary>
151        /// invalidate and recalculate this graphs data, this must be called after changes to relevant graph properties
152        /// </summary>
153        public virtual void Invalidate() {
154            m_isReady = false;
155        }
156        /// <summary>
157        /// draws the graph into the panel
158        /// </summary>
159        /// <param name="p">extended drawing properties</param>
160        public abstract void Draw(ILRenderProperties p);
161        /// <summary>
162        /// clear ressources of the graph
163        /// </summary>
164        public virtual void Dispose() {
165            m_globalClipping.Changed -= new ILClippingDataChangedEvent(m_globalClipping_Changed);
166            if (m_label != null) {
167                m_label.Changed -= m_label_Changed;
168                m_label.Dispose();
169            }
170        }
171        /// <summary>
172        /// determine general type of graph (2D/3D)
173        /// </summary>
174        /// <returns>true for 3D graphs (e.g. surf, scene graph) and false for 2D graphs (plot2D)</returns>
175        public abstract bool Is3DGraph();
176
177        #endregion
178
179    }
180}
Note: See TracBrowser for help on using the repository browser.