Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions PyReconstruct/modules/gui/main/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(self, filename):
self.mouse_palette = None
self.zarr_palette = None
self.viewer = None
self.scene_peek = None
self.shortcuts_widget = None
self.is_zooming = False
self.restart_mainwindow = False
Expand Down Expand Up @@ -277,6 +278,9 @@ def checkActions(self, context_menu=False, clicked_trace=None, clicked_label=Non
## Check for lists panel collapse (UI v1 Slice 3)
self.togglelistspanel_act.setChecked(self.field.table_manager.listsPanelCollapsed())

## Check for 3D scene peek (UI v1 — 3D peek)
self.threedscene_act.setChecked(self.scenePeekIsOpen())

## Group visibility
for group, viz in self.series.groups_visibility.items():
try:
Expand Down Expand Up @@ -338,6 +342,8 @@ def createShortcuts(self):
("Shift+F3", lambda : self.field.shearTform(sx=-0.005)),
("F4", lambda : self.field.shearTform(sy=0.005)),
("Shift+F4", lambda : self.field.shearTform(sy=-0.005)),

("Ctrl+Shift+D", lambda : self.toggleScenePeek()), # 3D scene peek (UI v1)
]

for kbd, act in shortcuts:
Expand Down Expand Up @@ -1724,6 +1730,50 @@ def _applyListsPanelState(self):
manager.setListsPanelCollapsed(collapsed)
self.togglelistspanel_act.setChecked(collapsed)

def scenePeekIsOpen(self) -> bool:
"""Whether the 3D peek exists and is open. Safe to call on any UI
refresh before the peek has been lazily built (checkActions uses it)."""
return bool(self.scene_peek) and self.scene_peek.is_open

def _ensureScenePeek(self):
"""Lazily build the 3D-scene slide-over over the current field."""
if self.scene_peek is None:
from PyReconstruct.modules.gui.main.scene_peek import ScenePeek
self.scene_peek = ScenePeek(self)
self.scene_peek.toggled.connect(self._onScenePeekToggled)
return self.scene_peek

def _onScenePeekToggled(self, is_open : bool):
"""Keep the View-menu checkbox in sync with the peek's open state."""
if hasattr(self, "threedscene_act"):
self.threedscene_act.setChecked(is_open)

def toggleScenePeek(self, show=None):
"""Open/close the right-edge 3D-scene slide-over (UI v1 — 3D peek).

Both production callers — the 3D-menu checkbox action and the
Ctrl+Shift+D shortcut — invoke this with NO argument, so it pure-toggles
off the panel's authoritative ``is_open`` (the checkbox is then re-synced
by ``_onScenePeekToggled``). ``show`` is a programmatic/test affordance
to force a state.

Params:
show (bool | None): force open (True) / closed (False); None toggles.
"""
peek = self._ensureScenePeek()
want_open = (not peek.is_open) if show is None else bool(show)
peek.open() if want_open else peek.close()

def openFullScene(self):
"""Hand off from the peek to the full window-based 3D viewer: bring an
existing scene forward, else open one for the selected objects (the same
path as the object list's "Add to scene")."""
if self.viewer and not self.viewer.is_closed:
self.viewer.activateWindow()
self.viewer.setFocus()
else:
self.field.addTo3D()

def setToObject(self, obj_name : str, section_num : int):
"""Focus the field on an object from a specified section.

Expand Down Expand Up @@ -3104,6 +3154,8 @@ def setTheme(self, new_theme=None):
self._apply_app_icon()
if self.mouse_palette is not None:
self.mouse_palette.refreshModeIcons()
if self.scene_peek is not None:
self.scene_peek.refreshTheme()

def addToRecentSeries(self, series_fp : str = None):
"""Add a series to the recently opened series list."""
Expand Down
2 changes: 2 additions & 0 deletions PyReconstruct/modules/gui/main/menubar.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def return_series_menu(self):
"text": "3D",
"opts":
[
("threedscene_act", "3D scene peek", "checkbox", self.toggleScenePeek),
None,
("load3Dscene_act", "Load 3D scene...", "", self.load3DScene),
]
},
Expand Down
Loading