mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 09:02:06 +00:00
ENH:Optimization of File Transfer System Part2
jira: [STUDIO-11777] Change-Id: I12744db7d2e3b53425454d632533768c54524677 (cherry picked from commit 4358e9ce351c5784e392a75d1ffcf2f54e1916ec)
This commit is contained in:
@@ -4,6 +4,8 @@ project(libslic3r_gui)
|
||||
include(PrecompiledHeader)
|
||||
|
||||
set(SLIC3R_GUI_SOURCES
|
||||
GUI/Widgets/AnimaController.hpp
|
||||
GUI/Widgets/AnimaController.cpp
|
||||
Config/Snapshot.cpp
|
||||
Config/Snapshot.hpp
|
||||
Config/Version.cpp
|
||||
|
||||
@@ -872,7 +872,7 @@ public:
|
||||
bool is_support_agora{false};
|
||||
bool is_support_upgrade_kit{false};
|
||||
bool is_support_command_homing { false };// fun[32]
|
||||
bool is_support_brtc { false }; // fun[31], support tcp and upload protocol
|
||||
bool is_support_brtc{false}; // fun[31], support tcp and upload protocol
|
||||
|
||||
bool installed_upgrade_kit{false};
|
||||
int nozzle_max_temperature = -1;
|
||||
|
||||
@@ -1245,9 +1245,9 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
|
||||
while (m_stopped) {
|
||||
if (m_session.owner == nullptr)
|
||||
return;
|
||||
m_status = Status::Stopped;
|
||||
SendChangedEvent(EVT_STATUS_CHANGED, m_status);
|
||||
m_cond.wait(l);
|
||||
m_status = Status::Reconnecting;
|
||||
SendChangedEvent(EVT_STATUS_CHANGED, m_status);
|
||||
m_cond.wait(l);
|
||||
}
|
||||
wxLogMessage("PrinterFileSystem::Reconnect Initializing");
|
||||
m_status = Status::Initializing;
|
||||
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
ListSyncing,
|
||||
ListReady,
|
||||
Failed,
|
||||
Stopped,
|
||||
Reconnecting,
|
||||
};
|
||||
|
||||
Status GetStatus() const { return m_status; }
|
||||
|
||||
77
src/slic3r/GUI/Widgets/AnimaController.cpp
Normal file
77
src/slic3r/GUI/Widgets/AnimaController.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "AnimaController.hpp"
|
||||
|
||||
#include <wx/dcclient.h>
|
||||
#include <wx/dcgraph.h>
|
||||
#ifdef __APPLE__
|
||||
#include "libslic3r/MacUtils.hpp"
|
||||
#endif
|
||||
|
||||
AnimaIcon::AnimaIcon(wxWindow *parent, wxWindowID id, std::vector<std::string> img_list, std::string img_enable, int ivt)
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize), m_ivt(ivt)
|
||||
{
|
||||
SetBackgroundColour((wxColour(255, 255, 255)));
|
||||
m_size = 20;
|
||||
|
||||
//add ScalableBitmap
|
||||
for (const auto &filename : img_list) m_images.emplace_back(create_scaled_bitmap(filename, this, m_size));
|
||||
m_image_enable = create_scaled_bitmap(img_enable, this, m_size-8);
|
||||
|
||||
// show first wxStaticBitmap
|
||||
if (!m_images.empty()) m_bitmap = new wxStaticBitmap(this, wxID_ANY, m_images[0], wxDefaultPosition, wxSize(FromDIP(m_size), FromDIP(m_size)));
|
||||
|
||||
|
||||
m_timer = new wxTimer();
|
||||
m_timer->SetOwner(this);
|
||||
|
||||
Bind(wxEVT_TIMER, [this](wxTimerEvent &) {
|
||||
if (m_timer->IsRunning() && !m_images.empty()) {
|
||||
m_current_frame = (m_current_frame + 1) % 4;
|
||||
m_bitmap->SetBitmap(m_images[m_current_frame]);
|
||||
}
|
||||
});
|
||||
|
||||
m_bitmap->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
|
||||
wxMouseEvent evt(wxEVT_LEFT_DOWN);
|
||||
evt.SetEventObject(this);
|
||||
wxPostEvent(this, evt);
|
||||
});
|
||||
|
||||
m_bitmap->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
|
||||
if (!m_timer->IsRunning())
|
||||
SetCursor(wxCursor(wxCURSOR_HAND));
|
||||
else
|
||||
SetCursor(wxCursor(wxCURSOR_ARROW));
|
||||
e.Skip();
|
||||
});
|
||||
m_bitmap->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
|
||||
SetCursor(wxCursor(wxCURSOR_ARROW));
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
SetSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
|
||||
SetMaxSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
|
||||
SetMinSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
|
||||
Refresh();
|
||||
|
||||
Play();
|
||||
}
|
||||
|
||||
|
||||
void AnimaIcon::Play()
|
||||
{
|
||||
if (true)
|
||||
m_timer->Start(m_ivt);
|
||||
|
||||
}
|
||||
|
||||
void AnimaIcon::Stop()
|
||||
{
|
||||
m_timer->Stop();
|
||||
}
|
||||
|
||||
void AnimaIcon::Enable()
|
||||
{
|
||||
if (m_bitmap) { m_bitmap->SetBitmap(m_image_enable); }
|
||||
}
|
||||
|
||||
|
||||
28
src/slic3r/GUI/Widgets/AnimaController.hpp
Normal file
28
src/slic3r/GUI/Widgets/AnimaController.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef slic3r_GUI_AnimaController_hpp_
|
||||
#define slic3r_GUI_AnimaController_hpp_
|
||||
|
||||
#include "../wxExtensions.hpp"
|
||||
#include "Label.hpp"
|
||||
|
||||
|
||||
class AnimaIcon : public wxPanel
|
||||
{
|
||||
public:
|
||||
AnimaIcon(wxWindow *parent, wxWindowID id, std::vector<std::string> img_list, std::string img_enable, int ivt = 1000);
|
||||
|
||||
void Play();
|
||||
void Stop();
|
||||
void Enable();
|
||||
bool IsRunning() const;
|
||||
|
||||
private:
|
||||
wxBitmap m_image_enable;
|
||||
wxStaticBitmap * m_bitmap{nullptr};
|
||||
std::vector<wxBitmap> m_images;
|
||||
wxTimer * m_timer;
|
||||
int m_current_frame = 0;
|
||||
int m_ivt;
|
||||
int m_size;
|
||||
};
|
||||
|
||||
#endif // !slic3r_GUI_AnimaController_hpp_
|
||||
@@ -15,7 +15,7 @@ ProgressBar::ProgressBar(wxWindow *parent, wxWindowID id, int max, const wxPoint
|
||||
{
|
||||
m_shownumber = shown;
|
||||
SetBackgroundColour(wxColour(255,255,255));
|
||||
|
||||
|
||||
if (size.y >= miniHeight) {
|
||||
m_miniHeight = size.y;
|
||||
} else {
|
||||
@@ -64,20 +64,20 @@ void ProgressBar::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, w
|
||||
}
|
||||
|
||||
|
||||
void ProgressBar::SetRadius(double radius) {
|
||||
void ProgressBar::SetRadius(double radius) {
|
||||
m_radius = radius;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ProgressBar::SetProgressForedColour(wxColour colour)
|
||||
void ProgressBar::SetProgressForedColour(wxColour colour)
|
||||
{
|
||||
m_progress_background_colour = colour;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ProgressBar::SetProgressBackgroundColour(wxColour colour)
|
||||
{
|
||||
m_progress_colour = colour;
|
||||
void ProgressBar::SetProgressBackgroundColour(wxColour colour)
|
||||
{
|
||||
m_progress_colour = colour;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
@@ -86,29 +86,29 @@ void ProgressBar::Rescale()
|
||||
;
|
||||
}
|
||||
|
||||
void ProgressBar::ShowNumber(bool shown)
|
||||
void ProgressBar::ShowNumber(bool shown)
|
||||
{
|
||||
m_shownumber = shown;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ProgressBar::Disable(wxString text)
|
||||
{
|
||||
void ProgressBar::Disable(wxString text)
|
||||
{
|
||||
if (m_disable) return;
|
||||
m_disable_text = text;
|
||||
m_disable = true;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ProgressBar::SetValue(int step)
|
||||
{
|
||||
void ProgressBar::SetValue(int step)
|
||||
{
|
||||
m_disable = false;
|
||||
SetProgress(step);
|
||||
}
|
||||
|
||||
void ProgressBar::Reset()
|
||||
{
|
||||
m_step = 0;
|
||||
void ProgressBar::Reset()
|
||||
{
|
||||
m_step = 0;
|
||||
SetValue(0);
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@ void ProgressBar::SetProgress(int step)
|
||||
}
|
||||
|
||||
|
||||
void ProgressBar::SetMinSize(const wxSize &size)
|
||||
{
|
||||
if (size.y >= miniHeight) {
|
||||
void ProgressBar::SetMinSize(const wxSize &size)
|
||||
{
|
||||
if (size.y >= miniHeight) {
|
||||
m_miniHeight = size.y;
|
||||
} else {
|
||||
return;
|
||||
@@ -177,7 +177,7 @@ void ProgressBar::doRender(wxDC &dc)
|
||||
dc.DrawRoundedRectangle(0, 0, size.x, size.y, m_radius);
|
||||
}
|
||||
|
||||
//draw progress
|
||||
//draw progress
|
||||
if (m_disable) {
|
||||
m_proportion = float(size.x * float(this->m_step) / float(this->m_max));
|
||||
if (m_proportion < m_radius * 2 && m_proportion != 0) { m_proportion = m_radius * 2; }
|
||||
@@ -228,11 +228,11 @@ void ProgressBar::doRender(wxDC &dc)
|
||||
dc.DrawText(text + wxString("%"), pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ProgressBar::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
void ProgressBar::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
wxWindow::DoSetSize(x, y, width, height, sizeFlags);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user