Display skirt and brim in toolpaths preview. Also take support material margin into account when sizing the window. #2169
This commit is contained in:
parent
70fb381ecf
commit
86bad17abb
@ -109,7 +109,7 @@ sub new {
|
||||
|
||||
my $self = $class->SUPER::new($parent);
|
||||
$self->print($print);
|
||||
$self->bb($self->print->bounding_box);
|
||||
$self->bb($self->print->total_bounding_box);
|
||||
|
||||
EVT_PAINT($self, sub {
|
||||
my $dc = Wx::PaintDC->new($self);
|
||||
@ -187,9 +187,24 @@ sub Render {
|
||||
glClearColor(1, 1, 1, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
my $skirt_drawn = 0;
|
||||
my $brim_drawn = 0;
|
||||
foreach my $layer (@{$self->layers}) {
|
||||
my $object = $layer->object;
|
||||
my $print_z = $layer->print_z;
|
||||
|
||||
# draw brim
|
||||
if ($layer->id == 0 && !$brim_drawn) {
|
||||
$self->color([0, 0, 0]);
|
||||
$self->_draw(undef, $print_z, $_) for @{$self->print->brim};
|
||||
$brim_drawn = 1;
|
||||
}
|
||||
if (($self->print->config->skirt_height == -1 || $self->print->config->skirt_height >= $layer->id) && !$skirt_drawn) {
|
||||
$self->color([0, 0, 0]);
|
||||
$self->_draw(undef, $print_z, $_) for @{$self->print->skirt};
|
||||
$skirt_drawn = 1;
|
||||
}
|
||||
|
||||
foreach my $layerm (@{$layer->regions}) {
|
||||
$self->color([0.7, 0, 0]);
|
||||
$self->_draw($object, $print_z, $_) for @{$layerm->perimeters};
|
||||
@ -231,9 +246,19 @@ sub _draw_path {
|
||||
}
|
||||
|
||||
glLineWidth(1);
|
||||
foreach my $copy (@{ $object->_shifted_copies }) {
|
||||
|
||||
if (defined $object) {
|
||||
foreach my $copy (@{ $object->_shifted_copies }) {
|
||||
foreach my $line (@{$path->polyline->lines}) {
|
||||
$line->translate(@$copy);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(@{$line->a});
|
||||
glVertex2f(@{$line->b});
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach my $line (@{$path->polyline->lines}) {
|
||||
$line->translate(@$copy);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(@{$line->a});
|
||||
glVertex2f(@{$line->b});
|
||||
|
@ -356,6 +356,8 @@ sub max_layer_height {
|
||||
return max(@{$self->config->nozzle_diameter});
|
||||
}
|
||||
|
||||
# the bounding box of objects placed in copies position
|
||||
# (without taking skirt/brim/support material into account)
|
||||
sub bounding_box {
|
||||
my $self = shift;
|
||||
|
||||
@ -370,6 +372,30 @@ sub bounding_box {
|
||||
return Slic3r::Geometry::BoundingBox->new_from_points([ map Slic3r::Point->new(@$_), @points ]);
|
||||
}
|
||||
|
||||
# the total bounding box of extrusions, including skirt/brim/support material
|
||||
sub total_bounding_box {
|
||||
my ($self) = @_;
|
||||
|
||||
# get objects bounding box
|
||||
my $bb = $self->bounding_box;
|
||||
|
||||
# check how much we need to increase it
|
||||
my $extra = 0;
|
||||
if ($self->has_support_material) {
|
||||
$extra = &Slic3r::Print::SupportMaterial::MARGIN;
|
||||
}
|
||||
if ($self->config->skirts > 0) {
|
||||
my $skirt_flow = $self->skirt_flow;
|
||||
$extra = max($extra, $self->config->skirt_distance + ($self->config->skirts * $skirt_flow->spacing));
|
||||
}
|
||||
$extra = max($extra, $self->config->brim_width);
|
||||
|
||||
if ($extra > 0) {
|
||||
$bb->offset(scale $extra);
|
||||
}
|
||||
return $bb;
|
||||
}
|
||||
|
||||
sub size {
|
||||
my $self = shift;
|
||||
return $self->bounding_box->size;
|
||||
@ -602,14 +628,8 @@ sub make_skirt {
|
||||
# skirt may be printed on several layers, having distinct layer heights,
|
||||
# but loops must be aligned so can't vary width/spacing
|
||||
# TODO: use each extruder's own flow
|
||||
my $first_layer_height = $self->objects->[0]->config->get_value('first_layer_height');
|
||||
my $flow = Slic3r::Flow->new_from_width(
|
||||
width => ($self->config->first_layer_extrusion_width || $self->regions->[0]->config->perimeter_extrusion_width),
|
||||
role => FLOW_ROLE_PERIMETER,
|
||||
nozzle_diameter => $self->config->nozzle_diameter->[0],
|
||||
layer_height => $first_layer_height,
|
||||
bridge_flow_ratio => 0,
|
||||
);
|
||||
my $first_layer_height = $self->skirt_first_layer_height;
|
||||
my $flow = $self->skirt_flow;
|
||||
my $spacing = $flow->spacing;
|
||||
my $mm3_per_mm = $flow->mm3_per_mm;
|
||||
|
||||
@ -677,14 +697,8 @@ sub make_brim {
|
||||
$self->status_cb->(88, "Generating brim");
|
||||
|
||||
# brim is only printed on first layer and uses support material extruder
|
||||
my $first_layer_height = $self->objects->[0]->config->get_abs_value('first_layer_height');
|
||||
my $flow = Slic3r::Flow->new_from_width(
|
||||
width => ($self->config->first_layer_extrusion_width || $self->regions->[0]->config->perimeter_extrusion_width),
|
||||
role => FLOW_ROLE_PERIMETER,
|
||||
nozzle_diameter => $self->config->get_at('nozzle_diameter', $self->objects->[0]->config->support_material_extruder-1),
|
||||
layer_height => $first_layer_height,
|
||||
bridge_flow_ratio => 0,
|
||||
);
|
||||
my $first_layer_height = $self->skirt_first_layer_height;
|
||||
my $flow = $self->skirt_flow;
|
||||
my $mm3_per_mm = $flow->mm3_per_mm;
|
||||
|
||||
my $grow_distance = $flow->scaled_width / 2;
|
||||
@ -738,6 +752,23 @@ sub make_brim {
|
||||
$self->set_step_done(STEP_BRIM);
|
||||
}
|
||||
|
||||
sub skirt_first_layer_height {
|
||||
my ($self) = @_;
|
||||
return $self->objects->[0]->config->get_abs_value('first_layer_height');
|
||||
}
|
||||
|
||||
sub skirt_flow {
|
||||
my ($self) = @_;
|
||||
|
||||
return Slic3r::Flow->new_from_width(
|
||||
width => ($self->config->first_layer_extrusion_width || $self->regions->[0]->config->perimeter_extrusion_width),
|
||||
role => FLOW_ROLE_PERIMETER,
|
||||
nozzle_diameter => $self->config->get_at('nozzle_diameter', $self->objects->[0]->config->support_material_extruder-1),
|
||||
layer_height => $self->skirt_first_layer_height,
|
||||
bridge_flow_ratio => 0,
|
||||
);
|
||||
}
|
||||
|
||||
sub write_gcode {
|
||||
my $self = shift;
|
||||
my ($file) = @_;
|
||||
|
@ -141,6 +141,23 @@ BoundingBox3Base<PointClass>::translate(coordf_t x, coordf_t y, coordf_t z)
|
||||
}
|
||||
template void BoundingBox3Base<Pointf3>::translate(coordf_t x, coordf_t y, coordf_t z);
|
||||
|
||||
template <class PointClass> void
|
||||
BoundingBoxBase<PointClass>::offset(coordf_t delta)
|
||||
{
|
||||
this->min.translate(-delta, -delta);
|
||||
this->max.translate(delta, delta);
|
||||
}
|
||||
template void BoundingBoxBase<Point>::offset(coordf_t delta);
|
||||
template void BoundingBoxBase<Pointf>::offset(coordf_t delta);
|
||||
|
||||
template <class PointClass> void
|
||||
BoundingBox3Base<PointClass>::offset(coordf_t delta)
|
||||
{
|
||||
this->min.translate(-delta, -delta, -delta);
|
||||
this->max.translate(delta, delta, delta);
|
||||
}
|
||||
template void BoundingBox3Base<Pointf3>::offset(coordf_t delta);
|
||||
|
||||
template <class PointClass> PointClass
|
||||
BoundingBoxBase<PointClass>::center() const
|
||||
{
|
||||
|
@ -26,6 +26,7 @@ class BoundingBoxBase
|
||||
void scale(double factor);
|
||||
PointClass size() const;
|
||||
void translate(coordf_t x, coordf_t y);
|
||||
void offset(coordf_t delta);
|
||||
PointClass center() const;
|
||||
};
|
||||
|
||||
@ -39,6 +40,7 @@ class BoundingBox3Base : public BoundingBoxBase<PointClass>
|
||||
void merge(const BoundingBox3Base<PointClass> &bb);
|
||||
PointClass size() const;
|
||||
void translate(coordf_t x, coordf_t y, coordf_t z);
|
||||
void offset(coordf_t delta);
|
||||
PointClass center() const;
|
||||
};
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
void merge_point(Point* point) %code{% THIS->merge(*point); %};
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
void offset(double delta);
|
||||
Polygon* polygon()
|
||||
%code{% RETVAL = new Polygon(); THIS->polygon(RETVAL); %};
|
||||
Clone<Point> size();
|
||||
|
Loading…
Reference in New Issue
Block a user