Skip to content
Open
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

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions src/slic3r/GUI/MediaPlayCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, BBLMediaCtrl *media_ctrl, const w
{
SetLabel("MediaPlayCtrl");
SetBackgroundColour(*wxWHITE);
m_media_ctrl->Bind(wxEVT_MEDIA_STATECHANGED, &MediaPlayCtrl::onStateChanged, this);
if (m_media_ctrl)
m_media_ctrl->Bind(wxEVT_MEDIA_STATECHANGED, &MediaPlayCtrl::onStateChanged, this);

m_button_play = new Button(this, "", "media_play", wxBORDER_NONE);
m_button_play->SetCanFocus(false);
Expand All @@ -55,7 +56,8 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, BBLMediaCtrl *media_ctrl, const w

m_label_stat = new Label(this, "");
m_label_stat->SetForegroundColour(wxColour("#323A3C"));
m_media_ctrl->Bind(EVT_MEDIA_CTRL_STAT, [this](auto & e) {
if (m_media_ctrl)
m_media_ctrl->Bind(EVT_MEDIA_CTRL_STAT, [this](auto & e) {
#if !BBL_RELEASE_TO_PUBLIC
wxSize size = m_media_ctrl->GetVideoSize();
m_label_stat->SetLabel(e.GetString() + wxString::Format(" VS:%ix%i", size.x, size.y));
Expand Down Expand Up @@ -259,6 +261,8 @@ void MediaPlayCtrl::Play()
{
if (!m_next_retry.IsValid() || wxDateTime::Now() < m_next_retry)
return;
if (!m_media_ctrl)
return;
if (!IsShownOnScreen())
return;
if (m_last_state != MEDIASTATE_IDLE) {
Expand Down Expand Up @@ -387,6 +391,8 @@ void start_ping_test();
void MediaPlayCtrl::Stop(wxString const &msg, wxString const &msg2)
{
int last_state = m_last_state;
if (!m_media_ctrl)
return;

if (m_last_state != MEDIASTATE_IDLE) {
m_media_ctrl->InvalidateBestSize();
Expand Down Expand Up @@ -553,8 +559,13 @@ void MediaPlayCtrl::ToggleStream()
NetworkAgent *agent = wxGetApp().getAgent();
if (!agent) return;
std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
auto token = std::weak_ptr(m_token);
agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto],
[this, m = m_machine, v = agent->get_version(), dv = m_dev_ver](std::string url) {
[this, m = m_machine, v = agent->get_version(), dv = m_dev_ver, token](std::string url) {
if (token.expired()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": token has been expired";
return;
}
if (boost::algorithm::starts_with(url, "bambu:///")) {
url += "&device=" + m;
url += "&net_ver=" + v;
Expand Down Expand Up @@ -597,9 +608,11 @@ void MediaPlayCtrl::jump_to_play()
void MediaPlayCtrl::onStateChanged(wxMediaEvent &event)
{
auto last_state = m_last_state;
if (!m_media_ctrl) return;
auto state = m_media_ctrl->GetState();
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::onStateChanged: " << state << ", last_state: " << last_state;
if ((int) state < 0) return;
if (!m_media_ctrl) return;
{
boost::unique_lock lock(m_mutex);
if (!m_tasks.empty()) {
Expand Down Expand Up @@ -667,6 +680,7 @@ bool MediaPlayCtrl::IsStreaming() const { return m_streaming; }

void MediaPlayCtrl::load()
{
if (!m_media_ctrl) return;
m_last_state = MEDIASTATE_LOADING;
SetStatus(_L("Loading..."));
if (wxGetApp().app_config->get("internal_developer_mode") == "true") {
Expand Down Expand Up @@ -701,6 +715,10 @@ void MediaPlayCtrl::media_proc()
while (m_tasks.empty()) {
m_cond.wait(lock);
}
if (!m_media_ctrl) {
m_tasks.pop_front();
continue;
}
wxString url = m_tasks.front();
if (m_tasks.size() >= 2 && !url.IsEmpty() && url[0] != '<' && m_tasks[1] == "<stop>") {
BOOST_LOG_TRIVIAL(trace) << "MediaPlayCtrl: busy skip url: " << url;
Expand Down
45 changes: 25 additions & 20 deletions src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4030,30 +4030,35 @@ void Sidebar::update_printer_thumbnail()
if (printer_thumbnails.find(printer_type) != printer_thumbnails.end()) // Use known cache first
p->image_printer->SetBitmap(create_scaled_bitmap(printer_thumbnails[printer_type], this, PRINTER_THUMBNAIL_SIZE.GetHeight()));
else {
try {
// No cache, try dedicated printer preview
p->image_printer->SetBitmap(create_scaled_bitmap("printer_preview_" + printer_type, this, 48));
// Success, cache it
printer_thumbnails[printer_type] = "printer_preview_" + printer_type;
return;
} catch (...) {}
const std::string printer_preview_key = printer_type.empty() ? std::string() : "printer_preview_" + printer_type;
if (!printer_preview_key.empty()) {
try {
// No cache, try dedicated printer preview
p->image_printer->SetBitmap(create_scaled_bitmap(printer_preview_key, this, 48));
// Success, cache it
printer_thumbnails[printer_type] = printer_preview_key;
return;
} catch (...) {}
}

// Orca: try to use the printer model cover as the thumbnail
const auto model_name = selected_preset.config.opt_string("printer_model");
std::string cover_file = model_name + "_cover.png";
for (auto vendor_profile : preset_bundle->vendors) {
for (auto vendor_model : vendor_profile.second.models) {
if (vendor_model.name == model_name) {
// Try to find the printer cover
boost::filesystem::path cover_path = boost::filesystem::absolute(boost::filesystem::path(resources_dir()) /
"/profiles/" / vendor_profile.second.id / cover_file)
if (!model_name.empty()) {
std::string cover_file = model_name + "_cover.png";
for (auto vendor_profile : preset_bundle->vendors) {
for (auto vendor_model : vendor_profile.second.models) {
if (vendor_model.name == model_name) {
// Try to find the printer cover
boost::filesystem::path cover_path = boost::filesystem::absolute(boost::filesystem::path(resources_dir()) /
"/profiles/" / vendor_profile.second.id / cover_file)
.make_preferred();
if (boost::filesystem::exists(cover_path)) {
try {
p->image_printer->SetBitmap(create_scaled_bitmap(cover_path.string(), this, PRINTER_THUMBNAIL_SIZE.GetHeight()));
printer_thumbnails[printer_type] = cover_path.string(); // Cache the path so we don't look up again
return;
} catch (...) {}
if (boost::filesystem::exists(cover_path)) {
try {
p->image_printer->SetBitmap(create_scaled_bitmap(cover_path.string(), this, PRINTER_THUMBNAIL_SIZE.GetHeight()));
printer_thumbnails[printer_type] = cover_path.string(); // Cache the path so we don't look up again
return;
} catch (...) {}
}
}
}
}
Expand Down
21 changes: 12 additions & 9 deletions src/slic3r/GUI/SelectMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5238,15 +5238,18 @@ void PrinterInfoBox::SetPrinters(const std::vector<MachineObject*>& sorted_print
drop_item.text_static_tips = _get_tips(obj);

// update image
try
{
drop_item.icon = create_scaled_bitmap("printer_preview_" + obj->printer_type, this, 32);
drop_item.icon_textctrl = create_scaled_bitmap("printer_preview_" + obj->printer_type, this, 52);
}
catch (const std::exception&)
{
drop_item.icon = create_scaled_bitmap("printer_preview_BL-P001", this, 32);
drop_item.icon_textctrl = create_scaled_bitmap("printer_preview_BL-P001", this, 52);
const std::string printer_preview_key = obj->printer_type.empty() ? std::string() : "printer_preview_" + obj->printer_type;
if (!printer_preview_key.empty()) {
try {
drop_item.icon = create_scaled_bitmap(printer_preview_key, this, 32);
drop_item.icon_textctrl = create_scaled_bitmap(printer_preview_key, this, 52);
} catch (const std::exception&) {
drop_item.icon = create_scaled_bitmap("printer_placeholder", this, 32);
drop_item.icon_textctrl = create_scaled_bitmap("printer_placeholder", this, 52);
}
} else {
drop_item.icon = create_scaled_bitmap("printer_placeholder", this, 32);
drop_item.icon_textctrl = create_scaled_bitmap("printer_placeholder", this, 52);
}

drop_item.tip = obj->get_printer_type_display_str();
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Widgets/PopupWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void PopupWindow::OnMouseEvent2(wxMouseEvent &evt)
void PopupWindow::topWindowActiavate(wxActivateEvent &event)
{
event.Skip();
if (!event.GetActive() && IsShown()) DismissAndNotify();
if (!event.GetActive() && IsShown() && ShouldDismissOnTopWindowDeactivate()) DismissAndNotify();
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/slic3r/GUI/Widgets/PopupWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class PopupWindow : public wxPopupTransientWindow
#ifdef __WXMSW__
void BindUnfocusEvent();
#endif
protected:
virtual bool ShouldDismissOnTopWindowDeactivate() { return true; }
private:
#ifdef __WXOSX__
void OnMouseEvent2(wxMouseEvent &evt);
Expand Down