Commit d6ded17c authored by Domanski, Marian M.'s avatar Domanski, Marian M.
Browse files

add logging, set combo box to current ras plan

parent 37c7df97
......@@ -43,6 +43,9 @@ class HecrasDialog(QDialog):
def __init__(self, main_window):
# Initialization
super().__init__()
class_name = self.__class__.__name__
self.logger = logger.getChild(class_name)
self.logger.debug("Initializing {}".format(class_name))
self.ui = Ui_HecrasDialog()
self.ui.setupUi(self)
self.setWindowTitle("HEC-RAS Settings")
......@@ -134,6 +137,7 @@ class HecrasDialog(QDialog):
"""Handle function for changing current plan"""
# Populate profile based on current plan in ras project
if self.ui.comboBox_plan.hasFocus():
self.logger.debug("Plan changed")
self.populate_profiles()
def handle_steadiness_change(self):
......@@ -147,15 +151,23 @@ class HecrasDialog(QDialog):
"""Populates the plans combo box"""
# Populate plans using current project
file_path = self.ui.lineEdit_project.text()
self.logger.debug("Populating plan names from RAS project")
if file_path != '':
with RASProject(file_path) as ras_project:
# Clear and populate plans
self.ui.comboBox_plan.clear()
self.ui.comboBox_plan.addItems(ras_project.plan_names())
# Set current plan to 1st plan
ras_project.set_current_plan(
self.ui.comboBox_plan.currentText())
self.ui.comboBox_plan.setCurrentIndex(0)
plan_names = ras_project.plan_names()
current_plan_name = ras_project.current_plan_name()
self.logger.debug("Plan names: {}".format(", ".join(plan_names)))
self.logger.debug("Current plan name in RAS project: {}".format(
current_plan_name))
# Clear and populate plans
self.ui.comboBox_plan.clear()
self.ui.comboBox_plan.addItems(plan_names)
current_index = plan_names.index(current_plan_name)
self.ui.comboBox_plan.setCurrentIndex(current_index)
def populate_profiles(self):
"""Populates the profiles combo box
......@@ -166,12 +178,17 @@ class HecrasDialog(QDialog):
file_path = self.ui.lineEdit_project.text()
try:
if file_path != '':
current_plan = self.ui.comboBox_plan.currentText()
self.logger.debug(
"Populating profiles for plan {}".format(current_plan))
with RASProject(file_path) as ras_project:
ras_project.set_current_plan(
self.ui.comboBox_plan.currentText())
self.ui.comboBox_profile.clear()
self.ui.comboBox_profile.addItems(
ras_project.profile_names())
ras_project.set_current_plan(current_plan)
profile_names = ras_project.profile_names()
self.logger.debug("Profile names: {}".format(
", ".join(profile_names)))
self.ui.comboBox_profile.clear()
self.ui.comboBox_profile.addItems(profile_names)
except:
self.close()
msg = QMessageBox()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment