Files
OrcaSlicer/src/slic3r/GUI/BBLStatusBarBind.cpp
T
HanifKoh 4895bc03b4 Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced (#16099)
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced

Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes.

clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer.

* Remove Unused Project Includes From Files With Platform-Specific Code

A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block.

* Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass

The platform-file pass treated pchheader.hpp as an ordinary header and
emptied it, and left GUI_Preview.hpp and 14 other files relying on
headers they no longer reached directly.

* Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call

* Include Headers That Files Reached Through Ones the Cleanup Removed

* Drop Includes Duplicated by the Cleanup or by Main's Own Additions

* Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
2026-10-05 16:47:17 +08:00

221 lines
4.7 KiB
C++

#include "BBLStatusBarBind.hpp"
#include <wx/panel.h>
#include <wx/event.h>
#include <wx/sizer.h>
#include "slic3r/GUI/Widgets/Label.hpp"
#include <string>
#include <wx/timer.h>
#include <wx/gauge.h>
#include <wx/button.h>
#include <wx/statusbr.h>
#include <wx/frame.h>
#include "wx/evtloop.h"
#include <wx/gdicmn.h>
#include <iostream>
#include "slic3r/GUI/Widgets/Button.hpp"
namespace Slic3r {
BBLStatusBarBind::BBLStatusBarBind(wxWindow *parent, int id)
: m_self{new wxPanel(parent, id == -1 ? wxID_ANY : id)}
, m_sizer(new wxBoxSizer(wxHORIZONTAL))
{
m_self->SetBackgroundColour(wxColour(255,255,255));
m_self->SetMinSize(wxSize(m_self->FromDIP(450), m_self->FromDIP(30)));
m_prog = new wxGauge(m_self, wxID_ANY, 100, wxDefaultPosition, wxSize(m_self->FromDIP(400), m_self->FromDIP(6)), wxGA_HORIZONTAL);
m_prog->SetValue(0);
m_stext_percent = new wxStaticText(m_self, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0);
m_stext_percent->SetForegroundColour(wxColour(107, 107, 107));
m_stext_percent->SetFont(::Label::Body_13);
m_stext_percent->Wrap(-1);
m_sizer->Add(m_prog, 1, wxALIGN_CENTER, 0);
m_sizer->Add(0, 0, 1, wxEXPAND, 0);
m_sizer->Add(m_stext_percent, 1, wxALIGN_CENTER, 0);
m_self->SetSizer(m_sizer);
m_self->Layout();
m_sizer->Fit(m_self);
}
void BBLStatusBarBind::set_prog_block()
{
}
int BBLStatusBarBind::get_progress() const
{
return m_prog->GetValue();
}
void BBLStatusBarBind::set_progress(int val)
{
set_prog_block();
if(val < 0)
return;
if (!m_sizer->IsShown(m_prog)) {
m_sizer->Show(m_prog);
m_sizer->Show(m_cancelbutton);
}
m_prog->SetValue(val);
set_percent_text(wxString::Format("%d%%", val));
m_sizer->Layout();
}
int BBLStatusBarBind::get_range() const
{
return m_prog->GetRange();
}
void BBLStatusBarBind::set_range(int val)
{
if(val != m_prog->GetRange()) {
m_prog->SetRange(val);
}
}
void BBLStatusBarBind::clear_percent()
{
}
void BBLStatusBarBind::show_error_info(wxString msg, int code, wxString description, wxString extra)
{
}
void BBLStatusBarBind::show_progress(bool show)
{
if (show) {
m_sizer->Show(m_prog);
m_sizer->Layout();
}
else {
//m_sizer->Hide(m_prog);
m_sizer->Layout();
}
}
void BBLStatusBarBind::start_busy(int rate)
{
m_busy = true;
show_progress(true);
show_cancel_button();
}
void BBLStatusBarBind::stop_busy()
{
show_progress(false);
hide_cancel_button();
m_prog->SetValue(0);
m_sizer->Layout();
m_busy = false;
}
void BBLStatusBarBind::set_cancel_callback_fina(BBLStatusBarBind::CancelFn ccb)
{
m_cancel_cb_fina = ccb;
if (ccb) {
m_sizer->Show(m_cancelbutton);
} else {
m_sizer->Hide(m_cancelbutton);
}
}
void BBLStatusBarBind::set_cancel_callback(BBLStatusBarBind::CancelFn ccb) {
/* m_cancel_cb = ccb;
if (ccb) {
m_sizer->Show(m_cancelbutton);
}
else {
m_sizer->Hide(m_cancelbutton);
}
m_sizer->Layout();*/
}
wxPanel* BBLStatusBarBind::get_panel()
{
return m_self;
}
void BBLStatusBarBind::set_status_text(const wxString& txt)
{
//auto txtss = "Sending the printing task has timed out.\nPlease try again!";
//auto txtss = "The printing project is being uploaded... 25%%";
//m_status_text->SetLabelText(txtss);
//m_status_text->SetLabelText(txt);
}
void BBLStatusBarBind::set_percent_text(const wxString &txt)
{
m_stext_percent->SetLabelText(txt);
}
void BBLStatusBarBind::set_status_text(const std::string& txt)
{
this->set_status_text(txt.c_str());
}
void BBLStatusBarBind::set_status_text(const char *txt)
{
this->set_status_text(wxString::FromUTF8(txt));
}
void BBLStatusBarBind::msw_rescale() {
set_prog_block();
m_cancelbutton->SetMinSize(wxSize(m_self->FromDIP(56), m_self->FromDIP(24)));
}
wxString BBLStatusBarBind::get_status_text() const
{
return m_status_text->GetLabelText();
}
bool BBLStatusBarBind::update_status(wxString &msg, bool &was_cancel, int percent, bool yield)
{
set_status_text(msg);
if (percent >= 0)
this->set_progress(percent);
if (yield)
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI | wxEVT_CATEGORY_USER_INPUT);
was_cancel = m_was_cancelled;
return true;
}
void BBLStatusBarBind::reset()
{
set_status_text("");
m_was_cancelled = false;
set_progress(0);
}
void BBLStatusBarBind::set_font(const wxFont &font)
{
m_self->SetFont(font);
}
void BBLStatusBarBind::show_cancel_button()
{
m_sizer->Show(m_cancelbutton);
m_sizer->Layout();
}
void BBLStatusBarBind::hide_cancel_button()
{
m_sizer->Hide(m_cancelbutton);
m_sizer->Layout();
}
}