diff --git a/src/libvgcode/include/PathVertex.hpp b/src/libvgcode/include/PathVertex.hpp index 36cdd24b69..569379137b 100644 --- a/src/libvgcode/include/PathVertex.hpp +++ b/src/libvgcode/include/PathVertex.hpp @@ -44,12 +44,12 @@ struct PathVertex // Segment volumetric rate // float volumetric_rate{ 0.0f }; -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS // // Segment weight // float weight{ 0.0f }; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS // // Segment extrusion role // diff --git a/src/libvgcode/include/Types.hpp b/src/libvgcode/include/Types.hpp index f4a44769bc..7d846769a0 100644 --- a/src/libvgcode/include/Types.hpp +++ b/src/libvgcode/include/Types.hpp @@ -5,7 +5,8 @@ #ifndef VGCODE_TYPES_HPP #define VGCODE_TYPES_HPP -#define ENABLE_COG_AND_TOOL_MARKERS 0 +#define VGCODE_ENABLE_COG_AND_TOOL_MARKERS 0 +#define VGCODE_ENABLE_DEBUG_CODE 0 #include #include @@ -155,10 +156,10 @@ enum class EOptionType : uint8_t ColorChanges, PausePrints, CustomGCodes, -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS CenterOfGravity, ToolMarker, -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS COUNT }; diff --git a/src/libvgcode/include/Viewer.hpp b/src/libvgcode/include/Viewer.hpp index f83295e6c0..f8e5492c9d 100644 --- a/src/libvgcode/include/Viewer.hpp +++ b/src/libvgcode/include/Viewer.hpp @@ -43,6 +43,7 @@ public: void reset(); // // Setup the viewer content from the given data. + // See: GCodeInputData // void load(GCodeInputData&& gcode_data); // @@ -55,7 +56,7 @@ public: // ************************************************************************ // Settings // The following methods can be used to query/customize the parameters - // used to chenge the way toolpaths are rendered. + // used to render the toolpaths. // ************************************************************************ // @@ -81,218 +82,60 @@ public: // void toggle_top_layer_only_view_range(); // - // Spiral vase mode - // Whether or not the gcode was generated with spiral vase mode enabled. - // See: GCodeInputData + // Returns true if the given option is visible. // - bool is_spiral_vase_mode() const; - // - // Return the list of detected time modes. - // - std::vector get_time_modes() const; - - // - // ************************************************************************ - // Layers range - // The following methods can be used to query/customize the visualized - // layers range. - // Layers are detected during the call to load() method. - // Their count can be queried using get_layers_count() method. - // Their global range is [0..get_layers_count() - 1]. - // ************************************************************************ - // - - // - // Return the current layers range. - // - const Interval& get_layers_view_range() const; - // - // Set the current layers range with the given interval. - // Values are clamped to [0..get_layers_count() - 1]. - // - void set_layers_view_range(const Interval& range); - // - // Set the current layers range with the given min and max values. - // Values are clamped to [0..get_layers_count() - 1]. - // - void set_layers_view_range(Interval::value_type min, Interval::value_type max); - // - // Return the count of detected layers. - // - size_t get_layers_count() const; - - // - // ************************************************************************ - // Layers zs - // The following methods can be used to query the layers zs. - // Layers are detected during the call to load() method. - // Their count can be queried using get_layers_count() method. - // Their global range is [0..get_layers_count() - 1]. - // ************************************************************************ - // - - // - // Return the z of the layer with the given id - // or 0.0f if the id does not belong to [0..get_layers_count() - 1]. - // - float get_layer_z(size_t layer_id) const; - // - // Return the list of zs of the detected layers. - // - std::vector get_layers_zs() const; - // - // Return the id of the layer closest to the given z. - // - size_t get_layer_id_at(float z) const; - - // - // ************************************************************************ - // Extruders - // The following methods can be used to query informations about extruders. - // Extruders are detected during the call to load() method. - // ************************************************************************ - // - - // - // Return the count of detected used extruders. - // - size_t get_used_extruders_count() const; - // - // Return the list of ids of the detected used extruders. - // - const std::vector& get_used_extruders_ids() const; - - AABox get_bounding_box(EBBoxType type) const; - bool is_option_visible(EOptionType type) const; + // + // Toggle the visibility state of the given option. + // void toggle_option_visibility(EOptionType type); - + // + // Returns true if the given extrusion role is visible. + // bool is_extrusion_role_visible(EGCodeExtrusionRole role) const; + // + // Toggle the visibility state of the given extrusion role. + // void toggle_extrusion_role_visibility(EGCodeExtrusionRole role); - - const Interval& get_view_full_range() const; - const Interval& get_view_enabled_range() const; - const Interval& get_view_visible_range() const; - // - // Set the current visible range. - // values are clamped to the current view global range - // - void set_view_visible_range(Interval::value_type min, Interval::value_type max); - + // Return the color used to render the given extrusion rols. // - // Return the count of vertices used to render the toolpaths - // - size_t get_vertices_count() const; - - // - // Return the vertex pointed by the max value of the view visible range - // - const PathVertex& get_current_vertex() const; - - // - // Return the index of vertex pointed by the max value of the view visible range - // - size_t get_current_vertex_id() const; - - // - // Return the vertex at the given index - // - const PathVertex& get_vertex_at(size_t id) const; - - // - // Return the estimated time, in seconds, at the vertex with the given index - // using the current time mode. - // - float get_estimated_time_at(size_t id) const; - - // - // Return the color used to render the given vertex with the current settings. - // - Color get_vertex_color(const PathVertex& vertex) const; - - // - // Return the count of path segments enabled for rendering - // - size_t get_enabled_segments_count() const; - - // - // Return the Interval containing the enabled segments - // - const Interval& get_enabled_segments_range() const; - - // - // Return the count of options enabled for rendering - // - size_t get_enabled_options_count() const; - - // - // Return the Interval containing the enabled options - // - const Interval& get_enabled_options_range() const; - - // - // Return the count of detected extrusion roles - // - size_t get_extrusion_roles_count() const; - - // - // Return the list of detected extrusion roles - // - std::vector get_extrusion_roles() const; - - // - // Return the count of detected options - // - size_t get_options_count() const; - - // - // Return the list of detected options - // - const std::vector& get_options() const; - - // - // Return the estimated time for the given role and the current time mode - // - float get_extrusion_role_time(EGCodeExtrusionRole role) const; - - // - // Return the estimated time for the given role and the given time mode - // - float get_extrusion_role_time(EGCodeExtrusionRole role, ETimeMode mode) const; - - // - // Return the estimated time for the travel moves and the current time mode - // - float get_travels_time() const; - - // - // Return the estimated time for the travel moves and the given time mode - // - float get_travels_time(ETimeMode mode) const; - - // - // Return the list of layers time for the current time mode - // - std::vector get_layers_times() const; - - // - // Return the list of layers time for the given time mode - // - std::vector get_layers_times(ETimeMode mode) const; - - size_t get_tool_colors_count() const; - const Palette& get_tool_colors() const; - void set_tool_colors(const Palette& colors); - const Color& get_extrusion_role_color(EGCodeExtrusionRole role) const; + // + // Set the color used to render the given extrusion role. + // void set_extrusion_role_color(EGCodeExtrusionRole role, const Color& color); + // + // Reset the colors used to render the extrusion roles to the default value. + // void reset_default_extrusion_roles_colors(); - + // + // Return the color used to render the given option. + // const Color& get_option_color(EOptionType type) const; + // + // Set the color used to render the given option. + // void set_option_color(EOptionType type, const Color& color); + // + // Reset the colors used to render the options to the default value. + // void reset_default_options_colors(); - + // + // Return the count of colors in the palette used to render + // the toolpaths when the view type is EViewType::Tool. + // + size_t get_tool_colors_count() const; + // + // Return the palette used to render the toolpaths when + // the view type is EViewType::Tool. + // + const Palette& get_tool_colors() const; + // + // Set the palette used to render the toolpaths when + // the view type is EViewType::Tool with the given one. + // + void set_tool_colors(const Palette& colors); // // Get the color range for the given view type. // Valid view types are: @@ -320,7 +163,6 @@ public: // EViewType::LayerTimeLogarithmic // void set_color_range_palette(EViewType type, const Palette& palette); - // // Get the radius, in mm, of the cylinders used to render the travel moves. // @@ -339,8 +181,153 @@ public: // Radius is clamped to [MIN_WIPES_RADIUS_MM..MAX_WIPES_RADIUS_MM] // void set_wipes_radius(float radius); + // + // Return the count of detected layers. + // + size_t get_layers_count() const; + // + // Return the current visible layers range. + // + const Interval& get_layers_view_range() const; + // + // Set the current visible layers range with the given interval. + // Values are clamped to [0..get_layers_count() - 1]. + // + void set_layers_view_range(const Interval& range); + // + // Set the current visible layers range with the given min and max values. + // Values are clamped to [0..get_layers_count() - 1]. + // + void set_layers_view_range(Interval::value_type min, Interval::value_type max); + // + // Return the current visible range. + // Three ranges are defined: full, enabled and visible. + // For all of them the range endpoints represent: + // [0] -> min vertex id + // [1] -> max vertex id + // Full is the range of vertices that could potentially be visualized accordingly to the current settings. + // Enabled is the part of the full range that is selected for visualization accordingly to the current settings. + // Visible is the part of the enabled range that is actually visualized accordingly to the current settings. + // + const Interval& get_view_visible_range() const; + // + // Set the current visible range. + // Values are clamped to the current view enabled range; + // + void set_view_visible_range(Interval::value_type min, Interval::value_type max); + // + // Return the current full range. + // + const Interval& get_view_full_range() const; + // + // Return the current enabled range. + // + const Interval& get_view_enabled_range() const; -#if ENABLE_COG_AND_TOOL_MARKERS + // + // ************************************************************************ + // Property getters + // The following methods can be used to query detected properties. + // ************************************************************************ + // + + // + // Spiral vase mode + // Whether or not the gcode was generated with spiral vase mode enabled. + // See: GCodeInputData + // + bool is_spiral_vase_mode() const; + // + // Return the z of the layer with the given id + // or 0.0f if the id does not belong to [0..get_layers_count() - 1]. + // + float get_layer_z(size_t layer_id) const; + // + // Return the list of zs of the detected layers. + // + std::vector get_layers_zs() const; + // + // Return the id of the layer closest to the given z. + // + size_t get_layer_id_at(float z) const; + // + // Return the count of detected used extruders. + // + size_t get_used_extruders_count() const; + // + // Return the list of ids of the detected used extruders. + // + const std::vector& get_used_extruders_ids() const; + // + // Return the list of detected time modes. + // + std::vector get_time_modes() const; + // + // Return the count of vertices used to render the toolpaths + // + size_t get_vertices_count() const; + // + // Return the vertex pointed by the max value of the view visible range + // + const PathVertex& get_current_vertex() const; + // + // Return the index of vertex pointed by the max value of the view visible range + // + size_t get_current_vertex_id() const; + // + // Return the vertex at the given index + // + const PathVertex& get_vertex_at(size_t id) const; + // + // Return the estimated time, in seconds, at the vertex with the given index + // using the current time mode. + // + float get_estimated_time_at(size_t id) const; + // + // Return the color used to render the given vertex with the current settings. + // + Color get_vertex_color(const PathVertex& vertex) const; + // + // Return the count of detected extrusion roles + // + size_t get_extrusion_roles_count() const; + // + // Return the list of detected extrusion roles + // + std::vector get_extrusion_roles() const; + // + // Return the count of detected options. + // + size_t get_options_count() const; + // + // Return the list of detected options. + // + const std::vector& get_options() const; + // + // Return the estimated time for the given role and the current time mode. + // + float get_extrusion_role_time(EGCodeExtrusionRole role) const; + // + // Return the estimated time for the travel moves and the current time mode. + // + float get_travels_time() const; + // + // Return the list of layers time for the current time mode. + // + std::vector get_layers_times() const; + // + // Return the axes aligned bounding box of the toolpaths. + // + AABox get_bounding_box(EBBoxType type) const; + +#if VGCODE_ENABLE_DEBUG_CODE + size_t get_enabled_segments_count() const; + const Interval& get_enabled_segments_range() const; + size_t get_enabled_options_count() const; + const Interval& get_enabled_options_range() const; +#endif // VGCODE_ENABLE_DEBUG_CODE + +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS // // Returns the position of the center of gravity of the toolpaths. // It does not take in account extrusions of type: @@ -372,7 +359,7 @@ public: float get_tool_marker_alpha() const; void set_tool_marker_alpha(float alpha); -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS private: ViewerImpl* m_impl{ nullptr }; diff --git a/src/libvgcode/src/CogMarker.cpp b/src/libvgcode/src/CogMarker.cpp index 19852cf378..4b3271a5c3 100644 --- a/src/libvgcode/src/CogMarker.cpp +++ b/src/libvgcode/src/CogMarker.cpp @@ -10,7 +10,7 @@ #include #include -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS namespace libvgcode { @@ -163,4 +163,4 @@ Vec3 CogMarker::get_position() const } // namespace libvgcode -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS diff --git a/src/libvgcode/src/CogMarker.hpp b/src/libvgcode/src/CogMarker.hpp index b7c9a19a09..3c2dc80ef7 100644 --- a/src/libvgcode/src/CogMarker.hpp +++ b/src/libvgcode/src/CogMarker.hpp @@ -7,7 +7,7 @@ #include "../include/Types.hpp" -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS namespace libvgcode { @@ -64,6 +64,6 @@ private: } // namespace libvgcode -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #endif // VGCODE_COGMARKER_HPP \ No newline at end of file diff --git a/src/libvgcode/src/Settings.hpp b/src/libvgcode/src/Settings.hpp index e8e295826f..9b447249aa 100644 --- a/src/libvgcode/src/Settings.hpp +++ b/src/libvgcode/src/Settings.hpp @@ -40,10 +40,10 @@ struct Settings { EOptionType::ColorChanges, false }, { EOptionType::PausePrints, false }, { EOptionType::CustomGCodes, false }, -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS { EOptionType::CenterOfGravity, false }, { EOptionType::ToolMarker, true } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS } }; std::map extrusion_roles_visibility{ { diff --git a/src/libvgcode/src/Shaders.hpp b/src/libvgcode/src/Shaders.hpp index 6aad577f08..cb6aac19d3 100644 --- a/src/libvgcode/src/Shaders.hpp +++ b/src/libvgcode/src/Shaders.hpp @@ -5,7 +5,7 @@ #ifndef VGCODE_SHADERS_HPP #define VGCODE_SHADERS_HPP -// needed for tech ENABLE_COG_AND_TOOL_MARKERS +// needed for tech VGCODE_ENABLE_COG_AND_TOOL_MARKERS #include "../include/Types.hpp" namespace libvgcode { @@ -203,7 +203,7 @@ static const char* Options_Fragment_Shader = " fragmentColor = vec4(color, 1.0);\n" "}\n"; -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS static const char* Cog_Marker_Vertex_Shader = "#version 150\n" "const vec3 light_top_dir = vec3(-0.4574957, 0.4574957, 0.7624929);\n" @@ -291,7 +291,7 @@ static const char* Tool_Marker_Fragment_Shader = "void main() {\n" " fragment_color = color;\n" "}\n"; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS } // namespace libvgcode diff --git a/src/libvgcode/src/ToolMarker.cpp b/src/libvgcode/src/ToolMarker.cpp index 15713a2115..9209a03467 100644 --- a/src/libvgcode/src/ToolMarker.cpp +++ b/src/libvgcode/src/ToolMarker.cpp @@ -8,7 +8,7 @@ #include -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS namespace libvgcode { @@ -164,4 +164,4 @@ void ToolMarker::render() } // namespace libvgcode -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS diff --git a/src/libvgcode/src/ToolMarker.hpp b/src/libvgcode/src/ToolMarker.hpp index dd59c8cb8d..23b82a3ce8 100644 --- a/src/libvgcode/src/ToolMarker.hpp +++ b/src/libvgcode/src/ToolMarker.hpp @@ -7,7 +7,7 @@ #include "../include/Types.hpp" -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS #include namespace libvgcode { @@ -65,6 +65,6 @@ private: } // namespace libvgcode -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #endif // VGCODE_TOOLMARKER_HPP \ No newline at end of file diff --git a/src/libvgcode/src/Viewer.cpp b/src/libvgcode/src/Viewer.cpp index f9ef48aa88..4757deb044 100644 --- a/src/libvgcode/src/Viewer.cpp +++ b/src/libvgcode/src/Viewer.cpp @@ -72,66 +72,6 @@ void Viewer::toggle_top_layer_only_view_range() m_impl->toggle_top_layer_only_view_range(); } -bool Viewer::is_spiral_vase_mode() const -{ - return m_impl->is_spiral_vase_mode(); -} - -std::vector Viewer::get_time_modes() const -{ - return m_impl->get_time_modes(); -} - -const Interval& Viewer::get_layers_view_range() const -{ - return m_impl->get_layers_view_range(); -} - -void Viewer::set_layers_view_range(const Interval& range) -{ - m_impl->set_layers_view_range(range); -} - -void Viewer::set_layers_view_range(Interval::value_type min, Interval::value_type max) -{ - m_impl->set_layers_view_range(min, max); -} - -size_t Viewer::get_layers_count() const -{ - return m_impl->get_layers_count(); -} - -float Viewer::get_layer_z(size_t layer_id) const -{ - return m_impl->get_layer_z(layer_id); -} - -std::vector Viewer::get_layers_zs() const -{ - return m_impl->get_layers_zs(); -} - -size_t Viewer::get_layer_id_at(float z) const -{ - return m_impl->get_layer_id_at(z); -} - -size_t Viewer::get_used_extruders_count() const -{ - return m_impl->get_used_extruders_count(); -} - -const std::vector& Viewer::get_used_extruders_ids() const -{ - return m_impl->get_used_extruders_ids(); -} - -AABox Viewer::get_bounding_box(EBBoxType type) const -{ - return m_impl->get_bounding_box(type); -} - bool Viewer::is_option_visible(EOptionType type) const { return m_impl->is_option_visible(type); @@ -152,141 +92,6 @@ void Viewer::toggle_extrusion_role_visibility(EGCodeExtrusionRole role) m_impl->toggle_extrusion_role_visibility(role); } -const Interval& Viewer::get_view_full_range() const -{ - return m_impl->get_view_full_range(); -} - -const Interval& Viewer::get_view_enabled_range() const -{ - return m_impl->get_view_enabled_range(); -} - -const Interval& Viewer::get_view_visible_range() const -{ - return m_impl->get_view_visible_range(); -} - -void Viewer::set_view_visible_range(Interval::value_type min, Interval::value_type max) -{ - m_impl->set_view_visible_range(min, max); -} - -size_t Viewer::get_vertices_count() const -{ - return m_impl->get_vertices_count(); -} - -const PathVertex& Viewer::get_current_vertex() const -{ - return m_impl->get_current_vertex(); -} - -size_t Viewer::get_current_vertex_id() const -{ - return m_impl->get_current_vertex_id(); -} - -const PathVertex& Viewer::get_vertex_at(size_t id) const -{ - return m_impl->get_vertex_at(id); -} - -float Viewer::get_estimated_time_at(size_t id) const -{ - return m_impl->get_estimated_time_at(id); -} - -Color Viewer::get_vertex_color(const PathVertex& vertex) const -{ - return m_impl->get_vertex_color(vertex); -} - -size_t Viewer::get_enabled_segments_count() const -{ - return m_impl->get_enabled_segments_count(); -} - -const Interval& Viewer::get_enabled_segments_range() const -{ - return m_impl->get_enabled_segments_range(); -} - -size_t Viewer::get_enabled_options_count() const -{ - return m_impl->get_enabled_options_count(); -} - -const Interval& Viewer::get_enabled_options_range() const -{ - return m_impl->get_enabled_options_range(); -} - -size_t Viewer::get_extrusion_roles_count() const -{ - return m_impl->get_extrusion_roles_count(); -} - -std::vector Viewer::get_extrusion_roles() const -{ - return m_impl->get_extrusion_roles(); -} - -size_t Viewer::get_options_count() const -{ - return m_impl->get_options_count(); -} - -const std::vector& Viewer::get_options() const -{ - return m_impl->get_options(); -} - -float Viewer::get_extrusion_role_time(EGCodeExtrusionRole role) const -{ - return m_impl->get_extrusion_role_time(role); -} - -float Viewer::get_extrusion_role_time(EGCodeExtrusionRole role, ETimeMode mode) const -{ - return m_impl->get_extrusion_role_time(role, mode); -} - -float Viewer::get_travels_time() const -{ - return m_impl->get_travels_time(); -} - -float Viewer::get_travels_time(ETimeMode mode) const -{ - return m_impl->get_travels_time(mode); -} - -std::vector Viewer::get_layers_times() const -{ - return m_impl->get_layers_times(); -} - -std::vector Viewer::get_layers_times(ETimeMode mode) const -{ - return m_impl->get_layers_times(mode); -} - -size_t Viewer::get_tool_colors_count() const -{ - return m_impl->get_tool_colors_count(); -} - -const Palette& Viewer::get_tool_colors() const -{ - return m_impl->get_tool_colors(); -} - -void Viewer::set_tool_colors(const Palette& colors) -{ - m_impl->set_tool_colors(colors); -} - const Color& Viewer::get_extrusion_role_color(EGCodeExtrusionRole role) const { return m_impl->get_extrusion_role_color(role); @@ -317,6 +122,21 @@ void Viewer::reset_default_options_colors() m_impl->reset_default_options_colors(); } +size_t Viewer::get_tool_colors_count() const +{ + return m_impl->get_tool_colors_count(); +} + +const Palette& Viewer::get_tool_colors() const +{ + return m_impl->get_tool_colors(); +} + +void Viewer::set_tool_colors(const Palette& colors) +{ + m_impl->set_tool_colors(colors); +} + const ColorRange& Viewer::get_color_range(EViewType type) const { return m_impl->get_color_range(type); @@ -347,7 +167,174 @@ void Viewer::set_wipes_radius(float radius) m_impl->set_wipes_radius(radius); } -#if ENABLE_COG_AND_TOOL_MARKERS +size_t Viewer::get_layers_count() const +{ + return m_impl->get_layers_count(); +} + +const Interval& Viewer::get_layers_view_range() const +{ + return m_impl->get_layers_view_range(); +} + +void Viewer::set_layers_view_range(const Interval& range) +{ + m_impl->set_layers_view_range(range); +} + +void Viewer::set_layers_view_range(Interval::value_type min, Interval::value_type max) +{ + m_impl->set_layers_view_range(min, max); +} + +const Interval& Viewer::get_view_visible_range() const +{ + return m_impl->get_view_visible_range(); +} + +void Viewer::set_view_visible_range(Interval::value_type min, Interval::value_type max) +{ + m_impl->set_view_visible_range(min, max); +} + +const Interval& Viewer::get_view_full_range() const +{ + return m_impl->get_view_full_range(); +} + +const Interval& Viewer::get_view_enabled_range() const +{ + return m_impl->get_view_enabled_range(); +} + +bool Viewer::is_spiral_vase_mode() const +{ + return m_impl->is_spiral_vase_mode(); +} + +float Viewer::get_layer_z(size_t layer_id) const +{ + return m_impl->get_layer_z(layer_id); +} + +std::vector Viewer::get_layers_zs() const +{ + return m_impl->get_layers_zs(); +} + +size_t Viewer::get_layer_id_at(float z) const +{ + return m_impl->get_layer_id_at(z); +} + +size_t Viewer::get_used_extruders_count() const +{ + return m_impl->get_used_extruders_count(); +} + +const std::vector& Viewer::get_used_extruders_ids() const +{ + return m_impl->get_used_extruders_ids(); +} + +std::vector Viewer::get_time_modes() const +{ + return m_impl->get_time_modes(); +} + +size_t Viewer::get_vertices_count() const +{ + return m_impl->get_vertices_count(); +} + +const PathVertex& Viewer::get_current_vertex() const +{ + return m_impl->get_current_vertex(); +} + +size_t Viewer::get_current_vertex_id() const +{ + return m_impl->get_current_vertex_id(); +} + +const PathVertex& Viewer::get_vertex_at(size_t id) const +{ + return m_impl->get_vertex_at(id); +} + +float Viewer::get_estimated_time_at(size_t id) const +{ + return m_impl->get_estimated_time_at(id); +} + +Color Viewer::get_vertex_color(const PathVertex& vertex) const +{ + return m_impl->get_vertex_color(vertex); +} + +size_t Viewer::get_extrusion_roles_count() const +{ + return m_impl->get_extrusion_roles_count(); +} + +std::vector Viewer::get_extrusion_roles() const +{ + return m_impl->get_extrusion_roles(); +} + +size_t Viewer::get_options_count() const +{ + return m_impl->get_options_count(); +} + +const std::vector& Viewer::get_options() const +{ + return m_impl->get_options(); +} + +float Viewer::get_extrusion_role_time(EGCodeExtrusionRole role) const +{ + return m_impl->get_extrusion_role_time(role); +} + +float Viewer::get_travels_time() const +{ + return m_impl->get_travels_time(); +} + +std::vector Viewer::get_layers_times() const +{ + return m_impl->get_layers_times(); +} + +AABox Viewer::get_bounding_box(EBBoxType type) const +{ + return m_impl->get_bounding_box(type); +} + +#if VGCODE_ENABLE_DEBUG_CODE +size_t Viewer::get_enabled_segments_count() const +{ + return m_impl->get_enabled_segments_count(); +} + +const Interval& Viewer::get_enabled_segments_range() const +{ + return m_impl->get_enabled_segments_range(); +} + +size_t Viewer::get_enabled_options_count() const +{ + return m_impl->get_enabled_options_count(); +} + +const Interval& Viewer::get_enabled_options_range() const +{ + return m_impl->get_enabled_options_range(); +} +#endif // VGCODE_ENABLE_DEBUG_CODE + +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS Vec3 Viewer::get_cog_position() const { return m_impl->get_cog_marker_position(); @@ -422,6 +409,6 @@ void Viewer::set_tool_marker_alpha(float alpha) { m_impl->set_tool_marker_alpha(alpha); } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS } // namespace libvgcode diff --git a/src/libvgcode/src/ViewerImpl.cpp b/src/libvgcode/src/ViewerImpl.cpp index 271b96dfea..3ee6a6c63e 100644 --- a/src/libvgcode/src/ViewerImpl.cpp +++ b/src/libvgcode/src/ViewerImpl.cpp @@ -368,7 +368,7 @@ void ViewerImpl::init() m_option_template.init(16); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS // cog marker shader m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader, Cog_Marker_Fragment_Shader); @@ -401,7 +401,7 @@ void ViewerImpl::init() m_uni_tool_marker_color_base != -1); m_tool_marker.init(32, 2.0f, 4.0f, 1.0f, 8.0f); -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS m_initialized = true; } @@ -409,10 +409,10 @@ void ViewerImpl::init() void ViewerImpl::shutdown() { reset(); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS m_tool_marker.shutdown(); m_cog_marker.shutdown(); -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS m_option_template.shutdown(); m_segment_template.shutdown(); if (m_options_shader_id != 0) { @@ -436,9 +436,9 @@ void ViewerImpl::reset() m_used_extruders_ids.clear(); m_vertices.clear(); m_valid_lines_bitset.clear(); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS m_cog_marker.reset(); -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS m_enabled_segments_count = 0; m_enabled_options_count = 0; @@ -492,7 +492,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data) m_used_extruders_ids.emplace_back(v.extruder_id); if (i > 0) { -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS // updates calculation for center of gravity if (v.type == EMoveType::Extrude && v.role != EGCodeExtrusionRole::Skirt && @@ -502,7 +502,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data) v.role != EGCodeExtrusionRole::Custom) { m_cog_marker.update(0.5f * (v.position + m_vertices[i - 1].position), v.weight); } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS } } @@ -758,12 +758,12 @@ void ViewerImpl::render(const Mat4x4& view_matrix, const Mat4x4& projection_matr render_segments(view_matrix, projection_matrix, camera_position); render_options(view_matrix, projection_matrix); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS if (m_settings.options_visibility.at(EOptionType::ToolMarker)) render_tool_marker(view_matrix, projection_matrix); if (m_settings.options_visibility.at(EOptionType::CenterOfGravity)) render_cog_marker(view_matrix, projection_matrix); -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS } void ViewerImpl::set_view_type(EViewType type) @@ -1299,7 +1299,7 @@ void ViewerImpl::render_options(const Mat4x4& view_matrix, const Mat4x4& project glsafe(glActiveTexture(curr_active_texture)); } -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS void ViewerImpl::render_cog_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix) { if (m_cog_marker_shader_id == 0) @@ -1378,6 +1378,6 @@ void ViewerImpl::render_tool_marker(const Mat4x4& view_matrix, const Mat4x4& pro glsafe(glUseProgram(curr_shader)); } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS } // namespace libvgcode diff --git a/src/libvgcode/src/ViewerImpl.hpp b/src/libvgcode/src/ViewerImpl.hpp index 64e55ba30f..25f4d8ba07 100644 --- a/src/libvgcode/src/ViewerImpl.hpp +++ b/src/libvgcode/src/ViewerImpl.hpp @@ -8,10 +8,10 @@ #include "Settings.hpp" #include "SegmentTemplate.hpp" #include "OptionTemplate.hpp" -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS #include "CogMarker.hpp" #include "ToolMarker.hpp" -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #include "../include/PathVertex.hpp" #include "../include/ColorRange.hpp" #include "Bitset.hpp" @@ -118,26 +118,23 @@ public: float get_estimated_time_at(size_t id) const; Color get_vertex_color(const PathVertex& vertex) const; +#if VGCODE_ENABLE_DEBUG_CODE size_t get_enabled_segments_count() const { return m_enabled_segments_count; } const Interval& get_enabled_segments_range() const { return m_enabled_segments_range.get(); } size_t get_enabled_options_count() const { return m_enabled_options_count; } const Interval& get_enabled_options_range() const { return m_enabled_options_range.get(); } +#endif // VGCODE_ENABLE_DEBUG_CODE + size_t get_extrusion_roles_count() const { return m_extrusion_roles.get_roles_count(); } std::vector get_extrusion_roles() const { return m_extrusion_roles.get_roles(); } float get_extrusion_role_time(EGCodeExtrusionRole role) const { return m_extrusion_roles.get_time(role, m_settings.time_mode); } - size_t get_extrusion_roles_count() const { return m_extrusion_roles.get_roles_count(); } - float get_extrusion_role_time(EGCodeExtrusionRole role, ETimeMode mode) const { return m_extrusion_roles.get_time(role, mode); } size_t get_options_count() const { return m_options.size(); } const std::vector& get_options() const { return m_options; } - float get_travels_time() const { return get_travels_time(m_settings.time_mode); } - float get_travels_time(ETimeMode mode) const { - return (mode < ETimeMode::COUNT) ? m_travels_time[static_cast(mode)] : 0.0f; - } - std::vector get_layers_times() const { return get_layers_times(m_settings.time_mode); } - std::vector get_layers_times(ETimeMode mode) const { return m_layers.get_times(mode); } + float get_travels_time() const { return m_travels_time[static_cast(m_settings.time_mode)]; } + std::vector get_layers_times() const { return m_layers.get_times(m_settings.time_mode); } size_t get_tool_colors_count() const { return m_tool_colors.size(); } const Palette& get_tool_colors() const { return m_tool_colors; } @@ -159,7 +156,7 @@ public: float get_wipes_radius() const { return m_wipes_radius; } void set_wipes_radius(float radius); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS Vec3 get_cog_marker_position() const { return m_cog_marker.get_position(); } float get_cog_marker_scale_factor() const { return m_cog_marker_scale_factor; } @@ -182,7 +179,7 @@ public: float get_tool_marker_alpha() const { return m_tool_marker.get_alpha(); } void set_tool_marker_alpha(float alpha) { m_tool_marker.set_alpha(alpha); } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS private: Settings m_settings; @@ -211,7 +208,7 @@ private: // OptionTemplate m_option_template; -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS // // The OpenGL element used to represent the center of gravity // @@ -223,7 +220,7 @@ private: // ToolMarker m_tool_marker; float m_tool_marker_scale_factor{ 1.0f }; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS // // cpu buffer to store vertices @@ -258,10 +255,10 @@ private: // unsigned int m_segments_shader_id{ 0 }; unsigned int m_options_shader_id{ 0 }; -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS unsigned int m_cog_marker_shader_id{ 0 }; unsigned int m_tool_marker_shader_id{ 0 }; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS // // Cache for OpenGL uniforms id for segments shader @@ -284,7 +281,7 @@ private: int m_uni_options_colors_tex_id{ -1 }; int m_uni_options_segment_index_tex_id{ -1 }; -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS // // Cache for OpenGL uniforms id for cog marker shader // @@ -301,7 +298,7 @@ private: int m_uni_tool_marker_view_matrix{ -1 }; int m_uni_tool_marker_projection_matrix{ -1 }; int m_uni_tool_marker_color_base{ -1 }; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS // // gpu buffers to store positions @@ -334,10 +331,10 @@ private: void update_heights_widths(); void render_segments(const Mat4x4& view_matrix, const Mat4x4& projection_matrix, const Vec3& camera_position); void render_options(const Mat4x4& view_matrix, const Mat4x4& projection_matrix); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS void render_cog_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix); void render_tool_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix); -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS // // Palette used to render extrusion moves by extrusion roles diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 43695e22c4..f53322e7c9 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -193,11 +193,11 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessorResult::MoveVertex& move #endif // !ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS void GCodeViewer::COG::render(bool fixed_screen_size) #else void GCodeViewer::COG::render() -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #else void GCodeViewer::COG::render() #endif // ENABLE_NEW_GCODE_VIEWER @@ -206,12 +206,12 @@ void GCodeViewer::COG::render() return; #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS fixed_screen_size = true; init(fixed_screen_size); #else init(); -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #else init(); #endif // ENABLE_NEW_GCODE_VIEWER @@ -227,11 +227,11 @@ void GCodeViewer::COG::render() const Camera& camera = wxGetApp().plater()->get_camera(); Transform3d model_matrix = Geometry::translation_transform(cog()) * Geometry::scale_transform(m_scale_factor); #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS if (fixed_screen_size) { #else if (m_fixed_screen_size) { -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #else if (m_fixed_screen_size) { #endif // ENABLE_NEW_GCODE_VIEWER @@ -915,9 +915,9 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s #if ENABLE_NEW_GCODE_VIEWER void GCodeViewer::SequentialView::render(float legend_height, const libvgcode::Viewer* viewer, uint32_t gcode_id) { -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS if (viewer == nullptr) -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS marker.render(); marker.render_position_window(viewer); #else @@ -1153,7 +1153,7 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const m_viewer.reset_default_extrusion_roles_colors(); m_viewer.load(std::move(data)); -#if !ENABLE_COG_AND_TOOL_MARKERS +#if !VGCODE_ENABLE_COG_AND_TOOL_MARKERS const size_t vertices_count = m_viewer.get_vertices_count(); m_cog.reset(); for (size_t i = 1; i < vertices_count; ++i) { @@ -1169,7 +1169,7 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const m_cog.add_segment(curr_pos, prev_pos, curr.volumetric_rate / curr.feedrate * (curr_pos - prev_pos).norm()); } } -#endif // !ENABLE_COG_AND_TOOL_MARKERS +#endif // !VGCODE_ENABLE_COG_AND_TOOL_MARKERS const libvgcode::AABox bbox = m_viewer.get_bounding_box(wxGetApp().is_gcode_viewer() ? libvgcode::EBBoxType::Full : libvgcode::EBBoxType::ExtrusionNoCustom); m_paths_bounding_box.min = libvgcode::convert(bbox[0]).cast(); @@ -1492,7 +1492,7 @@ void GCodeViewer::render() #endif // !ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS if (is_legend_shown()) { ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui(); const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size(); @@ -1525,7 +1525,7 @@ void GCodeViewer::render() imgui.end(); } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER } @@ -3853,12 +3853,12 @@ void GCodeViewer::render_toolpaths() const Camera& camera = wxGetApp().plater()->get_camera(); libvgcode::Mat4x4 converted_view_matrix = libvgcode::convert(static_cast(camera.get_view_matrix().matrix().cast())); libvgcode::Mat4x4 converted_projetion_matrix = libvgcode::convert(static_cast(camera.get_projection_matrix().matrix().cast())); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS m_viewer.set_cog_marker_scale_factor(m_cog_marker_fixed_screen_size ? 10.0f * m_cog_marker_size * camera.get_inv_zoom() : m_cog_marker_size); m_viewer.enable_tool_marker(m_viewer.get_view_enabled_range()[1] != m_viewer.get_view_visible_range()[1]); m_viewer.set_tool_marker_position(m_viewer.get_current_vertex().position); m_viewer.set_tool_marker_scale_factor(m_tool_marker_fixed_screen_size ? 10.0f * m_tool_marker_size * camera.get_inv_zoom() : m_tool_marker_size); -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS m_viewer.render(converted_view_matrix, converted_projetion_matrix); #if ENABLE_NEW_GCODE_VIEWER_DEBUG @@ -3876,6 +3876,7 @@ void GCodeViewer::render_toolpaths() ImGui::TableSetColumnIndex(1); imgui.text(std::to_string(m_viewer.get_vertices_count())); +#if VGCODE_ENABLE_DEBUG_CODE ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "# enabled lines"); @@ -3891,6 +3892,7 @@ void GCodeViewer::render_toolpaths() const libvgcode::Interval& enabled_options_range = m_viewer.get_enabled_options_range(); imgui.text(std::to_string(m_viewer.get_enabled_options_count()) + " [" + std::to_string(enabled_options_range[0]) + "-" + std::to_string(enabled_options_range[1]) + "]"); +#endif // VGCODE_ENABLE_DEBUG_CODE ImGui::Separator(); @@ -3949,7 +3951,7 @@ void GCodeViewer::render_toolpaths() ImGui::EndTable(); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS ImGui::Separator(); if (ImGui::BeginTable("Cog", 2)) { @@ -4001,7 +4003,7 @@ void GCodeViewer::render_toolpaths() ImGui::EndTable(); } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS } ImGui::Separator(); @@ -5575,7 +5577,7 @@ void GCodeViewer::render_legend(float& legend_height) std::function draw_callback) { #if ENABLE_NEW_GCODE_VIEWER bool active = false; -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS active = (type == Preview::OptionType::Shells) ? m_shells.visible : m_viewer.is_option_visible(libvgcode::convert(type)); #else switch (type) @@ -5585,7 +5587,7 @@ void GCodeViewer::render_legend(float& legend_height) case Preview::OptionType::Shells: { active = m_shells.visible; break; } default: { active = m_viewer.is_option_visible(libvgcode::convert(type)); break; } } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #else auto is_flag_set = [](unsigned int flags, unsigned int flag) { return (flags & (1 << flag)) != 0; @@ -5611,7 +5613,7 @@ void GCodeViewer::render_legend(float& legend_height) --view_visible_range[0]; } const bool keep_visible_range = view_visible_range != view_enabled_range; -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS if (type == Preview::OptionType::Shells) m_shells.visible = !active; else @@ -5627,7 +5629,7 @@ void GCodeViewer::render_legend(float& legend_height) break; } } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS std::optional view_visible_range_min = keep_visible_range ? std::optional{ static_cast(view_visible_range[0]) } : std::nullopt; std::optional view_visible_range_max = keep_visible_range ? std::optional{ static_cast(view_visible_range[1]) } : std::nullopt; wxGetApp().plater()->update_preview_moves_slider(view_visible_range_min, view_visible_range_max); diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index c76413ca53..60b40b3129 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -14,7 +14,7 @@ #if ENABLE_NEW_GCODE_VIEWER #include "LibVGCode/LibVGCodeWrapper.hpp" -// needed for tech ENABLE_COG_AND_TOOL_MARKERS +// needed for tech VGCODE_ENABLE_COG_AND_TOOL_MARKERS #include #endif // ENABLE_NEW_GCODE_VIEWER @@ -399,10 +399,10 @@ class GCodeViewer GLModel m_model; bool m_visible{ false }; #if ENABLE_NEW_GCODE_VIEWER -#if !ENABLE_COG_AND_TOOL_MARKERS +#if !VGCODE_ENABLE_COG_AND_TOOL_MARKERS // whether or not to render the model with fixed screen size bool m_fixed_screen_size{ true }; -#endif // !ENABLE_COG_AND_TOOL_MARKERS +#endif // !VGCODE_ENABLE_COG_AND_TOOL_MARKERS #else // whether or not to render the model with fixed screen size bool m_fixed_screen_size{ true }; @@ -413,11 +413,11 @@ class GCodeViewer public: #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS void render(bool fixed_screen_size); #else void render(); -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #else void render(); #endif // ENABLE_NEW_GCODE_VIEWER @@ -447,11 +447,11 @@ class GCodeViewer private: #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS void init(bool fixed_screen_size) { #else void init() { -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #else void init() { #endif // ENABLE_NEW_GCODE_VIEWER @@ -459,11 +459,11 @@ class GCodeViewer return; #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS const float radius = fixed_screen_size ? 10.0f : 1.0f; #else const float radius = m_fixed_screen_size ? 10.0f : 1.0f; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #else const float radius = m_fixed_screen_size ? 10.0f : 1.0f; #endif // ENABLE_NEW_GCODE_VIEWER @@ -857,13 +857,13 @@ private: Shells m_shells; COG m_cog; #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS // whether or not to render the cog model with fixed screen size bool m_cog_marker_fixed_screen_size{ true }; float m_cog_marker_size{ 1.0f }; bool m_tool_marker_fixed_screen_size{ false }; float m_tool_marker_size{ 1.0f }; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS bool m_legend_visible{ true }; bool m_legend_enabled{ true }; struct ViewTypeCache @@ -926,11 +926,11 @@ public: void reset(); void render(); #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS void render_cog() { m_cog.render(m_cog_marker_fixed_screen_size); } #else void render_cog() { m_cog.render(); } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS bool has_data() const { return !m_viewer.get_extrusion_roles().empty(); } #else void render_cog() { m_cog.render(); } @@ -963,7 +963,6 @@ public: return ret; } std::vector get_layers_times() const { return m_viewer.get_layers_times(); } - std::vector get_layers_times(libvgcode::ETimeMode mode) const { return m_viewer.get_layers_times(mode); } #else const std::vector& get_layers_zs() const { return m_layers.get_zs(); } #endif // ENABLE_NEW_GCODE_VIEWER @@ -1035,10 +1034,10 @@ public: void load_shells(const Print& print); #if ENABLE_NEW_GCODE_VIEWER -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS float get_cog_marker_scale_factor() const { return m_viewer.get_cog_marker_scale_factor(); } void set_cog_marker_scale_factor(float factor) { return m_viewer.set_cog_marker_scale_factor(factor); } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_VIEWER private: diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index ee723eb83f..617e789415 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -841,8 +841,6 @@ public: #if ENABLE_NEW_GCODE_VIEWER std::vector get_gcode_layers_zs() const; std::vector get_gcode_layers_times() const { return m_gcode_viewer.get_layers_times(); } - std::vector get_gcode_layers_times(libvgcode::ETimeMode mode) const { return m_gcode_viewer.get_layers_times(mode); } - const std::vector& get_gcode_layers_times_cache() const { return m_gcode_layers_times_cache; } void reset_gcode_layers_times_cache() { m_gcode_layers_times_cache.clear(); } #else diff --git a/src/slic3r/GUI/LibVGCode/LibVGCodeWrapper.cpp b/src/slic3r/GUI/LibVGCode/LibVGCodeWrapper.cpp index 006f5e2dc1..a2c2782bf6 100644 --- a/src/slic3r/GUI/LibVGCode/LibVGCodeWrapper.cpp +++ b/src/slic3r/GUI/LibVGCode/LibVGCodeWrapper.cpp @@ -116,13 +116,13 @@ EOptionType convert(const Slic3r::GUI::Preview::OptionType& type) case Slic3r::GUI::Preview::OptionType::ColorChanges: { return EOptionType::ColorChanges; } case Slic3r::GUI::Preview::OptionType::PausePrints: { return EOptionType::PausePrints; } case Slic3r::GUI::Preview::OptionType::CustomGCodes: { return EOptionType::CustomGCodes; } -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS case Slic3r::GUI::Preview::OptionType::CenterOfGravity: { return EOptionType::CenterOfGravity; } case Slic3r::GUI::Preview::OptionType::ToolMarker: { return EOptionType::ToolMarker; } #else case Slic3r::GUI::Preview::OptionType::CenterOfGravity: { return EOptionType::COUNT; } case Slic3r::GUI::Preview::OptionType::ToolMarker: { return EOptionType::COUNT; } -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS default: { return EOptionType::COUNT; } } } @@ -187,7 +187,7 @@ GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels // to allow libvgcode to properly detect the start/end of a path we need to add a 'phantom' vertex // equal to the current one with the exception of the position, which should match the previous move position, // and the times, which are set to zero -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed, curr.temperature, curr.volumetric_rate(), 0.0f, convert(curr.extrusion_role), curr_type, static_cast(curr.gcode_id), static_cast(curr.layer_id), @@ -197,12 +197,12 @@ GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels curr.temperature, curr.volumetric_rate(), convert(curr.extrusion_role), curr_type, static_cast(curr.gcode_id), static_cast(curr.layer_id), static_cast(curr.extruder_id), static_cast(curr.cp_color_id), { 0.0f, 0.0f } }; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS ret.vertices.emplace_back(vertex); } } -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed, curr.temperature, curr.volumetric_rate(), curr.mm3_per_mm * (curr.position - prev.position).norm(), convert(curr.extrusion_role), curr_type, static_cast(curr.gcode_id), static_cast(curr.layer_id), @@ -211,7 +211,7 @@ GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed, curr.temperature, curr.volumetric_rate(), convert(curr.extrusion_role), curr_type, static_cast(curr.gcode_id), static_cast(curr.layer_id), static_cast(curr.extruder_id), static_cast(curr.cp_color_id), curr.time }; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS ret.vertices.emplace_back(vertex); } ret.vertices.shrink_to_fit(); @@ -236,7 +236,7 @@ static void convert_lines_to_vertices(const Slic3r::Lines& lines, const std::vec if (ii == 0) { // add a dummy vertex at the start, to separate the current line from the others const Slic3r::Vec2f a = unscale(line.a).cast(); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(a.x(), a.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, extrusion_role, EMoveType::Noop, 0, static_cast(layer_id), static_cast(extruder_id), static_cast(color_id), { 0.0f, 0.0f } }; @@ -244,7 +244,7 @@ static void convert_lines_to_vertices(const Slic3r::Lines& lines, const std::vec libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(a.x(), a.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f, 0.0f, 0.0f, extrusion_role, EMoveType::Noop, 0, static_cast(layer_id), static_cast(extruder_id), static_cast(color_id), { 0.0f, 0.0f } }; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS vertices.emplace_back(vertex); // add the starting vertex of the segment vertex.type = EMoveType::Extrude; @@ -252,7 +252,7 @@ static void convert_lines_to_vertices(const Slic3r::Lines& lines, const std::vec } // add the ending vertex of the segment const Slic3r::Vec2f b = unscale(line.b).cast(); -#if ENABLE_COG_AND_TOOL_MARKERS +#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS const libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(b.x(), b.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, extrusion_role, EMoveType::Extrude, 0, static_cast(layer_id), static_cast(extruder_id), static_cast(color_id), { 0.0f, 0.0f } }; @@ -260,7 +260,7 @@ static void convert_lines_to_vertices(const Slic3r::Lines& lines, const std::vec const libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(b.x(), b.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f, 0.0f, 0.0f, extrusion_role, EMoveType::Extrude, 0, static_cast(layer_id), static_cast(extruder_id), static_cast(color_id), { 0.0f, 0.0f } }; -#endif // ENABLE_COG_AND_TOOL_MARKERS +#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS vertices.emplace_back(vertex); } }