Commit 3ca5cc5e authored by Lars Bittrich's avatar Lars Bittrich

moved and renamed Legend from analysisWidgets to colorlegend in main module where it is imported

parent f458c65b
...@@ -822,15 +822,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -822,15 +822,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.parent.contouritem.colorList = colorList self.parent.contouritem.colorList = colorList
self.parent.contouritem.update() self.parent.contouritem.update()
self.parent.imparent.legend.items = legendItems self.parent.imparent.legend.setTextColorItems(legendItems)
self.parent.imparent.legend.update()
self.parent.imparent.legend.show() self.parent.imparent.legend.show()
else: else:
self.parent.contouritem.colorList = [] self.parent.contouritem.colorList = []
self.parent.contouritem.update() self.parent.contouritem.update()
self.parent.imparent.legend.items = [] self.parent.imparent.legend.setTextColorItems([])
self.parent.imparent.legend.update()
self.parent.imparent.legend.hide() self.parent.imparent.legend.hide()
def show_hide_labels(self): def show_hide_labels(self):
......
...@@ -24,7 +24,7 @@ import numpy as np ...@@ -24,7 +24,7 @@ import numpy as np
WX, WY = 1024, 200 WX, WY = 1024, 200
class Legend(QtWidgets.QMdiSubWindow): class ColorLegend(QtWidgets.QMdiSubWindow):
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent) super().__init__(parent)
...@@ -38,6 +38,14 @@ class Legend(QtWidgets.QMdiSubWindow): ...@@ -38,6 +38,14 @@ class Legend(QtWidgets.QMdiSubWindow):
self.fontSize = 15 self.fontSize = 15
self.spacer = 10 self.spacer = 10
def setTextColorItems(self, items):
for text, color in items:
print(text, color)
assert type(text)==str or type(text)==np.str_, "items must be tuples of text and QColor"
assert type(color)==QtGui.QColor or type(color)==QtCore.Qt.GlobalColor, "items must be tuples of text and QColor"
self.items = items
self.update()
def mousePressEvent(self, event): def mousePressEvent(self, event):
if event.button()==QtCore.Qt.LeftButton: if event.button()==QtCore.Qt.LeftButton:
self.drag = event.pos() self.drag = event.pos()
......
...@@ -23,7 +23,7 @@ from sampleview import SampleView ...@@ -23,7 +23,7 @@ from sampleview import SampleView
from scalebar import ScaleBar from scalebar import ScaleBar
from ramancom.ramancontrol import defaultPath from ramancom.ramancontrol import defaultPath
from ramancom.ramanSwitch import RamanSwitch from ramancom.ramanSwitch import RamanSwitch
from analysis.analysisWidgets import Legend from colorlegend import ColorLegend
import os import os
from pathlib import Path from pathlib import Path
...@@ -39,7 +39,7 @@ class MeasureParticleWindow(QtWidgets.QMainWindow): ...@@ -39,7 +39,7 @@ class MeasureParticleWindow(QtWidgets.QMainWindow):
self.view.imparent = self self.view.imparent = self
self.view.ScalingChanged.connect(self.scalingChanged) self.view.ScalingChanged.connect(self.scalingChanged)
self.scalebar = ScaleBar(self) self.scalebar = ScaleBar(self)
self.legend = Legend(self) self.legend = ColorLegend(self)
self.ramanSwitch = RamanSwitch(self) self.ramanSwitch = RamanSwitch(self)
self.view.ScalingChanged.connect(self.scalebar.updateScale) self.view.ScalingChanged.connect(self.scalebar.updateScale)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment