GUI main
The plugin main window class.
QgisCplusMain
Bases: QDockWidget
, WidgetUi
Main plugin UI class
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
add_priority_group
Adds a new priority group into the plugin, then updates the priority list to show the new added priority group.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
add_priority_layer
Adds a new priority layer into the plugin, then updates the priority list to show the new added priority layer.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
add_priority_layer_group
Adds priority layer from the weighting layers into a priority group If no target_group or priority_layer is passed then the current selected group or priority layer from their respective list will be used.
Checks if priority layer is already in the target group and if so no addition is done.
Once the addition is done, the respective priority layer plugin settings are updated to store the new information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_group |
dict
|
Priority group where layer will be added to |
None
|
priority_layer |
dict
|
Priority weighting layer to be added |
None
|
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 |
|
add_scenario
Adds a new scenario into the scenario list.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
analysis_complete
Calls the responsible function for handling analysis results outputs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
ScenarioAnalysisTask
|
Analysis task |
required |
report_manager |
ReportManager
|
Report manager used to generate analysis report_templates |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
cancel_processing_task
Cancels the current processing task.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
edit_priority_group
Edits the current selected priority group and updates the group box list.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
edit_priority_layer
Edits the current selected priority layer and updates the layer box list.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
fetch_default_layer_list
Fetch default layer list from API.
fetch_scenario_history_list
Fetch scenario history list from API.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
group_value_changed
Slot to handle priority group widget changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group_name |
str
|
Group name |
required |
group_value |
int
|
Group value |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
has_trends_auth
Check if plugin has user Trends.Earth authentication.
Returns:
Type | Description |
---|---|
bool
|
True if user has provided the username and password. |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
initialize_priority_layers
Prepares the priority weighted layers UI with the defaults.
Gets the store priority layers from plugin settings and populates them into the QListWidget as QListWidgetItems then fetches the priority groups and adds them to the QTreeWidget as QTreeWidgetItems with their corresponding priority layers as their child items.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
load_layer_options
Retrieve outputs scenarion layers selection from settings and update the releated ui components
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
load_scenario
Edits the current selected scenario and updates the layer box list.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 |
|
main_task
Serves as a QgsTask function for the main task that contains smaller sub-tasks running the actual processing calculations.
move_layer_to_group
Moves a layer open in QGIS to another group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer |
QgsRasterLayer
|
Raster layer to move |
required |
group |
QgsLayerTreeGroup
|
Group to which the raster should be moved |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_fetch_scenario_history_list_finished
Callback when plugin has finished pulling scenario history list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
success |
bool
|
True if API call is successful |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_generate_comparison_report
Slot raised to generate a comparison for two or more selected scenario results.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 |
|
on_log_message_received
Slot to handle log tab updates and processing logs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
The received message from QGIS message log |
required |
tag |
str
|
Message log tag |
required |
level |
Qgis.MessageLevel
|
Message level enum value |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_manage_npv_pwls
Slot raised to show the dialog for managing NPV PWLs.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
|
on_npv_pwl_created
Callback that creates an PWL item when the corresponding raster layer has been created.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity_npv |
ActivityNpv
|
NPV mapping for an activity: |
required |
npv_pwl_path |
str
|
Absolute file path of the created NPV PWL. |
required |
algorithm |
QgsProcessingAlgorithm
|
Processing algorithm that created the NPV PWL. |
required |
context |
QgsProcessingContext
|
Contextual information that was used to create the NPV PWL in processing. |
required |
feedback |
QgsProcessingFeedback
|
Feedback to update on the processing progress. |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_npv_pwl_removed
Callback that is executed when an NPV PWL has been removed because it was disabled by the user.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_online_task_check_finished
Handler for view online task and generate report button.
The button itself will be shown when Cplus plugin becomes visible.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_progress_dialog_cancelled
Slot raised when analysis has been cancelled in progress dialog.
on_report_error
Slot raised when report task error has occured.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress_dialog |
ProgressDialog
|
Dialog responsible for showing all the analysis operations progress. |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_report_finished
Slot raised when report task has finished.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress_dialog |
ProgressDialog
|
Dialog responsible for showing all the analysis operations progress. |
required |
scenario_id |
str
|
Scenario analysis id |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_report_running
Slot raised when report task has started.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress_dialog |
ProgressDialog
|
Dialog responsible for showing all the analysis operations progress. |
required |
scenario_id |
str
|
Scenario analysis id |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_reporting_progress_changed
Slot raised when the reporting progress has changed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress_dialog |
ProgressDialog
|
Dialog responsible for showing all the analysis operations progress. |
required |
progress |
float
|
Analysis progress value between 0 and 100 |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_scenario_list_selection_changed
Slot raised when the selection of scenarios changes.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
on_tab_step_changed
Slot raised when the current tab changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
Zero-based index position of new current tab |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 |
|
on_view_status_button_clicked
Handler when view status report button in tab 4 is clicked.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
open_help
open_settings
outputs_options_changed
Handles selected outputs changes
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
post_analysis
Handles analysis outputs from the final analysis results. Adds the resulting scenario raster to the canvas with styling. Adds each of the activities to the canvas with styling. Adds each activities' pathways to the canvas.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_result |
ScenarioResult
|
ScenarioResult of output results |
required |
task |
ScenarioAnalysisTask
|
Analysis task |
required |
report_manager |
ReportManager
|
Report manager used to generate analysis report_templates |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 |
|
prepare_extent_box
Configure the spatial extent box with the initial settings.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
prepare_input
Initializes plugin input widgets
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
prepare_message_bar
Initializes the widget message bar settings
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
priority_groups_update
Updates the priority groups list item with the passed selected layer items.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_item |
QTreeWidgetItem
|
The priority group tree widget item that is to be updated |
required |
selected_items |
list
|
Priority layers items from the list widget |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
processing_options_changed
remove_priority_group
Removes the current active priority group.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
remove_priority_layer
Removes the current active priority layer.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
remove_priority_layer_group
Remove the current select priority layer from the current priority group.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
remove_scenario
Removes the current active scenario.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
report_job_is_for_current_scenario
Checks if the given scenario identifier is for the current scenario result.
This is to ensure that signals raised by the report manager refer to the current scenario result object and not for old jobs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_id |
str
|
Scenario identifier usually from a signal raised by the report manager. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the scenario identifier matches the current scenario object in the results, else False. |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
reset_reporting_feedback
Creates a new reporting feedback object and reconnects the signals.
We are doing this to address cases where the feedback is canceled and the same object has to be reused for subsequent report generation tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress_dialog |
ProgressDialog
|
Dialog responsible for showing all the analysis operations progress. |
required |
Returns:
Type | Description |
---|---|
QgsFeedback
|
Feedback instance to be used in storing processing status details. |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
restore_scenario
Update the first tab input with the last scenario details
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
run_analysis
Runs the plugin analysis Creates new QgsTask, progress dialog and report manager for each new scenario analysis.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 |
|
run_report
Run report generation. This should be called after the analysis is complete.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress_dialog |
ProgressDialog
|
Dialog responsible for showing all the analysis operations progress. |
required |
report_manager |
ReportManager
|
Report manager used to generate analysis report_templates |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
save_scenario
Save current scenario details into settings
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
scenario_results
Called when the task ends. Sets the progress bar to 100 if it finished.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
ScenarioAnalysisTask
|
Analysis task |
required |
report_manager |
ReportManager
|
Report manager used to generate analysis report_templates |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
show_message
Shows message on the main widget message bar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
Text message |
required |
level |
Qgis.MessageLevel
|
Message level type |
Warning
|
duration |
int
|
Duration of the shown message |
0
|
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
show_scenario_info
Loads dialog for showing scenario information.
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
style_activities_layer
Applies the styling to the passed layer that contains the passed list of activities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer |
QgsRasterLayer
|
Layer to be styled |
required |
activities |
list
|
List which contains the activities that were passed to the highest position analysis tool. |
required |
Returns:
Type | Description |
---|---|
QgsPalettedRasterRenderer
|
Renderer for the symbology. |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
style_activity_layer
Applies the styling to the layer that contains the passed activity name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer |
QgsRasterLayer
|
Raster layer to which to apply the symbology |
required |
activity |
Activity
|
activity |
required |
Returns:
Type | Description |
---|---|
QgsSingleBandPseudoColorRenderer
|
Renderer for the symbology. |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
task_terminated
Handles logging of the scenario analysis task status after it has been terminated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
Union[ScenarioAnalysisTask, ScenarioAnalysisTaskApiClient]
|
Task that was terminated |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
transform_extent
Transforms the passed extent into the destination crs
:param extent: Target extent
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source_crs |
QgsCoordinateReferenceSystem
|
Source CRS of the passed extent |
required |
dest_crs |
QgsCoordinateReferenceSystem
|
Destination CRS |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
update_message_bar
Changes the message in the message bar item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
Message to be updated |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
update_priority_layers
Updates the priority weighting layers list in the UI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
update_groups |
bool
|
Whether to update the priority groups list or not |
True
|
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
update_progress_bar
Sets the value of the progress bar
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress_dialog |
ProgressDialog
|
Dialog responsible for showing all the analysis operations progress. |
required |
value |
float
|
Value to be set on the progress bar |
required |
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
update_progress_dialog
Run report generation. This should be called after the analysis is complete.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress_dialog |
ProgressDialog
|
Dialog responsible for showing all the analysis operations progress. |
required |
message |
ReportManager
|
Report manager used to generate analysis report_templates |
None
|
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
update_pwl_layers
Updates the priority layers path available in the store activities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
notify |
bool
|
Whether to show message to user about the update |
False
|
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
update_scenario_list
Fetches scenarios from plugin settings and updates the scenario history list
Source code in src/cplus_plugin/gui/qgis_cplus_main.py
zoom_pilot_area
Zoom the current main map canvas to the pilot area extent.