Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs/src
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2018-02-22 10:59:47 +0300
committerEnrico Turri <enricoturri@seznam.cz>2018-02-22 10:59:47 +0300
commit81eff20ad193be012450f8f8d08f0e90fd5a62e8 (patch)
tree0f07cf0c87f77020b6bb42f0d88ffe51898fe8c9 /xs/src
parent36601723a208a34fd55ea34c67bd8548246d708d (diff)
GCode Preview - Added Custom extrusion role + extended layers range for GCode preview
Diffstat (limited to 'xs/src')
-rw-r--r--xs/src/libslic3r/ExtrusionEntity.hpp1
-rw-r--r--xs/src/libslic3r/GCode.cpp18
-rw-r--r--xs/src/libslic3r/GCode/Analyzer.cpp6
-rw-r--r--xs/src/libslic3r/GCode/PreviewData.cpp9
-rw-r--r--xs/src/slic3r/GUI/3DScene.cpp22
-rw-r--r--xs/src/slic3r/GUI/3DScene.hpp3
-rw-r--r--xs/src/slic3r/GUI/wxExtensions.cpp29
7 files changed, 85 insertions, 3 deletions
diff --git a/xs/src/libslic3r/ExtrusionEntity.hpp b/xs/src/libslic3r/ExtrusionEntity.hpp
index f5e243419..16ef51c1f 100644
--- a/xs/src/libslic3r/ExtrusionEntity.hpp
+++ b/xs/src/libslic3r/ExtrusionEntity.hpp
@@ -26,6 +26,7 @@ enum ExtrusionRole {
erSupportMaterial,
erSupportMaterialInterface,
erWipeTower,
+ erCustom,
// Extrusion role for a collection with multiple extrusion roles.
erMixed,
};
diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp
index 2c2df6ec3..28c03ba2c 100644
--- a/xs/src/libslic3r/GCode.cpp
+++ b/xs/src/libslic3r/GCode.cpp
@@ -587,6 +587,15 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data)
this->_print_first_layer_bed_temperature(file, print, start_gcode, initial_extruder_id, true);
// Set extruder(s) temperature before and after start G-code.
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, false);
+
+ if (m_enable_analyzer)
+ {
+ // adds tag for analyzer
+ char buf[32];
+ sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erCustom);
+ _writeln(file, buf);
+ }
+
// Write the custom start G-code
_writeln(file, start_gcode);
// Process filament-specific gcode in extruder order.
@@ -770,6 +779,15 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data)
// Write end commands to file.
_write(file, this->retract());
_write(file, m_writer.set_fan(false));
+
+ if (m_enable_analyzer)
+ {
+ // adds tag for analyzer
+ char buf[32];
+ sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erCustom);
+ _writeln(file, buf);
+ }
+
// Process filament-specific gcode in extruder order.
if (print.config.single_extruder_multi_material) {
// Process the end_filament_gcode for the active filament only.
diff --git a/xs/src/libslic3r/GCode/Analyzer.cpp b/xs/src/libslic3r/GCode/Analyzer.cpp
index f8d196f23..6530806c4 100644
--- a/xs/src/libslic3r/GCode/Analyzer.cpp
+++ b/xs/src/libslic3r/GCode/Analyzer.cpp
@@ -150,7 +150,13 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi
{
// processes 'special' comments contained in line
if (_process_tags(line))
+ {
+#if 0
+ // DEBUG ONLY: puts the line back into the gcode
+ m_process_output += line.raw() + "\n";
+#endif
return;
+ }
// sets new start position/extrusion
_set_start_position(_get_end_position());
diff --git a/xs/src/libslic3r/GCode/PreviewData.cpp b/xs/src/libslic3r/GCode/PreviewData.cpp
index 5a23d332d..183e10b2a 100644
--- a/xs/src/libslic3r/GCode/PreviewData.cpp
+++ b/xs/src/libslic3r/GCode/PreviewData.cpp
@@ -125,6 +125,7 @@ const GCodePreviewData::Color GCodePreviewData::Extrusion::Default_Extrusion_Rol
Color(0.0f, 0.5f, 0.0f, 1.0f), // erSupportMaterial
Color(0.0f, 0.0f, 0.5f, 1.0f), // erSupportMaterialInterface
Color(0.7f, 0.89f, 0.67f, 1.0f), // erWipeTower
+ Color(1.0f, 1.0f, 0.0f, 1.0f), // erCustom
Color(0.0f, 0.0f, 0.0f, 1.0f) // erMixed
};
@@ -144,6 +145,7 @@ const std::string GCodePreviewData::Extrusion::Default_Extrusion_Role_Names[Num_
"Support material",
"Support material interface",
"Wipe tower",
+ "Custom",
"Mixed"
};
@@ -360,8 +362,11 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
{
case Extrusion::FeatureType:
{
- items.reserve(erMixed - erPerimeter + 1);
- for (unsigned int i = (unsigned int)erPerimeter; i < (unsigned int)erMixed; ++i)
+ ExtrusionRole first_valid = erPerimeter;
+ ExtrusionRole last_valid = erCustom;
+
+ items.reserve(last_valid - first_valid + 1);
+ for (unsigned int i = (unsigned int)first_valid; i <= (unsigned int)last_valid; ++i)
{
items.emplace_back(extrusion.role_names[i], extrusion.role_colors[i]);
}
diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp
index 3a8aa5ca7..f492ed342 100644
--- a/xs/src/slic3r/GUI/3DScene.cpp
+++ b/xs/src/slic3r/GUI/3DScene.cpp
@@ -450,6 +450,25 @@ void GLVolumeCollection::render_legacy() const
glDisableClientState(GL_NORMAL_ARRAY);
}
+std::vector<double> GLVolumeCollection::get_current_print_zs() const
+{
+ std::vector<double> print_zs;
+
+ for (GLVolume *vol : this->volumes)
+ {
+ for (coordf_t z : vol->print_zs)
+ {
+ double round_z = (double)round(z * 100000.0f) / 100000.0f;
+ if (std::find(print_zs.begin(), print_zs.end(), round_z) == print_zs.end())
+ print_zs.push_back(round_z);
+ }
+ }
+
+ std::sort(print_zs.begin(), print_zs.end());
+
+ return print_zs;
+}
+
// caller is responsible for supplying NO lines with zero length
static void thick_lines_to_indexed_vertex_array(
const Lines &lines,
@@ -2205,6 +2224,9 @@ void _3DScene::_update_gcode_volumes_visibility(const GCodePreviewData& preview_
{
case GCodePreviewVolumeIndex::Extrusion:
{
+ if ((ExtrusionRole)s_gcode_preview_volume_index.first_volumes[i].flag == erCustom)
+ volume->zoom_to_volumes = false;
+
volume->is_active = preview_data.extrusion.is_role_flag_set((ExtrusionRole)s_gcode_preview_volume_index.first_volumes[i].flag);
break;
}
diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp
index 542be3ef6..3e26bf6d3 100644
--- a/xs/src/slic3r/GUI/3DScene.hpp
+++ b/xs/src/slic3r/GUI/3DScene.hpp
@@ -372,6 +372,9 @@ public:
void set_render_interleaved_only_volumes(const RenderInterleavedOnlyVolumes& render_interleaved_only_volumes) { _render_interleaved_only_volumes = render_interleaved_only_volumes; }
+ // Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection
+ std::vector<double> get_current_print_zs() const;
+
private:
GLVolumeCollection(const GLVolumeCollection &other);
GLVolumeCollection& operator=(const GLVolumeCollection &);
diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp
index 34a14ee12..1ebd7979e 100644
--- a/xs/src/slic3r/GUI/wxExtensions.cpp
+++ b/xs/src/slic3r/GUI/wxExtensions.cpp
@@ -48,7 +48,34 @@ wxSize wxCheckListBoxComboPopup::GetAdjustedSize(int minWidth, int prefHeight, i
void wxCheckListBoxComboPopup::OnKeyEvent(wxKeyEvent& evt)
{
- // do nothing, but prevents navigation in the list using arrows keys (which is not working properly)
+ // filters out all the keys which are not working properly
+ switch (evt.GetKeyCode())
+ {
+ case WXK_LEFT:
+ case WXK_UP:
+ case WXK_RIGHT:
+ case WXK_DOWN:
+ case WXK_PAGEUP:
+ case WXK_PAGEDOWN:
+ case WXK_END:
+ case WXK_HOME:
+ case WXK_NUMPAD_LEFT:
+ case WXK_NUMPAD_UP:
+ case WXK_NUMPAD_RIGHT:
+ case WXK_NUMPAD_DOWN:
+ case WXK_NUMPAD_PAGEUP:
+ case WXK_NUMPAD_PAGEDOWN:
+ case WXK_NUMPAD_END:
+ case WXK_NUMPAD_HOME:
+ {
+ break;
+ }
+ default:
+ {
+ evt.Skip();
+ break;
+ }
+ }
}
void wxCheckListBoxComboPopup::OnCheckListBox(wxCommandEvent& evt)