mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 06:09:03 +08:00
Refactoring in preview's new visualization
This commit is contained in:
parent
72d5116744
commit
f0a25c8ee0
@ -116,8 +116,8 @@ set(SLIC3R_GUI_SOURCES
|
||||
GUI/LibVGCode/Shaders.hpp
|
||||
GUI/LibVGCode/ToolMarker.hpp
|
||||
GUI/LibVGCode/ToolMarker.cpp
|
||||
GUI/LibVGCode/Toolpaths.hpp
|
||||
GUI/LibVGCode/Toolpaths.cpp
|
||||
GUI/LibVGCode/ViewerImpl.hpp
|
||||
GUI/LibVGCode/ViewerImpl.cpp
|
||||
GUI/LibVGCode/Types.hpp
|
||||
GUI/LibVGCode/Types.cpp
|
||||
GUI/LibVGCode/Utils.hpp
|
||||
|
@ -45,12 +45,6 @@
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/numformatter.h>
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//#if ENABLE_NEW_GCODE_VIEWER
|
||||
//#include "GCodeViewer/Types.hpp"
|
||||
//#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@ -884,7 +878,7 @@ void GCodeViewer::init()
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
try
|
||||
{
|
||||
m_gcode_viewer_2.init();
|
||||
m_new_viewer.init();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
@ -907,8 +901,8 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||
{
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_gcode_viewer_2.set_top_layer_only_view(get_app_config()->get_bool("seq_top_layer_only"));
|
||||
m_gcode_viewer_2.load(gcode_result, str_tool_colors);
|
||||
m_new_viewer.set_top_layer_only_view(get_app_config()->get_bool("seq_top_layer_only"));
|
||||
m_new_viewer.load(gcode_result, str_tool_colors);
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
@ -1031,7 +1025,7 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
if (m_gcode_viewer_2.get_view_type() == libvgcode::EViewType::Tool && !gcode_result.extruder_colors.empty())
|
||||
if (m_new_viewer.get_view_type() == libvgcode::EViewType::Tool && !gcode_result.extruder_colors.empty())
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
if (m_view_type == EViewType::Tool && !gcode_result.extruder_colors.empty())
|
||||
@ -1086,7 +1080,7 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
const std::array<std::vector<float>, static_cast<size_t>(libvgcode::ETimeMode::COUNT)>& layers_times = m_gcode_viewer_2.get_layers_times();
|
||||
const std::array<std::vector<float>, static_cast<size_t>(libvgcode::ETimeMode::COUNT)>& layers_times = m_new_viewer.get_layers_times();
|
||||
for (size_t i = 0; i < layers_times.size(); ++i) {
|
||||
for (float time : layers_times[i]) {
|
||||
m_extrusions.ranges.layer_time[i].update_from(time);
|
||||
@ -1176,7 +1170,7 @@ void GCodeViewer::render()
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
if (m_use_gcode_viewer_2) {
|
||||
if (m_use_new_viewer) {
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Matrix4f view_matrix = camera.get_view_matrix().matrix().cast<float>();
|
||||
const Matrix4f projection_matrix = camera.get_projection_matrix().matrix().cast<float>();
|
||||
@ -1188,10 +1182,10 @@ void GCodeViewer::render()
|
||||
libvgcode::Vec3f converted_tool_marker_position;
|
||||
std::memcpy(converted_tool_marker_position.data(), m_sequential_view.current_position.data(), 3 * sizeof(float));
|
||||
|
||||
m_gcode_viewer_2.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_gcode_viewer_2.set_tool_marker_position(converted_tool_marker_position);
|
||||
m_gcode_viewer_2.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);
|
||||
m_gcode_viewer_2.render(converted_view_matrix, converted_projetion_matrix);
|
||||
m_new_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_new_viewer.set_tool_marker_position(converted_tool_marker_position);
|
||||
m_new_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);
|
||||
m_new_viewer.render(converted_view_matrix, converted_projetion_matrix);
|
||||
}
|
||||
else
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
@ -1207,7 +1201,7 @@ void GCodeViewer::render()
|
||||
m_sequential_view.marker.set_z_offset(m_z_offset);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_sequential_view.render(legend_height, !m_use_gcode_viewer_2);
|
||||
m_sequential_view.render(legend_height, !m_use_new_viewer);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_sequential_view.render(legend_height);
|
||||
@ -1222,7 +1216,7 @@ void GCodeViewer::render()
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER_DEBUG
|
||||
if (m_use_gcode_viewer_2) {
|
||||
if (m_use_new_viewer) {
|
||||
ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui();
|
||||
imgui.begin(std::string("LibVGCode Viewer Controller"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
@ -1265,7 +1259,7 @@ void GCodeViewer::update_sequential_view_current(unsigned int first, unsigned in
|
||||
{
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_gcode_viewer_2.set_view_current_range(static_cast<uint32_t>(first), static_cast<uint32_t>(last));
|
||||
m_new_viewer.set_view_current_range(static_cast<uint32_t>(first), static_cast<uint32_t>(last));
|
||||
m_sequential_view.current.first = first;
|
||||
m_sequential_view.current.last = last;
|
||||
m_sequential_view.last_current = m_sequential_view.current;
|
||||
@ -1384,9 +1378,11 @@ void GCodeViewer::set_layers_z_range(const std::array<unsigned int, 2>& layers_z
|
||||
bool keep_sequential_current_first = layers_z_range[0] >= m_layers_z_range[0];
|
||||
bool keep_sequential_current_last = layers_z_range[1] <= m_layers_z_range[1];
|
||||
m_layers_z_range = layers_z_range;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_gcode_viewer_2.set_layers_range(static_cast<uint32_t>(layers_z_range[0]), static_cast<uint32_t>(layers_z_range[1]));
|
||||
m_new_viewer.set_layers_range(static_cast<uint32_t>(layers_z_range[0]), static_cast<uint32_t>(layers_z_range[1]));
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last);
|
||||
wxGetApp().plater()->update_preview_moves_slider();
|
||||
}
|
||||
@ -1913,7 +1909,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
bool account_for_volumetric_rate = m_gcode_viewer_2.get_view_type() == libvgcode::EViewType::VolumetricFlowRate;
|
||||
bool account_for_volumetric_rate = m_new_viewer.get_view_type() == libvgcode::EViewType::VolumetricFlowRate;
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
bool account_for_volumetric_rate = m_view_type == EViewType::VolumetricRate;
|
||||
@ -2693,7 +2689,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
ColorRGBA color;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
switch (m_gcode_viewer_2.get_view_type())
|
||||
switch (m_new_viewer.get_view_type())
|
||||
{
|
||||
case libvgcode::EViewType::FeatureType: { color = Extrusion_Role_Colors[static_cast<unsigned int>(path.role)]; break; }
|
||||
case libvgcode::EViewType::Height: { color = m_extrusions.ranges.height.get_color_at(path.height); break; }
|
||||
@ -2703,18 +2699,18 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
case libvgcode::EViewType::Temperature: { color = m_extrusions.ranges.temperature.get_color_at(path.temperature); break; }
|
||||
case libvgcode::EViewType::LayerTimeLinear:
|
||||
case libvgcode::EViewType::LayerTimeLogarithmic: {
|
||||
const std::array<std::vector<float>, static_cast<size_t>(libvgcode::ETimeMode::COUNT)>& layers_times = m_gcode_viewer_2.get_layers_times();
|
||||
const std::array<std::vector<float>, static_cast<size_t>(libvgcode::ETimeMode::COUNT)>& layers_times = m_new_viewer.get_layers_times();
|
||||
if (!layers_times.empty() && m_layers.size() == layers_times.front().size()) {
|
||||
const Path::Sub_Path& sub_path = path.sub_paths.front();
|
||||
double z = static_cast<double>(sub_path.first.position.z());
|
||||
const std::vector<double>& zs = m_layers.get_zs();
|
||||
const std::vector<Layers::Range>& ranges = m_layers.get_ranges();
|
||||
const size_t time_mode_id = static_cast<size_t>(m_gcode_viewer_2.get_time_mode());
|
||||
const size_t time_mode_id = static_cast<size_t>(m_new_viewer.get_time_mode());
|
||||
for (size_t i = 0; i < zs.size(); ++i) {
|
||||
if (std::abs(zs[i] - z) < EPSILON) {
|
||||
if (ranges[i].contains(sub_path.first.s_id)) {
|
||||
color = m_extrusions.ranges.layer_time[time_mode_id].get_color_at(layers_times[time_mode_id][i],
|
||||
(m_gcode_viewer_2.get_view_type() == libvgcode::EViewType::LayerTimeLinear) ?
|
||||
(m_new_viewer.get_view_type() == libvgcode::EViewType::LayerTimeLinear) ?
|
||||
Extrusions::Range::EType::Linear : Extrusions::Range::EType::Logarithmic);
|
||||
break;
|
||||
}
|
||||
@ -3031,7 +3027,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
if (!top_layer_only || m_sequential_view.current.last == global_endpoints.last ||
|
||||
is_travel_in_layers_range(path_id, m_layers_z_range[1], m_layers_z_range[1])) {
|
||||
const libvgcode::EViewType type = m_gcode_viewer_2.get_view_type();
|
||||
const libvgcode::EViewType type = m_new_viewer.get_view_type();
|
||||
color = (type == libvgcode::EViewType::Speed || type == libvgcode::EViewType::Tool || type == libvgcode::EViewType::ColorPrint) ?
|
||||
extrusion_color(path) : travel_color(path);
|
||||
}
|
||||
@ -3702,8 +3698,8 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
const PrintEstimatedStatistics::Mode& time_mode = m_print_statistics.modes[static_cast<size_t>(m_gcode_viewer_2.get_time_mode())];
|
||||
const libvgcode::EViewType curr_view_type = m_gcode_viewer_2.get_view_type();
|
||||
const PrintEstimatedStatistics::Mode& time_mode = m_print_statistics.modes[static_cast<size_t>(m_new_viewer.get_time_mode())];
|
||||
const libvgcode::EViewType curr_view_type = m_new_viewer.get_view_type();
|
||||
const int curr_view_type_i = static_cast<int>(curr_view_type);
|
||||
bool show_estimated_time = time_mode.time > 0.0f && (curr_view_type == libvgcode::EViewType::FeatureType ||
|
||||
curr_view_type == libvgcode::EViewType::LayerTimeLinear || curr_view_type == libvgcode::EViewType::LayerTimeLogarithmic ||
|
||||
@ -4092,7 +4088,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
std::vector<int> view_options_id;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
const std::array<std::vector<float>, static_cast<size_t>(libvgcode::ETimeMode::COUNT)>& layers_times = m_gcode_viewer_2.get_layers_times();
|
||||
const std::array<std::vector<float>, static_cast<size_t>(libvgcode::ETimeMode::COUNT)>& layers_times = m_new_viewer.get_layers_times();
|
||||
if (!layers_times.empty() && m_layers.size() == layers_times.front().size()) {
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@ -4141,13 +4137,13 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
if (curr_view_type_i != new_view_type_i) {
|
||||
m_gcode_viewer_2.set_view_type((libvgcode::EViewType)new_view_type_i);
|
||||
m_new_viewer.set_view_type((libvgcode::EViewType)new_view_type_i);
|
||||
wxGetApp().plater()->set_keep_current_preview_type(true);
|
||||
wxGetApp().plater()->refresh_print();
|
||||
view_type_changed = true;
|
||||
}
|
||||
|
||||
const libvgcode::EViewType new_view_type = m_gcode_viewer_2.get_view_type();
|
||||
const libvgcode::EViewType new_view_type = m_new_viewer.get_view_type();
|
||||
|
||||
// extrusion paths section -> title
|
||||
if (new_view_type == libvgcode::EViewType::FeatureType)
|
||||
@ -4203,7 +4199,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
visible, times[i], percents[i], max_time_percent, offsets, used_filaments_m[i], used_filaments_g[i], [this, role, visible]() {
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_gcode_viewer_2.toggle_extrusion_role_visibility((libvgcode::EGCodeExtrusionRole)role);
|
||||
m_new_viewer.toggle_extrusion_role_visibility((libvgcode::EGCodeExtrusionRole)role);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_extrusions.role_visibility_flags = visible ? m_extrusions.role_visibility_flags & ~(1 << int(role)) : m_extrusions.role_visibility_flags | (1 << int(role));
|
||||
@ -4232,8 +4228,8 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
case libvgcode::EViewType::FanSpeed: { append_range(m_extrusions.ranges.fan_speed, 0); break; }
|
||||
case libvgcode::EViewType::Temperature: { append_range(m_extrusions.ranges.temperature, 0); break; }
|
||||
case libvgcode::EViewType::VolumetricFlowRate: { append_range(m_extrusions.ranges.volumetric_rate, 3); break; }
|
||||
case libvgcode::EViewType::LayerTimeLinear: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_gcode_viewer_2.get_time_mode())], Extrusions::Range::EType::Linear); break; }
|
||||
case libvgcode::EViewType::LayerTimeLogarithmic: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_gcode_viewer_2.get_time_mode())], Extrusions::Range::EType::Logarithmic); break; }
|
||||
case libvgcode::EViewType::LayerTimeLinear: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_new_viewer.get_time_mode())], Extrusions::Range::EType::Linear); break; }
|
||||
case libvgcode::EViewType::LayerTimeLogarithmic: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_new_viewer.get_time_mode())], Extrusions::Range::EType::Logarithmic); break; }
|
||||
case libvgcode::EViewType::Tool: {
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@ -4596,7 +4592,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
if (custom_it != m_roles.end()) {
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
const bool custom_visible = m_gcode_viewer_2.is_extrusion_role_visible((libvgcode::EGCodeExtrusionRole)GCodeExtrusionRole::Custom);
|
||||
const bool custom_visible = m_new_viewer.is_extrusion_role_visible((libvgcode::EGCodeExtrusionRole)GCodeExtrusionRole::Custom);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
const bool custom_visible = is_visible(GCodeExtrusionRole::Custom);
|
||||
@ -4608,7 +4604,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
if (imgui.button(btn_text, ImVec2(-1.0f, 0.0f), true)) {
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_gcode_viewer_2.toggle_extrusion_role_visibility((libvgcode::EGCodeExtrusionRole)GCodeExtrusionRole::Custom);
|
||||
m_new_viewer.toggle_extrusion_role_visibility((libvgcode::EGCodeExtrusionRole)GCodeExtrusionRole::Custom);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_extrusions.role_visibility_flags = custom_visible ? m_extrusions.role_visibility_flags & ~(1 << int(GCodeExtrusionRole::Custom)) :
|
||||
@ -4663,7 +4659,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
const libvgcode::ETimeMode time_mode_id = m_gcode_viewer_2.get_time_mode();
|
||||
const libvgcode::ETimeMode time_mode_id = m_new_viewer.get_time_mode();
|
||||
if (can_show_mode_button(time_mode_id)) {
|
||||
switch (time_mode_id)
|
||||
{
|
||||
@ -4710,7 +4706,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
if (imgui.button(label)) {
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_gcode_viewer_2.set_time_mode(mode);
|
||||
m_new_viewer.set_time_mode(mode);
|
||||
if (new_view_type == libvgcode::EViewType::LayerTimeLinear || new_view_type == libvgcode::EViewType::LayerTimeLogarithmic)
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@ -4780,7 +4776,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
if (imgui.draw_radio_button(name, 1.5f * icon_size, active, draw_callback)) {
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_gcode_viewer_2.toggle_option_visibility((libvgcode::EOptionType)type);
|
||||
m_new_viewer.toggle_option_visibility((libvgcode::EOptionType)type);
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
unsigned int new_flags = set_flag(flags, flag, !active);
|
||||
|
@ -926,8 +926,8 @@ private:
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
libvgcode::Viewer m_gcode_viewer_2;
|
||||
bool m_use_gcode_viewer_2{ false };
|
||||
libvgcode::Viewer m_new_viewer;
|
||||
bool m_use_new_viewer{ false };
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
@ -991,8 +991,8 @@ public:
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
void set_view_type(libvgcode::EViewType type) { m_gcode_viewer_2.set_view_type(type); }
|
||||
libvgcode::EViewType get_view_type() const { return m_gcode_viewer_2.get_view_type(); }
|
||||
void set_view_type(libvgcode::EViewType type) { m_new_viewer.set_view_type(type); }
|
||||
libvgcode::EViewType get_view_type() const { return m_new_viewer.get_view_type(); }
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
EViewType get_view_type() const { return m_view_type; }
|
||||
@ -1040,10 +1040,10 @@ public:
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
bool use_gcode_viewer_2() const { return m_use_gcode_viewer_2; }
|
||||
void toggle_use_gcode_viewer_2() { m_use_gcode_viewer_2 = !m_use_gcode_viewer_2; }
|
||||
float get_cog_marker_scale_factor() const { return m_gcode_viewer_2.get_cog_marker_scale_factor(); }
|
||||
void set_cog_marker_scale_factor(float factor) { return m_gcode_viewer_2.set_cog_marker_scale_factor(factor); }
|
||||
bool use_gcode_viewer_2() const { return m_use_new_viewer; }
|
||||
void toggle_use_gcode_viewer_2() { m_use_new_viewer = !m_use_new_viewer; }
|
||||
float get_cog_marker_scale_factor() const { return m_new_viewer.get_cog_marker_scale_factor(); }
|
||||
void set_cog_marker_scale_factor(float factor) { return m_new_viewer.set_cog_marker_scale_factor(factor); }
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
@ -1059,7 +1059,7 @@ private:
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
bool is_visible(GCodeExtrusionRole role) const {
|
||||
return m_gcode_viewer_2.is_extrusion_role_visible((libvgcode::EGCodeExtrusionRole)role);
|
||||
return m_new_viewer.is_extrusion_role_visible((libvgcode::EGCodeExtrusionRole)role);
|
||||
}
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
@ -20,157 +20,157 @@ namespace libvgcode {
|
||||
|
||||
void Viewer::init()
|
||||
{
|
||||
m_toolpaths.init();
|
||||
m_impl.init();
|
||||
}
|
||||
|
||||
void Viewer::load(const Slic3r::GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
m_toolpaths.load(gcode_result, str_tool_colors);
|
||||
m_impl.load(gcode_result, str_tool_colors);
|
||||
}
|
||||
|
||||
void Viewer::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
{
|
||||
m_toolpaths.render(view_matrix, projection_matrix);
|
||||
m_impl.render(view_matrix, projection_matrix);
|
||||
}
|
||||
|
||||
EViewType Viewer::get_view_type() const
|
||||
{
|
||||
return m_toolpaths.get_view_type();
|
||||
return m_impl.get_view_type();
|
||||
}
|
||||
|
||||
void Viewer::set_view_type(EViewType type)
|
||||
{
|
||||
m_toolpaths.set_view_type(type);
|
||||
m_impl.set_view_type(type);
|
||||
}
|
||||
|
||||
ETimeMode Viewer::get_time_mode() const
|
||||
{
|
||||
return m_toolpaths.get_time_mode();
|
||||
return m_impl.get_time_mode();
|
||||
}
|
||||
|
||||
void Viewer::set_time_mode(ETimeMode mode)
|
||||
{
|
||||
m_toolpaths.set_time_mode(mode);
|
||||
m_impl.set_time_mode(mode);
|
||||
}
|
||||
|
||||
const std::array<uint32_t, 2>& Viewer::get_layers_range() const
|
||||
{
|
||||
return m_toolpaths.get_layers_range();
|
||||
return m_impl.get_layers_range();
|
||||
}
|
||||
|
||||
void Viewer::set_layers_range(const std::array<uint32_t, 2>& range)
|
||||
{
|
||||
m_toolpaths.set_layers_range(range);
|
||||
m_impl.set_layers_range(range);
|
||||
}
|
||||
|
||||
void Viewer::set_layers_range(uint32_t min, uint32_t max)
|
||||
{
|
||||
m_toolpaths.set_layers_range(min, max);
|
||||
m_impl.set_layers_range(min, max);
|
||||
}
|
||||
|
||||
bool Viewer::is_top_layer_only_view() const
|
||||
{
|
||||
return m_toolpaths.is_top_layer_only_view();
|
||||
return m_impl.is_top_layer_only_view();
|
||||
}
|
||||
|
||||
void Viewer::set_top_layer_only_view(bool top_layer_only_view)
|
||||
{
|
||||
m_toolpaths.set_top_layer_only_view(top_layer_only_view);
|
||||
m_impl.set_top_layer_only_view(top_layer_only_view);
|
||||
}
|
||||
|
||||
const std::array<std::vector<float>, static_cast<size_t>(ETimeMode::COUNT)>& Viewer::get_layers_times() const
|
||||
{
|
||||
return m_toolpaths.get_layers_times();
|
||||
return m_impl.get_layers_times();
|
||||
}
|
||||
|
||||
bool Viewer::is_option_visible(EOptionType type) const
|
||||
{
|
||||
return m_toolpaths.is_option_visible(type);
|
||||
return m_impl.is_option_visible(type);
|
||||
}
|
||||
|
||||
void Viewer::toggle_option_visibility(EOptionType type)
|
||||
{
|
||||
m_toolpaths.toggle_option_visibility(type);
|
||||
m_impl.toggle_option_visibility(type);
|
||||
}
|
||||
|
||||
bool Viewer::is_extrusion_role_visible(EGCodeExtrusionRole role) const
|
||||
{
|
||||
return m_toolpaths.is_extrusion_role_visible(role);
|
||||
return m_impl.is_extrusion_role_visible(role);
|
||||
}
|
||||
|
||||
void Viewer::toggle_extrusion_role_visibility(EGCodeExtrusionRole role)
|
||||
{
|
||||
m_toolpaths.toggle_extrusion_role_visibility(role);
|
||||
m_impl.toggle_extrusion_role_visibility(role);
|
||||
}
|
||||
|
||||
const std::array<uint32_t, 2>& Viewer::get_view_current_range() const
|
||||
{
|
||||
return m_toolpaths.get_view_current_range();
|
||||
return m_impl.get_view_current_range();
|
||||
}
|
||||
|
||||
const std::array<uint32_t, 2>& Viewer::get_view_global_range() const
|
||||
{
|
||||
return m_toolpaths.get_view_global_range();
|
||||
return m_impl.get_view_global_range();
|
||||
}
|
||||
|
||||
void Viewer::set_view_current_range(uint32_t min, uint32_t max)
|
||||
{
|
||||
m_toolpaths.set_view_current_range(min, max);
|
||||
m_impl.set_view_current_range(min, max);
|
||||
}
|
||||
|
||||
Vec3f Viewer::get_cog_position() const
|
||||
{
|
||||
return m_toolpaths.get_cog_marker_position();
|
||||
return m_impl.get_cog_marker_position();
|
||||
}
|
||||
|
||||
float Viewer::get_cog_marker_scale_factor() const
|
||||
{
|
||||
return m_toolpaths.get_cog_marker_scale_factor();
|
||||
return m_impl.get_cog_marker_scale_factor();
|
||||
}
|
||||
|
||||
void Viewer::set_cog_marker_scale_factor(float factor)
|
||||
{
|
||||
m_toolpaths.set_cog_marker_scale_factor(factor);
|
||||
m_impl.set_cog_marker_scale_factor(factor);
|
||||
}
|
||||
|
||||
const Vec3f& Viewer::get_tool_marker_position() const
|
||||
{
|
||||
return m_toolpaths.get_tool_marker_position();
|
||||
return m_impl.get_tool_marker_position();
|
||||
}
|
||||
|
||||
void Viewer::set_tool_marker_position(const Vec3f& position)
|
||||
{
|
||||
m_toolpaths.set_tool_marker_position(position);
|
||||
m_impl.set_tool_marker_position(position);
|
||||
}
|
||||
|
||||
float Viewer::get_tool_marker_scale_factor() const
|
||||
{
|
||||
return m_toolpaths.get_tool_marker_scale_factor();
|
||||
return m_impl.get_tool_marker_scale_factor();
|
||||
}
|
||||
|
||||
void Viewer::set_tool_marker_scale_factor(float factor)
|
||||
{
|
||||
m_toolpaths.set_tool_marker_scale_factor(factor);
|
||||
m_impl.set_tool_marker_scale_factor(factor);
|
||||
}
|
||||
|
||||
const Color& Viewer::get_tool_marker_color() const
|
||||
{
|
||||
return m_toolpaths.get_tool_marker_color();
|
||||
return m_impl.get_tool_marker_color();
|
||||
}
|
||||
|
||||
void Viewer::set_tool_marker_color(const Color& color)
|
||||
{
|
||||
m_toolpaths.set_tool_marker_color(color);
|
||||
m_impl.set_tool_marker_color(color);
|
||||
}
|
||||
|
||||
float Viewer::get_tool_marker_alpha() const
|
||||
{
|
||||
return m_toolpaths.get_tool_marker_alpha();
|
||||
return m_impl.get_tool_marker_alpha();
|
||||
}
|
||||
|
||||
void Viewer::set_tool_marker_alpha(float alpha)
|
||||
{
|
||||
m_toolpaths.set_tool_marker_alpha(alpha);
|
||||
m_impl.set_tool_marker_alpha(alpha);
|
||||
}
|
||||
|
||||
} // namespace libvgcode
|
||||
|
@ -10,7 +10,7 @@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
//################################################################################################################################
|
||||
|
||||
#include "Toolpaths.hpp"
|
||||
#include "ViewerImpl.hpp"
|
||||
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
@ -92,7 +92,7 @@ public:
|
||||
void set_tool_marker_alpha(float alpha);
|
||||
|
||||
private:
|
||||
Toolpaths m_toolpaths;
|
||||
ViewerImpl m_impl;
|
||||
};
|
||||
|
||||
} // namespace libvgcode
|
||||
|
@ -7,7 +7,7 @@
|
||||
///|/
|
||||
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#include "Toolpaths.hpp"
|
||||
#include "ViewerImpl.hpp"
|
||||
#include "ViewRange.hpp"
|
||||
#include "Settings.hpp"
|
||||
#include "Shaders.hpp"
|
||||
@ -451,7 +451,7 @@ static EOptionType type_to_option(EMoveType type) {
|
||||
}
|
||||
}
|
||||
|
||||
Toolpaths::~Toolpaths()
|
||||
ViewerImpl::~ViewerImpl()
|
||||
{
|
||||
reset();
|
||||
if (m_options_shader_id != 0)
|
||||
@ -460,7 +460,7 @@ Toolpaths::~Toolpaths()
|
||||
glDeleteProgram(m_segments_shader_id);
|
||||
}
|
||||
|
||||
void Toolpaths::init()
|
||||
void ViewerImpl::init()
|
||||
{
|
||||
if (m_segments_shader_id != 0)
|
||||
return;
|
||||
@ -539,7 +539,7 @@ void Toolpaths::init()
|
||||
m_tool_marker.init(32, 2.0f, 4.0f, 1.0f, 8.0f);
|
||||
}
|
||||
|
||||
void Toolpaths::load(const Slic3r::GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
|
||||
void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
if (m_settings.time_mode != ETimeMode::Normal) {
|
||||
const Slic3r::PrintEstimatedStatistics& stats = gcode_result.print_statistics;
|
||||
@ -740,7 +740,7 @@ void Toolpaths::load(const Slic3r::GCodeProcessorResult& gcode_result, const std
|
||||
m_settings.update_colors = true;
|
||||
}
|
||||
|
||||
void Toolpaths::update_enabled_entities()
|
||||
void ViewerImpl::update_enabled_entities()
|
||||
{
|
||||
std::vector<uint32_t> enabled_segments;
|
||||
std::vector<uint32_t> enabled_options;
|
||||
@ -813,7 +813,7 @@ static float encode_color(const Color& color) {
|
||||
return float(i_color);
|
||||
}
|
||||
|
||||
void Toolpaths::update_colors()
|
||||
void ViewerImpl::update_colors()
|
||||
{
|
||||
update_color_ranges();
|
||||
|
||||
@ -831,7 +831,7 @@ void Toolpaths::update_colors()
|
||||
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
|
||||
}
|
||||
|
||||
void Toolpaths::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
void ViewerImpl::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
{
|
||||
if (m_settings.update_view_global_range) {
|
||||
update_view_global_range();
|
||||
@ -863,27 +863,27 @@ void Toolpaths::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_mat
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER_DEBUG
|
||||
}
|
||||
|
||||
EViewType Toolpaths::get_view_type() const
|
||||
EViewType ViewerImpl::get_view_type() const
|
||||
{
|
||||
return m_settings.view_type;
|
||||
}
|
||||
|
||||
ETimeMode Toolpaths::get_time_mode() const
|
||||
ETimeMode ViewerImpl::get_time_mode() const
|
||||
{
|
||||
return m_settings.time_mode;
|
||||
}
|
||||
|
||||
const std::array<uint32_t, 2>& Toolpaths::get_layers_range() const
|
||||
const std::array<uint32_t, 2>& ViewerImpl::get_layers_range() const
|
||||
{
|
||||
return m_layers_range.get();
|
||||
}
|
||||
|
||||
bool Toolpaths::is_top_layer_only_view() const
|
||||
bool ViewerImpl::is_top_layer_only_view() const
|
||||
{
|
||||
return m_settings.top_layer_only_view;
|
||||
}
|
||||
|
||||
bool Toolpaths::is_option_visible(EOptionType type) const
|
||||
bool ViewerImpl::is_option_visible(EOptionType type) const
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -895,7 +895,7 @@ bool Toolpaths::is_option_visible(EOptionType type) const
|
||||
}
|
||||
}
|
||||
|
||||
bool Toolpaths::is_extrusion_role_visible(EGCodeExtrusionRole role) const
|
||||
bool ViewerImpl::is_extrusion_role_visible(EGCodeExtrusionRole role) const
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -907,37 +907,37 @@ bool Toolpaths::is_extrusion_role_visible(EGCodeExtrusionRole role) const
|
||||
}
|
||||
}
|
||||
|
||||
void Toolpaths::set_view_type(EViewType type)
|
||||
void ViewerImpl::set_view_type(EViewType type)
|
||||
{
|
||||
m_settings.view_type = type;
|
||||
m_settings.update_colors = true;
|
||||
}
|
||||
|
||||
void Toolpaths::set_time_mode(ETimeMode mode)
|
||||
void ViewerImpl::set_time_mode(ETimeMode mode)
|
||||
{
|
||||
m_settings.time_mode = mode;
|
||||
m_settings.update_colors = true;
|
||||
}
|
||||
|
||||
void Toolpaths::set_layers_range(const std::array<uint32_t, 2>& range)
|
||||
void ViewerImpl::set_layers_range(const std::array<uint32_t, 2>& range)
|
||||
{
|
||||
set_layers_range(range[0], range[1]);
|
||||
}
|
||||
|
||||
void Toolpaths::set_layers_range(uint32_t min, uint32_t max)
|
||||
void ViewerImpl::set_layers_range(uint32_t min, uint32_t max)
|
||||
{
|
||||
m_layers_range.set(min, max);
|
||||
m_settings.update_view_global_range = true;
|
||||
m_settings.update_enabled_entities = true;
|
||||
}
|
||||
|
||||
void Toolpaths::set_top_layer_only_view(bool top_layer_only_view)
|
||||
void ViewerImpl::set_top_layer_only_view(bool top_layer_only_view)
|
||||
{
|
||||
m_settings.top_layer_only_view = top_layer_only_view;
|
||||
m_settings.update_colors = true;
|
||||
}
|
||||
|
||||
void Toolpaths::toggle_option_visibility(EOptionType type)
|
||||
void ViewerImpl::toggle_option_visibility(EOptionType type)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -954,7 +954,7 @@ void Toolpaths::toggle_option_visibility(EOptionType type)
|
||||
}
|
||||
}
|
||||
|
||||
void Toolpaths::toggle_extrusion_role_visibility(EGCodeExtrusionRole role)
|
||||
void ViewerImpl::toggle_extrusion_role_visibility(EGCodeExtrusionRole role)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -969,17 +969,17 @@ void Toolpaths::toggle_extrusion_role_visibility(EGCodeExtrusionRole role)
|
||||
}
|
||||
}
|
||||
|
||||
const std::array<uint32_t, 2>& Toolpaths::get_view_current_range() const
|
||||
const std::array<uint32_t, 2>& ViewerImpl::get_view_current_range() const
|
||||
{
|
||||
return m_view_range.get_current_range();
|
||||
}
|
||||
|
||||
const std::array<uint32_t, 2>& Toolpaths::get_view_global_range() const
|
||||
const std::array<uint32_t, 2>& ViewerImpl::get_view_global_range() const
|
||||
{
|
||||
return m_view_range.get_global_range();
|
||||
}
|
||||
|
||||
void Toolpaths::set_view_current_range(uint32_t min, uint32_t max)
|
||||
void ViewerImpl::set_view_current_range(uint32_t min, uint32_t max)
|
||||
{
|
||||
uint32_t min_id = 0;
|
||||
for (size_t i = 0; i < m_vertices_map.size(); ++i) {
|
||||
@ -1016,72 +1016,72 @@ void Toolpaths::set_view_current_range(uint32_t min, uint32_t max)
|
||||
}
|
||||
}
|
||||
|
||||
const std::array<std::vector<float>, static_cast<size_t>(ETimeMode::COUNT)>& Toolpaths::get_layers_times() const
|
||||
const std::array<std::vector<float>, static_cast<size_t>(ETimeMode::COUNT)>& ViewerImpl::get_layers_times() const
|
||||
{
|
||||
return m_layers_times;
|
||||
}
|
||||
|
||||
Vec3f Toolpaths::get_cog_marker_position() const
|
||||
Vec3f ViewerImpl::get_cog_marker_position() const
|
||||
{
|
||||
return m_cog_marker.get_position();
|
||||
}
|
||||
|
||||
float Toolpaths::get_cog_marker_scale_factor() const
|
||||
float ViewerImpl::get_cog_marker_scale_factor() const
|
||||
{
|
||||
return m_cog_marker_scale_factor;
|
||||
}
|
||||
|
||||
const Vec3f& Toolpaths::get_tool_marker_position() const
|
||||
const Vec3f& ViewerImpl::get_tool_marker_position() const
|
||||
{
|
||||
return m_tool_marker.get_position();
|
||||
}
|
||||
|
||||
float Toolpaths::get_tool_marker_offset_z() const
|
||||
float ViewerImpl::get_tool_marker_offset_z() const
|
||||
{
|
||||
return m_tool_marker.get_offset_z();
|
||||
}
|
||||
|
||||
float Toolpaths::get_tool_marker_scale_factor() const
|
||||
float ViewerImpl::get_tool_marker_scale_factor() const
|
||||
{
|
||||
return m_tool_marker_scale_factor;
|
||||
}
|
||||
|
||||
const Color& Toolpaths::get_tool_marker_color() const
|
||||
const Color& ViewerImpl::get_tool_marker_color() const
|
||||
{
|
||||
return m_tool_marker.get_color();
|
||||
}
|
||||
|
||||
float Toolpaths::get_tool_marker_alpha() const
|
||||
float ViewerImpl::get_tool_marker_alpha() const
|
||||
{
|
||||
return m_tool_marker.get_alpha();
|
||||
}
|
||||
|
||||
void Toolpaths::set_cog_marker_scale_factor(float factor)
|
||||
void ViewerImpl::set_cog_marker_scale_factor(float factor)
|
||||
{
|
||||
m_cog_marker_scale_factor = std::max(factor, 0.001f);
|
||||
}
|
||||
|
||||
void Toolpaths::set_tool_marker_position(const Vec3f& position)
|
||||
void ViewerImpl::set_tool_marker_position(const Vec3f& position)
|
||||
{
|
||||
m_tool_marker.set_position(position);
|
||||
}
|
||||
|
||||
void Toolpaths::set_tool_marker_offset_z(float offset_z)
|
||||
void ViewerImpl::set_tool_marker_offset_z(float offset_z)
|
||||
{
|
||||
m_tool_marker.set_offset_z(offset_z);
|
||||
}
|
||||
|
||||
void Toolpaths::set_tool_marker_scale_factor(float factor)
|
||||
void ViewerImpl::set_tool_marker_scale_factor(float factor)
|
||||
{
|
||||
m_tool_marker_scale_factor = std::max(factor, 0.001f);
|
||||
}
|
||||
|
||||
void Toolpaths::set_tool_marker_color(const Color& color)
|
||||
void ViewerImpl::set_tool_marker_color(const Color& color)
|
||||
{
|
||||
m_tool_marker.set_color(color);
|
||||
}
|
||||
|
||||
void Toolpaths::set_tool_marker_alpha(float alpha)
|
||||
void ViewerImpl::set_tool_marker_alpha(float alpha)
|
||||
{
|
||||
m_tool_marker.set_alpha(alpha);
|
||||
}
|
||||
@ -1102,7 +1102,7 @@ static void delete_buffers(unsigned int& id)
|
||||
}
|
||||
}
|
||||
|
||||
void Toolpaths::reset()
|
||||
void ViewerImpl::reset()
|
||||
{
|
||||
m_layers.reset();
|
||||
m_layers_range.reset();
|
||||
@ -1130,7 +1130,7 @@ void Toolpaths::reset()
|
||||
delete_buffers(m_positions_buf_id);
|
||||
}
|
||||
|
||||
void Toolpaths::update_view_global_range()
|
||||
void ViewerImpl::update_view_global_range()
|
||||
{
|
||||
const std::array<uint32_t, 2>& layers_range = m_layers_range.get();
|
||||
const bool travels_visible = m_settings.options_visibility.at(EOptionType::Travels);
|
||||
@ -1177,7 +1177,7 @@ void Toolpaths::update_view_global_range()
|
||||
}
|
||||
}
|
||||
|
||||
void Toolpaths::update_color_ranges()
|
||||
void ViewerImpl::update_color_ranges()
|
||||
{
|
||||
m_width_range.reset();
|
||||
m_height_range.reset();
|
||||
@ -1210,7 +1210,7 @@ void Toolpaths::update_color_ranges()
|
||||
}
|
||||
}
|
||||
|
||||
Color Toolpaths::select_color(const PathVertex& v) const
|
||||
Color ViewerImpl::select_color(const PathVertex& v) const
|
||||
{
|
||||
if (v.type == EMoveType::Noop)
|
||||
return Dummy_Color;
|
||||
@ -1283,7 +1283,7 @@ Color Toolpaths::select_color(const PathVertex& v) const
|
||||
return Dummy_Color;
|
||||
}
|
||||
|
||||
void Toolpaths::render_segments(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix, const Vec3f& camera_position)
|
||||
void ViewerImpl::render_segments(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix, const Vec3f& camera_position)
|
||||
{
|
||||
if (m_segments_shader_id == 0)
|
||||
return;
|
||||
@ -1335,7 +1335,7 @@ void Toolpaths::render_segments(const Mat4x4f& view_matrix, const Mat4x4f& proje
|
||||
glsafe(glActiveTexture(curr_active_texture));
|
||||
}
|
||||
|
||||
void Toolpaths::render_options(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
void ViewerImpl::render_options(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
{
|
||||
if (m_options_shader_id == 0)
|
||||
return;
|
||||
@ -1386,7 +1386,7 @@ void Toolpaths::render_options(const Mat4x4f& view_matrix, const Mat4x4f& projec
|
||||
glsafe(glActiveTexture(curr_active_texture));
|
||||
}
|
||||
|
||||
void Toolpaths::render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
void ViewerImpl::render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
{
|
||||
if (m_cog_marker_shader_id == 0)
|
||||
return;
|
||||
@ -1417,7 +1417,7 @@ void Toolpaths::render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& pro
|
||||
glsafe(glUseProgram(curr_shader));
|
||||
}
|
||||
|
||||
void Toolpaths::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
void ViewerImpl::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
{
|
||||
if (m_tool_marker_shader_id == 0)
|
||||
return;
|
||||
@ -1462,7 +1462,7 @@ void Toolpaths::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& pr
|
||||
}
|
||||
|
||||
#if ENABLE_NEW_GCODE_VIEWER_DEBUG
|
||||
void Toolpaths::render_debug_window()
|
||||
void ViewerImpl::render_debug_window()
|
||||
{
|
||||
Slic3r::GUI::ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui();
|
||||
imgui.begin(std::string("LibVGCode Viewer Debug"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
@ -2,8 +2,8 @@
|
||||
///|/
|
||||
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#ifndef VGCODE_TOOLPATHS_HPP
|
||||
#define VGCODE_TOOLPATHS_HPP
|
||||
#ifndef VGCODE_VIEWERIMPL_HPP
|
||||
#define VGCODE_VIEWERIMPL_HPP
|
||||
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
@ -34,15 +34,15 @@ class Print;
|
||||
|
||||
namespace libvgcode {
|
||||
|
||||
class Toolpaths
|
||||
class ViewerImpl
|
||||
{
|
||||
public:
|
||||
Toolpaths() = default;
|
||||
~Toolpaths();
|
||||
Toolpaths(const Toolpaths& other) = delete;
|
||||
Toolpaths(Toolpaths&& other) = delete;
|
||||
Toolpaths& operator = (const Toolpaths& other) = delete;
|
||||
Toolpaths& operator = (Toolpaths&& other) = delete;
|
||||
ViewerImpl() = default;
|
||||
~ViewerImpl();
|
||||
ViewerImpl(const ViewerImpl& other) = delete;
|
||||
ViewerImpl(ViewerImpl&& other) = delete;
|
||||
ViewerImpl& operator = (const ViewerImpl& other) = delete;
|
||||
ViewerImpl& operator = (ViewerImpl&& other) = delete;
|
||||
|
||||
//
|
||||
// Initialize shader, uniform indices and segment geometry
|
||||
@ -278,4 +278,4 @@ private:
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//################################################################################################################################
|
||||
|
||||
#endif // VGCODE_TOOLPATHS_HPP
|
||||
#endif // VGCODE_VIEWERIMPL_HPP
|
Loading…
x
Reference in New Issue
Block a user