Merge branch 'master' into fs_emboss

# Conflicts:
#	src/libslic3r/Technologies.hpp
#	src/slic3r/GUI/GLCanvas3D.cpp
This commit is contained in:
Filip Sykala - NTB T15p 2022-09-29 18:47:21 +02:00
commit 0e3b7cae12
26 changed files with 884 additions and 1221 deletions

View File

@ -71,7 +71,7 @@ is currently unsupported because some of the dependencies don't support this, mo
Please note that the `CMAKE_OSX_DEPLOYMENT_TARGET` and `CMAKE_OSX_SYSROOT` options need to be set the same Please note that the `CMAKE_OSX_DEPLOYMENT_TARGET` and `CMAKE_OSX_SYSROOT` options need to be set the same
on both the dependencies bundle as well as PrusaSlicer itself. on both the dependencies bundle as well as PrusaSlicer itself.
Official Mac PrusaSlicer builds are currently built against SDK 10.9 to ensure compatibility with older Macs. Official macOS PrusaSlicer builds are currently (as of PrusaSlicer 2.5) built against SDK 10.12 to ensure compatibility with older Macs.
_Warning:_ XCode may be set such that it rejects SDKs bellow some version (silently, more or less). _Warning:_ XCode may be set such that it rejects SDKs bellow some version (silently, more or less).
This is set in the property list file This is set in the property list file

View File

@ -1,2 +1,3 @@
min_slic3r_version = 2.4.1-alpha0 min_slic3r_version = 2.4.1-alpha0
1.0.1 Various fixes and improvements. Commented filament sensor initialisation for v-Minion (optional HW).
1.0.0 Initial RatRig bundle 1.0.0 Initial RatRig bundle

View File

@ -9,7 +9,7 @@
name = RatRig name = RatRig
# Configuration version of this file. Config file will only be installed, if the config_version differs. # Configuration version of this file. Config file will only be installed, if the config_version differs.
# This means, the server may force the Slic3r configuration to be downgraded. # This means, the server may force the Slic3r configuration to be downgraded.
config_version = 1.0.0 config_version = 1.0.1
# Where to get the updates from? # Where to get the updates from?
config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/RatRig/ config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/RatRig/
# The printer models will be shown by the Configuration Wizard in this order, # The printer models will be shown by the Configuration Wizard in this order,
@ -25,7 +25,7 @@ technology = FFF
family = V-Core-3 family = V-Core-3
bed_model = rr-vc-300.stl bed_model = rr-vc-300.stl
bed_texture = rr-vc-300.svg bed_texture = rr-vc-300.svg
default_materials = Generic PETG V6 @RatRig; Generic PETG HF @RatRig; Generic PLA @RatRig; Esun ePA-CF @RatRig; Generic ABS @RatRig default_materials = Generic PETG V6 @RatRig; Generic PETG HF @RatRig; Generic PLA @RatRig; Esun ePA-CF @RatRig; Generic ABS @RatRig; Generic TPU @RatRig
[printer_model:VC3_400] [printer_model:VC3_400]
name = RatRig V-Core-3 400mm name = RatRig V-Core-3 400mm
@ -33,7 +33,7 @@ variants = 0.4
family = V-Core-3 family = V-Core-3
bed_model = rr-vc-400.stl bed_model = rr-vc-400.stl
bed_texture = rr-vc-400.svg bed_texture = rr-vc-400.svg
default_materials = Generic PETG V6 @RatRig; Generic PETG HF @RatRig; Generic PLA @RatRig; Esun ePA-CF @RatRig; Generic ABS @RatRig default_materials = Generic PETG V6 @RatRig; Generic PETG HF @RatRig; Generic PLA @RatRig; Esun ePA-CF @RatRig; Generic ABS @RatRig; Generic TPU @RatRig
[printer_model:VC3_500] [printer_model:VC3_500]
name = RatRig V-Core-3 500mm name = RatRig V-Core-3 500mm
@ -41,7 +41,7 @@ variants = 0.4
family = V-Core-3 family = V-Core-3
bed_model = rr-vc-500.stl bed_model = rr-vc-500.stl
bed_texture = rr-vc-500.svg bed_texture = rr-vc-500.svg
default_materials = Generic PETG V6 @RatRig; Generic PETG HF @RatRig; Generic PLA @RatRig; Esun ePA-CF @RatRig; Generic ABS @RatRig default_materials = Generic PETG V6 @RatRig; Generic PETG HF @RatRig; Generic PLA @RatRig; Esun ePA-CF @RatRig; Generic ABS @RatRig; Generic TPU @RatRig
[printer_model:VMINION] [printer_model:VMINION]
name = RatRig V-Minion name = RatRig V-Minion
@ -50,7 +50,7 @@ technology = FFF
family = V-Minion family = V-Minion
bed_model = rr-vminion.stl bed_model = rr-vminion.stl
bed_texture = rr-vminion.svg bed_texture = rr-vminion.svg
default_materials = Generic PETG V6 @RatRig; Generic PETG HF @RatRig; Generic PLA @RatRig; @Esun ePA-CF RatRig; Generic ABS @RatRig default_materials = Generic PETG V6 @RatRig; Generic PETG HF @RatRig; Generic PLA @RatRig; @Esun ePA-CF RatRig; Generic ABS @RatRig; Generic TPU @RatRig
[print:*common*] [print:*common*]
compatible_printers_condition = printer_model=~/.*VC3_.*/ and nozzle_diameter[0]==0.4 compatible_printers_condition = printer_model=~/.*VC3_.*/ and nozzle_diameter[0]==0.4
@ -75,7 +75,6 @@ dont_support_bridges = 1
draft_shield = 0 draft_shield = 0
ensure_vertical_shell_thickness = 1 ensure_vertical_shell_thickness = 1
exact_last_layer_height = 0 exact_last_layer_height = 0
external_infill_margin = 150%
external_perimeter_extrusion_width = 0.4 external_perimeter_extrusion_width = 0.4
external_perimeter_speed = 90% external_perimeter_speed = 90%
extruder_clearance_height = 25 extruder_clearance_height = 25
@ -116,7 +115,6 @@ notes =
only_retract_when_crossing_perimeters = 0 only_retract_when_crossing_perimeters = 0
ooze_prevention = 0 ooze_prevention = 0
output_filename_format = {input_filename_base}_{layer_height}mm_{filament_type[0]}_{print_time}.gcode output_filename_format = {input_filename_base}_{layer_height}mm_{filament_type[0]}_{print_time}.gcode
over_bridge_flow_ratio = 100%
perimeter_acceleration = 3000 perimeter_acceleration = 3000
perimeter_extruder = 1 perimeter_extruder = 1
perimeter_extrusion_width = 0.4 perimeter_extrusion_width = 0.4
@ -163,7 +161,6 @@ support_material_threshold = 65
support_material_with_sheath = 0 support_material_with_sheath = 0
support_material_xy_spacing = 60% support_material_xy_spacing = 60%
thin_walls = 0 thin_walls = 0
threads = 4
top_fill_pattern = monotonic top_fill_pattern = monotonic
top_infill_extrusion_width = 0.4 top_infill_extrusion_width = 0.4
top_solid_infill_speed = 60% top_solid_infill_speed = 60%
@ -437,7 +434,7 @@ retract_speed = 40
silent_mode = 0 silent_mode = 0
single_extruder_multi_material = 0 single_extruder_multi_material = 0
start_gcode = M190 S0 ; Prevents prusaslicer from prepending m190 to the gcode interfering with the macro\nM109 S0 ; Prevents prusaslicer from prepending m109 to the gcode interfering with the macro\nSTART_PRINT EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature]\n;enable this if you have a BTT Smart Filament Sensor\nSET_FILAMENT_SENSOR SENSOR=my_sensor ENABLE=0\n start_gcode = M190 S0 ; Prevents prusaslicer from prepending m190 to the gcode interfering with the macro\nM109 S0 ; Prevents prusaslicer from prepending m109 to the gcode interfering with the macro\nSTART_PRINT EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature]\n;enable this if you have a BTT Smart Filament Sensor\nSET_FILAMENT_SENSOR SENSOR=my_sensor ENABLE=0\n
thumbnails = 16x16,220x220 thumbnails = 64x64,400x300
toolchange_gcode = toolchange_gcode =
use_firmware_retraction = 0 use_firmware_retraction = 0
use_relative_e_distances = 1 use_relative_e_distances = 1
@ -499,10 +496,10 @@ retract_restart_extra_toolchange = 0
retract_speed = 40 retract_speed = 40
silent_mode = 0 silent_mode = 0
single_extruder_multi_material = 0 single_extruder_multi_material = 0
start_gcode = M190 S0 ; Prevents prusaslicer from prepending m190 to the gcode interfering with the macro\nM109 S0 ; Prevents prusaslicer from prepending m109 to the gcode interfering with the macro\nSTART_PRINT EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature]\n;enable this if you have a BTT Smart Filament Sensor\nSET_FILAMENT_SENSOR SENSOR=my_sensor ENABLE=0\n start_gcode = M190 S0 ; Prevents prusaslicer from prepending m190 to the gcode interfering with the macro\nM109 S0 ; Prevents prusaslicer from prepending m109 to the gcode interfering with the macro\nSTART_PRINT EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature]\n;enable this if you have a BTT Smart Filament Sensor\n; SET_FILAMENT_SENSOR SENSOR=my_sensor ENABLE=0\n
start_gcode_manual = 0 start_gcode_manual = 0
template_custom_gcode = template_custom_gcode =
thumbnails = 16x16,220x220 thumbnails = 64x64,400x300
thumbnails_color = #018aff thumbnails_color = #018aff
thumbnails_custom_color = 0 thumbnails_custom_color = 0
thumbnails_with_bed = 1 thumbnails_with_bed = 1
@ -744,4 +741,87 @@ min_fan_speed = 0
min_print_speed = 15 min_print_speed = 15
slowdown_below_layer_time = 10 slowdown_below_layer_time = 10
start_filament_gcode = "; Filament gcode\nSET_GCODE_OFFSET Z=0.0\n\n{if nozzle_diameter[0]==0.4} SET_PRESSURE_ADVANCE ADVANCE=0.045{elsif nozzle_diameter[0]==0.6}SET_PRESSURE_ADVANCE ADVANCE=0.02{endif}\n\n" start_filament_gcode = "; Filament gcode\nSET_GCODE_OFFSET Z=0.0\n\n{if nozzle_diameter[0]==0.4} SET_PRESSURE_ADVANCE ADVANCE=0.045{elsif nozzle_diameter[0]==0.6}SET_PRESSURE_ADVANCE ADVANCE=0.02{endif}\n\n"
temperature = 270 temperature = 270
[filament:Generic TPU @RatRig]
inherits = Generic PLA @RatRig
bed_temperature = 30
bridge_fan_speed = 100
bridge_internal_fan_speed = -1
chamber_temperature = 0
compatible_printers =
compatible_printers_condition =
compatible_prints =
compatible_prints_condition =
cooling = 1
disable_fan_first_layers = 2
end_filament_gcode = "; Filament-specific end gcode \n;END gcode for filament\n"
external_perimeter_fan_speed = -1
extrusion_multiplier = 0.89
fan_always_on = 1
fan_below_layer_time = 100
filament_colour = #FF00FF
filament_cooling_final_speed = 3.4
filament_cooling_initial_speed = 2.2
filament_cooling_moves = 4
filament_cooling_zone_pause = 0
filament_cost = 20
filament_custom_variables = ""
filament_density = 1.24
filament_deretract_speed = nil
filament_diameter = 1.75
filament_dip_extraction_speed = 70
filament_dip_insertion_speed = 33
filament_enable_toolchange_part_fan = 0
filament_enable_toolchange_temp = 0
filament_load_time = 0
filament_loading_speed = 28
filament_loading_speed_start = 3
filament_max_overlap = 100%
filament_max_speed = 0
filament_max_volumetric_speed = 5
filament_max_wipe_tower_speed = 0
filament_melt_zone_pause = 0
filament_minimal_purge_on_wipe_tower = 15
filament_notes = "This is a profile for TPU95A. It was tested with Anycubic TPU95A, but most of the economy TPU filaments behave pretty similar.\n\nYou will want to optimize the temperature. Even different colors of the same brand can require 10° more or less.\n\nIf you experience clogs or grinding, reduce the maximum volumetric speed!"
filament_ramming_parameters = "120 100 6.6 6.8 7.2 7.6 7.9 8.2 8.7 9.4 9.9 10.0| 0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6"
filament_retract_before_travel = nil
filament_retract_before_wipe = nil
filament_retract_layer_change = nil
filament_retract_length = 1
filament_retract_lift = 0.1
filament_retract_lift_above = nil
filament_retract_lift_below = nil
filament_retract_restart_extra = nil
filament_retract_speed = nil
filament_seam_gap = nil
filament_shrink = 100%
filament_skinnydip_distance = 31
filament_soluble = 0
filament_spool_weight = 0
filament_toolchange_delay = 0
filament_toolchange_part_fan_speed = 50
filament_toolchange_temp = 200
filament_type = FLEX
filament_unload_time = 0
filament_unloading_speed = 90
filament_unloading_speed_start = 100
filament_use_fast_skinnydip = 0
filament_use_skinnydip = 0
filament_vendor = Generic
filament_wipe = nil
filament_wipe_advanced_pigment = 0.5
filament_wipe_extra_perimeter = nil
filament_wipe_only_crossing = nil
filament_wipe_speed = nil
first_layer_bed_temperature = 30
first_layer_temperature = 220
full_fan_speed_layer = 4
max_fan_speed = 100
max_speed_reduction = 95%
min_fan_speed = 100
min_print_speed = 10
slowdown_below_layer_time = 8
start_filament_gcode = "; Filament gcode\nSET_GCODE_OFFSET Z=0\nSET_PRESSURE_ADVANCE ADVANCE=0.1"
temperature = 220
top_fan_speed = -1

View File

@ -710,6 +710,8 @@ Slic3r::Polylines diff_pl(const Slic3r::Polygons &subject, const Slic3r::Polygon
{ return _clipper_pl_closed(ClipperLib::ctDifference, ClipperUtils::PolygonsProvider(subject), ClipperUtils::PolygonsProvider(clip)); } { return _clipper_pl_closed(ClipperLib::ctDifference, ClipperUtils::PolygonsProvider(subject), ClipperUtils::PolygonsProvider(clip)); }
Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::Polygon &clip) Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::Polygon &clip)
{ return _clipper_pl_open(ClipperLib::ctIntersection, ClipperUtils::PolylinesProvider(subject), ClipperUtils::SinglePathProvider(clip.points)); } { return _clipper_pl_open(ClipperLib::ctIntersection, ClipperUtils::PolylinesProvider(subject), ClipperUtils::SinglePathProvider(clip.points)); }
Slic3r::Polylines intersection_pl(const Slic3r::Polyline &subject, const Slic3r::ExPolygon &clip)
{ return _clipper_pl_open(ClipperLib::ctIntersection, ClipperUtils::SinglePathProvider(subject.points), ClipperUtils::ExPolygonProvider(clip)); }
Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::ExPolygon &clip) Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::ExPolygon &clip)
{ return _clipper_pl_open(ClipperLib::ctIntersection, ClipperUtils::PolylinesProvider(subject), ClipperUtils::ExPolygonProvider(clip)); } { return _clipper_pl_open(ClipperLib::ctIntersection, ClipperUtils::PolylinesProvider(subject), ClipperUtils::ExPolygonProvider(clip)); }
Slic3r::Polylines intersection_pl(const Slic3r::Polyline &subject, const Slic3r::Polygons &clip) Slic3r::Polylines intersection_pl(const Slic3r::Polyline &subject, const Slic3r::Polygons &clip)

View File

@ -437,6 +437,7 @@ Slic3r::ExPolygons intersection_ex(const Slic3r::Surfaces &subject, const Slic3r
Slic3r::ExPolygons intersection_ex(const Slic3r::Surfaces &subject, const Slic3r::Surfaces &clip, ApplySafetyOffset do_safety_offset = ApplySafetyOffset::No); Slic3r::ExPolygons intersection_ex(const Slic3r::Surfaces &subject, const Slic3r::Surfaces &clip, ApplySafetyOffset do_safety_offset = ApplySafetyOffset::No);
Slic3r::ExPolygons intersection_ex(const Slic3r::SurfacesPtr &subject, const Slic3r::ExPolygons &clip, ApplySafetyOffset do_safety_offset = ApplySafetyOffset::No); Slic3r::ExPolygons intersection_ex(const Slic3r::SurfacesPtr &subject, const Slic3r::ExPolygons &clip, ApplySafetyOffset do_safety_offset = ApplySafetyOffset::No);
Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::Polygon &clip); Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::Polygon &clip);
Slic3r::Polylines intersection_pl(const Slic3r::Polyline &subject, const Slic3r::ExPolygon &clip);
Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::ExPolygon &clip); Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::ExPolygon &clip);
Slic3r::Polylines intersection_pl(const Slic3r::Polyline &subject, const Slic3r::Polygons &clip); Slic3r::Polylines intersection_pl(const Slic3r::Polyline &subject, const Slic3r::Polygons &clip);
Slic3r::Polylines intersection_pl(const Slic3r::Polyline &subject, const Slic3r::ExPolygons &clip); Slic3r::Polylines intersection_pl(const Slic3r::Polyline &subject, const Slic3r::ExPolygons &clip);

View File

@ -6,6 +6,66 @@
namespace Slic3r { namespace Slic3r {
class InfillPolylineClipper : public FillPlanePath::InfillPolylineOutput {
public:
InfillPolylineClipper(const BoundingBox bbox, const double scale_out) : FillPlanePath::InfillPolylineOutput(scale_out), m_bbox(bbox) {}
void add_point(const Vec2d &pt);
Points&& result() { return std::move(m_out); }
bool clips() const override { return true; }
private:
enum class Side {
Left = 1,
Right = 2,
Top = 4,
Bottom = 8
};
int sides(const Point &p) const {
return int(p.x() < m_bbox.min.x()) * int(Side::Left) +
int(p.x() > m_bbox.max.x()) * int(Side::Right) +
int(p.y() < m_bbox.min.y()) * int(Side::Bottom) +
int(p.y() > m_bbox.max.y()) * int(Side::Top);
};
// Bounding box to clip the polyline with.
BoundingBox m_bbox;
// Classification of the two last points processed.
int m_sides_prev;
int m_sides_this;
};
void InfillPolylineClipper::add_point(const Vec2d &fpt)
{
const Point pt{ this->scaled(fpt) };
if (m_out.size() < 2) {
// Collect the two first points and their status.
(m_out.empty() ? m_sides_prev : m_sides_this) = sides(pt);
m_out.emplace_back(pt);
} else {
// Classify the last inserted point, possibly remove it.
int sides_next = sides(pt);
if (// This point is inside. Take it.
m_sides_this == 0 ||
// Either this point is outside and previous or next is inside, or
// the edge possibly cuts corner of the bounding box.
(m_sides_prev & m_sides_this & sides_next) == 0) {
// Keep the last point.
m_sides_prev = m_sides_this;
} else {
// All the three points (this, prev, next) are outside at the same side.
// Ignore the last point.
m_out.pop_back();
}
// And save the current point.
m_out.emplace_back(pt);
m_sides_this = sides_next;
}
}
void FillPlanePath::_fill_surface_single( void FillPlanePath::_fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,
@ -13,37 +73,52 @@ void FillPlanePath::_fill_surface_single(
ExPolygon expolygon, ExPolygon expolygon,
Polylines &polylines_out) Polylines &polylines_out)
{ {
expolygon.rotate(- direction.first); expolygon.rotate(-direction.first);
coord_t distance_between_lines = coord_t(scale_(this->spacing) / params.density); //FIXME Vojtech: We are not sure whether the user expects the fill patterns on visible surfaces to be aligned across all the islands of a single layer.
// One may align for this->centered() to align the patterns for Archimedean Chords and Octagram Spiral patterns.
// align infill across layers using the object's bounding box const bool align = params.density < 0.995;
// Rotated bounding box of the whole object.
BoundingBox bounding_box = this->bounding_box.rotated(- direction.first); BoundingBox snug_bounding_box = get_extents(expolygon).inflated(SCALED_EPSILON);
Point shift = this->_centered() ? // Rotated bounding box of the area to fill in with the pattern.
BoundingBox bounding_box = align ?
// Sparse infill needs to be aligned across layers. Align infill across layers using the object's bounding box.
this->bounding_box.rotated(-direction.first) :
// Solid infill does not need to be aligned across layers, generate the infill pattern
// around the clipping expolygon only.
snug_bounding_box;
Point shift = this->centered() ?
bounding_box.center() : bounding_box.center() :
bounding_box.min; bounding_box.min;
expolygon.translate(-shift.x(), -shift.y()); expolygon.translate(-shift.x(), -shift.y());
bounding_box.translate(-shift.x(), -shift.y()); bounding_box.translate(-shift.x(), -shift.y());
Pointfs pts = _generate( Polyline polyline;
coord_t(ceil(coordf_t(bounding_box.min.x()) / distance_between_lines)), {
coord_t(ceil(coordf_t(bounding_box.min.y()) / distance_between_lines)), auto distance_between_lines = scaled<double>(this->spacing) / params.density;
coord_t(ceil(coordf_t(bounding_box.max.x()) / distance_between_lines)), auto min_x = coord_t(ceil(coordf_t(bounding_box.min.x()) / distance_between_lines));
coord_t(ceil(coordf_t(bounding_box.max.y()) / distance_between_lines)), auto min_y = coord_t(ceil(coordf_t(bounding_box.min.y()) / distance_between_lines));
params.resolution); auto max_x = coord_t(ceil(coordf_t(bounding_box.max.x()) / distance_between_lines));
auto max_y = coord_t(ceil(coordf_t(bounding_box.max.y()) / distance_between_lines));
auto resolution = scaled<double>(params.resolution) / distance_between_lines;
if (align) {
// Filling in a bounding box over the whole object, clip generated polyline against the snug bounding box.
snug_bounding_box.translate(-shift.x(), -shift.y());
InfillPolylineClipper output(snug_bounding_box, distance_between_lines);
this->generate(min_x, min_y, max_x, max_y, resolution, output);
polyline.points = std::move(output.result());
} else {
// Filling in a snug bounding box, no need to clip.
InfillPolylineOutput output(distance_between_lines);
this->generate(min_x, min_y, max_x, max_y, resolution, output);
polyline.points = std::move(output.result());
}
}
if (pts.size() >= 2) { if (polyline.size() >= 2) {
// Convert points to a polyline, upscale. Polylines polylines = intersection_pl(polyline, expolygon);
Polylines polylines(1, Polyline());
Polyline &polyline = polylines.front();
polyline.points.reserve(pts.size());
for (const Vec2d &pt : pts)
polyline.points.emplace_back(
coord_t(floor(pt.x() * distance_between_lines + 0.5)),
coord_t(floor(pt.y() * distance_between_lines + 0.5)));
polylines = intersection_pl(polylines, expolygon);
Polylines chained; Polylines chained;
if (params.dont_connect() || params.density > 0.5 || polylines.size() <= 1) if (params.dont_connect() || params.density > 0.5 || polylines.size() <= 1)
chained = chain_polylines(std::move(polylines)); chained = chain_polylines(std::move(polylines));
@ -59,7 +134,8 @@ void FillPlanePath::_fill_surface_single(
} }
// Follow an Archimedean spiral, in polar coordinates: r=a+b\theta // Follow an Archimedean spiral, in polar coordinates: r=a+b\theta
Pointfs FillArchimedeanChords::_generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution) template<typename Output>
static void generate_archimedean_chords(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution, Output &output)
{ {
// Radius to achieve. // Radius to achieve.
coordf_t rmax = std::sqrt(coordf_t(max_x)*coordf_t(max_x)+coordf_t(max_y)*coordf_t(max_y)) * std::sqrt(2.) + 1.5; coordf_t rmax = std::sqrt(coordf_t(max_x)*coordf_t(max_x)+coordf_t(max_y)*coordf_t(max_y)) * std::sqrt(2.) + 1.5;
@ -70,15 +146,22 @@ Pointfs FillArchimedeanChords::_generate(coord_t min_x, coord_t min_y, coord_t m
coordf_t r = 1; coordf_t r = 1;
Pointfs out; Pointfs out;
//FIXME Vojtech: If used as a solid infill, there is a gap left at the center. //FIXME Vojtech: If used as a solid infill, there is a gap left at the center.
out.emplace_back(0, 0); output.add_point({ 0, 0 });
out.emplace_back(1, 0); output.add_point({ 1, 0 });
while (r < rmax) { while (r < rmax) {
// Discretization angle to achieve a discretization error lower than resolution. // Discretization angle to achieve a discretization error lower than resolution.
theta += 2. * acos(1. - resolution / r); theta += 2. * acos(1. - resolution / r);
r = a + b * theta; r = a + b * theta;
out.emplace_back(r * cos(theta), r * sin(theta)); output.add_point({ r * cos(theta), r * sin(theta) });
} }
return out; }
void FillArchimedeanChords::generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution, InfillPolylineOutput &output)
{
if (output.clips())
generate_archimedean_chords(min_x, min_y, max_x, max_y, resolution, static_cast<InfillPolylineClipper&>(output));
else
generate_archimedean_chords(min_x, min_y, max_x, max_y, resolution, output);
} }
// Adapted from // Adapted from
@ -126,7 +209,8 @@ static inline Point hilbert_n_to_xy(const size_t n)
return Point(x, y); return Point(x, y);
} }
Pointfs FillHilbertCurve::_generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double /* resolution */) template<typename Output>
static void generate_hilbert_curve(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, Output &output)
{ {
// Minimum power of two square to fit the domain. // Minimum power of two square to fit the domain.
size_t sz = 2; size_t sz = 2;
@ -140,46 +224,59 @@ Pointfs FillHilbertCurve::_generate(coord_t min_x, coord_t min_y, coord_t max_x,
} }
size_t sz2 = sz * sz; size_t sz2 = sz * sz;
Pointfs line; output.reserve(sz2);
line.reserve(sz2);
for (size_t i = 0; i < sz2; ++ i) { for (size_t i = 0; i < sz2; ++ i) {
Point p = hilbert_n_to_xy(i); Point p = hilbert_n_to_xy(i);
line.emplace_back(p.x() + min_x, p.y() + min_y); output.add_point({ p.x() + min_x, p.y() + min_y });
} }
return line;
} }
Pointfs FillOctagramSpiral::_generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double /* resolution */) void FillHilbertCurve::generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double /* resolution */, InfillPolylineOutput &output)
{
if (output.clips())
generate_hilbert_curve(min_x, min_y, max_x, max_y, static_cast<InfillPolylineClipper&>(output));
else
generate_hilbert_curve(min_x, min_y, max_x, max_y, output);
}
template<typename Output>
static void generate_octagram_spiral(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, Output &output)
{ {
// Radius to achieve. // Radius to achieve.
coordf_t rmax = std::sqrt(coordf_t(max_x)*coordf_t(max_x)+coordf_t(max_y)*coordf_t(max_y)) * std::sqrt(2.) + 1.5; coordf_t rmax = std::sqrt(coordf_t(max_x)*coordf_t(max_x)+coordf_t(max_y)*coordf_t(max_y)) * std::sqrt(2.) + 1.5;
// Now unwind the spiral. // Now unwind the spiral.
coordf_t r = 0; coordf_t r = 0;
coordf_t r_inc = sqrt(2.); coordf_t r_inc = sqrt(2.);
Pointfs out; output.add_point({ 0., 0. });
out.emplace_back(0., 0.);
while (r < rmax) { while (r < rmax) {
r += r_inc; r += r_inc;
coordf_t rx = r / sqrt(2.); coordf_t rx = r / sqrt(2.);
coordf_t r2 = r + rx; coordf_t r2 = r + rx;
out.emplace_back( r, 0.); output.add_point({ r, 0. });
out.emplace_back( r2, rx); output.add_point({ r2, rx });
out.emplace_back( rx, rx); output.add_point({ rx, rx });
out.emplace_back( rx, r2); output.add_point({ rx, r2 });
out.emplace_back( 0., r); output.add_point({ 0., r });
out.emplace_back(-rx, r2); output.add_point({-rx, r2 });
out.emplace_back(-rx, rx); output.add_point({-rx, rx });
out.emplace_back(-r2, rx); output.add_point({-r2, rx });
out.emplace_back(- r, 0.); output.add_point({- r, 0. });
out.emplace_back(-r2, -rx); output.add_point({-r2, -rx });
out.emplace_back(-rx, -rx); output.add_point({-rx, -rx });
out.emplace_back(-rx, -r2); output.add_point({-rx, -r2 });
out.emplace_back( 0., -r); output.add_point({ 0., -r });
out.emplace_back( rx, -r2); output.add_point({ rx, -r2 });
out.emplace_back( rx, -rx); output.add_point({ rx, -rx });
out.emplace_back( r2+r_inc, -rx); output.add_point({ r2+r_inc, -rx });
} }
return out; }
void FillOctagramSpiral::generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double /* resolution */, InfillPolylineOutput &output)
{
if (output.clips())
generate_octagram_spiral(min_x, min_y, max_x, max_y, static_cast<InfillPolylineClipper&>(output));
else
generate_octagram_spiral(min_x, min_y, max_x, max_y, output);
} }
} // namespace Slic3r } // namespace Slic3r

View File

@ -27,8 +27,30 @@ protected:
Polylines &polylines_out) override; Polylines &polylines_out) override;
float _layer_angle(size_t idx) const override { return 0.f; } float _layer_angle(size_t idx) const override { return 0.f; }
virtual bool _centered() const = 0; virtual bool centered() const = 0;
virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution) = 0;
friend class InfillPolylineClipper;
class InfillPolylineOutput {
public:
InfillPolylineOutput(const double scale_out) : m_scale_out(scale_out) {}
void reserve(size_t n) { m_out.reserve(n); }
void add_point(const Vec2d& pt) { m_out.emplace_back(this->scaled(pt)); }
Points&& result() { return std::move(m_out); }
virtual bool clips() const { return false; }
protected:
const Point scaled(const Vec2d &fpt) const { return { coord_t(floor(fpt.x() * m_scale_out + 0.5)), coord_t(floor(fpt.y() * m_scale_out + 0.5)) }; }
// Output polyline.
Points m_out;
private:
// Scaling coefficient of the generated points before tested against m_bbox and clipped by bbox.
double m_scale_out;
};
virtual void generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution, InfillPolylineOutput &output) = 0;
}; };
class FillArchimedeanChords : public FillPlanePath class FillArchimedeanChords : public FillPlanePath
@ -38,8 +60,8 @@ public:
~FillArchimedeanChords() override = default; ~FillArchimedeanChords() override = default;
protected: protected:
bool _centered() const override { return true; } bool centered() const override { return true; }
Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution) override; void generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution, InfillPolylineOutput &output) override;
}; };
class FillHilbertCurve : public FillPlanePath class FillHilbertCurve : public FillPlanePath
@ -49,8 +71,8 @@ public:
~FillHilbertCurve() override = default; ~FillHilbertCurve() override = default;
protected: protected:
bool _centered() const override { return false; } bool centered() const override { return false; }
Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution) override; void generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution, InfillPolylineOutput &output) override;
}; };
class FillOctagramSpiral : public FillPlanePath class FillOctagramSpiral : public FillPlanePath
@ -60,8 +82,8 @@ public:
~FillOctagramSpiral() override = default; ~FillOctagramSpiral() override = default;
protected: protected:
bool _centered() const override { return true; } bool centered() const override { return true; }
Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution) override; void generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution, InfillPolylineOutput &output) override;
}; };
} // namespace Slic3r } // namespace Slic3r

View File

@ -199,9 +199,7 @@ void GCodeProcessor::TimeMachine::reset()
max_travel_acceleration = 0.0f; max_travel_acceleration = 0.0f;
extrude_factor_override_percentage = 1.0f; extrude_factor_override_percentage = 1.0f;
time = 0.0f; time = 0.0f;
#if ENABLE_TRAVEL_TIME
travel_time = 0.0f; travel_time = 0.0f;
#endif // ENABLE_TRAVEL_TIME
stop_times = std::vector<StopTime>(); stop_times = std::vector<StopTime>();
curr.reset(); curr.reset();
prev.reset(); prev.reset();
@ -317,17 +315,12 @@ void GCodeProcessor::TimeMachine::calculate_time(size_t keep_last_n_blocks, floa
block_time += additional_time; block_time += additional_time;
time += block_time; time += block_time;
#if ENABLE_TRAVEL_TIME
if (block.move_type == EMoveType::Travel) if (block.move_type == EMoveType::Travel)
travel_time += block_time; travel_time += block_time;
else else
roles_time[static_cast<size_t>(block.role)] += block_time; roles_time[static_cast<size_t>(block.role)] += block_time;
#endif // ENABLE_TRAVEL_TIME
gcode_time.cache += block_time; gcode_time.cache += block_time;
moves_time[static_cast<size_t>(block.move_type)] += block_time; moves_time[static_cast<size_t>(block.move_type)] += block_time;
#if !ENABLE_TRAVEL_TIME
roles_time[static_cast<size_t>(block.role)] += block_time;
#endif // !ENABLE_TRAVEL_TIME
if (block.layer_id >= layers_time.size()) { if (block.layer_id >= layers_time.size()) {
const size_t curr_size = layers_time.size(); const size_t curr_size = layers_time.size();
layers_time.resize(block.layer_id); layers_time.resize(block.layer_id);
@ -1465,7 +1458,6 @@ std::string GCodeProcessor::get_time_dhm(PrintEstimatedStatistics::ETimeMode mod
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].time)) : std::string("N/A"); return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].time)) : std::string("N/A");
} }
#if ENABLE_TRAVEL_TIME
float GCodeProcessor::get_travel_time(PrintEstimatedStatistics::ETimeMode mode) const float GCodeProcessor::get_travel_time(PrintEstimatedStatistics::ETimeMode mode) const
{ {
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? m_time_processor.machines[static_cast<size_t>(mode)].travel_time : 0.0f; return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? m_time_processor.machines[static_cast<size_t>(mode)].travel_time : 0.0f;
@ -1475,7 +1467,6 @@ std::string GCodeProcessor::get_travel_time_dhm(PrintEstimatedStatistics::ETimeM
{ {
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].travel_time)) : std::string("N/A"); return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].travel_time)) : std::string("N/A");
} }
#endif // ENABLE_TRAVEL_TIME
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> GCodeProcessor::get_custom_gcode_times(PrintEstimatedStatistics::ETimeMode mode, bool include_remaining) const std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> GCodeProcessor::get_custom_gcode_times(PrintEstimatedStatistics::ETimeMode mode, bool include_remaining) const
{ {
@ -4327,9 +4318,7 @@ void GCodeProcessor::update_estimated_times_stats()
auto update_mode = [this](PrintEstimatedStatistics::ETimeMode mode) { auto update_mode = [this](PrintEstimatedStatistics::ETimeMode mode) {
PrintEstimatedStatistics::Mode& data = m_result.print_statistics.modes[static_cast<size_t>(mode)]; PrintEstimatedStatistics::Mode& data = m_result.print_statistics.modes[static_cast<size_t>(mode)];
data.time = get_time(mode); data.time = get_time(mode);
#if ENABLE_TRAVEL_TIME
data.travel_time = get_travel_time(mode); data.travel_time = get_travel_time(mode);
#endif // ENABLE_TRAVEL_TIME
data.custom_gcode_times = get_custom_gcode_times(mode, true); data.custom_gcode_times = get_custom_gcode_times(mode, true);
data.moves_times = get_moves_time(mode); data.moves_times = get_moves_time(mode);
data.roles_times = get_roles_time(mode); data.roles_times = get_roles_time(mode);

View File

@ -44,9 +44,7 @@ namespace Slic3r {
struct Mode struct Mode
{ {
float time; float time;
#if ENABLE_TRAVEL_TIME
float travel_time; float travel_time;
#endif // ENABLE_TRAVEL_TIME
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> custom_gcode_times; std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> custom_gcode_times;
std::vector<std::pair<EMoveType, float>> moves_times; std::vector<std::pair<EMoveType, float>> moves_times;
std::vector<std::pair<ExtrusionRole, float>> roles_times; std::vector<std::pair<ExtrusionRole, float>> roles_times;
@ -54,9 +52,7 @@ namespace Slic3r {
void reset() { void reset() {
time = 0.0f; time = 0.0f;
#if ENABLE_TRAVEL_TIME
travel_time = 0.0f; travel_time = 0.0f;
#endif // ENABLE_TRAVEL_TIME
custom_gcode_times.clear(); custom_gcode_times.clear();
moves_times.clear(); moves_times.clear();
roles_times.clear(); roles_times.clear();
@ -307,9 +303,7 @@ namespace Slic3r {
float max_travel_acceleration; // mm/s^2 float max_travel_acceleration; // mm/s^2
float extrude_factor_override_percentage; float extrude_factor_override_percentage;
float time; // s float time; // s
#if ENABLE_TRAVEL_TIME
float travel_time; // s float travel_time; // s
#endif // ENABLE_TRAVEL_TIME
struct StopTime struct StopTime
{ {
unsigned int g1_line_id; unsigned int g1_line_id;
@ -635,10 +629,8 @@ namespace Slic3r {
float get_time(PrintEstimatedStatistics::ETimeMode mode) const; float get_time(PrintEstimatedStatistics::ETimeMode mode) const;
std::string get_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const; std::string get_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const;
#if ENABLE_TRAVEL_TIME
float get_travel_time(PrintEstimatedStatistics::ETimeMode mode) const; float get_travel_time(PrintEstimatedStatistics::ETimeMode mode) const;
std::string get_travel_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const; std::string get_travel_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const;
#endif // ENABLE_TRAVEL_TIME
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> get_custom_gcode_times(PrintEstimatedStatistics::ETimeMode mode, bool include_remaining) const; std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> get_custom_gcode_times(PrintEstimatedStatistics::ETimeMode mode, bool include_remaining) const;
std::vector<std::pair<EMoveType, float>> get_moves_time(PrintEstimatedStatistics::ETimeMode mode) const; std::vector<std::pair<EMoveType, float>> get_moves_time(PrintEstimatedStatistics::ETimeMode mode) const;

View File

@ -39,12 +39,6 @@
//==================== //====================
#define ENABLE_2_5_0_ALPHA1 1 #define ENABLE_2_5_0_ALPHA1 1
// Enable changes in preview layout
#define ENABLE_PREVIEW_LAYOUT (1 && ENABLE_2_5_0_ALPHA1)
// Enable drawing the items in legend toolbar using icons
#define ENABLE_LEGEND_TOOLBAR_ICONS (1 && ENABLE_PREVIEW_LAYOUT)
// Enable showing time estimate for travel moves in legend
#define ENABLE_TRAVEL_TIME (1 && ENABLE_2_5_0_ALPHA1)
// Enable removal of wipe tower magic object_id equal to 1000 // Enable removal of wipe tower magic object_id equal to 1000
#define ENABLE_WIPETOWER_OBJECTID_1000_REMOVAL (1 && ENABLE_2_5_0_ALPHA1) #define ENABLE_WIPETOWER_OBJECTID_1000_REMOVAL (1 && ENABLE_2_5_0_ALPHA1)
// Enable removal of legacy OpenGL calls // Enable removal of legacy OpenGL calls

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,6 @@ static constexpr const coord_t SUPPORT_TREE_COLLISION_RESOLUTION = scaled<coord_
// The number of vertices in each circle. // The number of vertices in each circle.
static constexpr const size_t SUPPORT_TREE_CIRCLE_RESOLUTION = 25; static constexpr const size_t SUPPORT_TREE_CIRCLE_RESOLUTION = 25;
static constexpr const bool SUPPORT_TREE_ONLY_GRACIOUS_TO_MODEL = false;
static constexpr const bool SUPPORT_TREE_AVOID_SUPPORT_BLOCKER = true; static constexpr const bool SUPPORT_TREE_AVOID_SUPPORT_BLOCKER = true;
enum class InterfacePreference enum class InterfacePreference
@ -93,72 +92,18 @@ struct AreaIncreaseSettings
struct TreeSupportSettings; struct TreeSupportSettings;
struct SupportElementID // C++17 does not support in place initializers of bit values, thus a constructor zeroing the bits is provided.
{ struct SupportElementStateBits {
/*! SupportElementStateBits() :
* \brief The layer this support elements wants reach to_buildplate(false),
*/ to_model_gracious(false),
LayerIndex target_height; use_min_xy_dist(false),
supports_roof(false),
/*! can_use_safe_radius(false),
* \brief The position this support elements wants to support on layer=target_height skip_ovalisation(false),
*/ deleted(false),
Point target_position; marked(false)
}; {}
struct SupportElementState : public SupportElementID
{
/*!
* \brief The next position this support elements wants to reach. NOTE: This is mainly a suggestion regarding direction inside the influence area.
*/
Point next_position;
/*!
* \brief The next height this support elements wants to reach
*/
LayerIndex next_height;
/*!
* \brief The Effective distance to top of this element regarding radius increases and collision calculations.
*/
uint32_t effective_radius_height;
/*!
* \brief The amount of layers this element is below the topmost layer of this branch.
*/
uint32_t distance_to_top;
/*!
* \brief The resulting center point around which a circle will be drawn later.
* Will be set by setPointsOnAreas
*/
Point result_on_layer { std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max() };
bool result_on_layer_is_set() const { return this->result_on_layer != Point{ std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max() }; }
void result_on_layer_reset() { this->result_on_layer = Point{ std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max() }; }
/*!
* \brief The amount of extra radius we got from merging branches that could have reached the buildplate, but merged with ones that can not.
*/
coord_t increased_to_model_radius; // how much to model we increased only relevant for merging
/*!
* \brief Counter about the times the elephant foot was increased. Can be fractions for merge reasons.
*/
double elephant_foot_increases;
/*!
* \brief The element trys not to move until this dtt is reached, is set to 0 if the element had to move.
*/
uint32_t dont_move_until;
/*!
* \brief Settings used to increase the influence area to its current state.
*/
AreaIncreaseSettings last_area_increase;
/*!
* \brief Amount of roof layers that were not yet added, because the branch needed to move.
*/
uint32_t missing_roof_layers;
/*! /*!
* \brief The element trys to reach the buildplate * \brief The element trys to reach the buildplate
@ -190,11 +135,83 @@ struct SupportElementState : public SupportElementID
*/ */
bool skip_ovalisation : 1; bool skip_ovalisation : 1;
// Not valid anymore, to be deleted.
bool deleted : 1;
// General purpose flag marking a visited element.
bool marked : 1;
};
struct SupportElementState : public SupportElementStateBits
{
/*!
* \brief The layer this support elements wants reach
*/
LayerIndex target_height;
/*!
* \brief The position this support elements wants to support on layer=target_height
*/
Point target_position;
/*!
* \brief The next position this support elements wants to reach. NOTE: This is mainly a suggestion regarding direction inside the influence area.
*/
Point next_position;
/*!
* \brief The next height this support elements wants to reach
*/
LayerIndex layer_idx;
/*!
* \brief The Effective distance to top of this element regarding radius increases and collision calculations.
*/
uint32_t effective_radius_height;
/*!
* \brief The amount of layers this element is below the topmost layer of this branch.
*/
uint32_t distance_to_top;
/*!
* \brief The resulting center point around which a circle will be drawn later.
* Will be set by setPointsOnAreas
*/
Point result_on_layer { std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max() };
bool result_on_layer_is_set() const { return this->result_on_layer != Point{ std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max() }; }
void result_on_layer_reset() { this->result_on_layer = Point{ std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max() }; }
/*!
* \brief The amount of extra radius we got from merging branches that could have reached the buildplate, but merged with ones that can not.
*/
coord_t increased_to_model_radius; // how much to model we increased only relevant for merging
/*!
* \brief Counter about the times the elephant foot was increased. Can be fractions for merge reasons.
*/
double elephant_foot_increases;
/*!
* \brief The element trys not to move until this dtt is reached, is set to 0 if the element had to move.
*/
uint32_t dont_move_until;
/*!
* \brief Settings used to increase the influence area to its current state.
*/
AreaIncreaseSettings last_area_increase;
/*!
* \brief Amount of roof layers that were not yet added, because the branch needed to move.
*/
uint32_t missing_roof_layers;
// called by increase_single_area() and increaseAreas() // called by increase_single_area() and increaseAreas()
[[nodiscard]] static SupportElementState propagate_down(const SupportElementState &src) [[nodiscard]] static SupportElementState propagate_down(const SupportElementState &src)
{ {
SupportElementState dst{ src }; SupportElementState dst{ src };
++ dst.distance_to_top; ++ dst.distance_to_top;
-- dst.layer_idx;
// set to invalid as we are a new node on a new layer // set to invalid as we are a new node on a new layer
dst.result_on_layer_reset(); dst.result_on_layer_reset();
dst.skip_ovalisation = false; dst.skip_ovalisation = false;
@ -204,22 +221,32 @@ struct SupportElementState : public SupportElementID
struct SupportElement struct SupportElement
{ {
using ParentIndices =
#ifdef NDEBUG
// To reduce memory allocation in release mode.
boost::container::small_vector<int32_t, 4>;
#else // NDEBUG
// To ease debugging.
std::vector<int32_t>;
#endif // NDEBUG
// SupportElement(const SupportElementState &state) : SupportElementState(state) {} // SupportElement(const SupportElementState &state) : SupportElementState(state) {}
SupportElement(const SupportElementState &state, Polygons &&influence_area) : state(state), influence_area(std::move(influence_area)) {} SupportElement(const SupportElementState &state, Polygons &&influence_area) : state(state), influence_area(std::move(influence_area)) {}
SupportElement(const SupportElementState &state, boost::container::small_vector<SupportElement*, 4> &&parents, Polygons &&influence_area) : SupportElement(const SupportElementState &state, ParentIndices &&parents, Polygons &&influence_area) :
state(state), parents(std::move(parents)), influence_area(std::move(influence_area)) {} state(state), parents(std::move(parents)), influence_area(std::move(influence_area)) {}
SupportElementState state; SupportElementState state;
/*! /*!
* \brief All elements in the layer above the current one that are supported by this element * \brief All elements in the layer above the current one that are supported by this element
*/ */
boost::container::small_vector<SupportElement*, 4> parents; ParentIndices parents;
/*! /*!
* \brief The resulting influence area. * \brief The resulting influence area.
* Will only be set in the results of createLayerPathing, and will be nullptr inside! * Will only be set in the results of createLayerPathing, and will be nullptr inside!
*/ */
Polygons influence_area; Polygons influence_area;
}; };
/*! /*!

View File

@ -111,7 +111,7 @@
</dict> </dict>
</array> </array>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>10.10</string> <string>10.12</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>NSApplication</string> <string>NSApplication</string>
<key>NSHighResolutionCapable</key> <key>NSHighResolutionCapable</key>

View File

@ -34,8 +34,11 @@ void BitmapCache::clear()
{ {
for (std::pair<const std::string, wxBitmap*> &bitmap : m_map) for (std::pair<const std::string, wxBitmap*> &bitmap : m_map)
delete bitmap.second; delete bitmap.second;
m_map.clear(); m_map.clear();
for (std::pair<const std::string, wxBitmapBundle*> &bitmap_bundle : m_bndl_map)
delete bitmap_bundle.second;
m_bndl_map.clear();
} }
static wxBitmap wxImage_to_wxBitmap_with_alpha(wxImage &&image, float scale = 1.0f) static wxBitmap wxImage_to_wxBitmap_with_alpha(wxImage &&image, float scale = 1.0f)

View File

@ -907,21 +907,10 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
// update buffers' render paths // update buffers' render paths
#if ENABLE_PREVIEW_LAYOUT
refresh_render_paths(false, false); refresh_render_paths(false, false);
#else
refresh_render_paths();
#endif // ENABLE_PREVIEW_LAYOUT
log_memory_used("Refreshed G-code extrusion paths, "); log_memory_used("Refreshed G-code extrusion paths, ");
} }
#if !ENABLE_PREVIEW_LAYOUT
void GCodeViewer::refresh_render_paths()
{
refresh_render_paths(false, false);
}
#endif // !ENABLE_PREVIEW_LAYOUT
void GCodeViewer::update_shells_color_by_extruder(const DynamicPrintConfig* config) void GCodeViewer::update_shells_color_by_extruder(const DynamicPrintConfig* config)
{ {
if (config != nullptr) if (config != nullptr)
@ -958,9 +947,7 @@ void GCodeViewer::reset()
m_statistics.reset_all(); m_statistics.reset_all();
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
m_contained_in_bed = true; m_contained_in_bed = true;
#if ENABLE_PREVIEW_LAYOUT
m_legend_resizer.reset(); m_legend_resizer.reset();
#endif // ENABLE_PREVIEW_LAYOUT
} }
void GCodeViewer::render() void GCodeViewer::render()
@ -1073,9 +1060,6 @@ unsigned int GCodeViewer::get_options_visibility_flags() const
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::CenterOfGravity), m_cog.is_visible()); flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::CenterOfGravity), m_cog.is_visible());
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::Shells), m_shells.visible); flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::Shells), m_shells.visible);
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::ToolMarker), m_sequential_view.marker.is_visible()); flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::ToolMarker), m_sequential_view.marker.is_visible());
#if !ENABLE_PREVIEW_LAYOUT
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::Legend), is_legend_enabled());
#endif // !ENABLE_PREVIEW_LAYOUT
return flags; return flags;
} }
@ -1097,9 +1081,6 @@ void GCodeViewer::set_options_visibility_from_flags(unsigned int flags)
m_cog.set_visible(is_flag_set(static_cast<unsigned int>(Preview::OptionType::CenterOfGravity))); m_cog.set_visible(is_flag_set(static_cast<unsigned int>(Preview::OptionType::CenterOfGravity)));
m_shells.visible = is_flag_set(static_cast<unsigned int>(Preview::OptionType::Shells)); m_shells.visible = is_flag_set(static_cast<unsigned int>(Preview::OptionType::Shells));
m_sequential_view.marker.set_visible(is_flag_set(static_cast<unsigned int>(Preview::OptionType::ToolMarker))); m_sequential_view.marker.set_visible(is_flag_set(static_cast<unsigned int>(Preview::OptionType::ToolMarker)));
#if !ENABLE_PREVIEW_LAYOUT
enable_legend(is_flag_set(static_cast<unsigned int>(Preview::OptionType::Legend)));
#endif // !ENABLE_PREVIEW_LAYOUT
} }
void GCodeViewer::set_layers_z_range(const std::array<unsigned int, 2>& layers_z_range) void GCodeViewer::set_layers_z_range(const std::array<unsigned int, 2>& layers_z_range)
@ -3434,11 +3415,7 @@ void GCodeViewer::render_legend(float& legend_height)
const float max_height = 0.75f * static_cast<float>(cnv_size.get_height()); const float max_height = 0.75f * static_cast<float>(cnv_size.get_height());
const float child_height = 0.3333f * max_height; const float child_height = 0.3333f * max_height;
ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, max_height }); ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, max_height });
#if ENABLE_PREVIEW_LAYOUT
imgui.begin(std::string("Legend"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove); imgui.begin(std::string("Legend"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
#else
imgui.begin(std::string("Legend"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove);
#endif // ENABLE_PREVIEW_LAYOUT
enum class EItemType : unsigned char enum class EItemType : unsigned char
{ {
@ -3537,7 +3514,6 @@ void GCodeViewer::render_legend(float& legend_height)
} }
else { else {
imgui.text(label); imgui.text(label);
#if ENABLE_TRAVEL_TIME
if (!time.empty()) { if (!time.empty()) {
ImGui::SameLine(offsets[0]); ImGui::SameLine(offsets[0]);
imgui.text(time); imgui.text(time);
@ -3553,9 +3529,6 @@ void GCodeViewer::render_legend(float& legend_height)
ImGui::TextUnformatted((percent > 0.0f) ? buf : ""); ImGui::TextUnformatted((percent > 0.0f) ? buf : "");
} }
else if (used_filament_m > 0.0) { else if (used_filament_m > 0.0) {
#else
if (used_filament_m > 0.0) {
#endif // ENABLE_TRAVEL_TIME
char buf[64]; char buf[64];
ImGui::SameLine(offsets[0]); ImGui::SameLine(offsets[0]);
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", used_filament_m); ::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", used_filament_m);
@ -3796,7 +3769,6 @@ void GCodeViewer::render_legend(float& legend_height)
offsets = calculate_offsets(labels, times, { "Extruder NNN", longest_used_filament_string }, icon_size); offsets = calculate_offsets(labels, times, { "Extruder NNN", longest_used_filament_string }, icon_size);
} }
#if ENABLE_PREVIEW_LAYOUT
// selection section // selection section
bool view_type_changed = false; bool view_type_changed = false;
int old_view_type = static_cast<int>(get_view_type()); int old_view_type = static_cast<int>(get_view_type());
@ -3834,160 +3806,124 @@ void GCodeViewer::render_legend(float& legend_height)
append_headers({ _u8L(""), _u8L("Used filament"), _u8L(""), _u8L("") }, offsets); append_headers({ _u8L(""), _u8L("Used filament"), _u8L(""), _u8L("") }, offsets);
else else
ImGui::Separator(); ImGui::Separator();
#else
// extrusion paths section -> title
switch (m_view_type)
{
case EViewType::FeatureType:
{
append_headers({ _u8L("Feature type"), _u8L("Time"), _u8L("Percentage"), _u8L("Used filament") }, offsets);
break;
}
case EViewType::Height: { imgui.title(_u8L("Height (mm)")); break; }
case EViewType::Width: { imgui.title(_u8L("Width (mm)")); break; }
case EViewType::Feedrate: { imgui.title(_u8L("Speed (mm/s)")); break; }
case EViewType::FanSpeed: { imgui.title(_u8L("Fan Speed (%)")); break; }
case EViewType::Temperature: { imgui.title(_u8L("Temperature (°C)")); break; }
case EViewType::VolumetricRate: { imgui.title(_u8L("Volumetric flow rate (mm³/s)")); break; }
case EViewType::LayerTimeLinear: { imgui.title(_u8L("Layer time (linear)")); break; }
case EViewType::LayerTimeLogarithmic: { imgui.title(_u8L("Layer time (logarithmic)")); break; }
case EViewType::Tool: {
append_headers({ _u8L("Tool"), _u8L("Used filament") }, offsets);
break;
}
case EViewType::ColorPrint: { imgui.title(_u8L("Color Print")); break; }
default: { break; }
}
#endif // ENABLE_PREVIEW_LAYOUT
#if ENABLE_PREVIEW_LAYOUT
if (!view_type_changed) { if (!view_type_changed) {
#endif // ENABLE_PREVIEW_LAYOUT // extrusion paths section -> items
// extrusion paths section -> items switch (m_view_type)
switch (m_view_type) {
{ case EViewType::FeatureType:
case EViewType::FeatureType: {
{ max_time_percent = std::max(max_time_percent, time_mode.travel_time / time_mode.time);
#if ENABLE_TRAVEL_TIME
max_time_percent = std::max(max_time_percent, time_mode.travel_time / time_mode.time);
#endif // ENABLE_TRAVEL_TIME
for (size_t i = 0; i < m_roles.size(); ++i) { for (size_t i = 0; i < m_roles.size(); ++i) {
ExtrusionRole role = m_roles[i]; ExtrusionRole role = m_roles[i];
if (role >= erCount) if (role >= erCount)
continue; continue;
const bool visible = is_visible(role); const bool visible = is_visible(role);
append_item(EItemType::Rect, Extrusion_Role_Colors[static_cast<unsigned int>(role)], labels[i], append_item(EItemType::Rect, Extrusion_Role_Colors[static_cast<unsigned int>(role)], labels[i],
visible, times[i], percents[i], max_time_percent, offsets, used_filaments_m[i], used_filaments_g[i], [this, role, visible]() { visible, times[i], percents[i], max_time_percent, offsets, used_filaments_m[i], used_filaments_g[i], [this, role, visible]() {
m_extrusions.role_visibility_flags = visible ? m_extrusions.role_visibility_flags & ~(1 << role) : m_extrusions.role_visibility_flags | (1 << role); m_extrusions.role_visibility_flags = visible ? m_extrusions.role_visibility_flags & ~(1 << role) : m_extrusions.role_visibility_flags | (1 << role);
// update buffers' render paths // update buffers' render paths
refresh_render_paths(false, false); refresh_render_paths(false, false);
wxGetApp().plater()->update_preview_moves_slider(); wxGetApp().plater()->update_preview_moves_slider();
wxGetApp().plater()->get_current_canvas3D()->set_as_dirty(); wxGetApp().plater()->get_current_canvas3D()->set_as_dirty();
#if !ENABLE_PREVIEW_LAYOUT
wxGetApp().plater()->update_preview_bottom_toolbar();
#endif // !ENABLE_PREVIEW_LAYOUT
}
);
}
#if ENABLE_TRAVEL_TIME
if (m_buffers[buffer_id(EMoveType::Travel)].visible)
append_item(EItemType::Line, Travel_Colors[0], _u8L("Travel"), true, short_time(get_time_dhms(time_mode.travel_time)),
time_mode.travel_time / time_mode.time, max_time_percent, offsets, 0.0f, 0.0f);
#endif // ENABLE_TRAVEL_TIME
break;
}
case EViewType::Height: { append_range(m_extrusions.ranges.height, 3); break; }
case EViewType::Width: { append_range(m_extrusions.ranges.width, 3); break; }
case EViewType::Feedrate: { append_range(m_extrusions.ranges.feedrate, 1); break; }
case EViewType::FanSpeed: { append_range(m_extrusions.ranges.fan_speed, 0); break; }
case EViewType::Temperature: { append_range(m_extrusions.ranges.temperature, 0); break; }
case EViewType::VolumetricRate: { append_range(m_extrusions.ranges.volumetric_rate, 3); break; }
case EViewType::LayerTimeLinear: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_time_estimate_mode)], Extrusions::Range::EType::Linear); break; }
case EViewType::LayerTimeLogarithmic: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_time_estimate_mode)], Extrusions::Range::EType::Logarithmic); break; }
case EViewType::Tool: {
// shows only extruders actually used
for (unsigned char extruder_id : m_extruder_ids) {
if (used_filaments_m[extruder_id] > 0.0 && used_filaments_g[extruder_id] > 0.0)
append_item(EItemType::Rect, m_tool_colors[extruder_id], _u8L("Extruder") + " " + std::to_string(extruder_id + 1),
true, "", 0.0f, 0.0f, offsets, used_filaments_m[extruder_id], used_filaments_g[extruder_id]);
}
break;
}
case EViewType::ColorPrint:
{
const std::vector<CustomGCode::Item>& custom_gcode_per_print_z = wxGetApp().is_editor() ? wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes : m_custom_gcode_per_print_z;
size_t total_items = 1;
for (unsigned char i : m_extruder_ids) {
total_items += color_print_ranges(i, custom_gcode_per_print_z).size();
}
const bool need_scrollable = static_cast<float>(total_items) * icon_size + (static_cast<float>(total_items) - 1.0f) * ImGui::GetStyle().ItemSpacing.y > child_height;
// add scrollable region, if needed
if (need_scrollable)
ImGui::BeginChild("color_prints", { -1.0f, child_height }, false);
if (m_extruders_count == 1) { // single extruder use case
const std::vector<std::pair<ColorRGBA, std::pair<double, double>>> cp_values = color_print_ranges(0, custom_gcode_per_print_z);
const int items_cnt = static_cast<int>(cp_values.size());
if (items_cnt == 0) // There are no color changes, but there are some pause print or custom Gcode
append_item(EItemType::Rect, m_tool_colors.front(), _u8L("Default color"));
else {
for (int i = items_cnt; i >= 0; --i) {
// create label for color change item
if (i == 0) {
append_item(EItemType::Rect, m_tool_colors[0], upto_label(cp_values.front().second.first));
break;
} }
else if (i == items_cnt) { );
append_item(EItemType::Rect, cp_values[i - 1].first, above_label(cp_values[i - 1].second.second));
continue;
}
append_item(EItemType::Rect, cp_values[i - 1].first, fromto_label(cp_values[i - 1].second.second, cp_values[i].second.first));
}
} }
if (m_buffers[buffer_id(EMoveType::Travel)].visible)
append_item(EItemType::Line, Travel_Colors[0], _u8L("Travel"), true, short_time(get_time_dhms(time_mode.travel_time)),
time_mode.travel_time / time_mode.time, max_time_percent, offsets, 0.0f, 0.0f);
break;
} }
else { // multi extruder use case case EViewType::Height: { append_range(m_extrusions.ranges.height, 3); break; }
case EViewType::Width: { append_range(m_extrusions.ranges.width, 3); break; }
case EViewType::Feedrate: { append_range(m_extrusions.ranges.feedrate, 1); break; }
case EViewType::FanSpeed: { append_range(m_extrusions.ranges.fan_speed, 0); break; }
case EViewType::Temperature: { append_range(m_extrusions.ranges.temperature, 0); break; }
case EViewType::VolumetricRate: { append_range(m_extrusions.ranges.volumetric_rate, 3); break; }
case EViewType::LayerTimeLinear: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_time_estimate_mode)], Extrusions::Range::EType::Linear); break; }
case EViewType::LayerTimeLogarithmic: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_time_estimate_mode)], Extrusions::Range::EType::Logarithmic); break; }
case EViewType::Tool: {
// shows only extruders actually used // shows only extruders actually used
for (unsigned char extruder_id : m_extruder_ids) {
if (used_filaments_m[extruder_id] > 0.0 && used_filaments_g[extruder_id] > 0.0)
append_item(EItemType::Rect, m_tool_colors[extruder_id], _u8L("Extruder") + " " + std::to_string(extruder_id + 1),
true, "", 0.0f, 0.0f, offsets, used_filaments_m[extruder_id], used_filaments_g[extruder_id]);
}
break;
}
case EViewType::ColorPrint:
{
const std::vector<CustomGCode::Item>& custom_gcode_per_print_z = wxGetApp().is_editor() ? wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes : m_custom_gcode_per_print_z;
size_t total_items = 1;
for (unsigned char i : m_extruder_ids) { for (unsigned char i : m_extruder_ids) {
const std::vector<std::pair<ColorRGBA, std::pair<double, double>>> cp_values = color_print_ranges(i, custom_gcode_per_print_z); total_items += color_print_ranges(i, custom_gcode_per_print_z).size();
}
const bool need_scrollable = static_cast<float>(total_items) * icon_size + (static_cast<float>(total_items) - 1.0f) * ImGui::GetStyle().ItemSpacing.y > child_height;
// add scrollable region, if needed
if (need_scrollable)
ImGui::BeginChild("color_prints", { -1.0f, child_height }, false);
if (m_extruders_count == 1) { // single extruder use case
const std::vector<std::pair<ColorRGBA, std::pair<double, double>>> cp_values = color_print_ranges(0, custom_gcode_per_print_z);
const int items_cnt = static_cast<int>(cp_values.size()); const int items_cnt = static_cast<int>(cp_values.size());
if (items_cnt == 0) if (items_cnt == 0) // There are no color changes, but there are some pause print or custom Gcode
// There are no color changes, but there are some pause print or custom Gcode append_item(EItemType::Rect, m_tool_colors.front(), _u8L("Default color"));
append_item(EItemType::Rect, m_tool_colors[i], _u8L("Extruder") + " " + std::to_string(i + 1) + " " + _u8L("default color"));
else { else {
for (int j = items_cnt; j >= 0; --j) { for (int i = items_cnt; i >= 0; --i) {
// create label for color change item // create label for color change item
std::string label = _u8L("Extruder") + " " + std::to_string(i + 1); if (i == 0) {
if (j == 0) { append_item(EItemType::Rect, m_tool_colors[0], upto_label(cp_values.front().second.first));
label += " " + upto_label(cp_values.front().second.first);
append_item(EItemType::Rect, m_tool_colors[i], label);
break; break;
} }
else if (j == items_cnt) { else if (i == items_cnt) {
label += " " + above_label(cp_values[j - 1].second.second); append_item(EItemType::Rect, cp_values[i - 1].first, above_label(cp_values[i - 1].second.second));
append_item(EItemType::Rect, cp_values[j - 1].first, label);
continue; continue;
} }
append_item(EItemType::Rect, cp_values[i - 1].first, fromto_label(cp_values[i - 1].second.second, cp_values[i].second.first));
label += " " + fromto_label(cp_values[j - 1].second.second, cp_values[j].second.first);
append_item(EItemType::Rect, cp_values[j - 1].first, label);
} }
} }
} }
} else { // multi extruder use case
if (need_scrollable) // shows only extruders actually used
ImGui::EndChild(); for (unsigned char i : m_extruder_ids) {
const std::vector<std::pair<ColorRGBA, std::pair<double, double>>> cp_values = color_print_ranges(i, custom_gcode_per_print_z);
const int items_cnt = static_cast<int>(cp_values.size());
if (items_cnt == 0)
// There are no color changes, but there are some pause print or custom Gcode
append_item(EItemType::Rect, m_tool_colors[i], _u8L("Extruder") + " " + std::to_string(i + 1) + " " + _u8L("default color"));
else {
for (int j = items_cnt; j >= 0; --j) {
// create label for color change item
std::string label = _u8L("Extruder") + " " + std::to_string(i + 1);
if (j == 0) {
label += " " + upto_label(cp_values.front().second.first);
append_item(EItemType::Rect, m_tool_colors[i], label);
break;
}
else if (j == items_cnt) {
label += " " + above_label(cp_values[j - 1].second.second);
append_item(EItemType::Rect, cp_values[j - 1].first, label);
continue;
}
break; label += " " + fromto_label(cp_values[j - 1].second.second, cp_values[j].second.first);
append_item(EItemType::Rect, cp_values[j - 1].first, label);
}
}
}
}
if (need_scrollable)
ImGui::EndChild();
break;
}
default: { break; }
}
} }
default: { break; }
}
#if ENABLE_PREVIEW_LAYOUT
}
#endif // ENABLE_PREVIEW_LAYOUT
// partial estimated printing time section // partial estimated printing time section
if (m_view_type == EViewType::ColorPrint) { if (m_view_type == EViewType::ColorPrint) {
@ -4164,89 +4100,6 @@ void GCodeViewer::render_legend(float& legend_height)
} }
} }
#if !ENABLE_PREVIEW_LAYOUT
// travel paths section
if (m_buffers[buffer_id(EMoveType::Travel)].visible) {
switch (m_view_type)
{
case EViewType::Feedrate:
case EViewType::Tool:
case EViewType::ColorPrint: {
break;
}
default: {
// title
ImGui::Spacing();
imgui.title(_u8L("Travel"));
// items
append_item(EItemType::Line, Travel_Colors[0], _u8L("Movement"));
append_item(EItemType::Line, Travel_Colors[1], _u8L("Extrusion"));
append_item(EItemType::Line, Travel_Colors[2], _u8L("Retraction"));
break;
}
}
}
// wipe paths section
if (m_buffers[buffer_id(EMoveType::Wipe)].visible) {
switch (m_view_type)
{
case EViewType::Feedrate:
case EViewType::Tool:
case EViewType::ColorPrint: { break; }
default: {
// title
ImGui::Spacing();
imgui.title(_u8L("Wipe"));
// items
append_item(EItemType::Line, Wipe_Color, _u8L("Wipe"));
break;
}
}
}
auto any_option_available = [this]() {
auto available = [this](EMoveType type) {
const TBuffer& buffer = m_buffers[buffer_id(type)];
return buffer.visible && buffer.has_data();
};
return available(EMoveType::Color_change) ||
available(EMoveType::Custom_GCode) ||
available(EMoveType::Pause_Print) ||
available(EMoveType::Retract) ||
available(EMoveType::Tool_change) ||
available(EMoveType::Unretract) ||
available(EMoveType::Seam);
};
auto add_option = [this, append_item](EMoveType move_type, EOptionsColors color, const std::string& text) {
const TBuffer& buffer = m_buffers[buffer_id(move_type)];
if (buffer.visible && buffer.has_data())
append_item(EItemType::Circle, Options_Colors[static_cast<unsigned int>(color)], text);
};
// options section
if (any_option_available()) {
// title
ImGui::Spacing();
imgui.title(_u8L("Options"));
// items
add_option(EMoveType::Retract, EOptionsColors::Retractions, _u8L("Retractions"));
add_option(EMoveType::Unretract, EOptionsColors::Unretractions, _u8L("Deretractions"));
add_option(EMoveType::Seam, EOptionsColors::Seams, _u8L("Seams"));
add_option(EMoveType::Tool_change, EOptionsColors::ToolChanges, _u8L("Tool changes"));
add_option(EMoveType::Color_change, EOptionsColors::ColorChanges, _u8L("Color changes"));
add_option(EMoveType::Pause_Print, EOptionsColors::PausePrints, _u8L("Print pauses"));
add_option(EMoveType::Custom_GCode, EOptionsColors::CustomGCodes, _u8L("Custom G-codes"));
}
#endif // !ENABLE_PREVIEW_LAYOUT
auto add_strings_row_to_table = [&imgui](const std::string& col_1, const ImVec4& col_1_color, const std::string& col_2, const ImVec4& col_2_color) { auto add_strings_row_to_table = [&imgui](const std::string& col_1, const ImVec4& col_1_color, const std::string& col_2, const ImVec4& col_2_color) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
@ -4369,7 +4222,6 @@ void GCodeViewer::render_legend(float& legend_height)
} }
} }
#if ENABLE_PREVIEW_LAYOUT
// toolbar section // toolbar section
auto toggle_button = [this, &imgui, icon_size](Preview::OptionType type, const std::string& name, auto toggle_button = [this, &imgui, icon_size](Preview::OptionType type, const std::string& name,
std::function<void(ImGuiWindow& window, const ImVec2& pos, float size)> draw_callback) { std::function<void(ImGuiWindow& window, const ImVec2& pos, float size)> draw_callback) {
@ -4409,7 +4261,6 @@ void GCodeViewer::render_legend(float& legend_height)
} }
}; };
#if ENABLE_LEGEND_TOOLBAR_ICONS
auto image_icon = [&imgui](ImGuiWindow& window, const ImVec2& pos, float size, const wchar_t& icon_id) { auto image_icon = [&imgui](ImGuiWindow& window, const ImVec2& pos, float size, const wchar_t& icon_id) {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
const ImTextureID tex_id = io.Fonts->TexID; const ImTextureID tex_id = io.Fonts->TexID;
@ -4420,163 +4271,59 @@ void GCodeViewer::render_legend(float& legend_height)
const ImVec2 uv1 = { static_cast<float>(rect->X + rect->Width) / tex_w, static_cast<float>(rect->Y + rect->Height) / tex_h }; const ImVec2 uv1 = { static_cast<float>(rect->X + rect->Width) / tex_w, static_cast<float>(rect->Y + rect->Height) / tex_h };
window.DrawList->AddImage(tex_id, pos, { pos.x + size, pos.y + size }, uv0, uv1, ImGuiWrapper::to_ImU32({ 1.0f, 1.0f, 1.0f, 1.0f })); window.DrawList->AddImage(tex_id, pos, { pos.x + size, pos.y + size }, uv0, uv1, ImGuiWrapper::to_ImU32({ 1.0f, 1.0f, 1.0f, 1.0f }));
}; };
#else
auto circle_icon = [](ImGuiWindow& window, const ImVec2& pos, float size, const ColorRGBA& color) {
const float margin = 3.0f;
const ImVec2 center(0.5f * (pos.x + pos.x + size), 0.5f * (pos.y + pos.y + size));
window.DrawList->AddCircleFilled(center, 0.5f * (size - 2.0f * margin), ImGuiWrapper::to_ImU32(color), 16);
};
auto line_icon = [](ImGuiWindow& window, const ImVec2& pos, float size, const ColorRGBA& color) {
const float margin = 3.0f;
window.DrawList->AddLine({ pos.x + margin, pos.y + size - margin }, { pos.x + size - margin, pos.y + margin }, ImGuiWrapper::to_ImU32(color), 3.0f);
};
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
ImGui::Spacing(); ImGui::Spacing();
ImGui::Separator(); ImGui::Separator();
ImGui::Spacing(); ImGui::Spacing();
ImGui::Spacing(); ImGui::Spacing();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::Travel, _u8L("Travel"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::Travel, _u8L("Travel"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendTravel); image_icon(window, pos, size, ImGui::LegendTravel);
#else
toggle_button(Preview::OptionType::Travel, _u8L("Travel"), [line_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
line_icon(window, pos, size, Travel_Colors[0]);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::Wipe, _u8L("Wipe"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::Wipe, _u8L("Wipe"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendWipe); image_icon(window, pos, size, ImGui::LegendWipe);
#else
toggle_button(Preview::OptionType::Wipe, _u8L("Wipe"), [line_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
line_icon(window, pos, size, Wipe_Color);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::Retractions, _u8L("Retractions"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::Retractions, _u8L("Retractions"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendRetract); image_icon(window, pos, size, ImGui::LegendRetract);
#else
toggle_button(Preview::OptionType::Retractions, _u8L("Retractions"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast<unsigned int>(EOptionsColors::Retractions)]);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::Unretractions, _u8L("Deretractions"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::Unretractions, _u8L("Deretractions"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendDeretract); image_icon(window, pos, size, ImGui::LegendDeretract);
#else
toggle_button(Preview::OptionType::Unretractions, _u8L("Deretractions"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast<unsigned int>(EOptionsColors::Unretractions)]);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::Seams, _u8L("Seams"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::Seams, _u8L("Seams"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendSeams); image_icon(window, pos, size, ImGui::LegendSeams);
#else
toggle_button(Preview::OptionType::Seams, _u8L("Seams"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast<unsigned int>(EOptionsColors::Seams)]);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::ToolChanges, _u8L("Tool changes"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::ToolChanges, _u8L("Tool changes"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendToolChanges); image_icon(window, pos, size, ImGui::LegendToolChanges);
#else
toggle_button(Preview::OptionType::ToolChanges, _u8L("Tool changes"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast<unsigned int>(EOptionsColors::ToolChanges)]);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::ColorChanges, _u8L("Color changes"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::ColorChanges, _u8L("Color changes"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendColorChanges); image_icon(window, pos, size, ImGui::LegendColorChanges);
#else
toggle_button(Preview::OptionType::ColorChanges, _u8L("Color changes"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast<unsigned int>(EOptionsColors::ColorChanges)]);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::PausePrints, _u8L("Print pauses"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::PausePrints, _u8L("Print pauses"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendPausePrints); image_icon(window, pos, size, ImGui::LegendPausePrints);
#else
toggle_button(Preview::OptionType::PausePrints, _u8L("Print pauses"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast<unsigned int>(EOptionsColors::PausePrints)]);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::CustomGCodes, _u8L("Custom G-codes"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::CustomGCodes, _u8L("Custom G-codes"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendCustomGCodes); image_icon(window, pos, size, ImGui::LegendCustomGCodes);
#else
toggle_button(Preview::OptionType::CustomGCodes, _u8L("Custom G-codes"), [circle_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
circle_icon(window, pos, size, Options_Colors[static_cast<unsigned int>(EOptionsColors::CustomGCodes)]);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::CenterOfGravity, _u8L("Center of gravity"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::CenterOfGravity, _u8L("Center of gravity"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendCOG); image_icon(window, pos, size, ImGui::LegendCOG);
}); });
#else
toggle_button(Preview::OptionType::CenterOfGravity, _u8L("Center of gravity"), [](ImGuiWindow& window, const ImVec2& pos, float size) {
const ImU32 black = ImGuiWrapper::to_ImU32({ 0.0f, 0.0f, 0.0f, 1.0f });
const ImU32 white = ImGuiWrapper::to_ImU32({ 1.0f, 1.0f, 1.0f, 1.0f });
const float margin = 3.0f;
const ImVec2 center(0.5f * (pos.x + pos.x + size), 0.5f * (pos.y + pos.y + size));
const float radius = 0.5f * (size - 2.0f * margin);
window.DrawList->PathArcToFast(center, radius, 0, 3);
window.DrawList->PathLineTo(center);
window.DrawList->PathFillConvex(black);
window.DrawList->PathArcToFast(center, radius, 3, 6);
window.DrawList->PathLineTo(center);
window.DrawList->PathFillConvex(white);
window.DrawList->PathArcToFast(center, radius, 6, 9);
window.DrawList->PathLineTo(center);
window.DrawList->PathFillConvex(black);
window.DrawList->PathArcToFast(center, radius, 9, 12);
window.DrawList->PathLineTo(center);
window.DrawList->PathFillConvex(white);
window.DrawList->AddCircle(center, radius, black, 16);
});
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
ImGui::SameLine(); ImGui::SameLine();
if (!wxGetApp().is_gcode_viewer()) { if (!wxGetApp().is_gcode_viewer()) {
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::Shells, _u8L("Shells"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::Shells, _u8L("Shells"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendShells); image_icon(window, pos, size, ImGui::LegendShells);
#else
toggle_button(Preview::OptionType::Shells, _u8L("Shells"), [](ImGuiWindow& window, const ImVec2& pos, float size) {
const ImU32 color = ImGuiWrapper::to_ImU32({ 1.0f, 1.0f, 1.0f, 1.0f });
const float margin = 3.0f;
const float proj = 0.25f * size;
window.DrawList->AddRect({ pos.x + margin, pos.y + size - margin }, { pos.x + size - margin - proj, pos.y + margin + proj }, color);
window.DrawList->AddLine({ pos.x + margin, pos.y + margin + proj }, { pos.x + margin + proj, pos.y + margin }, color);
window.DrawList->AddLine({ pos.x + size - margin - proj, pos.y + margin + proj }, { pos.x + size - margin, pos.y + margin }, color);
window.DrawList->AddLine({ pos.x + size - margin - proj, pos.y + size - margin }, { pos.x + size - margin, pos.y + size - margin - proj }, color);
window.DrawList->AddLine({ pos.x + margin + proj, pos.y + margin }, { pos.x + size - margin, pos.y + margin }, color);
window.DrawList->AddLine({ pos.x + size - margin, pos.y + margin }, { pos.x + size - margin, pos.y + size - margin - proj }, color);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
ImGui::SameLine(); ImGui::SameLine();
} }
#if ENABLE_LEGEND_TOOLBAR_ICONS
toggle_button(Preview::OptionType::ToolMarker, _u8L("Tool marker"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) { toggle_button(Preview::OptionType::ToolMarker, _u8L("Tool marker"), [image_icon](ImGuiWindow& window, const ImVec2& pos, float size) {
image_icon(window, pos, size, ImGui::LegendToolMarker); image_icon(window, pos, size, ImGui::LegendToolMarker);
#else
toggle_button(Preview::OptionType::ToolMarker, _u8L("Tool marker"), [](ImGuiWindow& window, const ImVec2& pos, float size) {
const ImU32 color = ImGuiWrapper::to_ImU32({ 1.0f, 1.0f, 1.0f, 0.8f });
const float margin = 3.0f;
const ImVec2 p1(0.5f * (pos.x + pos.x + size), pos.y + size - margin);
const ImVec2 p2(p1.x + 0.25f * size, p1.y - 0.25f * size);
const ImVec2 p3(p1.x - 0.25f * size, p1.y - 0.25f * size);
window.DrawList->AddTriangleFilled(p1, p2, p3, color);
const float mid_x = 0.5f * (pos.x + pos.x + size);
window.DrawList->AddRectFilled({ mid_x - 0.09375f * size, p1.y - 0.25f * size }, { mid_x + 0.09375f * size, pos.y + margin }, color);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
}); });
bool size_dirty = !ImGui::GetCurrentWindow()->ScrollbarY && ImGui::CalcWindowNextAutoFitSize(ImGui::GetCurrentWindow()).x != ImGui::GetWindowWidth(); bool size_dirty = !ImGui::GetCurrentWindow()->ScrollbarY && ImGui::CalcWindowNextAutoFitSize(ImGui::GetCurrentWindow()).x != ImGui::GetWindowWidth();
@ -4585,7 +4332,6 @@ void GCodeViewer::render_legend(float& legend_height)
wxGetApp().plater()->get_current_canvas3D()->request_extra_frame(); wxGetApp().plater()->get_current_canvas3D()->request_extra_frame();
} }
m_legend_resizer.dirty = size_dirty; m_legend_resizer.dirty = size_dirty;
#endif // ENABLE_PREVIEW_LAYOUT
legend_height = ImGui::GetWindowHeight(); legend_height = ImGui::GetWindowHeight();

View File

@ -773,14 +773,12 @@ private:
COG m_cog; COG m_cog;
EViewType m_view_type{ EViewType::FeatureType }; EViewType m_view_type{ EViewType::FeatureType };
bool m_legend_enabled{ true }; bool m_legend_enabled{ true };
#if ENABLE_PREVIEW_LAYOUT
struct LegendResizer struct LegendResizer
{ {
bool dirty{ true }; bool dirty{ true };
void reset() { dirty = true; } void reset() { dirty = true; }
}; };
LegendResizer m_legend_resizer; LegendResizer m_legend_resizer;
#endif // ENABLE_PREVIEW_LAYOUT
PrintEstimatedStatistics m_print_statistics; PrintEstimatedStatistics m_print_statistics;
PrintEstimatedStatistics::ETimeMode m_time_estimate_mode{ PrintEstimatedStatistics::ETimeMode::Normal }; PrintEstimatedStatistics::ETimeMode m_time_estimate_mode{ PrintEstimatedStatistics::ETimeMode::Normal };
#if ENABLE_GCODE_VIEWER_STATISTICS #if ENABLE_GCODE_VIEWER_STATISTICS
@ -808,11 +806,7 @@ public:
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
// recalculate ranges in dependence of what is visible and sets tool/print colors // recalculate ranges in dependence of what is visible and sets tool/print colors
void refresh(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors); void refresh(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
#if ENABLE_PREVIEW_LAYOUT
void refresh_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) const; void refresh_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) const;
#else
void refresh_render_paths();
#endif // ENABLE_PREVIEW_LAYOUT
void update_shells_color_by_extruder(const DynamicPrintConfig* config); void update_shells_color_by_extruder(const DynamicPrintConfig* config);
void reset(); void reset();
@ -857,9 +851,7 @@ public:
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; } std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; }
size_t get_extruders_count() { return m_extruders_count; } size_t get_extruders_count() { return m_extruders_count; }
#if ENABLE_PREVIEW_LAYOUT
void invalidate_legend() { m_legend_resizer.reset(); } void invalidate_legend() { m_legend_resizer.reset(); }
#endif // ENABLE_PREVIEW_LAYOUT
private: private:
void load_toolpaths(const GCodeProcessorResult& gcode_result); void load_toolpaths(const GCodeProcessorResult& gcode_result);
@ -868,9 +860,6 @@ private:
#else #else
void load_shells(const Print& print, bool initialized); void load_shells(const Print& print, bool initialized);
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if !ENABLE_PREVIEW_LAYOUT
void refresh_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) const;
#endif // !ENABLE_PREVIEW_LAYOUT
void render_toolpaths(); void render_toolpaths();
void render_shells(); void render_shells();
void render_legend(float& legend_height); void render_legend(float& legend_height);

View File

@ -2506,21 +2506,12 @@ void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, co
request_extra_frame(); request_extra_frame();
} }
#if ENABLE_PREVIEW_LAYOUT
void GLCanvas3D::refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) void GLCanvas3D::refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last)
{ {
m_gcode_viewer.refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last); m_gcode_viewer.refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last);
set_as_dirty(); set_as_dirty();
request_extra_frame(); request_extra_frame();
} }
#else
void GLCanvas3D::refresh_gcode_preview_render_paths()
{
m_gcode_viewer.refresh_render_paths();
set_as_dirty();
request_extra_frame();
}
#endif // ENABLE_PREVIEW_LAYOUT
void GLCanvas3D::load_sla_preview() void GLCanvas3D::load_sla_preview()
{ {
@ -2827,15 +2818,8 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
case 'k': { wxGetApp().plater()->get_camera().select_next_type(); m_dirty = true; break; } case 'k': { wxGetApp().plater()->get_camera().select_next_type(); m_dirty = true; break; }
case 'L': case 'L':
case 'l': { case 'l': {
if (!m_main_toolbar.is_enabled()) { if (!m_main_toolbar.is_enabled())
#if ENABLE_PREVIEW_LAYOUT
show_legend(!is_legend_shown()); show_legend(!is_legend_shown());
#else
m_gcode_viewer.enable_legend(!m_gcode_viewer.is_legend_enabled());
m_dirty = true;
wxGetApp().plater()->update_preview_bottom_toolbar();
#endif // ENABLE_PREVIEW_LAYOUT
}
break; break;
} }
case 'O': case 'O':
@ -4302,9 +4286,7 @@ void GLCanvas3D::set_cursor(ECursorType type)
void GLCanvas3D::msw_rescale() void GLCanvas3D::msw_rescale()
{ {
#if ENABLE_PREVIEW_LAYOUT
m_gcode_viewer.invalidate_legend(); m_gcode_viewer.invalidate_legend();
#endif // ENABLE_PREVIEW_LAYOUT
} }
void GLCanvas3D::update_tooltip_for_settings_item_in_main_toolbar() void GLCanvas3D::update_tooltip_for_settings_item_in_main_toolbar()

View File

@ -817,11 +817,7 @@ public:
void reload_scene(bool refresh_immediately, bool force_full_scene_refresh = false); void reload_scene(bool refresh_immediately, bool force_full_scene_refresh = false);
void load_gcode_preview(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors); void load_gcode_preview(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
#if ENABLE_PREVIEW_LAYOUT
void refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last); void refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last);
#else
void refresh_gcode_preview_render_paths();
#endif // ENABLE_PREVIEW_LAYOUT
void set_gcode_view_preview_type(GCodeViewer::EViewType type) { return m_gcode_viewer.set_view_type(type); } void set_gcode_view_preview_type(GCodeViewer::EViewType type) { return m_gcode_viewer.set_view_type(type); }
GCodeViewer::EViewType get_gcode_view_preview_type() const { return m_gcode_viewer.get_view_type(); } GCodeViewer::EViewType get_gcode_view_preview_type() const { return m_gcode_viewer.get_view_type(); }
void load_sla_preview(); void load_sla_preview();
@ -921,10 +917,8 @@ public:
bool are_labels_shown() const { return m_labels.is_shown(); } bool are_labels_shown() const { return m_labels.is_shown(); }
void show_labels(bool show) { m_labels.show(show); } void show_labels(bool show) { m_labels.show(show); }
#if ENABLE_PREVIEW_LAYOUT
bool is_legend_shown() const { return m_gcode_viewer.is_legend_enabled(); } bool is_legend_shown() const { return m_gcode_viewer.is_legend_enabled(); }
void show_legend(bool show) { m_gcode_viewer.enable_legend(show); m_dirty = true; } void show_legend(bool show) { m_gcode_viewer.enable_legend(show); m_dirty = true; }
#endif // ENABLE_PREVIEW_LAYOUT
bool is_using_slope() const { return m_slope.is_used(); } bool is_using_slope() const { return m_slope.is_used(); }
void use_slope(bool use) { m_slope.use(use); } void use_slope(bool use) { m_slope.use(use); }

View File

@ -208,73 +208,6 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Model* model)
m_layers_slider_sizer = create_layers_slider_sizer(); m_layers_slider_sizer = create_layers_slider_sizer();
wxGetApp().UpdateDarkUI(m_bottom_toolbar_panel = new wxPanel(this)); wxGetApp().UpdateDarkUI(m_bottom_toolbar_panel = new wxPanel(this));
#if !ENABLE_PREVIEW_LAYOUT
m_label_view_type = new wxStaticText(m_bottom_toolbar_panel, wxID_ANY, _L("View"));
#ifdef _WIN32
wxGetApp().UpdateDarkUI(m_choice_view_type = new BitmapComboBox(m_bottom_toolbar_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY));
#else
m_choice_view_type = new wxComboBox(m_bottom_toolbar_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
#endif
m_choice_view_type->Append(_L("Feature type"));
m_choice_view_type->Append(_L("Height"));
m_choice_view_type->Append(_L("Width"));
m_choice_view_type->Append(_L("Speed"));
m_choice_view_type->Append(_L("Fan speed"));
m_choice_view_type->Append(_L("Temperature"));
m_choice_view_type->Append(_L("Volumetric flow rate"));
m_choice_view_type->Append(_L("Layer time (linear)"));
m_choice_view_type->Append(_L("Layer time (logarithmic)"));
m_choice_view_type->Append(_L("Tool"));
m_choice_view_type->Append(_L("Color Print"));
m_choice_view_type->SetSelection(0);
m_label_show = new wxStaticText(m_bottom_toolbar_panel, wxID_ANY, _L("Show"));
#ifdef _WIN32
long combo_style = wxCB_READONLY | wxBORDER_SIMPLE; //set border allows use default color instead of theme color wich is allways light under MSW
#else
long combo_style = wxCB_READONLY;
#endif
m_combochecklist_features = new wxComboCtrl();
m_combochecklist_features->Create(m_bottom_toolbar_panel, wxID_ANY, _L("Feature types"), wxDefaultPosition, wxDefaultSize, combo_style);
std::string feature_items = GUI::into_u8(
_L("Unknown") + "|1|" +
_L("Perimeter") + "|1|" +
_L("External perimeter") + "|1|" +
_L("Overhang perimeter") + "|1|" +
_L("Internal infill") + "|1|" +
_L("Solid infill") + "|1|" +
_L("Top solid infill") + "|1|" +
_L("Ironing") + "|1|" +
_L("Bridge infill") + "|1|" +
_L("Gap fill") + "|1|" +
_L("Skirt/Brim") + "|1|" +
_L("Support material") + "|1|" +
_L("Support material interface") + "|1|" +
_L("Wipe tower") + "|1|" +
_L("Custom") + "|1"
);
Slic3r::GUI::create_combochecklist(m_combochecklist_features, GUI::into_u8(_L("Feature types")), feature_items);
m_combochecklist_options = new wxComboCtrl();
m_combochecklist_options->Create(m_bottom_toolbar_panel, wxID_ANY, _L("Options"), wxDefaultPosition, wxDefaultSize, combo_style);
std::string options_items = GUI::into_u8(
get_option_type_string(OptionType::Travel) + "|0|" +
get_option_type_string(OptionType::Wipe) + "|0|" +
get_option_type_string(OptionType::Retractions) + "|0|" +
get_option_type_string(OptionType::Unretractions) + "|0|" +
get_option_type_string(OptionType::Seams) + "|0|" +
get_option_type_string(OptionType::ToolChanges) + "|0|" +
get_option_type_string(OptionType::ColorChanges) + "|0|" +
get_option_type_string(OptionType::PausePrints) + "|0|" +
get_option_type_string(OptionType::CustomGCodes) + "|0|" +
get_option_type_string(OptionType::Shells) + "|0|" +
get_option_type_string(OptionType::ToolMarker) + "|1|" +
get_option_type_string(OptionType::Legend) + "|1"
);
Slic3r::GUI::create_combochecklist(m_combochecklist_options, GUI::into_u8(_L("Options")), options_items);
#endif // !ENABLE_PREVIEW_LAYOUT
m_left_sizer = new wxBoxSizer(wxVERTICAL); m_left_sizer = new wxBoxSizer(wxVERTICAL);
m_left_sizer->Add(m_canvas_widget, 1, wxALL | wxEXPAND, 0); m_left_sizer->Add(m_canvas_widget, 1, wxALL | wxEXPAND, 0);
@ -286,19 +219,6 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Model* model)
m_moves_slider->SetDrawMode(DoubleSlider::dmSequentialGCodeView); m_moves_slider->SetDrawMode(DoubleSlider::dmSequentialGCodeView);
wxBoxSizer* bottom_toolbar_sizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* bottom_toolbar_sizer = new wxBoxSizer(wxHORIZONTAL);
#if !ENABLE_PREVIEW_LAYOUT
bottom_toolbar_sizer->AddSpacer(5);
bottom_toolbar_sizer->Add(m_label_view_type, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
bottom_toolbar_sizer->Add(m_choice_view_type, 0, wxALIGN_CENTER_VERTICAL, 0);
bottom_toolbar_sizer->AddSpacer(5);
bottom_toolbar_sizer->Add(m_label_show, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
bottom_toolbar_sizer->Add(m_combochecklist_options, 0, wxALIGN_CENTER_VERTICAL, 0);
// change the following number if editing the layout of the bottom toolbar sizer. It is used into update_bottom_toolbar()
m_combochecklist_features_pos = 6;
bottom_toolbar_sizer->Add(m_combochecklist_features, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5);
bottom_toolbar_sizer->Hide(m_combochecklist_features);
bottom_toolbar_sizer->AddSpacer(5);
#endif // !ENABLE_PREVIEW_LAYOUT
bottom_toolbar_sizer->Add(m_moves_slider, 1, wxALL | wxEXPAND, 0); bottom_toolbar_sizer->Add(m_moves_slider, 1, wxALL | wxEXPAND, 0);
m_bottom_toolbar_panel->SetSizer(bottom_toolbar_sizer); m_bottom_toolbar_panel->SetSizer(bottom_toolbar_sizer);
@ -360,9 +280,6 @@ void Preview::load_print(bool keep_z_range)
else if (tech == ptSLA) else if (tech == ptSLA)
load_print_as_sla(); load_print_as_sla();
#if !ENABLE_PREVIEW_LAYOUT
update_bottom_toolbar();
#endif // !ENABLE_PREVIEW_LAYOUT
Layout(); Layout();
} }
@ -405,12 +322,6 @@ void Preview::refresh_print()
void Preview::msw_rescale() void Preview::msw_rescale()
{ {
#if !ENABLE_PREVIEW_LAYOUT
#ifdef _WIN32
m_choice_view_type->Rescale();
m_choice_view_type->SetMinSize(m_choice_view_type->GetSize());
#endif
#endif // !ENABLE_PREVIEW_LAYOUT
// rescale slider // rescale slider
if (m_layers_slider != nullptr) m_layers_slider->msw_rescale(); if (m_layers_slider != nullptr) m_layers_slider->msw_rescale();
if (m_moves_slider != nullptr) m_moves_slider->msw_rescale(); if (m_moves_slider != nullptr) m_moves_slider->msw_rescale();
@ -426,16 +337,8 @@ void Preview::sys_color_changed()
{ {
#ifdef _WIN32 #ifdef _WIN32
wxWindowUpdateLocker noUpdates(this); wxWindowUpdateLocker noUpdates(this);
wxGetApp().UpdateAllStaticTextDarkUI(m_bottom_toolbar_panel); wxGetApp().UpdateAllStaticTextDarkUI(m_bottom_toolbar_panel);
#if !ENABLE_PREVIEW_LAYOUT #endif // _WIN32
wxGetApp().UpdateDarkUI(m_choice_view_type);
wxGetApp().UpdateDarkUI(m_combochecklist_features);
wxGetApp().UpdateDarkUI(static_cast<wxCheckListBoxComboPopup*>(m_combochecklist_features->GetPopupControl()));
wxGetApp().UpdateDarkUI(m_combochecklist_options);
wxGetApp().UpdateDarkUI(static_cast<wxCheckListBoxComboPopup*>(m_combochecklist_options->GetPopupControl()));
#endif // !ENABLE_PREVIEW_LAYOUT
#endif
if (m_layers_slider != nullptr) if (m_layers_slider != nullptr)
m_layers_slider->sys_color_changed(); m_layers_slider->sys_color_changed();
@ -459,22 +362,12 @@ void Preview::edit_layers_slider(wxKeyEvent& evt)
void Preview::bind_event_handlers() void Preview::bind_event_handlers()
{ {
Bind(wxEVT_SIZE, &Preview::on_size, this); Bind(wxEVT_SIZE, &Preview::on_size, this);
#if !ENABLE_PREVIEW_LAYOUT
m_choice_view_type->Bind(wxEVT_COMBOBOX, &Preview::on_choice_view_type, this);
m_combochecklist_features->Bind(wxEVT_CHECKLISTBOX, &Preview::on_combochecklist_features, this);
m_combochecklist_options->Bind(wxEVT_CHECKLISTBOX, &Preview::on_combochecklist_options, this);
#endif // !ENABLE_PREVIEW_LAYOUT
m_moves_slider->Bind(wxEVT_SCROLL_CHANGED, &Preview::on_moves_slider_scroll_changed, this); m_moves_slider->Bind(wxEVT_SCROLL_CHANGED, &Preview::on_moves_slider_scroll_changed, this);
} }
void Preview::unbind_event_handlers() void Preview::unbind_event_handlers()
{ {
Unbind(wxEVT_SIZE, &Preview::on_size, this); Unbind(wxEVT_SIZE, &Preview::on_size, this);
#if !ENABLE_PREVIEW_LAYOUT
m_choice_view_type->Unbind(wxEVT_COMBOBOX, &Preview::on_choice_view_type, this);
m_combochecklist_features->Unbind(wxEVT_CHECKLISTBOX, &Preview::on_combochecklist_features, this);
m_combochecklist_options->Unbind(wxEVT_CHECKLISTBOX, &Preview::on_combochecklist_options, this);
#endif // !ENABLE_PREVIEW_LAYOUT
m_moves_slider->Unbind(wxEVT_SCROLL_CHANGED, &Preview::on_moves_slider_scroll_changed, this); m_moves_slider->Unbind(wxEVT_SCROLL_CHANGED, &Preview::on_moves_slider_scroll_changed, this);
} }
@ -495,75 +388,6 @@ void Preview::on_size(wxSizeEvent& evt)
Refresh(); Refresh();
} }
#if !ENABLE_PREVIEW_LAYOUT
void Preview::on_choice_view_type(wxCommandEvent& evt)
{
int selection = m_choice_view_type->GetCurrentSelection();
if (0 <= selection && selection < static_cast<int>(GCodeViewer::EViewType::Count)) {
m_canvas->set_toolpath_view_type(static_cast<GCodeViewer::EViewType>(selection));
m_keep_current_preview_type = true;
}
refresh_print();
}
void Preview::on_combochecklist_features(wxCommandEvent& evt)
{
unsigned int flags = Slic3r::GUI::combochecklist_get_flags(m_combochecklist_features);
m_canvas->set_toolpath_role_visibility_flags(flags);
refresh_print();
}
void Preview::on_combochecklist_options(wxCommandEvent& evt)
{
const unsigned int curr_flags = m_canvas->get_gcode_options_visibility_flags();
const unsigned int new_flags = Slic3r::GUI::combochecklist_get_flags(m_combochecklist_options);
if (curr_flags == new_flags)
return;
m_canvas->set_gcode_options_visibility_from_flags(new_flags);
if (m_canvas->get_gcode_view_type() == GCodeViewer::EViewType::Feedrate) {
const unsigned int diff_flags = curr_flags ^ new_flags;
if ((diff_flags & (1 << static_cast<unsigned int>(Preview::OptionType::Travel))) != 0)
refresh_print();
else
m_canvas->refresh_gcode_preview_render_paths();
}
else
m_canvas->refresh_gcode_preview_render_paths();
update_moves_slider();
}
void Preview::update_bottom_toolbar()
{
combochecklist_set_flags(m_combochecklist_features, m_canvas->get_toolpath_role_visibility_flags());
combochecklist_set_flags(m_combochecklist_options, m_canvas->get_gcode_options_visibility_flags());
// updates visibility of features combobox
if (m_bottom_toolbar_panel->IsShown()) {
wxSizer* sizer = m_bottom_toolbar_panel->GetSizer();
bool show = !m_canvas->is_gcode_legend_enabled() || m_canvas->get_gcode_view_type() != GCodeViewer::EViewType::FeatureType;
if (show) {
if (sizer->GetItem(m_combochecklist_features) == nullptr) {
sizer->Insert(m_combochecklist_features_pos, m_combochecklist_features, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5);
sizer->Show(m_combochecklist_features);
sizer->Layout();
Refresh();
}
}
else {
if (sizer->GetItem(m_combochecklist_features) != nullptr) {
sizer->Hide(m_combochecklist_features);
sizer->Detach(m_combochecklist_features);
sizer->Layout();
Refresh();
}
}
}
}
#endif // !ENABLE_PREVIEW_LAYOUT
wxBoxSizer* Preview::create_layers_slider_sizer() wxBoxSizer* Preview::create_layers_slider_sizer()
{ {
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
@ -1022,7 +846,6 @@ void Preview::load_print_as_fff(bool keep_z_range)
m_canvas->get_custom_gcode_per_print_z(); m_canvas->get_custom_gcode_per_print_z();
const bool contains_color_gcodes = std::any_of(std::begin(gcodes), std::end(gcodes), const bool contains_color_gcodes = std::any_of(std::begin(gcodes), std::end(gcodes),
[] (auto const& item) { return item.type == CustomGCode::Type::ColorChange; }); [] (auto const& item) { return item.type == CustomGCode::Type::ColorChange; });
#if ENABLE_PREVIEW_LAYOUT
const GCodeViewer::EViewType choice = contains_color_gcodes ? const GCodeViewer::EViewType choice = contains_color_gcodes ?
GCodeViewer::EViewType::ColorPrint : GCodeViewer::EViewType::ColorPrint :
(number_extruders > 1) ? GCodeViewer::EViewType::Tool : GCodeViewer::EViewType::FeatureType; (number_extruders > 1) ? GCodeViewer::EViewType::Tool : GCodeViewer::EViewType::FeatureType;
@ -1032,21 +855,6 @@ void Preview::load_print_as_fff(bool keep_z_range)
m_keep_current_preview_type = true; m_keep_current_preview_type = true;
refresh_print(); refresh_print();
} }
#else
const wxString choice = contains_color_gcodes ?
_L("Color Print") :
(number_extruders > 1) ? _L("Tool") : _L("Feature type");
int type = m_choice_view_type->FindString(choice);
if (m_choice_view_type->GetSelection() != type) {
if (0 <= type && type < static_cast<int>(GCodeViewer::EViewType::Count)) {
m_choice_view_type->SetSelection(type);
m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type));
if (wxGetApp().is_gcode_viewer())
m_keep_current_preview_type = true;
refresh_print();
}
}
#endif // ENABLE_PREVIEW_LAYOUT
} }
if (zs.empty()) { if (zs.empty()) {
@ -1121,27 +929,5 @@ void Preview::on_moves_slider_scroll_changed(wxCommandEvent& event)
m_canvas->render(); m_canvas->render();
} }
#if !ENABLE_PREVIEW_LAYOUT
wxString Preview::get_option_type_string(OptionType type) const
{
switch (type)
{
case OptionType::Travel: { return _L("Travel"); }
case OptionType::Wipe: { return _L("Wipe"); }
case OptionType::Retractions: { return _L("Retractions"); }
case OptionType::Unretractions: { return _L("Deretractions"); }
case OptionType::Seams: { return _L("Seams"); }
case OptionType::ToolChanges: { return _L("Tool changes"); }
case OptionType::ColorChanges: { return _L("Color changes"); }
case OptionType::PausePrints: { return _L("Print pauses"); }
case OptionType::CustomGCodes: { return _L("Custom G-codes"); }
case OptionType::Shells: { return _L("Shells"); }
case OptionType::ToolMarker: { return _L("Tool marker"); }
case OptionType::Legend: { return _L("Legend/Estimated printing time"); }
default: { return ""; }
}
}
#endif // !ENABLE_PREVIEW_LAYOUT
} // namespace GUI } // namespace GUI
} // namespace Slic3r } // namespace Slic3r

View File

@ -80,18 +80,6 @@ class Preview : public wxPanel
wxBoxSizer* m_left_sizer { nullptr }; wxBoxSizer* m_left_sizer { nullptr };
wxBoxSizer* m_layers_slider_sizer { nullptr }; wxBoxSizer* m_layers_slider_sizer { nullptr };
wxPanel* m_bottom_toolbar_panel { nullptr }; wxPanel* m_bottom_toolbar_panel { nullptr };
#if !ENABLE_PREVIEW_LAYOUT
wxStaticText* m_label_view_type { nullptr };
#ifdef _WIN32
BitmapComboBox* m_choice_view_type { nullptr };
#else
wxComboBox* m_choice_view_type { nullptr };
#endif
wxStaticText* m_label_show{ nullptr };
wxComboCtrl* m_combochecklist_features { nullptr };
size_t m_combochecklist_features_pos { 0 };
wxComboCtrl* m_combochecklist_options { nullptr };
#endif // !ENABLE_PREVIEW_LAYOUT
DynamicPrintConfig* m_config; DynamicPrintConfig* m_config;
BackgroundSlicingProcess* m_process; BackgroundSlicingProcess* m_process;
@ -129,9 +117,6 @@ public:
CenterOfGravity, CenterOfGravity,
Shells, Shells,
ToolMarker, ToolMarker,
#if !ENABLE_PREVIEW_LAYOUT
Legend
#endif // !ENABLE_PREVIEW_LAYOUT
}; };
Preview(wxWindow* parent, Bed3D& bed, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process, Preview(wxWindow* parent, Bed3D& bed, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process,
@ -159,17 +144,12 @@ public:
bool is_loaded() const { return m_loaded; } bool is_loaded() const { return m_loaded; }
#if !ENABLE_PREVIEW_LAYOUT
void update_bottom_toolbar();
#endif // !ENABLE_PREVIEW_LAYOUT
void update_moves_slider(); void update_moves_slider();
void enable_moves_slider(bool enable); void enable_moves_slider(bool enable);
void move_moves_slider(wxKeyEvent& evt); void move_moves_slider(wxKeyEvent& evt);
void hide_layers_slider(); void hide_layers_slider();
#if ENABLE_PREVIEW_LAYOUT
void set_keep_current_preview_type(bool value) { m_keep_current_preview_type = value; } void set_keep_current_preview_type(bool value) { m_keep_current_preview_type = value; }
#endif // ENABLE_PREVIEW_LAYOUT
private: private:
bool init(wxWindow* parent, Bed3D& bed, Model* model); bool init(wxWindow* parent, Bed3D& bed, Model* model);
@ -178,11 +158,6 @@ private:
void unbind_event_handlers(); void unbind_event_handlers();
void on_size(wxSizeEvent& evt); void on_size(wxSizeEvent& evt);
#if !ENABLE_PREVIEW_LAYOUT
void on_choice_view_type(wxCommandEvent& evt);
void on_combochecklist_features(wxCommandEvent& evt);
void on_combochecklist_options(wxCommandEvent& evt);
#endif // !ENABLE_PREVIEW_LAYOUT
// Create/Update/Reset double slider on 3dPreview // Create/Update/Reset double slider on 3dPreview
wxBoxSizer* create_layers_slider_sizer(); wxBoxSizer* create_layers_slider_sizer();
@ -199,9 +174,6 @@ private:
void on_layers_slider_scroll_changed(wxCommandEvent& event); void on_layers_slider_scroll_changed(wxCommandEvent& event);
void on_moves_slider_scroll_changed(wxCommandEvent& event); void on_moves_slider_scroll_changed(wxCommandEvent& event);
#if !ENABLE_PREVIEW_LAYOUT
wxString get_option_type_string(OptionType type) const;
#endif // !ENABLE_PREVIEW_LAYOUT
}; };
} // namespace GUI } // namespace GUI

View File

@ -62,20 +62,18 @@ static const std::map<const wchar_t, std::string> font_icons = {
}; };
static const std::map<const wchar_t, std::string> font_icons_large = { static const std::map<const wchar_t, std::string> font_icons_large = {
#if ENABLE_LEGEND_TOOLBAR_ICONS {ImGui::LegendTravel , "legend_travel" },
{ImGui::LegendTravel , "legend_travel" }, {ImGui::LegendWipe , "legend_wipe" },
{ImGui::LegendWipe , "legend_wipe" }, {ImGui::LegendRetract , "legend_retract" },
{ImGui::LegendRetract , "legend_retract" }, {ImGui::LegendDeretract , "legend_deretract" },
{ImGui::LegendDeretract , "legend_deretract" }, {ImGui::LegendSeams , "legend_seams" },
{ImGui::LegendSeams , "legend_seams" }, {ImGui::LegendToolChanges , "legend_toolchanges" },
{ImGui::LegendToolChanges , "legend_toolchanges" }, {ImGui::LegendColorChanges , "legend_colorchanges" },
{ImGui::LegendColorChanges , "legend_colorchanges" }, {ImGui::LegendPausePrints , "legend_pauseprints" },
{ImGui::LegendPausePrints , "legend_pauseprints" }, {ImGui::LegendCustomGCodes , "legend_customgcodes" },
{ImGui::LegendCustomGCodes , "legend_customgcodes" }, {ImGui::LegendCOG , "legend_cog" },
{ImGui::LegendCOG , "legend_cog" }, {ImGui::LegendShells , "legend_shells" },
{ImGui::LegendShells , "legend_shells" }, {ImGui::LegendToolMarker , "legend_toolmarker" },
{ImGui::LegendToolMarker , "legend_toolmarker" },
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
{ImGui::CloseNotifButton , "notification_close" }, {ImGui::CloseNotifButton , "notification_close" },
{ImGui::CloseNotifHoverButton , "notification_close_hover" }, {ImGui::CloseNotifHoverButton , "notification_close_hover" },
{ImGui::EjectButton , "notification_eject_sd" }, {ImGui::EjectButton , "notification_eject_sd" },
@ -423,7 +421,6 @@ bool ImGuiWrapper::radio_button(const wxString &label, bool active)
return ImGui::RadioButton(label_utf8.c_str(), active); return ImGui::RadioButton(label_utf8.c_str(), active);
} }
#if ENABLE_PREVIEW_LAYOUT
bool ImGuiWrapper::draw_radio_button(const std::string& name, float size, bool active, bool ImGuiWrapper::draw_radio_button(const std::string& name, float size, bool active,
std::function<void(ImGuiWindow& window, const ImVec2& pos, float size)> draw_callback) std::function<void(ImGuiWindow& window, const ImVec2& pos, float size)> draw_callback)
{ {
@ -457,7 +454,6 @@ bool ImGuiWrapper::draw_radio_button(const std::string& name, float size, bool a
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window.DC.LastItemStatusFlags); IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window.DC.LastItemStatusFlags);
return pressed; return pressed;
} }
#endif // ENABLE_PREVIEW_LAYOUT
bool ImGuiWrapper::input_double(const std::string &label, const double &value, const std::string &format) bool ImGuiWrapper::input_double(const std::string &label, const double &value, const std::string &format)
{ {
@ -602,7 +598,6 @@ bool ImGuiWrapper::slider_float(const char* label, float* v, float v_min, float
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 1, style.ItemSpacing.y }); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 1, style.ItemSpacing.y });
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_LEGEND_TOOLBAR_ICONS
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
assert(io.Fonts->TexWidth > 0 && io.Fonts->TexHeight > 0); assert(io.Fonts->TexWidth > 0 && io.Fonts->TexHeight > 0);
float inv_tex_w = 1.0f / float(io.Fonts->TexWidth); float inv_tex_w = 1.0f / float(io.Fonts->TexWidth);
@ -612,13 +607,11 @@ bool ImGuiWrapper::slider_float(const char* label, float* v, float v_min, float
const ImVec2 size = { float(rect->Width), float(rect->Height) }; const ImVec2 size = { float(rect->Width), float(rect->Height) };
const ImVec2 uv0 = ImVec2(float(rect->X) * inv_tex_w, float(rect->Y) * inv_tex_h); const ImVec2 uv0 = ImVec2(float(rect->X) * inv_tex_w, float(rect->Y) * inv_tex_h);
const ImVec2 uv1 = ImVec2(float(rect->X + rect->Width) * inv_tex_w, float(rect->Y + rect->Height) * inv_tex_h); const ImVec2 uv1 = ImVec2(float(rect->X + rect->Width) * inv_tex_w, float(rect->Y + rect->Height) * inv_tex_h);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
ImGui::PushStyleColor(ImGuiCol_Button, { 0.25f, 0.25f, 0.25f, 0.0f }); ImGui::PushStyleColor(ImGuiCol_Button, { 0.25f, 0.25f, 0.25f, 0.0f });
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { 0.4f, 0.4f, 0.4f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { 0.4f, 0.4f, 0.4f, 1.0f });
ImGui::PushStyleColor(ImGuiCol_ButtonActive, { 0.4f, 0.4f, 0.4f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonActive, { 0.4f, 0.4f, 0.4f, 1.0f });
#if ENABLE_LEGEND_TOOLBAR_ICONS
const ImTextureID tex_id = io.Fonts->TexID; const ImTextureID tex_id = io.Fonts->TexID;
if (image_button(tex_id, size, uv0, uv1, -1, ImVec4(0.0, 0.0, 0.0, 0.0), ImVec4(1.0, 1.0, 1.0, 1.0), ImGuiButtonFlags_PressedOnClick)) { if (image_button(tex_id, size, uv0, uv1, -1, ImVec4(0.0, 0.0, 0.0, 0.0), ImVec4(1.0, 1.0, 1.0, 1.0), ImGuiButtonFlags_PressedOnClick)) {
if (!slider_editing) if (!slider_editing)
@ -627,13 +620,6 @@ bool ImGuiWrapper::slider_float(const char* label, float* v, float v_min, float
ImGui::ClearActiveID(); ImGui::ClearActiveID();
this->set_requires_extra_frame(); this->set_requires_extra_frame();
} }
#else
std::wstring btn_name = ImGui::SliderFloatEditBtnIcon + boost::nowide::widen(str_label);
if (ImGui::Button(into_u8(btn_name).c_str())) {
ImGui::SetKeyboardFocusHere(-1);
this->set_requires_extra_frame();
}
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
ImGui::PopStyleColor(3); ImGui::PopStyleColor(3);
@ -715,14 +701,10 @@ bool ImGuiWrapper::image_button(ImTextureID user_texture_id, const ImVec2& size,
bool ImGuiWrapper::combo(const wxString& label, const std::vector<std::string>& options, int& selection, ImGuiComboFlags flags) bool ImGuiWrapper::combo(const wxString& label, const std::vector<std::string>& options, int& selection, ImGuiComboFlags flags)
{ {
// this is to force the label to the left of the widget: // this is to force the label to the left of the widget:
#if ENABLE_PREVIEW_LAYOUT
if (!label.empty()) { if (!label.empty()) {
#endif // ENABLE_PREVIEW_LAYOUT
text(label); text(label);
ImGui::SameLine(); ImGui::SameLine();
#if ENABLE_PREVIEW_LAYOUT
} }
#endif // ENABLE_PREVIEW_LAYOUT
int selection_out = selection; int selection_out = selection;
bool res = false; bool res = false;
@ -1172,13 +1154,11 @@ bool ImGuiWrapper::want_any_input() const
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput; return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput;
} }
#if ENABLE_LEGEND_TOOLBAR_ICONS
ImFontAtlasCustomRect* ImGuiWrapper::GetTextureCustomRect(const wchar_t& tex_id) ImFontAtlasCustomRect* ImGuiWrapper::GetTextureCustomRect(const wchar_t& tex_id)
{ {
auto item = m_custom_glyph_rects_ids.find(tex_id); auto item = m_custom_glyph_rects_ids.find(tex_id);
return (item != m_custom_glyph_rects_ids.end()) ? ImGui::GetIO().Fonts->GetCustomRectByIndex(m_custom_glyph_rects_ids[tex_id]) : nullptr; return (item != m_custom_glyph_rects_ids.end()) ? ImGui::GetIO().Fonts->GetCustomRectByIndex(m_custom_glyph_rects_ids[tex_id]) : nullptr;
} }
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
ImU32 ImGuiWrapper::to_ImU32(const ColorRGBA& color) ImU32 ImGuiWrapper::to_ImU32(const ColorRGBA& color)
{ {
@ -1602,7 +1582,6 @@ void ImGuiWrapper::init_font(bool compress)
int rect_id = io.Fonts->CustomRects.Size; // id of the rectangle added next int rect_id = io.Fonts->CustomRects.Size; // id of the rectangle added next
// add rectangles for the icons to the font atlas // add rectangles for the icons to the font atlas
#if ENABLE_LEGEND_TOOLBAR_ICONS
for (auto& icon : font_icons) { for (auto& icon : font_icons) {
m_custom_glyph_rects_ids[icon.first] = m_custom_glyph_rects_ids[icon.first] =
io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz, icon_sz, 3.0 * font_scale + icon_sz); io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz, icon_sz, 3.0 * font_scale + icon_sz);
@ -1614,15 +1593,7 @@ void ImGuiWrapper::init_font(bool compress)
for (auto& icon : font_icons_extra_large) { for (auto& icon : font_icons_extra_large) {
m_custom_glyph_rects_ids[icon.first] = m_custom_glyph_rects_ids[icon.first] =
io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz * 4, icon_sz * 4, 3.0 * font_scale + icon_sz * 4); io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz * 4, icon_sz * 4, 3.0 * font_scale + icon_sz * 4);
} }
#else
for (auto& icon : font_icons)
io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz, icon_sz, 3.0 * font_scale + icon_sz);
for (auto& icon : font_icons_large)
io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz * 2, icon_sz * 2, 3.0 * font_scale + icon_sz * 2);
for (auto& icon : font_icons_extra_large)
io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz * 4, icon_sz * 4, 3.0 * font_scale + icon_sz * 4);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
// Build texture atlas // Build texture atlas
unsigned char* pixels; unsigned char* pixels;

View File

@ -23,9 +23,7 @@ class wxString;
class wxMouseEvent; class wxMouseEvent;
class wxKeyEvent; class wxKeyEvent;
#if ENABLE_PREVIEW_LAYOUT
struct IMGUI_API ImGuiWindow; struct IMGUI_API ImGuiWindow;
#endif // ENABLE_PREVIEW_LAYOUT
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@ -42,9 +40,7 @@ class ImGuiWrapper
bool m_disabled{ false }; bool m_disabled{ false };
bool m_new_frame_open{ false }; bool m_new_frame_open{ false };
bool m_requires_extra_frame{ false }; bool m_requires_extra_frame{ false };
#if ENABLE_LEGEND_TOOLBAR_ICONS
std::map<wchar_t, int> m_custom_glyph_rects_ids; std::map<wchar_t, int> m_custom_glyph_rects_ids;
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
std::string m_clipboard_text; std::string m_clipboard_text;
public: public:
@ -99,9 +95,7 @@ public:
bool button(const wxString& label, float width, float height); bool button(const wxString& label, float width, float height);
bool button(const wxString& label, const ImVec2 &size, bool enable); // default size = ImVec2(0.f, 0.f) bool button(const wxString& label, const ImVec2 &size, bool enable); // default size = ImVec2(0.f, 0.f)
bool radio_button(const wxString &label, bool active); bool radio_button(const wxString &label, bool active);
#if ENABLE_PREVIEW_LAYOUT
bool draw_radio_button(const std::string& name, float size, bool active, std::function<void(ImGuiWindow& window, const ImVec2& pos, float size)> draw_callback); bool draw_radio_button(const std::string& name, float size, bool active, std::function<void(ImGuiWindow& window, const ImVec2& pos, float size)> draw_callback);
#endif // ENABLE_PREVIEW_LAYOUT
bool input_double(const std::string &label, const double &value, const std::string &format = "%.3f"); bool input_double(const std::string &label, const double &value, const std::string &format = "%.3f");
bool input_double(const wxString &label, const double &value, const std::string &format = "%.3f"); bool input_double(const wxString &label, const double &value, const std::string &format = "%.3f");
bool input_vec3(const std::string &label, const Vec3d &value, float width, const std::string &format = "%.3f"); bool input_vec3(const std::string &label, const Vec3d &value, float width, const std::string &format = "%.3f");
@ -221,9 +215,7 @@ public:
static ColorRGBA from_ImU32(const ImU32& color); static ColorRGBA from_ImU32(const ImU32& color);
static ColorRGBA from_ImVec4(const ImVec4& color); static ColorRGBA from_ImVec4(const ImVec4& color);
#if ENABLE_LEGEND_TOOLBAR_ICONS
ImFontAtlasCustomRect* GetTextureCustomRect(const wchar_t& tex_id); ImFontAtlasCustomRect* GetTextureCustomRect(const wchar_t& tex_id);
#endif // ENABLE_LEGEND_TOOLBAR_ICONS
static const ImVec4 COL_GREY_DARK; static const ImVec4 COL_GREY_DARK;
static const ImVec4 COL_GREY_LIGHT; static const ImVec4 COL_GREY_LIGHT;

View File

@ -1494,11 +1494,9 @@ void MainFrame::init_menubar_as_editor()
append_menu_check_item(viewMenu, wxID_ANY, _L("Show &Labels") + sep + "E", _L("Show object/instance labels in 3D scene"), append_menu_check_item(viewMenu, wxID_ANY, _L("Show &Labels") + sep + "E", _L("Show object/instance labels in 3D scene"),
[this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); }, this, [this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); }, this,
[this]() { return m_plater->is_view3D_shown(); }, [this]() { return m_plater->are_view3D_labels_shown(); }, this); [this]() { return m_plater->is_view3D_shown(); }, [this]() { return m_plater->are_view3D_labels_shown(); }, this);
#if ENABLE_PREVIEW_LAYOUT
append_menu_check_item(viewMenu, wxID_ANY, _L("Show Legen&d") + sep + "L", _L("Show legend in preview"), append_menu_check_item(viewMenu, wxID_ANY, _L("Show Legen&d") + sep + "L", _L("Show legend in preview"),
[this](wxCommandEvent&) { m_plater->show_legend(!m_plater->is_legend_shown()); }, this, [this](wxCommandEvent&) { m_plater->show_legend(!m_plater->is_legend_shown()); }, this,
[this]() { return m_plater->is_preview_shown(); }, [this]() { return m_plater->is_legend_shown(); }, this); [this]() { return m_plater->is_preview_shown(); }, [this]() { return m_plater->is_legend_shown(); }, this);
#endif // ENABLE_PREVIEW_LAYOUT
append_menu_check_item(viewMenu, wxID_ANY, _L("&Collapse Sidebar") + sep + "Shift+" + sep_space + "Tab", _L("Collapse sidebar"), append_menu_check_item(viewMenu, wxID_ANY, _L("&Collapse Sidebar") + sep + "Shift+" + sep_space + "Tab", _L("Collapse sidebar"),
[this](wxCommandEvent&) { m_plater->collapse_sidebar(!m_plater->is_sidebar_collapsed()); }, this, [this](wxCommandEvent&) { m_plater->collapse_sidebar(!m_plater->is_sidebar_collapsed()); }, this,
[]() { return true; }, [this]() { return m_plater->is_sidebar_collapsed(); }, this); []() { return true; }, [this]() { return m_plater->is_sidebar_collapsed(); }, this);
@ -1616,12 +1614,10 @@ void MainFrame::init_menubar_as_gcodeviewer()
if (m_plater != nullptr) { if (m_plater != nullptr) {
viewMenu = new wxMenu(); viewMenu = new wxMenu();
add_common_view_menu_items(viewMenu, this, std::bind(&MainFrame::can_change_view, this)); add_common_view_menu_items(viewMenu, this, std::bind(&MainFrame::can_change_view, this));
#if ENABLE_PREVIEW_LAYOUT
viewMenu->AppendSeparator(); viewMenu->AppendSeparator();
append_menu_check_item(viewMenu, wxID_ANY, _L("Show legen&d") + sep + "L", _L("Show legend"), append_menu_check_item(viewMenu, wxID_ANY, _L("Show legen&d") + sep + "L", _L("Show legend"),
[this](wxCommandEvent&) { m_plater->show_legend(!m_plater->is_legend_shown()); }, this, [this](wxCommandEvent&) { m_plater->show_legend(!m_plater->is_legend_shown()); }, this,
[this]() { return m_plater->is_preview_shown(); }, [this]() { return m_plater->is_legend_shown(); }, this); [this]() { return m_plater->is_preview_shown(); }, [this]() { return m_plater->is_legend_shown(); }, this);
#endif // ENABLE_PREVIEW_LAYOUT
} }
// helpmenu // helpmenu

View File

@ -1767,10 +1767,8 @@ struct Plater::priv
bool are_view3D_labels_shown() const { return (current_panel == view3D) && view3D->get_canvas3d()->are_labels_shown(); } bool are_view3D_labels_shown() const { return (current_panel == view3D) && view3D->get_canvas3d()->are_labels_shown(); }
void show_view3D_labels(bool show) { if (current_panel == view3D) view3D->get_canvas3d()->show_labels(show); } void show_view3D_labels(bool show) { if (current_panel == view3D) view3D->get_canvas3d()->show_labels(show); }
#if ENABLE_PREVIEW_LAYOUT
bool is_legend_shown() const { return (current_panel == preview) && preview->get_canvas3d()->is_legend_shown(); } bool is_legend_shown() const { return (current_panel == preview) && preview->get_canvas3d()->is_legend_shown(); }
void show_legend(bool show) { if (current_panel == preview) preview->get_canvas3d()->show_legend(show); } void show_legend(bool show) { if (current_panel == preview) preview->get_canvas3d()->show_legend(show); }
#endif // ENABLE_PREVIEW_LAYOUT
bool is_sidebar_collapsed() const { return sidebar->is_collapsed(); } bool is_sidebar_collapsed() const { return sidebar->is_collapsed(); }
void collapse_sidebar(bool collapse); void collapse_sidebar(bool collapse);
@ -1785,9 +1783,6 @@ struct Plater::priv
bool init_view_toolbar(); bool init_view_toolbar();
bool init_collapse_toolbar(); bool init_collapse_toolbar();
#if !ENABLE_PREVIEW_LAYOUT
void update_preview_bottom_toolbar();
#endif // !ENABLE_PREVIEW_LAYOUT
void update_preview_moves_slider(); void update_preview_moves_slider();
void enable_preview_moves_slider(bool enable); void enable_preview_moves_slider(bool enable);
@ -4746,13 +4741,6 @@ bool Plater::priv::init_collapse_toolbar()
return true; return true;
} }
#if !ENABLE_PREVIEW_LAYOUT
void Plater::priv::update_preview_bottom_toolbar()
{
preview->update_bottom_toolbar();
}
#endif // !ENABLE_PREVIEW_LAYOUT
void Plater::priv::update_preview_moves_slider() void Plater::priv::update_preview_moves_slider()
{ {
preview->update_moves_slider(); preview->update_moves_slider();
@ -5733,10 +5721,8 @@ bool Plater::is_view3D_shown() const { return p->is_view3D_shown(); }
bool Plater::are_view3D_labels_shown() const { return p->are_view3D_labels_shown(); } bool Plater::are_view3D_labels_shown() const { return p->are_view3D_labels_shown(); }
void Plater::show_view3D_labels(bool show) { p->show_view3D_labels(show); } void Plater::show_view3D_labels(bool show) { p->show_view3D_labels(show); }
#if ENABLE_PREVIEW_LAYOUT
bool Plater::is_legend_shown() const { return p->is_legend_shown(); } bool Plater::is_legend_shown() const { return p->is_legend_shown(); }
void Plater::show_legend(bool show) { p->show_legend(show); } void Plater::show_legend(bool show) { p->show_legend(show); }
#endif // ENABLE_PREVIEW_LAYOUT
bool Plater::is_sidebar_collapsed() const { return p->is_sidebar_collapsed(); } bool Plater::is_sidebar_collapsed() const { return p->is_sidebar_collapsed(); }
void Plater::collapse_sidebar(bool show) { p->collapse_sidebar(show); } void Plater::collapse_sidebar(bool show) { p->collapse_sidebar(show); }
@ -7094,13 +7080,6 @@ GLToolbar& Plater::get_collapse_toolbar()
return p->collapse_toolbar; return p->collapse_toolbar;
} }
#if !ENABLE_PREVIEW_LAYOUT
void Plater::update_preview_bottom_toolbar()
{
p->update_preview_bottom_toolbar();
}
#endif // !ENABLE_PREVIEW_LAYOUT
void Plater::update_preview_moves_slider() void Plater::update_preview_moves_slider()
{ {
p->update_preview_moves_slider(); p->update_preview_moves_slider();
@ -7209,12 +7188,10 @@ bool Plater::is_render_statistic_dialog_visible() const
return p->show_render_statistic_dialog; return p->show_render_statistic_dialog;
} }
#if ENABLE_PREVIEW_LAYOUT
void Plater::set_keep_current_preview_type(bool value) void Plater::set_keep_current_preview_type(bool value)
{ {
p->preview->set_keep_current_preview_type(value); p->preview->set_keep_current_preview_type(value);
} }
#endif // ENABLE_PREVIEW_LAYOUT
Plater::TakeSnapshot::TakeSnapshot(Plater *plater, const std::string &snapshot_name) Plater::TakeSnapshot::TakeSnapshot(Plater *plater, const std::string &snapshot_name)
: TakeSnapshot(plater, from_u8(snapshot_name)) {} : TakeSnapshot(plater, from_u8(snapshot_name)) {}

View File

@ -225,10 +225,8 @@ public:
bool are_view3D_labels_shown() const; bool are_view3D_labels_shown() const;
void show_view3D_labels(bool show); void show_view3D_labels(bool show);
#if ENABLE_PREVIEW_LAYOUT
bool is_legend_shown() const; bool is_legend_shown() const;
void show_legend(bool show); void show_legend(bool show);
#endif // ENABLE_PREVIEW_LAYOUT
bool is_sidebar_collapsed() const; bool is_sidebar_collapsed() const;
void collapse_sidebar(bool show); void collapse_sidebar(bool show);
@ -390,9 +388,6 @@ public:
const GLToolbar& get_collapse_toolbar() const; const GLToolbar& get_collapse_toolbar() const;
GLToolbar& get_collapse_toolbar(); GLToolbar& get_collapse_toolbar();
#if !ENABLE_PREVIEW_LAYOUT
void update_preview_bottom_toolbar();
#endif // !ENABLE_PREVIEW_LAYOUT
void update_preview_moves_slider(); void update_preview_moves_slider();
void enable_preview_moves_slider(bool enable); void enable_preview_moves_slider(bool enable);
@ -458,9 +453,7 @@ public:
void toggle_render_statistic_dialog(); void toggle_render_statistic_dialog();
bool is_render_statistic_dialog_visible() const; bool is_render_statistic_dialog_visible() const;
#if ENABLE_PREVIEW_LAYOUT
void set_keep_current_preview_type(bool value); void set_keep_current_preview_type(bool value);
#endif // ENABLE_PREVIEW_LAYOUT
// Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu. // Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition); bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition);

View File

@ -66,7 +66,7 @@ SCENARIO("Various Clipper operations - xs/t/11_clipper.t", "[ClipperUtils]") {
GIVEN("polyline") { GIVEN("polyline") {
Polyline polyline { { 50, 150 }, { 300, 150 } }; Polyline polyline { { 50, 150 }, { 300, 150 } };
WHEN("intersection_pl") { WHEN("intersection_pl") {
Polylines result = Slic3r::intersection_pl({ polyline }, { square, hole_in_square }); Polylines result = Slic3r::intersection_pl(polyline, ExPolygon{ square, hole_in_square });
THEN("correct number of result lines") { THEN("correct number of result lines") {
REQUIRE(result.size() == 2); REQUIRE(result.size() == 2);
} }
@ -99,7 +99,7 @@ SCENARIO("Various Clipper operations - xs/t/11_clipper.t", "[ClipperUtils]") {
{ 74730000, 74730000 }, { 55270000, 74730000 }, { 55270000, 68063296 }, { 44730000, 68063296 }, { 44730000, 74730000 }, { 25270000, 74730000 }, { 25270000, 55270000 }, { 31936670, 55270000 }, { 74730000, 74730000 }, { 55270000, 74730000 }, { 55270000, 68063296 }, { 44730000, 68063296 }, { 44730000, 74730000 }, { 25270000, 74730000 }, { 25270000, 55270000 }, { 31936670, 55270000 },
{ 31936670, 44730000 }, { 25270000, 44730000 }, { 25270000, 25270000 }, { 44730000, 25270000 }, { 44730000, 31936670 } }; { 31936670, 44730000 }, { 25270000, 44730000 }, { 25270000, 25270000 }, { 44730000, 25270000 }, { 44730000, 31936670 } };
Slic3r::Polygon clip { {75200000, 45200000}, {54800000, 45200000}, {54800000, 24800000}, {75200000, 24800000} }; Slic3r::Polygon clip { {75200000, 45200000}, {54800000, 45200000}, {54800000, 24800000}, {75200000, 24800000} };
Slic3r::Polylines result = Slic3r::intersection_pl(subject, { clip }); Slic3r::Polylines result = Slic3r::intersection_pl(subject, ExPolygon{ clip });
THEN("intersection_pl - result is not empty") { THEN("intersection_pl - result is not empty") {
REQUIRE(result.size() == 1); REQUIRE(result.size() == 1);
} }
@ -117,7 +117,7 @@ SCENARIO("Various Clipper operations - xs/t/11_clipper.t", "[ClipperUtils]") {
GIVEN("Clipper bug #126") { GIVEN("Clipper bug #126") {
Slic3r::Polyline subject { { 200000, 19799999 }, { 200000, 200000 }, { 24304692, 200000 }, { 15102879, 17506106 }, { 13883200, 19799999 }, { 200000, 19799999 } }; Slic3r::Polyline subject { { 200000, 19799999 }, { 200000, 200000 }, { 24304692, 200000 }, { 15102879, 17506106 }, { 13883200, 19799999 }, { 200000, 19799999 } };
Slic3r::Polygon clip { { 15257205, 18493894 }, { 14350057, 20200000 }, { -200000, 20200000 }, { -200000, -200000 }, { 25196917, -200000 } }; Slic3r::Polygon clip { { 15257205, 18493894 }, { 14350057, 20200000 }, { -200000, 20200000 }, { -200000, -200000 }, { 25196917, -200000 } };
Slic3r::Polylines result = Slic3r::intersection_pl(subject, { clip }); Slic3r::Polylines result = Slic3r::intersection_pl(subject, ExPolygon{ clip });
THEN("intersection_pl - result is not empty") { THEN("intersection_pl - result is not empty") {
REQUIRE(result.size() == 1); REQUIRE(result.size() == 1);
} }