3D Waterfall Plot
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 6int Row, Col, o, nQ, nStartRow, nStartCol;7int nEndRow, nEndCol, nTargetRows, nTargetCols;8int rowcounter, colcounter;9Boolean foundtargetindex = false;10 11Pe3do1.PePlot.Option.DxZoomMax = 2F; // v10 New properties to control max and min mousewheel zoom12Pe3do1.PePlot.Option.DxZoomMin = -2F;13 14Pe3do1.PePlot.Option.DxViewportPanFactor = 2.0F; // v10 New properties to control shift/drag and mousewheel sensitivity15Pe3do1.PeUserInterface.Scrollbar.MouseWheelZoomFactor = 3.75F;16 17// Enable smooth rotating and zooming //18Pe3do1.PeUserInterface.Scrollbar.ScrollSmoothness = 6;19Pe3do1.PeUserInterface.Scrollbar.MouseWheelZoomSmoothness = 6;20Pe3do1.PeUserInterface.Scrollbar.PinchZoomSmoothness = 3;21 22// Non-Surface chart, set PolyMode //23Pe3do1.PePlot.PolyMode = PolyMode.Scatter;24 25// Disable Legend //26Pe3do1.PeLegend.SubsetsToLegend[0] = -1;27 28// Pass Data //29nStartRow = 150;30nEndRow = 250;31nStartCol = 100;32nEndCol = 200;33nTargetRows = nEndRow - nStartRow + 1;34nTargetCols = nEndCol - nStartCol + 1;35nQ = nTargetRows * nTargetCols;36 37Int32[] pElevData = new Int32[2250000];38String filepath = null;39filepath = System.AppDomain.CurrentDomain.BaseDirectory + "\\terrain2.bin";40System.IO.FileStream fs = null;41try42{43 fs = new System.IO.FileStream(filepath, System.IO.FileMode.Open);44}45catch46{47 System.Windows.Forms.MessageBox.Show("Demo File Not Found?", "Error", System.Windows.Forms.MessageBoxButtons.OK);48 System.Windows.Forms.Application.Exit();49}50 51System.IO.BinaryReader r = new System.IO.BinaryReader(fs);52 53for (o = 0; o < 2250000; o++)54 pElevData[o] = r.ReadInt32();55fs.Close();56 57float[] pMyXData = new float[nQ];58float[] pMyYData = new float[nQ];59float[] pMyZData = new float[nQ];60rowcounter = 0;61colcounter = 0;62 63for (Row = 0; Row < 1500; Row++)64{65 for (Col = 0; Col < 1500; Col++)66 {67 foundtargetindex = false;68 if (Row >= nStartRow && Row <= nEndRow)69 {70 if (Col >= nStartCol && Col <= nEndCol)71 {72 foundtargetindex = true;73 o = (rowcounter * nTargetRows) + colcounter;74 pMyXData[o] = Col + 1;75 pMyZData[o] = Row + 1;76 pMyYData[o] = (float)(pElevData[(Row * 1500) + Col] * 0.1);77 }78 }79 if (foundtargetindex)80 colcounter = colcounter + 1;81 }82 if (foundtargetindex)83 rowcounter = rowcounter + 1;84}85 86Pe3do1.PeData.Subsets = nTargetRows;87Pe3do1.PeData.Points = nTargetCols;88 89// Perform the transfer of data //90Pe3do1.PeData.X.FastCopyFrom(pMyXData, nQ);91Pe3do1.PeData.Y.FastCopyFrom(pMyYData, nQ);92Pe3do1.PeData.Z.FastCopyFrom(pMyZData, nQ);93 94Pe3do1.PePlot.Option.WaterfallContours = true;95Pe3do1.PeColor.ContourColorBlends = 20;96Pe3do1.PeColor.ContourColorAlpha = 255;97Pe3do1.PeColor.ContourColorSet = ContourColorSet.BlueCyanGreenYellowBrownWhite;98 99Pe3do1.PePlot.Option.WaterfallBorders = true;100Pe3do1.PeColor.BarBorderColor = Color.FromArgb(255, 0, 0, 0);101 102for (int s = 0; s < Pe3do1.PeData.Subsets; s++)103 Pe3do1.PePlot.SubsetLineTypes[s] = LineType.MediumThinSolid;104 105Pe3do1.PeString.MainTitle = "";106Pe3do1.PeString.SubTitle = "||Mouse Wheel zooms. Mouse Drag rotates. Mouse Drag+SHIFT shifts image. ";107Pe3do1.PeString.MultiSubTitles[0] = "||Double Click start/stop Rotation. Mouse Drag+MIDDLE rotates light. ";108 109// Set camera position //110Pe3do1.PeUserInterface.Scrollbar.ViewingHeight = 36; // V9.5111Pe3do1.PeUserInterface.Scrollbar.DegreeOfRotation = 210;112Pe3do1.PePlot.Option.DxZoom = 0.47F;113 114// Set Plotting methods //115Pe3do1.PePlot.Method = Gigasoft.ProEssentials.Enums.ThreeDGraphPlottingMethod.Three; // Area116Pe3do1.PePlot.Allow.Area = true;117 118Pe3do1.PePlot.Option.DxFitControlShape = true;119Pe3do1.PeUserInterface.Menu.AnnotationControl = true; // v9.5120Pe3do1.PeUserInterface.Menu.ShowAnnotationText = MenuControl.Show;121Pe3do1.PeUserInterface.Menu.AnnotationTextFixedSize = MenuControl.Show;122Pe3do1.PeAnnotation.Graph.AnnotationTextFixedSize = true;123Pe3do1.PeUserInterface.Menu.ShowLegend = MenuControl.Hide;124Pe3do1.PeUserInterface.Menu.ShowWireFrame = MenuControl.Hide;125 126// Add some random graph annotations // // v9.5127int aCnt = 0;128for (int annot = 0; annot < 10; annot++)129{130 int nRndRow = (int)(Rand_Num.NextDouble() * (float)nTargetRows - 1);131 int nRndCol = (int)(Rand_Num.NextDouble() * (float)nTargetCols - 1);132 Pe3do1.PeAnnotation.Graph.X[aCnt] = nStartCol + nRndCol + 1;133 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nStartRow + nRndRow + 1;135 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.DiamondSolid;136 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";137 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 255, 255);138 MainWindow.m_nAnnotationStartIndices[annot] = aCnt;139 aCnt++;140 Pe3do1.PeAnnotation.Graph.X[aCnt] = nStartCol + nRndCol + 1;141 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nStartRow + nRndRow + 1;143 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.Pointer;144 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "|lAnnotation " + annot.ToString();145 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 255, 255);146 aCnt++;147}148 149// Add a Graph Annotation to highlight a slice with a thick line150int nHighLightSubset = 10;151 152aCnt = 50; // offset153int pt = 0;157Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.StartPoly;158aCnt++;159for (pt = 1; pt < nTargetCols - 1; pt++)160{164 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.AddPolyPoint;165 aCnt++;166}170Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.EndPolylineThick;171Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 0, 0);172Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";173 174Pe3do1.PeAnnotation.Show = true;175Pe3do1.PeAnnotation.Graph.Show = true;176Pe3do1.PeAnnotation.Graph.LeftJustificationOutside = true;177Pe3do1.PeAnnotation.Graph.SymbolObstacles = true;178Pe3do1.PeFont.GraphAnnotationTextSize = 110;179Pe3do1.PeUserInterface.HotSpot.GraphAnnotation = true;180Pe3do1.PeAnnotation.Graph.SizeCntl = 1.2;181Pe3do1.PePlot.Option.DegreePrompting = true;182 183Pe3do1.PePlot.LinesOrTubes = LinesOrTubes.AllTubes;184Pe3do1.PePlot.Option.TubeThicknessMin = .3f;185Pe3do1.PeUserInterface.HotSpot.Data = true;186Pe3do1.PeAnnotation.InFront = false;187 188// Set font size //190Pe3do1.PeFont.Fixed = true;191 192// Note RenderEngine 3DX requires setting renderengine before QuickStyle193Pe3do1.PeColor.BitmapGradientMode = true;194Pe3do1.PeColor.QuickStyle = QuickStyle.DarkNoBorder;195 196Pe3do1.PeConfigure.PrepareImages = true;197Pe3do1.PeUserInterface.Allow.FocalRect = false;198Pe3do1.PeConfigure.CacheBmp = true;199 200// Add Some Padding around image //201Pe3do1.PeConfigure.ImageAdjustLeft = 100;202Pe3do1.PeConfigure.ImageAdjustRight = 100;203Pe3do1.PeConfigure.ImageAdjustBottom = 100;204 205Pe3do1.PeConfigure.TextShadows = TextShadows.BoldText;206Pe3do1.PeFont.Label.Bold = true;207 208// Enable button dragging //209Pe3do1.PeUserInterface.Scrollbar.MouseDraggingX = true;210Pe3do1.PeUserInterface.Scrollbar.MouseDraggingY = true;211 212// Set various export defaults //213Pe3do1.PeSpecial.DpiX = 600;214Pe3do1.PeSpecial.DpiY = 600;215 216// default export setting //217Pe3do1.PeUserInterface.Dialog.ExportSizeDef = ExportSizeDef.NoSizeOrPixel;218Pe3do1.PeUserInterface.Dialog.ExportTypeDef = ExportTypeDef.Png;219Pe3do1.PeUserInterface.Dialog.ExportDestDef = ExportDestDef.Clipboard;220Pe3do1.PeUserInterface.Dialog.ExportUnitXDef = "1280";221Pe3do1.PeUserInterface.Dialog.ExportUnitYDef = "768";222Pe3do1.PeUserInterface.Dialog.ExportImageDpi = 300;223Pe3do1.PeUserInterface.Dialog.AllowEmfExport = false;224Pe3do1.PeUserInterface.Dialog.AllowWmfExport = false;225 226Pe3do1.PeConfigure.AntiAliasGraphics = true;227Pe3do1.PeConfigure.AntiAliasText = true;228 229Pe3do1.PeConfigure.RenderEngine = RenderEngine.Direct3D;230 231Pe3do1.PeFunction.Force3dxVerticeRebuild = true;232Pe3do1.PeFunction.Force3dxAnnotVerticeRebuild = true;233 234Pe3do1.PeFunction.ReinitializeResetImage();235Pe3do1.Invalidate();236Pe3do1.Refresh();Pego1.PeData.Y[s, p]Click underlined properties to view documentation