Triangulated Surface Realtime Example for WinForms

Nevron NOV Chart for WinForms ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WinForms Chart examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

Triangulated Surface Realtime Example for WinForms Description

The control features the World's fastest triangulator. This example demonstrates the NTriangulatedSurfaceSeries' ability to render large, dynamically changing datasets with minimal CPU load. It also illustrates an efficient method for populating data into the series.


Triangulated Surface Real Time Example

C# Triangulated Surface Realtime Example Code for Nevron Chart for WinForms
Language: C#

using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Chart.Tools;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NTriangulatedSurfaceRealTimeExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

        #region Example

        public NWidget CreateExampleContent()
        {
			NChartViewWithCommandBars chartViewWithCommandBars = new NChartViewWithCommandBars();
			NChartView chartView = chartViewWithCommandBars.View;
			chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian);

            chartView.Registered += OnChartViewRegistered;
            chartView.Unregistered += OnChartViewUnregistered;

            // configure title
            chartView.Surface.Titles[0].Text = "Realtime Grid Surface";

            // setup chart
            NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYZLinear);
            chart.Enable3D = true;
            chart.ModelWidth = 50;
            chart.ModelDepth = 50;
            chart.ModelHeight = 30;
            chart.FitMode = ENCartesianChartFitMode.Aspect;
            chart.Projection.SetPredefinedProjection(ENPredefinedProjection.OrthogonalTop);
            chart.Interactor = new NInteractor(new NTrackballTool());

            for (int i = 0; i < chart.Walls.GetChildrenCount(); i++)
            {
                ((NChartWall)chart.Walls.GetChildAt(i)).VisibilityMode = ENWallVisibilityMode.Hidden;
            }

            // setup Y axis
            NLinearScale scaleY = new NLinearScale();
            scaleY.ViewRangeInflateMode = ENScaleViewRangeInflateMode.None;
            scaleY.MinTickDistance = 10;
            scaleY.MajorGridLines.ShowAtWalls = ENChartWall.Left | ENChartWall.Back;
            chart.Axes[ENCartesianAxis.PrimaryY].Scale = scaleY;

            // add interlace stripe to the Y axis
            NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
            stripStyle.Interlaced = true;
            stripStyle.SetShowAtWall(ENChartWall.Back, true);
            stripStyle.SetShowAtWall(ENChartWall.Left, true);
            scaleY.Strips.Add(stripStyle);

            // setup X axis
            NLinearScale scaleX = new NLinearScale();
            scaleX.ViewRangeInflateMode = ENScaleViewRangeInflateMode.None;
            scaleX.MajorGridLines.ShowAtWalls = ENChartWall.Bottom | ENChartWall.Back;
            chart.Axes[ENCartesianAxis.PrimaryX].Scale= scaleX;

            // setup Z axis
            NLinearScale scaleZ = new NLinearScale();
            scaleZ.ViewRangeInflateMode = ENScaleViewRangeInflateMode.None;
            scaleZ.MajorGridLines.ShowAtWalls = ENChartWall.Bottom | ENChartWall.Left;
            chart.Axes[ENCartesianAxis.Depth].Scale = scaleZ;

            // add the surface series
            NTriangulatedSurfaceSeries surface = new NTriangulatedSurfaceSeries();
            chart.Series.Add(surface);
            m_Surface = surface;
            surface.Name = "Surface";

            surface.FillColorMode = ENColorMode.Zone;
            surface.ShowFrame = true;
            surface.FrameMode = ENSurfaceFrameMode.Mesh;
            surface.ShadingMode = ENShadingMode.Flat;

            return chartViewWithCommandBars;
        }

        public NWidget CreateExampleControls()
        {
            NStackPanel stack = new NStackPanel();
            NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);

            NComboBox gridSizeComboBox = new NComboBox();
            gridSizeComboBox.Items.Add(new NComboBoxItem("10x10"));
            gridSizeComboBox.Items.Add(new NComboBoxItem("100x100"));
            gridSizeComboBox.Items.Add(new NComboBoxItem("200x200"));
            gridSizeComboBox.Items.Add(new NComboBoxItem("500x500"));
            stack.Add(NPairBox.Create("Grid Size:", gridSizeComboBox));
            gridSizeComboBox.SelectedIndexChanged += OnGridSizeComboBoxSelectedIndexChanged;
            gridSizeComboBox.SelectedIndex = 1;

            NCheckBox enableShaderRenderingCheckBox = new NCheckBox("Enable Shader Rendering");
            stack.Add(enableShaderRenderingCheckBox);
            enableShaderRenderingCheckBox.CheckedChanged += OnEnableShaderRenderingCheckBoxCheckedChanged;
            enableShaderRenderingCheckBox.Checked = false;

            NButton toggleTimerButton = new NButton("Stop Timer");
            toggleTimerButton.Click += OnToggleTimerButtonClick;
            toggleTimerButton.Tag = 0;
            stack.Add(toggleTimerButton);

            return group;
        }

        public string GetExampleDescription()
        {
            return @"

The control features the World's fastest triangulator. This example demonstrates the NTriangulatedSurfaceSeries' ability to render large, dynamically changing datasets with minimal CPU load. It also illustrates an efficient method for populating data into the series.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Triangulated Surface Series", "https://www.nevron.com/docs/openvision/triangulated-surface-chart-series.html"), ("Surface Series Overview", "https://www.nevron.com/docs/openvision/surface-chart-series-overview.html"), ("3D Charts", "https://www.nevron.com/docs/openvision/3d-charts.html"), ("Chart Data Series", "https://www.nevron.com/docs/openvision/chart-data-series.html"), ("Zooming and Scrolling", "https://www.nevron.com/docs/openvision/chart-interactivity-zooming-and-scrolling.html"), }; } #endregion #region Implementation #endregion #region Event Handlers #endregion #region Fields NTimer m_Timer; NTriangulatedSurfaceSeries m_Surface; int m_GridSize; Random m_Random; double[,] m_Phase; double[,] m_Radius; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Triangulated Surface Realtime Example for WinForms Solution

VB.NET Triangulated Surface Realtime Example Code for Nevron Chart for WinForms
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Chart.Tools
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Forms
Imports System

Public Class Form1

#Region "Constructors"

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        ' Set form title
        Text = "NOV WinForms - NTriangulatedSurfaceRealTimeExample"

        ' Create the NOV example and its controls
        Dim exampleContent As NWidget = CreateExampleContent()
        Dim exampleControls As NWidget = CreateExampleControls()
        If Not exampleControls Is Nothing Then
            exampleControls.PreferredWidth = 300
        End If

        ' Place the example and its controls in a pair box
        Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
        pairBox.FillMode = ENStackFillMode.First
        pairBox.FitMode = ENStackFitMode.First
        pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)

        ' Host the example in the form
        Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
        host.Dock = DockStyle.Fill
        Controls.Add(host)
    End Sub


#End Region

#Region "Example"

        Public Function CreateExampleContent() As NWidget
            Dim chartViewWithCommandBars As NChartViewWithCommandBars = New NChartViewWithCommandBars()
            Dim chartView = chartViewWithCommandBars.View
            chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian)

            chartView.Registered += AddressOf OnChartViewRegistered
            chartView.Unregistered += AddressOf OnChartViewUnregistered

            ' configure title
            chartView.Surface.Titles(0).Text = "Realtime Grid Surface"

            ' setup chart
            Dim chart = CType(chartView.Surface.Charts(0), NCartesianChart)
            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYZLinear)
            chart.Enable3D = True
            chart.ModelWidth = 50
            chart.ModelDepth = 50
            chart.ModelHeight = 30
            chart.FitMode = ENCartesianChartFitMode.Aspect
            chart.Projection.SetPredefinedProjection(ENPredefinedProjection.OrthogonalTop)
            chart.Interactor = New NInteractor(New NTrackballTool())

            For i = 0 To chart.Walls.GetChildrenCount() - 1
                CType(chart.Walls.GetChildAt(i), NChartWall).VisibilityMode = ENWallVisibilityMode.Hidden
            Next

            ' setup Y axis
            Dim scaleY As NLinearScale = New NLinearScale()
            scaleY.ViewRangeInflateMode = ENScaleViewRangeInflateMode.None
            scaleY.MinTickDistance = 10
            scaleY.MajorGridLines.ShowAtWalls = ENChartWall.Left Or ENChartWall.Back
            chart.Axes(ENCartesianAxis.PrimaryY).Scale = scaleY

            ' add interlace stripe to the Y axis
            Dim stripStyle As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
            stripStyle.Interlaced = True
            stripStyle.SetShowAtWall(ENChartWall.Back, True)
            stripStyle.SetShowAtWall(ENChartWall.Left, True)
            scaleY.Strips.Add(stripStyle)

            ' setup X axis
            Dim scaleX As NLinearScale = New NLinearScale()
            scaleX.ViewRangeInflateMode = ENScaleViewRangeInflateMode.None
            scaleX.MajorGridLines.ShowAtWalls = ENChartWall.Bottom Or ENChartWall.Back
            chart.Axes(ENCartesianAxis.PrimaryX).Scale = scaleX

            ' setup Z axis
            Dim scaleZ As NLinearScale = New NLinearScale()
            scaleZ.ViewRangeInflateMode = ENScaleViewRangeInflateMode.None
            scaleZ.MajorGridLines.ShowAtWalls = ENChartWall.Bottom Or ENChartWall.Left
            chart.Axes(ENCartesianAxis.Depth).Scale = scaleZ

            ' add the surface series
            Dim surface As NTriangulatedSurfaceSeries = New NTriangulatedSurfaceSeries()
            chart.Series.Add(surface)
            m_Surface = surface
            surface.Name = "Surface"

            surface.FillColorMode = ENColorMode.Zone
            surface.ShowFrame = True
            surface.FrameMode = ENSurfaceFrameMode.Mesh
            surface.ShadingMode = ENShadingMode.Flat

            Return chartViewWithCommandBars
        End Function

        Public Function CreateExampleControls() As NWidget
            Dim stack As NStackPanel = New NStackPanel()
            Dim group As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)

            Dim gridSizeComboBox As NComboBox = New NComboBox()
            gridSizeComboBox.Items.Add(New NComboBoxItem("10x10"))
            gridSizeComboBox.Items.Add(New NComboBoxItem("100x100"))
            gridSizeComboBox.Items.Add(New NComboBoxItem("200x200"))
            gridSizeComboBox.Items.Add(New NComboBoxItem("500x500"))
            stack.Add(NPairBox.Create("Grid Size:", gridSizeComboBox))
            gridSizeComboBox.SelectedIndexChanged += AddressOf OnGridSizeComboBoxSelectedIndexChanged
            gridSizeComboBox.SelectedIndex = 1

            Dim enableShaderRenderingCheckBox As NCheckBox = New NCheckBox("Enable Shader Rendering")
            stack.Add(enableShaderRenderingCheckBox)
            enableShaderRenderingCheckBox.CheckedChanged += AddressOf OnEnableShaderRenderingCheckBoxCheckedChanged
            enableShaderRenderingCheckBox.Checked = False

            Dim toggleTimerButton As NButton = New NButton("Stop Timer")
            toggleTimerButton.Click += AddressOf OnToggleTimerButtonClick
            toggleTimerButton.Tag = 0
            stack.Add(toggleTimerButton)

            Return group
        End Function

        Public Function GetExampleDescription() As String
            Return "

The control features the World's fastest triangulator. This example demonstrates the NTriangulatedSurfaceSeries' ability to render large, dynamically changing datasets with minimal CPU load. It also illustrates an efficient method for populating data into the series.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Triangulated Surface Series", "https://www.nevron.com/docs/openvision/triangulated-surface-chart-series.html"), ("Surface Series Overview", "https://www.nevron.com/docs/openvision/surface-chart-series-overview.html"), ("3D Charts", "https://www.nevron.com/docs/openvision/3d-charts.html"), ("Chart Data Series", "https://www.nevron.com/docs/openvision/chart-data-series.html"), ("Zooming and Scrolling", "https://www.nevron.com/docs/openvision/chart-interactivity-zooming-and-scrolling.html")} End Function #End Region #Region "Implementation" #End Region #Region "Event Handlers" #End Region #Region "Fields" Private m_Timer As NTimer Private m_Surface As NTriangulatedSurfaceSeries Private m_GridSize As Integer Private m_Random As Random Private m_Phase As Double(,) Private m_Radius As Double(,) #End Region #Region "Static Methods" #End Region #Region "Constants" #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Triangulated Surface Realtime Example for WinForms Solution