diff options
author | Blaine | 2020-06-18 15:43:57 +0530 |
---|---|---|
committer | Blaine | 2020-06-18 15:43:57 +0530 |
commit | c0c5fe6186ca5776c9ff8199b88c13c2ad0e72a8 (patch) | |
tree | 51147c3cb4c97a6a1fb59605dd9860c7645c943d | |
parent | 384bdf5f033ba1453efdbb8baf43cdaa9049c9df (diff) | |
download | Chemical-PFD-c0c5fe6186ca5776c9ff8199b88c13c2ad0e72a8.tar.gz Chemical-PFD-c0c5fe6186ca5776c9ff8199b88c13c2ad0e72a8.tar.bz2 Chemical-PFD-c0c5fe6186ca5776c9ff8199b88c13c2ad0e72a8.zip |
save fileupdate
-rw-r--r-- | src/main/python/shapes/line.py | 11 | ||||
-rw-r--r-- | src/main/python/utils/app.py | 3 | ||||
-rw-r--r-- | src/main/python/utils/canvas.py | 25 | ||||
-rw-r--r-- | src/main/python/utils/streamTable.py | 12 |
4 files changed, 37 insertions, 14 deletions
diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 6883662..57778fa 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -292,13 +292,16 @@ class LineLabel(QGraphicsTextItem): "text": self.toPlainText(), "index": self.index, "gap": self.gap, - "pos": (self.pos().x(), self.pos().y()) + "pos": (self.pos().x(), self.pos().y()), + "values": self.values } def __setstate__(self, dict): self.setPlainText(dict['text']) self.index = dict['index'] self.gap = dict['gap'] + for key, value in dict['values']: + self.values[key] = value def findIndex(line, pos): @@ -1023,8 +1026,12 @@ class Line(QGraphicsPathItem): "refLine": hex(id(self.refLine)) if self.refLine else 0, "refIndex": self.refIndex, "label": [i for i in self.label], - "id": hex(id(self)) + "id": hex(id(self)), + "startGap": self.startGap, + "endGap": self.endGap } def __setstate__(self, dict): self.points = [QPointF(x, y) for x, y in dict["points"]] + self.startGap = dict['startGap'] + self.endGap = dict['endGap'] diff --git a/src/main/python/utils/app.py b/src/main/python/utils/app.py index 96a45b0..60ae47f 100644 --- a/src/main/python/utils/app.py +++ b/src/main/python/utils/app.py @@ -61,5 +61,4 @@ class JSON_Typer(JSONEncoder): importer = pyqtProperty(str, fileImporter) -shapeGrips = {} -lines = {}
\ No newline at end of file +memMap = {}
\ No newline at end of file diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index 47e95a9..e492878 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 shapeGrips, lines +from .app import memMap from .streamTable import streamTable, moveRect import shapes @@ -142,7 +142,8 @@ class canvas(customView): "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), - "landscape": self.landscape + "landscape": self.landscape, + "streamTable": [self.streamTable, (self.streamTableRect.pos().x(), self.streamTable.pos().y())] if self.streamTable else False } def __setstate__(self, dict): @@ -159,7 +160,7 @@ class canvas(customView): graphic.updateLineGripItem() graphic.updateSizeGripItem() for gripitem in item['lineGripItems']: - shapeGrips[gripitem[0]] = (graphic, gripitem[1]) + memMap[gripitem[0]] = (graphic, gripitem[1]) if item['label']: graphicLabel = shapes.ItemLabel(pos = QPointF(*item['label']['pos']), parent = graphic) graphicLabel.__setstate__(item['label']) @@ -167,19 +168,19 @@ class canvas(customView): for item in dict['lines']: line = shapes.Line(QPointF(*item['startPoint']), QPointF(*item['endPoint'])) - lines[item['id']] = line + memMap[item['id']] = line line.__setstate__(dict = item) self.painter.addItem(line) - graphic, index = shapeGrips[item['startGripItem']] + graphic, index = memMap[item['startGripItem']] line.startGripItem = graphic.lineGripItems[index] graphic.lineGripItems[index].line = line if item['endGripItem']: - graphic, index = shapeGrips[item['endGripItem']] + graphic, index = memMap[item['endGripItem']] line.endGripItem = graphic.lineGripItems[index] graphic.lineGripItems[index].line = line else: - line.refLine = lines[item['refLine']] - lines[item['refLine']].midLines.append(line) + line.refLine = memMap[item['refLine']] + memMap[item['refLine']].midLines.append(line) line.refIndex = item['refIndex'] for label in item['label']: labelItem = shapes.LineLabel(QPointF(*label['pos']), line) @@ -189,8 +190,12 @@ class canvas(customView): line.updateLine() line.addGrabber() - shapeGrips.clear() - lines.clear() + if dict['streamTable']: + table = streamTable(self.labelItems, self) + self.addStreamTable(QPointF(*dict['streamTable'][1]), table) + table.__setstate__(dict['streamTable'][0]) + + memMap.clear() self.painter.advance() diff --git a/src/main/python/utils/streamTable.py b/src/main/python/utils/streamTable.py index 7dfc27f..52b62c1 100644 --- a/src/main/python/utils/streamTable.py +++ b/src/main/python/utils/streamTable.py @@ -147,6 +147,18 @@ class streamTable(QTableView): for i in range(self.model.rowCount()): h += self.rowHeight(i) return QRect(0, 0, w, h) + + def __getstate__(self): + return { + "borderThickness": self.borderThickness, + "header": self.model.header + } + + def __setstate__(self, dict): + for key, value in dict['borderThickness']: + self.borderThickness[key] = value + self.model.header = dict['header'] + self.repaint() class drawBorderDelegate(QStyledItemDelegate): |