From eeada56c1f50dc9309df8ffde644ee60712e0021 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 19 Feb 2018 15:33:01 +0100 Subject: [PATCH 1/5] 1st attempt to fix JIRA SPE-22 (wrong file export on MAC) --- lib/Slic3r/GUI.pm | 4 ++-- lib/Slic3r/GUI/Plater.pm | 6 +++++- xs/src/slic3r/GUI/BedShapeDialog.cpp | 8 ++++---- xs/src/slic3r/GUI/GUI.hpp | 5 +++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 54a27dc991..bc06b254ac 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -40,10 +40,10 @@ use Wx::Event qw(EVT_IDLE EVT_COMMAND EVT_MENU); use base 'Wx::App'; use constant FILE_WILDCARDS => { - known => 'Known files (*.stl, *.obj, *.amf, *.xml, *.3mf, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.3mf;*.3MF;*.prusa;*.PRUSA', + known => 'Known files (*.stl, *.obj, *.amf, *.xml, *.3mf, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.zip.amf;*.amf;*.AMF;*.xml;*.XML;*.3mf;*.3MF;*.prusa;*.PRUSA', stl => 'STL files (*.stl)|*.stl;*.STL', obj => 'OBJ files (*.obj)|*.obj;*.OBJ', - amf => 'AMF files (*.amf)|*.amf;*.AMF;*.xml;*.XML', + amf => 'AMF files (*.amf)|*.zip.amf;*.amf;*.AMF;*.xml;*.XML', threemf => '3MF files (*.3mf)|*.3mf;*.3MF', prusa => 'Prusa Control files (*.prusa)|*.prusa;*.PRUSA', ini => 'INI files *.ini|*.ini;*.INI', diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index a74141d8c7..da2c08c58a 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1616,23 +1616,27 @@ sub export_3mf { sub _get_export_file { my ($self, $format) = @_; my $suffix = ''; + my $wildcard = 'known'; if ($format eq 'STL') { $suffix = '.stl'; + $wildcard = 'stl'; } elsif ($format eq 'AMF') { $suffix = '.zip.amf'; + $wildcard = 'amf'; } elsif ($format eq '3MF') { $suffix = '.3mf'; + $wildcard = 'threemf'; } my $output_file = eval { $self->{print}->output_filepath($main::opt{output} // '') }; Slic3r::GUI::catch_error($self) and return undef; $output_file =~ s/\.[gG][cC][oO][dD][eE]$/$suffix/; my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file), - basename($output_file), &Slic3r::GUI::MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + basename($output_file), &Slic3r::GUI::FILE_WILDCARDS->{$wildcard}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if ($dlg->ShowModal != wxID_OK) { $dlg->Destroy; return undef; diff --git a/xs/src/slic3r/GUI/BedShapeDialog.cpp b/xs/src/slic3r/GUI/BedShapeDialog.cpp index 5ee0c1f8ba..d8ef31ec32 100644 --- a/xs/src/slic3r/GUI/BedShapeDialog.cpp +++ b/xs/src/slic3r/GUI/BedShapeDialog.cpp @@ -290,13 +290,13 @@ void BedShapePanel::update_shape() void BedShapePanel::load_stl() { t_file_wild_card vec_FILE_WILDCARDS = get_file_wild_card(); - std::vector file_types = { "known", "stl", "obj", "amf", "prusa"}; - wxString MODEL_WILDCARD; + std::vector file_types = { "known", "stl", "obj", "amf", "3mf", "prusa" }; + wxString MODEL_WILDCARD; for (auto file_type: file_types) MODEL_WILDCARD += vec_FILE_WILDCARDS.at(file_type) + "|"; - auto dialog = new wxFileDialog(this, _L("Choose a file to import bed shape from (STL/OBJ/AMF/PRUSA):"), "", "", - MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST); + auto dialog = new wxFileDialog(this, _L("Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):"), "", "", + MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (dialog->ShowModal() != wxID_OK) { dialog->Destroy(); return; diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 14f429713d..8144521c75 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -39,8 +39,9 @@ inline t_file_wild_card& get_file_wild_card() { FILE_WILDCARDS["known"] = "Known files (*.stl, *.obj, *.amf, *.xml, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.prusa;*.PRUSA"; FILE_WILDCARDS["stl"] = "STL files (*.stl)|*.stl;*.STL"; FILE_WILDCARDS["obj"] = "OBJ files (*.obj)|*.obj;*.OBJ"; - FILE_WILDCARDS["amf"] = "AMF files (*.amf)|*.amf;*.AMF;*.xml;*.XML"; - FILE_WILDCARDS["prusa"] = "Prusa Control files (*.prusa)|*.prusa;*.PRUSA"; + FILE_WILDCARDS["amf"] = "AMF files (*.amf)|*.zip.amf;*.amf;*.AMF;*.xml;*.XML"; + FILE_WILDCARDS["3mf"] = "3MF files (*.3mf)|*.3mf;*.3MF;"; + FILE_WILDCARDS["prusa"] = "Prusa Control files (*.prusa)|*.prusa;*.PRUSA"; FILE_WILDCARDS["ini"] = "INI files *.ini|*.ini;*.INI"; FILE_WILDCARDS["gcode"] = "G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC"; FILE_WILDCARDS["svg"] = "SVG files *.svg|*.svg;*.SVG"; From e13a9adff252ca4f1c44fd3aad0fc5f0cbec9b3e Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 20 Feb 2018 11:10:54 +0100 Subject: [PATCH 2/5] 2nd attempt to fix JIRA SPE-22 (wrong file export on MAC) --- lib/Slic3r/GUI/Plater.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index da2c08c58a..88d4d89340 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1624,7 +1624,12 @@ sub _get_export_file { } elsif ($format eq 'AMF') { + if ($^O eq 'MacOS') { + # It seems that MacOS does not like double extension + $suffix = '.amf'; + } else { $suffix = '.zip.amf'; + } $wildcard = 'amf'; } elsif ($format eq '3MF') From 662ea15c239e810bfe5cccc99afc882eea84ef5d Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 20 Feb 2018 11:33:38 +0100 Subject: [PATCH 3/5] 3rd attempt to fix JIRA SPE-22 (wrong file export on MAC) --- lib/Slic3r/GUI/Plater.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 88d4d89340..9eab5172c2 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1624,12 +1624,12 @@ sub _get_export_file { } elsif ($format eq 'AMF') { - if ($^O eq 'MacOS') { - # It seems that MacOS does not like double extension - $suffix = '.amf'; - } else { - $suffix = '.zip.amf'; - } + if (&Wx::wxMAC) { + # It seems that MacOS does not like double extension + $suffix = '.amf'; + } else { + $suffix = '.zip.amf'; + } $wildcard = 'amf'; } elsif ($format eq '3MF') From 52eb6f6bcfd758a6dd9dbf8a0625cec1ac7827dd Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 22 Feb 2018 15:27:32 +0100 Subject: [PATCH 4/5] Remove .zip from file extension on import to avoid having it added again and again when exporting --- xs/src/libslic3r/Model.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index f65707ccba..1de99bbf82 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace Slic3r { @@ -91,7 +92,15 @@ Model Model::read_from_archive(const std::string &input_file, PresetBundle* bund throw std::runtime_error("The supplied file couldn't be read because it's empty"); for (ModelObject *o : model.objects) - o->input_file = input_file; + { + if (boost::algorithm::iends_with(input_file, ".zip.amf")) + { + // we remove the .zip part of the extension to avoid it be added to filenames when exporting + o->input_file = boost::ireplace_last_copy(input_file, ".zip.", "."); + } + else + o->input_file = input_file; + } if (add_default_instances) model.add_default_instances(); From acce8dbff6d9959b6ec879a4989c55ae11fa1deb Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 22 Feb 2018 14:44:07 +0100 Subject: [PATCH 5/5] A workaround of the dreaded Intel HD Graphics driver issue at least on the laptop of @roesel. fixes https://github.com/prusa3d/Slic3r/issues/672 The Intel HD Graphics hangs on the glFinish() call for some reason with one particular graphics driver revision. Also the glFinish() call was superfluous and it only may have had negative effect over the performance. Both glFinish() and glFlush() were removed for performance reasons where they were not needed, see https://www.khronos.org/opengl/wiki/Common_Mistakes --- lib/Slic3r/GUI/3DScene.pm | 29 +++++++++++----------------- lib/Slic3r/GUI/Plater/2DToolpaths.pm | 2 -- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index b16f7db423..7f2fe43461 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1172,18 +1172,17 @@ sub Render { glLightfv_p(GL_LIGHT1, GL_POSITION, 1, 0, 1, 0); if ($self->enable_picking) { - # Render the object for picking. - # FIXME This cannot possibly work in a multi-sampled context as the color gets mangled by the anti-aliasing. - # Better to use software ray-casting on a bounding-box hierarchy. - glPushAttrib(GL_ENABLE_BIT); - glDisable(GL_MULTISAMPLE) if ($self->{can_multisample}); - glDisable(GL_LIGHTING); - glDisable(GL_BLEND); - $self->draw_volumes(1); - glFlush(); - glFinish(); - if (my $pos = $self->_mouse_pos) { + # Render the object for picking. + # FIXME This cannot possibly work in a multi-sampled context as the color gets mangled by the anti-aliasing. + # Better to use software ray-casting on a bounding-box hierarchy. + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_MULTISAMPLE) if ($self->{can_multisample}); + glDisable(GL_LIGHTING); + glDisable(GL_BLEND); + $self->draw_volumes(1); + glPopAttrib(); + glFlush(); my $col = [ glReadPixels_p($pos->x, $self->GetSize->GetHeight - $pos->y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE) ]; my $volume_idx = $col->[0] + $col->[1]*256 + $col->[2]*256*256; $self->_hover_volume_idx(undef); @@ -1199,11 +1198,8 @@ sub Render { $self->on_hover->($volume_idx) if $self->on_hover; } + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glFlush(); - glFinish(); - glPopAttrib(); } # draw fixed background @@ -1337,9 +1333,6 @@ sub Render { $self->draw_active_object_annotations; $self->SwapBuffers(); - - # Calling glFinish has a performance penalty, but it seems to fix some OpenGL driver hang-up with extremely large scenes. -# glFinish(); } sub draw_volumes { diff --git a/lib/Slic3r/GUI/Plater/2DToolpaths.pm b/lib/Slic3r/GUI/Plater/2DToolpaths.pm index e48793bb09..96a252a08b 100644 --- a/lib/Slic3r/GUI/Plater/2DToolpaths.pm +++ b/lib/Slic3r/GUI/Plater/2DToolpaths.pm @@ -338,7 +338,6 @@ sub Render { glClear(GL_COLOR_BUFFER_BIT); if (!$self->GetParent->enabled || !$self->layers) { - glFlush(); $self->SwapBuffers; return; } @@ -486,7 +485,6 @@ sub Render { } gluDeleteTess($tess) if $tess; - glFlush(); $self->SwapBuffers; }