Skip to content

Commit

Permalink
Specific toolbar for camera configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mmouchous-ledger committed Feb 16, 2024
1 parent 47603a9 commit 8f65542
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 26 deletions.
62 changes: 37 additions & 25 deletions laserstudio/laserstudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .widgets.viewer import Viewer
from .widgets.keyboardbox import KeyboardBox
from .instruments.instruments import Instruments
from .widgets.stagesight import StageSightViewer, StageSight


class LaserStudio(QMainWindow):
Expand Down Expand Up @@ -124,31 +125,6 @@ def __init__(self, config: Optional[dict]):
w.clicked.connect(self.viewer.load_picture)
toolbar.addWidget(w)

if self.viewer.stage_sight is not None:
# Button to toggle off or on the camera image presentation
w = QPushButton(toolbar)
w.setToolTip("Show/Hide Image")
w.setCheckable(True)
w.setChecked(True)
icon = QIcon()
icon.addPixmap(
QPixmap(resource_path(":/icons/fontawesome-free/video-solid-24.png")),
QIcon.Mode.Normal,
QIcon.State.On,
)
icon.addPixmap(
QPixmap(
resource_path(":/icons/fontawesome-free/video-slash-solid-24.png")
),
QIcon.Mode.Normal,
QIcon.State.Off,
)
w.setIcon(icon)
w.setIconSize(QSize(24, 24))
w.toggled.connect(
lambda b: self.viewer.stage_sight.__setattr__("show_image", b)
)
toolbar.addWidget(w)

# Button to trigger a Go Next
w = QPushButton(toolbar)
Expand Down Expand Up @@ -223,6 +199,42 @@ def __init__(self, config: Optional[dict]):
toolbar.addWidget(w)
self.addToolBar(Qt.ToolBarArea.RightToolBarArea, toolbar)

# Camera Image toolbar
if self.instruments.camera is not None:
toolbar = QToolBar(self)
toolbar.setAllowedAreas(
Qt.ToolBarArea.LeftToolBarArea | Qt.ToolBarArea.RightToolBarArea
)
toolbar.setFloatable(True)
stage_sight = StageSight(None, self.instruments.camera)
toolbar.addWidget(StageSightViewer(stage_sight))

# Button to toggle off or on the camera image presentation in main viewer
w = QPushButton(toolbar)
w.setToolTip("Show/Hide Image")
w.setCheckable(True)
w.setChecked(True)
icon = QIcon()
icon.addPixmap(
QPixmap(resource_path(":/icons/fontawesome-free/video-solid-24.png")),
QIcon.Mode.Normal,
QIcon.State.On,
)
icon.addPixmap(
QPixmap(
resource_path(":/icons/fontawesome-free/video-slash-solid-24.png")
),
QIcon.Mode.Normal,
QIcon.State.Off,
)
w.setIcon(icon)
w.setIconSize(QSize(24, 24))
w.toggled.connect(
lambda b: self.viewer.stage_sight.__setattr__("show_image", b)
)
toolbar.addWidget(w)
self.addToolBar(Qt.ToolBarArea.RightToolBarArea, toolbar)

def handle_go_next(self):
"""Go Next operation.
Triggers the instruments to perform changes to go to next step of scan.
Expand Down
13 changes: 13 additions & 0 deletions laserstudio/widgets/stagesight.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
QGraphicsPixmapItem,
QGraphicsRectItem,
QGraphicsLineItem,
QGraphicsView,
QGraphicsScene,
)
from PyQt6.QtGui import QPen, QColor, QTransform, QImage, QPixmap
from PyQt6.QtCore import (
Expand All @@ -20,6 +22,17 @@
import logging


class StageSightViewer(QGraphicsView):
"""Simple version of Viewer, containing a StageSight"""

def __init__(self, stage_sight: "StageSight", parent=None):
super().__init__(parent)
s = QGraphicsScene()
self.scale(1, -1)
self.setScene(s)
s.addItem(stage_sight)


class StageSightObject(QObject):
# Signal emitted when a new position is set
position_changed = pyqtSignal(QPointF, name="positionChanged")
Expand Down
2 changes: 1 addition & 1 deletion laserstudio/widgets/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, parent=None):
self.scale(1, -1)

# By default, there is no StageSight
self.stage_sight = None
self.stage_sight: Optional[StageSight] = None

# Scanning geometry object and its representative item in the view.
# Also includes the scan path
Expand Down

0 comments on commit 8f65542

Please sign in to comment.