GCodeAnalyzer and GCodePreviewData removed from tech ENABLE_GCODE_VIEWER

This commit is contained in:
enricoturri1966 2020-05-07 10:49:12 +02:00
parent c29f0a4849
commit 5c6a56ca29
22 changed files with 311 additions and 156 deletions

View file

@ -8,19 +8,11 @@
#include "Print.hpp"
#include <boost/log/trivial.hpp>
#if ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
#include <boost/filesystem/path.hpp>
#endif // ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
#include "Analyzer.hpp"
#include "PreviewData.hpp"
#if ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
#include <boost/nowide/fstream.hpp>
// don't worry, this is just temporary
static boost::nowide::ofstream g_debug_output;
#endif // ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
#if !ENABLE_GCODE_VIEWER
static const std::string AXIS_STR = "XYZE";
static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
@ -184,19 +176,6 @@ bool GCodeAnalyzer::is_valid_extrusion_role(ExtrusionRole role)
return ((erPerimeter <= role) && (role < erMixed));
}
#if ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
void GCodeAnalyzer::open_debug_output_file()
{
boost::filesystem::path path("d:/analyzer.output");
g_debug_output.open(path.string());
}
void GCodeAnalyzer::close_debug_output_file()
{
g_debug_output.close();
}
#endif // ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLine& line)
{
// processes 'special' comments contained in line
@ -945,23 +924,6 @@ void GCodeAnalyzer::_store_move(GCodeAnalyzer::GCodeMove::EType type)
Vec3f start_position = _get_start_position() + extruder_offset;
Vec3f end_position = _get_end_position() + extruder_offset;
it->second.emplace_back(type, _get_extrusion_role(), extruder_id, _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), start_position, end_position, _get_delta_extrusion(), _get_fan_speed(), _get_cp_color_id());
#if ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
if (g_debug_output.good())
{
g_debug_output << std::to_string(static_cast<int>(type));
g_debug_output << ", " << std::to_string(static_cast<int>(_get_extrusion_role()));
g_debug_output << ", " << Slic3r::to_string(static_cast<Vec3d>(end_position.cast<double>()));
g_debug_output << ", " << std::to_string(extruder_id);
g_debug_output << ", " << std::to_string(_get_cp_color_id());
g_debug_output << ", " << std::to_string(_get_feedrate());
g_debug_output << ", " << std::to_string(_get_width());
g_debug_output << ", " << std::to_string(_get_height());
g_debug_output << ", " << std::to_string(_get_mm3_per_mm());
g_debug_output << ", " << std::to_string(_get_fan_speed());
g_debug_output << "\n";
}
#endif // ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
}
bool GCodeAnalyzer::_is_valid_extrusion_role(int value) const
@ -1231,3 +1193,5 @@ size_t GCodeAnalyzer::memory_used() const
}
} // namespace Slic3r
#endif // !ENABLE_GCODE_VIEWER

View file

@ -1,6 +1,8 @@
#ifndef slic3r_GCode_Analyzer_hpp_
#define slic3r_GCode_Analyzer_hpp_
#if !ENABLE_GCODE_VIEWER
#include "../libslic3r.h"
#include "../PrintConfig.hpp"
#include "../ExtrusionEntity.hpp"
@ -147,11 +149,6 @@ public:
static bool is_valid_extrusion_role(ExtrusionRole role);
#if ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
void open_debug_output_file();
void close_debug_output_file();
#endif // ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
private:
// Processes the given gcode line
void _process_gcode_line(GCodeReader& reader, const GCodeReader::GCodeLine& line);
@ -307,4 +304,6 @@ private:
} // namespace Slic3r
#endif // !ENABLE_GCODE_VIEWER
#endif /* slic3r_GCode_Analyzer_hpp_ */

View file

@ -5,6 +5,8 @@
#include <boost/format.hpp>
#if !ENABLE_GCODE_VIEWER
//! macro used to mark string used at localization,
#define L(s) (s)
@ -515,3 +517,5 @@ Color operator * (float f, const Color& color)
}
} // namespace Slic3r
#endif // !ENABLE_GCODE_VIEWER

View file

@ -1,6 +1,8 @@
#ifndef slic3r_GCode_PreviewData_hpp_
#define slic3r_GCode_PreviewData_hpp_
#if !ENABLE_GCODE_VIEWER
#include "../libslic3r.h"
#include "../ExtrusionEntity.hpp"
#include "../Point.hpp"
@ -391,4 +393,6 @@ public:
} // namespace Slic3r
#endif // !ENABLE_GCODE_VIEWER
#endif /* slic3r_GCode_PreviewData_hpp_ */

View file

@ -21,9 +21,10 @@ TODO LIST
#include <vector>
#include <numeric>
#include "Analyzer.hpp"
#if ENABLE_GCODE_VIEWER
#include "GCodeProcessor.hpp"
#else
#include "Analyzer.hpp"
#endif // ENABLE_GCODE_VIEWER
#include "BoundingBox.hpp"
@ -56,16 +57,16 @@ public:
{
// adds tag for analyzer:
char buf[64];
sprintf(buf, ";%s%f\n", GCodeAnalyzer::Height_Tag.c_str(), m_layer_height); // don't rely on GCodeAnalyzer knowing the layer height - it knows nothing at priming
m_gcode += buf;
#if ENABLE_GCODE_VIEWER
sprintf(buf, ";%s%f\n", GCodeProcessor::Height_Tag.c_str(), m_layer_height); // don't rely on GCodeAnalyzer knowing the layer height - it knows nothing at priming
m_gcode += buf;
#else
sprintf(buf, ";%s%f\n", GCodeAnalyzer::Height_Tag.c_str(), m_layer_height); // don't rely on GCodeAnalyzer knowing the layer height - it knows nothing at priming
#endif // ENABLE_GCODE_VIEWER
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
#if ENABLE_GCODE_VIEWER
m_gcode += buf;
#if ENABLE_GCODE_VIEWER
sprintf(buf, ";%s%d\n", GCodeProcessor::Extrusion_Role_Tag.c_str(), erWipeTower);
#else
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
#endif // ENABLE_GCODE_VIEWER
m_gcode += buf;
change_analyzer_line_width(line_width);
@ -74,12 +75,12 @@ public:
WipeTowerWriter& change_analyzer_line_width(float line_width) {
// adds tag for analyzer:
char buf[64];
sprintf(buf, ";%s%f\n", GCodeAnalyzer::Width_Tag.c_str(), line_width);
m_gcode += buf;
#if ENABLE_GCODE_VIEWER
sprintf(buf, ";%s%f\n", GCodeProcessor::Width_Tag.c_str(), line_width);
m_gcode += buf;
#else
sprintf(buf, ";%s%f\n", GCodeAnalyzer::Width_Tag.c_str(), line_width);
#endif // ENABLE_GCODE_VIEWER
m_gcode += buf;
return *this;
}
@ -88,12 +89,12 @@ public:
float mm3_per_mm = (len == 0.f ? 0.f : area * e / len);
// adds tag for analyzer:
char buf[64];
sprintf(buf, ";%s%f\n", GCodeAnalyzer::Mm3_Per_Mm_Tag.c_str(), mm3_per_mm);
m_gcode += buf;
#if ENABLE_GCODE_VIEWER
sprintf(buf, ";%s%f\n", GCodeProcessor::Mm3_Per_Mm_Tag.c_str(), mm3_per_mm);
m_gcode += buf;
#else
sprintf(buf, ";%s%f\n", GCodeAnalyzer::Mm3_Per_Mm_Tag.c_str(), mm3_per_mm);
#endif // ENABLE_GCODE_VIEWER
m_gcode += buf;
return *this;
}