mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
ENH:Add thermal precondition
jira:[STUDIO-13970][STUDIO-13904] Change-Id: I4b4fa27da1a65e0019c5f4c1dcc099c92189bf50 (cherry picked from commit 92dbde8385fec9719e0e9cfde764421793decd4d)
This commit is contained in:
106
src/slic3r/GUI/ThermalPreconditioningDialog.cpp
Normal file
106
src/slic3r/GUI/ThermalPreconditioningDialog.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
#include "ThermalPreconditioningDialog.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "DeviceManager.hpp"
|
||||
#include "DeviceCore/DevManager.h"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
BEGIN_EVENT_TABLE(ThermalPreconditioningDialog, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, ThermalPreconditioningDialog::on_ok_clicked)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
ThermalPreconditioningDialog::ThermalPreconditioningDialog(wxWindow* parent, std::string dev_id,const wxString& remaining_time)
|
||||
: wxDialog(parent, wxID_ANY, _L("Thermal Preconditioning for first layer optimization"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
, m_dev_id(dev_id)
|
||||
, m_refresh_timer(this)
|
||||
{
|
||||
wxBitmap bitmap = create_scaled_bitmap("thermal_preconditioning_title", this, 16);
|
||||
wxIcon icon;
|
||||
icon.CopyFromBitmap(bitmap);
|
||||
SetIcon(icon);
|
||||
create_ui();
|
||||
|
||||
Bind(wxEVT_TIMER, &ThermalPreconditioningDialog::on_timer, this);
|
||||
m_refresh_timer.Start(1000);
|
||||
|
||||
// Set remaining time
|
||||
if (!remaining_time.IsEmpty()) {
|
||||
m_remaining_time_label->SetLabelText(wxString::Format(_L("Remaining time: %s"), remaining_time));
|
||||
} else {
|
||||
m_remaining_time_label->SetLabelText(_L("Remaining time: Calculating..."));
|
||||
}
|
||||
|
||||
// Set dialog size and position
|
||||
SetSize(wxSize(FromDIP(400), FromDIP(200)));
|
||||
CentreOnScreen();
|
||||
}
|
||||
|
||||
void ThermalPreconditioningDialog::create_ui()
|
||||
{
|
||||
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
// Remaining time label
|
||||
m_remaining_time_label = new wxStaticText(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
|
||||
wxFont time_font = m_remaining_time_label->GetFont();
|
||||
time_font.SetPointSize(14);
|
||||
time_font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
m_remaining_time_label->SetFont(time_font);
|
||||
m_remaining_time_label->SetForegroundColour(wxColour(50, 58, 61));
|
||||
// Explanation text
|
||||
m_explanation_label = new wxStaticText(this, wxID_ANY,
|
||||
_L("The heated bed's thermal preconditioning helps optimize the first layer print quality. Printing will start once preconditioning is complete."),
|
||||
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
|
||||
m_explanation_label->Wrap(FromDIP(350));
|
||||
m_explanation_label->SetForegroundColour(wxColour(50, 58, 61));
|
||||
|
||||
// OK button
|
||||
m_ok_button = new wxButton(this, wxID_OK, _L("OK"));
|
||||
m_ok_button->SetBackgroundColour(wxColour("#B6F34F"));
|
||||
m_ok_button->SetForegroundColour(wxColour("#000000"));
|
||||
m_ok_button->SetMinSize(wxSize(FromDIP(80), FromDIP(32)));
|
||||
|
||||
// Layout
|
||||
main_sizer->Add(0, 0, 1, wxEXPAND);
|
||||
main_sizer->Add(m_remaining_time_label, 0, wxALIGN_CENTER);
|
||||
main_sizer->Add(m_explanation_label, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(25));
|
||||
main_sizer->Add(0, 0, 1, wxEXPAND);
|
||||
main_sizer->Add(m_ok_button, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, FromDIP(20));
|
||||
|
||||
SetSizer(main_sizer);
|
||||
}
|
||||
|
||||
void ThermalPreconditioningDialog::on_ok_clicked(wxCommandEvent& event)
|
||||
{
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
void ThermalPreconditioningDialog::update_thermal_remaining_time()
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return;
|
||||
MachineObject * m_obj = dev->get_my_machine(m_dev_id);
|
||||
|
||||
int remaining_seconds = m_obj->get_stage_remaining_seconds();
|
||||
wxString remaining_time;
|
||||
if (remaining_seconds >= 0) {
|
||||
int minutes = remaining_seconds/60;
|
||||
int seconds = remaining_seconds % 60;
|
||||
remaining_time = wxString::Format("Remaining time: %dmin%ds", minutes, seconds);
|
||||
}
|
||||
set_remaining_time_text(remaining_time);
|
||||
}
|
||||
|
||||
void ThermalPreconditioningDialog::on_timer(wxTimerEvent &event) {
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return;
|
||||
MachineObject *m_obj = dev->get_my_machine(m_dev_id);
|
||||
|
||||
if (IsShown() && m_obj && m_obj->stage_curr == 58) {
|
||||
update_thermal_remaining_time();
|
||||
} else {
|
||||
m_refresh_timer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
Reference in New Issue
Block a user