mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-06 11:47:58 -05:00
* Restore the Custom Camera Source in the Device Tab The printer-agent refactor reused the Device tab's WebView for the generic snapshot stream and dropped the "Custom camera source" row from the Camera Setting popup along with the code that showed the user's URL in that WebView. The two app-config keys were then read nowhere, so anyone who had a custom camera configured lost it on upgrade. Bring the row back and show the stored URL when the source is enabled, with the title-bar switch button toggling between it and the printer's own stream. The agent-driven snapshot path leaves the WebView alone while a custom source is enabled, a URL without a scheme gets http://, and the Enable/Disable labels are translatable separately. * Offer the Custom Camera Source Only Alongside the Bambu Native Stream The custom view hides the Device tab's media control and play bar, which every agent camera mode plays through (snapshot mode via the very WebView the custom source takes over), and the 2.4.2 feature was only ever used against the Bambu native stream. Gate the row and the stored URL on camera mode none, which is that stream, so the custom source never contends with an agent's own playback. Stop the native stream when the custom view takes over, reapply the switch icon on rescale and theme change, trim and normalise the URL in one shared helper, and reword the hint to say a URL is expected. * Keep the Custom Camera View in Step With the Agent's Camera Mode Selecting a printer whose agent streams through the shared WebView leaves the stored custom source unsupported, so reapply the view whenever the stored state and the applied one differ, on every camera tick and on the no-printer reset. Read the config flag before asking the agent for its mode, so users without a custom source pay one config lookup per tick. Stop the printer stream for the view switch without the failure bookkeeping, which could open the LAN dialog mid-connect. Write the trimmed URL back into the field and store it only when enabling. * Load the Custom Camera Page Only While It Is On Screen Let the show helper own the WebView page: it stops the native stream, then loads the URL when the custom view comes up and a blank page when it goes away, so a hidden view pulls no stream and the load never races the stop. Track the applied state in a member and evaluate the stored state once per tick. A view-switch stop leaves no retry count or back-off behind, the URL field is read-only while the source is enabled, and the gating comment says what mode none actually is. * Pass the Custom Camera URL Through Once Per Tick Read the stored URL once per camera tick and hand it to the sync, apply and show helpers, so a toggle can no longer show a blank page when the URL is empty and the camera-state branches no longer start with an empty if. Disable the URL field while the source is enabled, which greys it out, instead of a read-only state with no visual cue. The gating comment now gives the real reason: the custom view hides the media control and play bar that every agent mode plays through, and the feature was only ever used against the Bambu native stream. * Offer the Custom Camera Source With the Bambu Printer Agent Only Printer agents are not for general use in 2.5.0, so gate the row on the active printer agent being the Bambu one instead of on its camera mode. The interaction with the other agents' camera modes gets a proper design after the release. * Note That the Custom Camera Source Is a Temporary Bambu-Only Patch Say at the gate and in the header that the feature is a patch for the Bambu printer agent and is to be deprecated or extended to the other agents once printer agents are fully implemented.
149 lines
4.6 KiB
C++
149 lines
4.6 KiB
C++
#ifndef slic3r_CameraPopup_hpp_
|
|
#define slic3r_CameraPopup_hpp_
|
|
|
|
#include "slic3r/GUI/MonitorBasePanel.h"
|
|
#include "DeviceManager.hpp"
|
|
#include "GUI.hpp"
|
|
#include <wx/event.h>
|
|
#include <cstddef>
|
|
#include <string>
|
|
#include <vector>
|
|
#include "slic3r/GUI/DeviceErrorDialog.hpp"
|
|
#include "slic3r/GUI/wxExtensions.hpp"
|
|
#include <wx/panel.h>
|
|
#include <wx/bitmap.h>
|
|
#include <wx/image.h>
|
|
#include <wx/string.h>
|
|
#include <wx/scrolwin.h>
|
|
#include <wx/rtti.h>
|
|
#include <wx/timer.h>
|
|
#include <wx/sizer.h>
|
|
#include <wx/gbsizer.h>
|
|
#include <wx/webrequest.h>
|
|
#include <wx/hyperlink.h>
|
|
#include "Widgets/SwitchButton.hpp"
|
|
#include "Widgets/RadioBox.hpp"
|
|
#include "Widgets/PopupWindow.hpp"
|
|
#include "Widgets/Button.hpp"
|
|
#include "Widgets/TextInput.hpp"
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
|
|
wxDECLARE_EVENT(EVT_VCAMERA_SWITCH, wxMouseEvent);
|
|
wxDECLARE_EVENT(EVT_SDCARD_ABSENT_HINT, wxCommandEvent);
|
|
wxDECLARE_EVENT(EVT_CAM_SOURCE_CHANGE, wxCommandEvent);
|
|
|
|
class CameraPopup : public PopupWindow
|
|
{
|
|
public:
|
|
CameraPopup(wxWindow *parent);
|
|
virtual ~CameraPopup() {}
|
|
|
|
// PopupWindow virtual methods are all overridden to log them
|
|
virtual void Popup(wxWindow *focus = NULL) wxOVERRIDE;
|
|
virtual void OnDismiss() wxOVERRIDE;
|
|
virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE;
|
|
virtual bool Show(bool show = true) wxOVERRIDE;
|
|
|
|
void sync_vcamera_state(bool show_vcamera);
|
|
void check_func_supported(MachineObject* obj);
|
|
void update(bool vcamera_streaming);
|
|
|
|
// Temporary patch for the Bambu printer agent only. The custom view hides the Device tab's
|
|
// media control and play bar and takes over its WebView, which the other agents' camera
|
|
// modes play through. Once printer agents are fully implemented, camera sources are
|
|
// expected to come from the agents themselves, and this feature is to be deprecated or
|
|
// extended to the other agents.
|
|
static bool custom_source_supported();
|
|
// The URL to show, normalised; empty when the source is disabled, blank or unsupported.
|
|
static std::string custom_source_url();
|
|
|
|
enum CameraResolution
|
|
{
|
|
RESOLUTION_720P = 0,
|
|
RESOLUTION_1080P = 1,
|
|
RESOLUTION_OPTIONS_NUM = 2
|
|
};
|
|
|
|
void rescale();
|
|
|
|
protected:
|
|
void on_switch_recording(wxCommandEvent& event);
|
|
void on_set_resolution();
|
|
void sdcard_absent_hint();
|
|
void on_camera_source_changed(wxCommandEvent& event);
|
|
void set_custom_cam_button_state(bool state);
|
|
|
|
wxWindow * create_item_radiobox(wxString title, wxWindow *parent, wxString tooltip, int padding_left);
|
|
void select_curr_radiobox(int btn_idx);
|
|
void sync_resolution_setting(std::string resolution);
|
|
void reset_resolution_setting();
|
|
wxString to_resolution_label_string(CameraResolution resolution);
|
|
std::string to_resolution_msg_string(CameraResolution resolution);
|
|
|
|
private:
|
|
MachineObject* m_obj { nullptr };
|
|
wxTimer* m_interval_timer{nullptr};
|
|
bool m_is_in_interval{ false };
|
|
wxStaticText* m_text_recording;
|
|
SwitchButton* m_switch_recording;
|
|
wxStaticText* m_text_vcamera;
|
|
SwitchButton* m_switch_vcamera;
|
|
#if !BBL_RELEASE_TO_PUBLIC
|
|
wxStaticText* m_text_liveview_retry;
|
|
SwitchButton* m_switch_liveview_retry;
|
|
#endif //BBL_RELEASE_TO_PUBLIC
|
|
wxStaticText* m_custom_camera_hint;
|
|
TextInput* m_custom_camera_input;
|
|
Button* m_custom_camera_input_confirm;
|
|
bool m_custom_camera_enabled{ false };
|
|
wxStaticText* m_text_resolution;
|
|
wxWindow* m_resolution_options[RESOLUTION_OPTIONS_NUM];
|
|
wxScrolledWindow *m_panel;
|
|
wxBoxSizer* main_sizer;
|
|
std::vector<RadioBox*> resolution_rbtns;
|
|
std::vector<wxStaticText*> resolution_texts;
|
|
CameraResolution curr_sel_resolution = RESOLUTION_1080P;
|
|
Label* vcamera_guide_link { nullptr };
|
|
wxPanel* link_underline{ nullptr };
|
|
bool is_vcamera_show = false;
|
|
bool allow_alter_resolution = false;
|
|
|
|
void start_interval();
|
|
void stop_interval(wxTimerEvent& event);
|
|
void OnMouse(wxMouseEvent &event);
|
|
void OnSize(wxSizeEvent &event);
|
|
void OnSetFocus(wxFocusEvent &event);
|
|
void OnKillFocus(wxFocusEvent &event);
|
|
void OnLeftUp(wxMouseEvent& event);
|
|
|
|
private:
|
|
wxDECLARE_ABSTRACT_CLASS(CameraPopup);
|
|
wxDECLARE_EVENT_TABLE();
|
|
};
|
|
|
|
|
|
class CameraItem : public wxPanel
|
|
{
|
|
public:
|
|
CameraItem(wxWindow *parent, std::string normal, std::string hover);
|
|
~CameraItem();
|
|
|
|
MachineObject *m_obj{nullptr};
|
|
bool m_hover{false};
|
|
ScalableBitmap m_bitmap_normal;
|
|
ScalableBitmap m_bitmap_hover;
|
|
|
|
void msw_rescale();
|
|
void on_enter_win(wxMouseEvent &evt);
|
|
void on_level_win(wxMouseEvent &evt);
|
|
void paintEvent(wxPaintEvent &evt);
|
|
void render(wxDC &dc);
|
|
void doRender(wxDC &dc);
|
|
};
|
|
|
|
}
|
|
}
|
|
#endif
|