mirror of
https://github.com/QIDITECH/QIDIStudio.git
synced 2026-02-07 12:21:50 +03:00
update slic3r
This commit is contained in:
@@ -41,13 +41,14 @@ namespace Slic3r {
|
||||
namespace GUI {
|
||||
//1.9.5
|
||||
static int SecondsSinceLastInput();
|
||||
MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const wxPoint &pos, const wxSize &size)
|
||||
MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl3 *media_ctrl, const wxPoint &pos, const wxSize &size)
|
||||
: wxPanel(parent, wxID_ANY, pos, size)
|
||||
, m_media_ctrl(media_ctrl)
|
||||
{
|
||||
SetLabel("MediaPlayCtrl");
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
m_media_ctrl->Bind(wxEVT_MEDIA_STATECHANGED, &MediaPlayCtrl::onStateChanged, this);
|
||||
m_media_ctrl->SetIdleImage(from_u8(resources_dir() + "/images/live_stream_default.png"));
|
||||
|
||||
m_button_play = new Button(this, "", "media_play", wxBORDER_NONE);
|
||||
m_button_play->SetCanFocus(false);
|
||||
@@ -92,7 +93,7 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
||||
m_button_play->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto &e) { TogglePlay(); });
|
||||
m_button_play->Bind(wxEVT_RIGHT_UP, [this](auto & e) { m_media_ctrl->Play(); });
|
||||
m_label_status->Bind(wxEVT_LEFT_UP, [this](auto &e) {
|
||||
auto url = wxString::Format(L"https://wiki.qidilab.com/%s/software/qidi-studio/faq/live-view", L"en");
|
||||
auto url = wxString::Format(L"https://wiki.qidi3d.com/%s/software/qidi-studio/faq/live-view", L"en");
|
||||
wxLaunchDefaultBrowser(url);
|
||||
});
|
||||
|
||||
@@ -156,7 +157,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
||||
m_dev_ver = obj->get_ota_version();
|
||||
m_lan_mode = obj->is_lan_mode_printer();
|
||||
m_lan_proto = obj->liveview_local;
|
||||
m_remote_support = obj->liveview_remote;
|
||||
m_remote_proto = obj->liveview_remote;
|
||||
m_lan_ip = obj->dev_ip;
|
||||
m_lan_passwd = obj->get_access_code();
|
||||
m_device_busy = obj->is_camera_busy_off();
|
||||
@@ -169,21 +170,13 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
||||
m_lan_passwd.clear();
|
||||
m_dev_ver.clear();
|
||||
m_tutk_state.clear();
|
||||
m_remote_support = false;
|
||||
m_remote_proto = 0;
|
||||
m_device_busy = false;
|
||||
}
|
||||
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
|
||||
if (machine == m_machine) {
|
||||
if (m_last_state == MEDIASTATE_IDLE && IsEnabled())
|
||||
Play();
|
||||
else if (m_last_state == MEDIASTATE_IDLE && m_tutk_state == "disable"
|
||||
&& m_last_user_play + wxTimeSpan::Seconds(3) < wxDateTime::Now()) {
|
||||
// resend ttcode to printer
|
||||
if (auto agent = wxGetApp().getAgent())
|
||||
agent->get_camera_url(machine, [](auto) {});
|
||||
m_last_user_play = wxDateTime::Now();
|
||||
}
|
||||
//1.9.7.52
|
||||
if (m_last_state == wxMediaState::wxMEDIASTATE_PLAYING) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
if (m_play_timer <= now) {
|
||||
@@ -261,6 +254,18 @@ wxString hide_passwd(wxString url, std::vector<wxString> const &passwords)
|
||||
return url;
|
||||
}
|
||||
|
||||
void refresh_agora_url(char const* device, char const* dev_ver, char const* channel, void* context, void (*callback)(void* context, char const* url))
|
||||
{
|
||||
std::string device2 =device;
|
||||
device2 += "|";
|
||||
device2 += dev_ver;
|
||||
device2 += "|\"agora\"|";
|
||||
device2 += channel;
|
||||
wxGetApp().getAgent()->get_camera_url(device2, [context, callback](std::string url) {
|
||||
callback(context, url.c_str());
|
||||
});
|
||||
}
|
||||
|
||||
void MediaPlayCtrl::Play()
|
||||
{
|
||||
if (!m_next_retry.IsValid() || wxDateTime::Now() < m_next_retry)
|
||||
@@ -289,11 +294,12 @@ void MediaPlayCtrl::Play()
|
||||
return;
|
||||
}
|
||||
|
||||
m_button_play->SetIcon("media_stop");
|
||||
m_play_timer = std::chrono::system_clock::now();
|
||||
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
std::string agent_version = agent ? agent->get_version() : "";
|
||||
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) {
|
||||
m_disable_lan = m_remote_support && !m_lan_mode; // try remote next time
|
||||
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) {
|
||||
m_disable_lan = m_remote_proto && !m_lan_mode; // try remote next time
|
||||
std::string url;
|
||||
if (m_lan_proto == MachineObject::LVL_Local)
|
||||
url = "qidi:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
|
||||
@@ -309,19 +315,20 @@ void MediaPlayCtrl::Play()
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(hide_id_middle_string(url, url.find(m_lan_ip), m_lan_ip.length()), {m_lan_passwd});
|
||||
m_url = url;
|
||||
load();
|
||||
m_button_play->SetIcon("media_stop");
|
||||
return;
|
||||
}
|
||||
|
||||
// m_lan_mode && m_lan_proto > LVL_Disable (use local tunnel)
|
||||
// m_lan_mode && m_lan_proto == LVL_Disable (*)
|
||||
// m_lan_mode && m_lan_proto == LVL_None (x)
|
||||
// !m_lan_mode && m_remote_support (go on)
|
||||
// !m_lan_mode && !m_remote_support && m_lan_proto > LVL_None (use local tunnel)
|
||||
// !m_lan_mode && !m_remote_support && m_lan_proto == LVL_Disable (*)
|
||||
// !m_lan_mode && !m_remote_support && m_lan_proto == LVL_None (x)
|
||||
// !m_lan_mode && m_remote_proto (go on)
|
||||
// !m_lan_mode && !m_remote_proto && m_lan_proto > LVL_None (use local tunnel)
|
||||
// !m_lan_mode && !m_remote_proto && m_lan_proto == LVL_Disable (*)
|
||||
// !m_lan_mode && !m_remote_proto && m_lan_proto == LVL_None (x)
|
||||
|
||||
if (m_lan_proto <= MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support)) {
|
||||
Stop(m_lan_proto == MachineObject::LVL_None
|
||||
if (m_lan_proto <= MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto)) {
|
||||
Stop(m_lan_proto == MachineObject::LVL_None
|
||||
? _L("Problem occured. Please update the printer firmware and try again.")
|
||||
: _L("LAN Only Liveview is off. Please turn on the liveview on printer screen."));
|
||||
return;
|
||||
@@ -333,7 +340,7 @@ void MediaPlayCtrl::Play()
|
||||
//1.9.5
|
||||
m_button_play->SetIcon("media_stop");
|
||||
|
||||
if (!m_remote_support) { // not support tutk
|
||||
if (!m_remote_proto) { // not support tutk
|
||||
m_failed_code = -1;
|
||||
m_url = "qidi:///local/";
|
||||
Stop(_L("Please enter the IP of printer to connect."));
|
||||
@@ -342,19 +349,20 @@ void MediaPlayCtrl::Play()
|
||||
|
||||
m_label_stat->SetLabel({});
|
||||
SetStatus(_L("Initializing..."));
|
||||
m_play_timer = std::chrono::system_clock::now();
|
||||
|
||||
if (agent) {
|
||||
agent->get_camera_url(m_machine,
|
||||
std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
|
||||
agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto],
|
||||
[this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) {
|
||||
if (boost::algorithm::starts_with(url, "qidi:///")) {
|
||||
url += "&device=" + into_u8(m);
|
||||
url += "&net_ver=" + v;
|
||||
url += "&dev_ver=" + dv;
|
||||
url += "&refresh_url=" + boost::lexical_cast<std::string>(&refresh_agora_url);
|
||||
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
|
||||
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(url,
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(url,
|
||||
{"?uid=", "authkey=", "passwd=", "license=", "token="});
|
||||
CallAfter([this, m, url] {
|
||||
if (m != m_machine) {
|
||||
@@ -364,7 +372,7 @@ void MediaPlayCtrl::Play()
|
||||
if (m_last_state == MEDIASTATE_IDLE) {
|
||||
if (url.empty() || !boost::algorithm::starts_with(url, "qidi:///")) {
|
||||
m_failed_code = 3;
|
||||
Stop(_L("Connection Failed. Please check the network and try again"));
|
||||
Stop(_L("Connection Failed. Please check the network and try again"), from_u8(url));
|
||||
} else {
|
||||
m_url = url;
|
||||
load();
|
||||
@@ -379,7 +387,7 @@ void MediaPlayCtrl::Play()
|
||||
|
||||
void start_ping_test();
|
||||
|
||||
void MediaPlayCtrl::Stop(wxString const &msg)
|
||||
void MediaPlayCtrl::Stop(wxString const &msg, wxString const &msg2)
|
||||
{
|
||||
int last_state = m_last_state;
|
||||
|
||||
@@ -422,9 +430,9 @@ void MediaPlayCtrl::Stop(wxString const &msg)
|
||||
}
|
||||
|
||||
auto tunnel = m_url.empty() ? "" : into_u8(wxURI(m_url).GetPath()).substr(1);
|
||||
if (auto n = tunnel.find_first_of('/_'); n != std::string::npos)
|
||||
if (auto n = tunnel.find_first_of("/_"); n != std::string::npos)
|
||||
tunnel = tunnel.substr(0, n);
|
||||
if (last_state != wxMEDIASTATE_PLAYING && m_failed_code != 0
|
||||
if (last_state != wxMEDIASTATE_PLAYING && m_failed_code != 0
|
||||
&& m_last_failed_codes.find(m_failed_code) == m_last_failed_codes.end()
|
||||
&& (m_user_triggered || m_failed_retry > 3)) {
|
||||
json j;
|
||||
@@ -442,6 +450,8 @@ void MediaPlayCtrl::Stop(wxString const &msg)
|
||||
j["tutk_state"] = m_tutk_state;
|
||||
}
|
||||
j["msg"] = into_u8(msg);
|
||||
if (!msg2.IsEmpty())
|
||||
j["msg2"] = into_u8(msg2);
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
if (agent)
|
||||
agent->track_event("start_liveview", j.dump());
|
||||
@@ -560,7 +570,7 @@ void MediaPlayCtrl::ToggleStream()
|
||||
wxGetApp().app_config->set("not_show_vcamera_stop_prev", "1");
|
||||
if (res == wxID_CANCEL) return;
|
||||
}
|
||||
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) {
|
||||
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) {
|
||||
std::string url;
|
||||
if (m_lan_proto == MachineObject::LVL_Local)
|
||||
url = "qidi:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
|
||||
@@ -586,10 +596,11 @@ void MediaPlayCtrl::ToggleStream()
|
||||
url += "&device=" + m;
|
||||
url += "&net_ver=" + v;
|
||||
url += "&dev_ver=" + dv;
|
||||
url += "&refresh_url=" + boost::lexical_cast<std::string>(&refresh_agora_url);
|
||||
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
|
||||
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_passwd(url,
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_passwd(url,
|
||||
{"?uid=", "authkey=", "passwd=", "license=", "token="});
|
||||
CallAfter([this, m, url] {
|
||||
if (m != m_machine) return;
|
||||
@@ -661,7 +672,7 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent &event)
|
||||
j["result"] = "success";
|
||||
j["code"] = 0;
|
||||
auto tunnel = into_u8(wxURI(m_url).GetPath()).substr(1);
|
||||
if (auto n = tunnel.find_first_of('/_'); n != std::string::npos)
|
||||
if (auto n = tunnel.find_first_of("/_"); n != std::string::npos)
|
||||
tunnel = tunnel.substr(0, n);
|
||||
j["tunnel"] = tunnel;
|
||||
if (tunnel == "tutk") {
|
||||
@@ -695,6 +706,7 @@ void MediaPlayCtrl::SetStatus(wxString const &msg2, bool hyperlink)
|
||||
int state2 = m_last_state >= MEDIASTATE_IDLE ? m_last_state - MEDIASTATE_IDLE :
|
||||
m_last_state + MEDIASTATE_IDLE - MEDIASTATE_IDLE;
|
||||
msg += wxString::Format(" [%d:%d]", state2, m_failed_code);
|
||||
msg += wxDateTime::Now().Format(_T(" <%m-%d %H:%M>"));
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::SetStatus: " << msg.ToUTF8().data() << " tutk_state: " << m_tutk_state;
|
||||
#ifdef __WXMSW__
|
||||
@@ -771,7 +783,9 @@ void MediaPlayCtrl::media_proc()
|
||||
break;
|
||||
}
|
||||
else if (url == "<play>") {
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: start play";
|
||||
m_media_ctrl->Play();
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: end play";
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: start load";
|
||||
@@ -901,25 +915,19 @@ static int SecondsSinceLastInput()
|
||||
|
||||
}}
|
||||
|
||||
void wxMediaCtrl2::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
void wxMediaCtrl_OnSize(wxWindow * ctrl, wxSize const & videoSize, int width, int height)
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
wxWindow::DoSetSize(x, y, width, height, sizeFlags);
|
||||
#else
|
||||
wxMediaCtrl::DoSetSize(x, y, width, height, sizeFlags);
|
||||
#endif
|
||||
if (sizeFlags & wxSIZE_USE_EXISTING) return;
|
||||
wxSize size = m_video_size;
|
||||
wxSize size = videoSize;
|
||||
if (!size.IsFullySpecified()) size = {16, 9};
|
||||
int maxHeight = (width * size.GetHeight() + size.GetHeight() - 1) / size.GetWidth();
|
||||
if (maxHeight != GetMaxHeight()) {
|
||||
// BOOST_LOG_TRIVIAL(info) << "wxMediaCtrl2::DoSetSize: width: " << width << ", height: " << height << ", maxHeight: " << maxHeight;
|
||||
SetMaxSize({-1, maxHeight});
|
||||
CallAfter([this] {
|
||||
if (auto p = GetParent()) {
|
||||
if (maxHeight != ctrl->GetMaxHeight()) {
|
||||
// BOOST_LOG_TRIVIAL(info) << "wxMediaCtrl_OnSize: width: " << width << ", height: " << height << ", maxHeight: " << maxHeight;
|
||||
ctrl->SetMaxSize({-1, maxHeight});
|
||||
ctrl->CallAfter([ctrl] {
|
||||
if (auto p = ctrl->GetParent()) {
|
||||
p->Layout();
|
||||
p->Refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user