OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::ThermalPreconditioningDialog Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/ThermalPreconditioningDialog.hpp>

Inheritance diagram for Slic3r::GUI::ThermalPreconditioningDialog:
Collaboration diagram for Slic3r::GUI::ThermalPreconditioningDialog:

Public Member Functions

 ThermalPreconditioningDialog (wxWindow *parent, std::string dev_id, const wxString &remaining_time)
 ~ThermalPreconditioningDialog ()
void update_thermal_remaining_time ()

Private Member Functions

void create_ui ()
void on_ok_clicked (wxCommandEvent &event)
void on_timer (wxTimerEvent &event)

Private Attributes

std::string m_dev_id
wxTimer * m_refresh_timer
wxStaticText * m_remaining_time_label
wxStaticText * m_explanation_label
wxButton * m_ok_button

Detailed Description

Constructor & Destructor Documentation

◆ ThermalPreconditioningDialog()

Slic3r::GUI::ThermalPreconditioningDialog::ThermalPreconditioningDialog ( wxWindow * parent,
std::string dev_id,
const wxString & remaining_time )
27 : wxDialog(parent, wxID_ANY, _L("Thermal Preconditioning for first layer optimization"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
28 , m_dev_id(dev_id)
29{
30 // Apply dark-mode-friendly background for the dialog
31 SetBackgroundColour(StateColor::darkModeColorFor(wxColour(255, 255, 255)));
32 create_ui();
33 m_refresh_timer = new wxTimer(this);
34 this->Bind(wxEVT_TIMER, &ThermalPreconditioningDialog::on_timer, this);
35 m_refresh_timer->Start(1000);
36
37 // Set remaining time
38 m_remaining_time_label->SetLabelText(_L("Remaining time: Calculating..."));
39
40 Layout();
41 // Set dialog size and position
42 SetSize(wxSize(FromDIP(400), FromDIP(200)));
43 wxGetApp().UpdateDlgDarkUI(this);
44 CentreOnScreen();
45}
#define _L(s)
Definition OBJ.cpp:34
void on_timer(wxTimerEvent &event)
Definition ThermalPreconditioningDialog.cpp:117
wxStaticText * m_remaining_time_label
Definition ThermalPreconditioningDialog.hpp:41
void create_ui()
Definition ThermalPreconditioningDialog.cpp:56
wxTimer * m_refresh_timer
Definition ThermalPreconditioningDialog.hpp:40
std::string m_dev_id
Definition ThermalPreconditioningDialog.hpp:39
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References ThermalPreconditioningDialog(), _L, create_ui(), StateColor::darkModeColorFor(), m_dev_id, m_refresh_timer, m_remaining_time_label, and on_timer().

Referenced by ThermalPreconditioningDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~ThermalPreconditioningDialog()

Slic3r::GUI::ThermalPreconditioningDialog::~ThermalPreconditioningDialog ( )
48{
49 if (m_refresh_timer && m_refresh_timer->IsRunning()) {
50 m_refresh_timer->Stop();
51 delete m_refresh_timer;
52 m_refresh_timer = nullptr;
53 }
54}

References m_refresh_timer.

Member Function Documentation

◆ create_ui()

void Slic3r::GUI::ThermalPreconditioningDialog::create_ui ( )
private
57{
58 wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
59 // Remaining time label
60 m_remaining_time_label = new wxStaticText(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
61 wxFont time_font = m_remaining_time_label->GetFont();
62 time_font.SetPointSize(14);
63 time_font.SetWeight(wxFONTWEIGHT_BOLD);
64 m_remaining_time_label->SetFont(time_font);
65 m_remaining_time_label->SetForegroundColour(StateColor::darkModeColorFor(wxColour(50, 58, 61)));
66
67 // Explanation text
69 new wxStaticText(this, wxID_ANY,
70 _L("The heated bed's thermal preconditioning helps optimize the first layer print quality. Printing will start once preconditioning is complete."),
71 wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
72 m_explanation_label->Wrap(FromDIP(350));
73 m_explanation_label->SetForegroundColour(StateColor::darkModeColorFor(wxColour(50, 58, 61)));
74
75 m_ok_button = new wxButton(this, wxID_OK, _L("OK"));
76#ifdef __WXMAC__
77 m_ok_button->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
78 m_ok_button->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
79#else
80 m_ok_button->SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#B6F34F")));
81 m_ok_button->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#000000")));
82 m_ok_button->SetMinSize(wxSize(FromDIP(80), FromDIP(32)));
83 m_ok_button->SetMaxSize(wxSize(FromDIP(80), FromDIP(32)));
84#endif
85
86 // Layout
87 main_sizer->Add(0, 0, 1, wxEXPAND);
88 main_sizer->Add(m_remaining_time_label, 0, wxALIGN_CENTER);
89 main_sizer->Add(m_explanation_label, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(25));
90 main_sizer->Add(0, 0, 1, wxEXPAND);
91 main_sizer->Add(m_ok_button, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, FromDIP(20));
92
93 SetSizer(main_sizer);
94}
class WXDLLIMPEXP_FWD_CORE wxButton
Definition ProgressDialog.hpp:27
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
wxButton * m_ok_button
Definition ThermalPreconditioningDialog.hpp:43
wxStaticText * m_explanation_label
Definition ThermalPreconditioningDialog.hpp:42

References _L, StateColor::darkModeColorFor(), m_explanation_label, m_ok_button, m_remaining_time_label, wxButton, and wxStaticText.

Referenced by ThermalPreconditioningDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_ok_clicked()

void Slic3r::GUI::ThermalPreconditioningDialog::on_ok_clicked ( wxCommandEvent & event)
private
96{ EndModal(wxID_OK); }

◆ on_timer()

void Slic3r::GUI::ThermalPreconditioningDialog::on_timer ( wxTimerEvent & event)
private
117 {
118 DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
119 if (!dev) return;
120 MachineObject *m_obj = dev->get_my_machine(m_dev_id);
121
122 if (IsShown() && m_obj && m_obj->stage_curr == 58) {
124 } else {
125 m_refresh_timer->Stop();
126 }
127}
void update_thermal_remaining_time()
Definition ThermalPreconditioningDialog.cpp:98

References Slic3r::DeviceManager::get_my_machine(), m_dev_id, m_refresh_timer, Slic3r::MachineObject::stage_curr, and update_thermal_remaining_time().

Referenced by ThermalPreconditioningDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_thermal_remaining_time()

void Slic3r::GUI::ThermalPreconditioningDialog::update_thermal_remaining_time ( )
99{
100 DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
101 if (!dev) return;
102 MachineObject *m_obj = dev->get_my_machine(m_dev_id);
103
104 int remaining_seconds = m_obj->get_stage_remaining_seconds();
105 wxString remaining_time;
106 if (remaining_seconds >= 0) {
107 int minutes = remaining_seconds / 60;
108 int seconds = remaining_seconds % 60;
109 remaining_time = wxString::Format(_L("Remaining time: %dmin%ds"), minutes, seconds);
110 }
111
112 if (m_remaining_time_label) m_remaining_time_label->SetLabelText(remaining_time);
113
114 Layout();
115}

References _L, Slic3r::DeviceManager::get_my_machine(), Slic3r::MachineObject::get_stage_remaining_seconds(), m_dev_id, and m_remaining_time_label.

Referenced by on_timer().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_dev_id

std::string Slic3r::GUI::ThermalPreconditioningDialog::m_dev_id
private

◆ m_explanation_label

wxStaticText* Slic3r::GUI::ThermalPreconditioningDialog::m_explanation_label
private

Referenced by create_ui().

◆ m_ok_button

wxButton* Slic3r::GUI::ThermalPreconditioningDialog::m_ok_button
private

Referenced by create_ui().

◆ m_refresh_timer

wxTimer* Slic3r::GUI::ThermalPreconditioningDialog::m_refresh_timer
private

◆ m_remaining_time_label

wxStaticText* Slic3r::GUI::ThermalPreconditioningDialog::m_remaining_time_label
private

The documentation for this class was generated from the following files: