mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-30 04:11:00 +00:00
Give the Design tab its own camera view
The Camera is Plater-owned and shared by every canvas, and Design sits outside the panel switch that saves and restores it for Prepare, Preview and Assemble — so orbiting in Design moved what the editor tabs showed, and Design lost its own view on every switch. Trade the live camera for a parked one on the way in and back on the way out, so Design keeps its view the way Assemble already does.
This commit is contained in:
@@ -189,6 +189,15 @@ DesignCanvas::DesignCanvas(wxWindow* parent)
|
||||
|
||||
refresh_bed();
|
||||
|
||||
// The view this canvas opens on. Built lazily, on the way into the Design tab, so this
|
||||
// is the view the user is looking at right now.
|
||||
m_parked_camera = wxGetApp().plater()->get_camera();
|
||||
|
||||
// Before any of this class's own Binds below: wx calls dynamically bound handlers in
|
||||
// reverse order of binding, and GLCanvas3D::on_mouse takes wxEVT_RIGHT_UP / ENTER_WINDOW
|
||||
// without skipping them — so whatever is bound last is the only handler that sees them.
|
||||
// The context menu, the focus-follows-mouse and the status-chip re-anchor all depend on
|
||||
// running first, which is only true while this call stays ahead of them.
|
||||
m_canvas->bind_event_handlers();
|
||||
|
||||
// The Design GL canvas only receives key events (Esc to exit/enter Select, Ctrl+Z undo)
|
||||
@@ -268,6 +277,24 @@ void DesignCanvas::request_repaint()
|
||||
}
|
||||
}
|
||||
|
||||
void DesignCanvas::enter_viewport()
|
||||
{
|
||||
if (!m_camera_swapped) swap_camera();
|
||||
}
|
||||
|
||||
void DesignCanvas::leave_viewport()
|
||||
{
|
||||
if (m_camera_swapped) swap_camera();
|
||||
}
|
||||
|
||||
void DesignCanvas::swap_camera()
|
||||
{
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (plater == nullptr) return;
|
||||
std::swap(plater->get_camera(), m_parked_camera);
|
||||
m_camera_swapped = !m_camera_swapped;
|
||||
}
|
||||
|
||||
void DesignCanvas::force_repaint()
|
||||
{
|
||||
if (m_canvas == nullptr || m_canvas_widget == nullptr)
|
||||
|
||||
Reference in New Issue
Block a user