Skip to content

Commit

Permalink
change colormap handling; add installation notes (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
irkri committed Jan 3, 2025
1 parent e381714 commit 8a60d94
Show file tree
Hide file tree
Showing 8 changed files with 402 additions and 383 deletions.
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,39 @@
- [Quick Start Guide](docs/walkthrough.md)
- [Core Functionalities](docs/Tabs_explained.md)



## Development

To compile and develop locally:

1. Clone the repository:
```bash
git clone https://github.com/CodeSchmiedeHGW/BLITZ.git
cd BLITZ
```

$ git clone https://github.com/CodeSchmiedeHGW/BLITZ.git
$ cd BLITZ

2. Set up a virtual environment and install dependencies:
```bash
pip install poetry
poetry install
poetry run python -m blitz

$ pip install poetry
$ poetry install
$ poetry run python -m blitz

Sometimes the installation with poetry might fail due to package restrictions with ``PyQt5``.
For a quick fix, comment out the following three lines in [pyproject.toml](pyproject.toml).
```
3. To create a binary executable:
```bash
pyinstaller --onefile --noconsole --icon=./resources/icon/blitz.ico blitz_main.py
# PyQt5 = "^5.15.11"
# pyqtgraph = "^0.13.7"
# QDarkStyle = "^3.2.3"
```
Afterwards, just install these packages via ``pip`` inside the newly created virtual
environment:
$ poetry shell
$ python -m pip install PyQt5==5.15.11
$ python -m pip install pyqtgraph==0.13.7
$ python -m pip install QDarkStyle==3.2.3
3. To create a binary executable:
$ pyinstaller --onefile --noconsole --icon=./resources/icon/blitz.ico blitz_main.py
## Additional Resources
Expand Down
2 changes: 1 addition & 1 deletion blitz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "1.2.1"
__version__ = "1.3.0"

from . import data, layout
2 changes: 1 addition & 1 deletion blitz/data/image.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Any, Literal, Optional
from typing import Literal, Optional

import numpy as np
import pyqtgraph as pg
Expand Down
13 changes: 9 additions & 4 deletions blitz/layout/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
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 @@ -267,9 +266,10 @@ def setup_sync(self) -> None:
self.ui.spinbox_max_ram.setValue,
)

# very dirty workaround of getting the name of the user chosen
# very dirty workaround of getting the name of the user-chosen
# gradient from the LUT
def loadPreset(name: str):
self.ui.checkbox_auto_colormap.setChecked(False)
self.ui.image_viewer.ui.histogram.gradient.lastCM = name
self.ui.image_viewer.ui.histogram.gradient.restoreState(
Gradients[name] # type: ignore
Expand All @@ -278,16 +278,21 @@ 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(
self.ui.image_viewer.ui.histogram.gradient.lastCM = (
settings.get("default/colormap")
)
if settings.get("default/colormap") != "greyclip":
self.ui.checkbox_auto_colormap.setChecked(False)

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,
lambda name:
self.ui.image_viewer.ui.histogram.gradient.restoreState(
Gradients[name]
),
)
settings.connect_sync(
"web/address",
Expand Down
5 changes: 3 additions & 2 deletions blitz/layout/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from PyQt5.QtCore import QPoint, pyqtSignal
from PyQt5.QtGui import QDropEvent
from pyqtgraph import RectROI
from pyqtgraph.graphicsItems.GradientEditorItem import Gradients

from .. import settings
from ..data.load import DataLoader, ImageData
Expand Down Expand Up @@ -143,11 +144,11 @@ def auto_colormap(self) -> None:
if (min_ := self.image.min()) < 0 < (max_ := self.image.max()):
max_ = max(abs(min_), max_)
min_ = - max_
self.ui.histogram.gradient.loadPreset('bipolar')
self.ui.histogram.gradient.restoreState(Gradients['bipolar'])
self.setLevels(min=min_, max=max_)
self.ui.histogram.setHistogramRange(min_, max_)
else:
self.ui.histogram.gradient.loadPreset('greyclip')
self.ui.histogram.gradient.restoreState(Gradients['greyclip'])
super().autoLevels()

def load_data(self, path: Optional[Path] = None, **kwargs) -> None:
Expand Down
Loading

0 comments on commit 8a60d94

Please sign in to comment.