Removed the GCodePreviewData from the Print class, it does not belong here,
as the GCode is generated outside of the Print class. Exported the GCodePreviewData as GCode::PreviewData to Perl. When exporting the G-code with a command line Slic3r, the GCodeAnalyzer is now supressed for performance reasons. Removed obsolete Perl module Slic3r::GUI::Plater::3DToolpaths.
This commit is contained in:
parent
3a6436f6f0
commit
b1f5e7e8fa
20 changed files with 166 additions and 401 deletions
|
@ -136,6 +136,7 @@ sub thread_cleanup {
|
||||||
*Slic3r::Flow::DESTROY = sub {};
|
*Slic3r::Flow::DESTROY = sub {};
|
||||||
*Slic3r::GCode::DESTROY = sub {};
|
*Slic3r::GCode::DESTROY = sub {};
|
||||||
*Slic3r::GCode::PlaceholderParser::DESTROY = sub {};
|
*Slic3r::GCode::PlaceholderParser::DESTROY = sub {};
|
||||||
|
*Slic3r::GCode::PreviewData::DESTROY = sub {};
|
||||||
*Slic3r::GCode::Sender::DESTROY = sub {};
|
*Slic3r::GCode::Sender::DESTROY = sub {};
|
||||||
*Slic3r::Geometry::BoundingBox::DESTROY = sub {};
|
*Slic3r::Geometry::BoundingBox::DESTROY = sub {};
|
||||||
*Slic3r::Geometry::BoundingBoxf::DESTROY = sub {};
|
*Slic3r::Geometry::BoundingBoxf::DESTROY = sub {};
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# Slic3r::GUI::3DScene;
|
# Slic3r::GUI::3DScene;
|
||||||
#
|
#
|
||||||
# Slic3r::GUI::Plater::3D derives from Slic3r::GUI::3DScene,
|
# Slic3r::GUI::Plater::3D derives from Slic3r::GUI::3DScene,
|
||||||
# Slic3r::GUI::Plater::3DPreview, Slic3r::GUI::Plater::3DToolpaths,
|
# Slic3r::GUI::Plater::3DPreview,
|
||||||
# Slic3r::GUI::Plater::ObjectCutDialog and Slic3r::GUI::Plater::ObjectPartsPanel
|
# Slic3r::GUI::Plater::ObjectCutDialog and Slic3r::GUI::Plater::ObjectPartsPanel
|
||||||
# own $self->{canvas} of the Slic3r::GUI::3DScene type.
|
# own $self->{canvas} of the Slic3r::GUI::3DScene type.
|
||||||
#
|
#
|
||||||
|
@ -2029,10 +2029,10 @@ sub load_wipe_tower_toolpaths {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub load_gcode_preview {
|
sub load_gcode_preview {
|
||||||
my ($self, $print, $colors) = @_;
|
my ($self, $print, $gcode_preview_data, $colors) = @_;
|
||||||
|
|
||||||
$self->SetCurrent($self->GetContext) if $self->UseVBOs;
|
$self->SetCurrent($self->GetContext) if $self->UseVBOs;
|
||||||
Slic3r::GUI::_3DScene::load_gcode_preview($print, $self->volumes, $colors, $self->UseVBOs);
|
Slic3r::GUI::_3DScene::load_gcode_preview($print, $gcode_preview_data, $self->volumes, $colors, $self->UseVBOs);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_toolpaths_range {
|
sub set_toolpaths_range {
|
||||||
|
|
|
@ -60,6 +60,7 @@ sub new {
|
||||||
$self->{print} = Slic3r::Print->new;
|
$self->{print} = Slic3r::Print->new;
|
||||||
# List of Perl objects Slic3r::GUI::Plater::Object, representing a 2D preview of the platter.
|
# List of Perl objects Slic3r::GUI::Plater::Object, representing a 2D preview of the platter.
|
||||||
$self->{objects} = [];
|
$self->{objects} = [];
|
||||||
|
$self->{gcode_preview_data} = Slic3r::GCode::PreviewData->new;
|
||||||
|
|
||||||
$self->{print}->set_status_cb(sub {
|
$self->{print}->set_status_cb(sub {
|
||||||
my ($percent, $message) = @_;
|
my ($percent, $message) = @_;
|
||||||
|
@ -140,7 +141,7 @@ sub new {
|
||||||
|
|
||||||
# Initialize 3D toolpaths preview
|
# Initialize 3D toolpaths preview
|
||||||
if ($Slic3r::GUI::have_OpenGL) {
|
if ($Slic3r::GUI::have_OpenGL) {
|
||||||
$self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}, $self->{config});
|
$self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}, $self->{gcode_preview_data}, $self->{config});
|
||||||
$self->{preview3D}->canvas->on_viewport_changed(sub {
|
$self->{preview3D}->canvas->on_viewport_changed(sub {
|
||||||
$self->{canvas3D}->set_viewport_from_scene($self->{preview3D}->canvas);
|
$self->{canvas3D}->set_viewport_from_scene($self->{preview3D}->canvas);
|
||||||
});
|
});
|
||||||
|
@ -785,7 +786,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);
|
||||||
$self->{print}->clear_gcode_preview_data;
|
$self->{gcode_preview_data}->reset;
|
||||||
$self->{list}->DeleteItem($obj_idx);
|
$self->{list}->DeleteItem($obj_idx);
|
||||||
$self->object_list_changed;
|
$self->object_list_changed;
|
||||||
|
|
||||||
|
@ -806,7 +807,7 @@ sub reset {
|
||||||
@{$self->{objects}} = ();
|
@{$self->{objects}} = ();
|
||||||
$self->{model}->clear_objects;
|
$self->{model}->clear_objects;
|
||||||
$self->{print}->clear_objects;
|
$self->{print}->clear_objects;
|
||||||
$self->{print}->clear_gcode_preview_data;
|
$self->{gcode_preview_data}->reset;
|
||||||
$self->{list}->DeleteAllItems;
|
$self->{list}->DeleteAllItems;
|
||||||
$self->object_list_changed;
|
$self->object_list_changed;
|
||||||
|
|
||||||
|
@ -1267,7 +1268,7 @@ sub reslice {
|
||||||
# Rather perform one additional unnecessary update of the print object instead of skipping a pending async update.
|
# Rather perform one additional unnecessary update of the print object instead of skipping a pending async update.
|
||||||
$self->async_apply_config;
|
$self->async_apply_config;
|
||||||
# Reset gcode data
|
# Reset gcode data
|
||||||
$self->{print}->clear_gcode_preview_data;
|
$self->{gcode_preview_data}->reset;
|
||||||
$self->statusbar->SetCancelCallback(sub {
|
$self->statusbar->SetCancelCallback(sub {
|
||||||
$self->stop_background_process;
|
$self->stop_background_process;
|
||||||
$self->statusbar->SetStatusText("Slicing cancelled");
|
$self->statusbar->SetStatusText("Slicing cancelled");
|
||||||
|
@ -1381,7 +1382,7 @@ sub on_process_completed {
|
||||||
|
|
||||||
$self->{export_thread} = Slic3r::spawn_thread(sub {
|
$self->{export_thread} = Slic3r::spawn_thread(sub {
|
||||||
eval {
|
eval {
|
||||||
$_thread_self->{print}->export_gcode(output_file => $_thread_self->{export_gcode_output_file});
|
$_thread_self->{print}->export_gcode(output_file => $_thread_self->{export_gcode_output_file}, gcode_preview_data => $_thread_self->{gcode_preview_data});
|
||||||
};
|
};
|
||||||
my $export_completed_event = Wx::CommandEvent->new($EXPORT_COMPLETED_EVENT);
|
my $export_completed_event = Wx::CommandEvent->new($EXPORT_COMPLETED_EVENT);
|
||||||
if ($@) {
|
if ($@) {
|
||||||
|
|
|
@ -8,11 +8,11 @@ use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE wxCB_READONLY);
|
||||||
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 base qw(Wx::Panel Class::Accessor);
|
use base qw(Wx::Panel Class::Accessor);
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(qw(print enabled _loaded canvas slider_low slider_high single_layer auto_zoom));
|
__PACKAGE__->mk_accessors(qw(print gcode_preview_data enabled _loaded canvas slider_low slider_high single_layer auto_zoom));
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my ($parent, $print, $config) = @_;
|
my ($parent, $print, $gcode_preview_data, $config) = @_;
|
||||||
|
|
||||||
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition);
|
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition);
|
||||||
$self->{config} = $config;
|
$self->{config} = $config;
|
||||||
|
@ -192,7 +192,7 @@ sub new {
|
||||||
});
|
});
|
||||||
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->gcode_preview_data->set_type($selection);
|
||||||
$self->auto_zoom(0);
|
$self->auto_zoom(0);
|
||||||
$self->reload_print;
|
$self->reload_print;
|
||||||
$self->auto_zoom(1);
|
$self->auto_zoom(1);
|
||||||
|
@ -200,31 +200,31 @@ sub new {
|
||||||
EVT_CHECKLISTBOX($self, $combochecklist_features, sub {
|
EVT_CHECKLISTBOX($self, $combochecklist_features, sub {
|
||||||
my $flags = Slic3r::GUI::combochecklist_get_flags($combochecklist_features);
|
my $flags = Slic3r::GUI::combochecklist_get_flags($combochecklist_features);
|
||||||
|
|
||||||
$self->print->set_gcode_preview_extrusion_flags($flags);
|
$self->gcode_preview_data->set_extrusion_flags($flags);
|
||||||
$self->auto_zoom(0);
|
$self->auto_zoom(0);
|
||||||
$self->refresh_print;
|
$self->refresh_print;
|
||||||
$self->auto_zoom(1);
|
$self->auto_zoom(1);
|
||||||
});
|
});
|
||||||
EVT_CHECKBOX($self, $checkbox_travel, sub {
|
EVT_CHECKBOX($self, $checkbox_travel, sub {
|
||||||
$self->print->set_gcode_preview_travel_visible($checkbox_travel->IsChecked());
|
$self->gcode_preview_data->set_travel_visible($checkbox_travel->IsChecked());
|
||||||
$self->auto_zoom(0);
|
$self->auto_zoom(0);
|
||||||
$self->refresh_print;
|
$self->refresh_print;
|
||||||
$self->auto_zoom(1);
|
$self->auto_zoom(1);
|
||||||
});
|
});
|
||||||
EVT_CHECKBOX($self, $checkbox_retractions, sub {
|
EVT_CHECKBOX($self, $checkbox_retractions, sub {
|
||||||
$self->print->set_gcode_preview_retractions_visible($checkbox_retractions->IsChecked());
|
$self->gcode_preview_data->set_retractions_visible($checkbox_retractions->IsChecked());
|
||||||
$self->auto_zoom(0);
|
$self->auto_zoom(0);
|
||||||
$self->refresh_print;
|
$self->refresh_print;
|
||||||
$self->auto_zoom(1);
|
$self->auto_zoom(1);
|
||||||
});
|
});
|
||||||
EVT_CHECKBOX($self, $checkbox_unretractions, sub {
|
EVT_CHECKBOX($self, $checkbox_unretractions, sub {
|
||||||
$self->print->set_gcode_preview_unretractions_visible($checkbox_unretractions->IsChecked());
|
$self->gcode_preview_data->set_unretractions_visible($checkbox_unretractions->IsChecked());
|
||||||
$self->auto_zoom(0);
|
$self->auto_zoom(0);
|
||||||
$self->refresh_print;
|
$self->refresh_print;
|
||||||
$self->auto_zoom(1);
|
$self->auto_zoom(1);
|
||||||
});
|
});
|
||||||
EVT_CHECKBOX($self, $checkbox_shells, sub {
|
EVT_CHECKBOX($self, $checkbox_shells, sub {
|
||||||
$self->print->set_gcode_preview_shells_visible($checkbox_shells->IsChecked());
|
$self->gcode_preview_data->set_shells_visible($checkbox_shells->IsChecked());
|
||||||
$self->auto_zoom(0);
|
$self->auto_zoom(0);
|
||||||
$self->refresh_print;
|
$self->refresh_print;
|
||||||
$self->auto_zoom(1);
|
$self->auto_zoom(1);
|
||||||
|
@ -236,6 +236,7 @@ sub new {
|
||||||
|
|
||||||
# init canvas
|
# init canvas
|
||||||
$self->print($print);
|
$self->print($print);
|
||||||
|
$self->gcode_preview_data($gcode_preview_data);
|
||||||
|
|
||||||
# sets colors for gcode preview extrusion roles
|
# sets colors for gcode preview extrusion roles
|
||||||
my @extrusion_roles_colors = (
|
my @extrusion_roles_colors = (
|
||||||
|
@ -252,7 +253,7 @@ sub new {
|
||||||
'Support material interface' => '00007F',
|
'Support material interface' => '00007F',
|
||||||
'Wipe tower' => 'B3E3AB',
|
'Wipe tower' => 'B3E3AB',
|
||||||
);
|
);
|
||||||
$self->print->set_gcode_extrusion_paths_colors(\@extrusion_roles_colors);
|
$self->gcode_preview_data->set_extrusion_paths_colors(\@extrusion_roles_colors);
|
||||||
|
|
||||||
$self->reload_print;
|
$self->reload_print;
|
||||||
|
|
||||||
|
@ -354,7 +355,7 @@ sub load_print {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($self->IsShown) {
|
if ($self->IsShown) {
|
||||||
$self->canvas->load_gcode_preview($self->print, \@colors);
|
$self->canvas->load_gcode_preview($self->print, $self->gcode_preview_data, \@colors);
|
||||||
|
|
||||||
# # load skirt and brim
|
# # load skirt and brim
|
||||||
# $self->canvas->load_print_toolpaths($self->print, \@colors);
|
# $self->canvas->load_print_toolpaths($self->print, \@colors);
|
||||||
|
|
|
@ -1,159 +0,0 @@
|
||||||
package Slic3r::GUI::Plater::3DToolpaths;
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use utf8;
|
|
||||||
|
|
||||||
use Slic3r::Print::State ':steps';
|
|
||||||
use Wx qw(:misc :sizer :slider :statictext wxWHITE);
|
|
||||||
use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN);
|
|
||||||
use base qw(Wx::Panel Class::Accessor);
|
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(qw(print enabled _loaded canvas slider));
|
|
||||||
|
|
||||||
sub new {
|
|
||||||
my $class = shift;
|
|
||||||
my ($parent, $print) = @_;
|
|
||||||
|
|
||||||
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition);
|
|
||||||
|
|
||||||
# init GUI elements
|
|
||||||
my $canvas = Slic3r::GUI::3DScene->new($self);
|
|
||||||
$self->canvas($canvas);
|
|
||||||
my $slider = Wx::Slider->new(
|
|
||||||
$self, -1,
|
|
||||||
0, # default
|
|
||||||
0, # min
|
|
||||||
# we set max to a bogus non-zero value because the MSW implementation of wxSlider
|
|
||||||
# will skip drawing the slider if max <= min:
|
|
||||||
1, # max
|
|
||||||
wxDefaultPosition,
|
|
||||||
wxDefaultSize,
|
|
||||||
wxVERTICAL | wxSL_INVERSE,
|
|
||||||
);
|
|
||||||
$self->slider($slider);
|
|
||||||
|
|
||||||
my $z_label = $self->{z_label} = Wx::StaticText->new($self, -1, "", wxDefaultPosition,
|
|
||||||
[40,-1], wxALIGN_CENTRE_HORIZONTAL);
|
|
||||||
$z_label->SetFont($Slic3r::GUI::small_font);
|
|
||||||
|
|
||||||
my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
|
|
||||||
$vsizer->Add($slider, 1, wxALL | wxEXPAND | wxALIGN_CENTER, 3);
|
|
||||||
$vsizer->Add($z_label, 0, wxALL | wxEXPAND | wxALIGN_CENTER, 3);
|
|
||||||
|
|
||||||
my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
|
||||||
$sizer->Add($canvas, 1, wxALL | wxEXPAND, 0);
|
|
||||||
$sizer->Add($vsizer, 0, wxTOP | wxBOTTOM | wxEXPAND, 5);
|
|
||||||
|
|
||||||
EVT_SLIDER($self, $slider, sub {
|
|
||||||
$self->set_z($self->{layers_z}[$slider->GetValue])
|
|
||||||
if $self->enabled;
|
|
||||||
});
|
|
||||||
EVT_KEY_DOWN($canvas, sub {
|
|
||||||
my ($s, $event) = @_;
|
|
||||||
if ($event->HasModifiers) {
|
|
||||||
$event->Skip;
|
|
||||||
} else {
|
|
||||||
my $key = $event->GetKeyCode;
|
|
||||||
if ($key == 85 || $key == 315) {
|
|
||||||
$slider->SetValue($slider->GetValue + 1);
|
|
||||||
$self->set_z($self->{layers_z}[$slider->GetValue]);
|
|
||||||
} elsif ($key == 68 || $key == 317) {
|
|
||||||
$slider->SetValue($slider->GetValue - 1);
|
|
||||||
$self->set_z($self->{layers_z}[$slider->GetValue]);
|
|
||||||
} else {
|
|
||||||
$event->Skip;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$self->SetSizer($sizer);
|
|
||||||
$self->SetMinSize($self->GetSize);
|
|
||||||
$sizer->SetSizeHints($self);
|
|
||||||
|
|
||||||
# init canvas
|
|
||||||
$self->print($print);
|
|
||||||
$self->reload_print;
|
|
||||||
|
|
||||||
return $self;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub reload_print {
|
|
||||||
my ($self) = @_;
|
|
||||||
|
|
||||||
$self->canvas->reset_objects;
|
|
||||||
$self->_loaded(0);
|
|
||||||
$self->load_print;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub load_print {
|
|
||||||
my ($self) = @_;
|
|
||||||
|
|
||||||
return if $self->_loaded;
|
|
||||||
|
|
||||||
# we require that there's at least one object and the posSlice step
|
|
||||||
# is performed on all of them (this ensures that _shifted_copies was
|
|
||||||
# populated and we know the number of layers)
|
|
||||||
if (!$self->print->object_step_done(STEP_SLICE)) {
|
|
||||||
$self->enabled(0);
|
|
||||||
$self->slider->Hide;
|
|
||||||
$self->canvas->Refresh; # clears canvas
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $z_idx;
|
|
||||||
{
|
|
||||||
my %z = (); # z => 1
|
|
||||||
foreach my $object (@{$self->{print}->objects}) {
|
|
||||||
foreach my $layer (@{$object->layers}, @{$object->support_layers}) {
|
|
||||||
$z{$layer->print_z} = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$self->enabled(1);
|
|
||||||
$self->{layers_z} = [ sort { $a <=> $b } keys %z ];
|
|
||||||
$self->slider->SetRange(0, scalar(@{$self->{layers_z}})-1);
|
|
||||||
if (($z_idx = $self->slider->GetValue) <= $#{$self->{layers_z}} && $self->slider->GetValue != 0) {
|
|
||||||
# use $z_idx
|
|
||||||
} else {
|
|
||||||
$self->slider->SetValue(scalar(@{$self->{layers_z}})-1);
|
|
||||||
$z_idx = @{$self->{layers_z}} ? -1 : undef;
|
|
||||||
}
|
|
||||||
$self->slider->Show;
|
|
||||||
$self->Layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($self->IsShown) {
|
|
||||||
$self->canvas->load_gcode_preview($self->print);
|
|
||||||
|
|
||||||
# # load skirt and brim
|
|
||||||
# $self->canvas->load_print_toolpaths($self->print);
|
|
||||||
#
|
|
||||||
# foreach my $object (@{$self->print->objects}) {
|
|
||||||
# $self->canvas->load_print_object_toolpaths($object);
|
|
||||||
#
|
|
||||||
# # Show the objects in very transparent color.
|
|
||||||
# #my @volume_ids = $self->canvas->load_object($object->model_object);
|
|
||||||
# #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids;
|
|
||||||
# }
|
|
||||||
|
|
||||||
$self->canvas->zoom_to_volumes;
|
|
||||||
$self->_loaded(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->set_z($self->{layers_z}[$z_idx]);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub set_z {
|
|
||||||
my ($self, $z) = @_;
|
|
||||||
|
|
||||||
return if !$self->enabled;
|
|
||||||
$self->{z_label}->SetLabel(sprintf '%.2f', $z);
|
|
||||||
$self->canvas->set_toolpaths_range(0, $z);
|
|
||||||
$self->canvas->Refresh if $self->IsShown;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub set_bed_shape {
|
|
||||||
my ($self, $bed_shape) = @_;
|
|
||||||
$self->canvas->set_bed_shape($bed_shape);
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
|
|
@ -81,7 +81,7 @@ sub export_gcode {
|
||||||
$self->status_cb->(90, "Exporting G-code" . ($output_file ? " to $output_file" : ""));
|
$self->status_cb->(90, "Exporting G-code" . ($output_file ? " to $output_file" : ""));
|
||||||
|
|
||||||
# The following line may die for multiple reasons.
|
# The following line may die for multiple reasons.
|
||||||
Slic3r::GCode->new->do_export($self, $output_file);
|
Slic3r::GCode->new->do_export($self, $output_file, $params{gcode_preview_data});
|
||||||
|
|
||||||
# run post-processing scripts
|
# run post-processing scripts
|
||||||
if (@{$self->config->post_process}) {
|
if (@{$self->config->post_process}) {
|
||||||
|
|
|
@ -348,7 +348,7 @@ std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collec
|
||||||
return layers_to_print;
|
return layers_to_print;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCode::do_export(Print *print, const char *path)
|
void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_data)
|
||||||
{
|
{
|
||||||
PROFILE_CLEAR();
|
PROFILE_CLEAR();
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ void GCode::do_export(Print *print, const char *path)
|
||||||
throw std::runtime_error(std::string("G-code export to ") + path + " failed.\nCannot open the file for writing.\n");
|
throw std::runtime_error(std::string("G-code export to ") + path + " failed.\nCannot open the file for writing.\n");
|
||||||
|
|
||||||
this->m_placeholder_parser_failed_templates.clear();
|
this->m_placeholder_parser_failed_templates.clear();
|
||||||
this->_do_export(*print, file);
|
this->_do_export(*print, file, preview_data);
|
||||||
fflush(file);
|
fflush(file);
|
||||||
if (ferror(file)) {
|
if (ferror(file)) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
@ -394,7 +394,7 @@ void GCode::do_export(Print *print, const char *path)
|
||||||
PROFILE_OUTPUT(debug_out_path("gcode-export-profile.txt").c_str());
|
PROFILE_OUTPUT(debug_out_path("gcode-export-profile.txt").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCode::_do_export(Print &print, FILE *file)
|
void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data)
|
||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
PROFILE_FUNC();
|
||||||
|
|
||||||
|
@ -404,6 +404,7 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||||
|
|
||||||
// resets analyzer
|
// resets analyzer
|
||||||
m_analyzer.reset();
|
m_analyzer.reset();
|
||||||
|
m_enable_analyzer = preview_data != nullptr;
|
||||||
|
|
||||||
// resets analyzer's tracking data
|
// resets analyzer's tracking data
|
||||||
m_last_mm3_per_mm = GCodeAnalyzer::Default_mm3_per_mm;
|
m_last_mm3_per_mm = GCodeAnalyzer::Default_mm3_per_mm;
|
||||||
|
@ -820,7 +821,8 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// starts analizer calculations
|
// starts analizer calculations
|
||||||
m_analyzer.calc_gcode_preview_data(print);
|
if (preview_data != nullptr)
|
||||||
|
m_analyzer.calc_gcode_preview_data(*preview_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace Slic3r {
|
||||||
|
|
||||||
// Forward declarations.
|
// Forward declarations.
|
||||||
class GCode;
|
class GCode;
|
||||||
|
class GCodePreviewData;
|
||||||
|
|
||||||
class AvoidCrossingPerimeters {
|
class AvoidCrossingPerimeters {
|
||||||
public:
|
public:
|
||||||
|
@ -119,7 +120,7 @@ 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),
|
||||||
m_enable_analyzer(true),
|
m_enable_analyzer(false),
|
||||||
m_layer_count(0),
|
m_layer_count(0),
|
||||||
m_layer_index(-1),
|
m_layer_index(-1),
|
||||||
m_layer(nullptr),
|
m_layer(nullptr),
|
||||||
|
@ -136,7 +137,7 @@ public:
|
||||||
~GCode() {}
|
~GCode() {}
|
||||||
|
|
||||||
// throws std::runtime_exception
|
// throws std::runtime_exception
|
||||||
void do_export(Print *print, const char *path);
|
void do_export(Print *print, const char *path, GCodePreviewData *preview_data = nullptr);
|
||||||
|
|
||||||
// Exported for the helper classes (OozePrevention, Wipe) and for the Perl binding for unit tests.
|
// Exported for the helper classes (OozePrevention, Wipe) and for the Perl binding for unit tests.
|
||||||
const Pointf& origin() const { return m_origin; }
|
const Pointf& origin() const { return m_origin; }
|
||||||
|
@ -153,8 +154,6 @@ 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; }
|
||||||
bool enable_analyzer() const { return m_enable_analyzer; }
|
|
||||||
void enable_analyzer(bool enable) { m_enable_analyzer = enable; }
|
|
||||||
|
|
||||||
// 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; }
|
||||||
|
@ -162,7 +161,7 @@ public:
|
||||||
void apply_print_config(const PrintConfig &print_config);
|
void apply_print_config(const PrintConfig &print_config);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _do_export(Print &print, FILE *file);
|
void _do_export(Print &print, FILE *file, GCodePreviewData *preview_data);
|
||||||
|
|
||||||
// Object and support extrusions of the same PrintObject at the same print_z.
|
// Object and support extrusions of the same PrintObject at the same print_z.
|
||||||
struct LayerToPrint
|
struct LayerToPrint
|
||||||
|
|
|
@ -123,22 +123,22 @@ const std::string& GCodeAnalyzer::process_gcode(const std::string& gcode)
|
||||||
return m_process_output;
|
return m_process_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeAnalyzer::calc_gcode_preview_data(Print& print)
|
void GCodeAnalyzer::calc_gcode_preview_data(GCodePreviewData& preview_data)
|
||||||
{
|
{
|
||||||
// resets preview data
|
// resets preview data
|
||||||
print.gcode_preview.reset();
|
preview_data.reset();
|
||||||
|
|
||||||
// calculates extrusion layers
|
// calculates extrusion layers
|
||||||
_calc_gcode_preview_extrusion_layers(print);
|
_calc_gcode_preview_extrusion_layers(preview_data);
|
||||||
|
|
||||||
// calculates travel
|
// calculates travel
|
||||||
_calc_gcode_preview_travel(print);
|
_calc_gcode_preview_travel(preview_data);
|
||||||
|
|
||||||
// calculates retractions
|
// calculates retractions
|
||||||
_calc_gcode_preview_retractions(print);
|
_calc_gcode_preview_retractions(preview_data);
|
||||||
|
|
||||||
// calculates unretractions
|
// calculates unretractions
|
||||||
_calc_gcode_preview_unretractions(print);
|
_calc_gcode_preview_unretractions(preview_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GCodeAnalyzer::is_valid_extrusion_role(ExtrusionRole role)
|
bool GCodeAnalyzer::is_valid_extrusion_role(ExtrusionRole role)
|
||||||
|
@ -601,7 +601,7 @@ bool GCodeAnalyzer::_is_valid_extrusion_role(int value) const
|
||||||
return ((int)erNone <= value) && (value <= (int)erMixed);
|
return ((int)erNone <= value) && (value <= (int)erMixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(Print& print)
|
void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& preview_data)
|
||||||
{
|
{
|
||||||
struct Helper
|
struct Helper
|
||||||
{
|
{
|
||||||
|
@ -619,7 +619,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(Print& print)
|
||||||
return layers.back();
|
return layers.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void store_polyline(const Polyline& polyline, const Metadata& data, float z, Print& print)
|
static void store_polyline(const Polyline& polyline, const Metadata& data, float z, GCodePreviewData& preview_data)
|
||||||
{
|
{
|
||||||
// if the polyline is valid, create the extrusion path from it and store it
|
// if the polyline is valid, create the extrusion path from it and store it
|
||||||
if (polyline.is_valid())
|
if (polyline.is_valid())
|
||||||
|
@ -629,7 +629,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(Print& print)
|
||||||
path.feedrate = data.feedrate;
|
path.feedrate = data.feedrate;
|
||||||
path.extruder_id = data.extruder_id;
|
path.extruder_id = data.extruder_id;
|
||||||
|
|
||||||
get_layer_at_z(print.gcode_preview.extrusion.layers, z).paths.push_back(path);
|
get_layer_at_z(preview_data.extrusion.layers, z).paths.push_back(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -653,7 +653,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(Print& print)
|
||||||
{
|
{
|
||||||
// store current polyline
|
// store current polyline
|
||||||
polyline.remove_duplicate_points();
|
polyline.remove_duplicate_points();
|
||||||
Helper::store_polyline(polyline, data, z, print);
|
Helper::store_polyline(polyline, data, z, preview_data);
|
||||||
|
|
||||||
// reset current polyline
|
// reset current polyline
|
||||||
polyline = Polyline();
|
polyline = Polyline();
|
||||||
|
@ -679,23 +679,24 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(Print& print)
|
||||||
|
|
||||||
// store last polyline
|
// store last polyline
|
||||||
polyline.remove_duplicate_points();
|
polyline.remove_duplicate_points();
|
||||||
Helper::store_polyline(polyline, data, z, print);
|
Helper::store_polyline(polyline, data, z, preview_data);
|
||||||
|
|
||||||
// updates preview ranges data
|
// updates preview ranges data
|
||||||
print.gcode_preview.extrusion.ranges.height.set_from(height_range);
|
preview_data.extrusion.ranges.height.set_from(height_range);
|
||||||
print.gcode_preview.extrusion.ranges.width.set_from(width_range);
|
preview_data.extrusion.ranges.width.set_from(width_range);
|
||||||
print.gcode_preview.extrusion.ranges.feedrate.set_from(feedrate_range);
|
preview_data.extrusion.ranges.feedrate.set_from(feedrate_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeAnalyzer::_calc_gcode_preview_travel(Print& print)
|
void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data)
|
||||||
{
|
{
|
||||||
struct Helper
|
struct Helper
|
||||||
{
|
{
|
||||||
static void store_polyline(const Polyline3& polyline, GCodePreviewData::Travel::EType type, GCodePreviewData::Travel::Polyline::EDirection direction, float feedrate, unsigned int extruder_id, Print& print)
|
static void store_polyline(const Polyline3& polyline, GCodePreviewData::Travel::EType type, GCodePreviewData::Travel::Polyline::EDirection direction,
|
||||||
|
float feedrate, unsigned int extruder_id, GCodePreviewData& preview_data)
|
||||||
{
|
{
|
||||||
// if the polyline is valid, store it
|
// if the polyline is valid, store it
|
||||||
if (polyline.is_valid())
|
if (polyline.is_valid())
|
||||||
print.gcode_preview.travel.polylines.emplace_back(type, direction, feedrate, extruder_id, polyline);
|
preview_data.travel.polylines.emplace_back(type, direction, feedrate, extruder_id, polyline);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -720,7 +721,7 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(Print& print)
|
||||||
{
|
{
|
||||||
// store current polyline
|
// store current polyline
|
||||||
polyline.remove_duplicate_points();
|
polyline.remove_duplicate_points();
|
||||||
Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, print);
|
Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, preview_data);
|
||||||
|
|
||||||
// reset current polyline
|
// reset current polyline
|
||||||
polyline = Polyline3();
|
polyline = Polyline3();
|
||||||
|
@ -742,10 +743,10 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(Print& print)
|
||||||
|
|
||||||
// store last polyline
|
// store last polyline
|
||||||
polyline.remove_duplicate_points();
|
polyline.remove_duplicate_points();
|
||||||
Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, print);
|
Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, preview_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeAnalyzer::_calc_gcode_preview_retractions(Print& print)
|
void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_data)
|
||||||
{
|
{
|
||||||
TypeToMovesMap::iterator retraction_moves = m_moves_map.find(GCodeMove::Retract);
|
TypeToMovesMap::iterator retraction_moves = m_moves_map.find(GCodeMove::Retract);
|
||||||
if (retraction_moves == m_moves_map.end())
|
if (retraction_moves == m_moves_map.end())
|
||||||
|
@ -755,11 +756,11 @@ void GCodeAnalyzer::_calc_gcode_preview_retractions(Print& print)
|
||||||
{
|
{
|
||||||
// store position
|
// store position
|
||||||
Point3 position(scale_(move.start_position.x), scale_(move.start_position.y), scale_(move.start_position.z));
|
Point3 position(scale_(move.start_position.x), scale_(move.start_position.y), scale_(move.start_position.z));
|
||||||
print.gcode_preview.retraction.positions.emplace_back(position, move.data.width, move.data.height);
|
preview_data.retraction.positions.emplace_back(position, move.data.width, move.data.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeAnalyzer::_calc_gcode_preview_unretractions(Print& print)
|
void GCodeAnalyzer::_calc_gcode_preview_unretractions(GCodePreviewData& preview_data)
|
||||||
{
|
{
|
||||||
TypeToMovesMap::iterator unretraction_moves = m_moves_map.find(GCodeMove::Unretract);
|
TypeToMovesMap::iterator unretraction_moves = m_moves_map.find(GCodeMove::Unretract);
|
||||||
if (unretraction_moves == m_moves_map.end())
|
if (unretraction_moves == m_moves_map.end())
|
||||||
|
@ -769,7 +770,7 @@ void GCodeAnalyzer::_calc_gcode_preview_unretractions(Print& print)
|
||||||
{
|
{
|
||||||
// store position
|
// store position
|
||||||
Point3 position(scale_(move.start_position.x), scale_(move.start_position.y), scale_(move.start_position.z));
|
Point3 position(scale_(move.start_position.x), scale_(move.start_position.y), scale_(move.start_position.z));
|
||||||
print.gcode_preview.unretraction.positions.emplace_back(position, move.data.width, move.data.height);
|
preview_data.unretraction.positions.emplace_back(position, move.data.width, move.data.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
class Print;
|
class GCodePreviewData;
|
||||||
|
|
||||||
class GCodeAnalyzer
|
class GCodeAnalyzer
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,7 @@ public:
|
||||||
const std::string& process_gcode(const std::string& gcode);
|
const std::string& process_gcode(const std::string& gcode);
|
||||||
|
|
||||||
// Calculates all data needed for gcode visualization
|
// Calculates all data needed for gcode visualization
|
||||||
void calc_gcode_preview_data(Print& print);
|
void calc_gcode_preview_data(GCodePreviewData& preview_data);
|
||||||
|
|
||||||
static bool is_valid_extrusion_role(ExtrusionRole role);
|
static bool is_valid_extrusion_role(ExtrusionRole role);
|
||||||
|
|
||||||
|
@ -216,10 +216,10 @@ private:
|
||||||
// Checks if the given int is a valid extrusion role (contained into enum ExtrusionRole)
|
// Checks if the given int is a valid extrusion role (contained into enum ExtrusionRole)
|
||||||
bool _is_valid_extrusion_role(int value) const;
|
bool _is_valid_extrusion_role(int value) const;
|
||||||
|
|
||||||
void _calc_gcode_preview_extrusion_layers(Print& print);
|
void _calc_gcode_preview_extrusion_layers(GCodePreviewData& preview_data);
|
||||||
void _calc_gcode_preview_travel(Print& print);
|
void _calc_gcode_preview_travel(GCodePreviewData& preview_data);
|
||||||
void _calc_gcode_preview_retractions(Print& print);
|
void _calc_gcode_preview_retractions(GCodePreviewData& preview_data);
|
||||||
void _calc_gcode_preview_unretractions(Print& print);
|
void _calc_gcode_preview_unretractions(GCodePreviewData& preview_data);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
|
@ -66,89 +66,6 @@ bool Print::reload_model_instances()
|
||||||
return invalidated;
|
return invalidated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Print::clear_gcode_preview_data()
|
|
||||||
{
|
|
||||||
gcode_preview.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Print::set_gcode_preview_type(unsigned char type)
|
|
||||||
{
|
|
||||||
if ((0 <= type) && (type < GCodePreviewData::Extrusion::Num_View_Types))
|
|
||||||
gcode_preview.extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Print::set_gcode_preview_extrusion_flags(unsigned int flags)
|
|
||||||
{
|
|
||||||
gcode_preview.extrusion.role_flags = flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Print::is_gcode_preview_extrusion_role_enabled(ExtrusionRole role)
|
|
||||||
{
|
|
||||||
return gcode_preview.extrusion.is_role_flag_set(role);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Print::set_gcode_preview_travel_visible(bool visible)
|
|
||||||
{
|
|
||||||
gcode_preview.travel.is_visible = visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Print::set_gcode_preview_retractions_visible(bool visible)
|
|
||||||
{
|
|
||||||
gcode_preview.retraction.is_visible = visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Print::set_gcode_preview_unretractions_visible(bool visible)
|
|
||||||
{
|
|
||||||
gcode_preview.unretraction.is_visible = visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Print::set_gcode_preview_shells_visible(bool visible)
|
|
||||||
{
|
|
||||||
gcode_preview.shell.is_visible = visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Print::set_gcode_extrusion_paths_colors(const std::vector<std::string>& colors)
|
|
||||||
{
|
|
||||||
unsigned int size = (unsigned int)colors.size();
|
|
||||||
|
|
||||||
if (size % 2 != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < size; i += 2)
|
|
||||||
{
|
|
||||||
const std::string& color_str = colors[i + 1];
|
|
||||||
|
|
||||||
if (color_str.size() == 6)
|
|
||||||
{
|
|
||||||
bool valid = true;
|
|
||||||
for (int c = 0; c < 6; ++c)
|
|
||||||
{
|
|
||||||
if (::isxdigit(color_str[c]) == 0)
|
|
||||||
{
|
|
||||||
valid = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valid)
|
|
||||||
{
|
|
||||||
unsigned int color;
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << std::hex << color_str;
|
|
||||||
ss >> color;
|
|
||||||
|
|
||||||
float den = 1.0f / 255.0f;
|
|
||||||
|
|
||||||
float r = (float)((color & 0xFF0000) >> 16) * den;
|
|
||||||
float g = (float)((color & 0x00FF00) >> 8) * den;
|
|
||||||
float b = (float)(color & 0x0000FF) * den;
|
|
||||||
|
|
||||||
gcode_preview.set_extrusion_role_color(colors[i], r, g, b, 1.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintRegion* Print::add_region()
|
PrintRegion* Print::add_region()
|
||||||
{
|
{
|
||||||
regions.push_back(new PrintRegion(this));
|
regions.push_back(new PrintRegion(this));
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "Slicing.hpp"
|
#include "Slicing.hpp"
|
||||||
#include "GCode/ToolOrdering.hpp"
|
#include "GCode/ToolOrdering.hpp"
|
||||||
#include "GCode/WipeTower.hpp"
|
#include "GCode/WipeTower.hpp"
|
||||||
#include "GCode/PreviewData.hpp"
|
|
||||||
|
|
||||||
#include "tbb/atomic.h"
|
#include "tbb/atomic.h"
|
||||||
|
|
||||||
|
@ -241,7 +240,6 @@ 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;
|
||||||
GCodePreviewData 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(); }
|
||||||
|
@ -255,27 +253,6 @@ public:
|
||||||
void reload_object(size_t idx);
|
void reload_object(size_t idx);
|
||||||
bool reload_model_instances();
|
bool reload_model_instances();
|
||||||
|
|
||||||
void clear_gcode_preview_data();
|
|
||||||
void set_gcode_preview_type(unsigned char type);
|
|
||||||
void set_gcode_preview_extrusion_flags(unsigned int flags);
|
|
||||||
bool is_gcode_preview_extrusion_role_enabled(ExtrusionRole role);
|
|
||||||
void set_gcode_preview_travel_visible(bool visible);
|
|
||||||
void set_gcode_preview_retractions_visible(bool visible);
|
|
||||||
void set_gcode_preview_unretractions_visible(bool visible);
|
|
||||||
void set_gcode_preview_shells_visible(bool visible);
|
|
||||||
|
|
||||||
// Sets the extrusion path colors from the given strings vector.
|
|
||||||
// Data in the vector should be formatted as follows:
|
|
||||||
// std::vector<std::string> role_colors =
|
|
||||||
// { <role_1>, <color_1>,
|
|
||||||
// <role_2>, <color_2>,
|
|
||||||
// <role_3>, <color_3>,
|
|
||||||
// ...
|
|
||||||
// <role_N>, <color_N> };
|
|
||||||
// where <role_X> should be a string from GCodePreviewData::Extrusion::Default_Extrusion_Role_Names[]
|
|
||||||
// and <color_X> an RGB color in hex format (i.e. red = FF0000)
|
|
||||||
void set_gcode_extrusion_paths_colors(const std::vector<std::string>& colors);
|
|
||||||
|
|
||||||
// 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); }
|
||||||
const PrintRegion* get_region(size_t idx) const { return regions.at(idx); }
|
const PrintRegion* get_region(size_t idx) const { return regions.at(idx); }
|
||||||
|
|
|
@ -15,6 +15,7 @@ REGISTER_CLASS(Filler, "Filler");
|
||||||
REGISTER_CLASS(Flow, "Flow");
|
REGISTER_CLASS(Flow, "Flow");
|
||||||
REGISTER_CLASS(CoolingBuffer, "GCode::CoolingBuffer");
|
REGISTER_CLASS(CoolingBuffer, "GCode::CoolingBuffer");
|
||||||
REGISTER_CLASS(GCode, "GCode");
|
REGISTER_CLASS(GCode, "GCode");
|
||||||
|
REGISTER_CLASS(GCodePreviewData, "GCode::PreviewData");
|
||||||
REGISTER_CLASS(GCodeSender, "GCode::Sender");
|
REGISTER_CLASS(GCodeSender, "GCode::Sender");
|
||||||
REGISTER_CLASS(Layer, "Layer");
|
REGISTER_CLASS(Layer, "Layer");
|
||||||
REGISTER_CLASS(SupportLayer, "Layer::Support");
|
REGISTER_CLASS(SupportLayer, "Layer::Support");
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "../../libslic3r/ExtrusionEntity.hpp"
|
#include "../../libslic3r/ExtrusionEntity.hpp"
|
||||||
#include "../../libslic3r/ExtrusionEntityCollection.hpp"
|
#include "../../libslic3r/ExtrusionEntityCollection.hpp"
|
||||||
#include "../../libslic3r/Geometry.hpp"
|
#include "../../libslic3r/Geometry.hpp"
|
||||||
|
#include "../../libslic3r/GCode/PreviewData.hpp"
|
||||||
#include "../../libslic3r/Print.hpp"
|
#include "../../libslic3r/Print.hpp"
|
||||||
#include "../../libslic3r/Slicing.hpp"
|
#include "../../libslic3r/Slicing.hpp"
|
||||||
#include "GCode/Analyzer.hpp"
|
#include "GCode/Analyzer.hpp"
|
||||||
|
@ -1128,13 +1129,13 @@ _3DScene::LegendTexture::~LegendTexture()
|
||||||
_destroy_texture();
|
_destroy_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _3DScene::LegendTexture::generate_texture(const Print& print, const std::vector<float>& tool_colors)
|
bool _3DScene::LegendTexture::generate_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors)
|
||||||
{
|
{
|
||||||
_destroy_texture();
|
_destroy_texture();
|
||||||
|
|
||||||
// collects items to render
|
// collects items to render
|
||||||
const std::string& title = print.gcode_preview.get_legend_title();
|
const std::string& title = preview_data.get_legend_title();
|
||||||
const GCodePreviewData::LegendItemsList& items = print.gcode_preview.get_legend_items(tool_colors);
|
const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors);
|
||||||
|
|
||||||
unsigned int items_count = (unsigned int)items.size();
|
unsigned int items_count = (unsigned int)items.size();
|
||||||
if (items_count == 0)
|
if (items_count == 0)
|
||||||
|
@ -1240,7 +1241,7 @@ bool _3DScene::LegendTexture::generate_texture(const Print& print, const std::ve
|
||||||
|
|
||||||
memDC.SelectObject(wxNullBitmap);
|
memDC.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
return _create_texture(print, bitmap);
|
return _create_texture(preview_data, bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int _3DScene::LegendTexture::get_texture_id() const
|
unsigned int _3DScene::LegendTexture::get_texture_id() const
|
||||||
|
@ -1263,7 +1264,7 @@ void _3DScene::LegendTexture::reset_texture()
|
||||||
_destroy_texture();
|
_destroy_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _3DScene::LegendTexture::_create_texture(const Print& print, const wxBitmap& bitmap)
|
bool _3DScene::LegendTexture::_create_texture(const GCodePreviewData& preview_data, const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
if ((m_tex_width == 0) || (m_tex_height == 0))
|
if ((m_tex_width == 0) || (m_tex_height == 0))
|
||||||
return false;
|
return false;
|
||||||
|
@ -1341,9 +1342,9 @@ static inline std::vector<float> parse_colors(const std::vector<std::string> &sc
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::load_gcode_preview(const Print* print, GLVolumeCollection* volumes, const std::vector<std::string>& str_tool_colors, bool use_VBOs)
|
void _3DScene::load_gcode_preview(const Print* print, const GCodePreviewData* preview_data, GLVolumeCollection* volumes, const std::vector<std::string>& str_tool_colors, bool use_VBOs)
|
||||||
{
|
{
|
||||||
if ((print == nullptr) || (volumes == nullptr))
|
if ((preview_data == nullptr) || (volumes == nullptr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (volumes->empty())
|
if (volumes->empty())
|
||||||
|
@ -1352,10 +1353,10 @@ void _3DScene::load_gcode_preview(const Print* print, GLVolumeCollection* volume
|
||||||
|
|
||||||
s_gcode_preview_volume_index.reset();
|
s_gcode_preview_volume_index.reset();
|
||||||
|
|
||||||
_load_gcode_extrusion_paths(*print, *volumes, tool_colors, use_VBOs);
|
_load_gcode_extrusion_paths(*preview_data, *volumes, tool_colors, use_VBOs);
|
||||||
_load_gcode_travel_paths(*print, *volumes, tool_colors, use_VBOs);
|
_load_gcode_travel_paths(*preview_data, *volumes, tool_colors, use_VBOs);
|
||||||
_load_gcode_retractions(*print, *volumes, use_VBOs);
|
_load_gcode_retractions(*preview_data, *volumes, use_VBOs);
|
||||||
_load_gcode_unretractions(*print, *volumes, use_VBOs);
|
_load_gcode_unretractions(*preview_data, *volumes, use_VBOs);
|
||||||
|
|
||||||
if (volumes->empty())
|
if (volumes->empty())
|
||||||
{
|
{
|
||||||
|
@ -1364,14 +1365,14 @@ void _3DScene::load_gcode_preview(const Print* print, GLVolumeCollection* volume
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_generate_legend_texture(*print, tool_colors);
|
_generate_legend_texture(*preview_data, tool_colors);
|
||||||
|
|
||||||
_load_shells(*print, *volumes, use_VBOs);
|
_load_shells(*print, *volumes, use_VBOs);
|
||||||
volumes->set_render_interleaved_only_volumes(GLVolumeCollection::RenderInterleavedOnlyVolumes(true, 0.25f));
|
volumes->set_render_interleaved_only_volumes(GLVolumeCollection::RenderInterleavedOnlyVolumes(true, 0.25f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_update_gcode_volumes_visibility(*print, *volumes);
|
_update_gcode_volumes_visibility(*preview_data, *volumes);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int _3DScene::get_legend_texture_id()
|
unsigned int _3DScene::get_legend_texture_id()
|
||||||
|
@ -1751,7 +1752,7 @@ 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";
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::_load_gcode_extrusion_paths(const Print& print, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs)
|
void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, 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
|
||||||
struct Helper
|
struct Helper
|
||||||
|
@ -1831,12 +1832,12 @@ void _3DScene::_load_gcode_extrusion_paths(const Print& print, GLVolumeCollectio
|
||||||
|
|
||||||
// detects filters
|
// detects filters
|
||||||
FiltersList filters;
|
FiltersList filters;
|
||||||
for (const GCodePreviewData::Extrusion::Layer& layer : print.gcode_preview.extrusion.layers)
|
for (const GCodePreviewData::Extrusion::Layer& layer : preview_data.extrusion.layers)
|
||||||
{
|
{
|
||||||
for (const ExtrusionPath& path : layer.paths)
|
for (const ExtrusionPath& path : layer.paths)
|
||||||
{
|
{
|
||||||
ExtrusionRole role = path.role();
|
ExtrusionRole role = path.role();
|
||||||
float path_filter = Helper::path_filter(print.gcode_preview.extrusion.view_type, path);
|
float path_filter = Helper::path_filter(preview_data.extrusion.view_type, path);
|
||||||
if (std::find(filters.begin(), filters.end(), Filter(path_filter, role)) == filters.end())
|
if (std::find(filters.begin(), filters.end(), Filter(path_filter, role)) == filters.end())
|
||||||
filters.emplace_back(path_filter, role);
|
filters.emplace_back(path_filter, role);
|
||||||
}
|
}
|
||||||
|
@ -1851,7 +1852,7 @@ void _3DScene::_load_gcode_extrusion_paths(const Print& print, GLVolumeCollectio
|
||||||
{
|
{
|
||||||
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Extrusion, (unsigned int)filter.role, (unsigned int)volumes.volumes.size());
|
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Extrusion, (unsigned int)filter.role, (unsigned int)volumes.volumes.size());
|
||||||
|
|
||||||
GLVolume* volume = new GLVolume(Helper::path_color(print.gcode_preview, tool_colors, filter.value).rgba);
|
GLVolume* volume = new GLVolume(Helper::path_color(preview_data, tool_colors, filter.value).rgba);
|
||||||
if (volume != nullptr)
|
if (volume != nullptr)
|
||||||
{
|
{
|
||||||
filter.volume = volume;
|
filter.volume = volume;
|
||||||
|
@ -1877,11 +1878,11 @@ void _3DScene::_load_gcode_extrusion_paths(const Print& print, GLVolumeCollectio
|
||||||
}
|
}
|
||||||
|
|
||||||
// populates volumes
|
// populates volumes
|
||||||
for (const GCodePreviewData::Extrusion::Layer& layer : print.gcode_preview.extrusion.layers)
|
for (const GCodePreviewData::Extrusion::Layer& layer : preview_data.extrusion.layers)
|
||||||
{
|
{
|
||||||
for (const ExtrusionPath& path : layer.paths)
|
for (const ExtrusionPath& path : layer.paths)
|
||||||
{
|
{
|
||||||
float path_filter = Helper::path_filter(print.gcode_preview.extrusion.view_type, path);
|
float path_filter = Helper::path_filter(preview_data.extrusion.view_type, path);
|
||||||
FiltersList::iterator filter = std::find(filters.begin(), filters.end(), Filter(path_filter, path.role()));
|
FiltersList::iterator filter = std::find(filters.begin(), filters.end(), Filter(path_filter, path.role()));
|
||||||
if (filter != filters.end())
|
if (filter != filters.end())
|
||||||
{
|
{
|
||||||
|
@ -1906,27 +1907,27 @@ void _3DScene::_load_gcode_extrusion_paths(const Print& print, GLVolumeCollectio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::_load_gcode_travel_paths(const Print& print, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs)
|
void _3DScene::_load_gcode_travel_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs)
|
||||||
{
|
{
|
||||||
size_t initial_volumes_count = volumes.volumes.size();
|
size_t initial_volumes_count = volumes.volumes.size();
|
||||||
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Travel, 0, (unsigned int)initial_volumes_count);
|
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Travel, 0, (unsigned int)initial_volumes_count);
|
||||||
|
|
||||||
bool res = true;
|
bool res = true;
|
||||||
switch (print.gcode_preview.extrusion.view_type)
|
switch (preview_data.extrusion.view_type)
|
||||||
{
|
{
|
||||||
case GCodePreviewData::Extrusion::Feedrate:
|
case GCodePreviewData::Extrusion::Feedrate:
|
||||||
{
|
{
|
||||||
res = _travel_paths_by_feedrate(print, volumes);
|
res = _travel_paths_by_feedrate(preview_data, volumes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodePreviewData::Extrusion::Tool:
|
case GCodePreviewData::Extrusion::Tool:
|
||||||
{
|
{
|
||||||
res = _travel_paths_by_tool(print, volumes, tool_colors);
|
res = _travel_paths_by_tool(preview_data, volumes, tool_colors);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
res = _travel_paths_by_type(print, volumes);
|
res = _travel_paths_by_type(preview_data, volumes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1961,7 +1962,7 @@ void _3DScene::_load_gcode_travel_paths(const Print& print, GLVolumeCollection&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _3DScene::_travel_paths_by_type(const Print& print, GLVolumeCollection& volumes)
|
bool _3DScene::_travel_paths_by_type(const GCodePreviewData& preview_data, GLVolumeCollection& volumes)
|
||||||
{
|
{
|
||||||
// Helper structure for types
|
// Helper structure for types
|
||||||
struct Type
|
struct Type
|
||||||
|
@ -1987,7 +1988,7 @@ bool _3DScene::_travel_paths_by_type(const Print& print, GLVolumeCollection& vol
|
||||||
|
|
||||||
// detects types
|
// detects types
|
||||||
TypesList types;
|
TypesList types;
|
||||||
for (const GCodePreviewData::Travel::Polyline& polyline : print.gcode_preview.travel.polylines)
|
for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
|
||||||
{
|
{
|
||||||
if (std::find(types.begin(), types.end(), Type(polyline.type)) == types.end())
|
if (std::find(types.begin(), types.end(), Type(polyline.type)) == types.end())
|
||||||
types.emplace_back(polyline.type);
|
types.emplace_back(polyline.type);
|
||||||
|
@ -2000,7 +2001,7 @@ bool _3DScene::_travel_paths_by_type(const Print& print, GLVolumeCollection& vol
|
||||||
// creates a new volume for each type
|
// creates a new volume for each type
|
||||||
for (Type& type : types)
|
for (Type& type : types)
|
||||||
{
|
{
|
||||||
GLVolume* volume = new GLVolume(print.gcode_preview.travel.type_colors[type.value].rgba);
|
GLVolume* volume = new GLVolume(preview_data.travel.type_colors[type.value].rgba);
|
||||||
if (volume == nullptr)
|
if (volume == nullptr)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
|
@ -2011,7 +2012,7 @@ bool _3DScene::_travel_paths_by_type(const Print& print, GLVolumeCollection& vol
|
||||||
}
|
}
|
||||||
|
|
||||||
// populates volumes
|
// populates volumes
|
||||||
for (const GCodePreviewData::Travel::Polyline& polyline : print.gcode_preview.travel.polylines)
|
for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
|
||||||
{
|
{
|
||||||
TypesList::iterator type = std::find(types.begin(), types.end(), Type(polyline.type));
|
TypesList::iterator type = std::find(types.begin(), types.end(), Type(polyline.type));
|
||||||
if (type != types.end())
|
if (type != types.end())
|
||||||
|
@ -2020,14 +2021,14 @@ bool _3DScene::_travel_paths_by_type(const Print& print, GLVolumeCollection& vol
|
||||||
type->volume->offsets.push_back(type->volume->indexed_vertex_array.quad_indices.size());
|
type->volume->offsets.push_back(type->volume->indexed_vertex_array.quad_indices.size());
|
||||||
type->volume->offsets.push_back(type->volume->indexed_vertex_array.triangle_indices.size());
|
type->volume->offsets.push_back(type->volume->indexed_vertex_array.triangle_indices.size());
|
||||||
|
|
||||||
polyline3_to_verts(polyline.polyline, print.gcode_preview.travel.width, print.gcode_preview.travel.height, *type->volume);
|
polyline3_to_verts(polyline.polyline, preview_data.travel.width, preview_data.travel.height, *type->volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _3DScene::_travel_paths_by_feedrate(const Print& print, GLVolumeCollection& volumes)
|
bool _3DScene::_travel_paths_by_feedrate(const GCodePreviewData& preview_data, GLVolumeCollection& volumes)
|
||||||
{
|
{
|
||||||
// Helper structure for feedrate
|
// Helper structure for feedrate
|
||||||
struct Feedrate
|
struct Feedrate
|
||||||
|
@ -2053,7 +2054,7 @@ bool _3DScene::_travel_paths_by_feedrate(const Print& print, GLVolumeCollection&
|
||||||
|
|
||||||
// detects feedrates
|
// detects feedrates
|
||||||
FeedratesList feedrates;
|
FeedratesList feedrates;
|
||||||
for (const GCodePreviewData::Travel::Polyline& polyline : print.gcode_preview.travel.polylines)
|
for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
|
||||||
{
|
{
|
||||||
if (std::find(feedrates.begin(), feedrates.end(), Feedrate(polyline.feedrate)) == feedrates.end())
|
if (std::find(feedrates.begin(), feedrates.end(), Feedrate(polyline.feedrate)) == feedrates.end())
|
||||||
feedrates.emplace_back(polyline.feedrate);
|
feedrates.emplace_back(polyline.feedrate);
|
||||||
|
@ -2066,7 +2067,7 @@ bool _3DScene::_travel_paths_by_feedrate(const Print& print, GLVolumeCollection&
|
||||||
// creates a new volume for each feedrate
|
// creates a new volume for each feedrate
|
||||||
for (Feedrate& feedrate : feedrates)
|
for (Feedrate& feedrate : feedrates)
|
||||||
{
|
{
|
||||||
GLVolume* volume = new GLVolume(print.gcode_preview.get_extrusion_feedrate_color(feedrate.value).rgba);
|
GLVolume* volume = new GLVolume(preview_data.get_extrusion_feedrate_color(feedrate.value).rgba);
|
||||||
if (volume == nullptr)
|
if (volume == nullptr)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
|
@ -2077,7 +2078,7 @@ bool _3DScene::_travel_paths_by_feedrate(const Print& print, GLVolumeCollection&
|
||||||
}
|
}
|
||||||
|
|
||||||
// populates volumes
|
// populates volumes
|
||||||
for (const GCodePreviewData::Travel::Polyline& polyline : print.gcode_preview.travel.polylines)
|
for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
|
||||||
{
|
{
|
||||||
FeedratesList::iterator feedrate = std::find(feedrates.begin(), feedrates.end(), Feedrate(polyline.feedrate));
|
FeedratesList::iterator feedrate = std::find(feedrates.begin(), feedrates.end(), Feedrate(polyline.feedrate));
|
||||||
if (feedrate != feedrates.end())
|
if (feedrate != feedrates.end())
|
||||||
|
@ -2086,14 +2087,14 @@ bool _3DScene::_travel_paths_by_feedrate(const Print& print, GLVolumeCollection&
|
||||||
feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.quad_indices.size());
|
feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.quad_indices.size());
|
||||||
feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.triangle_indices.size());
|
feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.triangle_indices.size());
|
||||||
|
|
||||||
polyline3_to_verts(polyline.polyline, print.gcode_preview.travel.width, print.gcode_preview.travel.height, *feedrate->volume);
|
polyline3_to_verts(polyline.polyline, preview_data.travel.width, preview_data.travel.height, *feedrate->volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _3DScene::_travel_paths_by_tool(const Print& print, GLVolumeCollection& volumes, const std::vector<float>& tool_colors)
|
bool _3DScene::_travel_paths_by_tool(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors)
|
||||||
{
|
{
|
||||||
// Helper structure for tool
|
// Helper structure for tool
|
||||||
struct Tool
|
struct Tool
|
||||||
|
@ -2119,7 +2120,7 @@ bool _3DScene::_travel_paths_by_tool(const Print& print, GLVolumeCollection& vol
|
||||||
|
|
||||||
// detects tools
|
// detects tools
|
||||||
ToolsList tools;
|
ToolsList tools;
|
||||||
for (const GCodePreviewData::Travel::Polyline& polyline : print.gcode_preview.travel.polylines)
|
for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
|
||||||
{
|
{
|
||||||
if (std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id)) == tools.end())
|
if (std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id)) == tools.end())
|
||||||
tools.emplace_back(polyline.extruder_id);
|
tools.emplace_back(polyline.extruder_id);
|
||||||
|
@ -2143,7 +2144,7 @@ bool _3DScene::_travel_paths_by_tool(const Print& print, GLVolumeCollection& vol
|
||||||
}
|
}
|
||||||
|
|
||||||
// populates volumes
|
// populates volumes
|
||||||
for (const GCodePreviewData::Travel::Polyline& polyline : print.gcode_preview.travel.polylines)
|
for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
|
||||||
{
|
{
|
||||||
ToolsList::iterator tool = std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id));
|
ToolsList::iterator tool = std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id));
|
||||||
if (tool != tools.end())
|
if (tool != tools.end())
|
||||||
|
@ -2152,27 +2153,27 @@ bool _3DScene::_travel_paths_by_tool(const Print& print, GLVolumeCollection& vol
|
||||||
tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.quad_indices.size());
|
tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.quad_indices.size());
|
||||||
tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.triangle_indices.size());
|
tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.triangle_indices.size());
|
||||||
|
|
||||||
polyline3_to_verts(polyline.polyline, print.gcode_preview.travel.width, print.gcode_preview.travel.height, *tool->volume);
|
polyline3_to_verts(polyline.polyline, preview_data.travel.width, preview_data.travel.height, *tool->volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::_load_gcode_retractions(const Print& print, GLVolumeCollection& volumes, bool use_VBOs)
|
void _3DScene::_load_gcode_retractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs)
|
||||||
{
|
{
|
||||||
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Retraction, 0, (unsigned int)volumes.volumes.size());
|
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Retraction, 0, (unsigned int)volumes.volumes.size());
|
||||||
|
|
||||||
// nothing to render, return
|
// nothing to render, return
|
||||||
if (print.gcode_preview.retraction.positions.empty())
|
if (preview_data.retraction.positions.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLVolume* volume = new GLVolume(print.gcode_preview.retraction.color.rgba);
|
GLVolume* volume = new GLVolume(preview_data.retraction.color.rgba);
|
||||||
if (volume != nullptr)
|
if (volume != nullptr)
|
||||||
{
|
{
|
||||||
volumes.volumes.emplace_back(volume);
|
volumes.volumes.emplace_back(volume);
|
||||||
|
|
||||||
for (const GCodePreviewData::Retraction::Position& position : print.gcode_preview.retraction.positions)
|
for (const GCodePreviewData::Retraction::Position& position : preview_data.retraction.positions)
|
||||||
{
|
{
|
||||||
volume->print_zs.push_back(unscale(position.position.z));
|
volume->print_zs.push_back(unscale(position.position.z));
|
||||||
volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
|
volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
|
||||||
|
@ -2187,20 +2188,20 @@ void _3DScene::_load_gcode_retractions(const Print& print, GLVolumeCollection& v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::_load_gcode_unretractions(const Print& print, GLVolumeCollection& volumes, bool use_VBOs)
|
void _3DScene::_load_gcode_unretractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs)
|
||||||
{
|
{
|
||||||
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Unretraction, 0, (unsigned int)volumes.volumes.size());
|
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Unretraction, 0, (unsigned int)volumes.volumes.size());
|
||||||
|
|
||||||
// nothing to render, return
|
// nothing to render, return
|
||||||
if (print.gcode_preview.unretraction.positions.empty())
|
if (preview_data.unretraction.positions.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLVolume* volume = new GLVolume(print.gcode_preview.unretraction.color.rgba);
|
GLVolume* volume = new GLVolume(preview_data.unretraction.color.rgba);
|
||||||
if (volume != nullptr)
|
if (volume != nullptr)
|
||||||
{
|
{
|
||||||
volumes.volumes.emplace_back(volume);
|
volumes.volumes.emplace_back(volume);
|
||||||
|
|
||||||
for (const GCodePreviewData::Retraction::Position& position : print.gcode_preview.unretraction.positions)
|
for (const GCodePreviewData::Retraction::Position& position : preview_data.unretraction.positions)
|
||||||
{
|
{
|
||||||
volume->print_zs.push_back(unscale(position.position.z));
|
volume->print_zs.push_back(unscale(position.position.z));
|
||||||
volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
|
volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
|
||||||
|
@ -2215,7 +2216,7 @@ void _3DScene::_load_gcode_unretractions(const Print& print, GLVolumeCollection&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::_update_gcode_volumes_visibility(const Print& print, GLVolumeCollection& volumes)
|
void _3DScene::_update_gcode_volumes_visibility(const GCodePreviewData& preview_data, GLVolumeCollection& volumes)
|
||||||
{
|
{
|
||||||
unsigned int size = (unsigned int)s_gcode_preview_volume_index.first_volumes.size();
|
unsigned int size = (unsigned int)s_gcode_preview_volume_index.first_volumes.size();
|
||||||
for (unsigned int i = 0; i < size; ++i)
|
for (unsigned int i = 0; i < size; ++i)
|
||||||
|
@ -2231,27 +2232,27 @@ void _3DScene::_update_gcode_volumes_visibility(const Print& print, GLVolumeColl
|
||||||
{
|
{
|
||||||
case GCodePreviewVolumeIndex::Extrusion:
|
case GCodePreviewVolumeIndex::Extrusion:
|
||||||
{
|
{
|
||||||
volume->is_active = print.gcode_preview.extrusion.is_role_flag_set((ExtrusionRole)s_gcode_preview_volume_index.first_volumes[i].flag);
|
volume->is_active = preview_data.extrusion.is_role_flag_set((ExtrusionRole)s_gcode_preview_volume_index.first_volumes[i].flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodePreviewVolumeIndex::Travel:
|
case GCodePreviewVolumeIndex::Travel:
|
||||||
{
|
{
|
||||||
volume->is_active = print.gcode_preview.travel.is_visible;
|
volume->is_active = preview_data.travel.is_visible;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodePreviewVolumeIndex::Retraction:
|
case GCodePreviewVolumeIndex::Retraction:
|
||||||
{
|
{
|
||||||
volume->is_active = print.gcode_preview.retraction.is_visible;
|
volume->is_active = preview_data.retraction.is_visible;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodePreviewVolumeIndex::Unretraction:
|
case GCodePreviewVolumeIndex::Unretraction:
|
||||||
{
|
{
|
||||||
volume->is_active = print.gcode_preview.unretraction.is_visible;
|
volume->is_active = preview_data.unretraction.is_visible;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodePreviewVolumeIndex::Shell:
|
case GCodePreviewVolumeIndex::Shell:
|
||||||
{
|
{
|
||||||
volume->is_active = print.gcode_preview.shell.is_visible;
|
volume->is_active = preview_data.shell.is_visible;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -2264,9 +2265,9 @@ void _3DScene::_update_gcode_volumes_visibility(const Print& print, GLVolumeColl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::_generate_legend_texture(const Print& print, const std::vector<float>& tool_colors)
|
void _3DScene::_generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors)
|
||||||
{
|
{
|
||||||
s_legend_texture.generate_texture(print, tool_colors);
|
s_legend_texture.generate_texture(preview_data, tool_colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::_load_shells(const Print& print, GLVolumeCollection& volumes, bool use_VBOs)
|
void _3DScene::_load_shells(const Print& print, GLVolumeCollection& volumes, bool use_VBOs)
|
||||||
|
|
|
@ -15,6 +15,7 @@ class Print;
|
||||||
class PrintObject;
|
class PrintObject;
|
||||||
class Model;
|
class Model;
|
||||||
class ModelObject;
|
class ModelObject;
|
||||||
|
class GCodePreviewData;
|
||||||
|
|
||||||
// A container for interleaved arrays of 3D vertices and normals,
|
// A container for interleaved arrays of 3D vertices and normals,
|
||||||
// possibly indexed by triangles and / or quads.
|
// possibly indexed by triangles and / or quads.
|
||||||
|
@ -423,7 +424,7 @@ class _3DScene
|
||||||
LegendTexture();
|
LegendTexture();
|
||||||
~LegendTexture();
|
~LegendTexture();
|
||||||
|
|
||||||
bool generate_texture(const Print& print, const std::vector<float>& tool_colors);
|
bool generate_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
||||||
|
|
||||||
unsigned int get_texture_id() const;
|
unsigned int get_texture_id() const;
|
||||||
unsigned int get_texture_width() const;
|
unsigned int get_texture_width() const;
|
||||||
|
@ -432,7 +433,7 @@ class _3DScene
|
||||||
void reset_texture();
|
void reset_texture();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _create_texture(const Print& print, const wxBitmap& bitmap);
|
bool _create_texture(const GCodePreviewData& preview_data, const wxBitmap& bitmap);
|
||||||
void _destroy_texture();
|
void _destroy_texture();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -441,7 +442,7 @@ class _3DScene
|
||||||
public:
|
public:
|
||||||
static void _glew_init();
|
static void _glew_init();
|
||||||
|
|
||||||
static void load_gcode_preview(const Print* print, GLVolumeCollection* volumes, const std::vector<std::string>& str_tool_colors, bool use_VBOs);
|
static void load_gcode_preview(const Print* print, const GCodePreviewData* preview_data, GLVolumeCollection* volumes, const std::vector<std::string>& str_tool_colors, 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();
|
||||||
|
@ -469,20 +470,20 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// generates gcode extrusion paths geometry
|
// generates gcode extrusion paths geometry
|
||||||
static void _load_gcode_extrusion_paths(const Print& print, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs);
|
static void _load_gcode_extrusion_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs);
|
||||||
// generates gcode travel paths geometry
|
// generates gcode travel paths geometry
|
||||||
static void _load_gcode_travel_paths(const Print& print, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs);
|
static void _load_gcode_travel_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs);
|
||||||
static bool _travel_paths_by_type(const Print& print, GLVolumeCollection& volumes);
|
static bool _travel_paths_by_type(const GCodePreviewData& preview_data, GLVolumeCollection& volumes);
|
||||||
static bool _travel_paths_by_feedrate(const Print& print, GLVolumeCollection& volumes);
|
static bool _travel_paths_by_feedrate(const GCodePreviewData& preview_data, GLVolumeCollection& volumes);
|
||||||
static bool _travel_paths_by_tool(const Print& print, GLVolumeCollection& volumes, const std::vector<float>& tool_colors);
|
static bool _travel_paths_by_tool(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors);
|
||||||
// generates gcode retractions geometry
|
// generates gcode retractions geometry
|
||||||
static void _load_gcode_retractions(const Print& print, GLVolumeCollection& volumes, bool use_VBOs);
|
static void _load_gcode_retractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs);
|
||||||
// generates gcode unretractions geometry
|
// generates gcode unretractions geometry
|
||||||
static void _load_gcode_unretractions(const Print& print, GLVolumeCollection& volumes, bool use_VBOs);
|
static void _load_gcode_unretractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs);
|
||||||
// sets gcode geometry visibility according to user selection
|
// sets gcode geometry visibility according to user selection
|
||||||
static void _update_gcode_volumes_visibility(const Print& print, GLVolumeCollection& volumes);
|
static void _update_gcode_volumes_visibility(const GCodePreviewData& preview_data, 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, const std::vector<float>& tool_colors);
|
static void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
||||||
// generates objects and wipe tower geometry
|
// generates objects and wipe tower geometry
|
||||||
static void _load_shells(const Print& print, GLVolumeCollection& volumes, bool use_VBOs);
|
static void _load_shells(const Print& print, GLVolumeCollection& volumes, bool use_VBOs);
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <xsinit.h>
|
#include <xsinit.h>
|
||||||
#include "libslic3r/GCode.hpp"
|
#include "libslic3r/GCode.hpp"
|
||||||
#include "libslic3r/GCode/CoolingBuffer.hpp"
|
#include "libslic3r/GCode/CoolingBuffer.hpp"
|
||||||
|
#include "libslic3r/GCode/PreviewData.hpp"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%name{Slic3r::GCode::CoolingBuffer} class CoolingBuffer {
|
%name{Slic3r::GCode::CoolingBuffer} class CoolingBuffer {
|
||||||
|
@ -17,10 +18,10 @@
|
||||||
%name{Slic3r::GCode} class GCode {
|
%name{Slic3r::GCode} class GCode {
|
||||||
GCode();
|
GCode();
|
||||||
~GCode();
|
~GCode();
|
||||||
void do_export(Print *print, const char *path)
|
void do_export(Print *print, const char *path, GCodePreviewData *preview_data)
|
||||||
%code%{
|
%code%{
|
||||||
try {
|
try {
|
||||||
THIS->do_export(print, path);
|
THIS->do_export(print, path, preview_data);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
croak(e.what());
|
croak(e.what());
|
||||||
}
|
}
|
||||||
|
@ -50,3 +51,25 @@
|
||||||
Ref<StaticPrintConfig> config()
|
Ref<StaticPrintConfig> config()
|
||||||
%code{% RETVAL = const_cast<StaticPrintConfig*>(static_cast<const StaticPrintConfig*>(static_cast<const PrintObjectConfig*>(&THIS->config()))); %};
|
%code{% RETVAL = const_cast<StaticPrintConfig*>(static_cast<const StaticPrintConfig*>(static_cast<const PrintObjectConfig*>(&THIS->config()))); %};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
%name{Slic3r::GCode::PreviewData} class GCodePreviewData {
|
||||||
|
GCodePreviewData();
|
||||||
|
~GCodePreviewData();
|
||||||
|
void reset();
|
||||||
|
void set_type(int type)
|
||||||
|
%code%{
|
||||||
|
if ((0 <= type) && (type < GCodePreviewData::Extrusion::Num_View_Types))
|
||||||
|
THIS->extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)type;
|
||||||
|
%};
|
||||||
|
void set_extrusion_flags(int flags)
|
||||||
|
%code%{ THIS->extrusion.role_flags = (unsigned int)flags; %};
|
||||||
|
void set_travel_visible(bool visible)
|
||||||
|
%code%{ THIS->travel.is_visible = visible; %};
|
||||||
|
void set_retractions_visible(bool visible)
|
||||||
|
%code%{ THIS->retraction.is_visible = visible; %};
|
||||||
|
void set_unretractions_visible(bool visible)
|
||||||
|
%code%{ THIS->unretraction.is_visible = visible; %};
|
||||||
|
void set_shells_visible(bool visible)
|
||||||
|
%code%{ THIS->shell.is_visible = visible; %};
|
||||||
|
void set_extrusion_paths_colors(std::vector<std::string> colors);
|
||||||
|
};
|
||||||
|
|
|
@ -195,12 +195,13 @@ _load_wipe_tower_toolpaths(print, volumes, tool_colors, use_VBOs)
|
||||||
_3DScene::_load_wipe_tower_toolpaths(print, volumes, tool_colors, use_VBOs != 0);
|
_3DScene::_load_wipe_tower_toolpaths(print, volumes, tool_colors, use_VBOs != 0);
|
||||||
|
|
||||||
void
|
void
|
||||||
load_gcode_preview(print, volumes, str_tool_colors, use_VBOs)
|
load_gcode_preview(print, preview_data, volumes, str_tool_colors, use_VBOs)
|
||||||
Print *print;
|
Print *print;
|
||||||
|
GCodePreviewData *preview_data;
|
||||||
GLVolumeCollection *volumes;
|
GLVolumeCollection *volumes;
|
||||||
std::vector<std::string> str_tool_colors;
|
std::vector<std::string> str_tool_colors;
|
||||||
int use_VBOs;
|
int use_VBOs;
|
||||||
CODE:
|
CODE:
|
||||||
_3DScene::load_gcode_preview(print, volumes, str_tool_colors, use_VBOs != 0);
|
_3DScene::load_gcode_preview(print, preview_data, volumes, str_tool_colors, use_VBOs != 0);
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -165,15 +165,6 @@ _constant()
|
||||||
size_t object_count()
|
size_t object_count()
|
||||||
%code%{ RETVAL = THIS->objects.size(); %};
|
%code%{ RETVAL = THIS->objects.size(); %};
|
||||||
|
|
||||||
void clear_gcode_preview_data();
|
|
||||||
void set_gcode_preview_type(unsigned char type);
|
|
||||||
void set_gcode_preview_extrusion_flags(unsigned int flags);
|
|
||||||
void set_gcode_preview_travel_visible(bool visible);
|
|
||||||
void set_gcode_preview_retractions_visible(bool visible);
|
|
||||||
void set_gcode_preview_unretractions_visible(bool visible);
|
|
||||||
void set_gcode_preview_shells_visible(bool visible);
|
|
||||||
void set_gcode_extrusion_paths_colors(std::vector<std::string> colors);
|
|
||||||
|
|
||||||
PrintRegionPtrs* regions()
|
PrintRegionPtrs* regions()
|
||||||
%code%{ RETVAL = &THIS->regions; %};
|
%code%{ RETVAL = &THIS->regions; %};
|
||||||
Ref<PrintRegion> get_region(int idx);
|
Ref<PrintRegion> get_region(int idx);
|
||||||
|
|
|
@ -191,6 +191,10 @@ GCode* O_OBJECT_SLIC3R
|
||||||
Ref<GCode> O_OBJECT_SLIC3R_T
|
Ref<GCode> O_OBJECT_SLIC3R_T
|
||||||
Clone<GCode> O_OBJECT_SLIC3R_T
|
Clone<GCode> O_OBJECT_SLIC3R_T
|
||||||
|
|
||||||
|
GCodePreviewData* O_OBJECT_SLIC3R
|
||||||
|
Ref<GCodePreviewData> O_OBJECT_SLIC3R_T
|
||||||
|
Clone<GCodePreviewData> O_OBJECT_SLIC3R_T
|
||||||
|
|
||||||
MotionPlanner* O_OBJECT_SLIC3R
|
MotionPlanner* O_OBJECT_SLIC3R
|
||||||
Ref<MotionPlanner> O_OBJECT_SLIC3R_T
|
Ref<MotionPlanner> O_OBJECT_SLIC3R_T
|
||||||
Clone<MotionPlanner> O_OBJECT_SLIC3R_T
|
Clone<MotionPlanner> O_OBJECT_SLIC3R_T
|
||||||
|
|
|
@ -155,6 +155,9 @@
|
||||||
%typemap{Ref<GCode>}{simple};
|
%typemap{Ref<GCode>}{simple};
|
||||||
%typemap{Clone<GCode>}{simple};
|
%typemap{Clone<GCode>}{simple};
|
||||||
|
|
||||||
|
%typemap{GCodePreviewData*};
|
||||||
|
%typemap{Ref<GCodePreviewData>}{simple};
|
||||||
|
%typemap{Clone<GCodePreviewData>}{simple};
|
||||||
|
|
||||||
%typemap{Points};
|
%typemap{Points};
|
||||||
%typemap{Pointfs};
|
%typemap{Pointfs};
|
||||||
|
|
Loading…
Reference in a new issue