Contoured surface
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 = 4F; // v10 New properties to control max and min mousewheel zoom12Pe3do1.PePlot.Option.DxZoomMin = -4F;13 14Pe3do1.PePlot.Option.DxViewportPanFactor = 1.5F; // v10 New properties to control shift/drag and mousewheel sensitivity15Pe3do1.PeUserInterface.Scrollbar.MouseWheelZoomFactor = 3.5F;16 17// Enable smooth rotating and zooming //18Pe3do1.PeUserInterface.Scrollbar.ScrollSmoothness = 4;19Pe3do1.PeUserInterface.Scrollbar.MouseWheelZoomSmoothness = 4;20Pe3do1.PeUserInterface.Scrollbar.PinchZoomSmoothness = 2;21 22// Enable button dragging //23Pe3do1.PeUserInterface.Scrollbar.MouseDraggingX = true;24Pe3do1.PeUserInterface.Scrollbar.MouseDraggingY = true;25 26// Do not auto fit to shape of window //27Pe3do1.PePlot.Option.DxFitControlShape = false;28 29// When data is not square use GridAspectX or Z30Pe3do1.PeGrid.Option.GridAspectX = 1.5F;31Pe3do1.PeGrid.Option.GridAspectZ = 1.0F;32 33// Set eye/camera distance, or Zoom amount //34Pe3do1.PePlot.Option.DxZoom = -1.20F;35// Set camera position //36Pe3do1.PeUserInterface.Scrollbar.ViewingHeight = 26;37Pe3do1.PeUserInterface.Scrollbar.DegreeOfRotation = 232;38 39// Set a light location //40Pe3do1.PeFunction.SetLight(0, 2.5F, -1.5F, .25F);41 42// Enable DegreePrompting, to view rotation, zoom, light location to aid43// in determining different default values for such properties //44Pe3do1.PePlot.Option.DegreePrompting = true;45 46// Set PlottingMethod //47Pe3do1.PePlot.Method = ThreeDGraphPlottingMethod.Four;48 49// Pass Data //50Pe3do1.PeGrid.Configure.XAxisScaleControl = Gigasoft.ProEssentials.Enums.ScaleControl.Log;51Pe3do1.PeString.XAxisLabel = "X in Log";52 53int nRndRow = (int)(Rand_Num.NextDouble() * 320.0F) + 80;54int nRndCol = (int)(Rand_Num.NextDouble() * 320.0F) + 80;55 56nStartRow = 100;57nEndRow = 250;58nTargetRows = nEndRow - nStartRow + 1;59 60nStartCol = 200;61nEndCol = 250;62nTargetCols = nEndCol - nStartCol + 1;63nQ = nTargetRows * nTargetCols;64 65Int32[] pElevData = new Int32[2250000];66String filepath = null;67filepath = System.AppDomain.CurrentDomain.BaseDirectory + "\\terrain2.bin";68System.IO.FileStream fs = null;69try70{71 fs = new System.IO.FileStream(filepath, System.IO.FileMode.Open);72}73catch74{75 System.Windows.Forms.MessageBox.Show("Demo File Not Found?", "Error", System.Windows.Forms.MessageBoxButtons.OK);76 System.Windows.Forms.Application.Exit();77}78 79System.IO.BinaryReader r = new System.IO.BinaryReader(fs);80 81for (o = 0; o < 2250000; o++)82 pElevData[o] = r.ReadInt32();83fs.Close();84 85float[] pMyXData = new float[nQ];86float[] pMyYData = new float[nQ];87float[] pMyZData = new float[nQ];88rowcounter = 0;89colcounter = 0;90 91for (Row = 0; Row < 1500; Row++)92{93 for (Col = 0; Col < 1500; Col++)94 {95 foundtargetindex = false;96 if (Row >= nStartRow && Row <= nEndRow)97 {98 if (Col >= nStartCol && Col <= nEndCol)99 {100 foundtargetindex = true;101 o = (rowcounter * nTargetRows) + colcounter;102 pMyXData[o] = (Col + 1) * (Col - nStartCol + 1);103 pMyZData[o] = Row + 1;104 float f = (float)(pElevData[(Row * 1500) + Col]);105 if (f < 14100.0f) { f = 10000.0F; } // create a plateau106 if (f > 16000.0f) { f = 17000.0F; } // create a plateau107 pMyYData[o] = f * 0.1F;108 }109 }110 if (foundtargetindex)111 colcounter = colcounter + 1;112 }113 if (foundtargetindex)114 rowcounter = rowcounter + 1;115}116 117Pe3do1.PeData.Subsets = nTargetRows;118Pe3do1.PeData.Points = nTargetCols;119 120// Perform the transfer of data //121Pe3do1.PeData.X.FastCopyFrom(pMyXData, nQ);122Pe3do1.PeData.Y.FastCopyFrom(pMyYData, nQ);123Pe3do1.PeData.Z.FastCopyFrom(pMyZData, nQ);124 125Pe3do1.PeData.NullDataValue = 0.0F;126 127Pe3do1.PeLegend.Location = LegendLocation.Left;128Pe3do1.PeLegend.Show = true;129Pe3do1.PeUserInterface.Menu.LegendLocation = MenuControl.Show;130 131// v9 features132Pe3do1.PeColor.ContourColorProportions[0] = .1F;133Pe3do1.PeColor.ContourColorProportions[1] = .05F;134Pe3do1.PeColor.ContourColorProportions[2] = .1F;135Pe3do1.PeColor.ContourColorProportions[3] = .63F;136Pe3do1.PeColor.ContourColorProportions[4] = .06F;137Pe3do1.PeColor.ContourColorProportions[5] = .06F;138 139Pe3do1.PeColor.ContourColorBlends = 0; // this must be set before COLORSET, COLORSET ALWAYS LAST140Pe3do1.PeColor.ContourColorSet = ContourColorSet.BlueCyanGreenYellowBrownWhite;141 142Pe3do1.PePlot.Option.ShowContour = ShowContour.BottomLines;143Pe3do1.PePlot.Option.ShowWireFrame = true;144Pe3do1.PeColor.BarBorderColor = Color.FromArgb(85, 0, 0, 0);145 146Pe3do1.PeGrid.Configure.AutoMinMaxPadding = 0;147Pe3do1.PeData.SurfaceNullDataGaps = true;148Pe3do1.PeLegend.ContourStyle = true;149 150// Set various other properties //151Pe3do1.PeFont.Fixed = true;152 153Pe3do1.PeString.MainTitle = "";154Pe3do1.PeString.SubTitle = "||Mouse Wheel zooms. Mouse Drag rotates. Mouse Drag+SHIFT shifts image. ";155Pe3do1.PeString.MultiSubTitles[0] = "||Double Click start/stop Rotation. Mouse Drag+MIDDLE rotates light. ";156 158Pe3do1.PeFont.SizeGlobalCntl = 1.1F;159Pe3do1.PeLegend.ContourLegendPrecision = ContourLegendPrecision.ZeroDecimals;160 161Pe3do1.PeConfigure.PrepareImages = true;162Pe3do1.PeConfigure.CacheBmp = true;163Pe3do1.PeUserInterface.Allow.FocalRect = false;164 165Pe3do1.PeColor.SubsetColors[(int)(SurfaceColors.WireFrame)] = Color.FromArgb(255, 198, 0, 0);166Pe3do1.PeColor.SubsetColors[(int)(SurfaceColors.SolidSurface)] = Color.FromArgb(255, 0, 148, 0);167 168// Add Some Padding around image //169Pe3do1.PeConfigure.ImageAdjustLeft = 100;170Pe3do1.PeConfigure.ImageAdjustRight = 100;171Pe3do1.PeConfigure.ImageAdjustBottom = 100;172 173Pe3do1.PeConfigure.TextShadows = TextShadows.BoldText;174Pe3do1.PeFont.Label.Bold = true;175 176// Set various export defaults //177Pe3do1.PeSpecial.DpiX = 600;178Pe3do1.PeSpecial.DpiY = 600;179 180// default export setting //181Pe3do1.PeUserInterface.Dialog.ExportSizeDef = ExportSizeDef.NoSizeOrPixel;182Pe3do1.PeUserInterface.Dialog.ExportTypeDef = ExportTypeDef.Png;183Pe3do1.PeUserInterface.Dialog.ExportDestDef = ExportDestDef.Clipboard;184Pe3do1.PeUserInterface.Dialog.ExportUnitXDef = "1280";185Pe3do1.PeUserInterface.Dialog.ExportUnitYDef = "768";186Pe3do1.PeUserInterface.Dialog.ExportImageDpi = 300;187Pe3do1.PeUserInterface.Dialog.AllowEmfExport = false;188Pe3do1.PeUserInterface.Dialog.AllowWmfExport = false;189 190Pe3do1.PeData.Precision = DataPrecision.TwoDecimals;191 192// Enable CursorPromptTracking HighlighColor, etc only applicable to Direct3D RenderEngine193Pe3do1.PeUserInterface.Cursor.PromptTracking = true;194Pe3do1.PeUserInterface.Cursor.PromptStyle = CursorPromptStyle.YValue; // only y and xyz are options.195Pe3do1.PeUserInterface.Cursor.TrackingCustomDataText = true;196Pe3do1.PeUserInterface.Cursor.PromptLocation = CursorPromptLocation.Text;197 198Pe3do1.PeUserInterface.Cursor.HighlightColor = Color.FromArgb(255, 255, 0, 0);199Pe3do1.PeUserInterface.HotSpot.Data = true; // true provides hotspot data200 201Pe3do1.PeUserInterface.Menu.DataShadow = MenuControl.Show;202 203Pe3do1.PeUserInterface.Menu.AnnotationControl = true;204Pe3do1.PeUserInterface.Menu.ShowAnnotationText = MenuControl.Show;205Pe3do1.PeUserInterface.Menu.AnnotationTextFixedSize = MenuControl.Show;206 207Pe3do1.PeConfigure.TextShadows = TextShadows.BoldText;208 209// Add some random graph annotations //210int aCnt = 0;211for (int annot = 0; annot < 10; annot++)212{213 nRndRow = (int)(Rand_Num.NextDouble() * (float)nTargetRows - 1);214 nRndCol = (int)(Rand_Num.NextDouble() * (float)nTargetCols - 1);215 float f = Pe3do1.PeData.X[nRndRow, nRndCol];216 Pe3do1.PeAnnotation.Graph.X[aCnt] = f;217 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nStartRow + nRndRow + 1;219 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.LargeDotSolid;220 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";221 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 0, 255, 0);222 MainWindow.m_nAnnotationStartIndices[annot] = aCnt;223 aCnt++;224 Pe3do1.PeAnnotation.Graph.X[aCnt] = f;225 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nStartRow + nRndRow + 1;227 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.Pointer;228 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "|lAnnotation " + annot.ToString();229 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 0, 255, 0);230 aCnt++;231}232 233Pe3do1.PeAnnotation.Line.YAxis[0] = 1200.0F;234Pe3do1.PeAnnotation.Line.YAxisColor[0] = Color.FromArgb(255, 255, 0, 0);235Pe3do1.PeAnnotation.Line.YAxisShow = true;236 237Pe3do1.PeAnnotation.Show = true;238Pe3do1.PeAnnotation.Graph.Show = true;239Pe3do1.PeAnnotation.Graph.LeftJustificationOutside = true;240Pe3do1.PeAnnotation.Graph.SymbolObstacles = true;241Pe3do1.PeFont.GraphAnnotationTextSize = 80;242Pe3do1.PeUserInterface.HotSpot.GraphAnnotation = true;243Pe3do1.PePlot.Option.DxSphereComplexity = 12;244Pe3do1.PeAnnotation.Graph.SizeCntl = .7f;245Pe3do1.PeAnnotation.InFront = true;246 247Pe3do1.PeUserInterface.Menu.CustomMenuText[0] = "Zoom Rotate on Center ";248Pe3do1.PeUserInterface.Menu.CustomMenuState[0, 0] = CustomMenuState.Checked;249Pe3do1.PeUserInterface.Menu.CustomMenuLocation[0] = CustomMenuLocation.AboveSeparator;250Pe3do1.PeString.MultiSubTitles[1] = "Key 0-9 rotates/zooms at annotation| |Popup Menu size/hide annotation text.";251 252// Set a default ViewingAt location.253float x, y, z;254x = (float)Pe3do1.PeAnnotation.Graph.X[0];255y = (float)Pe3do1.PeAnnotation.Graph.Y[0];256z = (float)Pe3do1.PeAnnotation.Graph.Z[0];257Pe3do1.PeFunction.SetViewingAt(x, y, z);258 259Pe3do1.PeConfigure.RenderEngine = RenderEngine.Direct3D;260Pe3do1.PeColor.BitmapGradientMode = false;261Pe3do1.PeColor.QuickStyle = QuickStyle.DarkNoBorder;262 263Pe3do1.PeColor.GridBandsPatching = false;264Pe3do1.PeColor.GridBands = false;265Pe3do1.PeColor.YBackColor = Color.Empty;266Pe3do1.PeColor.GridBrighten = true; // v10 Brightens Grid Lines267Pe3do1.PeColor.GraphForeground = Color.FromArgb(255, 0, 255, 255);268 269Pe3do1.PeData.ComputeShader = true; // v10 Enable ComputeShader for fastest possible rendering.270 271Pe3do1.PeFunction.Force3dxVerticeRebuild = true;272Pe3do1.PeFunction.Force3dxAnnotVerticeRebuild = true;273 274Pe3do1.PeFunction.ReinitializeResetImage();275Pe3do1.Invalidate();276Pe3do1.Refresh();277 278/*279////////////////////////////////////////////280// PeCustomTrackingDataText event handler //281////////////////////////////////////////////282private void Pe3do1_PeCustomTrackingDataText(object sender, Gigasoft.ProEssentials.EventArg.CustomTrackingDataTextEventArgs e)283{284 double dY = Pe3do1.PeUserInterface.Cursor.CursorValueY;285 e.TrackingText = String.Format("Surface with Plateaus:\n{0:0.000}", dY);286}287 288/////////////////////////////////289// PeDataHotSpot event handler //290/////////////////////////////////291private void Pe3do1_PeDataHotSpot(object sender, Gigasoft.ProEssentials.EventArg.DataHotSpotEventArgs e)292{293 this.Text = "DataPoint value " + Pe3do1.PeData.Y[e.SubsetIndex, e.PointIndex].ToString() + " s=" + e.SubsetIndex.ToString() + " p=" + e.PointIndex.ToString();294}295*/Pego1.PeData.Y[s, p]Click underlined properties to view documentation