From 2cdd1b40a2cf410ea1970afeb692649e7cd07b29 Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 9 Jun 2020 12:39:52 +0530 Subject: implement id logic --- src/main/python/utils/canvas.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/main/python/utils/canvas.py') diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index a83aeb2..2b029e0 100644 --- a/src/main/python/utils/canvas.py +++ b/src/main/python/utils/canvas.py @@ -6,7 +6,7 @@ from PyQt5.QtWidgets import (QFileDialog, QApplication, QHBoxLayout, QMenu, from . import dialogs from .graphics import customView, customScene from .data import paperSizes, ppiList, sheetDimensionList -from .app import dumps, loads, JSON_Typer +from .app import dumps, loads, JSON_Typer, shapeGrips, lines import shapes @@ -129,7 +129,7 @@ class canvas(QWidget): "canvasSize": self._canvasSize, "ObjectName": self.objectName(), "symbols": [i for i in self.painter.items() if isinstance(i, shapes.NodeItem)], - "lines": [i for i in self.painter.items() if isinstance(i, shapes.Line)], + "lines": sorted([i for i in self.painter.items() if isinstance(i, shapes.Line)], key = lambda x: 1 if x.refLine else 0), # "lineLabels": [i.__getstate__() for i in self.painter.items() if isinstance(i, shapes.LineLabel)], # "itemLabels": [i.__getstate__() for i in self.painter.items() if isinstance(i, shapes.itemLabel)] } @@ -144,12 +144,29 @@ class canvas(QWidget): graphic.__setstate__(dict = item) self.painter.addItem(graphic) graphic.setPos(*item['pos']) + for gripitem in item['lineGripItems']: + shapeGrips[gripitem[0]] = (graphic, gripitem[1]) for item in dict['lines']: line = shapes.Line(QPointF(*item['startPoint']), QPointF(*item['endPoint'])) + lines[item['id']] = line line.__setstate__(dict = item) + graphic, index = shapeGrips[item['startGripItem']] + line.setStartGripItem = graphic.lineGripItems[index] + graphic.lineGripItems[index].line = line + print("hello2") + if item['endGripItem']: + graphic, index = shapeGrips[item['endGripItem']] + line.setEndGripItem = graphic.lineGripItems[index] + graphic.lineGripItems[index].line = line + else: + line.refLine = lines[item['refLine']] + line.refIndex = item['refIndex'] self.painter.addItem(line) + # line.addGrabber() + shapeGrips.clear() + lines.clear() self.painter.advance() # for item in dict['lineLabels']: -- cgit From 6da3f0038037ad3553370eb264912bfe380f2089 Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 9 Jun 2020 13:10:59 +0530 Subject: implement changeable file name --- src/main/python/utils/canvas.py | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/python/utils/canvas.py') diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index 2b029e0..d1da9bc 100644 --- a/src/main/python/utils/canvas.py +++ b/src/main/python/utils/canvas.py @@ -154,7 +154,6 @@ class canvas(QWidget): graphic, index = shapeGrips[item['startGripItem']] line.setStartGripItem = graphic.lineGripItems[index] graphic.lineGripItems[index].line = line - print("hello2") if item['endGripItem']: graphic, index = shapeGrips[item['endGripItem']] line.setEndGripItem = graphic.lineGripItems[index] -- cgit From a4a2642e9d9934c65a853d17c899ea9337ab9c5e Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 9 Jun 2020 14:25:52 +0530 Subject: complete loading --- src/main/python/utils/canvas.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/main/python/utils/canvas.py') diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index d1da9bc..93a7722 100644 --- a/src/main/python/utils/canvas.py +++ b/src/main/python/utils/canvas.py @@ -144,6 +144,8 @@ class canvas(QWidget): graphic.__setstate__(dict = item) self.painter.addItem(graphic) graphic.setPos(*item['pos']) + graphic.updateLineGripItem() + graphic.updateSizeGripItem() for gripitem in item['lineGripItems']: shapeGrips[gripitem[0]] = (graphic, gripitem[1]) @@ -151,18 +153,21 @@ class canvas(QWidget): line = shapes.Line(QPointF(*item['startPoint']), QPointF(*item['endPoint'])) lines[item['id']] = line line.__setstate__(dict = item) + self.painter.addItem(line) graphic, index = shapeGrips[item['startGripItem']] - line.setStartGripItem = graphic.lineGripItems[index] + line.startGripItem = graphic.lineGripItems[index] graphic.lineGripItems[index].line = line - if item['endGripItem']: + if item['endGripItem']: graphic, index = shapeGrips[item['endGripItem']] - line.setEndGripItem = graphic.lineGripItems[index] + print(graphic.lineGripItems[index]) + line.endGripItem = graphic.lineGripItems[index] graphic.lineGripItems[index].line = line else: line.refLine = lines[item['refLine']] + lines[item['refLine']].midLines.append(line) line.refIndex = item['refIndex'] - self.painter.addItem(line) - # line.addGrabber() + line.updateLine() + line.addGrabber() shapeGrips.clear() lines.clear() -- cgit From 08344c77962dced303078c2cc798348278183daa Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 9 Jun 2020 20:59:54 +0530 Subject: implement labels and version info to saved file --- src/main/python/utils/canvas.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/main/python/utils/canvas.py') diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index 93a7722..94661aa 100644 --- a/src/main/python/utils/canvas.py +++ b/src/main/python/utils/canvas.py @@ -6,7 +6,7 @@ from PyQt5.QtWidgets import (QFileDialog, QApplication, QHBoxLayout, QMenu, from . import dialogs from .graphics import customView, customScene from .data import paperSizes, ppiList, sheetDimensionList -from .app import dumps, loads, JSON_Typer, shapeGrips, lines +from .app import shapeGrips, lines import shapes @@ -129,9 +129,7 @@ class canvas(QWidget): "canvasSize": self._canvasSize, "ObjectName": self.objectName(), "symbols": [i for i in self.painter.items() if isinstance(i, shapes.NodeItem)], - "lines": sorted([i for i in self.painter.items() if isinstance(i, shapes.Line)], key = lambda x: 1 if x.refLine else 0), - # "lineLabels": [i.__getstate__() for i in self.painter.items() if isinstance(i, shapes.LineLabel)], - # "itemLabels": [i.__getstate__() for i in self.painter.items() if isinstance(i, shapes.itemLabel)] + "lines": sorted([i for i in self.painter.items() if isinstance(i, shapes.Line)], key = lambda x: 1 if x.refLine else 0) } def __setstate__(self, dict): @@ -148,6 +146,10 @@ class canvas(QWidget): graphic.updateSizeGripItem() for gripitem in item['lineGripItems']: shapeGrips[gripitem[0]] = (graphic, gripitem[1]) + if item['label']: + graphicLabel = shapes.ItemLabel(pos = QPointF(*item['label']['pos']), parent = graphic) + graphicLabel.__setstate__(item['label']) + self.painter.addItem(graphicLabel) for item in dict['lines']: line = shapes.Line(QPointF(*item['startPoint']), QPointF(*item['endPoint'])) @@ -166,16 +168,18 @@ class canvas(QWidget): line.refLine = lines[item['refLine']] lines[item['refLine']].midLines.append(line) line.refIndex = item['refIndex'] + for label in item['label']: + labelItem = shapes.LineLabel(QPointF(*label['pos']), line) + line.label.append(labelItem) + labelItem.__setstate__(label) + self.painter.addItem(labelItem) line.updateLine() line.addGrabber() - + shapeGrips.clear() lines.clear() self.painter.advance() - # for item in dict['lineLabels']: - # pass - # for item in dict['itemLabels']: - # pass + \ No newline at end of file -- cgit From c12a8397e195e2b517eb98a894b7a03886208b24 Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 9 Jun 2020 21:02:19 +0530 Subject: remove print statement --- src/main/python/utils/canvas.py | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/python/utils/canvas.py') diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index 94661aa..3f9cee5 100644 --- a/src/main/python/utils/canvas.py +++ b/src/main/python/utils/canvas.py @@ -161,7 +161,6 @@ class canvas(QWidget): graphic.lineGripItems[index].line = line if item['endGripItem']: graphic, index = shapeGrips[item['endGripItem']] - print(graphic.lineGripItems[index]) line.endGripItem = graphic.lineGripItems[index] graphic.lineGripItems[index].line = line else: -- cgit