diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index fd1ddf0550..08e5fdf6d8 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -156,12 +156,10 @@ void AppConfig::set_defaults() if (get("show_splash_screen").empty()) set("show_splash_screen", "1"); -#if ENABLE_CTRL_M_ON_WINDOWS #ifdef _WIN32 if (get("use_legacy_3DConnexion").empty()) set("use_legacy_3DConnexion", "0"); #endif // _WIN32 -#endif // ENABLE_CTRL_M_ON_WINDOWS // Remove legacy window positions/sizes erase("", "main_frame_maximized"); diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index c7b2c8f784..26a2062475 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1803,7 +1803,6 @@ namespace Skirt { static std::map> make_skirt_loops_per_extruder_1st_layer( const Print &print, - const std::vector & /*layers */, const LayerTools &layer_tools, // Heights (print_z) at which the skirt has already been extruded. std::vector &skirt_done) @@ -1811,7 +1810,8 @@ namespace Skirt { // Extrude skirt at the print_z of the raft layers and normal object layers // not at the print_z of the interlaced support material layers. std::map> skirt_loops_per_extruder_out; - if (skirt_done.empty() && print.has_skirt() && ! print.skirt().entities.empty()) { + assert(skirt_done.empty()); + if (skirt_done.empty() && print.has_skirt() && ! print.skirt().entities.empty() && layer_tools.has_skirt) { skirt_loops_per_extruder_all_printing(print, layer_tools, skirt_loops_per_extruder_out); skirt_done.emplace_back(layer_tools.print_z); } @@ -1820,36 +1820,34 @@ namespace Skirt { static std::map> make_skirt_loops_per_extruder_other_layers( const Print &print, - const std::vector &layers, const LayerTools &layer_tools, - // First non-empty support layer. - const SupportLayer *support_layer, // Heights (print_z) at which the skirt has already been extruded. std::vector &skirt_done) { // Extrude skirt at the print_z of the raft layers and normal object layers // not at the print_z of the interlaced support material layers. std::map> skirt_loops_per_extruder_out; - if (print.has_skirt() && ! print.skirt().entities.empty() && + if (print.has_skirt() && ! print.skirt().entities.empty() && layer_tools.has_skirt && // Not enough skirt layers printed yet. //FIXME infinite or high skirt does not make sense for sequential print! - (skirt_done.size() < (size_t)print.config().skirt_height.value || print.has_infinite_skirt()) && + (skirt_done.size() < (size_t)print.config().skirt_height.value || print.has_infinite_skirt())) { + bool valid = ! skirt_done.empty() && skirt_done.back() < layer_tools.print_z - EPSILON; + assert(valid); // This print_z has not been extruded yet (sequential print) // FIXME: The skirt_done should not be empty at this point. The check is a workaround // of https://github.com/prusa3d/PrusaSlicer/issues/5652, but it deserves a real fix. - (! skirt_done.empty() && skirt_done.back() < layer_tools.print_z - EPSILON) && - // and this layer is an object layer, or it is a raft layer. - (layer_tools.has_object || support_layer->id() < (size_t)support_layer->object()->config().raft_layers.value)) { + if (valid) { #if 0 - // Prime just the first printing extruder. This is original Slic3r's implementation. - skirt_loops_per_extruder_out[layer_tools.extruders.front()] = std::pair(0, print.config().skirts.value); + // Prime just the first printing extruder. This is original Slic3r's implementation. + skirt_loops_per_extruder_out[layer_tools.extruders.front()] = std::pair(0, print.config().skirts.value); #else - // Prime all extruders planned for this layer, see - // https://github.com/prusa3d/PrusaSlicer/issues/469#issuecomment-322450619 - skirt_loops_per_extruder_all_printing(print, layer_tools, skirt_loops_per_extruder_out); + // Prime all extruders planned for this layer, see + // https://github.com/prusa3d/PrusaSlicer/issues/469#issuecomment-322450619 + skirt_loops_per_extruder_all_printing(print, layer_tools, skirt_loops_per_extruder_out); #endif - assert(!skirt_done.empty()); - skirt_done.emplace_back(layer_tools.print_z); + assert(!skirt_done.empty()); + skirt_done.emplace_back(layer_tools.print_z); + } } return skirt_loops_per_extruder_out; } @@ -1992,8 +1990,8 @@ void GCode::process_layer( // Extrude skirt at the print_z of the raft layers and normal object layers // not at the print_z of the interlaced support material layers. skirt_loops_per_extruder = first_layer ? - Skirt::make_skirt_loops_per_extruder_1st_layer(print, layers, layer_tools, m_skirt_done) : - Skirt::make_skirt_loops_per_extruder_other_layers(print, layers, layer_tools, support_layer, m_skirt_done); + Skirt::make_skirt_loops_per_extruder_1st_layer(print, layer_tools, m_skirt_done) : + Skirt::make_skirt_loops_per_extruder_other_layers(print, layer_tools, m_skirt_done); // Group extrusions by an extruder, then by an object, an island and a region. std::map> by_extruder; diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index c4b2a35183..a4769af8e7 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -705,10 +705,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config) } m_time_processor.export_remaining_time_enabled = config.remaining_times.value; - -#if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING m_use_volumetric_e = config.use_volumetric_e; -#endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING } void GCodeProcessor::apply_config(const DynamicPrintConfig& config) @@ -870,11 +867,9 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) if (m_time_processor.machine_limits.machine_max_acceleration_x.values.size() > 1) enable_stealth_time_estimator(true); -#if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING const ConfigOptionBool* use_volumetric_e = config.option("use_volumetric_e"); if (use_volumetric_e != nullptr) m_use_volumetric_e = use_volumetric_e->value; -#endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING } void GCodeProcessor::enable_stealth_time_estimator(bool enabled) @@ -930,9 +925,7 @@ void GCodeProcessor::reset() m_result.reset(); m_result.id = ++s_result_id; -#if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING m_use_volumetric_e = false; -#endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING #if ENABLE_GCODE_VIEWER_DATA_CHECKING m_mm3_per_mm_compare.reset(); @@ -1840,14 +1833,10 @@ void GCodeProcessor::process_G0(const GCodeReader::GCodeLine& line) void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) { -#if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING float filament_diameter = (static_cast(m_extruder_id) < m_filament_diameters.size()) ? m_filament_diameters[m_extruder_id] : m_filament_diameters.back(); float filament_radius = 0.5f * filament_diameter; float area_filament_cross_section = static_cast(M_PI) * sqr(filament_radius); auto absolute_position = [this, area_filament_cross_section](Axis axis, const GCodeReader::GCodeLine& lineG1) { -#else - auto absolute_position = [this](Axis axis, const GCodeReader::GCodeLine& lineG1) { -#endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING bool is_relative = (m_global_positioning_type == EPositioningType::Relative); if (axis == E) is_relative |= (m_e_local_positioning_type == EPositioningType::Relative); @@ -1855,10 +1844,8 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) if (lineG1.has(Slic3r::Axis(axis))) { float lengthsScaleFactor = (m_units == EUnits::Inches) ? INCHES_TO_MM : 1.0f; float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor; -#if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING if (axis == E && m_use_volumetric_e) ret /= area_filament_cross_section; -#endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING return is_relative ? m_start_position[axis] + ret : m_origin[axis] + ret; } else @@ -1916,11 +1903,6 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) if (type == EMoveType::Extrude) { float delta_xyz = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z])); -#if !ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING - float filament_diameter = (static_cast(m_extruder_id) < m_filament_diameters.size()) ? m_filament_diameters[m_extruder_id] : m_filament_diameters.back(); - float filament_radius = 0.5f * filament_diameter; - float area_filament_cross_section = static_cast(M_PI) * sqr(filament_radius); -#endif // !ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING float volume_extruded_filament = area_filament_cross_section * delta_pos[E]; float area_toolpath_cross_section = volume_extruded_filament / delta_xyz; diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index 05f9a2ce33..f884df8ecc 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -473,9 +473,7 @@ namespace Slic3r { unsigned int m_g1_line_id; unsigned int m_layer_id; CpColor m_cp_color; -#if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING bool m_use_volumetric_e; -#endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING enum class EProducer { diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index fae4028deb..8520cf35bd 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -70,6 +70,20 @@ unsigned int LayerTools::extruder(const ExtrusionEntityCollection &extrusions, c return (extruder == 0) ? 0 : extruder - 1; } +static double calc_max_layer_height(const PrintConfig &config, double max_object_layer_height) +{ + double max_layer_height = std::numeric_limits::max(); + for (size_t i = 0; i < config.nozzle_diameter.values.size(); ++ i) { + double mlh = config.max_layer_height.values[i]; + if (mlh == 0.) + mlh = 0.75 * config.nozzle_diameter.values[i]; + max_layer_height = std::min(max_layer_height, mlh); + } + // The Prusa3D Fast (0.35mm layer height) print profile sets a higher layer height than what is normally allowed + // by the nozzle. This is a hack and it works by increasing extrusion width. See GH #3919. + return std::max(max_layer_height, max_object_layer_height); +} + // For the use case when each object is printed separately // (print.config().complete_objects is true). ToolOrdering::ToolOrdering(const PrintObject &object, unsigned int first_extruder, bool prime_multi_material) @@ -87,6 +101,7 @@ ToolOrdering::ToolOrdering(const PrintObject &object, unsigned int first_extrude zs.emplace_back(layer->print_z); this->initialize_layers(zs); } + double max_layer_height = calc_max_layer_height(object.print()->config(), object.config().layer_height); // Collect extruders reuqired to print the layers. this->collect_extruders(object, std::vector>()); @@ -94,9 +109,11 @@ ToolOrdering::ToolOrdering(const PrintObject &object, unsigned int first_extrude // Reorder the extruders to minimize tool switches. this->reorder_extruders(first_extruder); - this->fill_wipe_tower_partitions(object.print()->config(), object.layers().front()->print_z - object.layers().front()->height, object.config().layer_height); + this->fill_wipe_tower_partitions(object.print()->config(), object.layers().front()->print_z - object.layers().front()->height, max_layer_height); this->collect_extruder_statistics(prime_multi_material); + + this->mark_skirt_layers(object.print()->config(), max_layer_height); } // For the use case when all objects are printed at once. @@ -128,6 +145,7 @@ ToolOrdering::ToolOrdering(const Print &print, unsigned int first_extruder, bool } this->initialize_layers(zs); } + max_layer_height = calc_max_layer_height(print.config(), max_layer_height); // Use the extruder switches from Model::custom_gcode_per_print_z to override the extruder to print the object. // Do it only if all the objects were configured to be printed with a single extruder. @@ -150,6 +168,8 @@ ToolOrdering::ToolOrdering(const Print &print, unsigned int first_extruder, bool this->fill_wipe_tower_partitions(print.config(), object_bottom_z, max_layer_height); this->collect_extruder_statistics(prime_multi_material); + + this->mark_skirt_layers(print.config(), max_layer_height); } void ToolOrdering::initialize_layers(std::vector &zs) @@ -321,7 +341,7 @@ void ToolOrdering::reorder_extruders(unsigned int last_extruder_id) } } -void ToolOrdering::fill_wipe_tower_partitions(const PrintConfig &config, coordf_t object_bottom_z, coordf_t max_object_layer_height) +void ToolOrdering::fill_wipe_tower_partitions(const PrintConfig &config, coordf_t object_bottom_z, coordf_t max_layer_height) { if (m_layer_tools.empty()) return; @@ -347,17 +367,6 @@ void ToolOrdering::fill_wipe_tower_partitions(const PrintConfig &config, coordf_ lt.has_wipe_tower = (lt.has_object && lt.wipe_tower_partitions > 0) || lt.print_z < object_bottom_z + EPSILON; // Test for a raft, insert additional wipe tower layer to fill in the raft separation gap. - double max_layer_height = std::numeric_limits::max(); - for (size_t i = 0; i < config.nozzle_diameter.values.size(); ++ i) { - double mlh = config.max_layer_height.values[i]; - if (mlh == 0.) - mlh = 0.75 * config.nozzle_diameter.values[i]; - max_layer_height = std::min(max_layer_height, mlh); - } - // The Prusa3D Fast (0.35mm layer height) print profile sets a higher layer height than what is normally allowed - // by the nozzle. This is a hack and it works by increasing extrusion width. See GH #3919. - max_layer_height = std::max(max_layer_height, max_object_layer_height); - for (size_t i = 0; i + 1 < m_layer_tools.size(); ++ i) { const LayerTools < = m_layer_tools[i]; const LayerTools <_next = m_layer_tools[i + 1]; @@ -460,6 +469,48 @@ void ToolOrdering::collect_extruder_statistics(bool prime_multi_material) } } +// Layers are marked for infinite skirt aka draft shield. Not all the layers have to be printed. +void ToolOrdering::mark_skirt_layers(const PrintConfig &config, coordf_t max_layer_height) +{ + if (m_layer_tools.empty()) + return; + + if (m_layer_tools.front().extruders.empty()) { + // Empty first layer, no skirt will be printed. + //FIXME throw an exception? + return; + } + + size_t i = 0; + for (;;) { + m_layer_tools[i].has_skirt = true; + size_t j = i + 1; + for (; j < m_layer_tools.size() && ! m_layer_tools[j].has_object; ++ j); + // i and j are two successive layers printing an object. + if (j == m_layer_tools.size()) + // Don't print skirt above the last object layer. + break; + // Mark some printing intermediate layers as having skirt. + double last_z = m_layer_tools[i].print_z; + for (size_t k = i + 1; k < j; ++ k) { + if (m_layer_tools[k + 1].print_z - last_z > max_layer_height + EPSILON) { + // Layer k is the last one not violating the maximum layer height. + // Don't extrude skirt on empty layers. + while (m_layer_tools[k].extruders.empty()) + -- k; + if (m_layer_tools[k].has_skirt) { + // Skirt cannot be generated due to empty layers, there would be a missing layer in the skirt. + //FIXME throw an exception? + break; + } + m_layer_tools[k].has_skirt = true; + last_z = m_layer_tools[k].print_z; + } + } + i = j; + } +} + // Assign a pointer to a custom G-code to the respective ToolOrdering::LayerTools. // Ignore color changes, which are performed on a layer and for such an extruder, that the extruder will not be printing above that layer. // If multiple events are planned over a span of a single layer, use the last one. diff --git a/src/libslic3r/GCode/ToolOrdering.hpp b/src/libslic3r/GCode/ToolOrdering.hpp index e2e07533fa..0367303258 100644 --- a/src/libslic3r/GCode/ToolOrdering.hpp +++ b/src/libslic3r/GCode/ToolOrdering.hpp @@ -17,8 +17,6 @@ class LayerTools; namespace CustomGCode { struct Item; } class PrintRegion; - - // Object of this class holds information about whether an extrusion is printed immediately // after a toolchange (as part of infill/perimeter wiping) or not. One extrusion can be a part // of several copies - this has to be taken into account. @@ -69,8 +67,6 @@ private: const LayerTools* m_layer_tools = nullptr; // so we know which LayerTools object this belongs to }; - - class LayerTools { public: @@ -99,6 +95,9 @@ public: // If per layer extruder switches are inserted by the G-code preview slider, this value contains the new (1 based) extruder, with which the whole object layer is being printed with. // If not overriden, it is set to 0. unsigned int extruder_override = 0; + // Should a skirt be printed at this layer? + // Layers are marked for infinite skirt aka draft shield. Not all the layers have to be printed. + bool has_skirt = false; // Will there be anything extruded on this layer for the wipe tower? // Due to the support layers possibly interleaving the object layers, // wipe tower will be disabled for some support only layers. @@ -120,12 +119,10 @@ private: WipingExtrusions m_wiping_extrusions; }; - - class ToolOrdering { public: - ToolOrdering() {} + ToolOrdering() = default; // For the use case when each object is printed separately // (print.config.complete_objects is true). @@ -169,6 +166,7 @@ private: void collect_extruders(const PrintObject &object, const std::vector> &per_layer_extruder_switches); void reorder_extruders(unsigned int last_extruder_id); void fill_wipe_tower_partitions(const PrintConfig &config, coordf_t object_bottom_z, coordf_t max_layer_height); + void mark_skirt_layers(const PrintConfig &config, coordf_t max_layer_height); void collect_extruder_statistics(bool prime_multi_material); std::vector m_layer_tools; @@ -182,8 +180,6 @@ private: const PrintConfig* m_print_config_ptr = nullptr; }; - - } // namespace SLic3r #endif /* slic3r_ToolOrdering_hpp_ */ diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 84fdf3f629..c963418c30 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -418,7 +418,7 @@ void PrintObject::generate_support_material() { if (this->set_started(posSupportMaterial)) { this->clear_support_layers(); - if (this->has_support_material() && m_layers.size() > 1) { + if ((this->has_support() && m_layers.size() > 1) || (this->has_raft() && ! m_layers.empty())) { m_print->set_status(85, L("Generating support material")); this->_generate_support_material(); m_print->throw_if_canceled(); diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index d9efd75537..459a156034 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -501,7 +501,7 @@ void PrintObjectSupportMaterial::generate(PrintObject &object) // If raft is to be generated, the 1st top_contact layer will contain the 1st object layer silhouette with holes filled. // There is also a 1st intermediate layer containing bases of support columns. // Inflate the bases of the support columns and create the raft base under the object. - MyLayersPtr raft_layers = this->generate_raft_base(object, top_contacts, interface_layers, intermediate_layers, layer_storage); + MyLayersPtr raft_layers = this->generate_raft_base(object, top_contacts, interface_layers, intermediate_layers, base_interface_layers, layer_storage); #ifdef SLIC3R_DEBUG for (const MyLayer *l : interface_layers) @@ -1264,6 +1264,14 @@ namespace SupportMaterialInternal { offset(layerm->unsupported_bridge_edges, scale_(SUPPORT_MATERIAL_MARGIN), SUPPORT_SURFACES_OFFSET_PARAMETERS)); // Remove bridged areas from the supported areas. contact_polygons = diff(contact_polygons, bridges, true); + + #ifdef SLIC3R_DEBUG + static int iRun = 0; + SVG::export_expolygons(debug_out_path("support-top-contacts-remove-bridges-run%d.svg", iRun ++), + { { { union_ex(offset(layerm->unsupported_bridge_edges, scale_(SUPPORT_MATERIAL_MARGIN), SUPPORT_SURFACES_OFFSET_PARAMETERS), false) }, { "unsupported_bridge_edges", "orange", 0.5f } }, + { { union_ex(contact_polygons, false) }, { "contact_polygons", "blue", 0.5f } }, + { { union_ex(bridges, false) }, { "bridges", "red", "black", "", scaled(0.1f), 0.5f } } }); + #endif /* SLIC3R_DEBUG */ } } @@ -1678,7 +1686,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_ #endif /* SLIC3R_DEBUG */ } } - #ifdef SLIC3R_DEBUG + #ifdef SLIC3R_DEBUG SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), { { { union_ex(lower_layer_polygons, false) }, { "lower_layer_polygons", "gray", 0.2f } }, { { union_ex(*new_layer.contact_polygons, false) }, { "new_layer.contact_polygons", "yellow", 0.5f } }, @@ -2538,6 +2546,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::generate_raf const PrintObject &object, const MyLayersPtr &top_contacts, const MyLayersPtr &interface_layers, + const MyLayersPtr &base_interface_layers, const MyLayersPtr &base_layers, MyLayerStorage &layer_storage) const { @@ -2573,15 +2582,19 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::generate_raf // How much to inflate the support columns to be stable. This also applies to the 1st layer, if no raft layers are to be printed. const float inflate_factor_fine = float(scale_((m_slicing_params.raft_layers() > 1) ? 0.5 : EPSILON)); const float inflate_factor_1st_layer = std::max(0.f, float(scale_(object.config().raft_first_layer_expansion)) - inflate_factor_fine); - MyLayer *contacts = top_contacts .empty() ? nullptr : top_contacts .front(); - MyLayer *interfaces = interface_layers.empty() ? nullptr : interface_layers.front(); - MyLayer *columns_base = base_layers .empty() ? nullptr : base_layers .front(); + MyLayer *contacts = top_contacts .empty() ? nullptr : top_contacts .front(); + MyLayer *interfaces = interface_layers .empty() ? nullptr : interface_layers .front(); + MyLayer *base_interfaces = base_interface_layers.empty() ? nullptr : base_interface_layers.front(); + MyLayer *columns_base = base_layers .empty() ? nullptr : base_layers .front(); if (contacts != nullptr && contacts->print_z > std::max(m_slicing_params.first_print_layer_height, m_slicing_params.raft_contact_top_z) + EPSILON) // This is not the raft contact layer. contacts = nullptr; if (interfaces != nullptr && interfaces->bottom_print_z() > m_slicing_params.raft_interface_top_z + EPSILON) // This is not the raft column base layer. interfaces = nullptr; + if (base_interfaces != nullptr && base_interfaces->bottom_print_z() > m_slicing_params.raft_interface_top_z + EPSILON) + // This is not the raft column base layer. + base_interfaces = nullptr; if (columns_base != nullptr && columns_base->bottom_print_z() > m_slicing_params.raft_interface_top_z + EPSILON) // This is not the raft interface layer. columns_base = nullptr; @@ -2591,6 +2604,8 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::generate_raf polygons_append(interface_polygons, offset(contacts->polygons, inflate_factor_fine, SUPPORT_SURFACES_OFFSET_PARAMETERS)); if (interfaces != nullptr && ! interfaces->polygons.empty()) polygons_append(interface_polygons, offset(interfaces->polygons, inflate_factor_fine, SUPPORT_SURFACES_OFFSET_PARAMETERS)); + if (base_interfaces != nullptr && ! base_interfaces->polygons.empty()) + polygons_append(interface_polygons, offset(base_interfaces->polygons, inflate_factor_fine, SUPPORT_SURFACES_OFFSET_PARAMETERS)); // Output vector. MyLayersPtr raft_layers; @@ -2663,6 +2678,8 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::generate_raf contacts->polygons = diff(contacts->polygons, brim); if (interfaces) interfaces->polygons = diff(interfaces->polygons, brim); + if (base_interfaces) + base_interfaces->polygons = diff(base_interfaces->polygons, brim); } } @@ -2715,7 +2732,7 @@ std::pairangle = raft_angle_1st_layer; filler->spacing = m_first_layer_flow.spacing(); - // 70% of density on the 1st layer. - density = 0.7f; + density = float(m_object_config->raft_first_layer_density.value * 0.01); } else if (support_layer_id >= m_slicing_params.base_raft_layers) { filler->angle = raft_angle_interface; // We don't use $base_flow->spacing because we need a constant spacing diff --git a/src/libslic3r/SupportMaterial.hpp b/src/libslic3r/SupportMaterial.hpp index ddc5b944c0..7123290a62 100644 --- a/src/libslic3r/SupportMaterial.hpp +++ b/src/libslic3r/SupportMaterial.hpp @@ -195,6 +195,7 @@ private: const PrintObject &object, const MyLayersPtr &top_contacts, const MyLayersPtr &interface_layers, + const MyLayersPtr &base_interface_layers, const MyLayersPtr &base_layers, MyLayerStorage &layer_storage) const; diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 1c21e2f869..3ada1cd359 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -27,41 +27,10 @@ #define ENABLE_GCODE_VIEWER_STATISTICS 0 // Enable G-Code viewer comparison between toolpaths height and width detected from gcode and calculated at gcode generation #define ENABLE_GCODE_VIEWER_DATA_CHECKING 0 - - -//================= -// 2.2.0.rc1 techs -//================= -#define ENABLE_2_2_0_RC1 1 - -// Enable hack to remove crash when closing on OSX 10.9.5 -#define ENABLE_HACK_CLOSING_ON_OSX_10_9_5 (1 && ENABLE_2_2_0_RC1) - - -//==================== -// 2.3.0.alpha1 techs -//==================== -#define ENABLE_2_3_0_ALPHA1 1 - // Enable rendering of objects using environment map -#define ENABLE_ENVIRONMENT_MAP (0 && ENABLE_2_3_0_ALPHA1) - +#define ENABLE_ENVIRONMENT_MAP 0 // Enable smoothing of objects normals -#define ENABLE_SMOOTH_NORMALS (0 && ENABLE_2_3_0_ALPHA1) - -// Enable error logging for OpenGL calls when SLIC3R_LOGLEVEL >= 5 -#define ENABLE_OPENGL_ERROR_LOGGING (1 && ENABLE_2_3_0_ALPHA1) - -// Enable built-in DPI changed event handler of wxWidgets 3.1.3 -#define ENABLE_WX_3_1_3_DPI_CHANGED_EVENT (1 && ENABLE_2_3_0_ALPHA1) - - -//==================== -// 2.3.0.alpha3 techs -//==================== -#define ENABLE_2_3_0_ALPHA3 1 - -#define ENABLE_CTRL_M_ON_WINDOWS (1 && ENABLE_2_3_0_ALPHA3) +#define ENABLE_SMOOTH_NORMALS 0 //==================== @@ -80,22 +49,14 @@ #define ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN (1 && ENABLE_2_3_0_BETA1) -//================= -// 2.3.0.rc1 techs -//================= -#define ENABLE_2_3_0_RC1 1 - -#define ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING (1 && ENABLE_2_3_0_RC1) - - //==================== // 2.3.1.alpha1 techs //==================== #define ENABLE_2_3_1_ALPHA1 1 #define ENABLE_SPLITTED_VERTEX_BUFFER (1 && ENABLE_2_3_1_ALPHA1) -#define ENABLE_RELOAD_FROM_DISK_FOR_3MF (1 && ENABLE_2_3_1_ALPHA1) #define ENABLE_REDUCED_TOOLPATHS_SEGMENT_CAPS (1 && ENABLE_SPLITTED_VERTEX_BUFFER) +#define ENABLE_RELOAD_FROM_DISK_FOR_3MF (1 && ENABLE_2_3_1_ALPHA1) #define ENABLE_WARNING_TEXTURE_REMOVAL (1 && ENABLE_2_3_1_ALPHA1) #define ENABLE_GCODE_LINES_ID_IN_H_SLIDER (1 && ENABLE_2_3_1_ALPHA1) #define ENABLE_VALIDATE_CUSTOM_GCODE (1 && ENABLE_2_3_1_ALPHA1) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 3aafc9a3b9..04301061db 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -39,12 +39,11 @@ #ifdef HAS_GLSAFE void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char* function_name) { -#if defined(NDEBUG) && ENABLE_OPENGL_ERROR_LOGGING - // In release mode, if OpenGL debugging was forced by ENABLE_OPENGL_ERROR_LOGGING, only show - // OpenGL errors if sufficiently high loglevel. +#if defined(NDEBUG) + // In release mode, only show OpenGL errors if sufficiently high loglevel. if (Slic3r::get_logging_level() < 5) return; -#endif // ENABLE_OPENGL_ERROR_LOGGING +#endif // NDEBUG GLenum err = glGetError(); if (err == GL_NO_ERROR) diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 6565d5c096..e4d9c60672 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -10,10 +10,7 @@ #include -#if ENABLE_OPENGL_ERROR_LOGGING || ! defined(NDEBUG) - #define HAS_GLSAFE -#endif - +#define HAS_GLSAFE #ifdef HAS_GLSAFE extern void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name); inline void glAssertRecentCall() { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 59908bd806..b0bb6a8a4a 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -629,13 +629,13 @@ PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxStrin append(html_window, 0, wxEXPAND); list_printer->Bind(wxEVT_LISTBOX, [this](wxCommandEvent& evt) { - update_lists(evt.GetInt(), list_type->GetSelection(), list_vendor->GetSelection()); + update_lists(list_type->GetSelection(), list_vendor->GetSelection(), evt.GetInt()); }); list_type->Bind(wxEVT_LISTBOX, [this](wxCommandEvent &) { - update_lists(list_printer->GetSelection(), list_type->GetSelection(), list_vendor->GetSelection()); + update_lists(list_type->GetSelection(), list_vendor->GetSelection()); }); list_vendor->Bind(wxEVT_LISTBOX, [this](wxCommandEvent &) { - update_lists(list_printer->GetSelection(), list_type->GetSelection(), list_vendor->GetSelection()); + update_lists(list_type->GetSelection(), list_vendor->GetSelection()); }); list_profile->Bind(wxEVT_CHECKLISTBOX, [this](wxCommandEvent &evt) { select_material(evt.GetInt()); }); @@ -681,8 +681,7 @@ void PageMaterials::reload_presets() sort_list_data(list_printer, true, false); if (list_printer->GetCount() > 0) { list_printer->SetSelection(0); - sel_printer_count_prev = wxNOT_FOUND; - sel_printer_item_prev = wxNOT_FOUND; + sel_printers_prev.Clear(); sel_type_prev = wxNOT_FOUND; sel_vendor_prev = wxNOT_FOUND; update_lists(0, 0, 0); @@ -812,7 +811,7 @@ void PageMaterials::on_material_highlighted(int sel_material) set_compatible_printers_html_window(names, names.size() == materials->printers.size()); } -void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor) +void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected_printer/* = -1*/) { wxWindowUpdateLocker freeze_guard(this); (void)freeze_guard; @@ -820,7 +819,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor) wxArrayInt sel_printers; int sel_printers_count = list_printer->GetSelections(sel_printers); - if (sel_printers_count != sel_printer_count_prev || (sel_printers_count == 1 && sel_printer_item_prev != sel_printer && sel_printer != -1)) { + if (sel_printers != sel_printers_prev) { // Refresh type list list_type->Clear(); list_type->append(_L("(All)"), &EMPTY); @@ -828,7 +827,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor) // If all is selected with other printers // unselect "all" or all printers depending on last value if (sel_printers[0] == 0 && sel_printers_count > 1) { - if (sel_printer == 0) { + if (last_selected_printer == 0) { list_printer->SetSelection(wxNOT_FOUND); list_printer->SetSelection(0); } else { @@ -869,8 +868,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor) sort_list_data(list_type, true, true); } - sel_printer_count_prev = sel_printers_count; - sel_printer_item_prev = sel_printer; + sel_printers_prev = sel_printers; sel_type = 0; sel_type_prev = wxNOT_FOUND; list_type->SetSelection(sel_type); @@ -1089,8 +1087,7 @@ void PageMaterials::clear() list_type->Clear(); list_vendor->Clear(); list_profile->Clear(); - sel_printer_count_prev = wxNOT_FOUND; - sel_printer_item_prev = wxNOT_FOUND; + sel_printers_prev.Clear(); sel_type_prev = wxNOT_FOUND; sel_vendor_prev = wxNOT_FOUND; presets_loaded = false; diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp index d9c0e2dc15..581ec39b18 100644 --- a/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/src/slic3r/GUI/ConfigWizard_private.hpp @@ -327,7 +327,8 @@ struct PageMaterials: ConfigWizardPage Materials *materials; StringList *list_printer, *list_type, *list_vendor; PresetList *list_profile; - int sel_printer_count_prev, sel_printer_item_prev, sel_type_prev, sel_vendor_prev; + wxArrayInt sel_printers_prev; + int sel_type_prev, sel_vendor_prev; bool presets_loaded; wxFlexGridSizer *grid; @@ -342,7 +343,7 @@ struct PageMaterials: ConfigWizardPage PageMaterials(ConfigWizard *parent, Materials *materials, wxString title, wxString shortname, wxString list1name); void reload_presets(); - void update_lists(int sel1, int sel2, int sel3); + void update_lists(int sel_type, int sel_vendor, int last_selected_printer = -1); void on_material_highlighted(int sel_material); void on_material_hovered(int sel_material); void select_material(int i); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 0aec25404c..3267320df2 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2509,8 +2509,6 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) #endif /* __APPLE__ */ post_event(SimpleEvent(EVT_GLTOOLBAR_COPY)); break; - -#if ENABLE_CTRL_M_ON_WINDOWS #ifdef __APPLE__ case 'm': case 'M': @@ -2529,18 +2527,6 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) #endif //_WIN32 break; } -#else -#if defined(__linux__) || defined(__APPLE__) - case WXK_CONTROL_M: - { - Mouse3DController& controller = wxGetApp().plater()->get_mouse3d_controller(); - controller.show_settings_dialog(!controller.is_settings_dialog_shown()); - m_dirty = true; - break; - } -#endif /* __linux__ */ -#endif // ENABLE_CTRL_M_ON_WINDOWS - #ifdef __APPLE__ case 'v': case 'V': diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index dbb200f83b..4f02c6c23d 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -26,11 +26,7 @@ class wxCheckBox; class wxTopLevelWindow; class wxRect; -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT #define wxVERSION_EQUAL_OR_GREATER_THAN(major, minor, release) ((wxMAJOR_VERSION > major) || ((wxMAJOR_VERSION == major) && (wxMINOR_VERSION > minor)) || ((wxMAJOR_VERSION == major) && (wxMINOR_VERSION == minor) && (wxRELEASE_NUMBER >= release))) -#else -#define wxVERSION_EQUAL_OR_GREATER_THAN(major, minor, release) 0 -#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT namespace Slic3r { namespace GUI { @@ -99,12 +95,12 @@ public: // Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3). // So, calculate the m_em_unit value from the font size, as before -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && !defined(__WXGTK__) +#if !defined(__WXGTK__) m_em_unit = std::max(10, 10.0f * m_scale_factor); #else // initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window. m_em_unit = std::max(10, this->GetTextExtent("m").x - 1); -#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT +#endif // __WXGTK__ // recalc_font(); @@ -235,11 +231,7 @@ private: m_normal_font = this->GetFont(); // update em_unit value for new window font -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT m_em_unit = std::max(10, 10.0f * m_scale_factor); -#else - m_em_unit = std::max(10, this->GetTextExtent("m").x - 1); -#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT // rescale missed controls sizes and images on_dpi_changed(suggested_rect); diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 04e6769e4c..a7363837ea 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -147,17 +147,11 @@ void KBShortcutsDialog::fill_shortcuts() { "O", L("Zoom out") }, { "Tab", L("Switch between Editor/Preview") }, { "Shift+Tab", L("Collapse/Expand the sidebar") }, -#if ENABLE_CTRL_M_ON_WINDOWS #ifdef _WIN32 { ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog, if enabled") }, #else { ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog") }, #endif // _WIN32 -#else -#if defined(__linux__) || defined(__APPLE__) - { ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog") }, -#endif // __linux__ -#endif // ENABLE_CTRL_M_ON_WINDOWS #if ENABLE_RENDER_PICKING_PASS // Don't localize debugging texts. { "P", "Toggle picking pass texture rendering on/off" }, diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 386a150f70..91357ff6c4 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -803,11 +803,7 @@ bool MainFrame::can_reslice() const void MainFrame::on_dpi_changed(const wxRect& suggested_rect) { -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT wxGetApp().update_fonts(this); -#else - wxGetApp().update_fonts(); -#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT this->SetFont(this->normal_font()); // update Plater @@ -1848,14 +1844,14 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe) if (wxGetApp().is_gcode_viewer()) return; -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__) +#if defined(__WXMSW__) // ys_FIXME! temporary workaround for correct font scaling // Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts, // From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); #else this->SetFont(wxGetApp().normal_font()); -#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT +#endif // __WXMSW__ this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); // Load the icon either from the exe, or from the ico file. diff --git a/src/slic3r/GUI/Mouse3DController.cpp b/src/slic3r/GUI/Mouse3DController.cpp index 9ff5688be2..57b82fc782 100644 --- a/src/slic3r/GUI/Mouse3DController.cpp +++ b/src/slic3r/GUI/Mouse3DController.cpp @@ -100,7 +100,6 @@ void Mouse3DController::State::append_button(unsigned int id, size_t /* input_qu } #ifdef _WIN32 -#if ENABLE_CTRL_M_ON_WINDOWS static std::string format_device_string(int vid, int pid) { std::string ret; @@ -257,7 +256,6 @@ static std::string detect_attached_device() return ret; } -#endif // ENABLE_CTRL_M_ON_WINDOWS // Called by Win32 HID enumeration callback. void Mouse3DController::device_attached(const std::string &device) @@ -274,7 +272,6 @@ void Mouse3DController::device_attached(const std::string &device) // Never mind, enumeration will be performed until connected. m_wakeup = true; m_stop_condition.notify_all(); -#if ENABLE_CTRL_M_ON_WINDOWS m_device_str = format_device_string(vid, pid); if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) { tbb::mutex::scoped_lock lock(m_params_ui_mutex); @@ -283,12 +280,10 @@ void Mouse3DController::device_attached(const std::string &device) else m_params_by_device[format_device_string(vid, pid)] = Params(); m_connected = true; -#endif // ENABLE_CTRL_M_ON_WINDOWS } } } -#if ENABLE_CTRL_M_ON_WINDOWS void Mouse3DController::device_detached(const std::string& device) { int vid = 0; @@ -302,7 +297,6 @@ void Mouse3DController::device_detached(const std::string& device) m_device_str = ""; m_connected = false; } -#endif // ENABLE_CTRL_M_ON_WINDOWS // Filter out mouse scroll events produced by the 3DConnexion driver. bool Mouse3DController::State::process_mouse_wheel() @@ -415,7 +409,6 @@ bool Mouse3DController::apply(Camera& camera) m_settings_dialog_closed_by_user = false; } -#if ENABLE_CTRL_M_ON_WINDOWS #ifdef _WIN32 { tbb::mutex::scoped_lock lock(m_params_ui_mutex); @@ -425,7 +418,6 @@ bool Mouse3DController::apply(Camera& camera) } } #endif // _WIN32 -#endif // ENABLE_CTRL_M_ON_WINDOWS return m_state.apply(m_params, camera); } @@ -661,7 +653,6 @@ bool Mouse3DController::handle_input(const DataPacketAxis& packet) // Initialize the application. void Mouse3DController::init() { -#if ENABLE_CTRL_M_ON_WINDOWS #ifdef _WIN32 m_device_str = detect_attached_device(); if (!m_device_str.empty()) { @@ -670,7 +661,6 @@ void Mouse3DController::init() m_params = m_params_ui = it_params->second; } #endif // _WIN32 -#endif // ENABLE_CTRL_M_ON_WINDOWS assert(! m_thread.joinable()); if (! m_thread.joinable()) { @@ -698,12 +688,10 @@ void Mouse3DController::shutdown() m_stop = false; } -#if ENABLE_CTRL_M_ON_WINDOWS #ifdef _WIN32 if (!m_device_str.empty()) m_params_by_device[m_device_str] = m_params_ui; #endif // _WIN32 -#endif // ENABLE_CTRL_M_ON_WINDOWS } // Main routine of the worker thread. @@ -1064,9 +1052,7 @@ bool Mouse3DController::handle_raw_input_win32(const unsigned char *data, const DataPacketRaw packet; memcpy(packet.data(), data, packet_length); handle_packet(packet, packet_length, m_params, m_state); -#if ENABLE_CTRL_M_ON_WINDOWS m_connected = true; -#endif // ENABLE_CTRL_M_ON_WINDOWS } return true; diff --git a/src/slic3r/GUI/Mouse3DController.hpp b/src/slic3r/GUI/Mouse3DController.hpp index af131992ce..3376ef8140 100644 --- a/src/slic3r/GUI/Mouse3DController.hpp +++ b/src/slic3r/GUI/Mouse3DController.hpp @@ -195,9 +195,7 @@ public: // Called by Win32 HID enumeration callback. void device_attached(const std::string &device); -#if ENABLE_CTRL_M_ON_WINDOWS void device_detached(const std::string& device); -#endif // ENABLE_CTRL_M_ON_WINDOWS // On Windows, the 3DConnexion driver sends out mouse wheel rotation events to an active application // if the application does not register at the driver. This is a workaround to ignore these superfluous diff --git a/src/slic3r/GUI/OpenGLManager.cpp b/src/slic3r/GUI/OpenGLManager.cpp index 4f1e00793b..0fa97bfc11 100644 --- a/src/slic3r/GUI/OpenGLManager.cpp +++ b/src/slic3r/GUI/OpenGLManager.cpp @@ -14,14 +14,10 @@ #include #include -#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5 #ifdef __APPLE__ // Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets #include -#endif // __APPLE__ -#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5 -#ifdef __APPLE__ #include "../Utils/MacDarkMode.hpp" #endif // __APPLE__ @@ -202,34 +198,26 @@ bool OpenGLManager::s_compressed_textures_supported = false; OpenGLManager::EMultisampleState OpenGLManager::s_multisample = OpenGLManager::EMultisampleState::Unknown; OpenGLManager::EFramebufferType OpenGLManager::s_framebuffers_type = OpenGLManager::EFramebufferType::Unknown; -#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5 #ifdef __APPLE__ // Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets OpenGLManager::OSInfo OpenGLManager::s_os_info; #endif // __APPLE__ -#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5 OpenGLManager::~OpenGLManager() { m_shaders_manager.shutdown(); -#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5 #ifdef __APPLE__ // This is an ugly hack needed to solve the crash happening when closing the application on OSX 10.9.5 with newer wxWidgets // The crash is triggered inside wxGLContext destructor if (s_os_info.major != 10 || s_os_info.minor != 9 || s_os_info.micro != 5) { #endif //__APPLE__ -#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5 - if (m_context != nullptr) delete m_context; - -#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5 #ifdef __APPLE__ } #endif //__APPLE__ -#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5 } bool OpenGLManager::init_gl() @@ -286,14 +274,12 @@ wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas) if (m_context == nullptr) { m_context = new wxGLContext(&canvas); -#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5 #ifdef __APPLE__ // Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets s_os_info.major = wxPlatformInfo::Get().GetOSMajorVersion(); s_os_info.minor = wxPlatformInfo::Get().GetOSMinorVersion(); s_os_info.micro = wxPlatformInfo::Get().GetOSMicroVersion(); #endif //__APPLE__ -#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5 } return m_context; } diff --git a/src/slic3r/GUI/OpenGLManager.hpp b/src/slic3r/GUI/OpenGLManager.hpp index c89cdf3a61..5f8cd7959c 100644 --- a/src/slic3r/GUI/OpenGLManager.hpp +++ b/src/slic3r/GUI/OpenGLManager.hpp @@ -51,7 +51,6 @@ public: void detect() const; }; -#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5 #ifdef __APPLE__ // Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets struct OSInfo @@ -61,7 +60,6 @@ public: int micro{ 0 }; }; #endif //__APPLE__ -#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5 private: enum class EMultisampleState : unsigned char @@ -75,12 +73,10 @@ private: wxGLContext* m_context{ nullptr }; GLShadersManager m_shaders_manager; static GLInfo s_gl_info; -#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5 #ifdef __APPLE__ // Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets static OSInfo s_os_info; #endif //__APPLE__ -#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5 static bool s_compressed_textures_supported; static EMultisampleState s_multisample; static EFramebufferType s_framebuffers_type; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6400bbbcc6..fe67049254 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1931,11 +1931,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) this->q->Bind(EVT_HID_DEVICE_ATTACHED, [this](HIDDeviceAttachedEvent &evt) { mouse3d_controller.device_attached(evt.data); }); -#if ENABLE_CTRL_M_ON_WINDOWS this->q->Bind(EVT_HID_DEVICE_DETACHED, [this](HIDDeviceAttachedEvent& evt) { mouse3d_controller.device_detached(evt.data); }); -#endif // ENABLE_CTRL_M_ON_WINDOWS #endif /* _WIN32 */ notification_manager = new NotificationManager(this->q); @@ -3336,16 +3334,14 @@ void Plater::priv::set_current_panel(wxPanel* panel) void Plater::priv::on_select_preset(wxCommandEvent &evt) { - auto preset_type = static_cast(evt.GetInt()); - auto *combo = static_cast(evt.GetEventObject()); + PlaterPresetComboBox* combo = static_cast(evt.GetEventObject()); + Preset::Type preset_type = combo->get_type(); // see https://github.com/prusa3d/PrusaSlicer/issues/3889 // Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender"), // m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive. // So, use GetSelection() from event parameter - // But in this function we couldn't use evt.GetSelection(), because m_commandInt is used for preset_type - // Thus, get selection in this way: - int selection = combo->FindString(evt.GetString(), true); + int selection = evt.GetSelection(); auto idx = combo->get_extruder_idx(); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index cba941a396..e28bd589d7 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -215,7 +215,6 @@ void PreferencesDialog::build() option = Option(def, "show_splash_screen"); m_optgroup_general->append_single_option_line(option); -#if ENABLE_CTRL_M_ON_WINDOWS #if defined(_WIN32) || defined(__APPLE__) def.label = L("Enable support for legacy 3DConnexion devices"); def.type = coBool; @@ -224,7 +223,6 @@ void PreferencesDialog::build() option = Option(def, "use_legacy_3DConnexion"); m_optgroup_general->append_single_option_line(option); #endif // _WIN32 || __APPLE__ -#endif // ENABLE_CTRL_M_ON_WINDOWS activate_options_tab(m_optgroup_general); diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 0754df5712..da723a36b8 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -121,23 +121,26 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_suppress_change = false; }); Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_suppress_change = true; }); - Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) { - // see https://github.com/prusa3d/PrusaSlicer/issues/3889 - // Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender") - // m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive. - // So, use GetSelection() from event parameter - auto selected_item = evt.GetSelection(); + Bind(wxEVT_COMBOBOX, &PresetComboBox::OnSelect, this); +} - auto marker = reinterpret_cast(this->GetClientData(selected_item)); - if (marker >= LABEL_ITEM_DISABLED && marker < LABEL_ITEM_MAX) - this->SetSelection(this->m_last_selected); - else if (on_selection_changed && (m_last_selected != selected_item || m_collection->current_is_dirty())) { - m_last_selected = selected_item; - on_selection_changed(selected_item); - evt.StopPropagation(); - } - evt.Skip(); - }); +void PresetComboBox::OnSelect(wxCommandEvent& evt) +{ + // see https://github.com/prusa3d/PrusaSlicer/issues/3889 + // Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender") + // m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive. + // So, use GetSelection() from event parameter + auto selected_item = evt.GetSelection(); + + auto marker = reinterpret_cast(this->GetClientData(selected_item)); + if (marker >= LABEL_ITEM_DISABLED && marker < LABEL_ITEM_MAX) + this->SetSelection(this->m_last_selected); + else if (on_selection_changed && (m_last_selected != selected_item || m_collection->current_is_dirty())) { + m_last_selected = selected_item; + on_selection_changed(selected_item); + evt.StopPropagation(); + } + evt.Skip(); } PresetComboBox::~PresetComboBox() @@ -602,34 +605,6 @@ void PresetComboBox::OnDrawItem(wxDC& dc, PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset_type) : PresetComboBox(parent, preset_type, wxSize(15 * wxGetApp().em_unit(), -1)) { - Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) { - auto selected_item = evt.GetSelection(); - - auto marker = reinterpret_cast(this->GetClientData(selected_item)); - if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) { - this->SetSelection(this->m_last_selected); - evt.StopPropagation(); - if (marker == LABEL_ITEM_WIZARD_PRINTERS) - show_add_menu(); - else - { - ConfigWizard::StartPage sp = ConfigWizard::SP_WELCOME; - switch (marker) { - case LABEL_ITEM_WIZARD_FILAMENTS: sp = ConfigWizard::SP_FILAMENTS; break; - case LABEL_ITEM_WIZARD_MATERIALS: sp = ConfigWizard::SP_MATERIALS; break; - default: break; - } - wxTheApp->CallAfter([sp]() { wxGetApp().run_wizard(ConfigWizard::RR_USER, sp); }); - } - } else if (marker == LABEL_ITEM_PHYSICAL_PRINTER || this->m_last_selected != selected_item || m_collection->current_is_dirty() ) { - this->m_last_selected = selected_item; - evt.SetInt(this->m_type); - evt.Skip(); - } else { - evt.StopPropagation(); - } - }); - if (m_type == Preset::TYPE_FILAMENT) { Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) { @@ -717,6 +692,35 @@ PlaterPresetComboBox::~PlaterPresetComboBox() edit_btn->Destroy(); } +void PlaterPresetComboBox::OnSelect(wxCommandEvent &evt) +{ + auto selected_item = evt.GetSelection(); + + auto marker = reinterpret_cast(this->GetClientData(selected_item)); + if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) { + this->SetSelection(this->m_last_selected); + evt.StopPropagation(); + if (marker == LABEL_ITEM_MARKER) + return; + if (marker == LABEL_ITEM_WIZARD_PRINTERS) + show_add_menu(); + else { + ConfigWizard::StartPage sp = ConfigWizard::SP_WELCOME; + switch (marker) { + case LABEL_ITEM_WIZARD_FILAMENTS: sp = ConfigWizard::SP_FILAMENTS; break; + case LABEL_ITEM_WIZARD_MATERIALS: sp = ConfigWizard::SP_MATERIALS; break; + default: break; + } + wxTheApp->CallAfter([sp]() { wxGetApp().run_wizard(ConfigWizard::RR_USER, sp); }); + } + return; + } + else if (marker == LABEL_ITEM_PHYSICAL_PRINTER || this->m_last_selected != selected_item || m_collection->current_is_dirty()) + this->m_last_selected = selected_item; + + evt.Skip(); +} + bool PlaterPresetComboBox::switch_to_tab() { Tab* tab = wxGetApp().get_tab(m_type); @@ -957,40 +961,42 @@ void PlaterPresetComboBox::msw_rescale() TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type) : PresetComboBox(parent, preset_type, wxSize(35 * wxGetApp().em_unit(), -1)) { - Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) { - // see https://github.com/prusa3d/PrusaSlicer/issues/3889 - // Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender") - // m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive. - // So, use GetSelection() from event parameter - auto selected_item = evt.GetSelection(); +} - auto marker = reinterpret_cast(this->GetClientData(selected_item)); - if (marker >= LABEL_ITEM_DISABLED && marker < LABEL_ITEM_MAX) { - this->SetSelection(this->m_last_selected); - if (marker == LABEL_ITEM_WIZARD_PRINTERS) - wxTheApp->CallAfter([this]() { - wxGetApp().run_wizard(ConfigWizard::RR_USER, ConfigWizard::SP_PRINTERS); +void TabPresetComboBox::OnSelect(wxCommandEvent &evt) +{ + // see https://github.com/prusa3d/PrusaSlicer/issues/3889 + // Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender") + // m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive. + // So, use GetSelection() from event parameter + auto selected_item = evt.GetSelection(); - // update combobox if its parent is a PhysicalPrinterDialog - PhysicalPrinterDialog* parent = dynamic_cast(this->GetParent()); - if (parent != nullptr) - update(); - }); - } - else if (on_selection_changed && (m_last_selected != selected_item || m_collection->current_is_dirty()) ) { - m_last_selected = selected_item; - on_selection_changed(selected_item); - } + auto marker = reinterpret_cast(this->GetClientData(selected_item)); + if (marker >= LABEL_ITEM_DISABLED && marker < LABEL_ITEM_MAX) { + this->SetSelection(this->m_last_selected); + if (marker == LABEL_ITEM_WIZARD_PRINTERS) + wxTheApp->CallAfter([this]() { + wxGetApp().run_wizard(ConfigWizard::RR_USER, ConfigWizard::SP_PRINTERS); - evt.StopPropagation(); + // update combobox if its parent is a PhysicalPrinterDialog + PhysicalPrinterDialog* parent = dynamic_cast(this->GetParent()); + if (parent != nullptr) + update(); + }); + } + else if (on_selection_changed && (m_last_selected != selected_item || m_collection->current_is_dirty())) { + m_last_selected = selected_item; + on_selection_changed(selected_item); + } + + evt.StopPropagation(); #ifdef __WXMSW__ - // From the Win 2004 preset combobox lose a focus after change the preset selection - // and that is why the up/down arrow doesn't work properly - // (see https://github.com/prusa3d/PrusaSlicer/issues/5531 ). - // So, set the focus to the combobox explicitly - this->SetFocus(); -#endif - }); + // From the Win 2004 preset combobox lose a focus after change the preset selection + // and that is why the up/down arrow doesn't work properly + // (see https://github.com/prusa3d/PrusaSlicer/issues/5531 ). + // So, set the focus to the combobox explicitly + this->SetFocus(); +#endif } wxString TabPresetComboBox::get_preset_name(const Preset& preset) diff --git a/src/slic3r/GUI/PresetComboBoxes.hpp b/src/slic3r/GUI/PresetComboBoxes.hpp index 6f41c95f4e..efcbec3706 100644 --- a/src/slic3r/GUI/PresetComboBoxes.hpp +++ b/src/slic3r/GUI/PresetComboBoxes.hpp @@ -71,6 +71,7 @@ public: void show_all(bool show_all); virtual void update(); virtual void msw_rescale(); + virtual void OnSelect(wxCommandEvent& evt); protected: typedef std::size_t Marker; @@ -167,6 +168,7 @@ public: wxString get_preset_name(const Preset& preset) override; void update() override; void msw_rescale() override; + void OnSelect(wxCommandEvent& evt) override; private: int m_extruder_idx = -1; @@ -193,6 +195,7 @@ public: void update() override; void update_dirty(); void msw_rescale() override; + void OnSelect(wxCommandEvent& evt) override; void set_enable_all(bool enable=true) { m_enable_all = enable; } diff --git a/src/slic3r/GUI/SavePresetDialog.cpp b/src/slic3r/GUI/SavePresetDialog.cpp index e659f8e02a..9c5e72fde1 100644 --- a/src/slic3r/GUI/SavePresetDialog.cpp +++ b/src/slic3r/GUI/SavePresetDialog.cpp @@ -209,12 +209,12 @@ SavePresetDialog::~SavePresetDialog() void SavePresetDialog::build(std::vector types, std::string suffix) { SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__) +#if defined(__WXMSW__) // ys_FIXME! temporary workaround for correct font scaling // Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts, // From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); -#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT +#endif // __WXMSW__ if (suffix.empty()) suffix = _CTX_utf8(L_CONTEXT("Copy", "PresetName"), "PresetName"); diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 473f7e6e17..7d2879f0a3 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -792,12 +792,12 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_ wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); SetBackgroundColour(bgr_clr); -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__) +#if defined(__WXMSW__) // ys_FIXME! temporary workaround for correct font scaling // Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts, // From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); -#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT +#endif // __WXMSW__ int border = 10; int em = em_unit(); @@ -1375,12 +1375,12 @@ DiffPresetDialog::DiffPresetDialog(MainFrame* mainframe) wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); SetBackgroundColour(bgr_clr); -#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__) +#if defined(__WXMSW__) // ys_FIXME! temporary workaround for correct font scaling // Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts, // From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); -#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT +#endif // __WXMSW__ int border = 10; int em = em_unit();