mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00

Signed-off-by: SoftFever <softfeverever@gmail.com> # Conflicts: # bbl/i18n/BambuStudio.pot # bbl/i18n/de/BambuStudio_de.po # bbl/i18n/en/BambuStudio_en.po # bbl/i18n/es/BambuStudio_es.po # bbl/i18n/fr/BambuStudio_fr.po # bbl/i18n/hu/BambuStudio_hu.po # bbl/i18n/it/BambuStudio_it.po # bbl/i18n/nl/BambuStudio_nl.po # bbl/i18n/sv/BambuStudio_sv.po # bbl/i18n/zh_cn/BambuStudio_zh_CN.po # deps/Boost/Boost.cmake # deps/wxWidgets/wxWidgets.cmake # resources/config.json # resources/i18n/de/BambuStudio.mo # resources/i18n/en/BambuStudio.mo # resources/i18n/es/BambuStudio.mo # resources/i18n/fr/BambuStudio.mo # resources/i18n/hu/BambuStudio.mo # resources/i18n/it/BambuStudio.mo # resources/i18n/nl/BambuStudio.mo # resources/i18n/sv/BambuStudio.mo # resources/i18n/zh_cn/BambuStudio.mo # resources/images/tips_arrow.svg # resources/profiles/Anycubic.json # resources/profiles/Anycubic/filament/Anycubic Generic ABS.json # resources/profiles/Anycubic/filament/Anycubic Generic ASA.json # resources/profiles/Anycubic/filament/Anycubic Generic PA-CF.json # resources/profiles/Anycubic/filament/Anycubic Generic PA.json # resources/profiles/Anycubic/filament/Anycubic Generic PC.json # resources/profiles/Anycubic/filament/Anycubic Generic PETG.json # resources/profiles/Anycubic/filament/Anycubic Generic PLA-CF.json # resources/profiles/Anycubic/filament/Anycubic Generic PLA.json # resources/profiles/Anycubic/filament/Anycubic Generic PVA.json # resources/profiles/Anycubic/filament/Anycubic Generic TPU.json # resources/profiles/Anycubic/filament/fdm_filament_common.json # resources/profiles/Anycubic/machine/Anycubic 4Max Pro 0.4 nozzle.json # resources/profiles/Anycubic/machine/Anycubic 4Max Pro.json # resources/profiles/Anycubic/process/0.20mm Standard @4MaxPro.json # resources/profiles/Anycubic/process/fdm_process_common.json # resources/profiles/BBL.json # resources/profiles/BBL/machine/Bambu Lab P1P 0.2 nozzle.json # resources/profiles/BBL/machine/Bambu Lab P1P 0.4 nozzle.json # resources/profiles/BBL/machine/Bambu Lab P1P 0.6 nozzle.json # resources/profiles/BBL/machine/Bambu Lab P1P 0.8 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 0.2 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 0.4 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 0.6 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 0.8 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.2 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.4 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.6 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.8 nozzle.json # resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json # resources/profiles/Voron.json # resources/web/data/text.js # resources/web/image/printer/Anycubic 4Max Pro_cover.png # src/BambuStudio.cpp # src/libslic3r/GCode.cpp # src/libslic3r/GCode.hpp # src/libslic3r/GCode/GCodeProcessor.cpp # src/libslic3r/GCodeWriter.hpp # src/libslic3r/PerimeterGenerator.cpp # src/libslic3r/PresetBundle.cpp # src/libslic3r/Print.cpp # src/libslic3r/Print.hpp # src/libslic3r/PrintConfig.cpp # src/libslic3r/PrintConfig.hpp # src/libslic3r/PrintObject.cpp # src/slic3r/GUI/AMSMaterialsSetting.cpp # src/slic3r/GUI/AMSMaterialsSetting.hpp # src/slic3r/GUI/AmsMappingPopup.cpp # src/slic3r/GUI/AmsMappingPopup.hpp # src/slic3r/GUI/Auxiliary.cpp # src/slic3r/GUI/BackgroundSlicingProcess.cpp # src/slic3r/GUI/ConfigManipulation.cpp # src/slic3r/GUI/DeviceManager.cpp # src/slic3r/GUI/DeviceManager.hpp # src/slic3r/GUI/ExtrusionCalibration.cpp # src/slic3r/GUI/GCodeViewer.cpp # src/slic3r/GUI/GCodeViewer.hpp # src/slic3r/GUI/GUI_App.cpp # src/slic3r/GUI/IMSlider.cpp # src/slic3r/GUI/Jobs/PrintJob.cpp # src/slic3r/GUI/Jobs/PrintJob.hpp # src/slic3r/GUI/Jobs/SendJob.cpp # src/slic3r/GUI/Jobs/SendJob.hpp # src/slic3r/GUI/MainFrame.cpp # src/slic3r/GUI/MainFrame.hpp # src/slic3r/GUI/MediaPlayCtrl.cpp # src/slic3r/GUI/OptionsGroup.cpp # src/slic3r/GUI/PhysicalPrinterDialog.cpp # src/slic3r/GUI/Plater.cpp # src/slic3r/GUI/PrintHostDialogs.cpp # src/slic3r/GUI/Printer/BambuTunnel.h # src/slic3r/GUI/Printer/PrinterFileSystem.cpp # src/slic3r/GUI/Printer/gstbambusrc.c # src/slic3r/GUI/Printer/gstbambusrc.h # src/slic3r/GUI/ReleaseNote.cpp # src/slic3r/GUI/ReleaseNote.hpp # src/slic3r/GUI/SelectMachine.cpp # src/slic3r/GUI/SendToPrinter.cpp # src/slic3r/GUI/SetBedTypeDialog.cpp # src/slic3r/GUI/StatusPanel.cpp # src/slic3r/GUI/StatusPanel.hpp # src/slic3r/GUI/Tab.cpp # src/slic3r/GUI/Widgets/AMSControl.cpp # src/slic3r/GUI/Widgets/AMSControl.hpp # src/slic3r/GUI/Widgets/ImageSwitchButton.cpp # src/slic3r/GUI/Widgets/Label.cpp # src/slic3r/GUI/WipeTowerDialog.cpp # src/slic3r/Utils/Process.cpp # src/slic3r/Utils/bambu_networking.hpp # version.inc
191 lines
No EOL
6.5 KiB
C++
191 lines
No EOL
6.5 KiB
C++
#include "RecenterDialog.hpp"
|
|
#include "GUI_App.hpp"
|
|
#include <slic3r/GUI/I18N.hpp>
|
|
#include <wx/dcgraph.h>
|
|
#include <wx/dcmemory.h>
|
|
#include <slic3r/GUI/Widgets/Label.hpp>
|
|
|
|
#define BORDER FromDIP(25)
|
|
#define DRAW_PANEL_SIZE wxSize(FromDIP(475), FromDIP(100))
|
|
|
|
const wxColour text_color(107, 107, 107);
|
|
|
|
namespace Slic3r { namespace GUI {
|
|
RecenterDialog::RecenterDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
|
|
: DPIDialog(parent, id, _L("Confirm"), pos, size, style)
|
|
{
|
|
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
|
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
|
|
|
hint1 = _L("Please home all axes (click ");
|
|
hint2 = _L(") to locate the toolhead's position. This prevents device moving beyond the printable boundary and causing equipment wear.");
|
|
|
|
init_bitmap();
|
|
|
|
SetBackgroundColour(*wxWHITE);
|
|
|
|
auto* main_sizer = new wxBoxSizer(wxVERTICAL);
|
|
auto* button_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
wxPanel* m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
|
|
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
|
|
|
m_button_confirm = new Button(this, _L("Go Home"));
|
|
m_button_confirm->SetFont(Label::Body_14);
|
|
m_button_confirm->SetMinSize(wxSize(-1, FromDIP(24)));
|
|
m_button_confirm->SetCornerRadius(FromDIP(12));
|
|
StateColor confirm_btn_bg(std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
|
|
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
|
|
m_button_confirm->SetBackgroundColor(confirm_btn_bg);
|
|
m_button_confirm->SetBorderColor(wxColour(0, 150, 136));
|
|
m_button_confirm->SetTextColor(*wxWHITE);
|
|
|
|
m_button_close = new Button(this, _L("Close"));
|
|
m_button_close->SetFont(Label::Body_14);
|
|
m_button_close->SetMinSize(wxSize(-1, FromDIP(24)));
|
|
m_button_close->SetCornerRadius(FromDIP(12));
|
|
StateColor close_btn_bg(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Hovered),
|
|
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
|
|
m_button_close->SetBackgroundColor(close_btn_bg);
|
|
m_button_close->SetBorderColor(wxColour(38, 46, 48));
|
|
m_button_close->SetTextColor(wxColour(38, 46, 48));
|
|
|
|
button_sizer->AddStretchSpacer();
|
|
button_sizer->Add(m_button_confirm);
|
|
button_sizer->AddSpacer(FromDIP(20));
|
|
button_sizer->Add(m_button_close);
|
|
|
|
main_sizer->Add(m_line_top, 0, wxEXPAND, 0);
|
|
main_sizer->AddSpacer(DRAW_PANEL_SIZE.y);
|
|
main_sizer->Add(button_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND, BORDER);
|
|
|
|
SetSizer(main_sizer);
|
|
|
|
CenterOnParent();
|
|
|
|
this->SetSize(wxSize(DRAW_PANEL_SIZE.x, -1));
|
|
this->SetMinSize(wxSize(DRAW_PANEL_SIZE.x, -1));
|
|
Layout();
|
|
Fit();
|
|
this->Bind(wxEVT_PAINT, &RecenterDialog::OnPaint, this);
|
|
m_button_confirm->Bind(wxEVT_BUTTON, &RecenterDialog::on_button_confirm, this);
|
|
m_button_close->Bind(wxEVT_BUTTON, &RecenterDialog::on_button_close, this);
|
|
|
|
wxGetApp().UpdateDlgDarkUI(this);
|
|
}
|
|
|
|
RecenterDialog::~RecenterDialog() {}
|
|
|
|
void RecenterDialog::init_bitmap() {
|
|
m_home_bmp = ScalableBitmap(this, "monitor_axis_home_icon", 24);
|
|
}
|
|
|
|
void RecenterDialog::OnPaint(wxPaintEvent& event){
|
|
wxPaintDC dc(this);
|
|
render(dc);
|
|
}
|
|
|
|
void RecenterDialog::render(wxDC& dc) {
|
|
wxSize size = GetSize();
|
|
|
|
dc.SetFont(Label::Body_14);
|
|
dc.SetTextForeground(text_color);
|
|
wxPoint pos_start = wxPoint(BORDER, BORDER);
|
|
|
|
wxSize hint1_size = dc.GetTextExtent(hint1);
|
|
wxPoint pos_hint1 = pos_start;
|
|
pos_hint1.y += (m_home_bmp.GetBmpWidth() - hint1_size.y) / 2;
|
|
dc.DrawText(hint1, pos_hint1);
|
|
|
|
wxPoint pos_bmp = pos_start;
|
|
pos_bmp.x += hint1_size.x;
|
|
dc.DrawBitmap(m_home_bmp.bmp(), pos_bmp);
|
|
|
|
wxSize hint2_size = dc.GetTextExtent(hint2);
|
|
wxPoint pos_hint2 = pos_hint1;
|
|
pos_hint2.x = pos_hint2.x + hint1_size.x + m_home_bmp.GetBmpWidth();
|
|
|
|
if (hint2_size.x + pos_hint2.x + BORDER > DRAW_PANEL_SIZE.x) {
|
|
bool is_ch = false;
|
|
if (hint2[0] > 0x80 && hint2[1] > 0x80)
|
|
is_ch = true;
|
|
|
|
wxString fisrt_line;
|
|
wxString remaining_line;
|
|
|
|
wxString count_txt;
|
|
int new_line_pos = 0;
|
|
for (int i = 0; i < hint2.length(); i++) {
|
|
count_txt += hint2[i];
|
|
auto text_size = dc.GetTextExtent(count_txt);
|
|
if (text_size.x + pos_hint2.x + BORDER < DRAW_PANEL_SIZE.x)
|
|
{
|
|
if (hint2[i] == ' ' || hint2[i] == '\n')
|
|
new_line_pos = i;
|
|
}
|
|
else {
|
|
if (!is_ch) {
|
|
fisrt_line = hint2.SubString(0, new_line_pos);
|
|
remaining_line = hint2.SubString(new_line_pos + 1, hint2.length());
|
|
break;
|
|
}
|
|
else {
|
|
fisrt_line = hint2.SubString(0, i - 1);
|
|
remaining_line = hint2.SubString(i, hint2.length());
|
|
break;
|
|
}
|
|
count_txt = "";
|
|
}
|
|
}
|
|
dc.DrawText(fisrt_line, pos_hint2);
|
|
|
|
|
|
count_txt = "";
|
|
new_line_pos = 0;
|
|
for (int i = 0; i < remaining_line.length(); i++) {
|
|
count_txt += remaining_line[i];
|
|
auto text_size = dc.GetTextExtent(count_txt);
|
|
if (text_size.x + BORDER + BORDER < DRAW_PANEL_SIZE.x)
|
|
{
|
|
if (remaining_line[i] == ' ' || remaining_line[i] == '\n')
|
|
new_line_pos = i;
|
|
}
|
|
else {
|
|
if (!is_ch){
|
|
remaining_line[new_line_pos] = '\n';
|
|
}
|
|
else {
|
|
remaining_line.insert(i, '\n');
|
|
}
|
|
count_txt = "";
|
|
}
|
|
}
|
|
wxPoint pos_txt = pos_hint1;
|
|
pos_txt.y += dc.GetCharHeight();
|
|
dc.DrawText(remaining_line, pos_txt);
|
|
}
|
|
else
|
|
dc.DrawText(hint2, pos_hint2);
|
|
}
|
|
|
|
void RecenterDialog::on_button_confirm(wxCommandEvent& event) {
|
|
if (this->IsModal())
|
|
this->EndModal(wxID_OK);
|
|
else
|
|
this->Close();
|
|
}
|
|
|
|
void RecenterDialog::on_button_close(wxCommandEvent& event) {
|
|
this->Close();
|
|
}
|
|
|
|
void RecenterDialog::on_dpi_changed(const wxRect& suggested_rect) {
|
|
init_bitmap();
|
|
m_button_confirm->SetMinSize(wxSize(-1, FromDIP(24)));
|
|
m_button_confirm->SetCornerRadius(FromDIP(12));
|
|
m_button_close->SetMinSize(wxSize(-1, FromDIP(24)));
|
|
m_button_close->SetCornerRadius(FromDIP(12));
|
|
Layout();
|
|
}
|
|
|
|
}} // namespace Slic3r::GUI
|