GCode Preview - Code cleanup
This commit is contained in:
parent
c63e6b74fa
commit
a417cf955d
@ -30,7 +30,6 @@ use Slic3r::Geometry qw(PI);
|
|||||||
# _dirty: boolean flag indicating, that the screen has to be redrawn on EVT_IDLE.
|
# _dirty: boolean flag indicating, that the screen has to be redrawn on EVT_IDLE.
|
||||||
# volumes: reference to vector of Slic3r::GUI::3DScene::Volume.
|
# volumes: reference to vector of Slic3r::GUI::3DScene::Volume.
|
||||||
# _camera_type: 'perspective' or 'ortho'
|
# _camera_type: 'perspective' or 'ortho'
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
__PACKAGE__->mk_accessors( qw(_quat _dirty init
|
__PACKAGE__->mk_accessors( qw(_quat _dirty init
|
||||||
enable_picking
|
enable_picking
|
||||||
enable_moving
|
enable_moving
|
||||||
@ -72,46 +71,6 @@ __PACKAGE__->mk_accessors( qw(_quat _dirty init
|
|||||||
|
|
||||||
) );
|
) );
|
||||||
|
|
||||||
#__PACKAGE__->mk_accessors( qw(_quat _dirty init
|
|
||||||
# enable_picking
|
|
||||||
# enable_moving
|
|
||||||
# use_plain_shader
|
|
||||||
# on_viewport_changed
|
|
||||||
# on_hover
|
|
||||||
# on_select
|
|
||||||
# on_double_click
|
|
||||||
# on_right_click
|
|
||||||
# on_move
|
|
||||||
# on_model_update
|
|
||||||
# volumes
|
|
||||||
# _sphi _stheta
|
|
||||||
# cutting_plane_z
|
|
||||||
# cut_lines_vertices
|
|
||||||
# bed_shape
|
|
||||||
# bed_triangles
|
|
||||||
# bed_grid_lines
|
|
||||||
# bed_polygon
|
|
||||||
# background
|
|
||||||
# origin
|
|
||||||
# _mouse_pos
|
|
||||||
# _hover_volume_idx
|
|
||||||
#
|
|
||||||
# _drag_volume_idx
|
|
||||||
# _drag_start_pos
|
|
||||||
# _drag_volume_center_offset
|
|
||||||
# _drag_start_xy
|
|
||||||
# _dragged
|
|
||||||
#
|
|
||||||
# _layer_height_edited
|
|
||||||
#
|
|
||||||
# _camera_type
|
|
||||||
# _camera_target
|
|
||||||
# _camera_distance
|
|
||||||
# _zoom
|
|
||||||
#
|
|
||||||
# ) );
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
use constant TRACKBALLSIZE => 0.8;
|
use constant TRACKBALLSIZE => 0.8;
|
||||||
use constant TURNTABLE_MODE => 1;
|
use constant TURNTABLE_MODE => 1;
|
||||||
use constant GROUND_Z => -0.02;
|
use constant GROUND_Z => -0.02;
|
||||||
@ -181,9 +140,7 @@ sub new {
|
|||||||
$self->_stheta(45);
|
$self->_stheta(45);
|
||||||
$self->_sphi(45);
|
$self->_sphi(45);
|
||||||
$self->_zoom(1);
|
$self->_zoom(1);
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->_legend_enabled(0);
|
$self->_legend_enabled(0);
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->use_plain_shader(0);
|
$self->use_plain_shader(0);
|
||||||
|
|
||||||
# Collection of GLVolume objects
|
# Collection of GLVolume objects
|
||||||
@ -256,12 +213,10 @@ sub new {
|
|||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
sub set_legend_enabled {
|
sub set_legend_enabled {
|
||||||
my ($self, $value) = @_;
|
my ($self, $value) = @_;
|
||||||
$self->_legend_enabled($value);
|
$self->_legend_enabled($value);
|
||||||
}
|
}
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
sub Destroy {
|
sub Destroy {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
@ -1370,10 +1325,8 @@ sub Render {
|
|||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
# draw gcode preview legend
|
# draw gcode preview legend
|
||||||
$self->draw_legend;
|
$self->draw_legend;
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
$self->draw_active_object_annotations;
|
$self->draw_active_object_annotations;
|
||||||
|
|
||||||
@ -1508,29 +1461,9 @@ sub _variable_layer_thickness_load_reset_image {
|
|||||||
# Paint the tooltip.
|
# Paint the tooltip.
|
||||||
sub _render_image {
|
sub _render_image {
|
||||||
my ($self, $image, $l, $r, $b, $t) = @_;
|
my ($self, $image, $l, $r, $b, $t) = @_;
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->_render_texture($image->{texture_id}, $l, $r, $b, $t);
|
$self->_render_texture($image->{texture_id}, $l, $r, $b, $t);
|
||||||
|
|
||||||
# glColor4f(1.,1.,1.,1.);
|
|
||||||
# glDisable(GL_LIGHTING);
|
|
||||||
# glEnable(GL_BLEND);
|
|
||||||
# glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
# glEnable(GL_TEXTURE_2D);
|
|
||||||
# glBindTexture(GL_TEXTURE_2D, $image->{texture_id});
|
|
||||||
# glBegin(GL_QUADS);
|
|
||||||
# glTexCoord2d(0.,1.); glVertex3f($l, $b, 0);
|
|
||||||
# glTexCoord2d(1.,1.); glVertex3f($r, $b, 0);
|
|
||||||
# glTexCoord2d(1.,0.); glVertex3f($r, $t, 0);
|
|
||||||
# glTexCoord2d(0.,0.); glVertex3f($l, $t, 0);
|
|
||||||
# glEnd();
|
|
||||||
# glBindTexture(GL_TEXTURE_2D, 0);
|
|
||||||
# glDisable(GL_TEXTURE_2D);
|
|
||||||
# glDisable(GL_BLEND);
|
|
||||||
# glEnable(GL_LIGHTING);
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
sub _render_texture {
|
sub _render_texture {
|
||||||
my ($self, $tex_id, $l, $r, $b, $t) = @_;
|
my ($self, $tex_id, $l, $r, $b, $t) = @_;
|
||||||
|
|
||||||
@ -1551,7 +1484,6 @@ sub _render_texture {
|
|||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
sub draw_active_object_annotations {
|
sub draw_active_object_annotations {
|
||||||
# $fakecolor is a boolean indicating, that the objects shall be rendered in a color coding the object index for picking.
|
# $fakecolor is a boolean indicating, that the objects shall be rendered in a color coding the object index for picking.
|
||||||
@ -1665,7 +1597,6 @@ sub draw_active_object_annotations {
|
|||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
sub draw_legend {
|
sub draw_legend {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
@ -1694,7 +1625,6 @@ sub draw_legend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
sub opengl_info
|
sub opengl_info
|
||||||
{
|
{
|
||||||
@ -2096,14 +2026,12 @@ sub load_wipe_tower_toolpaths {
|
|||||||
if ($print->step_done(STEP_WIPE_TOWER));
|
if ($print->step_done(STEP_WIPE_TOWER));
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
sub load_gcode_preview {
|
sub load_gcode_preview {
|
||||||
my ($self, $print) = @_;
|
my ($self, $print) = @_;
|
||||||
|
|
||||||
$self->SetCurrent($self->GetContext) if $self->UseVBOs;
|
$self->SetCurrent($self->GetContext) if $self->UseVBOs;
|
||||||
Slic3r::GUI::_3DScene::load_gcode_preview($print, $self->volumes, $self->UseVBOs);
|
Slic3r::GUI::_3DScene::load_gcode_preview($print, $self->volumes, $self->UseVBOs);
|
||||||
}
|
}
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
sub set_toolpaths_range {
|
sub set_toolpaths_range {
|
||||||
my ($self, $min_z, $max_z) = @_;
|
my ($self, $min_z, $max_z) = @_;
|
||||||
|
@ -153,7 +153,6 @@ sub new {
|
|||||||
|
|
||||||
EVT_NOTEBOOK_PAGE_CHANGED($self, $self->{preview_notebook}, sub {
|
EVT_NOTEBOOK_PAGE_CHANGED($self, $self->{preview_notebook}, sub {
|
||||||
my $preview = $self->{preview_notebook}->GetCurrentPage;
|
my $preview = $self->{preview_notebook}->GetCurrentPage;
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
if ($preview == $self->{preview3D})
|
if ($preview == $self->{preview3D})
|
||||||
{
|
{
|
||||||
$self->{preview3D}->canvas->set_legend_enabled(1);
|
$self->{preview3D}->canvas->set_legend_enabled(1);
|
||||||
@ -161,8 +160,7 @@ sub new {
|
|||||||
} else {
|
} else {
|
||||||
$self->{preview3D}->canvas->set_legend_enabled(0);
|
$self->{preview3D}->canvas->set_legend_enabled(0);
|
||||||
}
|
}
|
||||||
# $self->{preview3D}->load_print(1) if ($preview == $self->{preview3D});
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$preview->OnActivate if $preview->can('OnActivate');
|
$preview->OnActivate if $preview->can('OnActivate');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -785,9 +783,7 @@ sub remove {
|
|||||||
splice @{$self->{objects}}, $obj_idx, 1;
|
splice @{$self->{objects}}, $obj_idx, 1;
|
||||||
$self->{model}->delete_object($obj_idx);
|
$self->{model}->delete_object($obj_idx);
|
||||||
$self->{print}->delete_object($obj_idx);
|
$self->{print}->delete_object($obj_idx);
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->{print}->clear_gcode_preview_data;
|
$self->{print}->clear_gcode_preview_data;
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->{list}->DeleteItem($obj_idx);
|
$self->{list}->DeleteItem($obj_idx);
|
||||||
$self->object_list_changed;
|
$self->object_list_changed;
|
||||||
|
|
||||||
@ -808,9 +804,7 @@ sub reset {
|
|||||||
@{$self->{objects}} = ();
|
@{$self->{objects}} = ();
|
||||||
$self->{model}->clear_objects;
|
$self->{model}->clear_objects;
|
||||||
$self->{print}->clear_objects;
|
$self->{print}->clear_objects;
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->{print}->clear_gcode_preview_data;
|
$self->{print}->clear_gcode_preview_data;
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->{list}->DeleteAllItems;
|
$self->{list}->DeleteAllItems;
|
||||||
$self->object_list_changed;
|
$self->object_list_changed;
|
||||||
|
|
||||||
@ -1451,11 +1445,9 @@ sub on_export_completed {
|
|||||||
# this updates buttons status
|
# this updates buttons status
|
||||||
$self->object_list_changed;
|
$self->object_list_changed;
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
# refresh preview
|
# refresh preview
|
||||||
$self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
|
$self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
|
||||||
$self->{preview3D}->reload_print if $self->{preview3D};
|
$self->{preview3D}->reload_print if $self->{preview3D};
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub do_print {
|
sub do_print {
|
||||||
|
@ -5,16 +5,10 @@ use utf8;
|
|||||||
|
|
||||||
use Slic3r::Print::State ':steps';
|
use Slic3r::Print::State ':steps';
|
||||||
use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE);
|
use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE);
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX);
|
use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX);
|
||||||
#use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX);
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
use base qw(Wx::Panel Class::Accessor);
|
use base qw(Wx::Panel Class::Accessor);
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
__PACKAGE__->mk_accessors(qw(print enabled _loaded canvas slider_low slider_high single_layer auto_zoom));
|
__PACKAGE__->mk_accessors(qw(print enabled _loaded canvas slider_low slider_high single_layer auto_zoom));
|
||||||
#__PACKAGE__->mk_accessors(qw(print enabled _loaded canvas slider_low slider_high single_layer));
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
@ -24,9 +18,7 @@ sub new {
|
|||||||
$self->{config} = $config;
|
$self->{config} = $config;
|
||||||
$self->{number_extruders} = 1;
|
$self->{number_extruders} = 1;
|
||||||
$self->{preferred_color_mode} = 'feature';
|
$self->{preferred_color_mode} = 'feature';
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->auto_zoom(1);
|
$self->auto_zoom(1);
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
# init GUI elements
|
# init GUI elements
|
||||||
my $canvas = Slic3r::GUI::3DScene->new($self);
|
my $canvas = Slic3r::GUI::3DScene->new($self);
|
||||||
@ -69,7 +61,6 @@ sub new {
|
|||||||
my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, "1 Layer");
|
my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, "1 Layer");
|
||||||
my $checkbox_color_by_extruder = $self->{checkbox_color_by_extruder} = Wx::CheckBox->new($self, -1, "Tool");
|
my $checkbox_color_by_extruder = $self->{checkbox_color_by_extruder} = Wx::CheckBox->new($self, -1, "Tool");
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
my $choice_view_type = Wx::Choice->new($self, -1);
|
my $choice_view_type = Wx::Choice->new($self, -1);
|
||||||
$choice_view_type->Append("Feature type");
|
$choice_view_type->Append("Feature type");
|
||||||
$choice_view_type->Append("Height");
|
$choice_view_type->Append("Height");
|
||||||
@ -97,7 +88,6 @@ sub new {
|
|||||||
my $checkbox_travel = Wx::CheckBox->new($self, -1, "Travel");
|
my $checkbox_travel = Wx::CheckBox->new($self, -1, "Travel");
|
||||||
my $checkbox_retractions = Wx::CheckBox->new($self, -1, "Retractions");
|
my $checkbox_retractions = Wx::CheckBox->new($self, -1, "Retractions");
|
||||||
my $checkbox_unretractions = Wx::CheckBox->new($self, -1, "Unretractions");
|
my $checkbox_unretractions = Wx::CheckBox->new($self, -1, "Unretractions");
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||||
my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
|
my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||||
@ -112,13 +102,11 @@ sub new {
|
|||||||
$vsizer_outer->Add($hsizer, 3, wxALIGN_CENTER_HORIZONTAL, 0);
|
$vsizer_outer->Add($hsizer, 3, wxALIGN_CENTER_HORIZONTAL, 0);
|
||||||
$vsizer_outer->Add($checkbox_singlelayer, 0, wxTOP | wxALIGN_CENTER_HORIZONTAL, 5);
|
$vsizer_outer->Add($checkbox_singlelayer, 0, wxTOP | wxALIGN_CENTER_HORIZONTAL, 5);
|
||||||
$vsizer_outer->Add($checkbox_color_by_extruder, 0, wxTOP | wxALIGN_CENTER_HORIZONTAL, 5);
|
$vsizer_outer->Add($checkbox_color_by_extruder, 0, wxTOP | wxALIGN_CENTER_HORIZONTAL, 5);
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$vsizer_outer->Add($choice_view_type, 0, wxEXPAND | wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
|
$vsizer_outer->Add($choice_view_type, 0, wxEXPAND | wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
|
||||||
$vsizer_outer->Add($checklist_features, 0, wxTOP | wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
|
$vsizer_outer->Add($checklist_features, 0, wxTOP | wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
|
||||||
$vsizer_outer->Add($checkbox_travel, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
$vsizer_outer->Add($checkbox_travel, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
||||||
$vsizer_outer->Add($checkbox_retractions, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
$vsizer_outer->Add($checkbox_retractions, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
||||||
$vsizer_outer->Add($checkbox_unretractions, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
$vsizer_outer->Add($checkbox_unretractions, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||||
$sizer->Add($canvas, 1, wxALL | wxEXPAND, 0);
|
$sizer->Add($canvas, 1, wxALL | wxEXPAND, 0);
|
||||||
@ -199,7 +187,6 @@ sub new {
|
|||||||
$self->reload_print;
|
$self->reload_print;
|
||||||
});
|
});
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
EVT_CHOICE($self, $choice_view_type, sub {
|
EVT_CHOICE($self, $choice_view_type, sub {
|
||||||
my $selection = $choice_view_type->GetCurrentSelection();
|
my $selection = $choice_view_type->GetCurrentSelection();
|
||||||
$self->print->set_gcode_preview_type($selection);
|
$self->print->set_gcode_preview_type($selection);
|
||||||
@ -238,7 +225,6 @@ sub new {
|
|||||||
$self->refresh_print;
|
$self->refresh_print;
|
||||||
$self->auto_zoom(1);
|
$self->auto_zoom(1);
|
||||||
});
|
});
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
$self->SetSizer($sizer);
|
$self->SetSizer($sizer);
|
||||||
$self->SetMinSize($self->GetSize);
|
$self->SetMinSize($self->GetSize);
|
||||||
@ -258,16 +244,13 @@ sub reload_print {
|
|||||||
$self->_loaded(0);
|
$self->_loaded(0);
|
||||||
|
|
||||||
if (! $self->IsShown && ! $force) {
|
if (! $self->IsShown && ! $force) {
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
# $self->{reload_delayed} = 1;
|
# $self->{reload_delayed} = 1;
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->load_print;
|
$self->load_print;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
sub refresh_print {
|
sub refresh_print {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
@ -279,7 +262,6 @@ sub refresh_print {
|
|||||||
|
|
||||||
$self->load_print;
|
$self->load_print;
|
||||||
}
|
}
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
sub load_print {
|
sub load_print {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
@ -361,10 +343,9 @@ sub load_print {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($self->IsShown) {
|
if ($self->IsShown) {
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->canvas->load_gcode_preview($self->print);
|
$self->canvas->load_gcode_preview($self->print);
|
||||||
|
|
||||||
# load skirt and brim
|
# # load skirt and brim
|
||||||
# $self->canvas->load_print_toolpaths($self->print, \@colors);
|
# $self->canvas->load_print_toolpaths($self->print, \@colors);
|
||||||
# $self->canvas->load_wipe_tower_toolpaths($self->print, \@colors);
|
# $self->canvas->load_wipe_tower_toolpaths($self->print, \@colors);
|
||||||
#
|
#
|
||||||
@ -375,15 +356,10 @@ sub load_print {
|
|||||||
# #my @volume_ids = $self->canvas->load_object($object->model_object);
|
# #my @volume_ids = $self->canvas->load_object($object->model_object);
|
||||||
# #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids;
|
# #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids;
|
||||||
# }
|
# }
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
if ($self->auto_zoom)
|
if ($self->auto_zoom)
|
||||||
{
|
{
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->canvas->zoom_to_volumes;
|
$self->canvas->zoom_to_volumes;
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
}
|
}
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->_loaded(1);
|
$self->_loaded(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,10 +421,8 @@ sub set_number_extruders {
|
|||||||
|
|
||||||
# Called by the Platter wxNotebook when this page is activated.
|
# Called by the Platter wxNotebook when this page is activated.
|
||||||
sub OnActivate {
|
sub OnActivate {
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
# my ($self) = @_;
|
# my ($self) = @_;
|
||||||
# $self->reload_print(1) if ($self->{reload_delayed});
|
# $self->reload_print(1) if ($self->{reload_delayed});
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -122,7 +122,6 @@ sub load_print {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($self->IsShown) {
|
if ($self->IsShown) {
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->canvas->load_gcode_preview($self->print);
|
$self->canvas->load_gcode_preview($self->print);
|
||||||
|
|
||||||
# # load skirt and brim
|
# # load skirt and brim
|
||||||
@ -135,7 +134,7 @@ sub load_print {
|
|||||||
# #my @volume_ids = $self->canvas->load_object($object->model_object);
|
# #my @volume_ids = $self->canvas->load_object($object->model_object);
|
||||||
# #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids;
|
# #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids;
|
||||||
# }
|
# }
|
||||||
# ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
$self->canvas->zoom_to_volumes;
|
$self->canvas->zoom_to_volumes;
|
||||||
$self->_loaded(1);
|
$self->_loaded(1);
|
||||||
}
|
}
|
||||||
|
@ -4,50 +4,9 @@
|
|||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
template <class PointClass>
|
|
||||||
BoundingBoxBase<PointClass>::BoundingBoxBase(const std::vector<PointClass> &points)
|
|
||||||
{
|
|
||||||
if (points.empty())
|
|
||||||
CONFESS("Empty point set supplied to BoundingBoxBase constructor");
|
|
||||||
typename std::vector<PointClass>::const_iterator it = points.begin();
|
|
||||||
this->min.x = this->max.x = it->x;
|
|
||||||
this->min.y = this->max.y = it->y;
|
|
||||||
for (++it; it != points.end(); ++it) {
|
|
||||||
this->min.x = std::min(it->x, this->min.x);
|
|
||||||
this->min.y = std::min(it->y, this->min.y);
|
|
||||||
this->max.x = std::max(it->x, this->max.x);
|
|
||||||
this->max.y = std::max(it->y, this->max.y);
|
|
||||||
}
|
|
||||||
this->defined = true;
|
|
||||||
}
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
template BoundingBoxBase<Point>::BoundingBoxBase(const std::vector<Point> &points);
|
template BoundingBoxBase<Point>::BoundingBoxBase(const std::vector<Point> &points);
|
||||||
template BoundingBoxBase<Pointf>::BoundingBoxBase(const std::vector<Pointf> &points);
|
template BoundingBoxBase<Pointf>::BoundingBoxBase(const std::vector<Pointf> &points);
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
template <class PointClass>
|
|
||||||
BoundingBox3Base<PointClass>::BoundingBox3Base(const std::vector<PointClass> &points)
|
|
||||||
: BoundingBoxBase<PointClass>(points)
|
|
||||||
{
|
|
||||||
if (points.empty())
|
|
||||||
CONFESS("Empty point set supplied to BoundingBox3Base constructor");
|
|
||||||
typename std::vector<PointClass>::const_iterator it = points.begin();
|
|
||||||
this->min.z = this->max.z = it->z;
|
|
||||||
for (++it; it != points.end(); ++it) {
|
|
||||||
this->min.z = std::min(it->z, this->min.z);
|
|
||||||
this->max.z = std::max(it->z, this->max.z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
template BoundingBox3Base<Pointf3>::BoundingBox3Base(const std::vector<Pointf3> &points);
|
template BoundingBox3Base<Pointf3>::BoundingBox3Base(const std::vector<Pointf3> &points);
|
||||||
|
|
||||||
BoundingBox::BoundingBox(const Lines &lines)
|
BoundingBox::BoundingBox(const Lines &lines)
|
||||||
|
@ -23,8 +23,6 @@ public:
|
|||||||
BoundingBoxBase() : defined(false) {};
|
BoundingBoxBase() : defined(false) {};
|
||||||
BoundingBoxBase(const PointClass &pmin, const PointClass &pmax) :
|
BoundingBoxBase(const PointClass &pmin, const PointClass &pmax) :
|
||||||
min(pmin), max(pmax), defined(pmin.x < pmax.x && pmin.y < pmax.y) {}
|
min(pmin), max(pmax), defined(pmin.x < pmax.x && pmin.y < pmax.y) {}
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
BoundingBoxBase(const std::vector<PointClass>& points)
|
BoundingBoxBase(const std::vector<PointClass>& points)
|
||||||
{
|
{
|
||||||
if (points.empty())
|
if (points.empty())
|
||||||
@ -42,12 +40,6 @@ public:
|
|||||||
}
|
}
|
||||||
this->defined = (this->min.x < this->max.x) && (this->min.y < this->max.y);
|
this->defined = (this->min.x < this->max.x) && (this->min.y < this->max.y);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
BoundingBoxBase(const std::vector<PointClass> &points);
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
void merge(const PointClass &point);
|
void merge(const PointClass &point);
|
||||||
void merge(const std::vector<PointClass> &points);
|
void merge(const std::vector<PointClass> &points);
|
||||||
void merge(const BoundingBoxBase<PointClass> &bb);
|
void merge(const BoundingBoxBase<PointClass> &bb);
|
||||||
@ -78,8 +70,6 @@ public:
|
|||||||
BoundingBox3Base(const PointClass &pmin, const PointClass &pmax) :
|
BoundingBox3Base(const PointClass &pmin, const PointClass &pmax) :
|
||||||
BoundingBoxBase<PointClass>(pmin, pmax)
|
BoundingBoxBase<PointClass>(pmin, pmax)
|
||||||
{ if (pmin.z >= pmax.z) BoundingBoxBase<PointClass>::defined = false; }
|
{ if (pmin.z >= pmax.z) BoundingBoxBase<PointClass>::defined = false; }
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
BoundingBox3Base(const std::vector<PointClass>& points)
|
BoundingBox3Base(const std::vector<PointClass>& points)
|
||||||
: BoundingBoxBase<PointClass>(points)
|
: BoundingBoxBase<PointClass>(points)
|
||||||
{
|
{
|
||||||
@ -95,12 +85,6 @@ public:
|
|||||||
}
|
}
|
||||||
this->defined &= (this->min.z < this->max.z);
|
this->defined &= (this->min.z < this->max.z);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
BoundingBox3Base(const std::vector<PointClass> &points);
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
void merge(const PointClass &point);
|
void merge(const PointClass &point);
|
||||||
void merge(const std::vector<PointClass> &points);
|
void merge(const std::vector<PointClass> &points);
|
||||||
void merge(const BoundingBox3Base<PointClass> &bb);
|
void merge(const BoundingBox3Base<PointClass> &bb);
|
||||||
@ -138,15 +122,7 @@ class BoundingBox3 : public BoundingBox3Base<Point3>
|
|||||||
public:
|
public:
|
||||||
BoundingBox3() : BoundingBox3Base<Point3>() {};
|
BoundingBox3() : BoundingBox3Base<Point3>() {};
|
||||||
BoundingBox3(const Point3 &pmin, const Point3 &pmax) : BoundingBox3Base<Point3>(pmin, pmax) {};
|
BoundingBox3(const Point3 &pmin, const Point3 &pmax) : BoundingBox3Base<Point3>(pmin, pmax) {};
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
BoundingBox3(const Points3& points) : BoundingBox3Base<Point3>(points) {};
|
BoundingBox3(const Points3& points) : BoundingBox3Base<Point3>(points) {};
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
BoundingBox3(const std::vector<Point3> &points) : BoundingBox3Base<Point3>(points) {};
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class BoundingBoxf : public BoundingBoxBase<Pointf>
|
class BoundingBoxf : public BoundingBoxBase<Pointf>
|
||||||
|
@ -104,42 +104,17 @@ public:
|
|||||||
float width;
|
float width;
|
||||||
// Height of the extrusion, used for visualization purposed.
|
// Height of the extrusion, used for visualization purposed.
|
||||||
float height;
|
float height;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
// Feedrate of the extrusion, used for visualization purposed.
|
// Feedrate of the extrusion, used for visualization purposed.
|
||||||
float feedrate;
|
float feedrate;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), feedrate(0.0f), m_role(role) {};
|
ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), feedrate(0.0f), m_role(role) {};
|
||||||
ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height) : mm3_per_mm(mm3_per_mm), width(width), height(height), feedrate(0.0f), m_role(role) {};
|
ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height) : mm3_per_mm(mm3_per_mm), width(width), height(height), feedrate(0.0f), m_role(role) {};
|
||||||
ExtrusionPath(const ExtrusionPath &rhs) : polyline(rhs.polyline), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), m_role(rhs.m_role) {}
|
ExtrusionPath(const ExtrusionPath &rhs) : polyline(rhs.polyline), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), m_role(rhs.m_role) {}
|
||||||
ExtrusionPath(ExtrusionPath &&rhs) : polyline(std::move(rhs.polyline)), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), m_role(rhs.m_role) {}
|
ExtrusionPath(ExtrusionPath &&rhs) : polyline(std::move(rhs.polyline)), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), m_role(rhs.m_role) {}
|
||||||
// ExtrusionPath(ExtrusionRole role, const Flow &flow) : m_role(role), mm3_per_mm(flow.mm3_per_mm()), width(flow.width), height(flow.height), feedrate(0.0f) {};
|
// ExtrusionPath(ExtrusionRole role, const Flow &flow) : m_role(role), mm3_per_mm(flow.mm3_per_mm()), width(flow.width), height(flow.height), feedrate(0.0f) {};
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), m_role(role) {};
|
|
||||||
ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height) : mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role) {};
|
|
||||||
ExtrusionPath(const ExtrusionPath &rhs) : polyline(rhs.polyline), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), m_role(rhs.m_role) {}
|
|
||||||
ExtrusionPath(ExtrusionPath &&rhs) : polyline(std::move(rhs.polyline)), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), m_role(rhs.m_role) {}
|
|
||||||
// ExtrusionPath(ExtrusionRole role, const Flow &flow) : m_role(role), mm3_per_mm(flow.mm3_per_mm()), width(flow.width), height(flow.height) {};
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
ExtrusionPath& operator=(const ExtrusionPath &rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->polyline = rhs.polyline; return *this; }
|
ExtrusionPath& operator=(const ExtrusionPath &rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->polyline = rhs.polyline; return *this; }
|
||||||
ExtrusionPath& operator=(ExtrusionPath &&rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->polyline = std::move(rhs.polyline); return *this; }
|
ExtrusionPath& operator=(ExtrusionPath &&rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->polyline = std::move(rhs.polyline); return *this; }
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
ExtrusionPath& operator=(const ExtrusionPath &rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->polyline = rhs.polyline; return *this; }
|
|
||||||
ExtrusionPath& operator=(ExtrusionPath &&rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->polyline = std::move(rhs.polyline); return *this; }
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
ExtrusionPath* clone() const { return new ExtrusionPath (*this); }
|
ExtrusionPath* clone() const { return new ExtrusionPath (*this); }
|
||||||
void reverse() { this->polyline.reverse(); }
|
void reverse() { this->polyline.reverse(); }
|
||||||
|
@ -402,8 +402,6 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
m_time_estimator.reset();
|
m_time_estimator.reset();
|
||||||
m_time_estimator.set_dialect(print.config.gcode_flavor);
|
m_time_estimator.set_dialect(print.config.gcode_flavor);
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
// resets analyzer
|
// resets analyzer
|
||||||
m_analyzer.reset();
|
m_analyzer.reset();
|
||||||
|
|
||||||
@ -411,8 +409,6 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
m_last_mm3_per_mm = GCodeAnalyzer::Default_mm3_per_mm;
|
m_last_mm3_per_mm = GCodeAnalyzer::Default_mm3_per_mm;
|
||||||
m_last_width = GCodeAnalyzer::Default_Width;
|
m_last_width = GCodeAnalyzer::Default_Width;
|
||||||
m_last_height = GCodeAnalyzer::Default_Height;
|
m_last_height = GCodeAnalyzer::Default_Height;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
// How many times will be change_layer() called?
|
// How many times will be change_layer() called?
|
||||||
// change_layer() in turn increments the progress bar status.
|
// change_layer() in turn increments the progress bar status.
|
||||||
@ -823,12 +819,8 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
// starts analizer calculations
|
// starts analizer calculations
|
||||||
m_analyzer.calc_gcode_preview_data(print);
|
m_analyzer.calc_gcode_preview_data(print);
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCode::placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override)
|
std::string GCode::placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override)
|
||||||
@ -1320,18 +1312,7 @@ void GCode::process_layer(
|
|||||||
if (print_object == nullptr)
|
if (print_object == nullptr)
|
||||||
// This layer is empty for this particular object, it has neither object extrusions nor support extrusions at this print_z.
|
// This layer is empty for this particular object, it has neither object extrusions nor support extrusions at this print_z.
|
||||||
continue;
|
continue;
|
||||||
//############################################################################################################
|
|
||||||
#if !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
if (m_enable_analyzer_markers) {
|
|
||||||
// Store the binary pointer to the layer object directly into the G-code to be accessed by the GCodeAnalyzer.
|
|
||||||
char buf[64];
|
|
||||||
sprintf(buf, ";_LAYEROBJ:%p\n", m_layer);
|
|
||||||
gcode += buf;
|
|
||||||
}
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
m_config.apply(print_object->config, true);
|
m_config.apply(print_object->config, true);
|
||||||
m_layer = layers[layer_id].layer();
|
m_layer = layers[layer_id].layer();
|
||||||
if (m_config.avoid_crossing_perimeters)
|
if (m_config.avoid_crossing_perimeters)
|
||||||
@ -2023,18 +2004,8 @@ std::string GCode::extrude_support(const ExtrusionEntityCollection &support_fill
|
|||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
void GCode::_write(FILE* file, const char *what)
|
void GCode::_write(FILE* file, const char *what)
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
void GCode::_write(FILE* file, const char *what, size_t size)
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
{
|
{
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
if (what != nullptr) {
|
if (what != nullptr) {
|
||||||
// apply analyzer, if enabled
|
// apply analyzer, if enabled
|
||||||
const char* gcode = m_enable_analyzer ? m_analyzer.process_gcode(what).c_str() : what;
|
const char* gcode = m_enable_analyzer ? m_analyzer.process_gcode(what).c_str() : what;
|
||||||
@ -2043,16 +2014,6 @@ void GCode::_write(FILE* file, const char *what, size_t size)
|
|||||||
fwrite(gcode, 1, ::strlen(gcode), file);
|
fwrite(gcode, 1, ::strlen(gcode), file);
|
||||||
// updates time estimator and gcode lines vector
|
// updates time estimator and gcode lines vector
|
||||||
m_time_estimator.add_gcode_block(gcode);
|
m_time_estimator.add_gcode_block(gcode);
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
if (size > 0) {
|
|
||||||
// writes string to file
|
|
||||||
fwrite(what, 1, size, file);
|
|
||||||
// updates time estimator and gcode lines vector
|
|
||||||
m_time_estimator.add_gcode_block(what);
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2086,15 +2047,8 @@ void GCode::_write_format(FILE* file, const char* format, ...)
|
|||||||
char *bufptr = buffer_dynamic ? (char*)malloc(buflen) : buffer;
|
char *bufptr = buffer_dynamic ? (char*)malloc(buflen) : buffer;
|
||||||
int res = ::vsnprintf(bufptr, buflen, format, args);
|
int res = ::vsnprintf(bufptr, buflen, format, args);
|
||||||
if (res > 0)
|
if (res > 0)
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
_write(file, bufptr);
|
_write(file, bufptr);
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
_write(file, bufptr, res);
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
if (buffer_dynamic)
|
if (buffer_dynamic)
|
||||||
free(bufptr);
|
free(bufptr);
|
||||||
|
|
||||||
@ -2179,8 +2133,6 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||||||
double F = speed * 60; // convert mm/sec to mm/min
|
double F = speed * 60; // convert mm/sec to mm/min
|
||||||
|
|
||||||
// extrude arc or line
|
// extrude arc or line
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
if (m_enable_extrusion_role_markers || m_enable_analyzer)
|
if (m_enable_extrusion_role_markers || m_enable_analyzer)
|
||||||
{
|
{
|
||||||
if (path.role() != m_last_extrusion_role)
|
if (path.role() != m_last_extrusion_role)
|
||||||
@ -2231,19 +2183,6 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||||||
gcode += buf;
|
gcode += buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
if (m_enable_extrusion_role_markers || m_enable_analyzer_markers) {
|
|
||||||
if (path.role() != m_last_extrusion_role) {
|
|
||||||
m_last_extrusion_role = path.role();
|
|
||||||
char buf[32];
|
|
||||||
sprintf(buf, ";_EXTRUSION_ROLE:%d\n", int(path.role()));
|
|
||||||
gcode += buf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
std::string comment;
|
std::string comment;
|
||||||
if (m_enable_cooling_markers) {
|
if (m_enable_cooling_markers) {
|
||||||
|
@ -17,11 +17,7 @@
|
|||||||
#include "GCode/WipeTower.hpp"
|
#include "GCode/WipeTower.hpp"
|
||||||
#include "GCodeTimeEstimator.hpp"
|
#include "GCodeTimeEstimator.hpp"
|
||||||
#include "EdgeGrid.hpp"
|
#include "EdgeGrid.hpp"
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
#include "GCode/Analyzer.hpp"
|
#include "GCode/Analyzer.hpp"
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -123,28 +119,16 @@ public:
|
|||||||
m_enable_loop_clipping(true),
|
m_enable_loop_clipping(true),
|
||||||
m_enable_cooling_markers(false),
|
m_enable_cooling_markers(false),
|
||||||
m_enable_extrusion_role_markers(false),
|
m_enable_extrusion_role_markers(false),
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
m_enable_analyzer(true),
|
m_enable_analyzer(true),
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
m_enable_analyzer_markers(false),
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
m_layer_count(0),
|
m_layer_count(0),
|
||||||
m_layer_index(-1),
|
m_layer_index(-1),
|
||||||
m_layer(nullptr),
|
m_layer(nullptr),
|
||||||
m_volumetric_speed(0),
|
m_volumetric_speed(0),
|
||||||
m_last_pos_defined(false),
|
m_last_pos_defined(false),
|
||||||
m_last_extrusion_role(erNone),
|
m_last_extrusion_role(erNone),
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
m_last_mm3_per_mm(GCodeAnalyzer::Default_mm3_per_mm),
|
m_last_mm3_per_mm(GCodeAnalyzer::Default_mm3_per_mm),
|
||||||
m_last_width(GCodeAnalyzer::Default_Width),
|
m_last_width(GCodeAnalyzer::Default_Width),
|
||||||
m_last_height(GCodeAnalyzer::Default_Height),
|
m_last_height(GCodeAnalyzer::Default_Height),
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
m_brim_done(false),
|
m_brim_done(false),
|
||||||
m_second_layer_things_done(false),
|
m_second_layer_things_done(false),
|
||||||
m_last_obj_copy(nullptr, Point(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max()))
|
m_last_obj_copy(nullptr, Point(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max()))
|
||||||
@ -169,12 +153,8 @@ public:
|
|||||||
// inside the generated string and after the G-code export finishes.
|
// inside the generated string and after the G-code export finishes.
|
||||||
std::string placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override = nullptr);
|
std::string placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override = nullptr);
|
||||||
bool enable_cooling_markers() const { return m_enable_cooling_markers; }
|
bool enable_cooling_markers() const { return m_enable_cooling_markers; }
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
bool enable_analyzer() const { return m_enable_analyzer; }
|
bool enable_analyzer() const { return m_enable_analyzer; }
|
||||||
void enable_analyzer(bool enable) { m_enable_analyzer = enable; }
|
void enable_analyzer(bool enable) { m_enable_analyzer = enable; }
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
// For Perl bindings, to be used exclusively by unit tests.
|
// For Perl bindings, to be used exclusively by unit tests.
|
||||||
unsigned int layer_count() const { return m_layer_count; }
|
unsigned int layer_count() const { return m_layer_count; }
|
||||||
@ -267,20 +247,10 @@ protected:
|
|||||||
// Markers for the Pressure Equalizer to recognize the extrusion type.
|
// Markers for the Pressure Equalizer to recognize the extrusion type.
|
||||||
// The Pressure Equalizer removes the markers from the final G-code.
|
// The Pressure Equalizer removes the markers from the final G-code.
|
||||||
bool m_enable_extrusion_role_markers;
|
bool m_enable_extrusion_role_markers;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
// Enableds the G-code Analyzer.
|
// Enableds the G-code Analyzer.
|
||||||
// Extended markers will be added during G-code generation.
|
// Extended markers will be added during G-code generation.
|
||||||
// The G-code Analyzer will remove these comments from the final G-code.
|
// The G-code Analyzer will remove these comments from the final G-code.
|
||||||
bool m_enable_analyzer;
|
bool m_enable_analyzer;
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
// Extended markers for the G-code Analyzer.
|
|
||||||
// The G-code Analyzer will remove these comments from the final G-code.
|
|
||||||
bool m_enable_analyzer_markers;
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
// How many times will change_layer() be called?
|
// How many times will change_layer() be called?
|
||||||
// change_layer() will update the progress bar.
|
// change_layer() will update the progress bar.
|
||||||
unsigned int m_layer_count;
|
unsigned int m_layer_count;
|
||||||
@ -293,14 +263,10 @@ protected:
|
|||||||
double m_volumetric_speed;
|
double m_volumetric_speed;
|
||||||
// Support for the extrusion role markers. Which marker is active?
|
// Support for the extrusion role markers. Which marker is active?
|
||||||
ExtrusionRole m_last_extrusion_role;
|
ExtrusionRole m_last_extrusion_role;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
// Support for G-Code Analyzer
|
// Support for G-Code Analyzer
|
||||||
double m_last_mm3_per_mm;
|
double m_last_mm3_per_mm;
|
||||||
float m_last_width;
|
float m_last_width;
|
||||||
float m_last_height;
|
float m_last_height;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
Point m_last_pos;
|
Point m_last_pos;
|
||||||
bool m_last_pos_defined;
|
bool m_last_pos_defined;
|
||||||
@ -322,25 +288,12 @@ protected:
|
|||||||
// Time estimator
|
// Time estimator
|
||||||
GCodeTimeEstimator m_time_estimator;
|
GCodeTimeEstimator m_time_estimator;
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
// Analyzer
|
// Analyzer
|
||||||
GCodeAnalyzer m_analyzer;
|
GCodeAnalyzer m_analyzer;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
// Write a string into a file.
|
// Write a string into a file.
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
void _write(FILE* file, const std::string& what) { this->_write(file, what.c_str()); }
|
void _write(FILE* file, const std::string& what) { this->_write(file, what.c_str()); }
|
||||||
void _write(FILE* file, const char *what);
|
void _write(FILE* file, const char *what);
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
void _write(FILE* file, const std::string& what) { this->_write(file, what.c_str(), what.size()); }
|
|
||||||
void _write(FILE* file, const char *what, size_t size);
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
// Write a string into a file.
|
// Write a string into a file.
|
||||||
// Add a newline, if the string does not end with a newline already.
|
// Add a newline, if the string does not end with a newline already.
|
||||||
|
@ -4,16 +4,10 @@
|
|||||||
|
|
||||||
#include "../libslic3r.h"
|
#include "../libslic3r.h"
|
||||||
#include "../PrintConfig.hpp"
|
#include "../PrintConfig.hpp"
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
#include "Print.hpp"
|
#include "Print.hpp"
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
#include "Analyzer.hpp"
|
#include "Analyzer.hpp"
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
static const std::string AXIS_STR = "XYZE";
|
static const std::string AXIS_STR = "XYZE";
|
||||||
static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
|
static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
|
||||||
static const float INCHES_TO_MM = 25.4f;
|
static const float INCHES_TO_MM = 25.4f;
|
||||||
@ -21,333 +15,9 @@ static const float DEFAULT_FEEDRATE = 0.0f;
|
|||||||
static const unsigned int DEFAULT_EXTRUDER_ID = 0;
|
static const unsigned int DEFAULT_EXTRUDER_ID = 0;
|
||||||
static const Slic3r::Pointf3 DEFAULT_START_POSITION = Slic3r::Pointf3(0.0f, 0.0f, 0.0f);
|
static const Slic3r::Pointf3 DEFAULT_START_POSITION = Slic3r::Pointf3(0.0f, 0.0f, 0.0f);
|
||||||
static const float DEFAULT_START_EXTRUSION = 0.0f;
|
static const float DEFAULT_START_EXTRUSION = 0.0f;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
void GCodeMovesDB::reset()
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < m_layers.size(); ++ i)
|
|
||||||
delete m_layers[i];
|
|
||||||
m_layers.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
GCodeAnalyzer::GCodeAnalyzer(const Slic3r::GCodeConfig *config) :
|
|
||||||
m_config(config)
|
|
||||||
{
|
|
||||||
reset();
|
|
||||||
m_moves = new GCodeMovesDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
GCodeAnalyzer::~GCodeAnalyzer()
|
|
||||||
{
|
|
||||||
delete m_moves;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GCodeAnalyzer::reset()
|
|
||||||
{
|
|
||||||
output_buffer.clear();
|
|
||||||
output_buffer_length = 0;
|
|
||||||
|
|
||||||
m_current_extruder = 0;
|
|
||||||
// Zero the position of the XYZE axes + the current feed
|
|
||||||
memset(m_current_pos, 0, sizeof(float) * 5);
|
|
||||||
m_current_extrusion_role = erNone;
|
|
||||||
m_current_extrusion_width = 0;
|
|
||||||
m_current_extrusion_height = 0;
|
|
||||||
// Expect the first command to fill the nozzle (deretract).
|
|
||||||
m_retracted = true;
|
|
||||||
m_moves->reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* GCodeAnalyzer::process(const char *szGCode, bool flush)
|
|
||||||
{
|
|
||||||
// Reset length of the output_buffer.
|
|
||||||
output_buffer_length = 0;
|
|
||||||
|
|
||||||
if (szGCode != 0) {
|
|
||||||
const char *p = szGCode;
|
|
||||||
while (*p != 0) {
|
|
||||||
// Find end of the line.
|
|
||||||
const char *endl = p;
|
|
||||||
// Slic3r always generates end of lines in a Unix style.
|
|
||||||
for (; *endl != 0 && *endl != '\n'; ++ endl) ;
|
|
||||||
// Process a G-code line, store it into the provided GCodeLine object.
|
|
||||||
bool should_output = process_line(p, endl - p);
|
|
||||||
if (*endl == '\n')
|
|
||||||
++ endl;
|
|
||||||
if (should_output)
|
|
||||||
push_to_output(p, endl - p);
|
|
||||||
p = endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return output_buffer.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is a white space?
|
|
||||||
static inline bool is_ws(const char c) { return c == ' ' || c == '\t'; }
|
|
||||||
// Is it an end of line? Consider a comment to be an end of line as well.
|
|
||||||
static inline bool is_eol(const char c) { return c == 0 || c == '\r' || c == '\n' || c == ';'; };
|
|
||||||
// Is it a white space or end of line?
|
|
||||||
static inline bool is_ws_or_eol(const char c) { return is_ws(c) || is_eol(c); };
|
|
||||||
|
|
||||||
// Eat whitespaces.
|
|
||||||
static void eatws(const char *&line)
|
|
||||||
{
|
|
||||||
while (is_ws(*line))
|
|
||||||
++ line;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse an int starting at the current position of a line.
|
|
||||||
// If succeeded, the line pointer is advanced.
|
|
||||||
static inline int parse_int(const char *&line)
|
|
||||||
{
|
|
||||||
char *endptr = NULL;
|
|
||||||
long result = strtol(line, &endptr, 10);
|
|
||||||
if (endptr == NULL || !is_ws_or_eol(*endptr))
|
|
||||||
throw std::runtime_error("GCodeAnalyzer: Error parsing an int");
|
|
||||||
line = endptr;
|
|
||||||
return int(result);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Parse an int starting at the current position of a line.
|
|
||||||
// If succeeded, the line pointer is advanced.
|
|
||||||
static inline float parse_float(const char *&line)
|
|
||||||
{
|
|
||||||
char *endptr = NULL;
|
|
||||||
float result = strtof(line, &endptr);
|
|
||||||
if (endptr == NULL || !is_ws_or_eol(*endptr))
|
|
||||||
throw std::runtime_error("GCodeAnalyzer: Error parsing a float");
|
|
||||||
line = endptr;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define EXTRUSION_ROLE_TAG ";_EXTRUSION_ROLE:"
|
|
||||||
bool GCodeAnalyzer::process_line(const char *line, const size_t len)
|
|
||||||
{
|
|
||||||
if (strncmp(line, EXTRUSION_ROLE_TAG, strlen(EXTRUSION_ROLE_TAG)) == 0) {
|
|
||||||
line += strlen(EXTRUSION_ROLE_TAG);
|
|
||||||
int role = atoi(line);
|
|
||||||
this->m_current_extrusion_role = ExtrusionRole(role);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Set the type, copy the line to the buffer.
|
|
||||||
buf.type = GCODE_MOVE_TYPE_OTHER;
|
|
||||||
buf.modified = false;
|
|
||||||
if (buf.raw.size() < len + 1)
|
|
||||||
buf.raw.assign(line, line + len + 1);
|
|
||||||
else
|
|
||||||
memcpy(buf.raw.data(), line, len);
|
|
||||||
buf.raw[len] = 0;
|
|
||||||
buf.raw_length = len;
|
|
||||||
|
|
||||||
memcpy(buf.pos_start, m_current_pos, sizeof(float)*5);
|
|
||||||
memcpy(buf.pos_end, m_current_pos, sizeof(float)*5);
|
|
||||||
memset(buf.pos_provided, 0, 5);
|
|
||||||
|
|
||||||
buf.volumetric_extrusion_rate = 0.f;
|
|
||||||
buf.volumetric_extrusion_rate_start = 0.f;
|
|
||||||
buf.volumetric_extrusion_rate_end = 0.f;
|
|
||||||
buf.max_volumetric_extrusion_rate_slope_positive = 0.f;
|
|
||||||
buf.max_volumetric_extrusion_rate_slope_negative = 0.f;
|
|
||||||
buf.extrusion_role = m_current_extrusion_role;
|
|
||||||
|
|
||||||
// Parse the G-code line, store the result into the buf.
|
|
||||||
switch (toupper(*line ++)) {
|
|
||||||
case 'G': {
|
|
||||||
int gcode = parse_int(line);
|
|
||||||
eatws(line);
|
|
||||||
switch (gcode) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
// G0, G1: A FFF 3D printer does not make a difference between the two.
|
|
||||||
float new_pos[5];
|
|
||||||
memcpy(new_pos, m_current_pos, sizeof(float)*5);
|
|
||||||
bool changed[5] = { false, false, false, false, false };
|
|
||||||
while (!is_eol(*line)) {
|
|
||||||
char axis = toupper(*line++);
|
|
||||||
int i = -1;
|
|
||||||
switch (axis) {
|
|
||||||
case 'X':
|
|
||||||
case 'Y':
|
|
||||||
case 'Z':
|
|
||||||
i = axis - 'X';
|
|
||||||
break;
|
|
||||||
case 'E':
|
|
||||||
i = 3;
|
|
||||||
break;
|
|
||||||
case 'F':
|
|
||||||
i = 4;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
if (i == -1)
|
|
||||||
throw std::runtime_error(std::string("GCodeAnalyzer: Invalid axis for G0/G1: ") + axis);
|
|
||||||
buf.pos_provided[i] = true;
|
|
||||||
new_pos[i] = parse_float(line);
|
|
||||||
if (i == 3 && m_config->use_relative_e_distances.value)
|
|
||||||
new_pos[i] += m_current_pos[i];
|
|
||||||
changed[i] = new_pos[i] != m_current_pos[i];
|
|
||||||
eatws(line);
|
|
||||||
}
|
|
||||||
if (changed[3]) {
|
|
||||||
// Extrusion, retract or unretract.
|
|
||||||
float diff = new_pos[3] - m_current_pos[3];
|
|
||||||
if (diff < 0) {
|
|
||||||
buf.type = GCODE_MOVE_TYPE_RETRACT;
|
|
||||||
m_retracted = true;
|
|
||||||
} else if (! changed[0] && ! changed[1] && ! changed[2]) {
|
|
||||||
// assert(m_retracted);
|
|
||||||
buf.type = GCODE_MOVE_TYPE_UNRETRACT;
|
|
||||||
m_retracted = false;
|
|
||||||
} else {
|
|
||||||
assert(changed[0] || changed[1]);
|
|
||||||
// Moving in XY plane.
|
|
||||||
buf.type = GCODE_MOVE_TYPE_EXTRUDE;
|
|
||||||
// Calculate the volumetric extrusion rate.
|
|
||||||
float diff[4];
|
|
||||||
for (size_t i = 0; i < 4; ++ i)
|
|
||||||
diff[i] = new_pos[i] - m_current_pos[i];
|
|
||||||
// volumetric extrusion rate = A_filament * F_xyz * L_e / L_xyz [mm^3/min]
|
|
||||||
float len2 = diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2];
|
|
||||||
float rate = m_filament_crossections[m_current_extruder] * new_pos[4] * sqrt((diff[3]*diff[3])/len2);
|
|
||||||
buf.volumetric_extrusion_rate = rate;
|
|
||||||
buf.volumetric_extrusion_rate_start = rate;
|
|
||||||
buf.volumetric_extrusion_rate_end = rate;
|
|
||||||
m_stat.update(rate, sqrt(len2));
|
|
||||||
if (rate < 10.f) {
|
|
||||||
printf("Extremely low flow rate: %f\n", rate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (changed[0] || changed[1] || changed[2]) {
|
|
||||||
// Moving without extrusion.
|
|
||||||
buf.type = GCODE_MOVE_TYPE_MOVE;
|
|
||||||
}
|
|
||||||
memcpy(m_current_pos, new_pos, sizeof(float) * 5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 92:
|
|
||||||
{
|
|
||||||
// G92 : Set Position
|
|
||||||
// Set a logical coordinate position to a new value without actually moving the machine motors.
|
|
||||||
// Which axes to set?
|
|
||||||
bool set = false;
|
|
||||||
while (!is_eol(*line)) {
|
|
||||||
char axis = toupper(*line++);
|
|
||||||
switch (axis) {
|
|
||||||
case 'X':
|
|
||||||
case 'Y':
|
|
||||||
case 'Z':
|
|
||||||
m_current_pos[axis - 'X'] = (!is_ws_or_eol(*line)) ? parse_float(line) : 0.f;
|
|
||||||
set = true;
|
|
||||||
break;
|
|
||||||
case 'E':
|
|
||||||
m_current_pos[3] = (!is_ws_or_eol(*line)) ? parse_float(line) : 0.f;
|
|
||||||
set = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw std::runtime_error(std::string("GCodeAnalyzer: Incorrect axis in a G92 G-code: ") + axis);
|
|
||||||
}
|
|
||||||
eatws(line);
|
|
||||||
}
|
|
||||||
assert(set);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 10:
|
|
||||||
case 22:
|
|
||||||
// Firmware retract.
|
|
||||||
buf.type = GCODE_MOVE_TYPE_RETRACT;
|
|
||||||
m_retracted = true;
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
case 23:
|
|
||||||
// Firmware unretract.
|
|
||||||
buf.type = GCODE_MOVE_TYPE_UNRETRACT;
|
|
||||||
m_retracted = false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// Ignore the rest.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'M': {
|
|
||||||
int mcode = parse_int(line);
|
|
||||||
eatws(line);
|
|
||||||
switch (mcode) {
|
|
||||||
default:
|
|
||||||
// Ignore the rest of the M-codes.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'T':
|
|
||||||
{
|
|
||||||
// Activate an extruder head.
|
|
||||||
int new_extruder = parse_int(line);
|
|
||||||
if (new_extruder != m_current_extruder) {
|
|
||||||
m_current_extruder = new_extruder;
|
|
||||||
m_retracted = true;
|
|
||||||
buf.type = GCODE_MOVE_TYPE_TOOL_CHANGE;
|
|
||||||
} else {
|
|
||||||
buf.type = GCODE_MOVE_TYPE_NOOP;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.extruder_id = m_current_extruder;
|
|
||||||
memcpy(buf.pos_end, m_current_pos, sizeof(float)*5);
|
|
||||||
*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GCodeAnalyzer::push_to_output(const char *text, const size_t len, bool add_eol)
|
|
||||||
{
|
|
||||||
// New length of the output buffer content.
|
|
||||||
size_t len_new = output_buffer_length + len + 1;
|
|
||||||
if (add_eol)
|
|
||||||
++ len_new;
|
|
||||||
|
|
||||||
// Resize the output buffer to a power of 2 higher than the required memory.
|
|
||||||
if (output_buffer.size() < len_new) {
|
|
||||||
size_t v = len_new;
|
|
||||||
// Compute the next highest power of 2 of 32-bit v
|
|
||||||
// http://graphics.stanford.edu/~seander/bithacks.html
|
|
||||||
v--;
|
|
||||||
v |= v >> 1;
|
|
||||||
v |= v >> 2;
|
|
||||||
v |= v >> 4;
|
|
||||||
v |= v >> 8;
|
|
||||||
v |= v >> 16;
|
|
||||||
v++;
|
|
||||||
output_buffer.resize(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the text to the output.
|
|
||||||
if (len != 0) {
|
|
||||||
memcpy(output_buffer.data() + output_buffer_length, text, len);
|
|
||||||
output_buffer_length += len;
|
|
||||||
}
|
|
||||||
if (add_eol)
|
|
||||||
output_buffer[output_buffer_length ++] = '\n';
|
|
||||||
output_buffer[output_buffer_length] = 0;
|
|
||||||
}
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
const std::string GCodeAnalyzer::Extrusion_Role_Tag = "_ANALYZER_EXTR_ROLE:";
|
const std::string GCodeAnalyzer::Extrusion_Role_Tag = "_ANALYZER_EXTR_ROLE:";
|
||||||
const std::string GCodeAnalyzer::Mm3_Per_Mm_Tag = "_ANALYZER_MM3_PER_MM:";
|
const std::string GCodeAnalyzer::Mm3_Per_Mm_Tag = "_ANALYZER_MM3_PER_MM:";
|
||||||
const std::string GCodeAnalyzer::Width_Tag = "_ANALYZER_WIDTH:";
|
const std::string GCodeAnalyzer::Width_Tag = "_ANALYZER_WIDTH:";
|
||||||
@ -539,6 +209,7 @@ const GCodeAnalyzer::PreviewData::Color GCodeAnalyzer::PreviewData::Extrusion::D
|
|||||||
Color(0.0f, 0.0f, 0.0f, 1.0f) // erMixed
|
Color(0.0f, 0.0f, 0.0f, 1.0f) // erMixed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// todo: merge with Slic3r::ExtrusionRole2String() from GCode.cpp
|
||||||
const std::string GCodeAnalyzer::PreviewData::Extrusion::Default_Extrusion_Role_Names[Num_Extrusion_Roles]
|
const std::string GCodeAnalyzer::PreviewData::Extrusion::Default_Extrusion_Role_Names[Num_Extrusion_Roles]
|
||||||
{
|
{
|
||||||
"None",
|
"None",
|
||||||
@ -1424,7 +1095,5 @@ GCodeAnalyzer::PreviewData::Color operator * (float f, const GCodeAnalyzer::Prev
|
|||||||
clamp(0.0f, 1.0f, f * color.rgba[2]),
|
clamp(0.0f, 1.0f, f * color.rgba[2]),
|
||||||
clamp(0.0f, 1.0f, f * color.rgba[3]));
|
clamp(0.0f, 1.0f, f * color.rgba[3]));
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -5,169 +5,13 @@
|
|||||||
#include "../PrintConfig.hpp"
|
#include "../PrintConfig.hpp"
|
||||||
#include "../ExtrusionEntity.hpp"
|
#include "../ExtrusionEntity.hpp"
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
#include "Point.hpp"
|
#include "Point.hpp"
|
||||||
#include "GCodeReader.hpp"
|
#include "GCodeReader.hpp"
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
class Print;
|
class Print;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
enum GCodeMoveType
|
|
||||||
{
|
|
||||||
GCODE_MOVE_TYPE_NOOP,
|
|
||||||
GCODE_MOVE_TYPE_RETRACT,
|
|
||||||
GCODE_MOVE_TYPE_UNRETRACT,
|
|
||||||
GCODE_MOVE_TYPE_TOOL_CHANGE,
|
|
||||||
GCODE_MOVE_TYPE_MOVE,
|
|
||||||
GCODE_MOVE_TYPE_EXTRUDE,
|
|
||||||
};
|
|
||||||
|
|
||||||
// For visualization purposes, for the purposes of the G-code analysis and timing.
|
|
||||||
// The size of this structure is 56B.
|
|
||||||
// Keep the size of this structure as small as possible, because all moves of a complete print
|
|
||||||
// may be held in RAM.
|
|
||||||
struct GCodeMove
|
|
||||||
{
|
|
||||||
bool moving_xy(const float* pos_start) const { return fabs(pos_end[0] - pos_start[0]) > 0.f || fabs(pos_end[1] - pos_start[1]) > 0.f; }
|
|
||||||
bool moving_xy() const { return moving_xy(get_pos_start()); }
|
|
||||||
bool moving_z (const float* pos_start) const { return fabs(pos_end[2] - pos_start[2]) > 0.f; }
|
|
||||||
bool moving_z () const { return moving_z(get_pos_start()); }
|
|
||||||
bool extruding(const float* pos_start) const { return moving_xy() && pos_end[3] > pos_start[3]; }
|
|
||||||
bool extruding() const { return extruding(get_pos_start()); }
|
|
||||||
bool retracting(const float* pos_start) const { return pos_end[3] < pos_start[3]; }
|
|
||||||
bool retracting() const { return retracting(get_pos_start()); }
|
|
||||||
bool deretracting(const float* pos_start) const { return ! moving_xy() && pos_end[3] > pos_start[3]; }
|
|
||||||
bool deretracting() const { return deretracting(get_pos_start()); }
|
|
||||||
|
|
||||||
float dist_xy2(const float* pos_start) const { return (pos_end[0] - pos_start[0]) * (pos_end[0] - pos_start[0]) + (pos_end[1] - pos_start[1]) * (pos_end[1] - pos_start[1]); }
|
|
||||||
float dist_xy2() const { return dist_xy2(get_pos_start()); }
|
|
||||||
float dist_xyz2(const float* pos_start) const { return (pos_end[0] - pos_start[0]) * (pos_end[0] - pos_start[0]) + (pos_end[1] - pos_start[1]) * (pos_end[1] - pos_start[1]) + (pos_end[2] - pos_start[2]) * (pos_end[2] - pos_start[2]); }
|
|
||||||
float dist_xyz2() const { return dist_xyz2(get_pos_start()); }
|
|
||||||
|
|
||||||
float dist_xy(const float* pos_start) const { return sqrt(dist_xy2(pos_start)); }
|
|
||||||
float dist_xy() const { return dist_xy(get_pos_start()); }
|
|
||||||
float dist_xyz(const float* pos_start) const { return sqrt(dist_xyz2(pos_start)); }
|
|
||||||
float dist_xyz() const { return dist_xyz(get_pos_start()); }
|
|
||||||
|
|
||||||
float dist_e(const float* pos_start) const { return fabs(pos_end[3] - pos_start[3]); }
|
|
||||||
float dist_e() const { return dist_e(get_pos_start()); }
|
|
||||||
|
|
||||||
float feedrate() const { return pos_end[4]; }
|
|
||||||
float time(const float* pos_start) const { return dist_xyz(pos_start) / feedrate(); }
|
|
||||||
float time() const { return time(get_pos_start()); }
|
|
||||||
float time_inv(const float* pos_start) const { return feedrate() / dist_xyz(pos_start); }
|
|
||||||
float time_inv() const { return time_inv(get_pos_start()); }
|
|
||||||
|
|
||||||
const float* get_pos_start() const { assert(type != GCODE_MOVE_TYPE_NOOP); return this[-1].pos_end; }
|
|
||||||
|
|
||||||
// Pack the enums to conserve space. With C++x11 the allocation size could be declared for enums, but for old C++ this is the only portable way.
|
|
||||||
// GCodeLineType
|
|
||||||
uint8_t type;
|
|
||||||
// Index of the active extruder.
|
|
||||||
uint8_t extruder_id;
|
|
||||||
// ExtrusionRole
|
|
||||||
uint8_t extrusion_role;
|
|
||||||
// For example, is it a bridge flow? Is the fan on?
|
|
||||||
uint8_t flags;
|
|
||||||
// X,Y,Z,E,F. Storing the state of the currently active extruder only.
|
|
||||||
float pos_end[5];
|
|
||||||
// Extrusion width, height for this segment in um.
|
|
||||||
uint16_t extrusion_width;
|
|
||||||
uint16_t extrusion_height;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::vector<GCodeMove> GCodeMoves;
|
|
||||||
|
|
||||||
struct GCodeLayer
|
|
||||||
{
|
|
||||||
// Index of an object printed.
|
|
||||||
size_t object_idx;
|
|
||||||
// Index of an object instance printed.
|
|
||||||
size_t object_instance_idx;
|
|
||||||
// Index of the layer printed.
|
|
||||||
size_t layer_idx;
|
|
||||||
// Top z coordinate of the layer printed.
|
|
||||||
float layer_z_top;
|
|
||||||
|
|
||||||
// Moves over this layer. The 0th move is always of type GCODELINETYPE_NOOP and
|
|
||||||
// it sets the initial position and tool for the layer.
|
|
||||||
GCodeMoves moves;
|
|
||||||
|
|
||||||
// Indices into m_moves, where the tool changes happen.
|
|
||||||
// This is useful, if one wants to display just only a piece of the path quickly.
|
|
||||||
std::vector<size_t> tool_changes;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::vector<GCodeLayer*> GCodeLayerPtrs;
|
|
||||||
|
|
||||||
class GCodeMovesDB
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GCodeMovesDB() {};
|
|
||||||
~GCodeMovesDB() { reset(); }
|
|
||||||
void reset();
|
|
||||||
GCodeLayerPtrs m_layers;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Processes a G-code to extract moves and their types.
|
|
||||||
// This information is then used to render the print simulation colored by the extrusion type
|
|
||||||
// or various speeds.
|
|
||||||
// The GCodeAnalyzer is employed as a G-Code filter. It reads the G-code as it is generated,
|
|
||||||
// parses the comments generated by Slic3r just for the analyzer, and removes these comments.
|
|
||||||
class GCodeAnalyzer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GCodeAnalyzer(const Slic3r::GCodeConfig *config);
|
|
||||||
~GCodeAnalyzer();
|
|
||||||
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
// Process a next batch of G-code lines. Flush the internal buffers if asked for.
|
|
||||||
const char* process(const char *szGCode, bool flush);
|
|
||||||
// Length of the buffer returned by process().
|
|
||||||
size_t get_output_buffer_length() const { return output_buffer_length; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Keeps the reference, does not own the config.
|
|
||||||
const Slic3r::GCodeConfig *m_config;
|
|
||||||
|
|
||||||
// Internal data.
|
|
||||||
// X,Y,Z,E,F
|
|
||||||
float m_current_pos[5];
|
|
||||||
size_t m_current_extruder;
|
|
||||||
ExtrusionRole m_current_extrusion_role;
|
|
||||||
uint16_t m_current_extrusion_width;
|
|
||||||
uint16_t m_current_extrusion_height;
|
|
||||||
bool m_retracted;
|
|
||||||
|
|
||||||
GCodeMovesDB *m_moves;
|
|
||||||
|
|
||||||
// Output buffer will only grow. It will not be reallocated over and over.
|
|
||||||
std::vector<char> output_buffer;
|
|
||||||
size_t output_buffer_length;
|
|
||||||
|
|
||||||
bool process_line(const char *line, const size_t len);
|
|
||||||
|
|
||||||
// Push the text to the end of the output_buffer.
|
|
||||||
void push_to_output(const char *text, const size_t len, bool add_eol = true);
|
|
||||||
};
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // !ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
class GCodeAnalyzer
|
class GCodeAnalyzer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -553,9 +397,6 @@ private:
|
|||||||
GCodeAnalyzer::PreviewData::Color operator + (const GCodeAnalyzer::PreviewData::Color& c1, const GCodeAnalyzer::PreviewData::Color& c2);
|
GCodeAnalyzer::PreviewData::Color operator + (const GCodeAnalyzer::PreviewData::Color& c1, const GCodeAnalyzer::PreviewData::Color& c2);
|
||||||
GCodeAnalyzer::PreviewData::Color operator * (float f, const GCodeAnalyzer::PreviewData::Color& color);
|
GCodeAnalyzer::PreviewData::Color operator * (float f, const GCodeAnalyzer::PreviewData::Color& color);
|
||||||
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
#endif /* slic3r_GCode_Analyzer_hpp_ */
|
#endif /* slic3r_GCode_Analyzer_hpp_ */
|
||||||
|
@ -218,8 +218,6 @@ Line::ccw(const Point& point) const
|
|||||||
return point.ccw(*this);
|
return point.ccw(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
double Line3::length() const
|
double Line3::length() const
|
||||||
{
|
{
|
||||||
return a.distance_to(b);
|
return a.distance_to(b);
|
||||||
@ -229,8 +227,6 @@ Vector3 Line3::vector() const
|
|||||||
{
|
{
|
||||||
return Vector3(b.x - a.x, b.y - a.y, b.z - a.z);
|
return Vector3(b.x - a.x, b.y - a.y, b.z - a.z);
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
Pointf3
|
Pointf3
|
||||||
Linef3::intersect_plane(double z) const
|
Linef3::intersect_plane(double z) const
|
||||||
|
@ -7,20 +7,12 @@
|
|||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
class Line;
|
class Line;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
class Line3;
|
class Line3;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
class Linef3;
|
class Linef3;
|
||||||
class Polyline;
|
class Polyline;
|
||||||
class ThickLine;
|
class ThickLine;
|
||||||
typedef std::vector<Line> Lines;
|
typedef std::vector<Line> Lines;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
typedef std::vector<Line3> Lines3;
|
typedef std::vector<Line3> Lines3;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
typedef std::vector<ThickLine> ThickLines;
|
typedef std::vector<ThickLine> ThickLines;
|
||||||
|
|
||||||
class Line
|
class Line
|
||||||
@ -66,8 +58,6 @@ class ThickLine : public Line
|
|||||||
ThickLine(Point _a, Point _b) : Line(_a, _b), a_width(0), b_width(0) {};
|
ThickLine(Point _a, Point _b) : Line(_a, _b), a_width(0), b_width(0) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
class Line3
|
class Line3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -80,8 +70,6 @@ public:
|
|||||||
double length() const;
|
double length() const;
|
||||||
Vector3 vector() const;
|
Vector3 vector() const;
|
||||||
};
|
};
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
class Linef
|
class Linef
|
||||||
{
|
{
|
||||||
|
@ -214,8 +214,6 @@ MultiPoint::_douglas_peucker(const Points &points, const double tolerance)
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
void MultiPoint3::translate(double x, double y)
|
void MultiPoint3::translate(double x, double y)
|
||||||
{
|
{
|
||||||
for (Point3& p : points)
|
for (Point3& p : points)
|
||||||
@ -270,8 +268,6 @@ bool MultiPoint3::remove_duplicate_points()
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
BoundingBox get_extents(const MultiPoint &mp)
|
BoundingBox get_extents(const MultiPoint &mp)
|
||||||
{
|
{
|
||||||
|
@ -10,11 +10,7 @@
|
|||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
class BoundingBox;
|
class BoundingBox;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
class BoundingBox3;
|
class BoundingBox3;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
class MultiPoint
|
class MultiPoint
|
||||||
{
|
{
|
||||||
@ -84,8 +80,6 @@ public:
|
|||||||
static Points _douglas_peucker(const Points &points, const double tolerance);
|
static Points _douglas_peucker(const Points &points, const double tolerance);
|
||||||
};
|
};
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
class MultiPoint3
|
class MultiPoint3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -104,8 +98,6 @@ public:
|
|||||||
// Remove exact duplicates, return true if any duplicate has been removed.
|
// Remove exact duplicates, return true if any duplicate has been removed.
|
||||||
bool remove_duplicate_points();
|
bool remove_duplicate_points();
|
||||||
};
|
};
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
extern BoundingBox get_extents(const MultiPoint &mp);
|
extern BoundingBox get_extents(const MultiPoint &mp);
|
||||||
extern BoundingBox get_extents_rotated(const std::vector<Point> &points, double angle);
|
extern BoundingBox get_extents_rotated(const std::vector<Point> &points, double angle);
|
||||||
|
@ -14,29 +14,17 @@ class Line;
|
|||||||
class Linef;
|
class Linef;
|
||||||
class MultiPoint;
|
class MultiPoint;
|
||||||
class Point;
|
class Point;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
class Point3;
|
class Point3;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
class Pointf;
|
class Pointf;
|
||||||
class Pointf3;
|
class Pointf3;
|
||||||
typedef Point Vector;
|
typedef Point Vector;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
typedef Point3 Vector3;
|
typedef Point3 Vector3;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
typedef Pointf Vectorf;
|
typedef Pointf Vectorf;
|
||||||
typedef Pointf3 Vectorf3;
|
typedef Pointf3 Vectorf3;
|
||||||
typedef std::vector<Point> Points;
|
typedef std::vector<Point> Points;
|
||||||
typedef std::vector<Point*> PointPtrs;
|
typedef std::vector<Point*> PointPtrs;
|
||||||
typedef std::vector<const Point*> PointConstPtrs;
|
typedef std::vector<const Point*> PointConstPtrs;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
typedef std::vector<Point3> Points3;
|
typedef std::vector<Point3> Points3;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
typedef std::vector<Pointf> Pointfs;
|
typedef std::vector<Pointf> Pointfs;
|
||||||
typedef std::vector<Pointf3> Pointf3s;
|
typedef std::vector<Pointf3> Pointf3s;
|
||||||
|
|
||||||
@ -201,24 +189,11 @@ public:
|
|||||||
static Point3 new_scale(coordf_t x, coordf_t y, coordf_t z) { return Point3(coord_t(scale_(x)), coord_t(scale_(y)), coord_t(scale_(z))); }
|
static Point3 new_scale(coordf_t x, coordf_t y, coordf_t z) { return Point3(coord_t(scale_(x)), coord_t(scale_(y)), coord_t(scale_(z))); }
|
||||||
bool operator==(const Point3 &rhs) const { return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z; }
|
bool operator==(const Point3 &rhs) const { return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z; }
|
||||||
bool operator!=(const Point3 &rhs) const { return ! (*this == rhs); }
|
bool operator!=(const Point3 &rhs) const { return ! (*this == rhs); }
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
bool coincides_with(const Point3& rhs) const { return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z; }
|
bool coincides_with(const Point3& rhs) const { return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z; }
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
private:
|
private:
|
||||||
// Hide the following inherited methods:
|
// Hide the following inherited methods:
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
bool operator==(const Point &rhs) const;
|
bool operator==(const Point &rhs) const;
|
||||||
bool operator!=(const Point &rhs) const;
|
bool operator!=(const Point &rhs) const;
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
bool operator==(const Point &rhs);
|
|
||||||
bool operator!=(const Point &rhs);
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream &stm, const Pointf &pointf);
|
std::ostream& operator<<(std::ostream &stm, const Pointf &pointf);
|
||||||
@ -273,11 +248,7 @@ public:
|
|||||||
static Pointf3 new_unscale(coord_t x, coord_t y, coord_t z) {
|
static Pointf3 new_unscale(coord_t x, coord_t y, coord_t z) {
|
||||||
return Pointf3(unscale(x), unscale(y), unscale(z));
|
return Pointf3(unscale(x), unscale(y), unscale(z));
|
||||||
};
|
};
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
static Pointf3 new_unscale(const Point3& p) { return Pointf3(unscale(p.x), unscale(p.y), unscale(p.z)); }
|
static Pointf3 new_unscale(const Point3& p) { return Pointf3(unscale(p.x), unscale(p.y), unscale(p.z)); }
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
void scale(double factor);
|
void scale(double factor);
|
||||||
void translate(const Vectorf3 &vector);
|
void translate(const Vectorf3 &vector);
|
||||||
void translate(double x, double y, double z);
|
void translate(double x, double y, double z);
|
||||||
@ -290,21 +261,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Hide the following inherited methods:
|
// Hide the following inherited methods:
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
bool operator==(const Pointf &rhs) const;
|
bool operator==(const Pointf &rhs) const;
|
||||||
bool operator!=(const Pointf &rhs) const;
|
bool operator!=(const Pointf &rhs) const;
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
bool operator==(const Pointf &rhs);
|
|
||||||
bool operator!=(const Pointf &rhs);
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
inline Pointf3 operator+(const Pointf3& p1, const Pointf3& p2) { return Pointf3(p1.x + p2.x, p1.y + p2.y, p1.z + p2.z); }
|
inline Pointf3 operator+(const Pointf3& p1, const Pointf3& p2) { return Pointf3(p1.x + p2.x, p1.y + p2.y, p1.z + p2.z); }
|
||||||
inline Pointf3 operator-(const Pointf3& p1, const Pointf3& p2) { return Pointf3(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z); }
|
inline Pointf3 operator-(const Pointf3& p1, const Pointf3& p2) { return Pointf3(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z); }
|
||||||
inline Pointf3 operator-(const Pointf3& p) { return Pointf3(-p.x, -p.y, -p.z); }
|
inline Pointf3 operator-(const Pointf3& p) { return Pointf3(-p.x, -p.y, -p.z); }
|
||||||
@ -317,8 +277,6 @@ inline Pointf3 normalize(const Pointf3& v)
|
|||||||
coordf_t len = ::sqrt(sqr(v.x) + sqr(v.y) + sqr(v.z));
|
coordf_t len = ::sqrt(sqr(v.x) + sqr(v.y) + sqr(v.z));
|
||||||
return (len != 0.0) ? 1.0 / len * v : Pointf3(0.0, 0.0, 0.0);
|
return (len != 0.0) ? 1.0 / len * v : Pointf3(0.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
template<typename TO> inline TO convert_to(const Point &src) { return TO(typename TO::coord_type(src.x), typename TO::coord_type(src.y)); }
|
template<typename TO> inline TO convert_to(const Point &src) { return TO(typename TO::coord_type(src.x), typename TO::coord_type(src.y)); }
|
||||||
template<typename TO> inline TO convert_to(const Pointf &src) { return TO(typename TO::coord_type(src.x), typename TO::coord_type(src.y)); }
|
template<typename TO> inline TO convert_to(const Pointf &src) { return TO(typename TO::coord_type(src.x), typename TO::coord_type(src.y)); }
|
||||||
|
@ -278,8 +278,6 @@ ThickPolyline::reverse()
|
|||||||
std::swap(this->endpoints.first, this->endpoints.second);
|
std::swap(this->endpoints.first, this->endpoints.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
Lines3 Polyline3::lines() const
|
Lines3 Polyline3::lines() const
|
||||||
{
|
{
|
||||||
Lines3 lines;
|
Lines3 lines;
|
||||||
@ -293,7 +291,5 @@ Lines3 Polyline3::lines() const
|
|||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,8 +129,6 @@ class ThickPolyline : public Polyline {
|
|||||||
void reverse();
|
void reverse();
|
||||||
};
|
};
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
class Polyline3 : public MultiPoint3
|
class Polyline3 : public MultiPoint3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -138,8 +136,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<Polyline3> Polylines3;
|
typedef std::vector<Polyline3> Polylines3;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +66,6 @@ bool Print::reload_model_instances()
|
|||||||
return invalidated;
|
return invalidated;
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
void Print::clear_gcode_preview_data()
|
void Print::clear_gcode_preview_data()
|
||||||
{
|
{
|
||||||
gcode_preview.reset();
|
gcode_preview.reset();
|
||||||
@ -103,8 +101,6 @@ void Print::set_gcode_preview_unretractions_visible(bool visible)
|
|||||||
{
|
{
|
||||||
gcode_preview.unretraction.is_visible = visible;
|
gcode_preview.unretraction.is_visible = visible;
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
PrintRegion* Print::add_region()
|
PrintRegion* Print::add_region()
|
||||||
{
|
{
|
||||||
|
@ -15,11 +15,7 @@
|
|||||||
#include "Slicing.hpp"
|
#include "Slicing.hpp"
|
||||||
#include "GCode/ToolOrdering.hpp"
|
#include "GCode/ToolOrdering.hpp"
|
||||||
#include "GCode/WipeTower.hpp"
|
#include "GCode/WipeTower.hpp"
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
#include "GCode/Analyzer.hpp"
|
#include "GCode/Analyzer.hpp"
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
#include "tbb/atomic.h"
|
#include "tbb/atomic.h"
|
||||||
|
|
||||||
@ -245,11 +241,7 @@ public:
|
|||||||
|
|
||||||
// ordered collections of extrusion paths to build skirt loops and brim
|
// ordered collections of extrusion paths to build skirt loops and brim
|
||||||
ExtrusionEntityCollection skirt, brim;
|
ExtrusionEntityCollection skirt, brim;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
GCodeAnalyzer::PreviewData gcode_preview;
|
GCodeAnalyzer::PreviewData gcode_preview;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
Print() : total_used_filament(0), total_extruded_volume(0) { restart(); }
|
Print() : total_used_filament(0), total_extruded_volume(0) { restart(); }
|
||||||
~Print() { clear_objects(); }
|
~Print() { clear_objects(); }
|
||||||
@ -263,8 +255,6 @@ public:
|
|||||||
void reload_object(size_t idx);
|
void reload_object(size_t idx);
|
||||||
bool reload_model_instances();
|
bool reload_model_instances();
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
void clear_gcode_preview_data();
|
void clear_gcode_preview_data();
|
||||||
void set_gcode_preview_type(unsigned char type);
|
void set_gcode_preview_type(unsigned char type);
|
||||||
void set_gcode_preview_extrusion_flags(unsigned int flags);
|
void set_gcode_preview_extrusion_flags(unsigned int flags);
|
||||||
@ -272,8 +262,6 @@ public:
|
|||||||
void set_gcode_preview_travel_visible(bool visible);
|
void set_gcode_preview_travel_visible(bool visible);
|
||||||
void set_gcode_preview_retractions_visible(bool visible);
|
void set_gcode_preview_retractions_visible(bool visible);
|
||||||
void set_gcode_preview_unretractions_visible(bool visible);
|
void set_gcode_preview_unretractions_visible(bool visible);
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
// methods for handling regions
|
// methods for handling regions
|
||||||
PrintRegion* get_region(size_t idx) { return regions.at(idx); }
|
PrintRegion* get_region(size_t idx) { return regions.at(idx); }
|
||||||
|
@ -163,29 +163,12 @@ static inline T clamp(const T low, const T high, const T value)
|
|||||||
return std::max(low, std::min(high, value));
|
return std::max(low, std::min(high, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#define ENRICO_GCODE_PREVIEW 1
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
template <typename T, typename Number>
|
template <typename T, typename Number>
|
||||||
static inline T lerp(const T& a, const T& b, Number t)
|
static inline T lerp(const T& a, const T& b, Number t)
|
||||||
{
|
{
|
||||||
assert((t >= Number(-EPSILON)) && (t <= Number(1) + Number(EPSILON)));
|
assert((t >= Number(-EPSILON)) && (t <= Number(1) + Number(EPSILON)));
|
||||||
return (Number(1) - t) * a + t * b;
|
return (Number(1) - t) * a + t * b;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
//############################################################################################################
|
|
||||||
template <typename T>
|
|
||||||
static inline T lerp(const T a, const T b, const T t)
|
|
||||||
{
|
|
||||||
assert(t >= T(-EPSILON) && t <= T(1.+EPSILON));
|
|
||||||
return (1. - t) * a + t * b;
|
|
||||||
}
|
|
||||||
//############################################################################################################
|
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
@ -8,11 +8,7 @@
|
|||||||
#include "../../libslic3r/Geometry.hpp"
|
#include "../../libslic3r/Geometry.hpp"
|
||||||
#include "../../libslic3r/Print.hpp"
|
#include "../../libslic3r/Print.hpp"
|
||||||
#include "../../libslic3r/Slicing.hpp"
|
#include "../../libslic3r/Slicing.hpp"
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
#include "GCode/Analyzer.hpp"
|
#include "GCode/Analyzer.hpp"
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -25,14 +21,10 @@
|
|||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/spin_mutex.h>
|
#include <tbb/spin_mutex.h>
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
#include <wx/bitmap.h>
|
#include <wx/bitmap.h>
|
||||||
#include <wx/dcmemory.h>
|
#include <wx/dcmemory.h>
|
||||||
#include <wx/image.h>
|
#include <wx/image.h>
|
||||||
#include <wx/settings.h>
|
#include <wx/settings.h>
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
@ -215,12 +207,8 @@ void GLVolume::set_range(double min_z, double max_z)
|
|||||||
|
|
||||||
void GLVolume::render() const
|
void GLVolume::render() const
|
||||||
{
|
{
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
if (!is_active)
|
if (!is_active)
|
||||||
return;
|
return;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
@ -352,12 +340,9 @@ void GLVolumeCollection::render_VBOs() const
|
|||||||
GLint color_id = (current_program_id > 0) ? glGetUniformLocation(current_program_id, "uniform_color") : -1;
|
GLint color_id = (current_program_id > 0) ? glGetUniformLocation(current_program_id, "uniform_color") : -1;
|
||||||
|
|
||||||
for (GLVolume *volume : this->volumes) {
|
for (GLVolume *volume : this->volumes) {
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
if (!volume->is_active)
|
if (!volume->is_active)
|
||||||
continue;
|
continue;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
if (!volume->indexed_vertex_array.vertices_and_normals_interleaved_VBO_id)
|
if (!volume->indexed_vertex_array.vertices_and_normals_interleaved_VBO_id)
|
||||||
continue;
|
continue;
|
||||||
GLsizei n_triangles = GLsizei(std::min(volume->indexed_vertex_array.triangle_indices_size, volume->tverts_range.second - volume->tverts_range.first));
|
GLsizei n_triangles = GLsizei(std::min(volume->indexed_vertex_array.triangle_indices_size, volume->tverts_range.second - volume->tverts_range.first));
|
||||||
@ -396,12 +381,9 @@ void GLVolumeCollection::render_legacy() const
|
|||||||
|
|
||||||
for (GLVolume *volume : this->volumes) {
|
for (GLVolume *volume : this->volumes) {
|
||||||
assert(! volume->indexed_vertex_array.vertices_and_normals_interleaved_VBO_id);
|
assert(! volume->indexed_vertex_array.vertices_and_normals_interleaved_VBO_id);
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
if (!volume->is_active)
|
if (!volume->is_active)
|
||||||
continue;
|
continue;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
GLsizei n_triangles = GLsizei(std::min(volume->indexed_vertex_array.triangle_indices_size, volume->tverts_range.second - volume->tverts_range.first));
|
GLsizei n_triangles = GLsizei(std::min(volume->indexed_vertex_array.triangle_indices_size, volume->tverts_range.second - volume->tverts_range.first));
|
||||||
GLsizei n_quads = GLsizei(std::min(volume->indexed_vertex_array.quad_indices_size, volume->qverts_range.second - volume->qverts_range.first));
|
GLsizei n_quads = GLsizei(std::min(volume->indexed_vertex_array.quad_indices_size, volume->qverts_range.second - volume->qverts_range.first));
|
||||||
if (n_triangles + n_quads == 0)
|
if (n_triangles + n_quads == 0)
|
||||||
@ -638,8 +620,6 @@ static void thick_lines_to_indexed_vertex_array(
|
|||||||
#undef BOTTOM
|
#undef BOTTOM
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
// caller is responsible for supplying NO lines with zero length
|
// caller is responsible for supplying NO lines with zero length
|
||||||
static void thick_lines_to_indexed_vertex_array(const Lines3& lines,
|
static void thick_lines_to_indexed_vertex_array(const Lines3& lines,
|
||||||
const std::vector<double>& widths,
|
const std::vector<double>& widths,
|
||||||
@ -954,8 +934,6 @@ static void point_to_indexed_vertex_array(const Point3& point,
|
|||||||
volume.push_triangle(idxs[3], idxs[1], idxs[4]);
|
volume.push_triangle(idxs[3], idxs[1], idxs[4]);
|
||||||
volume.push_triangle(idxs[0], idxs[3], idxs[4]);
|
volume.push_triangle(idxs[0], idxs[3], idxs[4]);
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
static void thick_lines_to_verts(
|
static void thick_lines_to_verts(
|
||||||
const Lines &lines,
|
const Lines &lines,
|
||||||
@ -968,8 +946,6 @@ static void thick_lines_to_verts(
|
|||||||
thick_lines_to_indexed_vertex_array(lines, widths, heights, closed, top_z, volume.indexed_vertex_array);
|
thick_lines_to_indexed_vertex_array(lines, widths, heights, closed, top_z, volume.indexed_vertex_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
static void thick_lines_to_verts(const Lines3& lines,
|
static void thick_lines_to_verts(const Lines3& lines,
|
||||||
const std::vector<double>& widths,
|
const std::vector<double>& widths,
|
||||||
const std::vector<double>& heights,
|
const std::vector<double>& heights,
|
||||||
@ -995,8 +971,6 @@ static inline void extrusionentity_to_verts(const ExtrusionPath &extrusion_path,
|
|||||||
std::vector<double> heights(lines.size(), extrusion_path.height);
|
std::vector<double> heights(lines.size(), extrusion_path.height);
|
||||||
thick_lines_to_verts(lines, widths, heights, false, print_z, volume);
|
thick_lines_to_verts(lines, widths, heights, false, print_z, volume);
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
// Fill in the qverts and tverts with quads and triangles for the extrusion_path.
|
// Fill in the qverts and tverts with quads and triangles for the extrusion_path.
|
||||||
static inline void extrusionentity_to_verts(const ExtrusionPath &extrusion_path, float print_z, const Point ©, GLVolume &volume)
|
static inline void extrusionentity_to_verts(const ExtrusionPath &extrusion_path, float print_z, const Point ©, GLVolume &volume)
|
||||||
@ -1081,8 +1055,6 @@ static void extrusionentity_to_verts(const ExtrusionEntity *extrusion_entity, fl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
static void polyline3_to_verts(const Polyline3& polyline, double width, double height, GLVolume& volume)
|
static void polyline3_to_verts(const Polyline3& polyline, double width, double height, GLVolume& volume)
|
||||||
{
|
{
|
||||||
Lines3 lines = polyline.lines();
|
Lines3 lines = polyline.lines();
|
||||||
@ -1300,8 +1272,6 @@ void _3DScene::LegendTexture::_destroy_texture()
|
|||||||
m_tex_id = 0;
|
m_tex_id = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
void _3DScene::_glew_init()
|
void _3DScene::_glew_init()
|
||||||
{
|
{
|
||||||
@ -1335,8 +1305,6 @@ static inline std::vector<float> parse_colors(const std::vector<std::string> &sc
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
void _3DScene::load_gcode_preview(const Print* print, GLVolumeCollection* volumes, bool use_VBOs)
|
void _3DScene::load_gcode_preview(const Print* print, GLVolumeCollection* volumes, bool use_VBOs)
|
||||||
{
|
{
|
||||||
if (volumes->empty())
|
if (volumes->empty())
|
||||||
@ -1368,8 +1336,6 @@ unsigned int _3DScene::get_legend_texture_height()
|
|||||||
{
|
{
|
||||||
return s_legend_texture.get_texture_height();
|
return s_legend_texture.get_texture_height();
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
// Create 3D thick extrusion lines for a skirt and brim.
|
// Create 3D thick extrusion lines for a skirt and brim.
|
||||||
// Adds a new Slic3r::GUI::3DScene::Volume to volumes.
|
// Adds a new Slic3r::GUI::3DScene::Volume to volumes.
|
||||||
@ -1728,8 +1694,6 @@ void _3DScene::_load_wipe_tower_toolpaths(
|
|||||||
BOOST_LOG_TRIVIAL(debug) << "Loading wipe tower toolpaths in parallel - end";
|
BOOST_LOG_TRIVIAL(debug) << "Loading wipe tower toolpaths in parallel - end";
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
void _3DScene::_load_gcode_extrusion_paths(const Print& print, GLVolumeCollection& volumes, bool use_VBOs)
|
void _3DScene::_load_gcode_extrusion_paths(const Print& print, GLVolumeCollection& volumes, bool use_VBOs)
|
||||||
{
|
{
|
||||||
// helper functions to select data in dependence of the extrusion view type
|
// helper functions to select data in dependence of the extrusion view type
|
||||||
@ -2071,7 +2035,5 @@ void _3DScene::_generate_legend_texture(const Print& print)
|
|||||||
{
|
{
|
||||||
s_legend_texture.generate_texture(print);
|
s_legend_texture.generate_texture(print);
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,7 @@
|
|||||||
#include "../../libslic3r/TriangleMesh.hpp"
|
#include "../../libslic3r/TriangleMesh.hpp"
|
||||||
#include "../../libslic3r/Utils.hpp"
|
#include "../../libslic3r/Utils.hpp"
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
class wxBitmap;
|
class wxBitmap;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
@ -112,13 +108,9 @@ public:
|
|||||||
push_geometry(float(x), float(y), float(z), float(nx), float(ny), float(nz));
|
push_geometry(float(x), float(y), float(z), float(nx), float(ny), float(nz));
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
inline void push_geometry(const Pointf3& p, const Vectorf3& n) {
|
inline void push_geometry(const Pointf3& p, const Vectorf3& n) {
|
||||||
push_geometry(p.x, p.y, p.z, n.x, n.y, n.z);
|
push_geometry(p.x, p.y, p.z, n.x, n.y, n.z);
|
||||||
}
|
}
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
inline void push_triangle(int idx1, int idx2, int idx3) {
|
inline void push_triangle(int idx1, int idx2, int idx3) {
|
||||||
if (this->triangle_indices.size() + 3 > this->vertices_and_normals_interleaved.capacity())
|
if (this->triangle_indices.size() + 3 > this->vertices_and_normals_interleaved.capacity())
|
||||||
@ -221,11 +213,7 @@ public:
|
|||||||
select_group_id(-1),
|
select_group_id(-1),
|
||||||
drag_group_id(-1),
|
drag_group_id(-1),
|
||||||
selected(false),
|
selected(false),
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
is_active(true),
|
is_active(true),
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
hover(false),
|
hover(false),
|
||||||
tverts_range(0, size_t(-1)),
|
tverts_range(0, size_t(-1)),
|
||||||
qverts_range(0, size_t(-1))
|
qverts_range(0, size_t(-1))
|
||||||
@ -262,12 +250,8 @@ public:
|
|||||||
int drag_group_id;
|
int drag_group_id;
|
||||||
// Is this object selected?
|
// Is this object selected?
|
||||||
bool selected;
|
bool selected;
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
// Whether or not this volume is active for rendering
|
// Whether or not this volume is active for rendering
|
||||||
bool is_active;
|
bool is_active;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
// Boolean: Is mouse over this object?
|
// Boolean: Is mouse over this object?
|
||||||
bool hover;
|
bool hover;
|
||||||
|
|
||||||
@ -367,8 +351,6 @@ private:
|
|||||||
|
|
||||||
class _3DScene
|
class _3DScene
|
||||||
{
|
{
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
struct GCodePreviewData
|
struct GCodePreviewData
|
||||||
{
|
{
|
||||||
enum EType
|
enum EType
|
||||||
@ -427,19 +409,13 @@ class _3DScene
|
|||||||
};
|
};
|
||||||
|
|
||||||
static LegendTexture s_legend_texture;
|
static LegendTexture s_legend_texture;
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
public:
|
public:
|
||||||
static void _glew_init();
|
static void _glew_init();
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
static void load_gcode_preview(const Print* print, GLVolumeCollection* volumes, bool use_VBOs);
|
static void load_gcode_preview(const Print* print, GLVolumeCollection* volumes, bool use_VBOs);
|
||||||
static unsigned int get_legend_texture_id();
|
static unsigned int get_legend_texture_id();
|
||||||
static unsigned int get_legend_texture_width();
|
static unsigned int get_legend_texture_width();
|
||||||
static unsigned int get_legend_texture_height();
|
static unsigned int get_legend_texture_height();
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
|
|
||||||
static void _load_print_toolpaths(
|
static void _load_print_toolpaths(
|
||||||
const Print *print,
|
const Print *print,
|
||||||
@ -453,15 +429,12 @@ public:
|
|||||||
const std::vector<std::string> &tool_colors,
|
const std::vector<std::string> &tool_colors,
|
||||||
bool use_VBOs);
|
bool use_VBOs);
|
||||||
|
|
||||||
|
|
||||||
static void _load_wipe_tower_toolpaths(
|
static void _load_wipe_tower_toolpaths(
|
||||||
const Print *print,
|
const Print *print,
|
||||||
GLVolumeCollection *volumes,
|
GLVolumeCollection *volumes,
|
||||||
const std::vector<std::string> &tool_colors_str,
|
const std::vector<std::string> &tool_colors_str,
|
||||||
bool use_VBOs);
|
bool use_VBOs);
|
||||||
|
|
||||||
//############################################################################################################
|
|
||||||
#if ENRICO_GCODE_PREVIEW
|
|
||||||
private:
|
private:
|
||||||
// generates gcode extrusion paths geometry
|
// generates gcode extrusion paths geometry
|
||||||
static void _load_gcode_extrusion_paths(const Print& print, GLVolumeCollection& volumes, bool use_VBOs);
|
static void _load_gcode_extrusion_paths(const Print& print, GLVolumeCollection& volumes, bool use_VBOs);
|
||||||
@ -475,8 +448,6 @@ private:
|
|||||||
static void _update_gcode_volumes_visibility(const Print& print, GLVolumeCollection& volumes);
|
static void _update_gcode_volumes_visibility(const Print& print, GLVolumeCollection& volumes);
|
||||||
// generates the legend texture in dependence of the current shown view type
|
// generates the legend texture in dependence of the current shown view type
|
||||||
static void _generate_legend_texture(const Print& print);
|
static void _generate_legend_texture(const Print& print);
|
||||||
#endif // ENRICO_GCODE_PREVIEW
|
|
||||||
//############################################################################################################
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -165,14 +165,12 @@ _constant()
|
|||||||
size_t object_count()
|
size_t object_count()
|
||||||
%code%{ RETVAL = THIS->objects.size(); %};
|
%code%{ RETVAL = THIS->objects.size(); %};
|
||||||
|
|
||||||
// ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
void clear_gcode_preview_data();
|
void clear_gcode_preview_data();
|
||||||
void set_gcode_preview_type(unsigned char type);
|
void set_gcode_preview_type(unsigned char type);
|
||||||
void set_gcode_preview_extrusion_flags(unsigned int flags);
|
void set_gcode_preview_extrusion_flags(unsigned int flags);
|
||||||
void set_gcode_preview_travel_visible(bool visible);
|
void set_gcode_preview_travel_visible(bool visible);
|
||||||
void set_gcode_preview_retractions_visible(bool visible);
|
void set_gcode_preview_retractions_visible(bool visible);
|
||||||
void set_gcode_preview_unretractions_visible(bool visible);
|
void set_gcode_preview_unretractions_visible(bool visible);
|
||||||
// ===================== ENRICO_GCODE_PREVIEW ==================================================
|
|
||||||
|
|
||||||
PrintRegionPtrs* regions()
|
PrintRegionPtrs* regions()
|
||||||
%code%{ RETVAL = &THIS->regions; %};
|
%code%{ RETVAL = &THIS->regions; %};
|
||||||
|
Loading…
Reference in New Issue
Block a user