From 232309a879b4b8bbdad915c39695c8289daf929d Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 21 Jul 2021 16:13:40 +0200 Subject: [PATCH 1/8] Don't save shapes directory to the "last_dir" --- src/libslic3r/AppConfig.cpp | 2 ++ src/libslic3r/Utils.hpp | 3 +++ src/libslic3r/utils.cpp | 5 +++++ src/slic3r/GUI/GalleryDialog.cpp | 4 +--- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index cee9eafdc..1c2e846dd 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -544,6 +544,8 @@ void AppConfig::update_config_dir(const std::string &dir) void AppConfig::update_skein_dir(const std::string &dir) { + if (dir == sys_shapes_dir() || dir == custom_shapes_dir()) + return; // do not save "shapes gallery" directory this->set("recent", "skein_directory", dir); } /* diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 330f05ec8..211755bbb 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -50,6 +50,9 @@ void set_sys_shapes_dir(const std::string &path); // Return a full path to the system shapes gallery directory. const std::string& sys_shapes_dir(); +// Return a full path to the custom shapes gallery directory. +std::string custom_shapes_dir(); + // Set a path with preset files. void set_data_dir(const std::string &path); // Return a full path to the GUI resource files. diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 8f1cf07f2..3e38a3e67 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -202,6 +202,11 @@ const std::string& data_dir() return g_data_dir; } +std::string custom_shapes_dir() +{ + return (boost::filesystem::path(g_data_dir) / "shapes").string(); +} + #ifdef _WIN32 // The following helpers are borrowed from the LLVM project https://github.com/llvm namespace WindowsSupport diff --git a/src/slic3r/GUI/GalleryDialog.cpp b/src/slic3r/GUI/GalleryDialog.cpp index 539bcddbf..d64c09fb6 100644 --- a/src/slic3r/GUI/GalleryDialog.cpp +++ b/src/slic3r/GUI/GalleryDialog.cpp @@ -219,9 +219,7 @@ static void add_default_image(wxImageList* img_list, bool is_system) static fs::path get_dir(bool sys_dir) { - if (sys_dir) - return fs::absolute(fs::path(sys_shapes_dir())).make_preferred(); - return fs::absolute(fs::path(data_dir()) / "shapes").make_preferred(); + return fs::absolute(fs::path(sys_dir ? sys_shapes_dir() : custom_shapes_dir())).make_preferred(); } static std::string get_dir_path(bool sys_dir) From b80fb40fcd4143888ff3e909185c61e54a60e7d5 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 22 Jul 2021 08:35:21 +0200 Subject: [PATCH 2/8] Tech ENABLE_GCODE_LINES_ID_IN_H_SLIDER set as default --- src/libslic3r/AppConfig.cpp | 2 - src/libslic3r/GCode/GCodeProcessor.cpp | 53 -------------------------- src/libslic3r/GCode/GCodeProcessor.hpp | 29 -------------- src/libslic3r/Technologies.hpp | 2 - src/slic3r/GUI/DoubleSlider.cpp | 5 --- src/slic3r/GUI/DoubleSlider.hpp | 4 -- src/slic3r/GUI/GCodeViewer.cpp | 2 - src/slic3r/GUI/GCodeViewer.hpp | 2 - src/slic3r/GUI/GUI_App.cpp | 4 -- src/slic3r/GUI/GUI_Preview.cpp | 8 ---- src/slic3r/GUI/Preferences.cpp | 4 -- src/slic3r/GUI/Preferences.hpp | 8 +--- 12 files changed, 2 insertions(+), 121 deletions(-) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 1c2e846dd..9f97bebc0 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -155,10 +155,8 @@ void AppConfig::set_defaults() if (get("seq_top_layer_only").empty()) set("seq_top_layer_only", "1"); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER if (get("seq_top_gcode_indices").empty()) set("seq_top_gcode_indices", "1"); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER if (get("use_perspective_camera").empty()) set("use_perspective_camera", "1"); diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index b24404725..d8b09dfbd 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -361,11 +361,7 @@ void GCodeProcessor::TimeProcessor::reset() machines[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)].enabled = true; } -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, std::vector& moves) -#else -void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER { boost::nowide::ifstream in(filename); if (!in.good()) @@ -443,9 +439,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) // replace placeholder lines with the proper final value auto process_placeholders = [&](const std::string& gcode_line) { -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER unsigned int extra_lines_count = 0; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER // remove trailing '\n' std::string line = gcode_line.substr(0, gcode_line.length() - 1); @@ -464,26 +458,20 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) ret += format_line_M73_main(machine.line_m73_main_mask.c_str(), (line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? 0 : 100, (line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? time_in_minutes(machine.time) : 0); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER ++extra_lines_count; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER // export remaining time to next printer stop if (line == reserved_tag(ETags::First_Line_M73_Placeholder) && !machine.stop_times.empty()) { int to_export_stop = time_in_minutes(machine.stop_times.front().elapsed_time); ret += format_line_M73_stop_int(machine.line_m73_stop_mask.c_str(), to_export_stop); last_exported_stop[i] = to_export_stop; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER ++extra_lines_count; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER } #else ret += format_line_M73(machine.line_m73_mask.c_str(), (line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? 0 : 100, (line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? time_in_minutes(machine.time) : 0); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER ++extra_lines_count; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER #endif // ENABLE_EXTENDED_M73_LINES } } @@ -518,11 +506,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) } #endif // ENABLE_VALIDATE_CUSTOM_GCODE -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER return std::tuple(!ret.empty(), ret.empty() ? gcode_line : ret, (extra_lines_count == 0) ? extra_lines_count : extra_lines_count - 1); -#else - return std::make_pair(!ret.empty(), ret.empty() ? gcode_line : ret); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER }; // check for temporary lines @@ -546,9 +530,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) // add lines M73 to exported gcode auto process_line_G1 = [&]() { -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER unsigned int exported_lines_count = 0; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER if (export_remaining_time_enabled) { for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { const TimeMachine& machine = machines[i]; @@ -566,9 +548,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) export_line += format_line_M73_main(machine.line_m73_main_mask.c_str(), to_export_main.first, to_export_main.second); last_exported_main[i] = to_export_main; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER ++exported_lines_count; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER #else float elapsed_time = it->elapsed_time; std::pair to_export = { int(100.0f * elapsed_time / machine.time), @@ -577,9 +557,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) export_line += format_line_M73(machine.line_m73_mask.c_str(), to_export.first, to_export.second); last_exported[i] = to_export; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER ++exported_lines_count; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER #endif // ENABLE_EXTENDED_M73_LINES } #if ENABLE_EXTENDED_M73_LINES @@ -593,9 +571,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) if (last_exported_stop[i] != to_export_stop) { export_line += format_line_M73_stop_int(machine.line_m73_stop_mask.c_str(), to_export_stop); last_exported_stop[i] = to_export_stop; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER ++exported_lines_count; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER } } else { @@ -620,9 +596,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) export_line += format_line_M73_stop_float(machine.line_m73_stop_mask.c_str(), time_in_last_minute(it_stop->elapsed_time - it->elapsed_time)); last_exported_stop[i] = to_export_stop; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER ++exported_lines_count; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER } } } @@ -632,9 +606,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) } } } -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER return exported_lines_count; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER }; // helper function to write to disk @@ -649,10 +621,8 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) export_line.clear(); }; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER unsigned int line_id = 0; std::vector> offsets; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER while (std::getline(in, gcode_line)) { if (!in.good()) { @@ -660,19 +630,13 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) throw Slic3r::RuntimeError(std::string("Time estimator post process export failed.\nError while reading from file.\n")); } -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER ++line_id; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER gcode_line += "\n"; // replace placeholder lines -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER auto [processed, result, lines_added_count] = process_placeholders(gcode_line); if (processed && lines_added_count > 0) offsets.push_back({ line_id, lines_added_count }); -#else - auto [processed, result] = process_placeholders(gcode_line); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER gcode_line = result; if (!processed) { // remove temporary lines @@ -683,15 +647,10 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) parser.parse_line(gcode_line, [&](GCodeReader& reader, const GCodeReader::GCodeLine& line) { if (line.cmd_is("G1")) { -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER unsigned int extra_lines_count = process_line_G1(); ++g1_lines_counter; if (extra_lines_count > 0) offsets.push_back({ line_id, extra_lines_count }); -#else - process_line_G1(); - ++g1_lines_counter; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER } }); } @@ -707,7 +666,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) fclose(out); in.close(); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER // updates moves' gcode ids which have been modified by the insertion of the M73 lines unsigned int curr_offset_id = 0; unsigned int total_offset = 0; @@ -718,7 +676,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) } move.gcode_id += total_offset; } -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER if (rename_file(out_path, filename)) throw Slic3r::RuntimeError(std::string("Failed to rename the output G-code file from ") + out_path + " to " + filename + '\n' + @@ -1214,12 +1171,10 @@ void GCodeProcessor::reset() m_cached_position.reset(); m_wiping = false; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER m_line_id = 0; #if ENABLE_SEAMS_VISUALIZATION m_last_line_id = 0; #endif // ENABLE_SEAMS_VISUALIZATION -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER m_feedrate = 0.0f; m_width = 0.0f; m_height = 0.0f; @@ -1349,11 +1304,7 @@ void GCodeProcessor::process_file(const std::string& filename, bool apply_postpr // post-process to add M73 lines into the gcode if (apply_postprocess) -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER m_time_processor.post_process(filename, m_result.moves); -#else - m_time_processor.post_process(filename); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER #if ENABLE_GCODE_VIEWER_DATA_CHECKING std::cout << "\n"; @@ -1500,9 +1451,7 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line) { /* std::cout << line.raw() << std::endl; */ -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER ++m_line_id; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER // update start position m_start_position = m_end_position; @@ -3064,13 +3013,11 @@ void GCodeProcessor::store_move_vertex(EMoveType type) #endif // ENABLE_SEAMS_VISUALIZATION MoveVertex vertex = { -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER #if ENABLE_SEAMS_VISUALIZATION m_last_line_id, #else (type == EMoveType::Color_change || type == EMoveType::Pause_Print || type == EMoveType::Custom_GCode) ? m_line_id + 1 : m_line_id, #endif // ENABLE_SEAMS_VISUALIZATION -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER type, m_extrusion_role, m_extruder_id, diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index e6073042a..d911e8b64 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -210,7 +210,6 @@ namespace Slic3r { float time() const; }; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER struct MoveVertex { unsigned int gcode_id{ 0 }; @@ -230,7 +229,6 @@ namespace Slic3r { float volumetric_rate() const { return feedrate * mm3_per_mm; } }; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER private: struct TimeMachine @@ -326,12 +324,8 @@ namespace Slic3r { void reset(); // post process the file with the given filename to add remaining time lines M73 -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER // and updates moves' gcode ids accordingly void post_process(const std::string& filename, std::vector& moves); -#else - void post_process(const std::string& filename); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER }; struct UsedFilaments // filaments per ColorChange @@ -358,27 +352,6 @@ namespace Slic3r { }; public: -#if !ENABLE_GCODE_LINES_ID_IN_H_SLIDER - struct MoveVertex - { - EMoveType type{ EMoveType::Noop }; - ExtrusionRole extrusion_role{ erNone }; - unsigned char extruder_id{ 0 }; - unsigned char cp_color_id{ 0 }; - Vec3f position{ Vec3f::Zero() }; // mm - float delta_extruder{ 0.0f }; // mm - float feedrate{ 0.0f }; // mm/s - float width{ 0.0f }; // mm - float height{ 0.0f }; // mm - float mm3_per_mm{ 0.0f }; - float fan_speed{ 0.0f }; // percentage - float temperature{ 0.0f }; // Celsius degrees - float time{ 0.0f }; // s - - float volumetric_rate() const { return feedrate * mm3_per_mm; } - }; -#endif // !ENABLE_GCODE_LINES_ID_IN_H_SLIDER - struct Result { struct SettingsIds @@ -518,12 +491,10 @@ namespace Slic3r { CachedPosition m_cached_position; bool m_wiping; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER unsigned int m_line_id; #if ENABLE_SEAMS_VISUALIZATION unsigned int m_last_line_id; #endif // ENABLE_SEAMS_VISUALIZATION -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER float m_feedrate; // mm/s float m_width; // mm float m_height; // mm diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 07a9c6571..b853f054e 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -41,8 +41,6 @@ //==================== #define ENABLE_2_4_0_ALPHA0 1 -// Enable showing gcode line numbers in preview horizontal slider -#define ENABLE_GCODE_LINES_ID_IN_H_SLIDER (1 && ENABLE_2_4_0_ALPHA0) // Enable validation of custom gcode against gcode processor reserved keywords #define ENABLE_VALIDATE_CUSTOM_GCODE (1 && ENABLE_2_4_0_ALPHA0) // Enable showing a imgui window containing gcode in preview diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index e39b40ce4..5ece82f61 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -739,16 +739,11 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer return size_t(it - m_layers_values.begin()); }; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER if (m_draw_mode == dmSequentialGCodeView) { return (Slic3r::GUI::get_app_config()->get("seq_top_gcode_indices") == "1") ? wxString::Format("%lu", static_cast(m_alternate_values[value])) : wxString::Format("%lu", static_cast(m_values[value])); } -#else - if (m_draw_mode == dmSequentialGCodeView) - return wxString::Format("%lu", static_cast(m_values[value])); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER else { if (label_type == ltEstimatedTime) { if (m_is_wipe_tower) { diff --git a/src/slic3r/GUI/DoubleSlider.hpp b/src/slic3r/GUI/DoubleSlider.hpp index 36fa7b660..601cbc708 100644 --- a/src/slic3r/GUI/DoubleSlider.hpp +++ b/src/slic3r/GUI/DoubleSlider.hpp @@ -223,9 +223,7 @@ public: void SetKoefForLabels(const double koef) { m_label_koef = koef; } void SetSliderValues(const std::vector& values); void ChangeOneLayerLock(); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER void SetSliderAlternateValues(const std::vector& values) { m_alternate_values = values; } -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER Info GetTicksValues() const; void SetTicksValues(const Info &custom_gcode_per_print_z); @@ -409,9 +407,7 @@ private: std::vector m_extruder_colors; std::string m_print_obj_idxs; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER std::vector m_alternate_values; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER // control's view variables wxCoord SLIDER_MARGIN; // margin around slider diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 51a41b046..1d7b01dda 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1443,12 +1443,10 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) m_max_bounding_box = m_paths_bounding_box; m_max_bounding_box.merge(m_paths_bounding_box.max + m_sequential_view.marker.get_bounding_box().size()[2] * Vec3d::UnitZ()); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER m_sequential_view.gcode_ids.clear(); for (const GCodeProcessor::MoveVertex& move : gcode_result.moves) { m_sequential_view.gcode_ids.push_back(move.gcode_id); } -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER std::vector vertices(m_buffers.size()); std::vector indices(m_buffers.size()); diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index b12edadc9..1942a17a8 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -574,9 +574,7 @@ public: #if ENABLE_GCODE_WINDOW GCodeWindow gcode_window; #endif // ENABLE_GCODE_WINDOW -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER std::vector gcode_ids; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER #if ENABLE_GCODE_WINDOW void render(float legend_height) const; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 4a4711972..1b71e0d8c 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1908,11 +1908,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu) PreferencesDialog dlg(mainframe); dlg.ShowModal(); app_layout_changed = dlg.settings_layout_changed(); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed()) -#else - if (dlg.seq_top_layer_only_changed()) -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER this->plater_->refresh_print(); if (dlg.recreate_GUI()) { diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 336ff8f51..7b5705c47 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -834,25 +834,17 @@ void Preview::update_moves_slider() return; std::vector values(view.endpoints.last - view.endpoints.first + 1); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER std::vector alternate_values(view.endpoints.last - view.endpoints.first + 1); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER unsigned int count = 0; for (unsigned int i = view.endpoints.first; i <= view.endpoints.last; ++i) { -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER values[count] = static_cast(i + 1); if (view.gcode_ids[i] > 0) alternate_values[count] = static_cast(view.gcode_ids[i]); ++count; -#else - values[count++] = static_cast(i + 1); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER } m_moves_slider->SetSliderValues(values); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER m_moves_slider->SetSliderAlternateValues(alternate_values); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER m_moves_slider->SetMaxValue(view.endpoints.last - view.endpoints.first); m_moves_slider->SetSelectionSpan(view.current.first - view.endpoints.first, view.current.last - view.endpoints.first); } diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 933737f2f..fe1f0eeb4 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -292,7 +292,6 @@ void PreferencesDialog::build() option = Option(def, "seq_top_layer_only"); m_optgroup_gui->append_single_option_line(option); -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER def.label = L("Sequential slider shows gcode line numbers"); def.type = coBool; def.tooltip = L("If enabled, the sequential slider, in preview, shows the gcode lines numbers." @@ -300,7 +299,6 @@ void PreferencesDialog::build() def.set_default_value(new ConfigOptionBool{ app_config->get("seq_top_gcode_indices") == "1" }); option = Option(def, "seq_top_gcode_indices"); m_optgroup_gui->append_single_option_line(option); -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER if (is_editor) { def.label = L("Show sidebar collapse/expand button"); @@ -438,11 +436,9 @@ void PreferencesDialog::accept(wxEvent&) if (auto it = m_values.find("seq_top_layer_only"); it != m_values.end()) m_seq_top_layer_only_changed = app_config->get("seq_top_layer_only") != it->second; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER m_seq_top_gcode_indices_changed = false; if (auto it = m_values.find("seq_top_gcode_indices"); it != m_values.end()) m_seq_top_gcode_indices_changed = app_config->get("seq_top_gcode_indices") != it->second; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER m_settings_layout_changed = false; for (const std::string& key : { "old_settings_layout_mode", diff --git a/src/slic3r/GUI/Preferences.hpp b/src/slic3r/GUI/Preferences.hpp index 92e54ec9c..5c0f1a6d5 100644 --- a/src/slic3r/GUI/Preferences.hpp +++ b/src/slic3r/GUI/Preferences.hpp @@ -29,9 +29,7 @@ class PreferencesDialog : public DPIDialog bool isOSX {false}; bool m_settings_layout_changed {false}; bool m_seq_top_layer_only_changed{ false }; -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER bool m_seq_top_gcode_indices_changed{ false }; -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER bool m_recreate_GUI{false}; public: @@ -40,12 +38,10 @@ public: bool settings_layout_changed() const { return m_settings_layout_changed; } bool seq_top_layer_only_changed() const { return m_seq_top_layer_only_changed; } -#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER bool seq_seq_top_gcode_indices_changed() const { return m_seq_top_gcode_indices_changed; } -#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER bool recreate_GUI() const { return m_recreate_GUI; } - void build(); - void accept(wxEvent&); + void build(); + void accept(wxEvent&); protected: void on_dpi_changed(const wxRect &suggested_rect) override; From 5faac3c1057d7f83f6d9744dc33936e6fc05b383 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 22 Jul 2021 09:13:12 +0200 Subject: [PATCH 3/8] Tech ENABLE_VALIDATE_CUSTOM_GCODE set as default --- src/libslic3r/GCode.cpp | 64 ------------- src/libslic3r/GCode/GCodeProcessor.cpp | 123 ------------------------- src/libslic3r/GCode/GCodeProcessor.hpp | 18 +--- src/libslic3r/GCode/WipeTower.cpp | 9 -- src/libslic3r/GCodeReader.cpp | 5 - src/libslic3r/GCodeReader.hpp | 12 --- src/libslic3r/Technologies.hpp | 4 +- src/slic3r/GUI/DoubleSlider.cpp | 7 -- src/slic3r/GUI/MainFrame.cpp | 2 - src/slic3r/GUI/Tab.cpp | 30 ------ src/slic3r/GUI/Tab.hpp | 6 +- 11 files changed, 3 insertions(+), 277 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 24bd4939f..28cd8808f 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -172,11 +172,7 @@ namespace Slic3r { // subdivide the retraction in segments if (!wipe_path.empty()) { // add tag for processor -#if ENABLE_VALIDATE_CUSTOM_GCODE gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_Start) + "\n"; -#else - gcode += ";" + GCodeProcessor::Wipe_Start_Tag + "\n"; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE for (const Line& line : wipe_path.lines()) { double segment_length = line.length(); /* Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one @@ -192,11 +188,7 @@ namespace Slic3r { ); } // add tag for processor -#if ENABLE_VALIDATE_CUSTOM_GCODE gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_End) + "\n"; -#else - gcode += ";" + GCodeProcessor::Wipe_End_Tag + "\n"; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE gcodegen.set_last_pos(wipe_path.points.back()); } @@ -655,7 +647,6 @@ namespace DoExport { print_statistics.filament_stats = result.print_statistics.volumes_per_extruder; } -#if ENABLE_VALIDATE_CUSTOM_GCODE // if any reserved keyword is found, returns a std::vector containing the first MAX_COUNT keywords found // into pairs containing: // first: source @@ -714,7 +705,6 @@ namespace DoExport { return ret; } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE } // namespace DoExport void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* result, ThumbnailsGeneratorCallback thumbnail_cb) @@ -729,7 +719,6 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* re print->set_started(psGCodeExport); -#if ENABLE_VALIDATE_CUSTOM_GCODE // check if any custom gcode contains keywords used by the gcode processor to // produce time estimation and gcode toolpaths std::vector> validation_res = DoExport::validate_custom_gcode(*print); @@ -743,7 +732,6 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* re reports + _(L("This may cause problems in g-code visualization and printing time estimation."))); } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE BOOST_LOG_TRIVIAL(info) << "Exporting G-code..." << log_memory_info(); @@ -1168,11 +1156,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu // adds tags for time estimators if (print.config().remaining_times.value) -#if ENABLE_VALIDATE_CUSTOM_GCODE _write_format(file, ";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::First_Line_M73_Placeholder).c_str()); -#else - _writeln(file, GCodeProcessor::First_Line_M73_Placeholder_Tag); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE // Prepare the helper object for replacing placeholders in custom G-code and output filename. m_placeholder_parser = print.placeholder_parser(); @@ -1279,11 +1263,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, false); // adds tag for processor -#if ENABLE_VALIDATE_CUSTOM_GCODE _write_format(file, ";%s%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role).c_str(), ExtrusionEntity::role_to_string(erCustom).c_str()); -#else - _write_format(file, ";%s%s\n", GCodeProcessor::Extrusion_Role_Tag.c_str(), ExtrusionEntity::role_to_string(erCustom).c_str()); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE // Write the custom start G-code _writeln(file, start_gcode); @@ -1444,11 +1424,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu _write(file, m_writer.set_fan(false)); // adds tag for processor -#if ENABLE_VALIDATE_CUSTOM_GCODE _write_format(file, ";%s%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role).c_str(), ExtrusionEntity::role_to_string(erCustom).c_str()); -#else - _write_format(file, ";%s%s\n", GCodeProcessor::Extrusion_Role_Tag.c_str(), ExtrusionEntity::role_to_string(erCustom).c_str()); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE // Process filament-specific gcode in extruder order. { @@ -1475,11 +1451,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu // adds tags for time estimators if (print.config().remaining_times.value) -#if ENABLE_VALIDATE_CUSTOM_GCODE _write_format(file, ";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Last_Line_M73_Placeholder).c_str()); -#else - _writeln(file, GCodeProcessor::Last_Line_M73_Placeholder_Tag); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE print.throw_if_canceled(); @@ -1495,11 +1467,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu _write_format(file, "; total filament cost = %.2lf\n", print.m_print_statistics.total_cost); if (print.m_print_statistics.total_toolchanges > 0) _write_format(file, "; total toolchanges = %i\n", print.m_print_statistics.total_toolchanges); -#if ENABLE_VALIDATE_CUSTOM_GCODE _write_format(file, ";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str()); -#else - _writeln(file, GCodeProcessor::Estimated_Printing_Time_Placeholder_Tag); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE // Append full config. _write(file, "\n"); @@ -1799,11 +1767,7 @@ namespace ProcessLayer assert(m600_extruder_before_layer >= 0); // Color Change or Tool Change as Color Change. // add tag for processor -#if ENABLE_VALIDATE_CUSTOM_GCODE gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Color_Change) + ",T" + std::to_string(m600_extruder_before_layer) + "\n"; -#else - gcode += ";" + GCodeProcessor::Color_Change_Tag + ",T" + std::to_string(m600_extruder_before_layer) + "\n"; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE if (!single_extruder_printer && m600_extruder_before_layer >= 0 && first_extruder_id != (unsigned)m600_extruder_before_layer // && !MMU1 @@ -1828,11 +1792,7 @@ namespace ProcessLayer if (gcode_type == CustomGCode::PausePrint) // Pause print { // add tag for processor -#if ENABLE_VALIDATE_CUSTOM_GCODE gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Pause_Print) + "\n"; -#else - gcode += ";" + GCodeProcessor::Pause_Print_Tag + "\n"; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE //! FIXME_in_fw show message during print pause if (!pause_print_msg.empty()) gcode += "M117 " + pause_print_msg + "\n"; @@ -1840,11 +1800,7 @@ namespace ProcessLayer } else { // add tag for processor -#if ENABLE_VALIDATE_CUSTOM_GCODE gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Custom_Code) + "\n"; -#else - gcode += ";" + GCodeProcessor::Custom_Code_Tag + "\n"; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE if (gcode_type == CustomGCode::Template) // Template Custom Gcode gcode += gcodegen.placeholder_parser_process("template_custom_gcode", config.template_custom_gcode, current_extruder_id); else // custom Gcode @@ -1991,22 +1947,14 @@ void GCode::process_layer( assert(is_decimal_separator_point()); // for the sprintfs // add tag for processor -#if ENABLE_VALIDATE_CUSTOM_GCODE gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Layer_Change) + "\n"; -#else - gcode += ";" + GCodeProcessor::Layer_Change_Tag + "\n"; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE // export layer z char buf[64]; sprintf(buf, ";Z:%g\n", print_z); gcode += buf; // export layer height float height = first_layer ? static_cast(print_z) : static_cast(print_z) - m_last_layer_z; -#if ENABLE_VALIDATE_CUSTOM_GCODE sprintf(buf, ";%s%g\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Height).c_str(), height); -#else - sprintf(buf, ";%s%g\n", GCodeProcessor::Height_Tag.c_str(), height); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE gcode += buf; // update caches m_last_layer_z = static_cast(print_z); @@ -2835,21 +2783,13 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, if (path.role() != m_last_processor_extrusion_role) { m_last_processor_extrusion_role = path.role(); -#if ENABLE_VALIDATE_CUSTOM_GCODE sprintf(buf, ";%s%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role).c_str(), ExtrusionEntity::role_to_string(m_last_processor_extrusion_role).c_str()); -#else - sprintf(buf, ";%s%s\n", GCodeProcessor::Extrusion_Role_Tag.c_str(), ExtrusionEntity::role_to_string(m_last_processor_extrusion_role).c_str()); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE gcode += buf; } if (last_was_wipe_tower || m_last_width != path.width) { m_last_width = path.width; -#if ENABLE_VALIDATE_CUSTOM_GCODE sprintf(buf, ";%s%g\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Width).c_str(), m_last_width); -#else - sprintf(buf, ";%s%g\n", GCodeProcessor::Width_Tag.c_str(), m_last_width); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE gcode += buf; } @@ -2863,11 +2803,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, if (last_was_wipe_tower || std::abs(m_last_height - path.height) > EPSILON) { m_last_height = path.height; -#if ENABLE_VALIDATE_CUSTOM_GCODE sprintf(buf, ";%s%g\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Height).c_str(), m_last_height); -#else - sprintf(buf, ";%s%g\n", GCodeProcessor::Height_Tag.c_str(), m_last_height); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE gcode += buf; } diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index d8b09dfbd..ae50024d1 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -5,9 +5,7 @@ #include "GCodeProcessor.hpp" #include -#if ENABLE_VALIDATE_CUSTOM_GCODE #include -#endif // ENABLE_VALIDATE_CUSTOM_GCODE #include #include #include @@ -37,7 +35,6 @@ static const Slic3r::Vec3f DEFAULT_EXTRUDER_OFFSET = Slic3r::Vec3f::Zero(); namespace Slic3r { -#if ENABLE_VALIDATE_CUSTOM_GCODE const std::vector GCodeProcessor::Reserved_Tags = { "TYPE:", "WIPE_START", @@ -52,21 +49,6 @@ const std::vector GCodeProcessor::Reserved_Tags = { "_GP_LAST_LINE_M73_PLACEHOLDER", "_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER" }; -#else -const std::string GCodeProcessor::Extrusion_Role_Tag = "TYPE:"; -const std::string GCodeProcessor::Wipe_Start_Tag = "WIPE_START"; -const std::string GCodeProcessor::Wipe_End_Tag = "WIPE_END"; -const std::string GCodeProcessor::Height_Tag = "HEIGHT:"; -const std::string GCodeProcessor::Width_Tag = "WIDTH:"; -const std::string GCodeProcessor::Layer_Change_Tag = "LAYER_CHANGE"; -const std::string GCodeProcessor::Color_Change_Tag = "COLOR_CHANGE"; -const std::string GCodeProcessor::Pause_Print_Tag = "PAUSE_PRINT"; -const std::string GCodeProcessor::Custom_Code_Tag = "CUSTOM_GCODE"; - -const std::string GCodeProcessor::First_Line_M73_Placeholder_Tag = "; _GP_FIRST_LINE_M73_PLACEHOLDER"; -const std::string GCodeProcessor::Last_Line_M73_Placeholder_Tag = "; _GP_LAST_LINE_M73_PLACEHOLDER"; -const std::string GCodeProcessor::Estimated_Printing_Time_Placeholder_Tag = "; _GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER"; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE const float GCodeProcessor::Wipe_Width = 0.05f; const float GCodeProcessor::Wipe_Height = 0.05f; @@ -445,7 +427,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st std::string line = gcode_line.substr(0, gcode_line.length() - 1); std::string ret; -#if ENABLE_VALIDATE_CUSTOM_GCODE if (line.length() > 1) { line = line.substr(1); if (export_remaining_time_enabled && @@ -477,19 +458,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st } } else if (line == reserved_tag(ETags::Estimated_Printing_Time_Placeholder)) { -#else - if (export_remaining_time_enabled && (line == First_Line_M73_Placeholder_Tag || line == Last_Line_M73_Placeholder_Tag)) { - for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { - const TimeMachine& machine = machines[i]; - if (machine.enabled) { - ret += format_line_M73(machine.line_m73_mask.c_str(), - (line == First_Line_M73_Placeholder_Tag) ? 0 : 100, - (line == First_Line_M73_Placeholder_Tag) ? time_in_minutes(machines[i].time) : 0); - } - } - } - else if (line == Estimated_Printing_Time_Placeholder_Tag) { -#endif // ENABLE_VALIDATE_CUSTOM_GCODE for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { const TimeMachine& machine = machines[i]; PrintEstimatedStatistics::ETimeMode mode = static_cast(i); @@ -502,9 +470,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st } } } -#if ENABLE_VALIDATE_CUSTOM_GCODE } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE return std::tuple(!ret.empty(), ret.empty() ? gcode_line : ret, (extra_lines_count == 0) ? extra_lines_count : extra_lines_count - 1); }; @@ -784,7 +750,6 @@ const std::vector> GCodeProces unsigned int GCodeProcessor::s_result_id = 0; -#if ENABLE_VALIDATE_CUSTOM_GCODE bool GCodeProcessor::contains_reserved_tag(const std::string& gcode, std::string& found_tag) { bool ret = false; @@ -836,7 +801,6 @@ bool GCodeProcessor::contains_reserved_tags(const std::string& gcode, unsigned i return ret; } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE GCodeProcessor::GCodeProcessor() { @@ -1239,11 +1203,7 @@ void GCodeProcessor::process_file(const std::string& filename, bool apply_postpr if (cmd.length() == 0) { const std::string_view comment = line.comment(); if (comment.length() > 1 && detect_producer(comment)) -#if ENABLE_VALIDATE_CUSTOM_GCODE m_parser.quit_parsing(); -#else - m_parser.quit_parsing_file(); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE } }); @@ -1576,7 +1536,6 @@ void GCodeProcessor::process_tags(const std::string_view comment) if (m_producers_enabled && process_producers_tags(comment)) return; -#if ENABLE_VALIDATE_CUSTOM_GCODE // extrusion role tag if (boost::starts_with(comment, reserved_tag(ETags::Role))) { set_extrusion_role(ExtrusionEntity::string_to_role(comment.substr(reserved_tag(ETags::Role).length()))); @@ -1601,28 +1560,8 @@ void GCodeProcessor::process_tags(const std::string_view comment) m_wiping = false; return; } -#else - // extrusion role tag - if (boost::starts_with(comment, Extrusion_Role_Tag)) { - set_extrusion_role(ExtrusionEntity::string_to_role(comment.substr(Extrusion_Role_Tag.length()))); - return; - } - - // wipe start tag - if (boost::starts_with(comment, Wipe_Start_Tag)) { - m_wiping = true; - return; - } - - // wipe end tag - if (boost::starts_with(comment, Wipe_End_Tag)) { - m_wiping = false; - return; - } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE if (!m_producers_enabled || m_producer == EProducer::PrusaSlicer) { -#if ENABLE_VALIDATE_CUSTOM_GCODE // height tag if (boost::starts_with(comment, reserved_tag(ETags::Height))) { if (!parse_number(comment.substr(reserved_tag(ETags::Height).size()), m_forced_height)) @@ -1635,23 +1574,8 @@ void GCodeProcessor::process_tags(const std::string_view comment) BOOST_LOG_TRIVIAL(error) << "GCodeProcessor encountered an invalid value for Width (" << comment << ")."; return; } -#else - // height tag - if (boost::starts_with(comment, Height_Tag)) { - if (!parse_number(comment.substr(Height_Tag.size()), m_forced_height)) - BOOST_LOG_TRIVIAL(error) << "GCodeProcessor encountered an invalid value for Height (" << comment << ")."; - return; - } - // width tag - if (boost::starts_with(comment, Width_Tag)) { - if (!parse_number(comment.substr(Width_Tag.size()), m_forced_width)) - BOOST_LOG_TRIVIAL(error) << "GCodeProcessor encountered an invalid value for Width (" << comment << ")."; - return; - } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE } -#if ENABLE_VALIDATE_CUSTOM_GCODE // color change tag if (boost::starts_with(comment, reserved_tag(ETags::Color_Change))) { unsigned char extruder_id = 0; @@ -1699,53 +1623,6 @@ void GCodeProcessor::process_tags(const std::string_view comment) ++m_layer_id; return; } -#else - // color change tag - if (boost::starts_with(comment, Color_Change_Tag)) { - unsigned char extruder_id = 0; - if (boost::starts_with(comment.substr(Color_Change_Tag.size()), ",T")) { - int eid; - if (! parse_number(comment.substr(Color_Change_Tag.size() + 2), eid) || eid < 0 || eid > 255) { - BOOST_LOG_TRIVIAL(error) << "GCodeProcessor encountered an invalid value for Color_Change (" << comment << ")."; - return; - } - extruder_id = static_cast(eid); - } - - m_extruder_colors[extruder_id] = static_cast(m_extruder_offsets.size()) + m_cp_color.counter; // color_change position in list of color for preview - ++m_cp_color.counter; - if (m_cp_color.counter == UCHAR_MAX) - m_cp_color.counter = 0; - - if (m_extruder_id == extruder_id) { - m_cp_color.current = m_extruder_colors[extruder_id]; - store_move_vertex(EMoveType::Color_change); - } - - process_custom_gcode_time(CustomGCode::ColorChange); - - return; - } - - // pause print tag - if (comment == Pause_Print_Tag) { - store_move_vertex(EMoveType::Pause_Print); - process_custom_gcode_time(CustomGCode::PausePrint); - return; - } - - // custom code tag - if (comment == Custom_Code_Tag) { - store_move_vertex(EMoveType::Custom_GCode); - return; - } - - // layer change tag - if (comment == Layer_Change_Tag) { - ++m_layer_id; - return; - } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE #if ENABLE_GCODE_VIEWER_DATA_CHECKING // mm3_per_mm print tag diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index d911e8b64..c9aff8713 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -82,11 +82,9 @@ namespace Slic3r { class GCodeProcessor { -#if ENABLE_VALIDATE_CUSTOM_GCODE static const std::vector Reserved_Tags; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE + public: -#if ENABLE_VALIDATE_CUSTOM_GCODE enum class ETags : unsigned char { Role, @@ -109,20 +107,6 @@ namespace Slic3r { // checks the given gcode for reserved tags and returns true when finding any // (the first max_count found tags are returned into found_tag) static bool contains_reserved_tags(const std::string& gcode, unsigned int max_count, std::vector& found_tag); -#else - static const std::string Extrusion_Role_Tag; - static const std::string Wipe_Start_Tag; - static const std::string Wipe_End_Tag; - static const std::string Height_Tag; - static const std::string Layer_Change_Tag; - static const std::string Color_Change_Tag; - static const std::string Pause_Print_Tag; - static const std::string Custom_Code_Tag; - static const std::string First_Line_M73_Placeholder_Tag; - static const std::string Last_Line_M73_Placeholder_Tag; - static const std::string Estimated_Printing_Time_Placeholder_Tag; - static const std::string Width_Tag; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE static const float Wipe_Width; static const float Wipe_Height; diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 5e1937ad8..577ce9e34 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -34,13 +34,8 @@ public: { // adds tag for analyzer: std::ostringstream str; -#if ENABLE_VALIDATE_CUSTOM_GCODE str << ";" << GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Height) << m_layer_height << "\n"; // don't rely on GCodeAnalyzer knowing the layer height - it knows nothing at priming str << ";" << GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role) << ExtrusionEntity::role_to_string(erWipeTower) << "\n"; -#else - str << ";" << GCodeProcessor::Height_Tag << m_layer_height << "\n"; // don't rely on GCodeAnalyzer knowing the layer height - it knows nothing at priming - str << ";" << GCodeProcessor::Extrusion_Role_Tag << ExtrusionEntity::role_to_string(erWipeTower) << "\n"; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE m_gcode += str.str(); change_analyzer_line_width(line_width); } @@ -48,11 +43,7 @@ public: WipeTowerWriter& change_analyzer_line_width(float line_width) { // adds tag for analyzer: std::stringstream str; -#if ENABLE_VALIDATE_CUSTOM_GCODE str << ";" << GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Width) << line_width << "\n"; -#else - str << ";" << GCodeProcessor::Width_Tag << line_width << "\n"; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE m_gcode += str.str(); return *this; } diff --git a/src/libslic3r/GCodeReader.cpp b/src/libslic3r/GCodeReader.cpp index efc9ace6d..3c76e05c7 100644 --- a/src/libslic3r/GCodeReader.cpp +++ b/src/libslic3r/GCodeReader.cpp @@ -120,13 +120,8 @@ void GCodeReader::parse_file(const std::string &file, callback_t callback) { boost::nowide::ifstream f(file); std::string line; -#if ENABLE_VALIDATE_CUSTOM_GCODE m_parsing = true; while (m_parsing && std::getline(f, line)) -#else - m_parsing_file = true; - while (m_parsing_file && std::getline(f, line)) -#endif // ENABLE_VALIDATE_CUSTOM_GCODE this->parse_line(line, callback); } diff --git a/src/libslic3r/GCodeReader.hpp b/src/libslic3r/GCodeReader.hpp index 54e193799..ad9b7195a 100644 --- a/src/libslic3r/GCodeReader.hpp +++ b/src/libslic3r/GCodeReader.hpp @@ -84,12 +84,8 @@ public: { const char *ptr = buffer.c_str(); GCodeLine gline; -#if ENABLE_VALIDATE_CUSTOM_GCODE m_parsing = true; while (m_parsing && *ptr != 0) { -#else - while (*ptr != 0) { -#endif // ENABLE_VALIDATE_CUSTOM_GCODE gline.reset(); ptr = this->parse_line(ptr, gline, callback); } @@ -113,11 +109,7 @@ public: { GCodeLine gline; this->parse_line(line.c_str(), gline, callback); } void parse_file(const std::string &file, callback_t callback); -#if ENABLE_VALIDATE_CUSTOM_GCODE void quit_parsing() { m_parsing = false; } -#else - void quit_parsing_file() { m_parsing_file = false; } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE float& x() { return m_position[X]; } float x() const { return m_position[X]; } @@ -156,11 +148,7 @@ private: char m_extrusion_axis; float m_position[NUM_AXES]; bool m_verbose; -#if ENABLE_VALIDATE_CUSTOM_GCODE bool m_parsing{ false }; -#else - bool m_parsing_file{ false }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE }; } /* namespace Slic3r */ diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index b853f054e..128cb1d65 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -41,12 +41,10 @@ //==================== #define ENABLE_2_4_0_ALPHA0 1 -// Enable validation of custom gcode against gcode processor reserved keywords -#define ENABLE_VALIDATE_CUSTOM_GCODE (1 && ENABLE_2_4_0_ALPHA0) // Enable showing a imgui window containing gcode in preview #define ENABLE_GCODE_WINDOW (1 && ENABLE_2_4_0_ALPHA0) // Enable exporting lines M73 for remaining time to next printer stop to gcode -#define ENABLE_EXTENDED_M73_LINES (1 && ENABLE_VALIDATE_CUSTOM_GCODE) +#define ENABLE_EXTENDED_M73_LINES (1 && ENABLE_2_4_0_ALPHA0) // Enable a modified version of automatic downscale on load of objects too big #define ENABLE_MODIFIED_DOWNSCALE_ON_LOAD_OBJECTS_TOO_BIG (1 && ENABLE_2_4_0_ALPHA0) // Enable scrollable legend in preview diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 5ece82f61..597736b19 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -2175,7 +2175,6 @@ static std::string get_custom_code(const std::string& code_in, double height) wxTextEntryDialogStyle | wxTE_MULTILINE); upgrade_text_entry_dialog(&dlg); -#if ENABLE_VALIDATE_CUSTOM_GCODE bool valid = true; std::string value; do { @@ -2186,12 +2185,6 @@ static std::string get_custom_code(const std::string& code_in, double height) valid = GUI::Tab::validate_custom_gcode("Custom G-code", value); } while (!valid); return value; -#else - if (dlg.ShowModal() != wxID_OK) - return ""; - - return into_u8(dlg.GetValue()); -#endif // ENABLE_VALIDATE_CUSTOM_GCODE } static std::string get_pause_print_msg(const std::string& msg_in, double height) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 8614acf68..a95a5d0ef 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -675,14 +675,12 @@ void MainFrame::init_tabpanel() #else m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxBookCtrlEvent& e) { #endif -#if ENABLE_VALIDATE_CUSTOM_GCODE if (int old_selection = e.GetOldSelection(); old_selection != wxNOT_FOUND && old_selection < static_cast(m_tabpanel->GetPageCount())) { Tab* old_tab = dynamic_cast(m_tabpanel->GetPage(old_selection)); if (old_tab) old_tab->validate_custom_gcodes(); } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE wxWindow* panel = m_tabpanel->GetCurrentPage(); Tab* tab = dynamic_cast(panel); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 99c1e1598..f712615c5 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -5,9 +5,7 @@ #include "libslic3r/PresetBundle.hpp" #include "libslic3r/Utils.hpp" #include "libslic3r/Model.hpp" -#if ENABLE_VALIDATE_CUSTOM_GCODE #include "libslic3r/GCode/GCodeProcessor.hpp" -#endif // ENABLE_VALIDATE_CUSTOM_GCODE #include "slic3r/Utils/Http.hpp" #include "slic3r/Utils/PrintHost.hpp" @@ -1744,7 +1742,6 @@ void TabPrint::clear_pages() m_top_bottom_shell_thickness_explanation = nullptr; } -#if ENABLE_VALIDATE_CUSTOM_GCODE bool Tab::validate_custom_gcode(const wxString& title, const std::string& gcode) { std::vector tags; @@ -1770,7 +1767,6 @@ static void validate_custom_gcode_cb(Tab* tab, ConfigOptionsGroupShp opt_group, tab->update_dirty(); tab->on_value_change(opt_key, value); } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE void TabFilament::add_filament_overrides_page() { @@ -1996,11 +1992,9 @@ void TabFilament::build() page = add_options_page(L("Custom G-code"), "cog"); optgroup = page->new_optgroup(L("Start G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("start_filament_gcode"); option.opt.full_width = true; option.opt.is_code = true; @@ -2008,11 +2002,9 @@ void TabFilament::build() optgroup->append_single_option_line(option); optgroup = page->new_optgroup(L("End G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("end_filament_gcode"); option.opt.full_width = true; option.opt.is_code = true; @@ -2323,11 +2315,9 @@ void TabPrinter::build_fff() const int notes_field_height = 25; // 250 page = add_options_page(L("Custom G-code"), "cog"); optgroup = page->new_optgroup(L("Start G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("start_gcode"); option.opt.full_width = true; option.opt.is_code = true; @@ -2335,11 +2325,9 @@ void TabPrinter::build_fff() optgroup->append_single_option_line(option); optgroup = page->new_optgroup(L("End G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("end_gcode"); option.opt.full_width = true; option.opt.is_code = true; @@ -2347,11 +2335,9 @@ void TabPrinter::build_fff() optgroup->append_single_option_line(option); optgroup = page->new_optgroup(L("Before layer change G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("before_layer_gcode"); option.opt.full_width = true; option.opt.is_code = true; @@ -2359,11 +2345,9 @@ void TabPrinter::build_fff() optgroup->append_single_option_line(option); optgroup = page->new_optgroup(L("After layer change G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("layer_gcode"); option.opt.full_width = true; option.opt.is_code = true; @@ -2371,11 +2355,9 @@ void TabPrinter::build_fff() optgroup->append_single_option_line(option); optgroup = page->new_optgroup(L("Tool change G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("toolchange_gcode"); option.opt.full_width = true; option.opt.is_code = true; @@ -2383,11 +2365,9 @@ void TabPrinter::build_fff() optgroup->append_single_option_line(option); optgroup = page->new_optgroup(L("Between objects G-code (for sequential printing)"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("between_objects_gcode"); option.opt.full_width = true; option.opt.is_code = true; @@ -2395,33 +2375,27 @@ void TabPrinter::build_fff() optgroup->append_single_option_line(option); optgroup = page->new_optgroup(L("Color Change G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("color_change_gcode"); option.opt.is_code = true; option.opt.height = gcode_field_height;//150; optgroup->append_single_option_line(option); optgroup = page->new_optgroup(L("Pause Print G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("pause_print_gcode"); option.opt.is_code = true; option.opt.height = gcode_field_height;//150; optgroup->append_single_option_line(option); optgroup = page->new_optgroup(L("Template Custom G-code"), 0); -#if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup, opt_key, value); }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("template_custom_gcode"); option.opt.is_code = true; option.opt.height = gcode_field_height;//150; @@ -3904,7 +3878,6 @@ void TabPrinter::apply_extruder_cnt_from_cache() } } -#if ENABLE_VALIDATE_CUSTOM_GCODE bool Tab::validate_custom_gcodes() { if (m_type != Preset::TYPE_FILAMENT && @@ -3930,7 +3903,6 @@ bool Tab::validate_custom_gcodes() } return valid; } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE void TabPrinter::update_machine_limits_description(const MachineLimitsUsage usage) { @@ -4157,7 +4129,6 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la return optgroup; } -#if ENABLE_VALIDATE_CUSTOM_GCODE const ConfigOptionsGroupShp Page::get_optgroup(const wxString& title) const { for (ConfigOptionsGroupShp optgroup : m_optgroups) { @@ -4167,7 +4138,6 @@ const ConfigOptionsGroupShp Page::get_optgroup(const wxString& title) const return nullptr; } -#endif // ENABLE_VALIDATE_CUSTOM_GCODE void TabSLAMaterial::build() { diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 80b9cd873..5f6ed10aa 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -79,9 +79,7 @@ public: Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const; bool set_value(const t_config_option_key& opt_key, const boost::any& value); ConfigOptionsGroupShp new_optgroup(const wxString& title, int noncommon_label_width = -1); -#if ENABLE_VALIDATE_CUSTOM_GCODE const ConfigOptionsGroupShp get_optgroup(const wxString& title) const; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE bool set_item_colour(const wxColour *clr) { if (m_item_color != clr) { @@ -357,11 +355,9 @@ public: const std::map& get_category_icon_map() { return m_category_icon; } -#if ENABLE_VALIDATE_CUSTOM_GCODE static bool validate_custom_gcode(const wxString& title, const std::string& gcode); bool validate_custom_gcodes(); - bool validate_custom_gcodes_was_shown { false }; -#endif // ENABLE_VALIDATE_CUSTOM_GCODE + bool validate_custom_gcodes_was_shown{ false }; protected: void create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, const wxString& path, widget_t widget); From 7817105abeb227b0550f73ced2ad77d03452e58f Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 22 Jul 2021 09:37:02 +0200 Subject: [PATCH 4/8] Tech ENABLE_GCODE_WINDOW set as default --- src/libslic3r/GCode.cpp | 5 ----- src/libslic3r/GCode/GCodeProcessor.cpp | 4 ---- src/libslic3r/GCode/GCodeProcessor.hpp | 2 -- src/libslic3r/Technologies.hpp | 2 -- src/slic3r/GUI/BackgroundSlicingProcess.cpp | 4 ---- src/slic3r/GUI/GCodeViewer.cpp | 24 --------------------- src/slic3r/GUI/GCodeViewer.hpp | 14 ------------ src/slic3r/GUI/GLCanvas3D.cpp | 4 ---- src/slic3r/GUI/GLCanvas3D.hpp | 2 -- src/slic3r/GUI/KBShortcutsDialog.cpp | 2 -- src/slic3r/GUI/Plater.cpp | 2 -- src/slic3r/GUI/Plater.hpp | 2 -- 12 files changed, 67 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 28cd8808f..6f4523375 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -782,16 +782,11 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* re m_processor.process_file(path_tmp, true, [print]() { print->throw_if_canceled(); }); // DoExport::update_print_estimated_times_stats(m_processor, print->m_print_statistics); DoExport::update_print_estimated_stats(m_processor, m_writer.extruders(), print->m_print_statistics); -#if ENABLE_GCODE_WINDOW if (result != nullptr) { *result = std::move(m_processor.extract_result()); // set the filename to the correct value result->filename = path; } -#else - if (result != nullptr) - *result = std::move(m_processor.extract_result()); -#endif // ENABLE_GCODE_WINDOW BOOST_LOG_TRIVIAL(debug) << "Finished processing gcode, " << log_memory_info(); if (rename_file(path_tmp, path)) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index ae50024d1..72ac9ea42 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -9,9 +9,7 @@ #include #include #include -#if ENABLE_GCODE_WINDOW #include -#endif // ENABLE_GCODE_WINDOW #include #include @@ -1223,9 +1221,7 @@ void GCodeProcessor::process_file(const std::string& filename, bool apply_postpr } // process gcode -#if ENABLE_GCODE_WINDOW m_result.filename = filename; -#endif // ENABLE_GCODE_WINDOW m_result.id = ++s_result_id; // 1st move must be a dummy move m_result.moves.emplace_back(MoveVertex()); diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index c9aff8713..c8dab857a 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -350,9 +350,7 @@ namespace Slic3r { printer = ""; } }; -#if ENABLE_GCODE_WINDOW std::string filename; -#endif // ENABLE_GCODE_WINDOW unsigned int id; std::vector moves; Pointfs bed_shape; diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 128cb1d65..8e18cda22 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -41,8 +41,6 @@ //==================== #define ENABLE_2_4_0_ALPHA0 1 -// Enable showing a imgui window containing gcode in preview -#define ENABLE_GCODE_WINDOW (1 && ENABLE_2_4_0_ALPHA0) // Enable exporting lines M73 for remaining time to next printer stop to gcode #define ENABLE_EXTENDED_M73_LINES (1 && ENABLE_2_4_0_ALPHA0) // Enable a modified version of automatic downscale on load of objects too big diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index 5503eefbf..c48b8f2aa 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -155,19 +155,15 @@ void BackgroundSlicingProcess::process_fff() if (! m_export_path.empty()) { wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_export_began_id)); -#if ENABLE_GCODE_WINDOW // let the gcode window to unmap the temporary .gcode file (m_temp_output_path) // because the scripts may want to modify it GUI::wxGetApp().plater()->stop_mapping_gcode_window(); -#endif // ENABLE_GCODE_WINDOW m_print->set_status(95, _utf8(L("Running post-processing scripts"))); run_post_process_scripts(m_temp_output_path, m_fff_print->full_print_config()); -#if ENABLE_GCODE_WINDOW // let the gcode window to reload and remap the temporary .gcode file (m_temp_output_path) GUI::wxGetApp().plater()->start_mapping_gcode_window(); -#endif // ENABLE_GCODE_WINDOW //FIXME localize the messages // Perform the final post-processing of the export path by applying the print statistics over the file name. diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 1d7b01dda..51b29befa 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -23,9 +23,7 @@ #include #include -#if ENABLE_GCODE_WINDOW #include -#endif // ENABLE_GCODE_WINDOW #include #include #include @@ -269,7 +267,6 @@ void GCodeViewer::SequentialView::Marker::render() const ImGui::PopStyleVar(); } -#if ENABLE_GCODE_WINDOW void GCodeViewer::SequentialView::GCodeWindow::load_gcode() { if (m_filename.empty()) @@ -487,7 +484,6 @@ void GCodeViewer::SequentialView::render(float legend_height) const bottom -= wxGetApp().plater()->get_view_toolbar().get_height(); gcode_window.render(legend_height, bottom, static_cast(gcode_ids[current.last])); } -#endif // ENABLE_GCODE_WINDOW const std::vector GCodeViewer::Extrusion_Role_Colors {{ { 0.75f, 0.75f, 0.75f }, // erNone @@ -599,10 +595,8 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print& // release gpu memory, if used reset(); -#if ENABLE_GCODE_WINDOW m_sequential_view.gcode_window.set_filename(gcode_result.filename); m_sequential_view.gcode_window.load_gcode(); -#endif // ENABLE_GCODE_WINDOW load_toolpaths(gcode_result); @@ -761,9 +755,7 @@ void GCodeViewer::reset() m_layers_z_range = { 0, 0 }; m_roles = std::vector(); m_print_statistics.reset(); -#if ENABLE_GCODE_WINDOW m_sequential_view.gcode_window.reset(); -#endif // ENABLE_GCODE_WINDOW #if ENABLE_GCODE_VIEWER_STATISTICS m_statistics.reset_all(); #endif // ENABLE_GCODE_VIEWER_STATISTICS @@ -832,20 +824,12 @@ void GCodeViewer::render() const glsafe(::glEnable(GL_DEPTH_TEST)); render_toolpaths(); render_shells(); -#if ENABLE_GCODE_WINDOW float legend_height = 0.0f; render_legend(legend_height); -#else - render_legend(); -#endif // ENABLE_GCODE_WINDOW SequentialView* sequential_view = const_cast(&m_sequential_view); if (sequential_view->current.last != sequential_view->endpoints.last) { sequential_view->marker.set_world_position(sequential_view->current_position); -#if ENABLE_GCODE_WINDOW sequential_view->render(legend_height); -#else - sequential_view->marker.render(); -#endif // ENABLE_GCODE_WINDOW } #if ENABLE_GCODE_VIEWER_STATISTICS render_statistics(); @@ -1122,7 +1106,6 @@ void GCodeViewer::export_toolpaths_to_obj(const char* filename) const fclose(fp); } -#if ENABLE_GCODE_WINDOW void GCodeViewer::start_mapping_gcode_window() { m_sequential_view.gcode_window.load_gcode(); @@ -1132,7 +1115,6 @@ void GCodeViewer::stop_mapping_gcode_window() { m_sequential_view.gcode_window.stop_mapping_file(); } -#endif // ENABLE_GCODE_WINDOW void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) { @@ -2592,11 +2574,7 @@ void GCodeViewer::render_shells() const // glsafe(::glDepthMask(GL_TRUE)); } -#if ENABLE_GCODE_WINDOW void GCodeViewer::render_legend(float& legend_height) const -#else -void GCodeViewer::render_legend() const -#endif // ENABLE_GCODE_WINDOW { if (!m_legend_enabled) return; @@ -3474,9 +3452,7 @@ void GCodeViewer::render_legend() const } } -#if ENABLE_GCODE_WINDOW legend_height = ImGui::GetCurrentWindow()->Size.y; -#endif // ENABLE_GCODE_WINDOW imgui.end(); ImGui::PopStyleVar(); diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 1942a17a8..e62ab47af 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -5,9 +5,7 @@ #include "libslic3r/GCode/GCodeProcessor.hpp" #include "GLModel.hpp" -#if ENABLE_GCODE_WINDOW #include -#endif // ENABLE_GCODE_WINDOW #include #include @@ -520,7 +518,6 @@ public: void render() const; }; -#if ENABLE_GCODE_WINDOW class GCodeWindow { struct Line @@ -557,7 +554,6 @@ public: void stop_mapping_file(); }; -#endif // ENABLE_GCODE_WINDOW struct Endpoints { @@ -571,14 +567,10 @@ public: Endpoints last_current; Vec3f current_position{ Vec3f::Zero() }; Marker marker; -#if ENABLE_GCODE_WINDOW GCodeWindow gcode_window; -#endif // ENABLE_GCODE_WINDOW std::vector gcode_ids; -#if ENABLE_GCODE_WINDOW void render(float legend_height) const; -#endif // ENABLE_GCODE_WINDOW }; enum class EViewType : unsigned char @@ -671,11 +663,9 @@ public: void export_toolpaths_to_obj(const char* filename) const; -#if ENABLE_GCODE_WINDOW void start_mapping_gcode_window(); void stop_mapping_gcode_window(); void toggle_gcode_window_visibility() { m_sequential_view.gcode_window.toggle_visibility(); } -#endif // ENABLE_GCODE_WINDOW private: void load_toolpaths(const GCodeProcessor::Result& gcode_result); @@ -683,11 +673,7 @@ private: void refresh_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) const; void render_toolpaths() const; void render_shells() const; -#if ENABLE_GCODE_WINDOW void render_legend(float& legend_height) const; -#else - void render_legend() const; -#endif // ENABLE_GCODE_WINDOW #if ENABLE_GCODE_VIEWER_STATISTICS void render_statistics() const; #endif // ENABLE_GCODE_VIEWER_STATISTICS diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 5be2fc7ad..a83f35418 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1119,7 +1119,6 @@ int GLCanvas3D::check_volumes_outside_state() const return (int)state; } -#if ENABLE_GCODE_WINDOW void GLCanvas3D::start_mapping_gcode_window() { m_gcode_viewer.start_mapping_gcode_window(); @@ -1129,7 +1128,6 @@ void GLCanvas3D::stop_mapping_gcode_window() { m_gcode_viewer.stop_mapping_gcode_window(); } -#endif // ENABLE_GCODE_WINDOW void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo, int instance_idx) { @@ -2419,10 +2417,8 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) case 'a': { post_event(SimpleEvent(EVT_GLCANVAS_ARRANGE)); break; } case 'B': case 'b': { zoom_to_bed(); break; } -#if ENABLE_GCODE_WINDOW case 'C': case 'c': { m_gcode_viewer.toggle_gcode_window_visibility(); m_dirty = true; request_extra_frame(); break; } -#endif // ENABLE_GCODE_WINDOW case 'E': case 'e': { m_labels.show(!m_labels.is_shown()); m_dirty = true; break; } case 'G': diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 3ea32a9b7..ef94ec392 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -544,10 +544,8 @@ public: const GCodeViewer::SequentialView& get_gcode_sequential_view() const { return m_gcode_viewer.get_sequential_view(); } void update_gcode_sequential_view_current(unsigned int first, unsigned int last) { m_gcode_viewer.update_sequential_view_current(first, last); } -#if ENABLE_GCODE_WINDOW void start_mapping_gcode_window(); void stop_mapping_gcode_window(); -#endif // ENABLE_GCODE_WINDOW void toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1); void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1); diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 23df99bd9..77ce3d83e 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -221,9 +221,7 @@ void KBShortcutsDialog::fill_shortcuts() { "D", L("Horizontal slider - Move active thumb Right") }, { "X", L("On/Off one layer mode of the vertical slider") }, { "L", L("Show/Hide Legend and Estimated printing time") }, -#if ENABLE_GCODE_WINDOW { "C", L("Show/Hide G-code window") }, -#endif // ENABLE_GCODE_WINDOW }; m_full_shortcuts.push_back({ { _L("Preview"), "" }, preview_shortcuts }); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 55c7f371b..a32e4fd7a 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6176,7 +6176,6 @@ BoundingBoxf Plater::bed_shape_bb() const return p->bed_shape_bb(); } -#if ENABLE_GCODE_WINDOW void Plater::start_mapping_gcode_window() { p->preview->get_canvas3d()->start_mapping_gcode_window(); @@ -6186,7 +6185,6 @@ void Plater::stop_mapping_gcode_window() { p->preview->get_canvas3d()->stop_mapping_gcode_window(); } -#endif // ENABLE_GCODE_WINDOW void Plater::arrange() { diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index fc4001ba5..6fdd70032 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -284,10 +284,8 @@ public: GLCanvas3D* get_current_canvas3D(); BoundingBoxf bed_shape_bb() const; -#if ENABLE_GCODE_WINDOW void start_mapping_gcode_window(); void stop_mapping_gcode_window(); -#endif // ENABLE_GCODE_WINDOW void arrange(); void find_new_position(const ModelInstancePtrs &instances); From 81c78d0eccbb597c218299adde70da6da998c568 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 22 Jul 2021 09:55:39 +0200 Subject: [PATCH 5/8] Tech ENABLE_EXTENDED_M73_LINES set as default --- src/libslic3r/GCode/GCodeProcessor.cpp | 44 -------------------------- src/libslic3r/GCode/GCodeProcessor.hpp | 4 --- src/libslic3r/Technologies.hpp | 2 -- 3 files changed, 50 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 72ac9ea42..273cdbf00 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -182,9 +182,7 @@ void GCodeProcessor::TimeMachine::reset() max_travel_acceleration = 0.0f; extrude_factor_override_percentage = 1.0f; time = 0.0f; -#if ENABLE_EXTENDED_M73_LINES stop_times = std::vector(); -#endif // ENABLE_EXTENDED_M73_LINES curr.reset(); prev.reset(); gcode_time.reset(); @@ -312,13 +310,11 @@ void GCodeProcessor::TimeMachine::calculate_time(size_t keep_last_n_blocks) layers_time[block.layer_id - 1] += block_time; } g1_times_cache.push_back({ block.g1_line_id, time }); -#if ENABLE_EXTENDED_M73_LINES // update times for remaining time to printer stop placeholders auto it_stop_time = std::lower_bound(stop_times.begin(), stop_times.end(), block.g1_line_id, [](const StopTime& t, unsigned int value) { return t.g1_line_id < value; }); if (it_stop_time != stop_times.end() && it_stop_time->g1_line_id == block.g1_line_id) it_stop_time->elapsed_time = time; -#endif // ENABLE_EXTENDED_M73_LINES } if (keep_last_n_blocks) @@ -357,16 +353,12 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st return int(::roundf(time_in_seconds / 60.0f)); }; -#if ENABLE_EXTENDED_M73_LINES auto time_in_last_minute = [](float time_in_seconds) { assert(time_in_seconds <= 60.0f); return time_in_seconds / 60.0f; }; auto format_line_M73_main = [](const std::string& mask, int percent, int time) { -#else - auto format_line_M73 = [](const std::string& mask, int percent, int time) { -#endif // ENABLE_EXTENDED_M73_LINES char line_M73[64]; sprintf(line_M73, mask.c_str(), std::to_string(percent).c_str(), @@ -374,7 +366,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st return std::string(line_M73); }; -#if ENABLE_EXTENDED_M73_LINES auto format_line_M73_stop_int = [](const std::string& mask, int time) { char line_M73[64]; sprintf(line_M73, mask.c_str(), std::to_string(time).c_str()); @@ -390,13 +381,11 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st sprintf(line_M73, mask.c_str(), format_time_float(time).c_str()); return std::string(line_M73); }; -#endif // ENABLE_EXTENDED_M73_LINES GCodeReader parser; std::string gcode_line; size_t g1_lines_counter = 0; // keeps track of last exported pair -#if ENABLE_EXTENDED_M73_LINES std::array, static_cast(PrintEstimatedStatistics::ETimeMode::Count)> last_exported_main; for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { last_exported_main[i] = { 0, time_in_minutes(machines[i].time) }; @@ -407,12 +396,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { last_exported_stop[i] = time_in_minutes(machines[i].time); } -#else - std::array, static_cast(PrintEstimatedStatistics::ETimeMode::Count)> last_exported; - for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { - last_exported[i] = { 0, time_in_minutes(machines[i].time) }; - } -#endif // ENABLE_EXTENDED_M73_LINES // buffer line to export only when greater than 64K to reduce writing calls std::string export_line; @@ -432,7 +415,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { const TimeMachine& machine = machines[i]; if (machine.enabled) { -#if ENABLE_EXTENDED_M73_LINES // export pair ret += format_line_M73_main(machine.line_m73_main_mask.c_str(), (line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? 0 : 100, @@ -446,12 +428,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st last_exported_stop[i] = to_export_stop; ++extra_lines_count; } -#else - ret += format_line_M73(machine.line_m73_mask.c_str(), - (line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? 0 : 100, - (line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? time_in_minutes(machine.time) : 0); - ++extra_lines_count; -#endif // ENABLE_EXTENDED_M73_LINES } } } @@ -505,7 +481,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st while (it != machine.g1_times_cache.end() && it->id < g1_lines_counter) ++it; if (it != machine.g1_times_cache.end() && it->id == g1_lines_counter) { -#if ENABLE_EXTENDED_M73_LINES std::pair to_export_main = { int(100.0f * it->elapsed_time / machine.time), time_in_minutes(machine.time - it->elapsed_time) }; if (last_exported_main[i] != to_export_main) { @@ -513,18 +488,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st to_export_main.first, to_export_main.second); last_exported_main[i] = to_export_main; ++exported_lines_count; -#else - float elapsed_time = it->elapsed_time; - std::pair to_export = { int(100.0f * elapsed_time / machine.time), - time_in_minutes(machine.time - elapsed_time) }; - if (last_exported[i] != to_export) { - export_line += format_line_M73(machine.line_m73_mask.c_str(), - to_export.first, to_export.second); - last_exported[i] = to_export; - ++exported_lines_count; -#endif // ENABLE_EXTENDED_M73_LINES } -#if ENABLE_EXTENDED_M73_LINES // export remaining time to next printer stop auto it_stop = std::upper_bound(machine.stop_times.begin(), machine.stop_times.end(), it->elapsed_time, [](float value, const TimeMachine::StopTime& t) { return value < t.elapsed_time; }); @@ -565,7 +529,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st } } } -#endif // ENABLE_EXTENDED_M73_LINES } } } @@ -803,15 +766,10 @@ bool GCodeProcessor::contains_reserved_tags(const std::string& gcode, unsigned i GCodeProcessor::GCodeProcessor() { reset(); -#if ENABLE_EXTENDED_M73_LINES m_time_processor.machines[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)].line_m73_main_mask = "M73 P%s R%s\n"; m_time_processor.machines[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)].line_m73_stop_mask = "M73 C%s\n"; m_time_processor.machines[static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)].line_m73_main_mask = "M73 Q%s S%s\n"; m_time_processor.machines[static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)].line_m73_stop_mask = "M73 D%s\n"; -#else - m_time_processor.machines[static_cast(PrintEstimatedStatistics::ETimeMode::Normal)].line_m73_mask = "M73 P%s R%s\n"; - m_time_processor.machines[static_cast(PrintEstimatedStatistics::ETimeMode::Stealth)].line_m73_mask = "M73 Q%s S%s\n"; -#endif // ENABLE_EXTENDED_M73_LINES } void GCodeProcessor::apply_config(const PrintConfig& config) @@ -2911,7 +2869,6 @@ void GCodeProcessor::store_move_vertex(EMoveType type) }; m_result.moves.emplace_back(vertex); -#if ENABLE_EXTENDED_M73_LINES // stores stop time placeholders for later use if (type == EMoveType::Color_change || type == EMoveType::Pause_Print) { for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { @@ -2922,7 +2879,6 @@ void GCodeProcessor::store_move_vertex(EMoveType type) machine.stop_times.push_back({ m_g1_line_id, 0.0f }); } } -#endif // ENABLE_EXTENDED_M73_LINES } void GCodeProcessor::set_extrusion_role(ExtrusionRole role) diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index c8dab857a..5e28e9132 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -251,7 +251,6 @@ namespace Slic3r { float max_travel_acceleration; // mm/s^2 float extrude_factor_override_percentage; float time; // s -#if ENABLE_EXTENDED_M73_LINES struct StopTime { unsigned int g1_line_id; @@ -260,9 +259,6 @@ namespace Slic3r { std::vector stop_times; std::string line_m73_main_mask; std::string line_m73_stop_mask; -#else - std::string line_m73_mask; -#endif // ENABLE_EXTENDED_M73_LINES State curr; State prev; CustomGCodeTime gcode_time; diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 8e18cda22..cfeb12fa1 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -41,8 +41,6 @@ //==================== #define ENABLE_2_4_0_ALPHA0 1 -// Enable exporting lines M73 for remaining time to next printer stop to gcode -#define ENABLE_EXTENDED_M73_LINES (1 && ENABLE_2_4_0_ALPHA0) // Enable a modified version of automatic downscale on load of objects too big #define ENABLE_MODIFIED_DOWNSCALE_ON_LOAD_OBJECTS_TOO_BIG (1 && ENABLE_2_4_0_ALPHA0) // Enable scrollable legend in preview From 13c77990aa1a361d756e8618cd4a41f21c439965 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 22 Jul 2021 10:27:37 +0200 Subject: [PATCH 6/8] Follow-up of 1f3252dd782b526991d080a5417b640c17293705 -> Fixed rectangle selection --- src/slic3r/GUI/GLCanvas3D.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index a83f35418..b4afc05d6 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4893,6 +4893,7 @@ void GLCanvas3D::_rectangular_selection_picking_pass() glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); _render_volumes_for_picking(); + _render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward()); if (m_multisample_allowed) glsafe(::glEnable(GL_MULTISAMPLE)); @@ -4911,7 +4912,10 @@ void GLCanvas3D::_rectangular_selection_picking_pass() std::array data; // Only non-interpolated colors are valid, those have their lowest three bits zeroed. bool valid() const { return picking_checksum_alpha_channel(data[0], data[1], data[2]) == data[3]; } - int id() const { return data[0] + (data[1] << 8) + (data[2] << 16); } + // we reserve color = (0,0,0) for occluders (as the printbed) + // volumes' id are shifted by 1 + // see: _render_volumes_for_picking() + int id() const { return data[0] + (data[1] << 8) + (data[2] << 16) - 1; } }; std::vector frame(px_count); From 5bffed394b0fa2a35ecfaec174506c2172091f5b Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 22 Jul 2021 11:02:47 +0200 Subject: [PATCH 7/8] Fixed cursor size clamping in MMU segmentation gizmo --- src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index 9b28eedd1..90cfb54a6 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -368,8 +368,6 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } - // Manually inserted values aren't clamped by ImGui. Zero cursor size results in a crash. - m_cursor_radius = std::clamp(m_cursor_radius, CursorRadiusMin, CursorRadiusMax); ImGui::Separator(); @@ -435,6 +433,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } + // Manually inserted values aren't clamped by ImGui. Zero cursor size results in a crash. + m_cursor_radius = std::clamp(m_cursor_radius, CursorRadiusMin, CursorRadiusMax); m_imgui->checkbox(_L("Split triangles"), m_triangle_splitting_enabled); From 65b3be92fe456e00f384ed6a21d993f42b2301d0 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 22 Jul 2021 11:26:31 +0200 Subject: [PATCH 8/8] Techs DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA and ENABLE_ALLOW_NEGATIVE_Z set as default --- src/libslic3r/Model.cpp | 47 +------------------- src/libslic3r/Model.hpp | 8 +--- src/libslic3r/Print.cpp | 10 ----- src/libslic3r/PrintObject.cpp | 16 ------- src/libslic3r/Technologies.hpp | 3 -- src/slic3r/GUI/3DScene.cpp | 22 ---------- src/slic3r/GUI/3DScene.hpp | 2 - src/slic3r/GUI/GLCanvas3D.cpp | 47 ++------------------ src/slic3r/GUI/GUI_ObjectManipulation.cpp | 28 ------------ src/slic3r/GUI/GalleryDialog.cpp | 4 -- src/slic3r/GUI/Plater.cpp | 53 +---------------------- src/slic3r/GUI/Selection.cpp | 25 ----------- src/slic3r/GUI/Selection.hpp | 2 - 13 files changed, 7 insertions(+), 260 deletions(-) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 306f80394..5c291a0c6 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -918,7 +918,6 @@ BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_ // Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane. // This method is cheap in that it does not make any unnecessary copy of the volume meshes. // This method is used by the auto arrange function. -#if ENABLE_ALLOW_NEGATIVE_Z Polygon ModelObject::convex_hull_2d(const Transform3d& trafo_instance) const { Points pts; @@ -928,33 +927,6 @@ Polygon ModelObject::convex_hull_2d(const Transform3d& trafo_instance) const } return Geometry::convex_hull(std::move(pts)); } -#else -Polygon ModelObject::convex_hull_2d(const Transform3d &trafo_instance) const -{ - Points pts; - for (const ModelVolume *v : this->volumes) - if (v->is_model_part()) { - Transform3d trafo = trafo_instance * v->get_matrix(); - const indexed_triangle_set &its = v->mesh().its; - if (its.vertices.empty()) { - // Using the STL faces. - const stl_file& stl = v->mesh().stl; - for (const stl_facet &facet : stl.facet_start) - for (size_t j = 0; j < 3; ++ j) { - Vec3d p = trafo * facet.vertex[j].cast(); - pts.emplace_back(coord_t(scale_(p.x())), coord_t(scale_(p.y()))); - } - } else { - // Using the shared vertices should be a bit quicker than using the STL faces. - for (size_t i = 0; i < its.vertices.size(); ++ i) { - Vec3d p = trafo * its.vertices[i].cast(); - pts.emplace_back(coord_t(scale_(p.x())), coord_t(scale_(p.y()))); - } - } - } - return Geometry::convex_hull(std::move(pts)); -} -#endif // ENABLE_ALLOW_NEGATIVE_Z void ModelObject::center_around_origin(bool include_modifiers) { @@ -969,19 +941,12 @@ void ModelObject::center_around_origin(bool include_modifiers) this->origin_translation += shift; } -#if ENABLE_ALLOW_NEGATIVE_Z void ModelObject::ensure_on_bed(bool allow_negative_z) { const double min_z = get_min_z(); if (!allow_negative_z || min_z > SINKING_Z_THRESHOLD) translate_instances({ 0.0, 0.0, -min_z }); } -#else -void ModelObject::ensure_on_bed() -{ - translate_instances({ 0.0, 0.0, -get_min_z() }); -} -#endif // ENABLE_ALLOW_NEGATIVE_Z void ModelObject::translate_instances(const Vec3d& vector) { @@ -1927,20 +1892,10 @@ arrangement::ArrangePolygon ModelInstance::get_arrange_polygon() const Vec3d rotation = get_rotation(); rotation.z() = 0.; Transform3d trafo_instance = -#if ENABLE_ALLOW_NEGATIVE_Z - Geometry::assemble_transform(get_offset().z() * Vec3d::UnitZ(), rotation, - get_scaling_factor(), get_mirror()); -#else - Geometry::assemble_transform(Vec3d::Zero(), rotation, - get_scaling_factor(), get_mirror()); -#endif // ENABLE_ALLOW_NEGATIVE_Z + Geometry::assemble_transform(get_offset().z() * Vec3d::UnitZ(), rotation, get_scaling_factor(), get_mirror()); Polygon p = get_object()->convex_hull_2d(trafo_instance); -#if !ENABLE_ALLOW_NEGATIVE_Z - assert(!p.points.empty()); -#endif // !ENABLE_ALLOW_NEGATIVE_Z - // if (!p.points.empty()) { // Polygons pp{p}; // pp = p.simplify(scaled(SIMPLIFY_TOLERANCE_MM)); diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 5e7e4c03d..fda500810 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -322,12 +322,8 @@ public: Polygon convex_hull_2d(const Transform3d &trafo_instance) const; void center_around_origin(bool include_modifiers = true); - -#if ENABLE_ALLOW_NEGATIVE_Z void ensure_on_bed(bool allow_negative_z = false); -#else - void ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z + void translate_instances(const Vec3d& vector); void translate_instance(size_t instance_idx, const Vec3d& vector); void translate(const Vec3d &vector) { this->translate(vector(0), vector(1), vector(2)); } @@ -1176,9 +1172,7 @@ void check_model_ids_validity(const Model &model); void check_model_ids_equal(const Model &model1, const Model &model2); #endif /* NDEBUG */ -#if ENABLE_ALLOW_NEGATIVE_Z static const float SINKING_Z_THRESHOLD = -0.001f; -#endif // ENABLE_ALLOW_NEGATIVE_Z } // namespace Slic3r diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index e6603e36e..b3a1bc993 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -373,7 +373,6 @@ bool Print::sequential_print_horizontal_clearance_valid(const Print& print, Poly // FIXME: Arrangement has different parameters for offsetting (jtMiter, limit 2) // which causes that the warning will be showed after arrangement with the // appropriate object distance. Even if I set this to jtMiter the warning still shows up. -#if ENABLE_ALLOW_NEGATIVE_Z it_convex_hull = map_model_object_to_convex_hull.emplace_hint(it_convex_hull, model_object_id, offset(print_object->model_object()->convex_hull_2d( Geometry::assemble_transform({ 0.0, 0.0, model_instance0->get_offset().z() }, model_instance0->get_rotation(), model_instance0->get_scaling_factor(), model_instance0->get_mirror())), @@ -381,15 +380,6 @@ bool Print::sequential_print_horizontal_clearance_valid(const Print& print, Poly // exactly by satisfying the extruder_clearance_radius, this test will not trigger collision. float(scale_(0.5 * print.config().extruder_clearance_radius.value - EPSILON)), jtRound, scale_(0.1)).front()); -#else - it_convex_hull = map_model_object_to_convex_hull.emplace_hint(it_convex_hull, model_object_id, - offset(print_object->model_object()->convex_hull_2d( - Geometry::assemble_transform(Vec3d::Zero(), model_instance0->get_rotation(), model_instance0->get_scaling_factor(), model_instance0->get_mirror())), - // Shrink the extruder_clearance_radius a tiny bit, so that if the object arrangement algorithm placed the objects - // exactly by satisfying the extruder_clearance_radius, this test will not trigger collision. - float(scale_(0.5 * print.config().extruder_clearance_radius.value - EPSILON)), - jtRound, float(scale_(0.1))).front()); -#endif // ENABLE_ALLOW_NEGATIVE_Z } // Make a copy, so it may be rotated for instances. Polygon convex_hull0 = it_convex_hull->second; diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index e1d4096bf..7aa39c823 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1600,15 +1600,9 @@ PrintRegionConfig region_config_from_model_volume(const PrintRegionConfig &defau void PrintObject::update_slicing_parameters() { -#if ENABLE_ALLOW_NEGATIVE_Z if (!m_slicing_params.valid) m_slicing_params = SlicingParameters::create_from_config( this->print()->config(), m_config, this->model_object()->bounding_box().max.z(), this->object_extruders()); -#else - if (! m_slicing_params.valid) - m_slicing_params = SlicingParameters::create_from_config( - this->print()->config(), m_config, unscale(this->height()), this->object_extruders()); -#endif // ENABLE_ALLOW_NEGATIVE_Z } SlicingParameters PrintObject::slicing_parameters(const DynamicPrintConfig& full_config, const ModelObject& model_object, float object_max_z) @@ -1670,7 +1664,6 @@ bool PrintObject::update_layer_height_profile(const ModelObject &model_object, c updated = true; } -#if ENABLE_ALLOW_NEGATIVE_Z // Verify the layer_height_profile. if (!layer_height_profile.empty() && // Must not be of even length. @@ -1678,15 +1671,6 @@ bool PrintObject::update_layer_height_profile(const ModelObject &model_object, c // Last entry must be at the top of the object. std::abs(layer_height_profile[layer_height_profile.size() - 2] - slicing_parameters.object_print_z_max) > 1e-3)) layer_height_profile.clear(); -#else - // Verify the layer_height_profile. - if (! layer_height_profile.empty() && - // Must not be of even length. - ((layer_height_profile.size() & 1) != 0 || - // Last entry must be at the top of the object. - std::abs(layer_height_profile[layer_height_profile.size() - 2] - slicing_parameters.object_print_z_height()) > 1e-3)) - layer_height_profile.clear(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (layer_height_profile.empty()) { //layer_height_profile = layer_height_profile_adaptive(slicing_parameters, model_object.layer_config_ranges, model_object.volumes); diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index cfeb12fa1..d55a67724 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -53,9 +53,6 @@ #define ENABLE_PROJECT_DIRTY_STATE (1 && ENABLE_2_4_0_ALPHA0) // Enable project dirty state manager debug window #define ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW (0 && ENABLE_PROJECT_DIRTY_STATE) -// Enable to push object instances under the bed -#define ENABLE_ALLOW_NEGATIVE_Z (1 && ENABLE_2_4_0_ALPHA0) -#define DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA (1 && ENABLE_ALLOW_NEGATIVE_Z) // Enable delayed rendering of transparent volumes #define ENABLE_DELAYED_TRANSPARENT_VOLUMES_RENDERING (1 && ENABLE_2_4_0_ALPHA0) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index fb464ce02..f84d221bd 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -23,9 +23,7 @@ #include "libslic3r/Format/STL.hpp" #include "libslic3r/Utils.hpp" #include "libslic3r/AppConfig.hpp" -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA #include "libslic3r/PresetBundle.hpp" -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA #include #include @@ -342,16 +340,10 @@ void GLVolume::set_render_color(const std::array& rgba) void GLVolume::set_render_color() { -#if ENABLE_ALLOW_NEGATIVE_Z bool outside = is_outside || is_below_printbed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (force_native_color || force_neutral_color) { -#if ENABLE_ALLOW_NEGATIVE_Z if (outside && shader_outside_printer_detection_enabled) -#else - if (is_outside && shader_outside_printer_detection_enabled) -#endif // ENABLE_ALLOW_NEGATIVE_Z set_render_color(OUTSIDE_COLOR); else { if (force_native_color) @@ -366,18 +358,10 @@ void GLVolume::set_render_color() else if (hover == HS_Deselect) set_render_color(HOVER_DESELECT_COLOR); else if (selected) -#if ENABLE_ALLOW_NEGATIVE_Z set_render_color(outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR); -#else - set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR); -#endif // ENABLE_ALLOW_NEGATIVE_Z else if (disabled) set_render_color(DISABLED_COLOR); -#if ENABLE_ALLOW_NEGATIVE_Z else if (outside && shader_outside_printer_detection_enabled) -#else - else if (is_outside && shader_outside_printer_detection_enabled) -#endif // ENABLE_ALLOW_NEGATIVE_Z set_render_color(OUTSIDE_COLOR); else set_render_color(color); @@ -520,14 +504,9 @@ void GLVolume::render() const bool GLVolume::is_sla_support() const { return this->composite_id.volume_id == -int(slaposSupportTree); } bool GLVolume::is_sla_pad() const { return this->composite_id.volume_id == -int(slaposPad); } -#if ENABLE_ALLOW_NEGATIVE_Z bool GLVolume::is_sinking() const { -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (is_modifier || GUI::wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA) -#else - if (is_modifier) -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA return false; const BoundingBoxf3& box = transformed_convex_hull_bounding_box(); return box.min.z() < SINKING_Z_THRESHOLD && box.max.z() >= SINKING_Z_THRESHOLD; @@ -537,7 +516,6 @@ bool GLVolume::is_below_printbed() const { return transformed_convex_hull_bounding_box().max(2) < 0.0; } -#endif // ENABLE_ALLOW_NEGATIVE_Z std::vector GLVolumeCollection::load_object( const ModelObject *model_object, diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 217d39746..fad4427e8 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -459,10 +459,8 @@ public: bool is_sla_support() const; bool is_sla_pad() const; -#if ENABLE_ALLOW_NEGATIVE_Z bool is_sinking() const; bool is_below_printbed() const; -#endif // ENABLE_ALLOW_NEGATIVE_Z // Return an estimate of the memory consumed by this class. size_t cpu_memory_used() const { diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index b4afc05d6..e7f30bf17 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -169,17 +169,10 @@ void GLCanvas3D::LayersEditing::set_config(const DynamicPrintConfig* config) void GLCanvas3D::LayersEditing::select_object(const Model &model, int object_id) { const ModelObject *model_object_new = (object_id >= 0) ? model.objects[object_id] : nullptr; -#if ENABLE_ALLOW_NEGATIVE_Z // Maximum height of an object changes when the object gets rotated or scaled. // Changing maximum height of an object will invalidate the layer heigth editing profile. // m_model_object->bounding_box() is cached, therefore it is cheap even if this method is called frequently. const float new_max_z = (model_object_new == nullptr) ? 0.0f : static_cast(model_object_new->bounding_box().max.z()); -#else - // Maximum height of an object changes when the object gets rotated or scaled. - // Changing maximum height of an object will invalidate the layer heigth editing profile. - // m_model_object->raw_bounding_box() is cached, therefore it is cheap even if this method is called frequently. - float new_max_z = (model_object_new == nullptr) ? 0.f : model_object_new->raw_bounding_box().size().z(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (m_model_object != model_object_new || this->last_object_id != object_id || m_object_max_z != new_max_z || (model_object_new != nullptr && m_model_object->id() != model_object_new->id())) { m_layer_height_profile.clear(); @@ -3401,37 +3394,21 @@ void GLCanvas3D::do_move(const std::string& snapshot_type) wipe_tower_origin = v->get_volume_offset(); } -#if ENABLE_ALLOW_NEGATIVE_Z // Fixes flying instances -#else - // Fixes sinking/flying instances -#endif // ENABLE_ALLOW_NEGATIVE_Z for (const std::pair& i : done) { ModelObject* m = m_model->objects[i.first]; -#if ENABLE_ALLOW_NEGATIVE_Z const double shift_z = m->get_instance_min_z(i.second); -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (current_printer_technology() == ptSLA || shift_z > SINKING_Z_THRESHOLD) { -#else - if (shift_z > 0.0) { -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA const Vec3d shift(0.0, 0.0, -shift_z); -#else - const Vec3d shift(0.0, 0.0, -m->get_instance_min_z(i.second)); -#endif // ENABLE_ALLOW_NEGATIVE_Z - m_selection.translate(i.first, i.second, shift); - m->translate_instance(i.second, shift); -#if ENABLE_ALLOW_NEGATIVE_Z + m_selection.translate(i.first, i.second, shift); + m->translate_instance(i.second, shift); } -#endif // ENABLE_ALLOW_NEGATIVE_Z } -#if ENABLE_ALLOW_NEGATIVE_Z // if the selection is not valid to allow for layer editing after the move, we need to turn off the tool if it is running // similar to void Plater::priv::selection_changed() if (!wxGetApp().plater()->can_layers_editing() && is_layers_editing_enabled()) post_event(SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (object_moved) post_event(SimpleEvent(EVT_GLCANVAS_INSTANCE_MOVED)); @@ -3452,7 +3429,6 @@ void GLCanvas3D::do_rotate(const std::string& snapshot_type) if (!snapshot_type.empty()) wxGetApp().plater()->take_snapshot(_(snapshot_type)); -#if ENABLE_ALLOW_NEGATIVE_Z // stores current min_z of instances std::map, double> min_zs; if (!snapshot_type.empty()) { @@ -3463,7 +3439,6 @@ void GLCanvas3D::do_rotate(const std::string& snapshot_type) } } } -#endif // ENABLE_ALLOW_NEGATIVE_Z std::set> done; // keeps track of modified instances @@ -3501,19 +3476,13 @@ void GLCanvas3D::do_rotate(const std::string& snapshot_type) // Fixes sinking/flying instances for (const std::pair& i : done) { ModelObject* m = m_model->objects[i.first]; -#if ENABLE_ALLOW_NEGATIVE_Z double shift_z = m->get_instance_min_z(i.second); // leave sinking instances as sinking if (min_zs.empty() || min_zs.find({ i.first, i.second })->second >= SINKING_Z_THRESHOLD || shift_z > SINKING_Z_THRESHOLD) { Vec3d shift(0.0, 0.0, -shift_z); -#else - Vec3d shift(0.0, 0.0, -m->get_instance_min_z(i.second)); -#endif // ENABLE_ALLOW_NEGATIVE_Z m_selection.translate(i.first, i.second, shift); m->translate_instance(i.second, shift); -#if ENABLE_ALLOW_NEGATIVE_Z } -#endif // ENABLE_ALLOW_NEGATIVE_Z } if (!done.empty()) @@ -3530,7 +3499,6 @@ void GLCanvas3D::do_scale(const std::string& snapshot_type) if (!snapshot_type.empty()) wxGetApp().plater()->take_snapshot(_(snapshot_type)); -#if ENABLE_ALLOW_NEGATIVE_Z // stores current min_z of instances std::map, double> min_zs; if (!snapshot_type.empty()) { @@ -3541,7 +3509,6 @@ void GLCanvas3D::do_scale(const std::string& snapshot_type) } } } -#endif // ENABLE_ALLOW_NEGATIVE_Z std::set> done; // keeps track of modified instances @@ -3576,19 +3543,13 @@ void GLCanvas3D::do_scale(const std::string& snapshot_type) // Fixes sinking/flying instances for (const std::pair& i : done) { ModelObject* m = m_model->objects[i.first]; -#if ENABLE_ALLOW_NEGATIVE_Z double shift_z = m->get_instance_min_z(i.second); // leave sinking instances as sinking if (min_zs.empty() || min_zs.find({ i.first, i.second })->second >= SINKING_Z_THRESHOLD || shift_z > SINKING_Z_THRESHOLD) { Vec3d shift(0.0, 0.0, -shift_z); -#else - Vec3d shift(0.0, 0.0, -m->get_instance_min_z(i.second)); -#endif // ENABLE_ALLOW_NEGATIVE_Z - m_selection.translate(i.first, i.second, shift); - m->translate_instance(i.second, shift); -#if ENABLE_ALLOW_NEGATIVE_Z + m_selection.translate(i.first, i.second, shift); + m->translate_instance(i.second, shift); } -#endif // ENABLE_ALLOW_NEGATIVE_Z } if (!done.empty()) diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index d55acf054..42e0c8d54 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -30,28 +30,9 @@ const double ObjectManipulation::mm_to_in = 0.0393700787; // volume in world coordinate system. static double get_volume_min_z(const GLVolume& volume) { -#if ENABLE_ALLOW_NEGATIVE_Z return volume.transformed_convex_hull_bounding_box().min.z(); -#else - const Transform3f& world_matrix = volume.world_matrix().cast(); - - // need to get the ModelVolume pointer - const ModelObject* mo = wxGetApp().model().objects[volume.composite_id.object_id]; - const ModelVolume* mv = mo->volumes[volume.composite_id.volume_id]; - const TriangleMesh& hull = mv->get_convex_hull(); - - float min_z = std::numeric_limits::max(); - for (const stl_facet& facet : hull.stl.facet_start) { - for (int i = 0; i < 3; ++i) - min_z = std::min(min_z, Vec3f::UnitZ().dot(world_matrix * facet.vertex[i])); - } - - return min_z; -#endif // ENABLE_ALLOW_NEGATIVE_Z } - - static choice_ctrl* create_word_local_combo(wxWindow *parent) { wxSize size(15 * wxGetApp().em_unit(), -1); @@ -358,7 +339,6 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : change_position_value(1, diff.y()); change_position_value(2, diff.z()); } -#if ENABLE_ALLOW_NEGATIVE_Z else if (selection.is_single_full_instance()) { const ModelObjectPtrs& objects = wxGetApp().model().objects; const int idx = selection.get_object_idx(); @@ -371,7 +351,6 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : } } } -#endif // ENABLE_ALLOW_NEGATIVE_Z }); editors_grid_sizer->Add(m_drop_to_bed_button); @@ -702,10 +681,7 @@ void ObjectManipulation::update_reset_buttons_visibility() if (selection.is_single_full_instance()) { rotation = volume->get_instance_rotation(); scale = volume->get_instance_scaling_factor(); -#if ENABLE_ALLOW_NEGATIVE_Z min_z = wxGetApp().model().objects[volume->composite_id.object_id]->bounding_box().min.z(); -#endif // ENABLE_ALLOW_NEGATIVE_Z - } else { rotation = volume->get_volume_rotation(); @@ -714,11 +690,7 @@ void ObjectManipulation::update_reset_buttons_visibility() } show_rotation = !rotation.isApprox(Vec3d::Zero()); show_scale = !scale.isApprox(Vec3d::Ones()); -#if ENABLE_ALLOW_NEGATIVE_Z show_drop_to_bed = std::abs(min_z) > SINKING_Z_THRESHOLD; -#else - show_drop_to_bed = (std::abs(min_z) > EPSILON); -#endif // ENABLE_ALLOW_NEGATIVE_Z } wxGetApp().CallAfter([this, show_rotation, show_scale, show_drop_to_bed] { diff --git a/src/slic3r/GUI/GalleryDialog.cpp b/src/slic3r/GUI/GalleryDialog.cpp index d64c09fb6..f306dff98 100644 --- a/src/slic3r/GUI/GalleryDialog.cpp +++ b/src/slic3r/GUI/GalleryDialog.cpp @@ -253,11 +253,7 @@ static void generate_thumbnail_from_stl(const std::string& filename) assert(model.objects[0]->instances.size() == 1); model.objects[0]->center_around_origin(false); -#if ENABLE_ALLOW_NEGATIVE_Z model.objects[0]->ensure_on_bed(false); -#else - model.objects[0]->ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z const Vec3d bed_center_3d = wxGetApp().plater()->get_bed().get_bounding_box(false).center(); const Vec2d bed_center_2d = { bed_center_3d.x(), bed_center_3d.y()}; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index a32e4fd7a..1998ef19b 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1650,11 +1650,8 @@ struct Plater::priv BoundingBox scaled_bed_shape_bb() const; std::vector load_files(const std::vector& input_files, bool load_model, bool load_config, bool used_inches = false); -#if ENABLE_ALLOW_NEGATIVE_Z std::vector load_model_objects(const ModelObjectPtrs& model_objects, bool allow_negative_z = false); -#else - std::vector load_model_objects(const ModelObjectPtrs &model_objects); -#endif // ENABLE_ALLOW_NEGATIVE_Z + wxString get_export_file(GUI::FileType file_type); const Selection& get_selection() const; @@ -2417,19 +2414,11 @@ std::vector Plater::priv::load_files(const std::vector& input_ return obj_idxs; } -#if ENABLE_ALLOW_NEGATIVE_Z for (ModelObject* model_object : model.objects) { if (!type_3mf && !type_zip_amf) model_object->center_around_origin(false); model_object->ensure_on_bed(is_project_file); } -#else - for (ModelObject* model_object : model.objects) { - if (!type_3mf && !type_zip_amf) - model_object->center_around_origin(false); - model_object->ensure_on_bed(); - } -#endif // ENABLE_ALLOW_NEGATIVE_Z // check multi-part object adding for the SLA-printing if (printer_technology == ptSLA) { @@ -2443,11 +2432,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ } if (one_by_one) { -#if ENABLE_ALLOW_NEGATIVE_Z auto loaded_idxs = load_model_objects(model.objects, is_project_file); -#else - auto loaded_idxs = load_model_objects(model.objects); -#endif // ENABLE_ALLOW_NEGATIVE_Z obj_idxs.insert(obj_idxs.end(), loaded_idxs.begin(), loaded_idxs.end()); } else { // This must be an .stl or .obj file, which may contain a maximum of one volume. @@ -2500,11 +2485,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ // #define AUTOPLACEMENT_ON_LOAD -#if ENABLE_ALLOW_NEGATIVE_Z std::vector Plater::priv::load_model_objects(const ModelObjectPtrs& model_objects, bool allow_negative_z) -#else -std::vector Plater::priv::load_model_objects(const ModelObjectPtrs &model_objects) -#endif // ENABLE_ALLOW_NEGATIVE_Z { const BoundingBoxf bed_shape = bed_shape_bb(); const Vec3d bed_size = Slic3r::to_3d(bed_shape.size().cast(), 1.0) - 2.0 * Vec3d::Ones(); @@ -2582,11 +2563,7 @@ std::vector Plater::priv::load_model_objects(const ModelObjectPtrs &mode } #endif // ENABLE_MODIFIED_DOWNSCALE_ON_LOAD_OBJECTS_TOO_BIG -#if ENABLE_ALLOW_NEGATIVE_Z object->ensure_on_bed(allow_negative_z); -#else - object->ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z } #ifdef AUTOPLACEMENT_ON_LOAD @@ -3247,9 +3224,7 @@ void Plater::priv::replace_with_stl() ModelObject* old_model_object = model.objects[object_idx]; ModelVolume* old_volume = old_model_object->volumes[volume_idx]; -#if ENABLE_ALLOW_NEGATIVE_Z bool sinking = old_model_object->bounding_box().min.z() < SINKING_Z_THRESHOLD; -#endif // ENABLE_ALLOW_NEGATIVE_Z ModelObject* new_model_object = new_model.objects[0]; old_model_object->add_volume(*new_model_object->volumes[0]); @@ -3269,9 +3244,7 @@ void Plater::priv::replace_with_stl() new_volume->mmu_segmentation_facets.assign(old_volume->mmu_segmentation_facets); std::swap(old_model_object->volumes[volume_idx], old_model_object->volumes.back()); old_model_object->delete_volume(old_model_object->volumes.size() - 1); -#if ENABLE_ALLOW_NEGATIVE_Z if (!sinking) -#endif // ENABLE_ALLOW_NEGATIVE_Z old_model_object->ensure_on_bed(); old_model_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); @@ -3422,9 +3395,7 @@ void Plater::priv::reload_from_disk() ModelObject* old_model_object = model.objects[sel_v.object_idx]; ModelVolume* old_volume = old_model_object->volumes[sel_v.volume_idx]; -#if ENABLE_ALLOW_NEGATIVE_Z bool sinking = old_model_object->bounding_box().min.z() < SINKING_Z_THRESHOLD; -#endif // ENABLE_ALLOW_NEGATIVE_Z bool has_source = !old_volume->source.input_file.empty() && boost::algorithm::iequals(fs::path(old_volume->source.input_file).filename().string(), fs::path(path).filename().string()); bool has_name = !old_volume->name.empty() && boost::algorithm::iequals(old_volume->name, fs::path(path).filename().string()); @@ -3481,9 +3452,7 @@ void Plater::priv::reload_from_disk() new_volume->mmu_segmentation_facets.assign(old_volume->mmu_segmentation_facets); std::swap(old_model_object->volumes[sel_v.volume_idx], old_model_object->volumes.back()); old_model_object->delete_volume(old_model_object->volumes.size() - 1); -#if ENABLE_ALLOW_NEGATIVE_Z if (!sinking) -#endif // ENABLE_ALLOW_NEGATIVE_Z old_model_object->ensure_on_bed(); old_model_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); @@ -4277,12 +4246,8 @@ bool Plater::priv::layers_height_allowed() const return false; int obj_idx = get_selected_object_idx(); -#if ENABLE_ALLOW_NEGATIVE_Z return 0 <= obj_idx && obj_idx < (int)model.objects.size() && model.objects[obj_idx]->bounding_box().max.z() > SINKING_Z_THRESHOLD && config->opt_bool("variable_layer_height") && view3D->is_layers_editing_allowed(); -#else - return 0 <= obj_idx && obj_idx < (int)model.objects.size() && config->opt_bool("variable_layer_height") && view3D->is_layers_editing_allowed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z } bool Plater::priv::can_mirror() const @@ -6223,13 +6188,11 @@ bool Plater::set_printer_technology(PrinterTechnology printer_technology) //FIXME for SLA synchronize //p->background_process.apply(Model)! -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (printer_technology == ptSLA) { for (ModelObject* model_object : p->model.objects) { model_object->ensure_on_bed(); } } -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA p->label_btn_export = printer_technology == ptFFF ? L("Export G-code") : L("Export"); p->label_btn_send = printer_technology == ptFFF ? L("Send G-code") : L("Send to printer"); @@ -6250,15 +6213,7 @@ void Plater::changed_object(int obj_idx) return; // recenter and re - align to Z = 0 auto model_object = p->model.objects[obj_idx]; -#if ENABLE_ALLOW_NEGATIVE_Z -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA model_object->ensure_on_bed(this->p->printer_technology != ptSLA); -#else - model_object->ensure_on_bed(true); -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA -#else - model_object->ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (this->p->printer_technology == ptSLA) { // Update the SLAPrint from the current Model, so that the reload_scene() // pulls the correct data, update the 3D scene. @@ -6277,17 +6232,11 @@ void Plater::changed_objects(const std::vector& object_idxs) return; for (size_t obj_idx : object_idxs) { -#if ENABLE_ALLOW_NEGATIVE_Z if (obj_idx < p->model.objects.size()) { if (p->model.objects[obj_idx]->bounding_box().min.z() >= SINKING_Z_THRESHOLD) // re - align to Z = 0 p->model.objects[obj_idx]->ensure_on_bed(); } -#else - if (obj_idx < p->model.objects.size()) - // recenter and re - align to Z = 0 - p->model.objects[obj_idx]->ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z } if (this->p->printer_technology == ptSLA) { // Update the SLAPrint from the current Model, so that the reload_scene() diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index f2e879605..ec882a3a5 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -13,9 +13,7 @@ #include "libslic3r/LocalesUtils.hpp" #include "libslic3r/Model.hpp" -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA #include "libslic3r/PresetBundle.hpp" -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA #include @@ -838,21 +836,13 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type if (!m_valid) return; -#if ENABLE_ALLOW_NEGATIVE_Z bool is_any_volume_sinking = false; -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA bool is_sla = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA; -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA -#endif // ENABLE_ALLOW_NEGATIVE_Z for (unsigned int i : m_list) { GLVolume &volume = *(*m_volumes)[i]; -#if ENABLE_ALLOW_NEGATIVE_Z -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (!is_sla) -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA is_any_volume_sinking |= !volume.is_modifier && std::find(m_cache.sinking_volumes.begin(), m_cache.sinking_volumes.end(), i) != m_cache.sinking_volumes.end(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (is_single_full_instance()) { if (transformation_type.relative()) { Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scale); @@ -908,10 +898,8 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type synchronize_unselected_volumes(); #endif // !DISABLE_INSTANCES_SYNCH -#if ENABLE_ALLOW_NEGATIVE_Z if (!is_any_volume_sinking) ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z this->set_bounding_boxes_dirty(); } @@ -1657,16 +1645,12 @@ void Selection::update_type() void Selection::set_caches() { m_cache.volumes_data.clear(); -#if ENABLE_ALLOW_NEGATIVE_Z m_cache.sinking_volumes.clear(); -#endif // ENABLE_ALLOW_NEGATIVE_Z for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i) { const GLVolume& v = *(*m_volumes)[i]; m_cache.volumes_data.emplace(i, VolumeCache(v.get_volume_transformation(), v.get_instance_transformation())); -#if ENABLE_ALLOW_NEGATIVE_Z if (v.is_sinking()) m_cache.sinking_volumes.push_back(i); -#endif // ENABLE_ALLOW_NEGATIVE_Z } m_cache.dragging_center = get_bounding_box().center(); } @@ -2071,21 +2055,12 @@ void Selection::synchronize_unselected_instances(SyncRotationType sync_rotation_ assert(is_rotation_xy_synchronized(m_cache.volumes_data[i].get_instance_rotation(), m_cache.volumes_data[j].get_instance_rotation())); switch (sync_rotation_type) { case SYNC_ROTATION_NONE: { -#if ENABLE_ALLOW_NEGATIVE_Z // z only rotation -> synch instance z // The X,Y rotations should be synchronized from start to end of the rotation. assert(is_rotation_xy_synchronized(rotation, v->get_instance_rotation())); -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA) -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA v->set_instance_offset(Z, volume->get_instance_offset().z()); break; -#else - // z only rotation -> keep instance z - // The X,Y rotations should be synchronized from start to end of the rotation. - assert(is_rotation_xy_synchronized(rotation, v->get_instance_rotation())); - break; -#endif // ENABLE_ALLOW_NEGATIVE_Z } case SYNC_ROTATION_FULL: // rotation comes from place on face -> force given z diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index c6409f9f2..0e0e869ef 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -186,10 +186,8 @@ private: // to a set of indices of ModelVolume instances in ModelObject::instances // Here the index means a position inside the respective std::vector, not ObjectID. ObjectIdxsToInstanceIdxsMap content; -#if ENABLE_ALLOW_NEGATIVE_Z // List of ids of the volumes which are sinking when starting dragging std::vector sinking_volumes; -#endif // ENABLE_ALLOW_NEGATIVE_Z }; // Volumes owned by GLCanvas3D.