From 27ab8ff4e1fc9efdc5ca61ff1ae70cdfde16b4e8 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 12 Mar 2018 15:41:25 +0100 Subject: [PATCH] Configuration layer changes (cooling_time, bridging, adhesion moved from dedicated dialog to filament/print settings) --- xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp | 12 ++--- xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp | 42 ++++++++--------- xs/src/libslic3r/Print.cpp | 5 ++ xs/src/libslic3r/PrintConfig.cpp | 23 ++++++++++ xs/src/libslic3r/PrintConfig.hpp | 6 +++ xs/src/slic3r/GUI/Preset.cpp | 6 +-- xs/src/slic3r/GUI/Tab.cpp | 23 ++++++++++ xs/src/slic3r/GUI/WipeTowerDialog.cpp | 51 ++------------------- xs/src/slic3r/GUI/WipeTowerDialog.hpp | 33 ------------- 9 files changed, 91 insertions(+), 110 deletions(-) diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index 624b48903..b94950af1 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -734,7 +734,7 @@ void WipeTowerPrusaMM::toolchange_Unload( writer.travel(xl, cleaning_box.ld.y + m_depth_traversed + y_step/2.f ); // move to starting position // if the ending point of the ram would end up in mid air, align it with the end of the wipe tower: - if (m_layer_info > m_plan.begin() && m_layer_info < m_plan.end() && (m_layer_info-1!=m_plan.begin() || !m_par.adhesion )) { + if (m_layer_info > m_plan.begin() && m_layer_info < m_plan.end() && (m_layer_info-1!=m_plan.begin() || !m_adhesion )) { // this is y of the center of previous sparse infill border float sparse_beginning_y = m_wipe_tower_pos.y; @@ -821,8 +821,8 @@ void WipeTowerPrusaMM::toolchange_Unload( const float start_x = writer.x(); turning_point = ( xr-start_x > start_x-xl ? xr : xl ); const float max_x_dist = 2*std::abs(start_x-turning_point); - const unsigned int N = 4 + std::max(0,(m_par.cooling_time[m_current_tool]-14)/3); - float time = m_par.cooling_time[m_current_tool] / float(N); + const unsigned int N = 4 + std::max(0,(m_filpar[m_current_tool].cooling_time-14)/3); + float time = m_filpar[m_current_tool].cooling_time / float(N); i = 0; while (i fill_box.ld.x+EPSILON) writer.travel(fill_box.ld.x,writer.y()); if (writer.y() > fill_box.ld.y+EPSILON) writer.travel(writer.x(),fill_box.ld.y); - if (m_is_first_layer && m_par.adhesion) { + if (m_is_first_layer && m_adhesion) { // Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower. box.expand(-m_perimeter_width/2.f); unsigned nsteps = int(floor((box.lu.y - box.ld.y) / (2*m_perimeter_width))); @@ -1045,7 +1045,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() writer.travel(fill_box.ld + xy(m_perimeter_width * 2, 0.f)) .extrude(fill_box.lu + xy(m_perimeter_width * 2, 0.f), 2900 * speed_factor); - const int n = 1+(right-left)/(m_par.bridging); + const int n = 1+(right-left)/(m_bridging); const float dx = (right-left)/n; for (int i=1;i<=n;++i) { float x=left+dx*i; diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp index 3182c8b8e..3c2f82ffd 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.hpp @@ -68,13 +68,12 @@ struct WipeTowerParameters { WipeTowerParameters() { } // create new empty object WipeTowerParameters(const std::string& init_data) { // create object and initialize from std::string std::istringstream in(init_data); // validation of input is left to the caller - in >> bridging >> adhesion >> sampling; + in >> sampling; for (std::vector vect{} ; in >> vect ;) { // until we get to fail state ("**")... - if (vect.size()>=3) { - cooling_time.push_back(vect[0]); - ramming_line_width_multiplicator.push_back(vect[1]); - ramming_step_multiplicator.push_back(vect[2]); - vect.erase(vect.begin(),vect.begin()+3); + if (vect.size()>=2) { + ramming_line_width_multiplicator.push_back(vect[0]); + ramming_step_multiplicator.push_back(vect[1]); + vect.erase(vect.begin(),vect.begin()+2); } else vect.clear(); // something's not right, we will restore defaults anyway ramming_speed.push_back(vect); @@ -102,16 +101,16 @@ struct WipeTowerParameters { for (unsigned int i=0;i cooling_time; std::vector ramming_line_width_multiplicator; std::vector ramming_step_multiplicator; std::vector> ramming_speed; @@ -192,7 +185,7 @@ public: // width -- width of wipe tower in mm ( default 60 mm - leave as it is ) // wipe_area -- space available for one toolchange in mm WipeTowerPrusaMM(float x, float y, float width, float wipe_area, float rotation_angle, float cooling_tube_retraction, - float cooling_tube_length, float parking_pos_retraction, std::string& parameters, + float cooling_tube_length, float parking_pos_retraction, float bridging, bool adhesion, std::string& parameters, unsigned int initial_tool) : m_wipe_tower_pos(x, y), m_wipe_tower_width(width), @@ -205,8 +198,11 @@ public: m_cooling_tube_length(cooling_tube_length), m_parking_pos_retraction(parking_pos_retraction), m_current_tool(initial_tool), - m_par(parameters) + m_par(parameters) { + m_bridging = bridging; + m_adhesion = adhesion; + for (size_t i = 0; i < 4; ++ i) { // Extruder specific parameters. m_filpar[i].material = PLA; @@ -226,7 +222,7 @@ public: // Set the extruder properties. void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed, - float unloading_speed, float delay) + float unloading_speed, float delay, int cooling_time) { m_filpar[idx].material = material; m_filpar[idx].temperature = temp; @@ -234,6 +230,7 @@ public: m_filpar[idx].loading_speed = loading_speed; m_filpar[idx].unloading_speed = unloading_speed; m_filpar[idx].delay = delay; + m_filpar[idx].cooling_time = cooling_time; } @@ -340,6 +337,8 @@ private: float m_cooling_tube_retraction = 0.f; float m_cooling_tube_length = 0.f; float m_parking_pos_retraction = 0.f; + float m_bridging = 0.f; + bool m_adhesion = true; float m_line_width = Nozzle_Diameter * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. float m_extrusion_flow = 0.038; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. @@ -352,6 +351,7 @@ private: float loading_speed; float unloading_speed; float delay; + int cooling_time; }; // Extruder specific parameters. diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 5affad297..95c57339a 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -188,6 +188,7 @@ bool Print::invalidate_state_by_config_options(const std::vectorconfig.wipe_tower_width.value), float(this->config.wipe_tower_per_color_wipe.value), float(this->config.wipe_tower_rotation_angle.value), float(this->config.cooling_tube_retraction.value), float(this->config.cooling_tube_length.value), float(this->config.parking_pos_retraction.value), + float(this->config.wipe_tower_bridging), bool(this->config.wipe_tower_adhesion), this->config.wipe_tower_advanced.value,m_tool_ordering.first_extruder()); //wipe_tower.set_retract(); @@ -1044,6 +1048,7 @@ void Print::_make_wipe_tower() this->config.first_layer_temperature.get_at(i), this->config.filament_loading_speed.get_at(i), this->config.filament_unloading_speed.get_at(i), + this->config.filament_toolchange_delay.get_at(i), this->config.filament_toolchange_delay.get_at(i)); // When printing the first layer's wipe tower, the first extruder is expected to be active and primed. diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index f31e5de3b..b0b1c4e99 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -469,6 +469,15 @@ PrintConfigDef::PrintConfigDef() def->cli = "filament-toolchange-delay=f@"; def->min = 0; def->default_value = new ConfigOptionFloats { 0. }; + + def = this->add("filament_cooling_time", coInts); + def->label = L("Cooling time"); + def->tooltip = L("The filament is slowly moved back and forth after retraction into the cooling tube " + "for this amount of time."); + def->cli = "filament_cooling_time=i@"; + def->sidetext = L("s"); + def->min = 0; + def->default_value = new ConfigOptionInts { 14 }; def = this->add("filament_diameter", coFloats); def->label = L("Diameter"); @@ -1800,6 +1809,20 @@ PrintConfigDef::PrintConfigDef() def->sidetext = L("degrees"); def->cli = "wipe-tower-rotation-angle=f"; def->default_value = new ConfigOptionFloat(0.); + + def = this->add("wipe_tower_bridging", coFloat); + def->label = L("Maximal bridging distance"); + def->tooltip = L("Maximal distance between supports on sparse infill sections. "); + def->sidetext = L("mm"); + def->cli = "wipe-tower-bridging=f"; + def->default_value = new ConfigOptionFloat(10.); + + def = this->add("wipe_tower_adhesion", coBool); + def->label = L("Increase first layer adhesion"); + def->tooltip = L("This prevents using sparse infill on the first layer, if it would be " + "normally applied. Dense infill is used instead. "); + def->cli = "wipe-tower_adhesion!"; + def->default_value = new ConfigOptionBool(true); def = this->add("xy_size_compensation", coFloat); def->label = L("XY Size Compensation"); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 06aa343b8..501a8ac36 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -470,6 +470,7 @@ public: ConfigOptionFloats filament_loading_speed; ConfigOptionFloats filament_unloading_speed; ConfigOptionFloats filament_toolchange_delay; + ConfigOptionInts filament_cooling_time; ConfigOptionBool gcode_comments; ConfigOptionEnum gcode_flavor; ConfigOptionString layer_gcode; @@ -525,6 +526,7 @@ protected: OPT_PTR(filament_loading_speed); OPT_PTR(filament_unloading_speed); OPT_PTR(filament_toolchange_delay); + OPT_PTR(filament_cooling_time); OPT_PTR(gcode_comments); OPT_PTR(gcode_flavor); OPT_PTR(layer_gcode); @@ -624,6 +626,8 @@ public: ConfigOptionFloat wipe_tower_width; ConfigOptionFloat wipe_tower_per_color_wipe; ConfigOptionFloat wipe_tower_rotation_angle; + ConfigOptionFloat wipe_tower_bridging; + ConfigOptionBool wipe_tower_adhesion; ConfigOptionFloat z_offset; protected: @@ -690,6 +694,8 @@ protected: OPT_PTR(wipe_tower_width); OPT_PTR(wipe_tower_per_color_wipe); OPT_PTR(wipe_tower_rotation_angle); + OPT_PTR(wipe_tower_bridging); + OPT_PTR(wipe_tower_adhesion); OPT_PTR(z_offset); } }; diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index a8b6a514c..92bfef416 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -199,8 +199,8 @@ const std::vector& Preset::print_options() "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower_advanced", "wipe_tower", "wipe_tower_x", - "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "compatible_printers", - "compatible_printers_condition" + "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_adhesion", "wipe_tower_bridging", + "compatible_printers", "compatible_printers_condition" }; return s_opts; @@ -211,7 +211,7 @@ const std::vector& Preset::filament_options() static std::vector s_opts { "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_unloading_speed", "filament_toolchange_delay", - "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", + "filament_cooling_time", "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers", "compatible_printers_condition" }; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 177fccc59..ea80e2ece 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -458,6 +458,8 @@ void TabPrint::build() optgroup->append_single_option_line("wipe_tower_width"); optgroup->append_single_option_line("wipe_tower_per_color_wipe"); optgroup->append_single_option_line("wipe_tower_rotation_angle"); + optgroup->append_single_option_line("wipe_tower_bridging"); + optgroup->append_single_option_line("wipe_tower_adhesion"); line = { _(L("Advanced")), "" }; line.widget = [this](wxWindow* parent){ m_wipe_tower_btn = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); @@ -880,6 +882,27 @@ void TabFilament::build() optgroup->append_single_option_line("filament_loading_speed"); optgroup->append_single_option_line("filament_unloading_speed"); optgroup->append_single_option_line("filament_toolchange_delay"); + optgroup->append_single_option_line("filament_cooling_time"); + line = { _(L("Ramming")), "" }; + line.widget = [this](wxWindow* parent){ + auto ramming_dialog = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT); + auto sizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(ramming_dialog); + /*m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) + { + std::string init_data = (m_config->option("wipe_tower_advanced"))->value; + std::cout << "dialog init: " << init_data << std::endl; + WipeTowerDialog dlg(this,init_data); // dlg lives on stack, no need to call Destroy + + if (dlg.ShowModal() == wxID_OK) { + load_key_value("wipe_tower_advanced", dlg.GetValue()); + std::cout << std::endl << "dialog returned: " << dlg.GetValue() << std::endl; + } + }));*/ + return sizer; + }; + optgroup->append_line(line); + page = add_options_page(_(L("Custom G-code")), "cog.png"); optgroup = page->new_optgroup(_(L("Start G-code")), 0); diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 323749b0a..1891a401c 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -3,13 +3,8 @@ // Human-readable output of Parameters structure std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par) { - str << "bridging: " << par.bridging << "\n"; - str << "adhesion: " << par.adhesion << "\n"; str << "sampling: " << par.sampling << "\n"; - str << "cooling times: "; - for (const auto& a : par.cooling_time) str << a << " "; - str << "line widths: "; for (const auto& a : par.ramming_line_width_multiplicator) str << a << " "; @@ -116,30 +111,6 @@ void RammingPanel::line_parameters_changed() { - -CoolingPanel::CoolingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) -: wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) -{ - new wxStaticText(this,wxID_ANY,wxString("Time (in seconds) reserved for cooling after unload:"),wxPoint(220,50) ,wxSize(400,25),wxALIGN_LEFT); - for (int i=0;i<4;++i) { - new wxStaticText(this,wxID_ANY,wxString("Filament #")<=m_widget_edits.size()) - break; // so we don't initialize non-existent widget - m_widget_edits[i]->SetValue(p.cooling_time[i]); - } -} - -void CoolingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { - p.cooling_time.clear(); - for (int i=0;i<4;++i) - p.cooling_time.push_back(m_widget_edits[i]->GetValue()); -} - - - WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) : wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) { @@ -208,20 +179,6 @@ void WipingPanel::fill_in_matrix() { -GeneralPanel::GeneralPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p) : wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED) { - new wxStaticText(this,wxID_ANY,wxString("Maximum bridging over sparse infill (mm):"),wxPoint(100,105) ,wxSize(280,25),wxALIGN_LEFT); - m_widget_bridge = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxPoint(380,100),wxSize(50,25),wxALIGN_RIGHT|wxSP_ARROW_KEYS,1,50,10); - m_widget_adhesion = new wxCheckBox(this,wxID_ANY,"Increased adhesion of first layer",wxPoint(100,150),wxSize(330,25),wxALIGN_RIGHT); - m_widget_bridge->SetValue(p.bridging); - m_widget_adhesion->SetValue(p.adhesion); -} - -void GeneralPanel::fill_parameters(Slic3r::WipeTowerParameters& p) { - p.bridging = m_widget_bridge->GetValue(); - p.adhesion = m_widget_adhesion->GetValue(); -} - - @@ -238,13 +195,13 @@ WipeTowerDialog::WipeTowerDialog(wxWindow* parent,const std::string& init_data) wxNotebook* notebook = new wxNotebook(this,wxID_ANY,wxPoint(0,0),wxSize(800,450)); - m_panel_general = new GeneralPanel(notebook,parameters); + //m_panel_general = new GeneralPanel(notebook,parameters); m_panel_ramming = new RammingPanel(notebook,parameters); - m_panel_cooling = new CoolingPanel(notebook,parameters); + //m_panel_cooling = new CoolingPanel(notebook,parameters); m_panel_wiping = new WipingPanel(notebook,parameters); - notebook->AddPage(m_panel_general,"General"); + //notebook->AddPage(m_panel_general,"General"); notebook->AddPage(m_panel_ramming,"Ramming"); - notebook->AddPage(m_panel_cooling,"Cooling"); + //notebook->AddPage(m_panel_cooling,"Cooling"); notebook->AddPage(m_panel_wiping,"Wiping"); this->Show(); diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.hpp b/xs/src/slic3r/GUI/WipeTowerDialog.hpp index 452886bc3..8a1c88be8 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.hpp @@ -40,23 +40,6 @@ private: - - - -class CoolingPanel : public wxPanel { -public: - CoolingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); - void fill_parameters(Slic3r::WipeTowerParameters& p); - -private: - std::vector m_widget_edits; -}; - - - - - - class WipingPanel : public wxPanel { public: WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); @@ -74,18 +57,6 @@ private: -class GeneralPanel : public wxPanel { -public: - GeneralPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p); - void fill_parameters(Slic3r::WipeTowerParameters& p); - -private: - wxSpinCtrl* m_widget_bridge; - wxCheckBox* m_widget_adhesion; -}; - - - class WipeTowerDialog : public wxDialog { public: @@ -96,17 +67,13 @@ public: private: std::string m_file_name="config_wipe_tower"; - GeneralPanel* m_panel_general = nullptr; RammingPanel* m_panel_ramming = nullptr; - CoolingPanel* m_panel_cooling = nullptr; WipingPanel* m_panel_wiping = nullptr; std::string m_output_data = ""; std::string read_dialog_values() { Slic3r::WipeTowerParameters p; - m_panel_general->fill_parameters(p); m_panel_ramming->fill_parameters(p); - m_panel_cooling->fill_parameters(p); m_panel_wiping ->fill_parameters(p); return p.to_string(); }