O-Calc Pro Report – “My First Report”

  Plugin development

The default O-Calc Pro Report template will create a simple report with default header and a single table of pole capacity utilization values.  Below are some explanations of the various code components of this simple report example.

Defining the Report Format, Fonts, and Colors:

  1. public static class ReportFont
  2. {
  3. public static double cPageWidth = 6.25;
  4. public static string cFontName = "Arial";
  5. public static MD.Unit cFontSizeLarge = MD.Unit.FromPoint(9.75);
  6. public static MD.Unit cFontSizeSmall = MD.Unit.FromPoint(7.85);
  7. }
  8.  
  9. public partial class Report : PPL_Lib.ReportTemplate
  10. {
  11.  
  12. //globally defined colors and fonts
  13. MD.Color Yellow = MD.Colors.LightYellow;
  14. MD.Color White = MD.Colors.White;
  15. MD.ParagraphAlignment JustifyRight = MD.ParagraphAlignment.Right;
  16. MD.ParagraphAlignment JustifyLeft = MD.ParagraphAlignment.Left;
  17. MD.ParagraphAlignment JustifyCenter = MD.ParagraphAlignment.Center;
  18. MD.Font SmallFont = new MD.Font(ReportFont.cFontName, ReportFont.cFontSizeSmall);
  19. MD.Font StandardFont = new MD.Font(ReportFont.cFontName, ReportFont.cFontSizeLarge);
  20. FontModifier Bold = new FontModifier(true, false, false);

This font, color, and paragraph parameters will be used in the main body of the report. These parameters do not define the header section of the report.

Define the Name (or Names) of the Report(s):

  1. //implement more than one additional report subtype (total will be this number plus the master)
  2. public override int SubtypesCount { get { return 0; } }
  3.  
  4. public override REPORT_TYPE Type { get { return REPORT_TYPE.INTEGRATED; } }
  5. public override String Name { get { return "My First Report"; } }
  6. public override String Description { get { return Name; } }
  7.  
  8. //make sure to implement ToString to show report name
  9. public override String ToString() { return Name; }

If you are defining more than one report time, change the SubtypesCount and create a separate name for each subtype.  In this example, a single report with the name “My First Report” is being created.

Define the structure type that is applicable for the report:

  1. //determine if this report is applicable for a structure
  2. public override bool IsApplicable(PPLMain pPPLMain, PPLPole pPole)
  3. {
  4. if (Filtered) return false;
  5. if (pPole is PPLWoodPole)
  6. {
  7. return true;
  8. }
  9. return false;
  10. }
  11. public override bool IsApplicableForType(PPLMain.POLE_TYPE pType)
  12. {
  13. if (Filtered) return false;
  14. return (pType == PPLMain.POLE_TYPE.WOOD);
  15. }

This section of the report will enable the user to determine what structure type this report will run on.  Structure types include WOOD, STEEL, COMPOSITE, CONCRETE, SEGMENTED, MULTI-POLE, and/or LATTICE.  In the example code above, this report will show up in the O-Calc Pro interface as an applicable report only for pole type of WOOD.

Add the Pole and format the Report as Desired

  1. public override void AddPole(PPLPole pPole, String pPoleName)
  2. {
  3. String pplx = cPPLMain.ReportingLoadedPolePath;
  4. try
  5. {
  6. pplx = System.IO.Path.GetFileName(pplx);
  7. }
  8. catch { }
  9.  
  10. PoleLoadInfo poleInfoMaster = cPPLMain.CurrentPoleLoadInfo;
  11. ReportItems reportItems = new ReportItems(poleInfoMaster, cPPLMain, pplx);
  12. ReportItems.ReportParameters RP = reportItems.cReportParameters;
  13.  
  14. CreateTable(ReportFont.cPageWidth, 4);
  15. cCurrentTable.Format.Font = SmallFont.Clone();
  16. cCurrentTable.Borders.Visible = false;
  17. //Header Row
  18. AddRow(Cell("Pole Capacity Utilization (%)", 2, MD.Colors.White, JustifyLeft, StandardFont, Bold),
  19. Cell("Height" + "\n(" + RP.Units_Len_Large_Abrev + ")", MD.Colors.White, JustifyRight, StandardFont, Bold),
  20. Cell("Wind Angle" + "\n(deg)", MD.Colors.White, JustifyRight, StandardFont, Bold));
  21. cCurrentTable.RightPadding = MD.Unit.FromInch(0.125);
  22.  
  23. //First Row
  24. AddRow(Cell("Maximum", JustifyLeft),
  25. Cell(Math.Round(RP.Sum_MCU, 1).ToString("0.0"), Yellow, JustifyRight, StandardFont, Bold,
  26. GetColorFromValueAndTolerance(RP.Sum_MCU, 80, 90, 99.5)),
  27. Cell(Math.Round(RP.Sum_MCU_Height, 1).ToString("0.0"), JustifyRight),
  28. Cell(Math.Round(RP.Sum_MCU_Wind_Angle, 1).ToString("0.0"), JustifyRight));
  29.  
  30. //Second Row
  31. AddRow(Cell("Groundline", JustifyLeft),
  32. Cell(Math.Round(RP.Sum_GLCU, 1).ToString("0.0"), Yellow, JustifyRight, StandardFont, Bold,
  33. GetColorFromValueAndTolerance(RP.Sum_GLCU, 80, 90, 99.5)),
  34. Cell(Math.Round(RP.Sum_GLCU_Height, 1).ToString("0.0"), JustifyRight),
  35. Cell(Math.Round(RP.Sum_GLCU_Wind_Angle, 1).ToString("0.0"), JustifyRight));
  36.  
  37. //Third Row
  38. AddRow(Cell("Vertical", JustifyLeft),
  39. Cell(Math.Round(RP.Sum_Vertical_Buckling_CU, 1).ToString("0.0"), Yellow, JustifyRight, StandardFont, Bold,
  40. GetColorFromValueAndTolerance(RP.Sum_Vertical_Buckling_CU, 80, 90, 99.5)),
  41. Cell(Math.Round(RP.Sum_Vertical_Buckling_Column_Height, 1).ToString("0.0"), JustifyRight),
  42. Cell(Math.Round(RP.Sum_Vertical_Buckling_Wind_Angle, 1).ToString("0.0"), JustifyRight));
  43.  
  44. cCurrentTable.BottomPadding = MD.Unit.FromInch(0.03);
  45. cCurrentTable.TopPadding = MD.Unit.FromInch(0.03);
  46.  
  47. cCurrentTable.SetEdge(0, 0, cCurrentTable.Columns.Count, cCurrentTable.Rows.Count, MDT.Edge.Box, MD.BorderStyle.Single, 1, MD.Colors.Black);
  48. cCurrentTable.SetEdge(0, 0, cCurrentTable.Columns.Count, 1, MDT.Edge.Box, MD.BorderStyle.Single, 1, MD.Colors.Black);
  49.  
  50. FinalizeTable();
  51. cDocument.LastSection.AddParagraph("\n");
  52. }

 

Facebooktwitterlinkedinmail