diff options
author | brenda-br | 2023-01-19 04:12:17 +0530 |
---|---|---|
committer | brenda-br | 2023-01-19 04:12:17 +0530 |
commit | 7dbb6b0e06281f37eff2179202a2ebdaf0fc2905 (patch) | |
tree | 2746168a79914286cf6482bc7f9c0862e4d5cde8 | |
parent | 4b7069b35a9a20ec5a0fb6dfeda7e116768045f0 (diff) | |
download | Chemical-Simulator-GUI-7dbb6b0e06281f37eff2179202a2ebdaf0fc2905.tar.gz Chemical-Simulator-GUI-7dbb6b0e06281f37eff2179202a2ebdaf0fc2905.tar.bz2 Chemical-Simulator-GUI-7dbb6b0e06281f37eff2179202a2ebdaf0fc2905.zip |
Fix #32 Simulation Window Stopped Shifting after closing Dock Widgets
19 files changed, 63 insertions, 23 deletions
diff --git a/DockWidgets/DockWidget.py b/DockWidgets/DockWidget.py index 97ac7c8..e7e5b8b 100644 --- a/DockWidgets/DockWidget.py +++ b/DockWidgets/DockWidget.py @@ -8,7 +8,7 @@ from Graphics import * ui_dialog,_ = loadUiType('DockWidgets/DockWidget.ui') class DockWidget(QDockWidget,ui_dialog): - + def __init__(self,name,comptype,obj,container, parent=None): QDockWidget.__init__(self,parent) self.setupUi(self) @@ -145,3 +145,7 @@ class DockWidget(QDockWidget,ui_dialog): except Exception as e: print(e) + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue((scrollHVal+currentVal)/2)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetCompoundSeparator.py b/DockWidgets/DockWidgetCompoundSeparator.py index 5a80f84..69b2770 100644 --- a/DockWidgets/DockWidgetCompoundSeparator.py +++ b/DockWidgets/DockWidgetCompoundSeparator.py @@ -97,3 +97,7 @@ class DockWidgetCompoundSeparator(QDockWidget,ui_dialog): except Exception as e: print(e) + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue((scrollHVal+currentVal)/2)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetCompressorExpander.py b/DockWidgets/DockWidgetCompressorExpander.py index 841b850..5309bba 100644 --- a/DockWidgets/DockWidgetCompressorExpander.py +++ b/DockWidgets/DockWidgetCompressorExpander.py @@ -142,5 +142,8 @@ class DockWidgetCompressorExpander(QDockWidget,ui_dialog): except Exception as e: print(e) - -
\ No newline at end of file + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue((scrollHVal+currentVal)/2)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetDistillationColumn.py b/DockWidgets/DockWidgetDistillationColumn.py index 34b8590..716cb1a 100644 --- a/DockWidgets/DockWidgetDistillationColumn.py +++ b/DockWidgets/DockWidgetDistillationColumn.py @@ -357,3 +357,8 @@ class DockWidgetDistillationColumn(QDockWidget, ui_dialog): t.resizeColumnsToContents() except Exception as e: print(e) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue((scrollHVal+currentVal)/2)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetFlash.py b/DockWidgets/DockWidgetFlash.py index ff8efb5..c288259 100644 --- a/DockWidgets/DockWidgetFlash.py +++ b/DockWidgets/DockWidgetFlash.py @@ -68,4 +68,9 @@ class DockWidgetFlash(QDockWidget,ui_dialog): self.hide() except Exception as e: - print(e)
\ No newline at end of file + print(e) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue((scrollHVal+currentVal)/2)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py index 54d57b9..09cddf4 100644 --- a/DockWidgets/DockWidgetMaterialStream.py +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -345,4 +345,8 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): except Exception as e: - print(e)
\ No newline at end of file + print(e) + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue((scrollHVal+currentVal)/2)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetMixer.py b/DockWidgets/DockWidgetMixer.py index 6ec6795..748ef4f 100644 --- a/DockWidgets/DockWidgetMixer.py +++ b/DockWidgets/DockWidgetMixer.py @@ -49,4 +49,8 @@ class DockWidgetMixer(QDockWidget,ui_dialog): self.hide() except Exception as e: - print(e)
\ No newline at end of file + print(e) + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue((scrollHVal+currentVal)/2)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetShortcutColumn.py b/DockWidgets/DockWidgetShortcutColumn.py index 3d0c287..efb044a 100644 --- a/DockWidgets/DockWidgetShortcutColumn.py +++ b/DockWidgets/DockWidgetShortcutColumn.py @@ -131,4 +131,8 @@ class DockWidgetShortcutColumn(QDockWidget,ui_dialog): self.tableWidget.setItem(rowPosition , 2, QTableWidgetItem(obj.variables[val]['unit'])) self.tableWidget.resizeColumnsToContents() except Exception as e: - print(e)
\ No newline at end of file + print(e) + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue((scrollHVal+currentVal)/2)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetSplitter.py b/DockWidgets/DockWidgetSplitter.py index 3b8383c..05dfb0b 100644 --- a/DockWidgets/DockWidgetSplitter.py +++ b/DockWidgets/DockWidgetSplitter.py @@ -68,3 +68,8 @@ class DockWidgetSplitter(QDockWidget,ui_dialog): self.hide() except Exception as e: print(e) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue((scrollHVal+currentVal)/2)
\ No newline at end of file diff --git a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc Binary files differindex 2404cc1..0ba8062 100644 --- a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc Binary files differindex 0f5405f..8d268fd 100644 --- a/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc Binary files differindex f19c476..36c37df 100644 --- a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc Binary files differindex a9f19b7..5598cca 100644 --- a/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc Binary files differindex 9d77ce1..2c0b566 100644 --- a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc Binary files differindex c085079..8826d30 100644 --- a/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc Binary files differindex b60e9c5..3b7dff3 100644 --- a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc Binary files differindex c9bc90e..550ae4f 100644 --- a/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc diff --git a/Graphics.py b/Graphics.py index 8b2c41d..1478786 100644 --- a/Graphics.py +++ b/Graphics.py @@ -30,6 +30,7 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): self.graphicsView = graphicsView self.pos = None self.unit_operations = unit_operations + self.graphicsView.horizontalScrollBarVal = self.graphicsView.horizontalScrollBar().value() def get_scene(self): return self.scene @@ -285,7 +286,7 @@ class NodeSocket(QtWidgets.QGraphicsItem): def paint(self, painter, option, widget): painter.setBrush(self.brush) painter.setPen(self.pen) - painter.drawEllipse(self.rect.x()-4,self.rect.y()-4,12,12) + painter.drawEllipse(self.rect) def mousePressEvent(self, event): cursor = QCursor( Qt.PointingHandCursor ) @@ -386,7 +387,7 @@ class NodeSocket(QtWidgets.QGraphicsItem): def hoverEnterEvent(self, event): cursor = QCursor( Qt.PointingHandCursor) - QApplication.instance().setOverrideCursor(cursor) + QApplication.instance().setOverrideCursor(cursor) def hoverLeaveEvent(self, event): cursor = QCursor( Qt.ArrowCursor ) @@ -532,28 +533,28 @@ class NodeItem(QtWidgets.QGraphicsItem): def initialize_sockets(self,type): if(self.type=="Flash" or self.type=="CompoundSeparator"): - input = [NodeSocket(QtCore.QRect(5,(self.rect.height()*x/(self.nin+1)-2),12,12), self, 'in', x) for x in range(1,self.nin+1) ] - output = [NodeSocket(QtCore.QRect(self.rect.width()-9,(self.rect.height()*x*1/(self.nop+1)),12,12), self, 'op', x) for x in range(1,self.nop+1)] + input = [NodeSocket(QtCore.QRect(5,(self.rect.height()*x/(self.nin+1)-2),4,4), self, 'in', x) for x in range(1,self.nin+1) ] + output = [NodeSocket(QtCore.QRect(self.rect.width()-9,(self.rect.height()*x*1/(self.nop+1)),4,4), self, 'op', x) for x in range(1,self.nop+1)] return input,output elif(self.type=="AdiabaticCompressor" or self.type=="AdiabaticExpander" or self.type =="Mixer" or self.type =="Splitter" or self.type =="Valve" ): - input = [NodeSocket(QtCore.QRect(-2.5, (self.rect.height()*x/(self.nin+1))-2,12,12), self, 'in', x) for x in range(1,self.nin+1) ] - output = [NodeSocket(QtCore.QRect(self.rect.width()-2.5,(self.rect.height()*x/(self.nop+1))-2,12,12), self, 'op', x) for x in range(1,self.nop+1)] + input = [NodeSocket(QtCore.QRect(-2.5, (self.rect.height()*x/(self.nin+1))-2,4,4), self, 'in', x) for x in range(1,self.nin+1) ] + output = [NodeSocket(QtCore.QRect(self.rect.width()-2.5,(self.rect.height()*x/(self.nop+1))-2,4,4), self, 'op', x) for x in range(1,self.nop+1)] return input,output elif(self.type=="Cooler" or self.type=="Heater"): - input = [NodeSocket(QtCore.QRect(3.5, (self.rect.height()*x/(self.nin+1))-2,12,12), self, 'in', x) for x in range(1,self.nin+1) ] - output = [NodeSocket(QtCore.QRect(self.rect.width()-8.0,(self.rect.height()*x/(self.nop+1))-2,12,12), self, 'op', x) for x in range(1,self.nop+1)] + input = [NodeSocket(QtCore.QRect(3.5, (self.rect.height()*x/(self.nin+1))-2,4,4), self, 'in', x) for x in range(1,self.nin+1) ] + output = [NodeSocket(QtCore.QRect(self.rect.width()-8.0,(self.rect.height()*x/(self.nop+1))-2,4,4), self, 'op', x) for x in range(1,self.nop+1)] return input,output elif(self.type=="CentrifugalPump"): - input = [NodeSocket(QtCore.QRect(-2.5,(self.rect.height()*x/(self.nin+1))-7, 12,12), self, 'in', x) for x in range(1,self.nin+1) ] - output = [NodeSocket(QtCore.QRect(self.rect.width()-2.5,-1.5,12,12), self, 'op', x) for x in range(1,self.nop+1)] + input = [NodeSocket(QtCore.QRect(-2.5,(self.rect.height()*x/(self.nin+1))-7, 4,4), self, 'in', x) for x in range(1,self.nin+1) ] + output = [NodeSocket(QtCore.QRect(self.rect.width()-2.5,-1.5,4,4), self, 'op', x) for x in range(1,self.nop+1)] return input,output elif(self.type=="DistillationColumn" or self.type=="ShortcutColumn"): - input = [NodeSocket(QtCore.QRect(-2.5,(self.rect.height()*x/(self.nin+1)),12,12), self, 'in', x) for x in range(1,self.nin+1) ] - output = [NodeSocket(QtCore.QRect(self.rect.width()-5.5,(self.rect.height()*1.44*x/(self.nop+1))-55,12,12), self, 'op', x) for x in range(1,self.nop+1)] + input = [NodeSocket(QtCore.QRect(-2.5,(self.rect.height()*x/(self.nin+1)),5,5), self, 'in', x) for x in range(1,self.nin+1) ] + output = [NodeSocket(QtCore.QRect(self.rect.width()-5.5,(self.rect.height()*1.44*x/(self.nop+1))-55,5,5), self, 'op', x) for x in range(1,self.nop+1)] return input,output elif(self.type=="MaterialStream"): - input = [NodeSocket(QtCore.QRect(-2.5,(self.rect.height()*x/(self.nin+1)-2),12,12), self, 'in', x) for x in range(1,self.nin+1) ] - output = [NodeSocket(QtCore.QRect(self.rect.width()+1,(self.rect.height()*x/(self.nin+1)-2),12,12), self, 'op', x) for x in range(1,self.nop+1)] + input = [NodeSocket(QtCore.QRect(-2.5,(self.rect.height()*x/(self.nin+1)-2),4,4), self, 'in', x) for x in range(1,self.nin+1) ] + output = [NodeSocket(QtCore.QRect(self.rect.width()-2.5,(self.rect.height()*x/(self.nin+1)-2),4,4), self, 'op', x) for x in range(1,self.nop+1)] return input,output def mouseMoveEvent(self, event): @@ -571,6 +572,7 @@ class NodeItem(QtWidgets.QGraphicsItem): def mouseDoubleClickEvent(self, event): + self.graphicsView.horizontalScrollBarVal = self.graphicsView.horizontalScrollBar().value() self.graphicsView.setInteractive(False) if len(stack): stack[-1].hide() @@ -592,8 +594,8 @@ class NodeItem(QtWidgets.QGraphicsItem): self.dock_widget.update_compounds() except AttributeError: pass - - + + def findMainWindow(self): ''' Global function to find the (open) QMainWindow in application Binary files differ |