mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-06 22:47:32 -06:00
Update wxWidgets to v3.2.1 (#2905)
* Upgrade wxWidgets to 3.2.1
Based on prusa3d/PrusaSlicer@9a7e024
Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>
* Implement BitmapCache
* update wxExtensions while keeping legacy items
* update dc.DrawBitmap calls to use get_bitmap
* Fix GetSize/Width/Height calls
* update BitmapComboBox
* fix ifndef in wxExtensions.hpp
* update my todos to OcraftyoneTODO
* Get to a compilable state
Everything seems to be working (including the plater). I am not seeing any graphical issues
* fix extruder color icons
* fix crash on opening support tab
* remove GetBmpSize method from DropDown.cpp
* Update TextInput to use bitmap bundles
* update a TODO after testing
* fix the rendering of the icons on combobox
* fix a few todos
* fix WipeTowerDialog.cpp
* Overhaul WipeTowerDialog
Removed simple version of the dialog since BBS removed the functionality but left the code.
Center the table (only seen when the table is smaller than the minimum size of the dialog)
Fix issue where editing a value causes the m_min_flush_label to change colors slightly
Fix an issue where changing a value or running an auto calc changes the disabled value from "-" to "0"
* update a few todos
* Update some todos
* Show dropdown when editing is started
* Update NanoSVG.cmake
Update NanoSVG to work with PR #2780
* Dim the icon on ComboBox when disabled
* solve ObjectDataViewModel todos
leaving colPrint and colEditing cases alone as it does not seem to impact anything
* Update names in wxExtensions
-Rename msw_rescale to sys_color_changed
-Replace GetBmpSize, GetBmpWidth, GetBmpHeight with renamed version (same name without "Bmp")
Both of these changes were also made by PrusaSlicer.
Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>
* update BitmapCache::from_svg
disable finding bundle in the cache to match load_svg
update to match values used in load_svg
* Update ScalableButton
change the signature and remove functions/vars pertaining to a default bmp
fix TODOs in ScalableButton
Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>
* fix up some more todos in wxExtensions
* update ScalableBitmap to use bmp bundles
use wxBitmapBundle by default
add flag to use old scaled bitmap function (specifically to solve issue with advanced toggle)
* attempt to fix macos deps build
* fix ubuntu build
* Revert "attempt to fix macos deps build"
Mistakenly made change to wrong file
This reverts commit d9c20b5121
.
* update wxWidgets patch
an attempt to fix macOS build
* Remove duplicate variable from OrcaSlicer.cpp
* Fix macOS build issue
* Fix blank DataViewItem being added to objects list
* Filament ComboBox editor updates
-Add show drop down feature to ObjectTable
-Call finish editing when ComboBox is closed in ObjectList
* remove Apple specific declarations missed during refactor
* delete old wxWidgets patch
* fix ubuntu seg fault
* include patch from #2926
* update patch to include wxWidgets/wxWidgets@991a74c
* fix deps not compiling on Windows
* update WipeTowerDialog
relocates the recalculate button back to its previous position
changes the wording of the tip message label
add spacing below the matrix
* finish patching wxWidgets
from prusa3d/PrusaSlicer@f8477d1 and prusa3d/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>
* fix combobox crash
* revert outside plate changes
---------
Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>
Co-authored-by: YuSanka <yusanka@gmail.com>
This commit is contained in:
parent
0bf65aa217
commit
25a055491e
98 changed files with 1639 additions and 6221 deletions
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <wx/sizer.h>
|
||||
|
||||
|
||||
using namespace Slic3r::GUI;
|
||||
|
||||
int scale(const int val) { return val * Slic3r::GUI::wxGetApp().em_unit() / 10; }
|
||||
|
@ -90,7 +89,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters)
|
|||
|
||||
#ifdef _WIN32
|
||||
#define style wxSP_ARROW_KEYS | wxBORDER_SIMPLE
|
||||
#else
|
||||
#else
|
||||
#define style wxSP_ARROW_KEYS
|
||||
#endif
|
||||
|
||||
|
@ -126,9 +125,9 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
|||
#endif
|
||||
sizer_chart->Add(m_chart, 0, wxALL, 5);
|
||||
|
||||
m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0.,5.0,3.,0.5);
|
||||
m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0,10000,0);
|
||||
m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100);
|
||||
m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0.,5.0,3.,0.5);
|
||||
m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0,10000,0);
|
||||
m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100);
|
||||
m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -157,7 +156,7 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
|||
m_widget_volume->SetValue(m_chart->get_volume());
|
||||
m_widget_volume->Disable();
|
||||
m_widget_ramming_line_width_multiplicator->SetValue(m_ramming_line_width_multiplicator);
|
||||
m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator);
|
||||
m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator);
|
||||
|
||||
m_widget_ramming_step_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
m_widget_ramming_line_width_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
|
@ -171,7 +170,7 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
|||
|
||||
m_widget_time->Bind(wxEVT_TEXT,[this](wxCommandEvent&) {m_chart->set_xy_range(m_widget_time->GetValue(),-1);});
|
||||
m_widget_time->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
|
||||
m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
|
||||
m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
|
||||
Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} );
|
||||
Refresh(true); // erase background
|
||||
}
|
||||
|
@ -189,7 +188,7 @@ std::string RammingPanel::get_parameters()
|
|||
stream << m_ramming_line_width_multiplicator << " " << m_ramming_step_multiplicator;
|
||||
for (const float& speed_value : speeds)
|
||||
stream << " " << speed_value;
|
||||
stream << "|";
|
||||
stream << "|";
|
||||
for (const auto& button : buttons)
|
||||
stream << " " << button.first << " " << button.second;
|
||||
return stream.str();
|
||||
|
@ -198,7 +197,7 @@ std::string RammingPanel::get_parameters()
|
|||
|
||||
#ifdef _WIN32
|
||||
#define style wxSP_ARROW_KEYS | wxBORDER_SIMPLE
|
||||
#else
|
||||
#else
|
||||
#define style wxSP_ARROW_KEYS
|
||||
#endif
|
||||
|
||||
|
@ -254,7 +253,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
|
|||
);
|
||||
|
||||
if (flags & wxRESET) {
|
||||
Button *calc_btn = new Button(this, _L("Auto-Calc"));
|
||||
Button *calc_btn = new Button(this, _L("Recalculate"));
|
||||
calc_btn->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
|
||||
calc_btn->SetCornerRadius(FromDIP(12));
|
||||
calc_btn->SetBackgroundColor(calc_btn_bg);
|
||||
|
@ -262,7 +261,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
|
|||
calc_btn->SetTextColor(calc_btn_text);
|
||||
calc_btn->SetFocus();
|
||||
calc_btn->SetId(wxID_RESET);
|
||||
btn_sizer->Add(calc_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
|
||||
btn_sizer->Add(calc_btn, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
|
||||
m_button_list[wxRESET] = calc_btn;
|
||||
}
|
||||
if (flags & wxOK) {
|
||||
|
@ -285,7 +284,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
|
|||
cancel_btn->SetBorderColor(cancel_btn_bd_);
|
||||
cancel_btn->SetTextColor(cancel_btn_text);
|
||||
cancel_btn->SetId(wxID_CANCEL);
|
||||
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
|
||||
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP / 2);
|
||||
m_button_list[wxCANCEL] = cancel_btn;
|
||||
}
|
||||
|
||||
|
@ -293,40 +292,11 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
|
|||
|
||||
}
|
||||
|
||||
wxBoxSizer* WipingPanel::create_calc_btn_sizer(wxWindow* parent) {
|
||||
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
StateColor calc_btn_bg(
|
||||
std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed),
|
||||
std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal)
|
||||
);
|
||||
|
||||
StateColor calc_btn_bd(
|
||||
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal)
|
||||
);
|
||||
|
||||
StateColor calc_btn_text(
|
||||
std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Normal)
|
||||
);
|
||||
|
||||
Button* calc_btn = new Button(parent, _L("Re-calculate"));
|
||||
calc_btn->SetFont(Label::Body_13);
|
||||
calc_btn->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
|
||||
calc_btn->SetCornerRadius(FromDIP(12));
|
||||
calc_btn->SetBackgroundColor(calc_btn_bg);
|
||||
calc_btn->SetBorderColor(calc_btn_bd);
|
||||
calc_btn->SetTextColor(calc_btn_text);
|
||||
calc_btn->SetFocus();
|
||||
btn_sizer->Add(calc_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
|
||||
calc_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { calc_flushing_volumes(); });
|
||||
|
||||
return btn_sizer;
|
||||
}
|
||||
void WipingDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
for (auto button_item : m_button_list)
|
||||
for (auto button_item : m_button_list)
|
||||
{
|
||||
if (button_item.first == wxRESET)
|
||||
if (button_item.first == wxRESET)
|
||||
{
|
||||
button_item.second->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
|
||||
button_item.second->SetCornerRadius(FromDIP(12));
|
||||
|
@ -362,20 +332,20 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
|
|||
|
||||
this->SetBackgroundColour(*wxWHITE);
|
||||
this->SetMinSize(wxSize(MIN_WIPING_DIALOG_WIDTH, -1));
|
||||
|
||||
|
||||
|
||||
m_panel_wiping = new WipingPanel(this, matrix, extruders, extruder_colours, nullptr, extra_flush_volume, flush_multiplier);
|
||||
|
||||
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
main_sizer->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
|
||||
|
||||
// set min sizer width according to extruders count
|
||||
auto sizer_width = (int)((sqrt(matrix.size()) + 2.8)*ITEM_WIDTH());
|
||||
sizer_width = sizer_width > MIN_WIPING_DIALOG_WIDTH ? sizer_width : MIN_WIPING_DIALOG_WIDTH;
|
||||
main_sizer->SetMinSize(wxSize(sizer_width, -1));
|
||||
main_sizer->Add(m_panel_wiping, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
auto btn_sizer = create_btn_sizer(wxOK | wxCANCEL);
|
||||
auto btn_sizer = create_btn_sizer(wxOK | wxCANCEL | wxRESET);
|
||||
main_sizer->Add(btn_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND, BTN_GAP);
|
||||
SetSizer(main_sizer);
|
||||
main_sizer->SetSizeHints(this);
|
||||
|
@ -383,7 +353,6 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
|
|||
if (this->FindWindowById(wxID_OK, this)) {
|
||||
this->FindWindowById(wxID_OK, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { // if OK button is clicked..
|
||||
m_output_matrix = m_panel_wiping->read_matrix_values(); // ..query wiping panel and save returned values
|
||||
m_output_extruders = m_panel_wiping->read_extruders_values(); // so they can be recovered later by calling get_...()
|
||||
EndModal(wxID_OK);
|
||||
}, wxID_OK);
|
||||
}
|
||||
|
@ -393,18 +362,16 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
if (this->FindWindowById(wxID_RESET, this)) {
|
||||
this->FindWindowById(wxID_RESET, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { m_panel_wiping->calc_flushing_volumes(); });
|
||||
}
|
||||
*/
|
||||
|
||||
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
|
||||
this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
|
||||
if (e.GetKeyCode() == WXK_ESCAPE) {
|
||||
if (this->IsModal())
|
||||
this->EndModal(wxID_CANCEL);
|
||||
else
|
||||
else
|
||||
this->Close();
|
||||
}
|
||||
else
|
||||
|
@ -427,6 +394,7 @@ void WipingPanel::create_panels(wxWindow* parent, const int num) {
|
|||
icon->SetCanFocus(false);
|
||||
icon_list2.push_back(icon);
|
||||
|
||||
sizer->AddStretchSpacer();
|
||||
sizer->AddSpacer(ROW_BEG_PADDING);
|
||||
sizer->Add(icon, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, ROW_VERT_PADDING);
|
||||
|
||||
|
@ -438,8 +406,9 @@ void WipingPanel::create_panels(wxWindow* parent, const int num) {
|
|||
sizer->Add(edit_boxes[j][i], 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
}
|
||||
sizer->AddSpacer(ROW_END_PADDING);
|
||||
sizer->AddStretchSpacer();
|
||||
|
||||
m_sizer_advanced->Add(panel, 0, wxRIGHT | wxLEFT | wxEXPAND, TABLE_BORDER);
|
||||
m_sizer->Add(panel, 0, wxRIGHT | wxLEFT | wxEXPAND, TABLE_BORDER);
|
||||
panel->Layout();
|
||||
}
|
||||
}
|
||||
|
@ -457,22 +426,12 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
Slic3r::decode_color(color, rgb);
|
||||
m_colours.push_back(wxColor(rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar()));
|
||||
}
|
||||
|
||||
auto sizer_width = (int)((sqrt(matrix.size())) * ITEM_WIDTH() + (sqrt(matrix.size()) + 1) * HEADER_BEG_PADDING);
|
||||
sizer_width = sizer_width > MIN_WIPING_DIALOG_WIDTH ? sizer_width : MIN_WIPING_DIALOG_WIDTH;
|
||||
// Create two switched panels with their own sizers
|
||||
m_sizer_simple = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer_advanced = new wxBoxSizer(wxVERTICAL);
|
||||
m_page_simple = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_page_advanced = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_page_simple->SetSizer(m_sizer_simple);
|
||||
m_page_advanced->SetSizer(m_sizer_advanced);
|
||||
m_page_advanced->SetBackgroundColour(*wxWHITE);
|
||||
|
||||
update_ui(m_page_simple);
|
||||
update_ui(m_page_advanced);
|
||||
|
||||
auto gridsizer_simple = new wxGridSizer(3, 5, 10);
|
||||
m_gridsizer_advanced = new wxGridSizer(m_number_of_extruders + 1, 5, 1);
|
||||
m_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
this->SetBackgroundColour(*wxWHITE);
|
||||
update_ui(this);
|
||||
|
||||
// First create controls for advanced mode and assign them to m_page_advanced:
|
||||
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
|
||||
|
@ -480,17 +439,17 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
|
||||
for (unsigned int j = 0; j < m_number_of_extruders; ++j) {
|
||||
#ifdef _WIN32
|
||||
wxTextCtrl* text = new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), wxTE_CENTER | wxBORDER_NONE | wxTE_PROCESS_ENTER);
|
||||
wxTextCtrl* text = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), wxTE_CENTER | wxBORDER_NONE | wxTE_PROCESS_ENTER);
|
||||
update_ui(text);
|
||||
edit_boxes.back().push_back(text);
|
||||
#else
|
||||
edit_boxes.back().push_back(new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1)));
|
||||
edit_boxes.back().push_back(new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1)));
|
||||
#endif
|
||||
if (i == j) {
|
||||
edit_boxes[i][j]->SetValue(wxString("-"));
|
||||
edit_boxes[i][j]->SetEditable(false);
|
||||
edit_boxes[i][j]->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent&) {});
|
||||
edit_boxes[i][j]->Bind(wxEVT_SET_FOCUS, [this](wxFocusEvent&) {});
|
||||
edit_boxes[i][j]->Bind(wxEVT_KILL_FOCUS, [](wxFocusEvent&) {});
|
||||
edit_boxes[i][j]->Bind(wxEVT_SET_FOCUS, [](wxFocusEvent&) {});
|
||||
}
|
||||
else {
|
||||
edit_boxes[i][j]->SetValue(wxString("") << int(m_matrix[m_number_of_extruders * j + i] * flush_multiplier));
|
||||
|
@ -519,13 +478,13 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
}
|
||||
|
||||
// BBS
|
||||
m_sizer_advanced->AddSpacer(FromDIP(10));
|
||||
auto tip_message_panel = new wxPanel(m_page_advanced, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
tip_message_panel->SetBackgroundColour(wxColour(238, 238, 238));
|
||||
m_sizer->AddSpacer(FromDIP(10));
|
||||
auto tip_message_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
tip_message_panel->SetBackgroundColour(*wxWHITE);
|
||||
auto message_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
tip_message_panel->SetSizer(message_sizer);
|
||||
{
|
||||
wxString message = _L("Studio would re-calculate your flushing volumes everytime the filaments color changed. You could disable the auto-calculate in Bambu Studio > Preferences");
|
||||
wxString message = _L("Orca recalculates your flushing volumes everytime the filament colors change. You can change this behavior in Preferences.");
|
||||
m_tip_message_label = new Label(tip_message_panel, wxEmptyString);
|
||||
wxClientDC dc(tip_message_panel);
|
||||
wxString multiline_message;
|
||||
|
@ -533,21 +492,20 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
m_tip_message_label->SetLabel(multiline_message);
|
||||
m_tip_message_label->SetFont(Label::Body_13);
|
||||
message_sizer->Add(m_tip_message_label, 0, wxEXPAND | wxALL, TIP_MESSAGES_PADDING);
|
||||
update_ui(m_tip_message_label);
|
||||
}
|
||||
m_sizer_advanced->Add(tip_message_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
|
||||
m_sizer->Add(tip_message_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
|
||||
bool is_show = wxGetApp().app_config->get("auto_calculate") == "true";
|
||||
tip_message_panel->Show(is_show);
|
||||
m_sizer_advanced->AddSpacer(FromDIP(10));
|
||||
auto calc_btn_sizer = create_calc_btn_sizer(m_page_advanced);
|
||||
m_sizer_advanced->Add(calc_btn_sizer, 0, wxEXPAND | wxLEFT, FromDIP(30));
|
||||
|
||||
//m_sizer_advanced->AddSpacer(FromDIP(10));
|
||||
m_sizer_advanced->AddSpacer(FromDIP(5));
|
||||
header_line_panel = new wxPanel(m_page_advanced, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_sizer->AddSpacer(FromDIP(10));
|
||||
|
||||
m_sizer->AddSpacer(FromDIP(5));
|
||||
header_line_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
header_line_panel->SetBackgroundColour(wxColour(238, 238, 238));
|
||||
auto header_line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
header_line_panel->SetSizer(header_line_sizer);
|
||||
|
||||
wxSizerItem* stretch_spacer = header_line_sizer->AddStretchSpacer();
|
||||
header_line_sizer->AddSpacer(HEADER_BEG_PADDING);
|
||||
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
|
||||
wxButton* icon = new wxButton(header_line_panel, wxID_ANY, {}, wxDefaultPosition, ICON_SIZE, wxBORDER_NONE | wxBU_AUTODRAW);
|
||||
|
@ -559,23 +517,24 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
header_line_sizer->Add(icon, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, HEADER_VERT_PADDING);
|
||||
}
|
||||
header_line_sizer->AddSpacer(HEADER_END_PADDING);
|
||||
|
||||
m_sizer_advanced->Add(header_line_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
|
||||
|
||||
create_panels(m_page_advanced, m_number_of_extruders);
|
||||
header_line_sizer->AddStretchSpacer();
|
||||
|
||||
//m_sizer_advanced->AddSpacer(BTN_SIZE.y);
|
||||
m_sizer->Add(header_line_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
|
||||
|
||||
create_panels(this, m_number_of_extruders);
|
||||
|
||||
m_sizer->AddSpacer(FromDIP(5));
|
||||
|
||||
// BBS: for tunning flush volumes
|
||||
{
|
||||
auto multi_desc_label = new wxStaticText(m_page_advanced, wxID_ANY, _(L("Flushing volume (mm³) for each filament pair.")), wxDefaultPosition, wxDefaultSize, 0);
|
||||
auto multi_desc_label = new wxStaticText(this, wxID_ANY, _(L("Flushing volume (mm³) for each filament pair.")), wxDefaultPosition, wxDefaultSize, 0);
|
||||
multi_desc_label->SetForegroundColour(g_text_color);
|
||||
m_sizer_advanced->Add(multi_desc_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
|
||||
m_sizer->Add(multi_desc_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
|
||||
|
||||
wxString min_flush_str = wxString::Format(_L("Suggestion: Flushing Volume in range [%d, %d]"), m_min_flush_volume, m_max_flush_volume);
|
||||
m_min_flush_label = new wxStaticText(m_page_advanced, wxID_ANY, min_flush_str, wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_min_flush_label = new wxStaticText( this, wxID_ANY, min_flush_str, wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_min_flush_label->SetForegroundColour(g_text_color);
|
||||
m_sizer_advanced->Add(m_min_flush_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
|
||||
m_sizer->Add(m_min_flush_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
|
||||
|
||||
auto on_apply_text_modify = [this](wxEvent& e) {
|
||||
wxString str = m_flush_multiplier_ebox->GetValue();
|
||||
|
@ -590,6 +549,8 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
}
|
||||
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
|
||||
for (unsigned int j = 0; j < m_number_of_extruders; ++j) {
|
||||
if (i == j)
|
||||
continue; // if it is from/to the same extruder, don't change the value and continue
|
||||
edit_boxes[i][j]->SetValue(to_string(int(m_matrix[m_number_of_extruders * j + i] * multiplier)));
|
||||
}
|
||||
}
|
||||
|
@ -598,91 +559,32 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
e.Skip();
|
||||
};
|
||||
|
||||
m_sizer_advanced->AddSpacer(10);
|
||||
m_sizer->AddSpacer(10);
|
||||
|
||||
wxBoxSizer* param_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxStaticText* flush_multiplier_title = new wxStaticText(m_page_advanced, wxID_ANY, _L("Multiplier"));
|
||||
wxStaticText* flush_multiplier_title = new wxStaticText(this, wxID_ANY, _L("Multiplier"));
|
||||
param_sizer->Add(flush_multiplier_title, 0, wxALIGN_CENTER | wxALL, 0);
|
||||
param_sizer->AddSpacer(FromDIP(5));
|
||||
m_flush_multiplier_ebox = new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(50), -1), wxTE_PROCESS_ENTER);
|
||||
m_flush_multiplier_ebox = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(50), -1), wxTE_PROCESS_ENTER);
|
||||
char flush_multi_str[32] = { 0 };
|
||||
snprintf(flush_multi_str, sizeof(flush_multi_str), "%.2f", flush_multiplier);
|
||||
m_flush_multiplier_ebox->SetValue(flush_multi_str);
|
||||
param_sizer->Add(m_flush_multiplier_ebox, 0, wxALIGN_CENTER | wxALL, 0);
|
||||
param_sizer->AddStretchSpacer(1);
|
||||
m_sizer_advanced->Add(param_sizer, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
|
||||
m_sizer->Add(param_sizer, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
|
||||
|
||||
m_sizer->AddSpacer(BTN_SIZE.y);
|
||||
|
||||
m_flush_multiplier_ebox->Bind(wxEVT_TEXT_ENTER, on_apply_text_modify);
|
||||
m_flush_multiplier_ebox->Bind(wxEVT_KILL_FOCUS, on_apply_text_modify);
|
||||
}
|
||||
this->update_warning_texts();
|
||||
|
||||
m_page_advanced->Hide();
|
||||
|
||||
// Now the same for simple mode:
|
||||
gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString("")), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
|
||||
gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("unloaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
|
||||
gridsizer_simple->Add(new wxStaticText(m_page_simple,wxID_ANY,wxString(_(L("loaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
auto add_spin_ctrl = [this](std::vector<wxSpinCtrl*>& vec, float initial)
|
||||
{
|
||||
wxSpinCtrl* spin_ctrl = new wxSpinCtrl(m_page_simple, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), style | wxALIGN_RIGHT, 0, 300, (int)initial);
|
||||
update_ui(spin_ctrl);
|
||||
vec.push_back(spin_ctrl);
|
||||
|
||||
#ifdef __WXOSX__
|
||||
// On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value
|
||||
// when it was changed from the text control, so the on_change callback
|
||||
// gets the old one, and on_kill_focus resets the control to the old value.
|
||||
// As a workaround, we get the new value from $event->GetString and store
|
||||
// here temporarily so that we can return it from get_value()
|
||||
spin_ctrl->Bind(wxEVT_TEXT, ([spin_ctrl](wxCommandEvent e)
|
||||
{
|
||||
long value;
|
||||
const bool parsed = e.GetString().ToLong(&value);
|
||||
int tmp_value = parsed && value >= INT_MIN && value <= INT_MAX ? (int)value : INT_MIN;
|
||||
|
||||
// Forcibly set the input value for SpinControl, since the value
|
||||
// inserted from the keyboard or clipboard is not updated under OSX
|
||||
if (tmp_value != INT_MIN) {
|
||||
spin_ctrl->SetValue(tmp_value);
|
||||
|
||||
// But in SetValue() is executed m_text_ctrl->SelectAll(), so
|
||||
// discard this selection and set insertion point to the end of string
|
||||
spin_ctrl->GetText()->SetInsertionPointEnd();
|
||||
}
|
||||
}), spin_ctrl->GetId());
|
||||
#endif
|
||||
};
|
||||
|
||||
for (unsigned int i=0;i<m_number_of_extruders;++i) {
|
||||
add_spin_ctrl(m_old, extruders[2 * i]);
|
||||
add_spin_ctrl(m_new, extruders[2 * i+1]);
|
||||
|
||||
auto hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxWindow* w = new wxWindow(m_page_simple, wxID_ANY, wxDefaultPosition, ICON_SIZE, wxBORDER_SIMPLE);
|
||||
w->SetCanFocus(false);
|
||||
w->SetBackgroundColour(m_colours[i]);
|
||||
hsizer->Add(w, wxALIGN_CENTER_VERTICAL);
|
||||
hsizer->AddSpacer(10);
|
||||
hsizer->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("Filament #"))) << i + 1 << ": "), 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
gridsizer_simple->Add(hsizer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
|
||||
gridsizer_simple->Add(m_old.back(),0);
|
||||
gridsizer_simple->Add(m_new.back(),0);
|
||||
}
|
||||
|
||||
m_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer->Add(m_page_simple, 0, wxEXPAND, 0);
|
||||
m_sizer->Add(m_page_advanced, 0, wxEXPAND, 0);
|
||||
|
||||
m_sizer->SetSizeHints(this);
|
||||
SetSizer(m_sizer);
|
||||
this->Layout();
|
||||
|
||||
toggle_advanced(); // to show/hide what is appropriate
|
||||
|
||||
header_line_panel->Bind(wxEVT_PAINT, [this](wxPaintEvent&) {
|
||||
header_line_panel->Bind(wxEVT_PAINT, [this, stretch_spacer](wxPaintEvent&) {
|
||||
wxPaintDC dc(header_line_panel);
|
||||
wxString from_text = _L("From");
|
||||
wxString to_text = _L("To");
|
||||
|
@ -691,7 +593,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
|
||||
int base_y = (header_line_panel->GetSize().y - from_text_size.y - to_text_size.y) / 2;
|
||||
int vol_width = ROW_BEG_PADDING + EDIT_BOXES_GAP / 2 + ICON_SIZE.x;
|
||||
int base_x = (vol_width - from_text_size.x - to_text_size.x) / 2;
|
||||
int base_x = stretch_spacer->GetSize().x + (vol_width - from_text_size.x - to_text_size.x) / 2;
|
||||
|
||||
// draw from text
|
||||
int x = base_x;
|
||||
|
@ -733,7 +635,7 @@ void WipingPanel::update_warning_texts()
|
|||
auto& box_vec = edit_boxes[i];
|
||||
for (int j = 0; j < box_vec.size(); j++) {
|
||||
if (i == j)
|
||||
continue;
|
||||
continue; // if it is from/to the same extruder, don't change the value and continue
|
||||
|
||||
auto text_box = box_vec[j];
|
||||
wxString str = text_box->GetValue();
|
||||
|
@ -758,8 +660,8 @@ void WipingPanel::update_warning_texts()
|
|||
m_min_flush_label->SetForegroundColour(g_warning_color);
|
||||
m_min_flush_label->Refresh();
|
||||
}
|
||||
else if (!has_exception_flush && m_min_flush_label->GetForegroundColour() != g_text_color) {
|
||||
m_min_flush_label->SetForegroundColour(g_text_color);
|
||||
else if (!has_exception_flush && m_min_flush_label->GetForegroundColour() != StateColor::darkModeColorFor(g_text_color)) {
|
||||
m_min_flush_label->SetForegroundColour(StateColor::darkModeColorFor(g_text_color));
|
||||
m_min_flush_label->Refresh();
|
||||
}
|
||||
}
|
||||
|
@ -770,27 +672,24 @@ void WipingPanel::calc_flushing_volumes()
|
|||
const wxColour& from = m_colours[from_idx];
|
||||
bool is_from_support = is_support_filament(from_idx);
|
||||
for (int to_idx = 0; to_idx < m_colours.size(); to_idx++) {
|
||||
if (from_idx == to_idx)
|
||||
continue; // if it is from/to the same extruder, don't change the value and continue
|
||||
|
||||
bool is_to_support = is_support_filament(to_idx);
|
||||
if (from_idx == to_idx) {
|
||||
edit_boxes[to_idx][from_idx]->SetValue(std::to_string(0));
|
||||
int flushing_volume = 0;
|
||||
if (is_to_support) {
|
||||
flushing_volume = Slic3r::g_flush_volume_to_support;
|
||||
}
|
||||
else {
|
||||
int flushing_volume = 0;
|
||||
if (is_to_support) {
|
||||
flushing_volume = Slic3r::g_flush_volume_to_support;
|
||||
const wxColour& to = m_colours[to_idx];
|
||||
flushing_volume = calc_flushing_volume(from, to);
|
||||
if (is_from_support) {
|
||||
flushing_volume = std::max(Slic3r::g_min_flush_volume_from_support, flushing_volume);
|
||||
}
|
||||
else {
|
||||
const wxColour& to = m_colours[to_idx];
|
||||
flushing_volume = calc_flushing_volume(from, to);
|
||||
if (is_from_support) {
|
||||
flushing_volume = std::max(Slic3r::g_min_flush_volume_from_support, flushing_volume);
|
||||
}
|
||||
}
|
||||
|
||||
m_matrix[m_number_of_extruders * from_idx + to_idx] = flushing_volume;
|
||||
flushing_volume = int(flushing_volume * get_flush_multiplier());
|
||||
edit_boxes[to_idx][from_idx]->SetValue(std::to_string(flushing_volume));
|
||||
}
|
||||
m_matrix[m_number_of_extruders * from_idx + to_idx] = flushing_volume;
|
||||
flushing_volume = int(flushing_volume * get_flush_multiplier());
|
||||
edit_boxes[to_idx][from_idx]->SetValue(std::to_string(flushing_volume));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -808,8 +707,6 @@ void WipingPanel::msw_rescale()
|
|||
|
||||
// Reads values from the (advanced) wiping matrix:
|
||||
std::vector<float> WipingPanel::read_matrix_values() {
|
||||
if (!m_advanced)
|
||||
fill_in_matrix();
|
||||
std::vector<float> output;
|
||||
for (unsigned int i=0;i<m_number_of_extruders;++i) {
|
||||
for (unsigned int j=0;j<m_number_of_extruders;++j) {
|
||||
|
@ -825,59 +722,4 @@ std::vector<float> WipingPanel::read_matrix_values() {
|
|||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
// Reads values from simple mode to save them for next time:
|
||||
std::vector<float> WipingPanel::read_extruders_values() {
|
||||
std::vector<float> output;
|
||||
for (unsigned int i=0;i<m_number_of_extruders;++i) {
|
||||
output.push_back(m_old[i]->GetValue());
|
||||
output.push_back(m_new[i]->GetValue());
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
// This updates the "advanced" matrix based on values from "simple" mode
|
||||
void WipingPanel::fill_in_matrix() {
|
||||
for (unsigned i=0;i<m_number_of_extruders;++i) {
|
||||
for (unsigned j=0;j<m_number_of_extruders;++j) {
|
||||
if (i==j) continue;
|
||||
edit_boxes[j][i]->SetValue(wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Function to check if simple and advanced settings are matching
|
||||
bool WipingPanel::advanced_matches_simple() {
|
||||
for (unsigned i=0;i<m_number_of_extruders;++i) {
|
||||
for (unsigned j=0;j<m_number_of_extruders;++j) {
|
||||
if (i==j) continue;
|
||||
if (edit_boxes[j][i]->GetValue() != (wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue())))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Switches the dialog from simple to advanced mode and vice versa
|
||||
void WipingPanel::toggle_advanced(bool user_action) {
|
||||
if (user_action)
|
||||
m_advanced = !m_advanced; // user demands a change -> toggle
|
||||
else {
|
||||
// BBS: show advanced mode by default
|
||||
//m_advanced = !advanced_matches_simple(); // if called from constructor, show what is appropriate
|
||||
m_advanced = true;
|
||||
}
|
||||
|
||||
(m_advanced ? m_page_advanced : m_page_simple)->Show();
|
||||
(!m_advanced ? m_page_advanced : m_page_simple)->Hide();
|
||||
|
||||
if (m_advanced)
|
||||
if (user_action) fill_in_matrix(); // otherwise keep values loaded from config
|
||||
|
||||
m_sizer->Layout();
|
||||
Refresh();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue