Skip to content

Commit

Permalink
colormap synchronisation (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
irkri committed Nov 22, 2024
1 parent fe4e2ce commit f1491d3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
31 changes: 25 additions & 6 deletions blitz/layout/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from PyQt5.QtCore import QCoreApplication, QUrl
from PyQt5.QtGui import QDesktopServices, QKeySequence
from PyQt5.QtWidgets import QApplication, QFileDialog, QMainWindow, QShortcut
from pyqtgraph.graphicsItems.GradientEditorItem import Gradients

from .. import __version__, settings
from ..data.image import ImageData
Expand All @@ -14,6 +15,7 @@
from .tof import TOFAdapter
from .ui import UI_MainWindow


URL_GITHUB = QUrl("https://github.com/CodeSchmiedeHGW/BLITZ")
URL_INP = QUrl("https://www.inp-greifswald.de/")

Expand Down Expand Up @@ -264,12 +266,29 @@ def setup_sync(self) -> None:
self.ui.spinbox_max_ram.value,
self.ui.spinbox_max_ram.setValue,
)
# settings.connect_sync(
# self.ui.image_viewer.ui.histogram.gradient.sigGradientChanged,
# # self.ui.spinbox_max_ram.value,
# # self.ui.spinbox_max_ram.setValue,
# "default/greyclip",
# )

# very dirty workaround of getting the name of the user chosen
# gradient from the LUT
def loadPreset(name: str):
self.ui.image_viewer.ui.histogram.gradient.lastCM = name
self.ui.image_viewer.ui.histogram.gradient.restoreState(
Gradients[name] # type: ignore
)
def lastColorMap():
return self.ui.image_viewer.ui.histogram.gradient.lastCM
self.ui.image_viewer.ui.histogram.gradient.lastColorMap = lastColorMap
self.ui.image_viewer.ui.histogram.gradient.loadPreset = loadPreset
self.ui.image_viewer.ui.histogram.gradient.loadPreset(
settings.get("default/colormap")
)

settings.connect_sync(
"default/colormap",
self.ui.image_viewer.ui.histogram
.gradient.sigGradientChangeFinished,
self.ui.image_viewer.ui.histogram.gradient.lastColorMap,
self.ui.image_viewer.ui.histogram.gradient.loadPreset,
)
settings.connect_sync(
"web/address",
self.ui.address_edit.editingFinished,
Expand Down
2 changes: 1 addition & 1 deletion blitz/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"default/multicore_files_threshold": 333,
"default/load_8bit": False,
"default/load_grayscale": True,
"default/max_ram": 2,
"default/max_ram": 2.,
"default/colormap": "greyclip",

"data/sync": False,
Expand Down

0 comments on commit f1491d3

Please sign in to comment.