Skip to content

Commit

Permalink
Adjusted AGEScanViewer
Browse files Browse the repository at this point in the history
  • Loading branch information
adryyan committed Sep 24, 2024
1 parent 9b17da0 commit 38b8c37
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include src/agepy/ageplot/*.mplstyle
include src/agepy/interactive/icons/roi.svg
include src/agepy/interactive/icons/*.svg
20 changes: 18 additions & 2 deletions src/agepy/interactive/_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,29 @@ def add_toolbar(self):

def add_roi_action(self, callback: callable):
# Add ROI button to toolbar
with imrsrc.path("agepy.interactive.icons", "roi.svg") as icon_path:
roi = QAction(QIcon(str(icon_path)), "Add ROI", self)
with imrsrc.path("agepy.interactive.icons", "roi.svg") as ipath:
roi = QAction(QIcon(str(ipath)), "Add ROI", self)
roi.setCheckable(True)
roi.triggered.connect(callback)
actions = self.toolbar.actions()
self.roi_button = self.toolbar.insertAction(actions[-1], roi)

def add_forward_backward_action(self,
bw_callback: callable,
fw_callback: callable
) -> None:
actions = self.toolbar.actions()
# Add backward step to toolbar
with imrsrc.path("agepy.interactive.icons", "bw-step.svg") as ipath:
bw = QAction(QIcon(str(ipath)), "Step Backward", self)
bw.triggered.connect(bw_callback)
self.bw = self.toolbar.insertAction(actions[-1], bw)
# Add forward step to toolbar
with imrsrc.path("agepy.interactive.icons", "fw-step.svg") as ipath:
fw = QAction(QIcon(str(ipath)), "Step Forward", self)
fw.triggered.connect(fw_callback)
self.fw = self.toolbar.insertAction(actions[-1], fw)

class AGEpp:
def __init__(self, viewer: QMainWindow, *args, **kwargs):
self.app = QApplication.instance()
Expand Down
1 change: 1 addition & 0 deletions src/agepy/interactive/icons/bw-step.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/agepy/interactive/icons/fw-step.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 6 additions & 11 deletions src/agepy/interactive/photons.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class AGEScanViewer(AGEDataViewer):

def __init__(self, scan, bins: int = 512) -> None:
super().__init__()
# Add plot to canvas
self.add_plot()
# Add the toolbar
self.add_toolbar()
# Add forward and backward buttons
self.add_forward_backward_action(self.plot_previous, self.plot_next)
# Get the data
self.y = []
self.err = []
Expand All @@ -24,17 +30,6 @@ def __init__(self, scan, bins: int = 512) -> None:
self.err.append(err)
# Remember current step
self.step = 0
# Add previous and next buttons
self.prev = QPushButton()
self.prev.clicked.connect(self.plot_previous)
icon_prev = self.style().standardIcon(QStyle.SP_ArrowBack)
self.prev.setIcon(icon_prev)
self.toolbar.addWidget(self.prev)
self.next = QPushButton()
self.next.clicked.connect(self.plot_next)
icon_next = self.style().standardIcon(QStyle.SP_ArrowForward)
self.next.setIcon(icon_next)
self.toolbar.addWidget(self.next)
# Plot the first step
self.plot(self.step)

Expand Down

0 comments on commit 38b8c37

Please sign in to comment.