Report Generator
CPLUS Report generator.
BaseScenarioReportGenerator
Base class for generating a scenario report.
Source code in src/cplus_plugin/lib/reports/generator.py
context
property
Returns the report context used by the generator.
Returns:
Type | Description |
---|---|
ReportContext
|
Report context object used by the generator. |
feedback
property
Returns the feedback object for process update and cancellation.
Returns:
Type | Description |
---|---|
QgsFeedback
|
Feedback object or None if not specified. |
layout
property
Returns the layout object used to generate the report.
Returns:
Type | Description |
---|---|
QgsPrintLayout
|
The layout object used to generate the report or None if the process was not successful. |
output_dir
property
Creates, if it does not exist, the output directory where the report_templates will be saved.
Returns:
Type | Description |
---|---|
str
|
Output directory where the report_templates will be saved. |
output_layout_path
property
Absolute path to a temporary file containing the layout as a QPT file.
When this object is used within a QgsTask, it is
recommended to use this layout path to reconstruct
the layout rather calling the layout
attribute since
it was created in a separate thread.
Returns:
Type | Description |
---|---|
str
|
Path to the layout template file. |
run
Initiates the report generation process and returns a result which contains information on whether the process succeeded or failed.
Returns:
Type | Description |
---|---|
ReportResult
|
The result of the report generation process. |
Source code in src/cplus_plugin/lib/reports/generator.py
set_label_font
classmethod
Set font properties of the given layout label item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
QgsLayoutItemLabel
|
Label item whose font properties will be updated. |
required |
size |
float
|
Point size of the font. |
required |
bold |
bool
|
True if font is to be bold, else False (default). |
False
|
italic |
bool
|
True if font is to be in italics, else False (default). |
False
|
Source code in src/cplus_plugin/lib/reports/generator.py
BaseScenarioReportGeneratorTask
Bases: QgsTask
Base proxy class for initiating the report generation process.
Source code in src/cplus_plugin/lib/reports/generator.py
context
property
Returns the report context used by the generator.
Returns:
Type | Description |
---|---|
ReportContext
|
Report context object used by the generator. |
result
property
Returns the result object which contains information on whether the process succeeded or failed.
Returns:
Type | Description |
---|---|
ReportResult
|
The result of the report generation process. |
cancel
run
Initiates the report generation process and returns a result indicating whether the process succeeded or failed.
Returns:
Type | Description |
---|---|
bool
|
True if the report generation process succeeded or False it if failed. |
Source code in src/cplus_plugin/lib/reports/generator.py
DuplicatableRepeatPageReportGenerator
Bases: BaseScenarioReportGenerator
Incorporates extra functionality for duplicating a repeat page.
Subclass must have _repeat_page
and _repeat_page_num
members.
Source code in src/cplus_plugin/lib/reports/generator.py
duplicate_repeat_page
Duplicates the repeat page and adds it to the layout at the given position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position |
int
|
Zero-based position to insert the duplicated page. If the position is greater than the number of pages, then the duplicated page will be inserted at the end of the layout. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the page was successfully duplicated else False. |
Source code in src/cplus_plugin/lib/reports/generator.py
get_dimension_for_repeat_item
Calculates the number of rows and columns for rendering items based on the size of CPLUS repeat item. It also determines the recommended width and height of the repeat area.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repeat_item |
CplusMapRepeatItem
|
The map repeat item where the items will be rendered. |
required |
Returns:
Type | Description |
---|---|
RepeatAreaDimension
|
A recommended number of rows and columns respectively for rendering the repeat items as well the recommended dimension of the repeat area. |
Source code in src/cplus_plugin/lib/reports/generator.py
ScenarioAnalysisReportGenerator
Bases: DuplicatableRepeatPageReportGenerator
Generator for CPLUS scenario analysis report.
Source code in src/cplus_plugin/lib/reports/generator.py
output_dir
property
Creates, if it does not exist, the output directory where the analysis report_templates will be saved. This is relative to the base directory and scenario output sub-folder.
Returns:
Type | Description |
---|---|
str
|
Output directory where the analysis report_templates will be saved. |
repeat_page
property
Returns the page item that will be repeated based on the number of activities in the scenario.
A repeat page is a layout page item that contains the first instance of a CplusMapRepeatItem.
Returns:
Type | Description |
---|---|
QgsLayoutItemPage
|
Page item containing a CplusMapRepeatItem or None if not found. |
export_to_pdf
Exports the layout to a PDF file in the output directory using the layout name as the file name.
Returns:
Type | Description |
---|---|
bool
|
True if the layout was successfully exported else False. |
Source code in src/cplus_plugin/lib/reports/generator.py
ScenarioAnalysisReportGeneratorTask
Bases: BaseScenarioReportGeneratorTask
Proxy class for initiating the report generation process.
Source code in src/cplus_plugin/lib/reports/generator.py
finished
If successful, add the layout to the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
bool
|
Flag indicating if the result of the report generation process. True if successful, else False. |
required |
Source code in src/cplus_plugin/lib/reports/generator.py
ScenarioComparisonReportGenerator
Bases: DuplicatableRepeatPageReportGenerator
Generator for CPLUS scenario comparison reports.
Source code in src/cplus_plugin/lib/reports/generator.py
output_dir
property
Creates, if it does not exist, the output directory where the comparison report_templates will be saved. This is relative to the base directory and comparison reports sub-folder.
Returns:
Type | Description |
---|---|
str
|
Output directory where the scenario report_templates will be saved. |
ScenarioComparisonReportGeneratorTask
Bases: BaseScenarioReportGeneratorTask
Proxy class for initiating the generation of scenario comparison reports.
Source code in src/cplus_plugin/lib/reports/generator.py
finished
If successful, add the layout to the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
bool
|
Flag indicating if the result of the report generation process. True if successful, else False. |
required |