3D Bar Chart
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 = 1.5F; // 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 = 4;19Pe3do1.PeUserInterface.Scrollbar.MouseWheelZoomSmoothness = 4;20Pe3do1.PeUserInterface.Scrollbar.PinchZoomSmoothness = 2;21 22// Non-Surface chart, set PolyMode //23Pe3do1.PePlot.PolyMode = PolyMode.ThreeDBar;24 25// change light location better suited for 3d bar26Pe3do1.PeFunction.SetLight(0, 4.6F, .8F, 9.5F);27 28// Pass Data //29nStartRow = 216;30nEndRow = 230;31nStartCol = 156;32nEndCol = 170;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}50System.IO.BinaryReader r = new System.IO.BinaryReader(fs);51 52for (o = 0; o < 2250000; o++)53 pElevData[o] = r.ReadInt32();54fs.Close();55 56float[] pMyXData = new float[nQ];57float[] pMyYData = new float[nQ];58float[] pMyZData = new float[nQ];59rowcounter = 0;60colcounter = 0;61 62for (Row = 0; Row < 1500; Row++)63{64 for (Col = 0; Col < 1500; Col++)65 {66 foundtargetindex = false;67 if (Row >= nStartRow && Row <= nEndRow)68 {69 if (Col >= nStartCol && Col <= nEndCol)70 {71 foundtargetindex = true;72 o = (rowcounter * nTargetRows) + colcounter;73 pMyXData[o] = Col + 1;74 pMyZData[o] = Row + 1;75 pMyYData[o] = (float)(pElevData[(Row * 1500) + Col] * 0.1);76 }77 }78 if (foundtargetindex)79 colcounter = colcounter + 1;80 }81 if (foundtargetindex)82 rowcounter = rowcounter + 1;83}84 85Pe3do1.PeData.Subsets = nTargetRows;86Pe3do1.PeData.Points = nTargetCols;87 88// Perform the transfer of data //89Pe3do1.PeData.X.FastCopyFrom(pMyXData, nQ);90Pe3do1.PeData.Y.FastCopyFrom(pMyYData, nQ);91Pe3do1.PeData.Z.FastCopyFrom(pMyZData, nQ);92 93// Set Various Other Properties //94Pe3do1.PeFont.Fixed = true;95 96Pe3do1.PeColor.SubsetColors[0] = Color.FromArgb(216, 0, 148, 0);97Pe3do1.PeColor.SubsetColors[1] = Color.FromArgb(216, 148, 0, 0);98Pe3do1.PeColor.SubsetColors[2] = Color.FromArgb(216, 0, 0, 148);99Pe3do1.PeColor.SubsetColors[3] = Color.FromArgb(216, 148, 148, 0);100Pe3do1.PeColor.SubsetColors[4] = Color.FromArgb(216, 0, 148, 148);101Pe3do1.PeColor.SubsetColors[5] = Color.FromArgb(216, 0, 182, 0);102Pe3do1.PeColor.SubsetColors[6] = Color.FromArgb(216, 182, 0, 0);103Pe3do1.PeColor.SubsetColors[7] = Color.FromArgb(216, 0, 0, 182);104Pe3do1.PeColor.SubsetColors[8] = Color.FromArgb(216, 182, 182, 0);105Pe3do1.PeColor.SubsetColors[9] = Color.FromArgb(216, 0, 182, 182);106Pe3do1.PeColor.SubsetColors[10] = Color.FromArgb(216, 0, 198, 0);107Pe3do1.PeColor.SubsetColors[11] = Color.FromArgb(216, 198, 0, 0);108Pe3do1.PeColor.SubsetColors[12] = Color.FromArgb(216, 0, 0, 198);109Pe3do1.PeColor.SubsetColors[13] = Color.FromArgb(216, 198, 198, 0);110Pe3do1.PeColor.SubsetColors[14] = Color.FromArgb(216, 0, 198, 148);111 112// Set subset labels for z axis //113Pe3do1.PeString.SubsetLabels[0] = "Row 1";114Pe3do1.PeString.SubsetLabels[1] = "Row 2";115Pe3do1.PeString.SubsetLabels[2] = "Row 3";116Pe3do1.PeString.SubsetLabels[3] = "Row 4";117Pe3do1.PeString.SubsetLabels[4] = "Row 5";118Pe3do1.PeString.SubsetLabels[5] = "Row 6";119Pe3do1.PeString.SubsetLabels[6] = "Row 7";120Pe3do1.PeString.SubsetLabels[7] = "Row 8";121Pe3do1.PeString.SubsetLabels[8] = "Row 9";122Pe3do1.PeString.SubsetLabels[9] = "Row 10";123Pe3do1.PeString.SubsetLabels[10] = "Row 11";124Pe3do1.PeString.SubsetLabels[11] = "Row 12";125Pe3do1.PeString.SubsetLabels[12] = "Row 13";126Pe3do1.PeString.SubsetLabels[13] = "Row 14";127Pe3do1.PeString.SubsetLabels[14] = "Row 15";128 129// Set point labels for x axis //130Pe3do1.PeString.PointLabels[0] = "Col 1";131Pe3do1.PeString.PointLabels[1] = "Col 2";132Pe3do1.PeString.PointLabels[2] = "Col 3";133Pe3do1.PeString.PointLabels[3] = "Col 4";134Pe3do1.PeString.PointLabels[4] = "Col 5";135Pe3do1.PeString.PointLabels[5] = "Col 6";136Pe3do1.PeString.PointLabels[6] = "Col 7";137Pe3do1.PeString.PointLabels[7] = "Col 8";138Pe3do1.PeString.PointLabels[8] = "Col 9";139Pe3do1.PeString.PointLabels[9] = "Col 10";140Pe3do1.PeString.PointLabels[10] = "Col 11";141Pe3do1.PeString.PointLabels[11] = "Col 12";142Pe3do1.PeString.PointLabels[12] = "Col 13";143Pe3do1.PeString.PointLabels[13] = "Col 14";144Pe3do1.PeString.PointLabels[14] = "Col 15";145 146// Set Titles //147Pe3do1.PeString.MainTitle = "";148Pe3do1.PeString.SubTitle = "||Mouse Wheel zooms. Mouse Drag rotates. Mouse Drag+SHIFT shifts image. ";149Pe3do1.PeString.MultiSubTitles[0] = "||Double Click start/stop Rotation. Mouse Drag+MIDDLE rotates light. ";150 151// Note RenderEngine 3DX requires setting renderengine before QuickStyle152Pe3do1.PeColor.BitmapGradientMode = true;153Pe3do1.PeColor.QuickStyle = QuickStyle.DarkNoBorder;154 155// Set camera position //156Pe3do1.PeUserInterface.Scrollbar.ViewingHeight = 19;157Pe3do1.PeUserInterface.Scrollbar.DegreeOfRotation = 338;158 159// Set Plotting methods //160Pe3do1.PePlot.Method = ThreeDGraphPlottingMethod.Two; // Shading161 162// Set font size //164 165// Prepare images in memory //166Pe3do1.PeConfigure.PrepareImages = true;167Pe3do1.PeConfigure.CacheBmp = true;168Pe3do1.PeUserInterface.Allow.FocalRect = false;169Pe3do1.PeUserInterface.Dialog.Style = false;170 171// Add Some Padding around image //172Pe3do1.PeConfigure.ImageAdjustLeft = 100;173Pe3do1.PeConfigure.ImageAdjustRight = 100;174Pe3do1.PeConfigure.ImageAdjustBottom = 100;175 176Pe3do1.PeConfigure.TextShadows = TextShadows.BoldText;177Pe3do1.PeFont.Label.Bold = true;178 179// Enable button dragging //180Pe3do1.PeUserInterface.Scrollbar.MouseDraggingX = true;181Pe3do1.PeUserInterface.Scrollbar.MouseDraggingY = true;182 183// default export setting //184Pe3do1.PeSpecial.DpiX = 600;185Pe3do1.PeSpecial.DpiY = 600;186Pe3do1.PeUserInterface.Dialog.ExportSizeDef = ExportSizeDef.NoSizeOrPixel;187Pe3do1.PeUserInterface.Dialog.ExportTypeDef = ExportTypeDef.Png;188Pe3do1.PeUserInterface.Dialog.ExportDestDef = ExportDestDef.Clipboard;189Pe3do1.PeUserInterface.Dialog.ExportUnitXDef = "1280";190Pe3do1.PeUserInterface.Dialog.ExportUnitYDef = "768";191Pe3do1.PeUserInterface.Dialog.ExportImageDpi = 300;192Pe3do1.PeUserInterface.Dialog.AllowEmfExport = false;193Pe3do1.PeUserInterface.Dialog.AllowWmfExport = false;194 195Pe3do1.PeConfigure.AntiAliasGraphics = true;196Pe3do1.PeConfigure.AntiAliasText = true;197 198Pe3do1.PeUserInterface.Cursor.PromptTracking = true;199Pe3do1.PeUserInterface.Cursor.PromptStyle = CursorPromptStyle.YValue;200Pe3do1.PeUserInterface.Cursor.PromptLocation = CursorPromptLocation.Text;201Pe3do1.PeUserInterface.Cursor.FontSizeTrackingCntl = 1.4F;202Pe3do1.PeUserInterface.Cursor.HighlightColor = Color.FromArgb(255, 255, 255, 255);203Pe3do1.PeData.Precision = DataPrecision.NoDecimals;204Pe3do1.PePlot.Option.LightStrength = .65F;205 206Pe3do1.PeConfigure.RenderEngine = RenderEngine.Direct3D;207 208Pe3do1.PeUserInterface.Menu.AnnotationControl = true;209Pe3do1.PeUserInterface.Menu.ShowAnnotationText = MenuControl.Show;210Pe3do1.PeUserInterface.Menu.AnnotationTextFixedSize = MenuControl.Show;211Pe3do1.PeUserInterface.Menu.ShowLegend = MenuControl.Hide;212Pe3do1.PeUserInterface.Menu.ShowWireFrame = MenuControl.Hide;213 214// Add some random graph annotations //215int aCnt = 0;216int annot;217 218Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5;219Pe3do1.PeAnnotation.Graph.Z[aCnt] = 14.5;221Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.ThickSolidLine;222Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";223Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 255, 255);224aCnt++;225for (annot = 1; annot < nTargetCols; annot++)226{227 Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + annot;228 Pe3do1.PeAnnotation.Graph.Z[aCnt] = 14.5;230 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.LineContinue;231 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";232 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 255, 255);233 aCnt++;234}235 236for (annot = 0; annot < 10; annot++)237{238 int nRndRow = (int)(Rand_Num.NextDouble() * (float)nTargetRows - 1);239 int nRndCol = (int)(Rand_Num.NextDouble() * (float)nTargetCols - 1);240 Pe3do1.PeAnnotation.Graph.X[aCnt] = nRndCol + 1.5;241 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nRndRow + 1.5;243 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.DiamondSolid;244 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";245 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 255, 255);246 aCnt++;247 Pe3do1.PeAnnotation.Graph.X[aCnt] = nRndCol + 1.5;248 Pe3do1.PeAnnotation.Graph.Z[aCnt] = nRndRow + 1.5;250 Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.Pointer;251 Pe3do1.PeAnnotation.Graph.Text[aCnt] = "|lAnnotation " + annot.ToString();252 Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 255, 255);253 aCnt++;254}255 256// v10 Drawing Box, first set axis direction of box ends257 258Pe3do1.PeAnnotation.Graph.X[aCnt] = 0.0F;259Pe3do1.PeAnnotation.Graph.Y[aCnt] = 1.0F;260Pe3do1.PeAnnotation.Graph.Z[aCnt] = 0.0F;261Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.AxisDirection;262Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";263Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 255, 255);264aCnt++;265 266// Drawing Box, set major minor radii, box dimensions267 268Pe3do1.PeAnnotation.Graph.X[aCnt] = .3333;269Pe3do1.PeAnnotation.Graph.Y[aCnt] = .3333;270Pe3do1.PeAnnotation.Graph.Z[aCnt] = 0.0;271Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.MajorMinorRadii;272Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";273Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 255, 255);274aCnt++;275 276// logic to place a box at subset and point277 278int nBarSubset = 11;279int nBarPoint = 11;280 281Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);283Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);284Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)GraphAnnotationType.BoxStart;285Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";286Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 0, 255);287aCnt++;288 289Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);291Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);292Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)(int)GraphAnnotationType.Box;293Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";294Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 0, 255);295aCnt++;296 297// add a box ontop a box298 299Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);301Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);302Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)GraphAnnotationType.BoxStart;303Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";304Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 120, 55);305aCnt++;306 307Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);309Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);310Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)(int)GraphAnnotationType.Box;311Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";312Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 120, 55);313aCnt++;314 315// add a top cap to box316Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);318Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);319Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.RectFill;320Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";321Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 120, 55);322aCnt++;323 324nBarSubset = 12;325nBarPoint = 14;326 327Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);329Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);330Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)GraphAnnotationType.BoxStart;331Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";332Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 0, 255);333aCnt++;334 335Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);337Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);338Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)(int)GraphAnnotationType.Box;339Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";340Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 0, 255);341aCnt++;342 343// add a box ontop a box344 345Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);347Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);348Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)GraphAnnotationType.BoxStart;349Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";350Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 120, 55);351aCnt++;352 353Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);355Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);356Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)(int)GraphAnnotationType.Box;357Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";358Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 120, 55);359aCnt++;360 361// add a top cap to box362Pe3do1.PeAnnotation.Graph.X[aCnt] = 1.5 + (1.0 * nBarPoint);364Pe3do1.PeAnnotation.Graph.Z[aCnt] = 1.5 + (1.0 * nBarSubset);365Pe3do1.PeAnnotation.Graph.Type[aCnt] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.RectFill;366Pe3do1.PeAnnotation.Graph.Text[aCnt] = "";367Pe3do1.PeAnnotation.Graph.Color[aCnt] = Color.FromArgb(255, 255, 120, 55);368aCnt++;369 370Pe3do1.PeAnnotation.Show = true;371Pe3do1.PeAnnotation.Graph.Show = true;372Pe3do1.PeAnnotation.Graph.LeftJustificationOutside = true;373Pe3do1.PeAnnotation.Graph.SymbolObstacles = true;374Pe3do1.PeFont.GraphAnnotationTextSize = 110;375Pe3do1.PeUserInterface.HotSpot.GraphAnnotation = true;376Pe3do1.PePlot.Option.DegreePrompting = true;377 378// ============================================================379// TABLE ANNOTATION -- Custom Legend (Left Center)380// Pe3do ThreeDBar mode does NOT generate a native subset legend,381// so we use a Table Annotation with symbol + text columns.382// ============================================================383Pe3do1.PeAnnotation.Table.Working = 0; // use table index 0385Pe3do1.PeAnnotation.Table.Columns = 2; // col 0 = color swatch, col 1 = label386 387for (int i = 0; i < Pe3do1.PeData.Subsets; i++)388{389 // Column 0: colored square symbol390 Pe3do1.PeAnnotation.Table.Type[i, 0] = LegendAnnotationType.LargeSquareSolid;391 Pe3do1.PeAnnotation.Table.Color[i, 0] = Pe3do1.PeColor.SubsetColors[i];392 393 // Column 1: subset name text394 Pe3do1.PeAnnotation.Table.Text[i, 1] = Pe3do1.PeString.SubsetLabels[i];395 Pe3do1.PeAnnotation.Table.Color[i, 1] = Color.FromArgb(255, 220, 220, 220); // light text for dark theme396}397 398Pe3do1.PeLegend.SimplePoint = true; // this produces cleaner legend symbols399Pe3do1.PeLegend.SimpleLine = true; // this produces cleaner legend symbols400 401Pe3do1.PeAnnotation.Table.Location = TALocation.LeftCenter;402Pe3do1.PeAnnotation.Table.Border = TABorder.NoBorder;403Pe3do1.PeAnnotation.Table.BackColor = Color.FromArgb(200, 30, 30, 30); // dark semi-transparent background404Pe3do1.PeAnnotation.Table.ForeColor = Color.FromArgb(255, 220, 220, 220); // default text color405Pe3do1.PeAnnotation.Table.TextSize = 90;406Pe3do1.PeAnnotation.Table.Moveable = TAMoveable.Full; // user can drag the legend407 408Pe3do1.PeAnnotation.Table.Show = true;409 410// Ensure global table annotation visibility is on411Pe3do1.PeAnnotation.ShowAllTableAnnotations = true;412 413 414Pe3do1.PeFunction.Force3dxVerticeRebuild = true;415Pe3do1.PeFunction.Force3dxAnnotVerticeRebuild = true;416 417Pe3do1.PeFunction.ReinitializeResetImage();418Pe3do1.Invalidate();419Pe3do1.Refresh();Pego1.PeData.Y[s, p]Click underlined properties to view documentation