Skip to content

Commit

Permalink
Merge pull request #895 from Giswater/dev-3.5
Browse files Browse the repository at this point in the history
Dev 3.5
  • Loading branch information
smaspons authored Jun 26, 2023
2 parents 70b1826 + 150f92d commit 7396dbd
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 13 deletions.
4 changes: 4 additions & 0 deletions config/user_params.config
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ _psector_replace_feature_keep_active = False
[init.btn_go2epa]
force_import_velocity_higher_50ms = False #If true, it will replace all '>50' velocities for '50'

[init.btn_go2epa_selector]
_load_result_layers = True #If true, it will automatically load the epa results layers
_load_compare_layers = True #If true, it will automatically load the epa compare layers

[session.btn_admin]
project_type = None
schema_name = None
Expand Down
3 changes: 3 additions & 0 deletions core/shared/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ def _activate_snapping(self, complet_result, ep, refresh_dialog=False):
dlg_interpolate.rejected.connect(partial(self._manage_interpolate_rejected))
dlg_interpolate.rb_interpolate.clicked.connect(partial(self._change_rb_type, dlg_interpolate, dlg_interpolate.rb_interpolate, complet_result, ep))
dlg_interpolate.rb_extrapolate.clicked.connect(partial(self._change_rb_type, dlg_interpolate, dlg_interpolate.rb_extrapolate, complet_result, ep))
dlg_interpolate.btn_accept.setEnabled(False)

tools_gw.open_dialog(dlg_interpolate, dlg_name='dialog_text')

Expand Down Expand Up @@ -1069,12 +1070,14 @@ def _snapping_node(self, dlg_interpolate, point, button):
self.rb_interpolate.append(rb)
dlg_interpolate.lbl_text.setText(f"Node1: {self.node1}\nNode2:")
tools_qgis.show_message(message, message_level=0, parameter=self.node1)
dlg_interpolate.btn_accept.setEnabled(False)
elif self.node1 != str(element_id):
self.node2 = str(element_id)
tools_qgis.draw_point(QgsPointXY(result.point()), rb, color=QColor(0, 150, 55, 100), width=10)
self.rb_interpolate.append(rb)
dlg_interpolate.lbl_text.setText(f"Node1: {self.node1}\nNode2: {self.node2}")
tools_qgis.show_message(message, message_level=0, parameter=self.node2)
dlg_interpolate.btn_accept.setEnabled(True)

if self.node1 and self.node2:

Expand Down
15 changes: 15 additions & 0 deletions core/toolbars/epa/go2epa_manager_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _manage_go2epa(self):
selection_model = self.dlg_manager.tbl_rpt_cat_result.selectionModel()
selection_model.selectionChanged.connect(partial(self._fill_txt_infolog))
selection_model.selectionChanged.connect(partial(self._enable_btn_corporate))
self.dlg_manager.tbl_rpt_cat_result.doubleClicked.connect(partial(self._set_result_id, self.dlg_manager, self.dlg_manager.tbl_rpt_cat_result))
self.dlg_manager.btn_close.clicked.connect(partial(tools_gw.close_dialog, self.dlg_manager))
self.dlg_manager.rejected.connect(partial(tools_gw.close_dialog, self.dlg_manager))
self.dlg_manager.txt_result_id.textChanged.connect(partial(self._fill_manager_table))
Expand Down Expand Up @@ -302,4 +303,18 @@ def _epa2data(self, widget, column_id):
# Refresh table
self._fill_manager_table()

def _set_result_id(self, dialog, widget):
selected_list = widget.selectionModel().selectedRows()
if len(selected_list) == 0:
message = "Any record selected"
tools_qgis.show_warning(message, dialog=dialog)
return

row = selected_list[0].row()
table_model = widget.model()
result_id = table_model.data(table_model.index(row, 0))
sql = f"DELETE FROM selector_rpt_main WHERE cur_user = current_user;" \
f"INSERT INTO selector_rpt_main (result_id, cur_user) VALUES ('{result_id}', current_user);"
tools_db.execute_sql(sql)

# endregion
24 changes: 17 additions & 7 deletions core/toolbars/epa/go2epa_selector_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ...ui.ui_manager import GwGo2EpaSelectorUi
from ...utils import tools_gw
from .... import global_vars
from ....lib import tools_qt, tools_db, tools_qgis
from ....lib import tools_qt, tools_db, tools_qgis, tools_os


class GwGo2EpaSelectorButton(GwAction):
Expand All @@ -34,6 +34,10 @@ def clicked_event(self):
def _load_result_layers(self):
""" Adds any missing Compare layers to TOC """

# Manage user variable
if not tools_os.set_boolean(tools_gw.get_config_parser('btn_go2epa_selector', 'load_result_layers', "user", "init")):
return

filtre = "(id LIKE 'v_rpt_arc%' OR id LIKE 'v_rpt_node%')"
if global_vars.project_type == 'ud':
filtre = "id LIKE 'v_rpt_%_sum'"
Expand All @@ -52,6 +56,10 @@ def _load_result_layers(self):
def _load_compare_layers(self):
""" Adds any missing Compare layers to TOC """

# Manage user variable
if not tools_os.set_boolean(tools_gw.get_config_parser('btn_go2epa_selector', 'load_compare_layers', "user", "init")):
return

filtre = 'v_rpt_comp_%'
if global_vars.project_type == 'ud':
filtre = 'v_rpt_comp_%_sum'
Expand Down Expand Up @@ -85,15 +93,17 @@ def _open_go2epa_selector(self):
"FROM v_ui_rpt_cat_result WHERE status = 'COMPLETED' ORDER BY result_id")
rows = tools_db.get_rows(sql)
tools_qt.fill_combo_values(self.dlg_go2epa_result.rpt_selector_result_id, rows)
tools_qt.set_combo_value(self.dlg_go2epa_result.rpt_selector_result_id,
tools_gw.get_config_parser('btn_go2epa_selector', 'rpt_selector_result', 'user',
'session'), 0)
sql2 = "SELECT result_id FROM selector_rpt_main WHERE cur_user = current_user"
row = tools_db.get_row(sql2)
if row:
tools_qt.set_combo_value(self.dlg_go2epa_result.rpt_selector_result_id, row[0], 0)

rows = tools_db.get_rows(sql, add_empty_row=True)
tools_qt.fill_combo_values(self.dlg_go2epa_result.rpt_selector_compare_id, rows)
tools_qt.set_combo_value(self.dlg_go2epa_result.rpt_selector_result_id,
tools_gw.get_config_parser('btn_go2epa_selector', 'rpt_selector_compare', 'user',
'session'), 0)
sql2 = "SELECT result_id FROM selector_rpt_compare WHERE cur_user = current_user"
row = tools_db.get_row(sql2)
if row:
tools_qt.set_combo_value(self.dlg_go2epa_result.rpt_selector_compare_id, row[0], 0)

if self.project_type == 'ws':

Expand Down
9 changes: 4 additions & 5 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ qgisMinimumVersion=3.10
qgisMaximumVersion=3.99
description=Plugin to manage water networks (water supply, sewerage and urban drainage) using QGIS and PostGIS-PostgreSQL(from 9.5 to 14.x)
about=Disclaimer: This plugin is released using the open source GNU-GPL3 license. Although a reasonable effort has been made to assure that the results obtained are correct, some of the capabilities provided by Giswater are experimental, therefore the development team and the Giswater Association are not responsible and assume no liability whatsoever for any results or any use made of the results obtained from the program, nor for any damages or litigation that result from the use of these programs for any purpose.
version=3.5.037
version=3.5.038
author=David Erill, Luigi Pirelli, Natasa Cica, Nestor Ibañez, Adrian Valenciano, Barbara Rzepka, Sergi Muñoz, Josep Lluís Sala, Edgar Fusté, Albert Bofill, Sergi Maspons, Elies Bertran, Abel García Juanes, Xavier Torret

Changelog=Version 3.5.037
- Bug fix in Dscenario Manager.
- Bug fix with config files. If they break the plugin will still load.
- Fix section title in go2epa options dialog.
Changelog=Version 3.5.038
- Add user variables to auto load or not go2epa selector layers
- Various bug fixes


tags= giswater, water networks, sewerage, urban drainage, EPANET, SWMM
Expand Down

0 comments on commit 7396dbd

Please sign in to comment.