From 35d23d57ec115505b335393f2443b864c9c15758 Mon Sep 17 00:00:00 2001 From: remi durand Date: Wed, 2 Jun 2021 17:17:30 +0200 Subject: [PATCH] disbale / use editable function of wxcombobox for calibrations supermerill/SuperSlicer#1228 --- src/slic3r/GUI/CalibrationBridgeDialog.cpp | 12 +++++++---- src/slic3r/GUI/CalibrationCubeDialog.cpp | 12 ++++++++--- .../GUI/CalibrationRetractionDialog.cpp | 21 ++++++++----------- src/slic3r/GUI/CalibrationTempDialog.cpp | 21 ++++++++++++------- 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/slic3r/GUI/CalibrationBridgeDialog.cpp b/src/slic3r/GUI/CalibrationBridgeDialog.cpp index ba481cdd4..84bfb11d1 100644 --- a/src/slic3r/GUI/CalibrationBridgeDialog.cpp +++ b/src/slic3r/GUI/CalibrationBridgeDialog.cpp @@ -62,10 +62,14 @@ void CalibrationBridgeDialog::create_geometry(std::string setting_to_test, bool gui_app->app_config->set("autocenter", "0"); } - int idx_steps = steps->GetSelection(); - int idx_nb = nb_tests->GetSelection(); - size_t step = 5 + (idx_steps == wxNOT_FOUND ? 0 : idx_steps * 5); - size_t nb_items = 1 + (idx_nb == wxNOT_FOUND ? 0 : idx_nb); + long step = 10; + if (!steps->GetValue().ToLong(&step)) { + step = 10; + } + long nb_items = 10; + if (!nb_tests->GetValue().ToLong(&nb_items)) { + nb_items = 10; + } std::vector items; for (size_t i = 0; i < nb_items; i++) diff --git a/src/slic3r/GUI/CalibrationCubeDialog.cpp b/src/slic3r/GUI/CalibrationCubeDialog.cpp index f42cad315..0ad82e1f2 100644 --- a/src/slic3r/GUI/CalibrationCubeDialog.cpp +++ b/src/slic3r/GUI/CalibrationCubeDialog.cpp @@ -24,17 +24,19 @@ namespace Slic3r { namespace GUI { void CalibrationCubeDialog::create_buttons(wxStdDialogButtonSizer* buttons){ - wxString choices_scale[] = { "10mm", "20mm", "30mm", "40mm" }; - scale = new wxComboBox(this, wxID_ANY, wxString{ "20mm" }, wxDefaultPosition, wxDefaultSize, 4, choices_scale); + wxString choices_scale[] = { "10", "20", "30", "40" }; + scale = new wxComboBox(this, wxID_ANY, wxString{ "20" }, wxDefaultPosition, wxDefaultSize, 4, choices_scale); scale->SetToolTip(_(L("You can choose the dimension of the cube. It's a simple scale, you can modify it in the right panel yourself if you prefer. It's just quicker to select it here."))); scale->SetSelection(1); wxString choices_goal[] = { "Dimensional accuracy (default)" , "infill/perimeter overlap"/*, "external perimeter overlap"*/}; calibrate = new wxComboBox(this, wxID_ANY, wxString{ "Dimensional accuracy (default)" }, wxDefaultPosition, wxDefaultSize, 2, choices_goal); calibrate->SetToolTip(_(L("Select a goal, this will change settings to increase the effects to search."))); calibrate->SetSelection(0); + calibrate->SetEditable(false); buttons->Add(new wxStaticText(this, wxID_ANY, wxString{ "dimension:" })); buttons->Add(scale); + buttons->Add(new wxStaticText(this, wxID_ANY, wxString{ "mm" })); buttons->AddSpacer(40); buttons->Add(new wxStaticText(this, wxID_ANY, wxString{ "goal:" })); buttons->Add(calibrate); @@ -74,7 +76,11 @@ void CalibrationCubeDialog::create_geometry(std::string calibration_path) { if (calibration_path == "xyzCalibration_cube.amf") cube_size = 20; int idx_scale = scale->GetSelection(); - float xyzScale = (10/cube_size) * (idx_scale+1); + double xyzScale = 20; + if (!scale->GetValue().ToDouble(&xyzScale)) { + xyzScale = 20; + } + xyzScale = xyzScale / cube_size; //do scaling model.objects[objs_idx[0]]->scale(xyzScale, xyzScale, xyzScale); diff --git a/src/slic3r/GUI/CalibrationRetractionDialog.cpp b/src/slic3r/GUI/CalibrationRetractionDialog.cpp index cbe9bf79d..252f55cf5 100644 --- a/src/slic3r/GUI/CalibrationRetractionDialog.cpp +++ b/src/slic3r/GUI/CalibrationRetractionDialog.cpp @@ -26,8 +26,8 @@ namespace Slic3r { namespace GUI { void CalibrationRetractionDialog::create_buttons(wxStdDialogButtonSizer* buttons){ - wxString choices_steps[] = { "0.1","0.2","0.5","1" }; - steps = new wxComboBox(this, wxID_ANY, wxString{ "0.2" }, wxDefaultPosition, wxDefaultSize, 4, choices_steps); + wxString choices_steps[] = { "0.1","0.2","0.5","1","2" }; + steps = new wxComboBox(this, wxID_ANY, wxString{ "0.2" }, wxDefaultPosition, wxDefaultSize, 5, choices_steps); steps->SetToolTip(_L("Each militer add this value to the retraction value. ")); steps->SetSelection(1); wxString choices_nb[] = { "2","4","6","8","10","15","20","25" }; @@ -47,6 +47,7 @@ void CalibrationRetractionDialog::create_buttons(wxStdDialogButtonSizer* buttons decr_temp = new wxComboBox(this, wxID_ANY, wxString{ "current" }, wxDefaultPosition, wxDefaultSize, 6, choices_decr); decr_temp->SetToolTip(_L("Select the number tower to print, and by how many degrees C to decrease each time.")); decr_temp->SetSelection(0); + decr_temp->SetEditable(false); buttons->Add(new wxStaticText(this, wxID_ANY, wxString{ "step:" })); buttons->Add(steps); @@ -109,7 +110,10 @@ void CalibrationRetractionDialog::create_geometry(wxCommandEvent& event_args) { gui_app->app_config->set("autocenter", "0"); } - size_t nb_retract = nb_steps->GetSelection() < 4 ? ((int(nb_steps->GetSelection()) + 1) * 2) : ((int(nb_steps->GetSelection()) - 2) * 5); + long nb_retract = 1; + if (!nb_steps->GetValue().ToLong(&nb_retract)) { + nb_retract = 15; + } size_t nb_items = 1; if (decr_temp->GetSelection() == 1) { nb_items = 2; @@ -141,16 +145,9 @@ void CalibrationRetractionDialog::create_geometry(wxCommandEvent& event_args) { temp = std::atoi(str.c_str()); double retraction_steps = 0.01; - if (steps->GetSelection() == 0) + if (!steps->GetValue().ToDouble(&retraction_steps)) { retraction_steps = 0.1; - if (steps->GetSelection() == 1) - retraction_steps = 0.2; - if (steps->GetSelection() == 2) - retraction_steps = 0.5; - if (steps->GetSelection() == 3) - retraction_steps = 1; - if (steps->GetSelection() == 4) - retraction_steps = 2; + } /// --- scale --- // model is created for a 0.4 nozzle, scale xy with nozzle size. diff --git a/src/slic3r/GUI/CalibrationTempDialog.cpp b/src/slic3r/GUI/CalibrationTempDialog.cpp index f0941f4b1..b49272e50 100644 --- a/src/slic3r/GUI/CalibrationTempDialog.cpp +++ b/src/slic3r/GUI/CalibrationTempDialog.cpp @@ -70,15 +70,22 @@ void CalibrationTempDialog::create_geometry(wxCommandEvent& event_args) { // -- get temps const ConfigOptionInts* temperature_config = filament_config->option("temperature"); assert(temperature_config->values.size() >= 1); - int idx_steps = steps->GetSelection(); - int idx_up = nb_up->GetSelection(); - int idx_down = nb_down->GetSelection(); + long nb_items_up = 1; + if (!nb_up->GetValue().ToLong(&nb_items_up)) { + nb_items_up = 2; + } + long nb_items_down = 1; + if (!nb_down->GetValue().ToLong(&nb_items_down)) { + nb_items_down = 2; + } int16_t temperature = 5 * (temperature_config->values[0] / 5); - size_t step_temp = 5 + (idx_steps == wxNOT_FOUND ? 0 : (idx_steps * 5)); - size_t nb_items = 1 + (idx_down == wxNOT_FOUND ? 0 : idx_down) - + (idx_up == wxNOT_FOUND ? 0 : idx_up); + long step_temp = 1; + if (!steps->GetValue().ToLong(&step_temp)) { + step_temp = 10; + } + size_t nb_items = 1 + nb_items_up + nb_items_down; //start at the highest temp - temperature = temperature + step_temp * (idx_up == wxNOT_FOUND ? 0 : idx_up); + temperature = temperature + step_temp * nb_items_up; /// --- scale --- //model is created for a 0.4 nozzle, scale xy with nozzle size.