Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associate edge output #174

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qgis/widgets/dataset_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
QVBoxLayout,
QWidget,
)
from ribasim_qgis.core.nodes import Edge, Node, load_nodes_from_geopackage
from ribasim_qgis.core.topology import derive_connectivity, explode_lines

from qgis.core import QgsMapLayer, QgsProject
from qgis.core.additions.edit import edit
from ribasim_qgis.core.nodes import Edge, Node, load_nodes_from_geopackage
from ribasim_qgis.core.topology import derive_connectivity, explode_lines


class DatasetTreeWidget(QTreeWidget):
Expand Down
1 change: 0 additions & 1 deletion qgis/widgets/nodes_widget.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from functools import partial

from PyQt5.QtWidgets import QGridLayout, QPushButton, QVBoxLayout, QWidget

from ribasim_qgis.core.nodes import NODES


Expand Down
29 changes: 20 additions & 9 deletions qgis/widgets/output_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,32 @@ class OutputWidget(QWidget):
def __init__(self, parent):
super().__init__(parent)
self.parent = parent
self.output_button = QPushButton("Associate Output")

self.output_button.clicked.connect(self.set_output)

self.node_output_button = QPushButton("Associate Node Output")
self.edge_output_button = QPushButton("Associate Edge Output")
self.node_output_button.clicked.connect(self.set_node_output)
self.edge_output_button.clicked.connect(self.set_edge_output)
layout = QVBoxLayout()
layout.addWidget(self.output_button)
layout.addWidget(self.node_output_button)
layout.addWidget(self.edge_output_button)
layout.addStretch()
self.setLayout(layout)

def set_output(self):
def _set_output(self, layer, column: str):
path, _ = QFileDialog.getOpenFileName(self, "Select file", "", "*.arrow")
if path == "":
return
if layer is not None:
layer.setCustomProperty("arrow_type", "timeseries")
layer.setCustomProperty("arrow_path", path)
layer.setCustomProperty("arrow_fid_column", column)
return

def set_node_output(self):
node_layer = self.parent.dataset_widget.node_layer
if node_layer is not None:
node_layer.setCustomProperty("arrow_type", "timeseries")
node_layer.setCustomProperty("arrow_path", path)
self._set_output(node_layer, "node_id")
return

def set_edge_output(self):
edge_layer = self.parent.dataset_widget.edge_layer
self._set_output(edge_layer, "edge_id")
return
4 changes: 2 additions & 2 deletions qgis/widgets/ribasim_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from typing import Any

from PyQt5.QtWidgets import QTabWidget, QVBoxLayout, QWidget

from qgis.core import QgsMapLayer, QgsProject
from ribasim_qgis.widgets.dataset_widget import DatasetWidget
from ribasim_qgis.widgets.nodes_widget import NodesWidget
from ribasim_qgis.widgets.output_widget import OutputWidget

from qgis.core import QgsMapLayer, QgsProject

PYQT_DELETED_ERROR = "wrapped C/C++ object of type QgsLayerTreeGroup has been deleted"


Expand Down