O-Calc Pro Report – “My First Report”
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:
-
public static class ReportFont
-
{
-
public static double cPageWidth = 6.25 ;
-
public static string cFontName = "Arial" ;
-
public static MD . Unit cFontSizeLarge = MD . Unit . FromPoint ( 9.75 ) ;
-
public static MD . Unit cFontSizeSmall = MD . Unit . FromPoint ( 7.85 ) ;
-
}
-
-
public partial class Report : PPL_Lib . ReportTemplate
-
{
-
-
//globally defined colors and fonts
-
MD . Color Yellow = MD . Colors . LightYellow ;
-
MD . Color White = MD . Colors . White ;
-
MD . ParagraphAlignment JustifyRight = MD . ParagraphAlignment . Right ;
-
MD . ParagraphAlignment JustifyLeft = MD . ParagraphAlignment . Left ;
-
MD . ParagraphAlignment JustifyCenter = MD . ParagraphAlignment . Center ;
-
MD . Font SmallFont = new MD . Font (ReportFont . cFontName, ReportFont . cFontSizeSmall ) ;
-
MD . Font StandardFont = new MD . Font (ReportFont . cFontName, ReportFont . cFontSizeLarge ) ;
-
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):
-
//implement more than one additional report subtype (total will be this number plus the master)
-
public override int SubtypesCount { get { return 0 ; } }
-
-
public override REPORT_TYPE Type { get { return REPORT_TYPE . INTEGRATED ; } }
-
public override String Name { get { return "My First Report" ; } }
-
public override String Description { get { return Name ; } }
-
-
//make sure to implement ToString to show report name
-
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:
-
//determine if this report is applicable for a structure
-
public override bool IsApplicable (PPLMain pPPLMain, PPLPole pPole )
-
{
-
if (Filtered ) return false ;
-
if (pPole is PPLWoodPole )
-
{
-
return true ;
-
}
-
return false ;
-
}
-
public override bool IsApplicableForType (PPLMain . POLE_TYPE pType )
-
{
-
if (Filtered ) return false ;
-
return (pType == PPLMain . POLE_TYPE . WOOD ) ;
-
}
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
-
public override void AddPole (PPLPole pPole, String pPoleName )
-
{
-
String pplx = cPPLMain . ReportingLoadedPolePath ;
-
try
-
{
-
pplx = System.IO . Path . GetFileName (pplx ) ;
-
}
-
catch { }
-
-
PoleLoadInfo poleInfoMaster = cPPLMain . CurrentPoleLoadInfo ;
-
ReportItems reportItems = new ReportItems (poleInfoMaster, cPPLMain, pplx ) ;
-
ReportItems . ReportParameters RP = reportItems . cReportParameters ;
-
-
CreateTable (ReportFont . cPageWidth, 4 ) ;
-
cCurrentTable . Format . Font = SmallFont . Clone ( ) ;
-
cCurrentTable . Borders . Visible = false ;
-
//Header Row
-
AddRow (Cell ( "Pole Capacity Utilization (%)", 2, MD . Colors . White, JustifyLeft, StandardFont, Bold ),
-
Cell ( "Height" + "\n(" + RP . Units_Len_Large_Abrev + ")", MD . Colors . White, JustifyRight, StandardFont, Bold ),
-
Cell ( "Wind Angle" + "\n(deg)", MD . Colors . White, JustifyRight, StandardFont, Bold ) ) ;
-
cCurrentTable . RightPadding = MD . Unit . FromInch ( 0.125 ) ;
-
-
//First Row
-
AddRow (Cell ( "Maximum", JustifyLeft ),
-
Cell (Math . Round (RP . Sum_MCU, 1 ) . ToString ( "0.0" ), Yellow, JustifyRight, StandardFont, Bold,
-
GetColorFromValueAndTolerance (RP . Sum_MCU, 80, 90, 99.5 ) ),
-
Cell (Math . Round (RP . Sum_MCU_Height, 1 ) . ToString ( "0.0" ), JustifyRight ),
-
Cell (Math . Round (RP . Sum_MCU_Wind_Angle, 1 ) . ToString ( "0.0" ), JustifyRight ) ) ;
-
-
//Second Row
-
AddRow (Cell ( "Groundline", JustifyLeft ),
-
Cell (Math . Round (RP . Sum_GLCU, 1 ) . ToString ( "0.0" ), Yellow, JustifyRight, StandardFont, Bold,
-
GetColorFromValueAndTolerance (RP . Sum_GLCU, 80, 90, 99.5 ) ),
-
Cell (Math . Round (RP . Sum_GLCU_Height, 1 ) . ToString ( "0.0" ), JustifyRight ),
-
Cell (Math . Round (RP . Sum_GLCU_Wind_Angle, 1 ) . ToString ( "0.0" ), JustifyRight ) ) ;
-
-
//Third Row
-
AddRow (Cell ( "Vertical", JustifyLeft ),
-
Cell (Math . Round (RP . Sum_Vertical_Buckling_CU, 1 ) . ToString ( "0.0" ), Yellow, JustifyRight, StandardFont, Bold,
-
GetColorFromValueAndTolerance (RP . Sum_Vertical_Buckling_CU, 80, 90, 99.5 ) ),
-
Cell (Math . Round (RP . Sum_Vertical_Buckling_Column_Height, 1 ) . ToString ( "0.0" ), JustifyRight ),
-
Cell (Math . Round (RP . Sum_Vertical_Buckling_Wind_Angle, 1 ) . ToString ( "0.0" ), JustifyRight ) ) ;
-
-
cCurrentTable . BottomPadding = MD . Unit . FromInch ( 0.03 ) ;
-
cCurrentTable . TopPadding = MD . Unit . FromInch ( 0.03 ) ;
-
-
cCurrentTable . SetEdge ( 0, 0, cCurrentTable . Columns . Count, cCurrentTable . Rows . Count, MDT . Edge . Box, MD . BorderStyle . Single, 1, MD . Colors . Black ) ;
-
cCurrentTable . SetEdge ( 0, 0, cCurrentTable . Columns . Count, 1, MDT . Edge . Box, MD . BorderStyle . Single, 1, MD . Colors . Black ) ;
-
-
FinalizeTable ( ) ;
-
cDocument . LastSection . AddParagraph ( "\n" ) ;
-
}