mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
Ramming dialog improvements & add step control for SpinInput class (#9651)
* init * update dialog buttons * Fix color on Linux & macOS * Fix dark mode dialog title color on Windows --------- Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "MsgDialog.hpp"
|
||||
#include "libslic3r/Color.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/StaticLine.hpp"
|
||||
#include "Widgets/DialogButtons.hpp"
|
||||
#include "slic3r/Utils/ColorSpaceConvert.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
@@ -49,37 +50,27 @@ static void update_ui(wxWindow* window)
|
||||
RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters)
|
||||
: wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/)
|
||||
{
|
||||
update_ui(this);
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
m_panel_ramming = new RammingPanel(this,parameters);
|
||||
|
||||
// Not found another way of getting the background colours of RammingDialog, RammingPanel and Chart correct than setting
|
||||
// them all explicitely. Reading the parent colour yielded colour that didn't really match it, no wxSYS_COLOUR_... matched
|
||||
// colour used for the dialog. Same issue (and "solution") here : https://forums.wxwidgets.org/viewtopic.php?f=1&t=39608
|
||||
// Whoever can fix this, feel free to do so.
|
||||
#ifndef _WIN32
|
||||
this-> SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK));
|
||||
m_panel_ramming->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK));
|
||||
#endif
|
||||
m_panel_ramming->Show(true);
|
||||
this->Show();
|
||||
|
||||
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
main_sizer->Add(m_panel_ramming, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
|
||||
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxBOTTOM, 10);
|
||||
auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
|
||||
main_sizer->Add(dlg_btns, 0, wxEXPAND);
|
||||
SetSizer(main_sizer);
|
||||
main_sizer->SetSizeHints(this);
|
||||
|
||||
update_ui(static_cast<wxButton*>(this->FindWindowById(wxID_OK, this)));
|
||||
update_ui(static_cast<wxButton*>(this->FindWindowById(wxID_CANCEL, this)));
|
||||
|
||||
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
|
||||
|
||||
this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) {
|
||||
m_output_data = m_panel_ramming->get_parameters();
|
||||
EndModal(wxID_OK);
|
||||
},wxID_OK);
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
this->Show();
|
||||
// wxMessageDialog dlg(this, _(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to "
|
||||
|
||||
Slic3r::GUI::MessageDialog dlg(this, _(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to "
|
||||
"properly shape the end of the unloaded filament so it does not prevent insertion of the new filament and can itself "
|
||||
"be reinserted later. This phase is important and different materials can require different extrusion speeds to get "
|
||||
@@ -100,6 +91,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters)
|
||||
RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize/*,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED*/)
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
update_ui(this);
|
||||
auto sizer_chart = new wxBoxSizer(wxVERTICAL);
|
||||
auto sizer_param = new wxBoxSizer(wxVERTICAL);
|
||||
@@ -120,48 +112,59 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
||||
buttons.push_back(std::make_pair(x, y));
|
||||
|
||||
m_chart = new Chart(this, wxRect(scale(10),scale(10),scale(480),scale(360)), buttons, ramming_speed_size, 0.25f, scale(10));
|
||||
#ifdef _WIN32
|
||||
update_ui(m_chart);
|
||||
#else
|
||||
m_chart->SetBackgroundColour(parent->GetBackgroundColour()); // see comment in RammingDialog constructor
|
||||
#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_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100);
|
||||
m_widget_time = new SpinInput(this, wxEmptyString, _L("ms") , wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 0 , 5000 , 3000, 500);
|
||||
m_widget_volume = new SpinInput(this, wxEmptyString, _L("mm³"), wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 0 , 10000, 0 );
|
||||
m_widget_ramming_line_width_multiplicator = new SpinInput(this, wxEmptyString, _L("%") , wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 10, 200 , 100 );
|
||||
m_widget_ramming_step_multiplicator = new SpinInput(this, wxEmptyString, _L("%") , wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 10, 200 , 100 );
|
||||
|
||||
#ifdef _WIN32
|
||||
update_ui(m_widget_time->GetText());
|
||||
update_ui(m_widget_volume);
|
||||
update_ui(m_widget_ramming_line_width_multiplicator);
|
||||
update_ui(m_widget_ramming_step_multiplicator);
|
||||
#endif
|
||||
auto add_title = [this, sizer_param](wxString label){
|
||||
auto title = new StaticLine(this, 0, label);
|
||||
title->SetFont(Label::Head_14);
|
||||
title->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#363636")));
|
||||
sizer_param->Add(title, 0, wxEXPAND | wxBOTTOM, scale(8));
|
||||
};
|
||||
|
||||
auto gsizer_param = new wxFlexGridSizer(2, 5, 15);
|
||||
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total ramming time")) + " (" + _(L("s")) + "):")), 0, wxALIGN_CENTER_VERTICAL);
|
||||
gsizer_param->Add(m_widget_time);
|
||||
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total rammed volume")) + " (" + _(L("mm")) + wxString("³):", wxConvUTF8))), 0, wxALIGN_CENTER_VERTICAL);
|
||||
gsizer_param->Add(m_widget_volume);
|
||||
gsizer_param->AddSpacer(20);
|
||||
gsizer_param->AddSpacer(20);
|
||||
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line width")) + " (%):")), 0, wxALIGN_CENTER_VERTICAL);
|
||||
gsizer_param->Add(m_widget_ramming_line_width_multiplicator);
|
||||
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line spacing")) + " (%):")), 0, wxALIGN_CENTER_VERTICAL);
|
||||
gsizer_param->Add(m_widget_ramming_step_multiplicator);
|
||||
SetFont(Label::Body_14);
|
||||
wxSize col_size;
|
||||
for(auto label : {"Time", "Volume", "Width", "Spacing"})
|
||||
col_size.IncTo(GetTextExtent(_L(label)));
|
||||
col_size = wxSize(col_size.x + scale(30) ,-1);
|
||||
|
||||
sizer_param->Add(gsizer_param, 0, wxTOP, scale(10));
|
||||
auto add_spin = [this, sizer_param, col_size](wxString label, SpinInput* spin){
|
||||
spin->Bind(wxEVT_KILL_FOCUS, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
e.Skip();
|
||||
});
|
||||
auto h_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto text = new wxStaticText(this, wxID_ANY, label, wxDefaultPosition, col_size);
|
||||
text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#363636")));
|
||||
h_sizer->Add(text, 0, wxALIGN_CENTER_VERTICAL);
|
||||
h_sizer->Add(spin);
|
||||
sizer_param->Add(h_sizer, 0, wxEXPAND | wxBOTTOM, scale(2));
|
||||
};
|
||||
|
||||
m_widget_time->SetValue(m_chart->get_time());
|
||||
m_widget_time->SetDigits(2);
|
||||
add_title(_L("Total ramming"));
|
||||
add_spin( _L("Time") , m_widget_time );
|
||||
add_spin( _L("Volume"), m_widget_volume);
|
||||
|
||||
sizer_param->AddSpacer(10);
|
||||
|
||||
add_title(_L("Ramming line"));
|
||||
add_spin( _L("Width") , m_widget_ramming_line_width_multiplicator);
|
||||
add_spin( _L("Spacing"), m_widget_ramming_step_multiplicator );
|
||||
|
||||
m_widget_time->SetValue(int(m_chart->get_time() * 1000));
|
||||
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->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
m_widget_ramming_line_width_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator);
|
||||
|
||||
m_widget_ramming_step_multiplicator->Bind(wxEVT_SPINCTRL,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
m_widget_ramming_line_width_multiplicator->Bind(wxEVT_SPINCTRL,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(sizer_chart, 0, wxALL, 5);
|
||||
@@ -170,10 +173,15 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
||||
sizer->SetSizeHints(this);
|
||||
SetSizer(sizer);
|
||||
|
||||
m_widget_time->Bind(wxEVT_TEXT,[this](wxCommandEvent&) {m_chart->set_xy_range(m_widget_time->GetValue(),-1);});
|
||||
m_widget_time->Bind(wxEVT_SPINCTRL,[this](wxCommandEvent&) {
|
||||
m_chart->set_xy_range(m_widget_time->GetValue() * 0.001,-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
|
||||
Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} );
|
||||
Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {
|
||||
m_widget_volume->SetValue(m_chart->get_volume());
|
||||
m_widget_time->SetValue(m_chart->get_time() * 1000);
|
||||
});
|
||||
Refresh(true); // erase background
|
||||
}
|
||||
|
||||
@@ -340,7 +348,7 @@ void WipingDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
// Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button to toggle simple/advanced mode:
|
||||
WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours,
|
||||
const std::vector<int>&extra_flush_volume, float flush_multiplier)
|
||||
: DPIDialog(parent ? parent : static_cast<wxWindow *>(wxGetApp().mainframe),
|
||||
: GUI::DPIDialog(parent ? parent : static_cast<wxWindow *>(wxGetApp().mainframe),
|
||||
wxID_ANY,
|
||||
_(L("Flushing volumes for filament change")),
|
||||
wxDefaultPosition,
|
||||
|
||||
Reference in New Issue
Block a user