void paintPoints(ISeriesProjection series, bool useColor) { GL.PushMatrix(); GL.PushAttrib(AttribMask.EnableBit); GL.DepthMask(false); GL.Disable(EnableCap.Texture2D); if (!useColor) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One); } else { GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); } GL.MatrixMode(MatrixMode.Modelview); GL.ClearColor(0, 0, 0, 0); GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit); setZoomPan(); GL.EnableClientState(ArrayCap.VertexArray); if (useColor) { GL.EnableClientState(ArrayCap.ColorArray); } //GL.EnableVertexAttribArray(0); GL.BindBuffer(BufferTarget.ArrayBuffer, m_VboMap[series.Name].vbo); GL.VertexPointer(3, VertexPointerType.Float, Vertex.Stride, 0); if (useColor) { GL.ColorPointer(3, ColorPointerType.Float, Vertex.Stride, Vector3.SizeInBytes); } GL.PointSize(1); GL.Color4(1.0f, 1.0, 1.0, 1.0f); //GL.Begin(BeginMode.Points); //foreach (var point in series.dataPoints) //{ // GL.Vertex2(point.X,point.Y); //} //GL.End(); GL.DrawArrays(BeginMode.Points, 0, m_VboMap[series.Name].length); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); //GL.DisableVertexAttribArray(0); GL.DisableClientState(ArrayCap.VertexArray); if (useColor) { GL.DisableClientState(ArrayCap.ColorArray); GL.Disable(EnableCap.DepthTest); } GL.PopAttrib(); GL.PopMatrix(); GL.DepthMask(true); }
void blurPoints(ISeriesProjection series) { m_DensityMap[series.Name].Bind(); m_DensityMap[series.Name].Clear(); paintPoints(series, false); m_DensityMap[series.Name].Blur(m_Bandwidth); m_DensityMap[series.Name].Filter(paintPoints, series); m_DensityMap[series.Name].UnBind(); series.Histogram = m_DensityMap[series.Name].Histogram; }
void renderSeries(ISeriesProjection series, float angle) { GL.MatrixMode(MatrixMode.Modelview); GL.ClearColor(0, 0, 0, 0); GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit); m_DensityMap[series.Name].Bind(); m_DensityMap[series.Name].Shade(series.Color.R / 255.0f, series.Color.G / 255.0f, series.Color.B / 255.0f, angle, m_StripePeriod, m_StripeWidth, m_DensityThreshold, m_ContourThreshold); m_DensityMap[series.Name].UnBind(); }
public void Filter(Action <ISeriesProjection, bool> paintPoints, ISeriesProjection series) { GL.BindTexture(TextureTarget.Texture2D, 0); GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, textureColor, 0); paintPoints(series, true); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, textureColor); Points.Clear(); GL.GetTexImage(TextureTarget.Texture2D, 0, PixelFormat.Red, PixelType.Float, ColorData); for (int i = 0; i < ColorData.Length; i++) { if (ColorData[i] != 0) { int val = (int)(ColorData[i] * series.dataPoints.Count); Points.Add(series.dataPoints[val]); } } }
void drawPoints(ISeriesProjection series) { GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); GL.Enable(EnableCap.PointSmooth); float range = Math.Max(series.Xmax - series.Xmin, series.Ymax - series.Ymin); DensityRenderer renderer = m_DensityMap[series.Name]; int num = (int)(Math.Ceiling(Width / m_ClutterWindow)); num = Math.Max(num, 1); int[] grid = new int[num * num]; float cellsize = range / num; float offx = transformX(0) - (float)(Math.Floor(transformX(0) / m_ClutterWindow) * m_ClutterWindow); float offy = transformY(0) - (float)(Math.Floor(transformY(0) / m_ClutterWindow) * m_ClutterWindow); var selectedList = new List <int>(grid.Length); var unselectedList = new List <int>(grid.Length); var allList = new List <int>(grid.Length); if (m_ClutterWindow == 0) { allList.AddRange(series.dataPoints.Select(d => d.Index)); unselectedList.AddRange(series.dataPoints.Select(d => d.Index)); } else { foreach (var p in m_DensityMap[series.Name].Points) { float xgl = transformX(p.X); float ygl = transformY(p.Y); int ix = (int)Math.Floor((xgl - offx) / m_ClutterWindow); int iy = (int)Math.Floor((ygl - offy) / m_ClutterWindow); bool allow = !(ix < 0 || ix >= num || iy < 0 || iy >= num); if (allow) { int count = grid[ix * num + iy]++; allow = allow && count == 0; } float clutterRad = renderer.GetDist(xgl, ygl) * 2.0f; if (clutterRad > m_ClutterWindow && allow) { allList.Add(p.Index); if (p.Selected) { selectedList.Add(p.Index); } else { unselectedList.Add(p.Index); } } } } //use vbo???////////////////////////////////////////////// GL.EnableClientState(ArrayCap.VertexArray); GL.DisableClientState(ArrayCap.ColorArray); GL.BindBuffer(BufferTarget.ArrayBuffer, m_VboMap[series.Name].vbo); GL.VertexPointer(3, VertexPointerType.Float, Vertex.Stride, 2 * Vector3.SizeInBytes); var unselectedVertices = unselectedList.ToArray(); var selectedVertices = selectedList.ToArray(); var allVertices = allList.ToArray(); GL.PointSize(5); Color modulated = ColorConv.Modulate(series.Color, .9f); GL.Color3(modulated); GL.DrawElements(BeginMode.Points, unselectedVertices.Length, DrawElementsType.UnsignedInt, unselectedVertices); GL.Color3(Color.FromArgb(0, 255, 0)); GL.DrawElements(BeginMode.Points, selectedVertices.Length, DrawElementsType.UnsignedInt, selectedVertices); GL.PointSize(3); GL.Color3(series.Color); GL.DrawElements(BeginMode.Points, allVertices.Length, DrawElementsType.UnsignedInt, allVertices); GL.DisableClientState(ArrayCap.VertexArray); GL.Disable(EnableCap.DepthTest); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); }
void doDistanceTransform(ISeriesProjection series) { m_DensityMap[series.Name].Bind(); m_DensityMap[series.Name].JumpFlooding(m_ContourThreshold); m_DensityMap[series.Name].UnBind(); }