Skip to content

GigasoftInc/winforms-chart-3d-surface-proessentials

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GigaPrime3D — GPU Compute Shader 3D Surface Chart (WinForms)

ProEssentials v10 WinForms .NET 8 demonstration of GPU compute-shader 3D surface rendering — real material-surface and terrain height-map data visualized across three synchronized charts. This is the WinForms sibling of the WPF GigaPrime3D demo; the ProEssentials chart configuration is identical between the two — only the host shell differs. It doubles as a small proof that WinForms is not a dead platform: it matches its WPF sibling pixel-for-pixel in look, feel, and performance, on a framework Microsoft still ships every year (.NET 10 LTS, supported into 2028).

GigaPrime3D WinForms Chart


Is WinForms Dead? No.

This project is the same chart, line for line, as the WPF GigaPrime3D demo — identical look, feel, and GPU performance — which is exactly the point: in 2026, choosing WinForms costs you nothing in capability. WinForms ships on an annual cadence with every .NET release, and .NET 10 is a Long-Term Support release (November 2025) supported into November 2028 — a multi-year runway, not a dead end. Genuinely shipped (not preview) WinForms work in .NET 10 includes fully integrated dark mode (one Application.SetColorMode call switches Classic / System / Dark), a clipboard implementation shared with WPF plus designer editors ported from .NET Framework, a new screen-capture protection API for sensitive on-screen data, and the async forms APIs out of preview. And for a charting engine that couples Direct3D directly to the window's hDC — as ProEssentials does — WinForms is at least as fast as WPF, often a touch faster, because it renders the native surface directly instead of through WPF's airspace/compositing layer. The reflexive "use WPF if you care about performance" gets it backwards here.


Three Synchronized Charts

Chart Type Purpose
Chart3DSurface Pe3do — 3D Surface Main GPU-rendered 3D surface with lighting, rotation, zoom (fills center)
Chart2DContour Pesgo — 2D Contour Linked top-down contour (bottom-left) — zoom here zooms the 3D chart
Chart2DLine Pesgo — 2D Cross Section Live cross-section at the X-plane position (right column)

Key Technical Features

GPU Compute Shader Surface ConstructionPeData.ComputeShader = true builds the 3D scene on the GPU (v10), ~10× faster than v9 CPU-side construction.

Zero Memory CopyPeData.X/Y/Z.UseDataAtLocation(...) shares one set of app buffers between the Pe3do surface and the Pesgo contour (no data transfer).

Linked Chart Zoom — zooming/panning the 2D contour updates ManualScaleControlX/Z on the 3D surface so both views stay synchronized.

Pixel Shader CullingPeGrid.Configure.DxPsManualCullXZ = true culls off-range geometry on the GPU during zoomed views.


WinForms vs WPF

The chart-logic blocks (Initialize3D / Initialize2DContour / Initialize2D / RefreshUi / MoveXPlane, the 256-entry jet palette, and all the Pe* calls) are copied verbatim from the WPF demo. Only the host shell was rewritten:

  • MainWindow.xaml 3-column Grid → code-built WinForms layout: 3D surface Dock=Fill in the center with the rotation/zoom/explode sliders overlaying its top-left; a 275px sidebar Dock=Left; a 220px line-chart column Dock=Right with the X-plane slider; the 2D contour floats 360×360 in the bottom-left.
  • App.xaml(.cs)Program.cs; MainWindow.xaml.csMainForm.cs (no .Designer.cs / .resx, so the WinForms designer is never invoked).
  • WPF Slider RoutedPropertyChangedEventArgs<double>EventArgs + slider.Value; CheckBox Checked/Unchecked pair → one CheckedChanged; ComboBox SelectionChangedSelectedIndexChanged; Window.ClosingFormClosing.
  • System.Windows.Media.ColorSystem.Drawing.Color; Cursor.LastMouseMove System.Windows.PointSystem.Drawing.Point; GCHandle pins freed in Dispose(bool); the WPF Dispatcher.InvokeAsync zoom defer → BeginInvoke.
  • Stock TrackBar/CheckBox → owner-drawn FlatSlider / FlatCheckBox so the dark sidebar matches the WPF look.

➡️ WPF version: wpf-chart-3d-surface-proessentials


Data Files

  • .bhm — Binary Height Map: 32-byte header (int32 width, int32 height, float minZ, float maxZ) followed by a flat array of 4-byte floats.
  • .png — decoded as raw pixel data for height values.

The HeightMap class handles both, computing physical dimensions in millimeters from pixel dimensions and resolution. Sample data ships with the project so it runs out of the box.


Interactive Controls

3D Surface — left-drag rotate · Shift+left-drag translate · wheel zoom · middle-drag light · right-click menu (Cursor Tracking, Undo Zoom). Sidebar: height-map selector, Legend / Bottom Contour / X-Plane / Cursor-Tracking checks, Reduce Data, Help, and Move / Light sliders. Overlay: Vertical/Horizontal rotation, Magnification, Explode-Z. 2D Contour — left-drag zoom (also zooms the 3D surface) · right-click Undo Zoom. X-Plane slider moves the cross-section plane and updates the 2D line chart live.


Prerequisites

  • Visual Studio 2022
  • .NET 8 SDK (Windows)
  • Internet connection for NuGet restore
  • x64, dedicated GPU recommended for the large data files

How to Run

  1. Open GigaPrime3D.sln in Visual Studio 2022
  2. Build → Rebuild Solution (restores the NuGet package automatically)
  3. Press F5
  4. Select a height map from the dropdown to load surface data

Designer note: No .Designer.cs by design — the UI is built in code in MainForm.cs, avoiding the native-control designer issues entirely.


NuGet Package

References ProEssentials.Chart.Net80.x64.Winforms from nuget.org. Package restore happens automatically on build.


License

Example code is MIT licensed. ProEssentials requires a commercial license for continued use.

About

Our Most Impressive 3d 2d example as Winforms vs WPF. GPU compute shader 3D surface chart. Three synchronized charts: 3D surface, 2D contour, 2D cross-section. Real scientific height map data. .NET 8. Clone, build, run. Compare to WPF.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages