Flattened Fly By
1//! Double Click to start and stop Auto Rotation. //2//! Left click and drag to rotate. Also Hold shift to translate. //3//! Mouse Wheel zooms in/out.4//! Middle Button hold down while drag rotates light. //5//! Right click to show popup menu. //6 7int Row, Col, o, nQ, nStartRow, nStartCol, s;8int nEndRow, nEndCol, nTargetRows, nTargetCols;9int rowcounter, colcounter;10Boolean foundtargetindex = false;11 12Pe3do1.PePlot.Option.DxZoomMax = 1.6F; // v10 New properties to control max and min mousewheel zoom13Pe3do1.PePlot.Option.DxZoomMin = -8F;14 15Pe3do1.PePlot.Option.DxViewportPanFactor = 3.5F; // v10 New properties to control shift/drag and mousewheel sensitivity16Pe3do1.PeUserInterface.Scrollbar.MouseWheelZoomFactor = 3.5F;17 18// Enable smooth rotating and zooming //19Pe3do1.PeUserInterface.Scrollbar.ScrollSmoothness = 4;20Pe3do1.PeUserInterface.Scrollbar.MouseWheelZoomSmoothness = 4;21Pe3do1.PeUserInterface.Scrollbar.PinchZoomSmoothness = 2;22 23// Hide Axes24Pe3do1.PeGrid.Option.ShowXAxis = ShowAxis.Empty;25Pe3do1.PeGrid.Option.ShowYAxis = ShowAxis.Empty;26Pe3do1.PeGrid.Option.ShowZAxis = ShowAxis.Empty;27 28// Set eye/camera distance, or Zoom amount //29Pe3do1.PeUserInterface.Scrollbar.ViewingHeight = 23;30Pe3do1.PeUserInterface.Scrollbar.DegreeOfRotation = 44;31 32// Set a light location //33Pe3do1.PeFunction.SetLight(0, .20F, -1.75F, 2.35F);34 35// Set eye/camera distance, or Zoom amount //36Pe3do1.PePlot.Option.DxZoom = -.37F;37 38// Set a chart translation //39Pe3do1.PePlot.Option.DxViewportX = -7.8F;40Pe3do1.PePlot.Option.DxViewportY = .8F;41 42// Enable button dragging //43Pe3do1.PeUserInterface.Scrollbar.MouseDraggingX = true;44Pe3do1.PeUserInterface.Scrollbar.MouseDraggingY = true;45 46// Enable DegreePrompting, to view rotation, zoom, light location to aid47// in determining different default values for such properties //48Pe3do1.PePlot.Option.DegreePrompting = true;49 50// Reduce the terrain height with respect to surface area51Pe3do1.PeGrid.Option.GridAspectX = 10.0F;52Pe3do1.PeGrid.Option.GridAspectZ = 10.0F;53Pe3do1.PePlot.Option.DxFitControlShape = false;54 55// Load data from terrain file56nStartRow = 0;57nEndRow = 1000;58nTargetRows = nEndRow - nStartRow + 1;59nStartCol = 0;60nEndCol = 1000;61nTargetCols = nEndCol - nStartCol + 1;62nQ = nTargetRows * nTargetCols;63 64Int32[] pElevData = new Int32[2250000];65 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[nTargetCols];86float[] pMyYData = new float[nQ];87float[] pMyZData = new float[nTargetCols];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 102 if (Row == nStartRow)103 pMyXData[Col - nStartCol] = Col + 1;104 105 if (Col == nStartCol)106 pMyZData[Row - nStartRow] = Row + 1;107 108 // See our help, topic SubsetByPoint to understand the below formula109 o = (rowcounter * nTargetRows) + colcounter;110 pMyYData[o] = (float)(pElevData[(Row * 1500) + Col] * 0.1);111 }112 }113 if (foundtargetindex)114 colcounter = colcounter + 1;115 }116 if (foundtargetindex)117 rowcounter = rowcounter + 1;118}119 120Pe3do1.PeData.Subsets = nTargetRows;121Pe3do1.PeData.Points = nTargetCols;122 123Pe3do1.PeData.DuplicateDataX = DuplicateData.PointIncrement; // Set duplicatex type properties before FastCopyFrom124Pe3do1.PeData.DuplicateDataZ = DuplicateData.SubsetIncrement;125 126// Perform the transfer of data //127Pe3do1.PeData.X.FastCopyFrom(pMyXData, nTargetCols);128Pe3do1.PeData.Y.FastCopyFrom(pMyYData, nQ);129Pe3do1.PeData.Z.FastCopyFrom(pMyZData, nTargetRows);130 131Pe3do1.PeLegend.ContourLegendPrecision = ContourLegendPrecision.ZeroDecimals;132 133// Set Contour Color regions //134Pe3do1.PeColor.SubsetColors.Clear();135for (s = 0; s <= 31; s++)136 Pe3do1.PeColor.SubsetColors[s] = Color.FromArgb(255, 0, (byte)(31 + (s * 7)), (byte)(95 + (s * 5)));137for (s = 0; s <= 31; s++)138 Pe3do1.PeColor.SubsetColors[32 + s] = Color.FromArgb(255, 0, (byte)(95 + (s * 5)), 0);139for (s = 0; s <= 35; s++)140 Pe3do1.PeColor.SubsetColors[64 + s] = Color.FromArgb(255, (byte)(128 + (s * 3)), (byte)(128 + (s * 3)), (byte)(128 + (s * 3)));141 142// For when ViewingStyle is monochrome //143for (s = 0; s <= 99; s++)144 Pe3do1.PeColor.SubsetShades[s] = Color.FromArgb(255, (byte)(50 + (s * 2)), (byte)(50 + (s * 2)), (byte)(50 + (s * 2)));145 146Pe3do1.PeLegend.ContourStyle = true;147Pe3do1.PePlot.Option.SurfacePolygonBorders = true;148Pe3do1.PeLegend.Show = true;149Pe3do1.PeLegend.Location = LegendLocation.Right;150Pe3do1.PeUserInterface.Menu.LegendLocation = MenuControl.Show;151Pe3do1.PePlot.Allow.WireFrame = false;152 153// Mechanism to control polygon border color //154Pe3do1.PeColor.SubsetColors[(int)(SurfaceColors.WireFrame)] = Color.FromArgb(255, 80, 80, 80);155Pe3do1.PeColor.SubsetColors[(int)(SurfaceColors.SolidSurface)] = Color.FromArgb(255, 148, 148, 148);156 157Pe3do1.PeString.MainTitle = "";158Pe3do1.PeString.SubTitle = "||Mouse Wheel zooms. Mouse Drag rotates. Mouse Drag+SHIFT shifts image. ";159Pe3do1.PeString.MultiSubTitles[0] = "||Double Click start/stop Rotation. Mouse Drag+MIDDLE rotates light. ";160 161Pe3do1.PeFont.Fixed = true;163Pe3do1.PeConfigure.PrepareImages = true;164Pe3do1.PeConfigure.CacheBmp = true;165Pe3do1.PeUserInterface.Allow.FocalRect = false;166 167Pe3do1.PeConfigure.ImageAdjustLeft = 0;168Pe3do1.PeConfigure.ImageAdjustRight = 0;169Pe3do1.PeConfigure.ImageAdjustBottom = 0;170 171Pe3do1.PeConfigure.TextShadows = TextShadows.BoldText;172Pe3do1.PeFont.Label.Bold = true;173 174// There are different plotting method values for each //175// case of PolyMode //176Pe3do1.PePlot.Method = ThreeDGraphPlottingMethod.Four;177Pe3do1.PePlot.Allow.WireFrame = false;178Pe3do1.PeUserInterface.Menu.Contour = MenuControl.Hide;179 180Pe3do1.PeUserInterface.Dialog.PlotCustomization = false;181 182// Set various export defaults //183Pe3do1.PeSpecial.DpiX = 600;184Pe3do1.PeSpecial.DpiY = 600;185 186// default export setting //187Pe3do1.PeUserInterface.Dialog.ExportSizeDef = ExportSizeDef.NoSizeOrPixel;188Pe3do1.PeUserInterface.Dialog.ExportTypeDef = ExportTypeDef.Png;189Pe3do1.PeUserInterface.Dialog.ExportDestDef = ExportDestDef.Clipboard;190Pe3do1.PeUserInterface.Dialog.ExportUnitXDef = "1280";191Pe3do1.PeUserInterface.Dialog.ExportUnitYDef = "768";192Pe3do1.PeUserInterface.Dialog.ExportImageDpi = 300;193Pe3do1.PeUserInterface.Allow.TextExport = false;194Pe3do1.PeUserInterface.Dialog.AllowEmfExport = false;195Pe3do1.PeUserInterface.Dialog.AllowWmfExport = false;196 197// Enable CursorPromptTracking HighlighColor, etc only applicable to Direct3D RenderEngine198Pe3do1.PeUserInterface.Cursor.PromptTracking = true;199Pe3do1.PeUserInterface.Cursor.PromptStyle = CursorPromptStyle.YValue; // only y and xyz are options.200Pe3do1.PeUserInterface.Cursor.HighlightColor = Color.FromArgb(255, 255, 0, 0);201Pe3do1.PeUserInterface.HotSpot.Data = false; // true provides hotspot data202Pe3do1.PeUserInterface.Menu.DataShadow = MenuControl.Show;203 204// v9.5205Pe3do1.PeUserInterface.Menu.AnnotationControl = true;206Pe3do1.PeUserInterface.Menu.ShowAnnotationText = MenuControl.Show;207Pe3do1.PeUserInterface.Menu.AnnotationTextFixedSize = MenuControl.Show;208 209// Add some random graph annotations // // v9.5210int aCnt = 0;211for (int annot = 0; annot < 20; annot++)212{213 int nRndRow = (int)(Rand_Num.NextDouble() * (float)nTargetRows - 1);214 int nRndCol = (int)(Rand_Num.NextDouble() * (float)nTargetCols - 1);215 Pe3do1.PeAnnotation.Graph.X[aCnt] = nStartCol + nRndCol + 1;216 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nStartRow + nRndRow + 1;218 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.LargeDotSolid;219 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";220 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 200, 0, 0);221 MainWindow.m_nAnnotationStartIndices[annot] = aCnt;222 aCnt++;223 Pe3do1.PeAnnotation.Graph.X[aCnt] = nStartCol + nRndCol + 1;224 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nStartRow + nRndRow + 1;226 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.Pointer;227 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "|lAnnotation " + annot.ToString();228 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 250, 250, 250);229 aCnt++;230}231Pe3do1.PeAnnotation.Show = true;232Pe3do1.PeAnnotation.Graph.Show = true;233Pe3do1.PeAnnotation.Graph.LeftJustificationOutside = true;234Pe3do1.PeAnnotation.Graph.SymbolObstacles = true;235Pe3do1.PeFont.GraphAnnotationTextSize = 110;236Pe3do1.PeUserInterface.HotSpot.GraphAnnotation = true;237 238Pe3do1.PeUserInterface.Menu.CustomMenuText[0] = "Zoom Rotate on Center ";239Pe3do1.PeUserInterface.Menu.CustomMenuState[0, 0] = CustomMenuState.Checked;240Pe3do1.PeUserInterface.Menu.CustomMenuLocation[0] = CustomMenuLocation.AboveSeparator;241Pe3do1.PeString.MultiSubTitles[1] = "Key 0-9 rotates/zooms at annotation| |Popup Menu size/hide annotation text.";242 243// Set a default ViewingAt location.244float x, y, z;245x = (float)Pe3do1.PeAnnotation.Graph.X[0];246y = (float)Pe3do1.PeAnnotation.Graph.Y[0];247z = (float)Pe3do1.PeAnnotation.Graph.Z[0];248Pe3do1.PeFunction.SetViewingAt(x, y, z);249 250Pe3do1.PeConfigure.RenderEngine = RenderEngine.Direct3D;251 252// Note RenderEngine 3DX requires setting RenderEngine before QuickStyle253Pe3do1.PeColor.BitmapGradientMode = true;254Pe3do1.PeColor.QuickStyle = QuickStyle.DarkLine;255Pe3do1.PeConfigure.BorderTypes = TABorder.NoBorder;256 257Pe3do1.PeData.ComputeShader = true; // v10 Enable ComputeShader for fastest possible rendering.258 259Pe3do1.PeFunction.Force3dxVerticeRebuild = true;260Pe3do1.PeFunction.Force3dxAnnotVerticeRebuild = true;261 262Pe3do1.PeFunction.ReinitializeResetImage();263Pe3do1.Invalidate();264Pe3do1.Refresh();265 266// The TableLayoutPanel takes a bit of taming to get the timer auto rotation working from the initial view267Pe3do1.PeUserInterface.AutoRotation = true;268Pe3do1.SuspendLayout();269Pe3do1.PeFunction.ReinitializeResetImage();270Pe3do1.Invalidate();271Pe3do1.Refresh();272Pe3do1.ResumeLayout();Pego1.PeData.Y[s, p]Click underlined properties to view documentation