From db1e22fcf2aa9fd38a10867cc24813f8c4c9f079 Mon Sep 17 00:00:00 2001 From: lucaszhao19 Date: Wed, 8 Jan 2020 17:04:01 +0530 Subject: Creating, deleting, saving and loading graphics related parts fully completed --- container.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'container.py') diff --git a/container.py b/container.py index 8b47c05..6cfc689 100644 --- a/container.py +++ b/container.py @@ -10,19 +10,18 @@ from PyQt5.QtWidgets import QGraphicsProxyWidget, QGraphicsObject, QGraphicsElli from PyQt5.QtGui import QBrush ,QTransform ,QMouseEvent import PyQt5.QtCore as QtCore import PyQt5.QtWidgets as QtWidgets -from dockWidget import dockWidget import datetime import itertools import json import pickle import os import sys -unitOp = [] +from Graphics import * + class Container(): - def __init__(self,msgbrowser): - #self.unitOp = [] + self.unitOp = [] self.thermoPackage = None self.compounds = None self.flowsheet = None @@ -33,6 +32,7 @@ class Container(): self.msg.setText("") self.opl=[] self.result=[] + self.graphics = Graphics(self.unitOp) def currentTime(self): now = datetime.datetime.now() @@ -65,24 +65,26 @@ class Container(): except Exception as e: print(e) - def addUnitOp(self,obj,scene,graphics): + @staticmethod + def addUnitOpObj(obj): + self.unitOp.append(obj) + + def addUnitOp(self,obj): box = None self.obj = obj - self.scene = scene - self.graphics = graphics + self.scene = self.graphics.getScene() box = self.graphics.createNodeItem(self.obj) self.scene.addItem(box) box.setPos(2500-30, 2500-30) - if(obj in unitOp): + if(obj in self.unitOp): pass else: - #self.unitOp.append(obj) - unitOp.append(obj) + self.unitOp.append(obj) self.msg.append("["+str(self.currentTime())+"] "+obj.name+" is instantiated .""") def fetchObject(self,name): - for i in unitOp: + for i in self.unitOp: if(i.name==name): return i @@ -109,11 +111,10 @@ class Container(): print("SIMULATE") print(mode) self.compounds = compound_selected - #self.connection() self.flowsheet = Flowsheet() self.flowsheet.add_comp_list(self.compounds) print("######## connection master#########\n",self.conn) - for i in unitOp : + for i in self.unitOp : print("here",i) self.flowsheet.add_UnitOpn(i) -- cgit