Ejemplo n.º 1
0
        /// <summary>
        /// [internal] constructor - do not use this! Use ILPanel.Graphs.Add...() instead!
        /// </summary>
        /// <param name="panel">panel hosting the scene</param>
        /// <param name="XData">x data array</param>
        /// <param name="YData">y data array</param>
        /// <param name="clippingContainer">hosting panels clipping data</param>
        public ILPlot2DGraph(ILPanel panel, ILBaseArray XData, ILBaseArray YData,
                             ILClippingData clippingContainer)
            : base(panel, clippingContainer)
        {
            if (!XData.IsVector)
            {
                throw new ILArgumentException("Plot2D: supplied data must be a real vector!");
            }
            if (!YData.IsVector)
            {
                throw new ILArgumentException("Plot2D: XData and YData must be real vectors!");
            }
            if (YData.Length != XData.Length)
            {
                throw new ILArgumentException("Plot2D: XData and YData must have the same length!");
            }
            int             pos = 0;
            ILArray <float> dataX, dataY;
            C4bV3f          vert = new C4bV3f();

            if (XData is ILArray <float> )
            {
                dataX = (ILArray <float>)XData;
            }
            else
            {
                dataX = ILMath.tosingle(XData);
            }
            if (YData is ILArray <float> )
            {
                dataY = (ILArray <float>)YData;
            }
            else
            {
                dataY = ILMath.tosingle(YData);
            }
            m_vertices            = new C4bV3f[dataX.Length + 1];
            m_vertexCount         = m_vertices.Length;
            m_startID             = m_vertexCount - 1;
            m_updateCount         = 0;
            m_properties          = new ILLineProperties();
            m_properties.Color    = Color.DarkBlue;
            m_properties.Changed += new EventHandler(m_properties_Changed);
            foreach (float val in dataX.Values)
            {
                vert.Position     = new ILPoint3Df(val, dataY.GetValue(pos), 0);
                vert.Color        = m_properties.Color;
                m_vertices[pos++] = vert;
            }
            m_marker          = new ILMarker(panel);
            m_marker.Changed += new EventHandler(m_marker_Changed);
            m_graphType       = GraphType.Plot2D;
            updateClipping();
        }
Ejemplo n.º 2
0
        public void SetVertex(int vertexID, IILVertexDefinition vertex)
        {
            C4bV3f curVert = m_vertices[vertexID];

            if (vertex.StoresColor)
            {
                curVert.Color = vertex.Color;
            }
            curVert.Position     = vertex.Position;
            m_vertices[vertexID] = curVert;
        }
Ejemplo n.º 3
0
        private void updateClipping()
        {
            ILPoint3Df max = ILPoint3Df.MinValue;
            ILPoint3Df min = ILPoint3Df.MaxValue;

            for (int i = 0; i < m_vertexCount; i++)
            {
                C4bV3f vert = m_vertices[i];
                max = ILPoint3Df.Max(vert.Position, max);
                min = ILPoint3Df.Min(vert.Position, min);
            }
            m_localClipping.Set(min, max);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// [internal] constructor - do not use this! Use ILPanel.Graphs.Add...() instead!
        /// </summary>
        /// <param name="panel">panel hosting the scene</param>
        /// <param name="sourceArray">data array</param>
        /// <param name="clippingContainer">hosting panels clipping data</param>
        public ILPlot2DGraph(ILPanel panel, ILBaseArray sourceArray,
                             ILClippingData clippingContainer)
            : base(panel, clippingContainer)
        {
            if (object.Equals(sourceArray, null) || !sourceArray.IsVector || !sourceArray.IsNumeric)
            {
                throw new ILArgumentException("Plot2D: supplied data must be numeric (real valued) vector!");
            }
            int             pos = 0;
            ILArray <float> data;
            C4bV3f          vert = new C4bV3f();

            if (sourceArray is ILArray <float> )
            {
                data = (ILArray <float>)sourceArray;
            }
            else
            {
                data = ILMath.tosingle(sourceArray);
            }
            m_vertices            = new C4bV3f[data.Length + 1];
            m_vertexCount         = m_vertices.Length;
            m_updateCount         = 0;
            m_startID             = 0;
            m_properties          = new ILLineProperties();
            m_properties.Color    = Color.DarkBlue;
            m_properties.Changed += new EventHandler(m_properties_Changed);
            foreach (float val in data.Values)
            {
                vert.Position     = new ILPoint3Df(pos, val, 0);
                vert.Color        = Color.Red;
                m_vertices[pos++] = vert;
            }
            m_marker          = new ILMarker(panel);
            m_marker.Changed += new EventHandler(m_properties_Changed);
            m_graphType       = GraphType.Plot2D;
            m_localClipping.Set(new ILPoint3Df(0, data.MinValue, 0), new ILPoint3Df(data.Length - 1, data.MaxValue, 0));
        }
Ejemplo n.º 5
0
        public override void DrawToLegend(ILRenderProperties p, Rectangle sampleArea, Rectangle labelArea)
        {
            if (p.Graphics != null)
            {
                // bitmap output is handled by base class
                base.DrawToLegend(p, sampleArea, labelArea);
                return;
            }
            int sampY = (int)(sampleArea.Top + sampleArea.Height / 2.0f);

            #region draw line
            if (m_properties.Visible)
            {
                ILNumerics.Drawing.Platform.OpenGL.ILOGLPanel.SetupLineStyle(m_properties);
                GL.Begin(BeginMode.Lines);
                GL.Vertex2(sampleArea.Left, sampY);
                GL.Vertex2(sampleArea.Right, sampY);
                GL.End();
            }
            #endregion

            #region draw marker
            if (m_marker.Visible)
            {
                C4bV3f pos = new C4bV3f();
                pos.XPosition = sampleArea.Left + sampleArea.Width / 2.0f;
                pos.YPosition = sampY;
                m_marker.Shape.Draw(p, m_marker, new C4bV3f[] { pos }, 0, -1);
            }
            #endregion
            //GL.Vertex2(sampleArea.Right,sampleArea.Bottom);
            //GL.Vertex2(sampleArea.Left,sampleArea.Bottom);
            m_label.m_position.X = labelArea.X + labelArea.Width / 2;
            m_label.m_position.Y = labelArea.Y + labelArea.Height / 2;
            m_label.Anchor       = new PointF(.5f, .5f); //  = TickLabelAlign.center | TickLabelAlign.vertCenter;
            m_label.Draw(p);
        }