public override void Draw(ILRenderProperties props, ILShape shape) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); ILLine line = (shape as ILLine); if (line != null && line.Border.Visible) { fixed(C4bV3f *pVertices = line.Vertices) { ILOGLPanel.SetupLineStyle(line.Border); GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); GL.DisableClientState(EnableCap.ColorArray); if (line.OldestVertexID == 0) { GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount); } else { GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID); GL.DrawElements(BeginMode.Lines, 2, DrawElementsType.UnsignedInt, m_closeLoopIndices); GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID); } } } ILOGLPanel.SetupLineStyle(line.Properties); fixed(C4bV3f *pVertices = line.Vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); if (line.Shading == ShadingStyles.Interpolate) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(line.FillColor); } if (line.OldestVertexID == 0) { GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount); } else { GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID); GL.DrawElements(BeginMode.Lines, 2, DrawElementsType.UnsignedInt, m_closeLoopIndices); GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID); } } }
private void createShapes() { // disable eventing, otherwise, for each line added the whole panel would get reconfigured // which would lead to a poor startup performance EventingSuspend(); // the ground is a lit surface if (m_surface == null) { List <ILArray <double> > mesh = Computation.CreateMesh(-m_max, m_max, m_lowCut, 0, m_res); m_surface = new ILLitSurface(m_panel, mesh[0], mesh[1], mesh[2], new ILColormap(Colormaps.Jet)); m_surface.Opacity = 190; Add(m_surface); } if (m_lines == null) { // we create all individual lines and save them (redundantly) for later convenient reference. // (the grid is made out of individual line shapes) List <ILArray <double> > lines = Computation.CreateLines(-m_max, m_max, m_lowCut, 0, m_res, m_gridSpacing, m_linesPositionOffset); m_lines = new List <ILLine>(); for (int i = 0; i < lines[0].Dimensions[1]; i++) { // x - grid ILLine line = new ILLine(m_panel, lines[0][null, i], lines[1][null, i], lines[2][null, i]); line.Properties.Color = m_gridProperties.Color; line.Label.Text = ""; line.Properties.Width = m_gridProperties.Width; line.CustomCenter = new ILPoint3Df(0, 0, -200); m_lines.Add(line); Add(line); // y - grid line = new ILLine(m_panel, lines[1][null, i], lines[0][null, i], lines[2][null, i]); line.Properties.Color = m_gridProperties.Color; line.Label.Text = ""; line.Properties.Width = m_gridProperties.Width; line.CustomCenter = new ILPoint3Df(0, 0, -200); m_lines.Add(line); Add(line); } } // re-enable eventing, still one shape to be added: the sphere, which will cause a reconfiguration // of the whole panel EventingResume(); // lit sphere if (m_sphere == null) { m_sphere = new ILLitSphere(m_panel, new ILPoint3Df(0, 0, 1.4f), 1.8f, Color.FromArgb(190, Color.Gold)); Add(m_sphere); m_sphere.Label.Text = ""; m_sphere.Opacity = 190; } }
private void updateLines() { // since we do not want the whole panel to get updated for every line, we disable // eventing for this scene graph node EventingSuspend(); // the grid is made out of individual line shapes List <ILArray <double> > lines = Computation.CreateLines(-m_max, m_max, m_lowCut, 0, m_res, m_gridSpacing, m_linesPositionOffset); // make sure, we have the exact number of lines needed int needCount = lines[0].Dimensions[1] * 2; // x and y direction -> * 2 if (m_lines.Count > needCount) { // if we have to many line shapes, we make unneeded lines invisible for (int i = m_lines.Count; i-- > needCount;) { ILLine shape = m_lines[i]; shape.Visible = false; } // just as well, we could instead have removed the shape from both: // the shape collection of the container (ILSceneGraphInnerNode) and // the (convenient but redundant) shape collection of the plot: //Remove(shape); //m_lines.Remove(shape); } while (m_lines.Count < needCount) { // we do not have enough lines - so we add new lines here ILLine newLine = new ILLine(m_panel); newLine.Properties.Color = m_gridProperties.Color; newLine.Label.Text = ""; newLine.Properties.Width = m_gridProperties.Width; newLine.CustomCenter = new ILPoint3Df(0, 0, -200); Add(newLine); m_lines.Add(newLine); } // reconfigures all lines for (int i = 0; i < lines[0].Dimensions[1]; i++) { // x - grid ILLine line = m_lines[i]; line.Visible = true; line.Update(lines[0][null, i], lines[1][null, i], lines[2][null, i]); // y - grid line = m_lines[i + lines[0].Dimensions[1]]; line.Update(lines[1][null, i], lines[0][null, i], lines[2][null, i]); } // re-enable eventing EventingResume(); }
private void createShapes() { // disable eventing, otherwise, for each line added the whole panel would get reconfigured // which would lead to a poor startup performance EventingSuspend(); // the ground is a lit surface if (m_surface == null) { List<ILArray<double>> mesh = Computation.CreateMesh(-m_max, m_max, m_lowCut, 0, m_res); m_surface = new ILLitSurface(m_panel, mesh[0], mesh[1], mesh[2], new ILColormap(Colormaps.Jet)); m_surface.Opacity = 190; Add(m_surface); } if (m_lines == null) { // we create all individual lines and save them (redundantly) for later convenient reference. // (the grid is made out of individual line shapes) List<ILArray<double>> lines = Computation.CreateLines(-m_max, m_max, m_lowCut, 0, m_res, m_gridSpacing, m_linesPositionOffset); m_lines = new List<ILLine>(); for (int i = 0; i < lines[0].Dimensions[1]; i++) { // x - grid ILLine line = new ILLine(m_panel, lines[0][null, i], lines[1][null, i], lines[2][null, i]); line.Properties.Color = m_gridProperties.Color; line.Label.Text = ""; line.Properties.Width = m_gridProperties.Width; line.CustomCenter = new ILPoint3Df(0,0,-200); m_lines.Add(line); Add(line); // y - grid line = new ILLine(m_panel, lines[1][null, i], lines[0][null, i], lines[2][null, i]); line.Properties.Color = m_gridProperties.Color; line.Label.Text = ""; line.Properties.Width = m_gridProperties.Width; line.CustomCenter = new ILPoint3Df(0,0,-200); m_lines.Add(line); Add(line); } } // re-enable eventing, still one shape to be added: the sphere, which will cause a reconfiguration // of the whole panel EventingResume(); // lit sphere if (m_sphere == null) { m_sphere = new ILLitSphere(m_panel, new ILPoint3Df(0,0,1.4f), 1.8f, Color.FromArgb(190,Color.Gold)); Add(m_sphere); m_sphere.Label.Text = ""; m_sphere.Opacity = 190; } }
private void updateLines() { // since we do not want the whole panel to get updated for every line, we disable // eventing for this scene graph node EventingSuspend(); // the grid is made out of individual line shapes List<ILArray<double>> lines = Computation.CreateLines(-m_max, m_max, m_lowCut, 0, m_res, m_gridSpacing, m_linesPositionOffset); // make sure, we have the exact number of lines needed int needCount = lines[0].Dimensions[1] * 2; // x and y direction -> * 2 if (m_lines.Count > needCount) { // if we have to many line shapes, we make unneeded lines invisible for (int i = m_lines.Count; i-->needCount;) { ILLine shape = m_lines[i]; shape.Visible = false; } // just as well, we could instead have removed the shape from both: // the shape collection of the container (ILSceneGraphInnerNode) and // the (convenient but redundant) shape collection of the plot: //Remove(shape); //m_lines.Remove(shape); } while (m_lines.Count < needCount) { // we do not have enough lines - so we add new lines here ILLine newLine = new ILLine(m_panel); newLine.Properties.Color = m_gridProperties.Color; newLine.Label.Text = ""; newLine.Properties.Width = m_gridProperties.Width; newLine.CustomCenter = new ILPoint3Df(0,0,-200); Add(newLine); m_lines.Add(newLine); } // reconfigures all lines for (int i = 0; i < lines[0].Dimensions[1]; i++) { // x - grid ILLine line = m_lines[i]; line.Visible = true; line.Update(lines[0][null, i], lines[1][null, i], lines[2][null, i]); // y - grid line = m_lines[i + lines[0].Dimensions[1]]; line.Update(lines[1][null, i], lines[0][null, i], lines[2][null, i]); } // re-enable eventing EventingResume(); }