/// /// 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.Drawing.Misc; using ILNumerics.Drawing.Graphs; using ILNumerics.Drawing.Interfaces; using ILNumerics.Drawing.Shapes; using ILNumerics.Exceptions; using ILNumerics; namespace ILNumerics.Drawing.Shapes { /// /// points rendering shape, to be used in scene graphs /// public class ILPoints : ILCompositeShape { #region attributes int m_width; #endregion #region properties /// /// size (of all points) /// public int Width { get { return m_width; } set { m_width = value; OnChanged(); } } #endregion #region constructors /// /// create new points /// /// panel hosting the scene graph /// number of points to create public ILPoints (ILPanel panel, int numPoints) : base (panel, numPoints, 1) { m_fillColor = Color.Black; m_width = 4; m_shading = ShadingStyles.Flat; //// colors //ILColorEnumerator colors = new ILColorEnumerator(); //for (int i = 0; i < numPoints; i++) { // m_vertices[i].Color = colors.NextColor(); //} } ///// ///// create point collection ///// ///// panel hosting the scene graph ///// numeric matrix with 1,2 or 3 rows, holding X,Y and Z values respectively ///// 3 rowed matrix with RGB values in columns. Values must lay in range 0...255. ///// If a 4th row is provided, it specifys the alpha value for the points (0...255). Otherwise the points will ///// be fully opaque. //public ILPoints (ILPanel panel, ILBaseArray data, ILBaseArray colors) // : base (panel, data.Dimensions[1],1) { // using (ILScope.Enter(data, colors)) { // ILArray fData; // #region x coords // if (data != null) { // if (data is ILArray) // fData = (ILArray)data; // else // fData = ILNumerics.ILMath.tosingle(data); // switch (fData.Dimensions[0]) { // case 0: // break; // case 1: // for (int i = 0; i < m_vertCount; i++) { // m_vertices[i].XPosition = fData.GetValue(i); // } // break; // case 2: // for (int i = 0; i < m_vertCount; i++) { // m_vertices[i].XPosition = fData.GetValue(0, i); // m_vertices[i].YPosition = fData.GetValue(1, i); // } // break; // default: // for (int i = 0; i < m_vertCount; i++) { // m_vertices[i].XPosition = fData.GetValue(0, i); // m_vertices[i].YPosition = fData.GetValue(1, i); // m_vertices[i].ZPosition = fData.GetValue(2, i); // } // break; // } // } // #endregion // #region colors // if (colors == null) { // // initialize as dark blue, fully opaque // for (int i = 0; i < m_vertCount; i++) { // m_vertices[i].Color = Color.DarkBlue; // } // } else if (colors.IsScalar && colors is ILDenseArray) { // Color col = (colors as ILDenseArray).GetValue(0); // for (int i = 0; i < m_vertCount; i++) { // m_vertices[i].Color = Color.DarkBlue; // } // } else { // ILArray bCols; // if (!colors.IsMatrix || !colors.IsNumeric || (colors.Dimensions[0] != 3 && colors.Dimensions[0] != 4)) { // throw new ILArgumentException("invalid argument: colors must be numeric matrix, 3 rows with R,G,B values!"); // } // if (colors is ILArray) // bCols = (ILArray)colors; // else // bCols = ILNumerics.ILMath.tobyte(colors); // if (colors.Dimensions[0] == 3) { // for (int i = 0; i < m_vertCount; i++) { // m_vertices[i].Color = Color.FromArgb(bCols.GetValue(0, i), bCols.GetValue(1, i), bCols.GetValue(2, i)); // } // } else { // for (int i = 0; i < m_vertCount; i++) { // m_vertices[i].Color = Color.FromArgb(bCols.GetValue(3, i), bCols.GetValue(0, i), bCols.GetValue(1, i), bCols.GetValue(2, i)); // } // } // } // #endregion // m_width = 4; // m_shading = ShadingStyles.Interpolate; // } //} #endregion } }