From c31f52cefea50e61afe05e9927a970a06ab8bb66 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Sat, 1 Apr 2023 18:58:16 +0200 Subject: [PATCH] multi-points drawing --- src/gui_qt/graphs/draw_inputs.py | 13 ++++++++++--- src/gui_qt/graphs/draw_objects.py | 6 ++++-- src/gui_qt/graphs/drawings.py | 2 -- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/gui_qt/graphs/draw_inputs.py b/src/gui_qt/graphs/draw_inputs.py index 815ddf2..2e77c5a 100644 --- a/src/gui_qt/graphs/draw_inputs.py +++ b/src/gui_qt/graphs/draw_inputs.py @@ -100,9 +100,16 @@ class MultiPointWidget(QtWidgets.QWidget, Ui_multipointwidget): return dic - def set_args(self, pos: float=0.0, angle: int = None, color = None): - self.pos_lineedit.setText(str(pos)) - self.orient_combobox.setCurrentIndex(angle%90) + def set_args(self, x: tuple = None, y: tuple = None, closed: bool = True, color=None): + self.table_widget.clear() + self.table_widget.setRowCount(0) + + for row, (x_i, y_i) in enumerate(zip(x, y)): + self.new_point() + self.table_widget.cellWidget(row, 0).setText(str(x_i)) + self.table_widget.cellWidget(row, 1).setText(str(y_i)) + + self.loop_checkbox.setChecked(closed) self.color_box.setCurrentIndex(self.color_box.findData(color)) diff --git a/src/gui_qt/graphs/draw_objects.py b/src/gui_qt/graphs/draw_objects.py index eed47c8..c1e1c13 100644 --- a/src/gui_qt/graphs/draw_objects.py +++ b/src/gui_qt/graphs/draw_objects.py @@ -85,11 +85,13 @@ class MultipointObject(BaseObject): dic['y'] = self._y return dic - def set_values(self, x=None, y=None, closed=None, color=None): + def set_values(self, pts: list, closed: bool = None, color=None): if color != self.color: self.drawing.setPen(mkPen(color.rgb())) + x, y = zip(*pts) + self._x = x self._y = y @@ -97,7 +99,7 @@ class MultipointObject(BaseObject): self._x += (x[0],) self._y += (y[0],) - self.drawing.setPos(self._x, self._y) + self.drawing.setData(self._x, self._y) class Rectangle(GraphicsObject): diff --git a/src/gui_qt/graphs/drawings.py b/src/gui_qt/graphs/drawings.py index 3c0c242..81067fb 100644 --- a/src/gui_qt/graphs/drawings.py +++ b/src/gui_qt/graphs/drawings.py @@ -62,8 +62,6 @@ class DrawingsWidget(QtWidgets.QWidget, Ui_Form): graph_id, obj = self.get_item() - print(dic) - if self._editmode: obj.set_values(**dic)