3D Large Shaded 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, s;7int nEndRow, nEndCol, nTargetRows, nTargetCols;8int rowcounter, colcounter;9Boolean foundtargetindex = false;10 11Pe3do1.PePlot.Option.DxZoomMax = 3F; // 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 = 3;19Pe3do1.PeUserInterface.Scrollbar.MouseWheelZoomSmoothness = 3;20Pe3do1.PeUserInterface.Scrollbar.PinchZoomSmoothness = 2;21 22// Enable DegreePrompting, to view rotation, zoom, light location to aid23// in determining different default values for such properties //24Pe3do1.PePlot.Option.DegreePrompting = true;25 26// Set eye/camera rotation //27Pe3do1.PeUserInterface.Scrollbar.ViewingHeight = 22;28Pe3do1.PeUserInterface.Scrollbar.DegreeOfRotation = 301;29 30// Set eye/camera distance, or Zoom amount //31Pe3do1.PePlot.Option.DxZoom = 0.0F;32 33// Set a light rotation location //34Pe3do1.PeFunction.SetLight(0, 1.5F, -1.5F, 2.0F);35 36// Set a chart translation //37Pe3do1.PePlot.Option.DxViewportX = 0.0F;38Pe3do1.PePlot.Option.DxViewportY = 0.7F;39 40// Enable button dragging //41Pe3do1.PeUserInterface.Scrollbar.MouseDraggingX = true;42Pe3do1.PeUserInterface.Scrollbar.MouseDraggingY = true;43 44// Pass Data //45nStartRow = 0;46nEndRow = 1000;47nStartCol = 0;48nEndCol = 1000;49nTargetRows = nEndRow - nStartRow + 1;50nTargetCols = nEndCol - nStartCol + 1;51nQ = nTargetRows * nTargetCols;52 53Int32[] pElevData = new Int32[2250000];54String filepath = null;55filepath = System.AppDomain.CurrentDomain.BaseDirectory + "\\terrain2.bin";56System.IO.FileStream fs = null;57try58{59 fs = new System.IO.FileStream(filepath, System.IO.FileMode.Open);60}61catch62{63 System.Windows.Forms.MessageBox.Show("Demo File Not Found?", "Error", System.Windows.Forms.MessageBoxButtons.OK);64 System.Windows.Forms.Application.Exit();65}66 67System.IO.BinaryReader r = new System.IO.BinaryReader(fs);68 69for (o = 0; o < 2250000; o++)70 pElevData[o] = r.ReadInt32();71fs.Close();72 73float[] pMyXData = new float[nTargetCols];74float[] pMyYData = new float[nQ];75float[] pMyZData = new float[nTargetRows];76rowcounter = 0;77colcounter = 0;78 79for (Row = 0; Row < 1500; Row++)80{81 for (Col = 0; Col < 1500; Col++)82 {83 foundtargetindex = false;84 if (Row >= nStartRow && Row <= nEndRow)85 {86 if (Col >= nStartCol && Col <= nEndCol)87 {88 foundtargetindex = true;89 90 if (Row == nStartRow)91 pMyXData[Col - nStartCol] = Col + 1;92 93 if (Col == nStartCol)94 pMyZData[Row - nStartRow] = Row + 1;95 96 // See our help, topic SubsetByPoint to understand the below formula97 o = (rowcounter * nTargetRows) + colcounter;98 pMyYData[o] = (float)(pElevData[(Row * 1500) + Col] * 0.1);99 }100 }101 if (foundtargetindex)102 colcounter = colcounter + 1;103 }104 if (foundtargetindex)105 rowcounter = rowcounter + 1;106}107 108Pe3do1.PeData.Subsets = nTargetRows;109Pe3do1.PeData.Points = nTargetCols;110 111Pe3do1.PeData.DuplicateDataX = DuplicateData.PointIncrement; // Set DuplicateDataX type properties before FastCopyFrom112Pe3do1.PeData.DuplicateDataZ = DuplicateData.SubsetIncrement;113 114// Perform the transfer of data //115Pe3do1.PeData.X.FastCopyFrom(pMyXData, nTargetCols);116Pe3do1.PeData.Y.FastCopyFrom(pMyYData, nQ);117Pe3do1.PeData.Z.FastCopyFrom(pMyZData, nTargetRows);118 119Pe3do1.PeLegend.ContourLegendPrecision = ContourLegendPrecision.ZeroDecimals;120 121Pe3do1.PeLegend.Location = LegendLocation.Right;122Pe3do1.PeLegend.ContourStyle = true;123 124// Set Contour Color regions //125Pe3do1.PeColor.SubsetColors.Clear();126for (s = 0; s <= 31; s++)127 Pe3do1.PeColor.SubsetColors[s] = Color.FromArgb(255, 0, (byte)(31 + (s * 7)), (byte)(95 + (s * 5)));128for (s = 0; s <= 31; s++)129 Pe3do1.PeColor.SubsetColors[32 + s] = Color.FromArgb(255, 0, (byte)(95 + (s * 5)), 0);130for (s = 0; s <= 35; s++)131 Pe3do1.PeColor.SubsetColors[64 + s] = Color.FromArgb(255, (byte)(128 + (s * 3)), (byte)(128 + (s * 3)), (byte)(128 + (s * 3)));132 133// For when ViewingStyle is monochrome //134for (s = 0; s <= 99; s++)135 Pe3do1.PeColor.SubsetShades[s] = Color.FromArgb(255, (byte)(50 + (s * 2)), (byte)(50 + (s * 2)), (byte)(50 + (s * 2)));136 137Pe3do1.PeLegend.ContourStyle = true;138Pe3do1.PeLegend.Show = true;139Pe3do1.PeLegend.Location = LegendLocation.Right;140Pe3do1.PeUserInterface.Menu.LegendLocation = MenuControl.Show;141 142// There are different plotting method values for each //143// case of PolyMode.144Pe3do1.PePlot.Method = Gigasoft.ProEssentials.Enums.ThreeDGraphPlottingMethod.Four;145Pe3do1.PePlot.Allow.WireFrame = false;146Pe3do1.PeUserInterface.Dialog.PlotCustomization = false;147 148// Set Titles //149Pe3do1.PeString.MainTitle = "";150Pe3do1.PeString.SubTitle = "||Mouse Wheel zooms. Mouse Drag rotates. Mouse Drag+SHIFT shifts image. ";151Pe3do1.PeString.MultiSubTitles[0] = "||Double Click start/stop Rotation. Mouse Drag+MIDDLE rotates light. ";152 153// Note RenderEngine 3DX requires setting renderengine before QuickStyle154Pe3do1.PeColor.BitmapGradientMode = true;155Pe3do1.PeColor.QuickStyle = QuickStyle.DarkNoBorder;156 157// Set font size //159 160Pe3do1.PeColor.SubsetColors[(int)SurfaceColors.WireFrame] = Color.FromArgb(255, 215, 215, 215);161Pe3do1.PeColor.SubsetColors[(int)SurfaceColors.SolidSurface] = Color.FromArgb(255, 228, 228, 228);162 163// Set Various Other Properties //164 165Pe3do1.PeConfigure.PrepareImages = true;166Pe3do1.PeConfigure.CacheBmp = true;167Pe3do1.PeUserInterface.Allow.FocalRect = false;168Pe3do1.PeFont.Fixed = true;169 170Pe3do1.PeConfigure.TextShadows = TextShadows.BoldText;171Pe3do1.PeFont.Label.Bold = true;172 173// Set various export defaults //174Pe3do1.PeSpecial.DpiX = 600;175Pe3do1.PeSpecial.DpiY = 600;176 177// default export setting //178Pe3do1.PeUserInterface.Dialog.ExportSizeDef = ExportSizeDef.NoSizeOrPixel;179Pe3do1.PeUserInterface.Dialog.ExportTypeDef = ExportTypeDef.Png;180Pe3do1.PeUserInterface.Dialog.ExportDestDef = ExportDestDef.Clipboard;181Pe3do1.PeUserInterface.Dialog.ExportUnitXDef = "1280";182Pe3do1.PeUserInterface.Dialog.ExportUnitYDef = "768";183Pe3do1.PeUserInterface.Dialog.ExportImageDpi = 300;184Pe3do1.PeUserInterface.Allow.TextExport = false;185Pe3do1.PeUserInterface.Dialog.AllowEmfExport = false;186Pe3do1.PeUserInterface.Dialog.AllowWmfExport = false;187 188// Enable CursorPromptTracking HighlighColor, etc only applicable to Direct3D RenderEngine189Pe3do1.PeUserInterface.HotSpot.Data = false; // true provides hotspot data190Pe3do1.PeUserInterface.Cursor.PromptTracking = true;191Pe3do1.PeUserInterface.Cursor.PromptStyle = CursorPromptStyle.YValue;192Pe3do1.PeData.Precision = DataPrecision.OneDecimal;193Pe3do1.PeUserInterface.Cursor.HighlightColor = Color.FromArgb(255, 255, 0, 0);194Pe3do1.PeUserInterface.Menu.Contour = MenuControl.Hide;195 196// v9.5197Pe3do1.PeUserInterface.Menu.AnnotationControl = true;198Pe3do1.PeUserInterface.Menu.ShowAnnotationText = MenuControl.Show;199Pe3do1.PeUserInterface.Menu.AnnotationTextFixedSize = MenuControl.Show;200Pe3do1.PePlot.Option.DxFitControlShape = false;201Pe3do1.PeGrid.Option.GridAspectX = 2.0F;202Pe3do1.PeGrid.Option.GridAspectZ = 2.0F;203 204// Add some random graph annotations //205int aCnt = 0;206for (int annot = 0; annot < 20; annot++)207{208 int nRndRow = (int)(Rand_Num.NextDouble() * (float)nTargetRows - 1);209 int nRndCol = (int)(Rand_Num.NextDouble() * (float)nTargetCols - 1);210 Pe3do1.PeAnnotation.Graph.X[aCnt] = nStartCol + nRndCol + 1;211 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nStartRow + nRndRow + 1;213 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.DotSolid;214 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";215 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 200, 0, 0);216 MainWindow.m_nAnnotationStartIndices[annot] = aCnt;217 aCnt++;218 Pe3do1.PeAnnotation.Graph.X[aCnt] = nStartCol + nRndCol + 1;219 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nStartRow + nRndRow + 1;221 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.Pointer;222 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "|lAnnotation " + annot.ToString();223 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 250, 250, 250);224 aCnt++;225}226Pe3do1.PeAnnotation.Show = true;227Pe3do1.PeAnnotation.Graph.Show = true;228Pe3do1.PeAnnotation.Graph.LeftJustificationOutside = true;229Pe3do1.PeAnnotation.Graph.SymbolObstacles = true;230Pe3do1.PeFont.GraphAnnotationTextSize = 110;231Pe3do1.PeUserInterface.HotSpot.GraphAnnotation = true;232 233Pe3do1.PeUserInterface.Menu.CustomMenuText[0] = "Zoom Rotate on Center ";234Pe3do1.PeUserInterface.Menu.CustomMenuState[0, 0] = CustomMenuState.Checked;235Pe3do1.PeUserInterface.Menu.CustomMenuLocation[0] = CustomMenuLocation.AboveSeparator;236Pe3do1.PeString.MultiSubTitles[1] = "Key 0-9 rotates/zooms at annotation| |Popup Menu size/hide annotation text.";237 238// Set a default ViewingAt location.239float x, y, z;240x = (float)Pe3do1.PeAnnotation.Graph.X[0];241y = (float)Pe3do1.PeAnnotation.Graph.Y[0];242z = (float)Pe3do1.PeAnnotation.Graph.Z[0];243Pe3do1.PeFunction.SetViewingAt(x, y, z);244 245Pe3do1.PeFunction.Force3dxVerticeRebuild = true;246Pe3do1.PeFunction.Force3dxAnnotVerticeRebuild = true;247 248Pe3do1.PeConfigure.RenderEngine = RenderEngine.Direct3D;249 250Pe3do1.PeData.ComputeShader = true; // v10 Enable ComputeShader for fastest possible rendering.251 252Pe3do1.PeFunction.ReinitializeResetImage();253Pe3do1.Invalidate();254Pe3do1.Refresh();Pego1.PeData.Y[s, p]Click underlined properties to view documentation