summaryrefslogtreecommitdiff
path: root/src/main/python/utils/canvas.py
diff options
context:
space:
mode:
authorBlaine2020-06-09 20:59:54 +0530
committerBlaine2020-06-10 11:29:50 +0530
commit08344c77962dced303078c2cc798348278183daa (patch)
treec5dec33a05d93898dd0a45473a4e3db68db03f76 /src/main/python/utils/canvas.py
parentf4aac3c926ee71c18516442c0a2440c27d4dd7a3 (diff)
downloadChemical-PFD-08344c77962dced303078c2cc798348278183daa.tar.gz
Chemical-PFD-08344c77962dced303078c2cc798348278183daa.tar.bz2
Chemical-PFD-08344c77962dced303078c2cc798348278183daa.zip
implement labels and version info to saved file
Diffstat (limited to 'src/main/python/utils/canvas.py')
-rw-r--r--src/main/python/utils/canvas.py22
1 files changed, 13 insertions, 9 deletions
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