Example 411: 3D Scatter, Line, Waterfall Realtime

Pe3do3D Scientific Objectadvanced

3D Scatter, Line, Waterfall Realtime

Preview

ProEssentials Pe3do 3D Scientific Object - 3D Scatter, Line, Waterfall Realtime
Click to enlarge

Source Code

Form6.cs
1//! Left click and drag to rotate. Also Hold shift to translate. //
2//! Mouse Wheel zooms in/out.
3//! Middle Button hold down while drag rotates light. //
4//! Right click to show popup menu. //
5
6// Non-Surface chart, set PolyMode //
7Pe3do1.PePlot.PolyMode = PolyMode.Scatter;
8
9// Disable Legend //
10Pe3do1.PeLegend.SubsetsToLegend[0] = -1;
11
12// Initialize Data //
13Pe3do1.PeData.Subsets = 100;
14Pe3do1.PeData.Points = 200;
15
16for (int s = 0; s < 100; s++)
17{
18 for (int p = 0; p < 200; p++)
19 {
20 Pe3do1.PeData.X[s, p] = p + 1;
21 Pe3do1.PeData.Y[s, p] = 0;
22 Pe3do1.PeData.Z[s, p] = s + 1;
23 }
24}
25
26Pe3do1.PePlot.Option.DxZoomMax = -1F; // v10 New properties to control max and min mousewheel zoom
27Pe3do1.PePlot.Option.DxZoomMin = -5F;
28
29Pe3do1.PePlot.Option.DxViewportPanFactor = 2.0F; // v10 New properties to control shift/drag and mousewheel sensitivity
30Pe3do1.PeUserInterface.Scrollbar.MouseWheelZoomFactor = 3.75F;
31
32// Manually scale y axis //
33Pe3do1.PeGrid.Configure.ManualScaleControlY = ManualScaleControl.MinMax;
34Pe3do1.PeGrid.Configure.ManualMinY = 75;
35Pe3do1.PeGrid.Configure.ManualMaxY = 270;
36Pe3do1.PeGrid.Configure.AutoMinMaxPadding = 0;
37
38Pe3do1.PePlot.Option.WaterfallContours = true;
39Pe3do1.PeColor.ContourColorBlends = 20;
40Pe3do1.PeColor.ContourColorAlpha = 255;
41Pe3do1.PeColor.ContourColorSet = ContourColorSet.BlueCyanGreenYellowBrownWhite;
42
43Pe3do1.PePlot.Option.ManualContourScaleControl = ManualScaleControl.MinMax;
44Pe3do1.PePlot.Option.ManualContourMin = 100.0F;
45Pe3do1.PePlot.Option.ManualContourMax = 240.0F;
46
47Pe3do1.PeString.MainTitle = "";
48
49Pe3do1.PePlot.Allow.Area = true;
50Pe3do1.PePlot.Allow.PointsPlusLine = true;
51Pe3do1.PeUserInterface.Dialog.Style = false;
52
53Pe3do1.PeFont.FontSize = FontSize.Medium;
54Pe3do1.PeFont.Fixed = true;
55
56Pe3do1.PeString.SubTitle = "||Mouse Wheel zooms. Mouse Drag rotates. Mouse Drag+SHIFT shifts image. ";
57Pe3do1.PeString.MultiSubTitles[0] = "||Double Click start/stop Rotation. Mouse Drag+MIDDLE rotates light. ";
58
59Pe3do1.PeGrid.Option.GridAspectZ = 5.0F;
60Pe3do1.PeGrid.Option.GridAspectX = 2.0F;
61
62Pe3do1.PeUserInterface.Scrollbar.ViewingHeight = 25;
63Pe3do1.PeUserInterface.Scrollbar.DegreeOfRotation = 31;
64Pe3do1.PePlot.Option.DxZoom = -3.37F;
65Pe3do1.PePlot.Option.DxViewportX = 1.75F;
66Pe3do1.PePlot.Option.DxViewportY = 1.92F;
67Pe3do1.PePlot.Option.DegreePrompting = true;
68
69Pe3do1.PePlot.Method = Gigasoft.ProEssentials.Enums.ThreeDGraphPlottingMethod.Three; // Area
70
71// v9 features
72Pe3do1.PePlot.Option.WaterfallBorders = true;
73Pe3do1.PeColor.BarBorderColor = Color.FromArgb(255, 0, 0, 0);
74
75// Note RenderEngine 3DX requires setting renderengine before QuickStyle
76Pe3do1.PeColor.BitmapGradientMode = true;
77Pe3do1.PeColor.QuickStyle = QuickStyle.DarkNoBorder;
78
79Pe3do1.PeColor.XZBackColor = Color.FromArgb(255, 0, 0, 0);
80Pe3do1.PeColor.YBackColor = Color.FromArgb(255, 0, 0, 0);
81Pe3do1.PeColor.GridBands = false;
82
83Pe3do1.PeConfigure.CacheBmp = true;
84Pe3do1.PeConfigure.PrepareImages = true;
85Pe3do1.PeUserInterface.Allow.FocalRect = false;
86
87// Add Some Padding around image //
88Pe3do1.PeConfigure.ImageAdjustLeft = 50;
89Pe3do1.PeConfigure.ImageAdjustRight = 50;
90Pe3do1.PeConfigure.ImageAdjustBottom = 50;
91
92Pe3do1.PeConfigure.TextShadows = TextShadows.BoldText;
93Pe3do1.PeFont.Label.Bold = true;
94
95// Set various export defaults //
96Pe3do1.PeSpecial.DpiX = 600;
97Pe3do1.PeSpecial.DpiY = 600;
98
99// default export setting //
100Pe3do1.PeUserInterface.Dialog.ExportSizeDef = ExportSizeDef.NoSizeOrPixel;
101Pe3do1.PeUserInterface.Dialog.ExportTypeDef = ExportTypeDef.Png;
102Pe3do1.PeUserInterface.Dialog.ExportDestDef = ExportDestDef.Clipboard;
103Pe3do1.PeUserInterface.Dialog.ExportUnitXDef = "1280";
104Pe3do1.PeUserInterface.Dialog.ExportUnitYDef = "768";
105Pe3do1.PeUserInterface.Dialog.ExportImageDpi = 300;
106Pe3do1.PeUserInterface.Dialog.AllowEmfExport = false;
107Pe3do1.PeUserInterface.Dialog.AllowWmfExport = false;
108
109// Enable button dragging //
110Pe3do1.PeUserInterface.Scrollbar.MouseDraggingX = true;
111Pe3do1.PeUserInterface.Scrollbar.MouseDraggingY = true;
112
113Pe3do1.PeUserInterface.Menu.ShowLegend = MenuControl.Hide;
114Pe3do1.PeUserInterface.Menu.ShowWireFrame = MenuControl.Hide;
115
116Pe3do1.PeConfigure.RenderEngine = RenderEngine.Direct3D;
117
118Pe3do1.PeFunction.ReinitializeResetImage();
119Pe3do1.Invalidate();
120Pe3do1.Refresh();
121
122MainWindow.m_nRealTimeCounter = 0;
123MainWindow.m_nOverallCounter = 200;
124
125MainWindow.Timer1.Interval = 25;
126MainWindow.Timer1.Start();
127
128/*
129/////////////////////////
130// Example Timer Event //
131/////////////////////////
132private void Timer1_Tick(object sender, System.EventArgs e)
133{
134 int p, nBump;
135 nBump = 0;
136
137 // This timer/tick event shows PeData.AppendYSubset is real time shifting a full subsets worth of data (Points = 200 for this case)
138 // so we are preparing 200 pieces of data. Since the 3d waterfall plotting method plots an area chart per subset
139 // a full subset area plot is shifted when we Append a subsets worth of data. More common realtime examples will use AppendYData
140 // that shifts 1 data point per subset rather than a full subsets worth of data per point.
141 // In other words, when using AppendYData, all 100 area plots would simultaneously/individually shift.
142
143 m_nOverallCounter = m_nOverallCounter + 1;
144 m_nRealTimeCounter = m_nRealTimeCounter + 1;
145 if (m_nRealTimeCounter > 5)
146 {
147 nBump = 0 + (int)((float)(Rand_Num.NextDouble()) * 100.0F);
148 m_nRealTimeCounter = 0;
149 }
150
151 float[] pNewXData = new float[200];
152 float[] pNewYData = new float[200];
153 float[] pNewZData = new float[200];
154
155 for (p = 0; p < 200; p++)
156 {
157 pNewZData[p] = m_nOverallCounter; // subset or sample iteration
158 pNewXData[p] = p + 1;
159 pNewYData[p] = 125.0F + ((float)(Rand_Num.NextDouble()) * 9.0F) + (25.0F * (float)Math.Sin(((float)m_nOverallCounter) * .04F * ((float)(p + 1) * 3.0F)));
160 }
161 if (nBump != 0)
162 pNewYData[nBump] = pNewYData[nBump] + 50.0F;
163
164 Pe3do1.PeData.Y.AppendSubset(pNewYData, 1);
165 Pe3do1.PeData.X.AppendSubset(pNewXData, 1);
166 Pe3do1.PeData.Z.AppendSubset(pNewZData, 1);
167
168 // Comment out above and replace with below to compare AppendYSubset with AppendYData
169 //float[] pNewXData = new float[100];
170 //float[] pNewYData = new float[100];
171 //float[] pNewZData = new float[100];
172 //for (p = 0; p < 100; p++)
173 //{
174 // pNewXData[p] = m_nOverallCounter; // subset or sample iteration
175 // pNewZData[p] = p + 1; // all points
176 // pNewYData[p] = 125.0F + ((float)(Rand_Num.NextDouble()) * 9.0F) + (25.0F * (float)Math.Sin(((float)m_nOverallCounter) * .04F * ((float)(p + 1) * 3.0F)));
177 //}
178 //if (nBump != 0)
179 // pNewYData[nBump] = pNewYData[nBump] + 50.0F;
180 //Pe3do1.PeData.Y.AppendData(pNewYData, 1);
181 //Pe3do1.PeData.X.AppendData(pNewXData, 1);
182 //Pe3do1.PeData.Z.AppendData(pNewZData, 1);
183
184 Pe3do1.PeFunction.PEreconstruct3dpolygons();
185 Pe3do1.Refresh();
186}
187*/
Tip: Uses property syntax like Pego1.PeData.Y[s, p]Click underlined properties to view documentation