GCode Preview - Code cleanup

This commit is contained in:
Enrico Turri 2018-01-17 10:39:05 +01:00
parent c63e6b74fa
commit a417cf955d
24 changed files with 12 additions and 987 deletions

View file

@ -17,11 +17,7 @@
#include "GCode/WipeTower.hpp"
#include "GCodeTimeEstimator.hpp"
#include "EdgeGrid.hpp"
//############################################################################################################
#if ENRICO_GCODE_PREVIEW
#include "GCode/Analyzer.hpp"
#endif // ENRICO_GCODE_PREVIEW
//############################################################################################################
#include <memory>
#include <string>
@ -123,28 +119,16 @@ public:
m_enable_loop_clipping(true),
m_enable_cooling_markers(false),
m_enable_extrusion_role_markers(false),
//############################################################################################################
#if ENRICO_GCODE_PREVIEW
m_enable_analyzer(true),
#else
//############################################################################################################
m_enable_analyzer_markers(false),
//############################################################################################################
#endif // ENRICO_GCODE_PREVIEW
//############################################################################################################
m_layer_count(0),
m_layer_index(-1),
m_layer(nullptr),
m_volumetric_speed(0),
m_last_pos_defined(false),
m_last_extrusion_role(erNone),
//############################################################################################################
#if ENRICO_GCODE_PREVIEW
m_last_mm3_per_mm(GCodeAnalyzer::Default_mm3_per_mm),
m_last_width(GCodeAnalyzer::Default_Width),
m_last_height(GCodeAnalyzer::Default_Height),
#endif // ENRICO_GCODE_PREVIEW
//############################################################################################################
m_brim_done(false),
m_second_layer_things_done(false),
m_last_obj_copy(nullptr, Point(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max()))
@ -169,12 +153,8 @@ public:
// 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);
bool enable_cooling_markers() const { return m_enable_cooling_markers; }
//############################################################################################################
#if ENRICO_GCODE_PREVIEW
bool enable_analyzer() const { return m_enable_analyzer; }
void enable_analyzer(bool enable) { m_enable_analyzer = enable; }
#endif // ENRICO_GCODE_PREVIEW
//############################################################################################################
// For Perl bindings, to be used exclusively by unit tests.
unsigned int layer_count() const { return m_layer_count; }
@ -267,20 +247,10 @@ protected:
// Markers for the Pressure Equalizer to recognize the extrusion type.
// The Pressure Equalizer removes the markers from the final G-code.
bool m_enable_extrusion_role_markers;
//############################################################################################################
#if ENRICO_GCODE_PREVIEW
// Enableds the G-code Analyzer.
// Extended markers will be added during G-code generation.
// The G-code Analyzer will remove these comments from the final G-code.
bool m_enable_analyzer;
#else
//############################################################################################################
// Extended markers for the G-code Analyzer.
// The G-code Analyzer will remove these comments from the final G-code.
bool m_enable_analyzer_markers;
//############################################################################################################
#endif // ENRICO_GCODE_PREVIEW
//############################################################################################################
// How many times will change_layer() be called?
// change_layer() will update the progress bar.
unsigned int m_layer_count;
@ -293,14 +263,10 @@ protected:
double m_volumetric_speed;
// Support for the extrusion role markers. Which marker is active?
ExtrusionRole m_last_extrusion_role;
//############################################################################################################
#if ENRICO_GCODE_PREVIEW
// Support for G-Code Analyzer
double m_last_mm3_per_mm;
float m_last_width;
float m_last_height;
#endif // ENRICO_GCODE_PREVIEW
//############################################################################################################
Point m_last_pos;
bool m_last_pos_defined;
@ -322,25 +288,12 @@ protected:
// Time estimator
GCodeTimeEstimator m_time_estimator;
//############################################################################################################
#if ENRICO_GCODE_PREVIEW
// Analyzer
GCodeAnalyzer m_analyzer;
#endif // ENRICO_GCODE_PREVIEW
//############################################################################################################
// Write a string into a file.
//############################################################################################################
#if ENRICO_GCODE_PREVIEW
void _write(FILE* file, const std::string& what) { this->_write(file, what.c_str()); }
void _write(FILE* file, const char *what);
#else
//############################################################################################################
void _write(FILE* file, const std::string& what) { this->_write(file, what.c_str(), what.size()); }
void _write(FILE* file, const char *what, size_t size);
//############################################################################################################
#endif // ENRICO_GCODE_PREVIEW
//############################################################################################################
// Write a string into a file.
// Add a newline, if the string does not end with a newline already.