Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GaussianProcessTuning/ILNumerics.2.14.4735.573/Drawing/Shapes/ILPoints.cs @ 9407

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

#1967: ILNumerics source for experimentation

File size: 8.0 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.Drawing.Misc;
46using ILNumerics.Drawing.Graphs; 
47using ILNumerics.Drawing.Interfaces;
48using ILNumerics.Drawing.Shapes;
49using ILNumerics.Exceptions;
50using ILNumerics;
51
52namespace ILNumerics.Drawing.Shapes {
53    /// <summary>
54    /// points rendering shape, to be used in scene graphs
55    /// </summary>
56    public class ILPoints : ILCompositeShape<C4bV3f> {
57
58        #region attributes
59        int m_width;
60        #endregion
61
62        #region properties
63        /// <summary>
64        /// size (of all points)
65        /// </summary>
66        public int Width {
67            get { return m_width; }
68            set {
69                m_width = value;
70                OnChanged();
71            }
72        }
73        #endregion
74
75        #region constructors
76        /// <summary>
77        /// create new points
78        /// </summary>
79        /// <param name="panel">panel hosting the scene graph</param>
80        /// <param name="numPoints">number of points to create</param>
81        public ILPoints (ILPanel panel, int numPoints)
82            : base (panel, numPoints, 1) {
83            m_fillColor = Color.Black;
84            m_width = 4;
85            m_shading = ShadingStyles.Flat;
86            //// colors
87            //ILColorEnumerator colors = new ILColorEnumerator();
88            //for (int i = 0; i < numPoints; i++) {
89            //    m_vertices[i].Color = colors.NextColor();
90            //}
91        }
92        ///// <summary>
93        ///// create point collection
94        ///// </summary>
95        ///// <param name="panel">panel hosting the scene graph</param>
96        ///// <param name="data">numeric matrix with 1,2 or 3 rows, holding X,Y and Z values respectively</param>
97        ///// <param name="colors">3 rowed matrix with RGB values in columns. Values must lay in range 0...255.
98        ///// If a 4th row is provided, it specifys the alpha value for the points (0...255). Otherwise the points will
99        ///// be fully opaque. </param>
100        //public ILPoints (ILPanel panel, ILBaseArray data, ILBaseArray colors)
101        //    : base (panel, data.Dimensions[1],1) {
102        //        using (ILScope.Enter(data, colors)) {
103        //            ILArray<float> fData;
104        //            #region x coords
105        //            if (data != null) {
106        //                if (data is ILArray<float>)
107        //                    fData = (ILArray<float>)data;
108        //                else
109        //                    fData = ILNumerics.ILMath.tosingle(data);
110        //                switch (fData.Dimensions[0]) {
111        //                    case 0:
112        //                        break;
113        //                    case 1:
114        //                        for (int i = 0; i < m_vertCount; i++) {
115        //                            m_vertices[i].XPosition = fData.GetValue(i);
116        //                        }
117        //                        break;
118        //                    case 2:
119        //                        for (int i = 0; i < m_vertCount; i++) {
120        //                            m_vertices[i].XPosition = fData.GetValue(0, i);
121        //                            m_vertices[i].YPosition = fData.GetValue(1, i);
122        //                        }
123        //                        break;
124        //                    default:
125        //                        for (int i = 0; i < m_vertCount; i++) {
126        //                            m_vertices[i].XPosition = fData.GetValue(0, i);
127        //                            m_vertices[i].YPosition = fData.GetValue(1, i);
128        //                            m_vertices[i].ZPosition = fData.GetValue(2, i);
129        //                        }
130        //                        break;
131        //                }
132        //            }
133        //            #endregion
134
135        //            #region colors
136        //            if (colors == null) {
137        //                // initialize as dark blue, fully opaque
138        //                for (int i = 0; i < m_vertCount; i++) {
139        //                    m_vertices[i].Color = Color.DarkBlue;
140        //                }
141        //            } else if (colors.IsScalar && colors is ILDenseArray<Color>) {
142        //                Color col = (colors as ILDenseArray<Color>).GetValue(0);
143        //                for (int i = 0; i < m_vertCount; i++) {
144        //                    m_vertices[i].Color = Color.DarkBlue;
145        //                }
146        //            } else {
147        //                ILArray<byte> bCols;
148        //                if (!colors.IsMatrix || !colors.IsNumeric || (colors.Dimensions[0] != 3 && colors.Dimensions[0] != 4)) {
149        //                    throw new ILArgumentException("invalid argument: colors must be numeric matrix, 3 rows with R,G,B values!");
150        //                }
151        //                if (colors is ILArray<byte>)
152        //                    bCols = (ILArray<byte>)colors;
153        //                else
154        //                    bCols = ILNumerics.ILMath.tobyte(colors);
155        //                if (colors.Dimensions[0] == 3) {
156        //                    for (int i = 0; i < m_vertCount; i++) {
157        //                        m_vertices[i].Color = Color.FromArgb(bCols.GetValue(0, i), bCols.GetValue(1, i), bCols.GetValue(2, i));
158        //                    }
159        //                } else {
160        //                    for (int i = 0; i < m_vertCount; i++) {
161        //                        m_vertices[i].Color = Color.FromArgb(bCols.GetValue(3, i), bCols.GetValue(0, i), bCols.GetValue(1, i), bCols.GetValue(2, i));
162        //                    }
163        //                }
164        //            }
165        //            #endregion
166        //            m_width = 4;
167        //            m_shading = ShadingStyles.Interpolate;
168        //        }
169        //}
170        #endregion
171
172    }
173}
Note: See TracBrowser for help on using the repository browser.