Merge branch 'wipe_tower_ui' into wipe_tower_improvements

This commit is contained in:
Lukas Matena 2018-03-29 09:47:12 +02:00
commit c73d564004
16 changed files with 7337 additions and 4866 deletions

View file

@ -174,6 +174,13 @@ sub recreate_GUI{
$topwindow->Destroy;
}
EVT_IDLE($self->{mainframe}, sub {
while (my $cb = shift @cb) {
$cb->();
}
$self->{app_config}->save if $self->{app_config}->dirty;
});
my $run_wizard = 1 if $self->{preset_bundle}->has_defauls_only;
if ($run_wizard) {
# On OSX the UI was not initialized correctly if the wizard was called

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -57,7 +57,7 @@ plan tests => 8;
my $config = Slic3r::Config::new_from_defaults;
$config->set('layer_height', 0.2);
$config->set('first_layer_height', 0.2);
$config->set('nozzle_diameter', [0.5]);
$config->set('nozzle_diameter', [0.5,0.5,0.5,0.5]);
$config->set('infill_every_layers', 2);
$config->set('perimeter_extruder', 1);
$config->set('infill_extruder', 2);

View file

@ -49,7 +49,7 @@ use Slic3r::Test;
my $parser = Slic3r::GCode::PlaceholderParser->new;
my $config = Slic3r::Config::new_from_defaults;
$config->set('printer_notes', ' PRINTER_VENDOR_PRUSA3D PRINTER_MODEL_MK2 ');
$config->set('nozzle_diameter', [0.6, 0.6, 0.6, 0.6]);
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$parser->apply_config($config);
$parser->set('foo' => 0);
$parser->set('bar' => 2);
@ -123,6 +123,7 @@ use Slic3r::Test;
{
my $config = Slic3r::Config->new;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('extruder', 2);
$config->set('first_layer_temperature', [200,205]);
@ -204,6 +205,7 @@ use Slic3r::Test;
{
my $config = Slic3r::Config->new;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6,0.6]);
$config->set('start_gcode', qq!
;substitution:{if infill_extruder==1}if block
{elsif infill_extruder==2}elsif block 1
@ -228,6 +230,7 @@ use Slic3r::Test;
{
my $config = Slic3r::Config->new;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('start_gcode',
';substitution:{if infill_extruder==1}{if perimeter_extruder==1}block11{else}block12{endif}' .
'{elsif infill_extruder==2}{if perimeter_extruder==1}block21{else}block22{endif}' .

View file

@ -164,6 +164,7 @@ SKIP:
for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
my $config = Slic3r::Config::new_from_defaults;
$config->set('nozzle_diameter', [0.4,0.4,0.4,0.4]);
$config->set('fill_pattern', $pattern);
$config->set('external_fill_pattern', $pattern);
$config->set('perimeters', 1);
@ -195,6 +196,7 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
{
my $config = Slic3r::Config::new_from_defaults;
$config->set('nozzle_diameter', [0.4,0.4,0.4,0.4]);
$config->set('infill_only_where_needed', 1);
$config->set('bottom_solid_layers', 0);
$config->set('infill_extruder', 2);
@ -276,7 +278,7 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
$config->set('fill_density', 0);
$config->set('layer_height', 0.2);
$config->set('first_layer_height', 0.2);
$config->set('nozzle_diameter', [0.35]);
$config->set('nozzle_diameter', [0.35,0.35,0.35,0.35]);
$config->set('infill_extruder', 2);
$config->set('solid_infill_extruder', 2);
$config->set('infill_extrusion_width', 0.52);

View file

@ -16,6 +16,7 @@ use Slic3r::Test;
{
my $config = Slic3r::Config::new_from_defaults;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('raft_layers', 2);
$config->set('infill_extruder', 2);
$config->set('solid_infill_extruder', 3);
@ -89,6 +90,7 @@ use Slic3r::Test;
{
my $config = Slic3r::Config::new_from_defaults;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('support_material_extruder', 3);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
@ -97,6 +99,7 @@ use Slic3r::Test;
{
my $config = Slic3r::Config->new;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('extruder', 2);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
@ -105,6 +108,7 @@ use Slic3r::Test;
{
my $config = Slic3r::Config->new;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('perimeter_extruder', 2);
$config->set('infill_extruder', 2);
$config->set('support_material_extruder', 2);
@ -126,6 +130,7 @@ use Slic3r::Test;
$upper_config->set('bottom_solid_layers', 1);
$upper_config->set('top_solid_layers', 0);
my $config = Slic3r::Config::new_from_defaults;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('fill_density', 0);
$config->set('solid_infill_speed', 99);
$config->set('top_solid_infill_speed', 99);
@ -172,6 +177,7 @@ use Slic3r::Test;
my $object = $model->objects->[0];
my $config = Slic3r::Config::new_from_defaults;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('layer_height', 0.4);
$config->set('first_layer_height', '100%');
$config->set('skirts', 0);

View file

@ -95,6 +95,7 @@ use Slic3r::Test qw(_eq);
1;
};
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('first_layer_height', $config->layer_height);
$config->set('first_layer_speed', '100%');
$config->set('start_gcode', ''); # to avoid dealing with the nozzle lift in start G-code
@ -207,6 +208,7 @@ use Slic3r::Test qw(_eq);
{
my $config = Slic3r::Config::new_from_defaults;
$config->set('nozzle_diameter', [0.6,0.6,0.6,0.6]);
$config->set('start_gcode', '');
$config->set('retract_lift', [3, 4]);
@ -255,4 +257,4 @@ use Slic3r::Test qw(_eq);
'Z is not lifted above the configured value for 2. extruder';
}
__END__
__END__

View file

@ -65,7 +65,7 @@ void Chart::draw(wxDC& dc) {
int x = m_rect.GetLeft();
if (last_mark-y < 50) continue;
dc.DrawLine(x-3,y,x+3,y);
dc.DrawText(wxString()<<math_y,wxPoint(x-25,y-7));
dc.DrawText(wxString()<<math_y,wxPoint(x-25,y-2/*7*/));
last_mark = y;
}

View file

@ -521,7 +521,7 @@ void TabPrint::build()
optgroup->append_single_option_line("wipe_tower_bridging");
line = { _(L("Advanced")), "" };
line.widget = [this](wxWindow* parent){
m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Purging volumes"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Purging volumes"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(m_wipe_tower_btn);
m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e)
@ -951,7 +951,7 @@ void TabFilament::build()
optgroup->append_single_option_line("filament_cooling_time");
line = { _(L("Ramming")), "" };
line.widget = [this](wxWindow* parent){
auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(ramming_dialog_btn);

View file

@ -11,18 +11,16 @@
RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters)
: wxDialog(parent, -1, wxT("Ramming customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
: wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
this->Centre();
m_panel_ramming = new RammingPanel(this,parameters);
m_panel_ramming->Show(true);
this->Show();
auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_panel_ramming, 1, wxEXPAND);
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
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);
SetSizer(main_sizer);
SetMinSize(GetSize());
main_sizer->SetSizeHints(this);
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
@ -38,34 +36,48 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters)
RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,400),wxBORDER_RAISED)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,/*wxPoint(50,50), wxSize(800,350),*/wxBORDER_RAISED).
{
new wxStaticText(this,wxID_ANY,wxString("Total ramming time (s):"), wxPoint(500,105), wxSize(200,25),wxALIGN_LEFT);
m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString, wxPoint(700,100), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0.,5.0,3.,0.5);
new wxStaticText(this,wxID_ANY,wxString("Total rammed volume (mm\u00B3):"), wxPoint(500,135), wxSize(200,25),wxALIGN_LEFT);
m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,130), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0,10000,0);
new wxStaticText(this,wxID_ANY,wxString("Ramming line width (%):"), wxPoint(500,205), wxSize(200,25),wxALIGN_LEFT);
m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,200), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100);
new wxStaticText(this,wxID_ANY,wxString("Ramming line spacing (%):"), wxPoint(500,235), wxSize(200,25),wxALIGN_LEFT);
m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,230), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100);
std::stringstream stream{parameters};
stream >> m_ramming_line_width_multiplicator >> m_ramming_step_multiplicator;
int ramming_speed_size = 0;
float dummy = 0.f;
while (stream >> dummy)
++ramming_speed_size;
stream.clear();
stream.get();
std::vector<std::pair<float,float>> buttons;
float x = 0.f;
float y = 0.f;
while (stream >> x >> y)
buttons.push_back(std::make_pair(x,y));
m_chart = new Chart(this,wxRect(10,10,480,360),buttons,ramming_speed_size,0.25f);
auto sizer_chart = new wxBoxSizer(wxVERTICAL);
auto sizer_param = new wxBoxSizer(wxVERTICAL);
std::stringstream stream{ parameters };
stream >> m_ramming_line_width_multiplicator >> m_ramming_step_multiplicator;
int ramming_speed_size = 0;
float dummy = 0.f;
while (stream >> dummy)
++ramming_speed_size;
stream.clear();
stream.get();
std::vector<std::pair<float, float>> buttons;
float x = 0.f;
float y = 0.f;
while (stream >> x >> y)
buttons.push_back(std::make_pair(x, y));
m_chart = new Chart(this, wxRect(10, 10, 480, 360), buttons, ramming_speed_size, 0.25f);
sizer_chart->Add(m_chart, 0, wxALL, 5);
m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,0.,5.0,3.,0.5);
m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,0,10000,0);
m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,10,200,100);
m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(75, -1),wxSP_ARROW_KEYS,10,200,100);
auto gsizer_param = new wxFlexGridSizer(2, 5, 15);
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total ramming time (s):")))), 0, wxALIGN_CENTER_VERTICAL);
gsizer_param->Add(m_widget_time);
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total rammed volume (mm"))+"\u00B3):")), 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);
sizer_param->Add(gsizer_param, 0, wxTOP, 100);
m_widget_time->SetValue(m_chart->get_time());
m_widget_time->SetDigits(2);
m_widget_volume->SetValue(m_chart->get_volume());
@ -75,6 +87,14 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
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(); });
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(sizer_chart, 0, wxALL, 5);
sizer->Add(sizer_param, 0, wxALL, 10);
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_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
@ -102,24 +122,24 @@ std::string RammingPanel::get_parameters()
}
#define ITEM_WIDTH 60
// 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)
: wxDialog(parent, -1, wxT(L("Wipe tower - Purging volume adjustment")), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
: wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
this->Centre();
auto widget_button = new wxButton(this,wxID_ANY,"-",wxPoint(0,0),wxDefaultSize);
m_panel_wiping = new WipingPanel(this,matrix,extruders, widget_button);
auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_panel_wiping, 1, wxEXPAND);
// set min sizer width according to extruders count
const auto sizer_width = (int)((sqrt(matrix.size()) + 2.8)*ITEM_WIDTH);
main_sizer->SetMinSize(wxSize(sizer_width, -1));
main_sizer->Add(widget_button,0,wxALIGN_CENTER_HORIZONTAL|wxCENTER,10);
main_sizer->Add(m_panel_wiping, 0, wxEXPAND | wxALL, 5);
main_sizer->Add(widget_button, 0, wxALIGN_CENTER_HORIZONTAL | wxCENTER | wxBOTTOM, 5);
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
SetSizer(main_sizer);
SetMinSize(GetSize());
main_sizer->SetSizeHints(this);
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
@ -133,68 +153,91 @@ WipingDialog::WipingDialog(wxWindow* parent,const std::vector<float>& matrix, co
this->Show();
}
// This function allows to "play" with sizers parameters (like align or border)
void WipingPanel::format_sizer(wxSizer* sizer, wxPanel* page, wxGridSizer* grid_sizer, const wxString& info, const wxString& table_title, int table_lshift/*=0*/)
{
sizer->Add(new wxStaticText(page, wxID_ANY, info), 0, wxEXPAND | wxLEFT, 15);
auto table_sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(table_sizer, 0, wxALIGN_LEFT | wxLEFT, table_lshift);
table_sizer->Add(new wxStaticText(page, wxID_ANY, table_title), 0, wxALIGN_CENTER | wxTOP, 50);
table_sizer->Add(grid_sizer, 0, wxALIGN_CENTER | wxTOP, 10);
}
// This panel contains all control widgets for both simple and advanced mode (these reside in separate sizers)
WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, wxButton* widget_button)
: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(500,350),wxBORDER_RAISED)
: wxPanel(parent,wxID_ANY, wxDefaultPosition, wxDefaultSize,wxBORDER_RAISED)
{
m_widget_button = widget_button; // pointer to the button in parent dialog
m_widget_button->Bind(wxEVT_BUTTON,[this](wxCommandEvent&){ toggle_advanced(true); });
m_number_of_extruders = (int)(sqrt(matrix.size())+0.001);
// Create two switched panels with their own sizers
m_sizer_simple = new wxBoxSizer(wxVERTICAL);
m_sizer_advanced = new wxBoxSizer(wxVERTICAL);
auto gridsizer_simple = new wxGridSizer(3,10,10);
auto gridsizer_advanced = new wxGridSizer(m_number_of_extruders+1,10,10);
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);
auto gridsizer_simple = new wxGridSizer(3, 5, 10);
auto gridsizer_advanced = new wxGridSizer(m_number_of_extruders+1, 5, 1);
// First create controls for simple mode and assign them to m_sizer_simple:
m_sizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("Total purging volume is calculated by summing two values below, depending on which tools are loaded/unloaded.")),wxPoint(40,25), wxSize(450,35)),-1,wxEXPAND,10);
m_sizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("Volume to purge (mm\u00B3) when the filament is being")),wxPoint(40,85) ,/*wxSize(500,25)*/wxDefaultSize,wxALIGN_LEFT),-1,wxEXPAND|wxALIGN_CENTER,10);
// First create controls for advanced mode and assign them to m_page_advanced:
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
edit_boxes.push_back(std::vector<wxTextCtrl*>(0));
gridsizer_simple->Add(0,-1,wxALL,10);
gridsizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("unloaded")),wxPoint(110,105) ,/*wxSize(80,25)*/wxDefaultSize,wxALIGN_CENTER),-1,wxALIGN_CENTER,10);
gridsizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("loaded")),wxPoint(195,105) ,/*wxSize(80,25)*/wxDefaultSize,wxALIGN_CENTER),-1,wxALIGN_CENTER,10);
for (unsigned int j = 0; j < m_number_of_extruders; ++j) {
edit_boxes.back().push_back(new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH, -1)));
if (i == j)
edit_boxes[i][j]->Disable();
else
edit_boxes[i][j]->SetValue(wxString("") << int(matrix[m_number_of_extruders*j + i]));
}
}
gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("")));
for (unsigned int i = 0; i < m_number_of_extruders; ++i)
gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
for (unsigned int j = 0; j < m_number_of_extruders; ++j)
gridsizer_advanced->Add(edit_boxes[j][i], 0);
}
for (unsigned int i=0;i<m_number_of_extruders;++i) {
m_old.push_back(new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxPoint(120,130+30*i),/*wxSize(50,25)*/wxDefaultSize,wxSP_ARROW_KEYS|wxALIGN_RIGHT,0,300,extruders[2*i]));
m_new.push_back(new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxPoint(195,130+30*i),/*wxSize(50,25)*/wxDefaultSize,wxSP_ARROW_KEYS|wxALIGN_RIGHT,0,300,extruders[2*i+1]));
gridsizer_simple->Add(new wxStaticText(this,wxID_ANY,wxString(L("Tool #"))<<i+1<<": ",wxPoint(20,135+30*i) ,/*wxSize(75,25)*/wxDefaultSize,wxALIGN_LEFT),-1,wxALL,10);
gridsizer_simple->Add(m_old.back(),-1,wxALIGN_CENTER,10);
gridsizer_simple->Add(m_new.back(),-1,wxALIGN_CENTER,10);
}
// collect and format sizer
format_sizer(m_sizer_advanced, m_page_advanced, gridsizer_advanced,
_(L("Here you can adjust required purging volume (mm\u00B3) for any given pair of tools.")),
_(L("Filament changed to")));
// Now the same for advanced mode:
wxPoint origin(50,85);
m_sizer_advanced->Add(new wxStaticText(this,wxID_ANY,wxString(L("Here you can adjust required purging volume (mm\u00B3) for any given pair of tools.")),wxPoint(40,25) ,/*wxSize(500,35)*/wxDefaultSize),-1,wxALL,10);
m_sizer_advanced->Add(new wxStaticText(this,wxID_ANY,wxString(L("Filament changed to")),origin+wxPoint(75,0) ,/*wxSize(500,25)*/wxDefaultSize),-1,wxALL,10);
// Hide preview page before new page creating
// It allows to do that from a beginning of the main panel
m_page_advanced->Hide();
for (unsigned int i=0;i<m_number_of_extruders;++i) {
edit_boxes.push_back(std::vector<wxTextCtrl*>(0));
// 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);
for (unsigned int j=0;j<m_number_of_extruders;++j) {
edit_boxes.back().push_back(new wxTextCtrl(this,wxID_ANY,wxEmptyString,origin+wxPoint(25+60*i,45+30*j),/*wxSize(50,25)*/wxDefaultSize));
if (i==j)
edit_boxes[i][j]->Disable();
else
edit_boxes[i][j]->SetValue(wxString("")<<int(matrix[m_number_of_extruders*j+i]));
}
}
for (unsigned int i=0;i<m_number_of_extruders;++i) {
m_old.push_back(new wxSpinCtrl(m_page_simple,wxID_ANY,wxEmptyString,wxDefaultPosition, wxSize(80, -1),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0,300,extruders[2*i]));
m_new.push_back(new wxSpinCtrl(m_page_simple,wxID_ANY,wxEmptyString,wxDefaultPosition, wxSize(80, -1),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0,300,extruders[2*i+1]));
gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("Tool #"))) << i + 1 << ": "), 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
gridsizer_simple->Add(m_old.back(),0);
gridsizer_simple->Add(m_new.back(),0);
}
gridsizer_advanced->Add(0,-1,wxALL,10);
for (unsigned int i=0;i<m_number_of_extruders;++i)
gridsizer_advanced->Add(new wxStaticText(this,wxID_ANY,wxString("")<<i+1,origin+wxPoint(45+60*i,25) ,/*wxSize(20,25)*/wxDefaultSize),-1,wxALL,10);
for (unsigned int i=0;i<m_number_of_extruders;++i) {
gridsizer_advanced->Add(new wxStaticText(this,wxID_ANY,wxString("")<<i+1,origin+wxPoint(0,50+30*i) ,/*wxSize(500,25)*/wxDefaultSize),-1,wxALL,10);
for (unsigned int j=0;j<m_number_of_extruders;++j)
gridsizer_advanced->Add(edit_boxes[j][i],-1,wxALL,10);
}
// collect and format sizer
format_sizer(m_sizer_simple, m_page_simple, gridsizer_simple,
_(L("Total purging volume is calculated by summing two values below, depending on which tools are loaded/unloaded.")),
_(L("Volume to purge (mm\u00B3) when the filament is being")), 50);
m_sizer = new wxBoxSizer(wxVERTICAL);
m_sizer->Add(m_page_simple, 0, wxEXPAND | wxALL, 25);
m_sizer->Add(m_page_advanced, 0, wxEXPAND | wxALL, 25);
m_sizer->SetSizeHints(this);
SetSizer(m_sizer);
m_sizer_simple->Add(gridsizer_simple,-1,wxALL,10);
m_sizer_advanced->Add(gridsizer_advanced,-1,wxALL,10);
toggle_advanced(); // to show/hide what is appropriate
}
@ -260,18 +303,16 @@ void WipingPanel::toggle_advanced(bool user_action) {
}
if (user_action)
m_advanced = !m_advanced; // user demands a change -> toggle
else {
else
m_advanced = !advanced_matches_simple(); // if called from constructor, show what is appropriate
(m_advanced ? m_sizer_advanced : m_sizer_simple)->SetSizeHints(this);
SetSizer(m_advanced ? m_sizer_advanced : m_sizer_simple);
}
m_sizer_simple->Show(!m_advanced);
m_sizer_advanced->Show(m_advanced);
(m_advanced ? m_page_advanced : m_page_simple)->Show();
(!m_advanced ? m_page_advanced : m_page_simple)->Hide();
m_widget_button->SetLabel(m_advanced ? L("Show simplified settings") : L("Show advanced settings"));
if (m_advanced)
if (user_action) fill_in_matrix(); // otherwise keep values loaded from config
this->Refresh();
}
m_sizer->Layout();
Refresh();
}

View file

@ -50,6 +50,7 @@ public:
std::vector<float> read_matrix_values();
std::vector<float> read_extruders_values();
void toggle_advanced(bool user_action = false);
void format_sizer(wxSizer* sizer, wxPanel* page, wxGridSizer* grid_sizer, const wxString& info, const wxString& table_title, int table_lshift=0);
private:
void fill_in_matrix();
@ -62,6 +63,9 @@ private:
std::vector<std::vector<wxTextCtrl*>> edit_boxes;
unsigned int m_number_of_extruders = 0;
bool m_advanced = false;
wxPanel* m_page_simple = nullptr;
wxPanel* m_page_advanced = nullptr;
wxBoxSizer* m_sizer = nullptr;
wxBoxSizer*m_sizer_simple = nullptr;
wxBoxSizer*m_sizer_advanced = nullptr;
wxButton* m_widget_button = nullptr;