mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 21:35:56 +08:00
New gcode visualization integration - Tool colors
This commit is contained in:
parent
d3fd11dad9
commit
e484726a98
@ -101,6 +101,8 @@ set(SLIC3R_GUI_SOURCES
|
||||
GUI/LibVGCode/ColorRange.cpp
|
||||
GUI/LibVGCode/ExtrusionRoles.hpp
|
||||
GUI/LibVGCode/ExtrusionRoles.cpp
|
||||
GUI/LibVGCode/GCodeInputData.hpp
|
||||
GUI/LibVGCode/GCodeInputData.cpp
|
||||
GUI/LibVGCode/Layers.hpp
|
||||
GUI/LibVGCode/Layers.cpp
|
||||
GUI/LibVGCode/OpenGLUtils.hpp
|
||||
|
@ -59,6 +59,11 @@ static ColorRGBA convert(const libvgcode::Color& c)
|
||||
return { c[0], c[1], c[2], 1.0f };
|
||||
}
|
||||
|
||||
static libvgcode::Color convert(const ColorRGBA& c)
|
||||
{
|
||||
return { c.r(), c.g(), c.b() };
|
||||
}
|
||||
|
||||
static GCodeExtrusionRole convert(libvgcode::EGCodeExtrusionRole role)
|
||||
{
|
||||
switch (role)
|
||||
@ -1168,42 +1173,60 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& print)
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
{
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
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
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
std::vector<ColorRGBA> tool_colors;
|
||||
if (m_new_viewer.get_view_type() == libvgcode::EViewType::Tool && !gcode_result.extruder_colors.empty())
|
||||
// update tool colors from config stored in the gcode
|
||||
decode_colors(gcode_result.extruder_colors, tool_colors);
|
||||
else
|
||||
// update tool colors
|
||||
decode_colors(str_tool_colors, tool_colors);
|
||||
|
||||
// ensure there are enough colors defined
|
||||
const ColorRGBA default_color = { 1.0f, 0.5f, 0.0f, 1.0f }; // "#FF8000"
|
||||
while (tool_colors.size() < std::max<size_t>(1, gcode_result.extruders_count)) {
|
||||
tool_colors.push_back(default_color);
|
||||
}
|
||||
|
||||
std::vector<libvgcode::Color> colors;
|
||||
colors.reserve(tool_colors.size());
|
||||
for (const ColorRGBA& color : tool_colors) {
|
||||
colors.emplace_back(convert(color));
|
||||
}
|
||||
m_new_viewer.set_tool_colors(colors);
|
||||
|
||||
// avoid processing if called with the same gcode_result
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
if (m_last_result_id == gcode_result.id) // << TODO: check this
|
||||
if (m_last_result_id == gcode_result.id)
|
||||
return;
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
if (m_last_result_id == gcode_result.id &&
|
||||
(m_last_view_type == m_view_type || (m_last_view_type != EViewType::VolumetricRate && m_view_type != EViewType::VolumetricRate)))
|
||||
return;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
m_last_result_id = gcode_result.id;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_last_view_type = m_view_type;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
// release gpu memory, if used
|
||||
reset();
|
||||
|
||||
libvgcode::GCodeInputData data;
|
||||
m_new_viewer.load(gcode_result, data);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
// avoid processing if called with the same gcode_result
|
||||
if (m_last_result_id == gcode_result.id &&
|
||||
(m_last_view_type == m_view_type || (m_last_view_type != EViewType::VolumetricRate && m_view_type != EViewType::VolumetricRate)))
|
||||
return;
|
||||
|
||||
m_last_result_id = gcode_result.id;
|
||||
m_last_view_type = m_view_type;
|
||||
// release gpu memory, if used
|
||||
reset();
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
m_sequential_view.gcode_window.load_gcode(gcode_result);
|
||||
|
||||
if (wxGetApp().is_gcode_viewer())
|
||||
@ -1284,7 +1307,15 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||
m_conflict_result->layer = m_layers.get_l_at(m_conflict_result->_height);
|
||||
}
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result)
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
{
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
auto start_time = std::chrono::high_resolution_clock::now();
|
||||
@ -1295,15 +1326,10 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
|
||||
|
||||
wxBusyCursor busy;
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
if (m_new_viewer.get_view_type() == libvgcode::EViewType::Tool && !gcode_result.extruder_colors.empty())
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
if (m_view_type == EViewType::Tool && !gcode_result.extruder_colors.empty())
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
// update tool colors from config stored in the gcode
|
||||
decode_colors(gcode_result.extruder_colors, m_tool_colors);
|
||||
else
|
||||
@ -1316,6 +1342,9 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
|
||||
// ensure there are enough colors defined
|
||||
while (m_tool_colors.size() < std::max(size_t(1), gcode_result.extruders_count))
|
||||
m_tool_colors.push_back(default_color);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
// update ranges for coloring / legend
|
||||
m_extrusions.reset_ranges();
|
||||
@ -1403,6 +1432,12 @@ void GCodeViewer::update_shells_color_by_extruder(const DynamicPrintConfig* conf
|
||||
|
||||
void GCodeViewer::reset()
|
||||
{
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_new_viewer.reset();
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
m_moves_count = 0;
|
||||
for (TBuffer& buffer : m_buffers) {
|
||||
buffer.reset();
|
||||
@ -1412,7 +1447,13 @@ void GCodeViewer::reset()
|
||||
m_max_bounding_box.reset();
|
||||
m_max_print_height = 0.0f;
|
||||
m_z_offset = 0.0f;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_tool_colors = std::vector<ColorRGBA>();
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_extruders_count = 0;
|
||||
m_extruder_ids = std::vector<unsigned char>();
|
||||
m_filament_diameters = std::vector<float>();
|
||||
@ -1420,13 +1461,13 @@ void GCodeViewer::reset()
|
||||
m_extrusions.reset_ranges();
|
||||
m_layers.reset();
|
||||
m_layers_z_range = { 0, 0 };
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_roles = std::vector<GCodeExtrusionRole>();
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_print_statistics.reset();
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
@ -3004,7 +3045,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
|
||||
auto extrusion_color = [this](const Path& path) {
|
||||
ColorRGBA color;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
switch (m_new_viewer.get_view_type())
|
||||
{
|
||||
@ -3037,19 +3078,16 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
break;
|
||||
}
|
||||
case libvgcode::EViewType::VolumetricFlowRate: { color = m_extrusions.ranges.volumetric_rate.get_color_at(path.volumetric_rate); break; }
|
||||
case libvgcode::EViewType::Tool: { color = m_tool_colors[path.extruder_id]; break; }
|
||||
case libvgcode::EViewType::Tool: { color = convert(m_new_viewer.get_tool_colors()[path.extruder_id]); break; }
|
||||
case libvgcode::EViewType::ColorPrint: {
|
||||
if (path.cp_color_id >= static_cast<unsigned char>(m_tool_colors.size()))
|
||||
color = ColorRGBA::GRAY();
|
||||
else
|
||||
color = m_tool_colors[path.cp_color_id];
|
||||
|
||||
color = (path.cp_color_id >= m_new_viewer.get_tool_colors_count()) ?
|
||||
ColorRGBA::GRAY() : convert(m_new_viewer.get_tool_colors()[path.cp_color_id]);
|
||||
break;
|
||||
}
|
||||
default: { color = ColorRGBA::WHITE(); break; }
|
||||
}
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
switch (m_view_type)
|
||||
{
|
||||
case EViewType::FeatureType: { color = Extrusion_Role_Colors[static_cast<unsigned int>(path.role)]; break; }
|
||||
@ -3090,9 +3128,9 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
}
|
||||
default: { color = ColorRGBA::WHITE(); break; }
|
||||
}
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
return color;
|
||||
};
|
||||
@ -4679,7 +4717,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
|
||||
break;
|
||||
}
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
case libvgcode::EViewType::Height: { append_range(m_extrusions.ranges.height, 3); break; }
|
||||
case libvgcode::EViewType::Width: { append_range(m_extrusions.ranges.width, 3); break; }
|
||||
@ -4690,8 +4728,17 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
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: {
|
||||
// shows only extruders actually used
|
||||
for (unsigned char extruder_id : m_extruder_ids) {
|
||||
if (used_filaments_m[extruder_id] > 0.0 && used_filaments_g[extruder_id] > 0.0)
|
||||
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors()[extruder_id]), _u8L("Extruder") + " " + std::to_string(extruder_id + 1),
|
||||
true, "", 0.0f, 0.0f, offsets, used_filaments_m[extruder_id], used_filaments_g[extruder_id]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case libvgcode::EViewType::ColorPrint:
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
case EViewType::Height: { append_range(m_extrusions.ranges.height, 3); break; }
|
||||
case EViewType::Width: { append_range(m_extrusions.ranges.width, 3); break; }
|
||||
case EViewType::Feedrate: { append_range(m_extrusions.ranges.feedrate, 1); break; }
|
||||
@ -4701,26 +4748,18 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
case EViewType::LayerTimeLinear: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_time_estimate_mode)], Extrusions::Range::EType::Linear); break; }
|
||||
case EViewType::LayerTimeLogarithmic: { append_time_range(m_extrusions.ranges.layer_time[static_cast<size_t>(m_time_estimate_mode)], Extrusions::Range::EType::Logarithmic); break; }
|
||||
case EViewType::Tool: {
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
// shows only extruders actually used
|
||||
for (unsigned char extruder_id : m_extruder_ids) {
|
||||
if (used_filaments_m[extruder_id] > 0.0 && used_filaments_g[extruder_id] > 0.0)
|
||||
append_item(EItemType::Rect, m_tool_colors[extruder_id], _u8L("Extruder") + " " + std::to_string(extruder_id + 1),
|
||||
true, "", 0.0f, 0.0f, offsets, used_filaments_m[extruder_id], used_filaments_g[extruder_id]);
|
||||
true, "", 0.0f, 0.0f, offsets, used_filaments_m[extruder_id], used_filaments_g[extruder_id]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
case libvgcode::EViewType::ColorPrint:
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
case EViewType::ColorPrint:
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
{
|
||||
const std::vector<CustomGCode::Item>& custom_gcode_per_print_z = wxGetApp().is_editor() ? wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes : m_custom_gcode_per_print_z;
|
||||
size_t total_items = 1;
|
||||
@ -4737,12 +4776,28 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
const std::vector<std::pair<ColorRGBA, std::pair<double, double>>> cp_values = color_print_ranges(0, custom_gcode_per_print_z);
|
||||
const int items_cnt = static_cast<int>(cp_values.size());
|
||||
if (items_cnt == 0) // There are no color changes, but there are some pause print or custom Gcode
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors().front()), _u8L("Default color"));
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
append_item(EItemType::Rect, m_tool_colors.front(), _u8L("Default color"));
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
else {
|
||||
for (int i = items_cnt; i >= 0; --i) {
|
||||
// create label for color change item
|
||||
if (i == 0) {
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors().front()), upto_label(cp_values.front().second.first));
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
append_item(EItemType::Rect, m_tool_colors[0], upto_label(cp_values.front().second.first));
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
break;
|
||||
}
|
||||
else if (i == items_cnt) {
|
||||
@ -4760,14 +4815,31 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
const int items_cnt = static_cast<int>(cp_values.size());
|
||||
if (items_cnt == 0)
|
||||
// There are no color changes, but there are some pause print or custom Gcode
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors()[i]), _u8L("Extruder") + " " +
|
||||
std::to_string(i + 1) + " " + _u8L("default color"));
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
append_item(EItemType::Rect, m_tool_colors[i], _u8L("Extruder") + " " + std::to_string(i + 1) + " " + _u8L("default color"));
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
else {
|
||||
for (int j = items_cnt; j >= 0; --j) {
|
||||
// create label for color change item
|
||||
std::string label = _u8L("Extruder") + " " + std::to_string(i + 1);
|
||||
if (j == 0) {
|
||||
label += " " + upto_label(cp_values.front().second.first);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
append_item(EItemType::Rect, convert(m_new_viewer.get_tool_colors()[i]), label);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
append_item(EItemType::Rect, m_tool_colors[i], label);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
break;
|
||||
}
|
||||
else if (j == items_cnt) {
|
||||
@ -4828,7 +4900,15 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
std::vector<CustomGCode::Item> custom_gcode_per_print_z = wxGetApp().is_editor() ? wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes : m_custom_gcode_per_print_z;
|
||||
std::vector<ColorRGBA> last_color(m_extruders_count);
|
||||
for (size_t i = 0; i < m_extruders_count; ++i) {
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
last_color[i] = convert(m_new_viewer.get_tool_colors()[i]);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
last_color[i] = m_tool_colors[i];
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
}
|
||||
int last_extruder_id = 1;
|
||||
int color_change_idx = 0;
|
||||
@ -5488,6 +5568,7 @@ ColorRGBA GCodeViewer::option_color(EMoveType move_type) const
|
||||
case EMoveType::Retract: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::Retract)); }
|
||||
case EMoveType::Unretract: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::Unretract)); }
|
||||
case EMoveType::Seam: { return convert(libvgcode::Options_Colors.at(libvgcode::EMoveType::Seam)); }
|
||||
default: { return convert(libvgcode::Dummy_Color); }
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
case EMoveType::Tool_change: { return Options_Colors[static_cast<unsigned int>(EOptionsColors::ToolChanges)]; }
|
||||
@ -5497,10 +5578,10 @@ ColorRGBA GCodeViewer::option_color(EMoveType move_type) const
|
||||
case EMoveType::Retract: { return Options_Colors[static_cast<unsigned int>(EOptionsColors::Retractions)]; }
|
||||
case EMoveType::Unretract: { return Options_Colors[static_cast<unsigned int>(EOptionsColors::Unretractions)]; }
|
||||
case EMoveType::Seam: { return Options_Colors[static_cast<unsigned int>(EOptionsColors::Seams)]; }
|
||||
default: { return { 0.0f, 0.0f, 0.0f, 1.0f }; }
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
default: { return { 0.0f, 0.0f, 0.0f, 1.0f }; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -890,7 +890,13 @@ private:
|
||||
BoundingBoxf3 m_max_bounding_box;
|
||||
float m_max_print_height{ 0.0f };
|
||||
float m_z_offset{ 0.0f };
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
std::vector<ColorRGBA> m_tool_colors;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
Layers m_layers;
|
||||
std::array<unsigned int, 2> m_layers_z_range;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@ -984,7 +990,15 @@ public:
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
// recalculate ranges in dependence of what is visible and sets tool/print colors
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
void refresh(const GCodeProcessorResult& gcode_result);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void refresh(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void refresh_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) const;
|
||||
void update_shells_color_by_extruder(const DynamicPrintConfig* config);
|
||||
|
||||
|
@ -2716,7 +2716,15 @@ void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, co
|
||||
_set_warning_notification_if_needed(EWarning::GCodeConflict);
|
||||
}
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_gcode_viewer.refresh(gcode_result);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_gcode_viewer.refresh(gcode_result, str_tool_colors);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
set_as_dirty();
|
||||
request_extra_frame();
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ void ExtrusionRoles::add(EGCodeExtrusionRole role, const std::array<float, stati
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ExtrusionRoles::get_roles_count() const
|
||||
size_t ExtrusionRoles::get_roles_count() const
|
||||
{
|
||||
return static_cast<uint32_t>(m_items.size());
|
||||
return m_items.size();
|
||||
}
|
||||
|
||||
std::vector<EGCodeExtrusionRole> ExtrusionRoles::get_roles() const
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
|
||||
void add(EGCodeExtrusionRole role, const std::array<float, static_cast<size_t>(ETimeMode::COUNT)>& times);
|
||||
|
||||
uint32_t get_roles_count() const;
|
||||
size_t get_roles_count() const;
|
||||
std::vector<EGCodeExtrusionRole> get_roles() const;
|
||||
float get_time(EGCodeExtrusionRole role, ETimeMode mode) const;
|
||||
|
||||
|
24
src/slic3r/GUI/LibVGCode/GCodeInputData.cpp
Normal file
24
src/slic3r/GUI/LibVGCode/GCodeInputData.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
#include "libslic3r/Technologies.hpp"
|
||||
//################################################################################################################################
|
||||
|
||||
///|/ Copyright (c) Prusa Research 2023 Enrico Turri @enricoturri1966
|
||||
///|/
|
||||
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#include "GCodeInputData.hpp"
|
||||
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
//################################################################################################################################
|
||||
|
||||
namespace libvgcode {
|
||||
|
||||
} // namespace libvgcode
|
||||
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//################################################################################################################################
|
29
src/slic3r/GUI/LibVGCode/GCodeInputData.hpp
Normal file
29
src/slic3r/GUI/LibVGCode/GCodeInputData.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
///|/ Copyright (c) Prusa Research 2023 Enrico Turri @enricoturri1966
|
||||
///|/
|
||||
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#ifndef VGCODE_GCODEINPUTDATA_HPP
|
||||
#define VGCODE_GCODEINPUTDATA_HPP
|
||||
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
//################################################################################################################################
|
||||
|
||||
//#include "Types.hpp"
|
||||
|
||||
namespace libvgcode {
|
||||
|
||||
struct GCodeInputData
|
||||
{
|
||||
// std::vector<Color> tool_colors;
|
||||
};
|
||||
|
||||
} // namespace libvgcode
|
||||
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//################################################################################################################################
|
||||
|
||||
#endif // VGCODE_BITSET_HPP
|
@ -123,7 +123,6 @@ enum class ETimeMode : uint8_t
|
||||
//
|
||||
static const Color Dummy_Color{ 0.25f, 0.25f, 0.25f };
|
||||
static const Color Wipe_Color{ 1.0f, 1.0f, 0.0f };
|
||||
static const Color Default_Tool_Color{ 1.0f, 0.502f, 0.0f };
|
||||
|
||||
//
|
||||
// Palette used to render moves by ranges
|
||||
|
@ -23,9 +23,14 @@ void Viewer::init()
|
||||
m_impl.init();
|
||||
}
|
||||
|
||||
void Viewer::load(const Slic3r::GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
|
||||
void Viewer::reset()
|
||||
{
|
||||
m_impl.load(gcode_result, str_tool_colors);
|
||||
m_impl.reset();
|
||||
}
|
||||
|
||||
void Viewer::load(const Slic3r::GCodeProcessorResult& gcode_result, const GCodeInputData& gcode_data)
|
||||
{
|
||||
m_impl.load(gcode_result, gcode_data);
|
||||
}
|
||||
|
||||
void Viewer::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||
@ -168,6 +173,21 @@ std::vector<float> 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 std::vector<Color>& Viewer::get_tool_colors() const
|
||||
{
|
||||
return m_impl.get_tool_colors();
|
||||
}
|
||||
|
||||
void Viewer::set_tool_colors(const std::vector<Color>& colors)
|
||||
{
|
||||
m_impl.set_tool_colors(colors);
|
||||
}
|
||||
|
||||
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
Vec3f Viewer::get_cog_position() const
|
||||
{
|
||||
|
@ -11,6 +11,8 @@
|
||||
//################################################################################################################################
|
||||
|
||||
#include "ViewerImpl.hpp"
|
||||
#include "Types.hpp"
|
||||
#include "GCodeInputData.hpp"
|
||||
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
@ -33,7 +35,8 @@ public:
|
||||
Viewer& operator = (Viewer&& other) = delete;
|
||||
|
||||
void init();
|
||||
void load(const Slic3r::GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
|
||||
void reset();
|
||||
void load(const Slic3r::GCodeProcessorResult& gcode_result, const GCodeInputData& gcode_data);
|
||||
void render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix);
|
||||
|
||||
EViewType get_view_type() const;
|
||||
@ -108,6 +111,10 @@ public:
|
||||
//
|
||||
std::vector<float> get_layers_times(ETimeMode mode) const;
|
||||
|
||||
size_t get_tool_colors_count() const;
|
||||
const std::vector<Color>& get_tool_colors() const;
|
||||
void set_tool_colors(const std::vector<Color>& colors);
|
||||
|
||||
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
//
|
||||
// Returns the position of the center of gravity of the toolpaths.
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "Shaders.hpp"
|
||||
#include "OpenGLUtils.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "GCodeInputData.hpp"
|
||||
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
@ -31,14 +32,50 @@ namespace libvgcode {
|
||||
|
||||
//################################################################################################################################
|
||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||
static EMoveType valueof(Slic3r::EMoveType type)
|
||||
// mapping from Slic3r::EMoveType to EMoveType
|
||||
static EMoveType convert(Slic3r::EMoveType type)
|
||||
{
|
||||
return static_cast<EMoveType>(static_cast<uint8_t>(type));
|
||||
switch (type)
|
||||
{
|
||||
case Slic3r::EMoveType::Noop: { return EMoveType::Noop; }
|
||||
case Slic3r::EMoveType::Retract: { return EMoveType::Retract; }
|
||||
case Slic3r::EMoveType::Unretract: { return EMoveType::Unretract; }
|
||||
case Slic3r::EMoveType::Seam: { return EMoveType::Seam; }
|
||||
case Slic3r::EMoveType::Tool_change: { return EMoveType::ToolChange; }
|
||||
case Slic3r::EMoveType::Color_change: { return EMoveType::ColorChange; }
|
||||
case Slic3r::EMoveType::Pause_Print: { return EMoveType::PausePrint; }
|
||||
case Slic3r::EMoveType::Custom_GCode: { return EMoveType::CustomGCode; }
|
||||
case Slic3r::EMoveType::Travel: { return EMoveType::Travel; }
|
||||
case Slic3r::EMoveType::Wipe: { return EMoveType::Wipe; }
|
||||
case Slic3r::EMoveType::Extrude: { return EMoveType::Extrude; }
|
||||
case Slic3r::EMoveType::Count: { return EMoveType::COUNT; }
|
||||
default: { return EMoveType::COUNT; }
|
||||
}
|
||||
}
|
||||
|
||||
static EGCodeExtrusionRole valueof(Slic3r::GCodeExtrusionRole role)
|
||||
// mapping from Slic3r::GCodeExtrusionRole to EGCodeExtrusionRole
|
||||
static EGCodeExtrusionRole convert(Slic3r::GCodeExtrusionRole role)
|
||||
{
|
||||
return static_cast<EGCodeExtrusionRole>(static_cast<uint8_t>(role));
|
||||
switch (role)
|
||||
{
|
||||
case Slic3r::GCodeExtrusionRole::None: { return EGCodeExtrusionRole::None; }
|
||||
case Slic3r::GCodeExtrusionRole::Perimeter: { return EGCodeExtrusionRole::Perimeter; }
|
||||
case Slic3r::GCodeExtrusionRole::ExternalPerimeter: { return EGCodeExtrusionRole::ExternalPerimeter; }
|
||||
case Slic3r::GCodeExtrusionRole::OverhangPerimeter: { return EGCodeExtrusionRole::OverhangPerimeter; }
|
||||
case Slic3r::GCodeExtrusionRole::InternalInfill: { return EGCodeExtrusionRole::InternalInfill; }
|
||||
case Slic3r::GCodeExtrusionRole::SolidInfill: { return EGCodeExtrusionRole::SolidInfill; }
|
||||
case Slic3r::GCodeExtrusionRole::TopSolidInfill: { return EGCodeExtrusionRole::TopSolidInfill; }
|
||||
case Slic3r::GCodeExtrusionRole::Ironing: { return EGCodeExtrusionRole::Ironing; }
|
||||
case Slic3r::GCodeExtrusionRole::BridgeInfill: { return EGCodeExtrusionRole::BridgeInfill; }
|
||||
case Slic3r::GCodeExtrusionRole::GapFill: { return EGCodeExtrusionRole::GapFill; }
|
||||
case Slic3r::GCodeExtrusionRole::Skirt: { return EGCodeExtrusionRole::Skirt; }
|
||||
case Slic3r::GCodeExtrusionRole::SupportMaterial: { return EGCodeExtrusionRole::SupportMaterial; }
|
||||
case Slic3r::GCodeExtrusionRole::SupportMaterialInterface: { return EGCodeExtrusionRole::SupportMaterialInterface; }
|
||||
case Slic3r::GCodeExtrusionRole::WipeTower: { return EGCodeExtrusionRole::WipeTower; }
|
||||
case Slic3r::GCodeExtrusionRole::Custom: { return EGCodeExtrusionRole::Custom; }
|
||||
case Slic3r::GCodeExtrusionRole::Count: { return EGCodeExtrusionRole::COUNT; }
|
||||
default: { return EGCodeExtrusionRole::COUNT; }
|
||||
}
|
||||
}
|
||||
|
||||
static Vec3f toVec3f(const Eigen::Matrix<float, 3, 1, Eigen::DontAlign>& v)
|
||||
@ -92,45 +129,6 @@ static float round_to_bin(const float value)
|
||||
return fast_round_up<int64_t>(a) * invscale[i];
|
||||
}
|
||||
|
||||
static int hex_digit_to_int(const char c) {
|
||||
return (c >= '0' && c <= '9') ? int(c - '0') :
|
||||
(c >= 'A' && c <= 'F') ? int(c - 'A') + 10 :
|
||||
(c >= 'a' && c <= 'f') ? int(c - 'a') + 10 : -1;
|
||||
};
|
||||
|
||||
bool decode_color(const std::string& color_in, Color& color_out)
|
||||
{
|
||||
constexpr const float INV_255 = 1.0f / 255.0f;
|
||||
|
||||
color_out.fill(0.0f);
|
||||
if (color_in.size() == 7 && color_in.front() == '#') {
|
||||
const char* c = color_in.data() + 1;
|
||||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
const int digit1 = hex_digit_to_int(*c++);
|
||||
const int digit2 = hex_digit_to_int(*c++);
|
||||
if (digit1 != -1 && digit2 != -1)
|
||||
color_out[i] = float(digit1 * 16 + digit2) * INV_255;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
assert(0.0f <= color_out[0] && color_out[0] <= 1.0f);
|
||||
assert(0.0f <= color_out[1] && color_out[1] <= 1.0f);
|
||||
assert(0.0f <= color_out[2] && color_out[2] <= 1.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool decode_colors(const std::vector<std::string>& colors_in, std::vector<Color>& colors_out)
|
||||
{
|
||||
colors_out = std::vector<Color>(colors_in.size());
|
||||
for (size_t i = 0; i < colors_in.size(); ++i) {
|
||||
if (!decode_color(colors_in[i], colors_out[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static Mat4x4f inverse(const Mat4x4f& m)
|
||||
{
|
||||
// ref: https://stackoverflow.com/questions/1148309/inverting-a-4x4-matrix
|
||||
@ -396,6 +394,22 @@ unsigned int init_shader(const std::string& shader_name, const char* vertex_shad
|
||||
return shader_id;
|
||||
}
|
||||
|
||||
static void delete_textures(unsigned int& id)
|
||||
{
|
||||
if (id != 0) {
|
||||
glsafe(glDeleteTextures(1, &id));
|
||||
id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void delete_buffers(unsigned int& id)
|
||||
{
|
||||
if (id != 0) {
|
||||
glsafe(glDeleteBuffers(1, &id));
|
||||
id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// mapping from EMoveType to EOptionType
|
||||
static EOptionType type_to_option(EMoveType type) {
|
||||
switch (type)
|
||||
@ -415,9 +429,9 @@ ViewerImpl::~ViewerImpl()
|
||||
{
|
||||
reset();
|
||||
if (m_options_shader_id != 0)
|
||||
glDeleteProgram(m_options_shader_id);
|
||||
glsafe(glDeleteProgram(m_options_shader_id));
|
||||
if (m_segments_shader_id != 0)
|
||||
glDeleteProgram(m_segments_shader_id);
|
||||
glsafe(glDeleteProgram(m_segments_shader_id));
|
||||
}
|
||||
|
||||
void ViewerImpl::init()
|
||||
@ -501,14 +515,46 @@ void ViewerImpl::init()
|
||||
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
}
|
||||
|
||||
void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
|
||||
void ViewerImpl::reset()
|
||||
{
|
||||
m_layers.reset();
|
||||
m_layers_range.reset();
|
||||
m_view_range.reset();
|
||||
m_old_current_range.reset();
|
||||
m_extrusion_roles.reset();
|
||||
m_travels_time = { 0.0f, 0.0f };
|
||||
m_vertices.clear();
|
||||
m_vertices_map.clear();
|
||||
m_valid_lines_bitset.clear();
|
||||
m_layers_times = std::array<std::vector<float>, static_cast<size_t>(ETimeMode::COUNT)>();
|
||||
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
m_cog_marker.reset();
|
||||
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
|
||||
delete_textures(m_enabled_options_tex_id);
|
||||
delete_buffers(m_enabled_options_buf_id);
|
||||
|
||||
delete_textures(m_enabled_segments_tex_id);
|
||||
delete_buffers(m_enabled_segments_buf_id);
|
||||
|
||||
delete_textures(m_colors_tex_id);
|
||||
delete_buffers(m_colors_buf_id);
|
||||
|
||||
delete_textures(m_heights_widths_angles_tex_id);
|
||||
delete_buffers(m_heights_widths_angles_buf_id);
|
||||
|
||||
delete_textures(m_positions_tex_id);
|
||||
delete_buffers(m_positions_buf_id);
|
||||
}
|
||||
|
||||
void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const GCodeInputData& gcode_data)
|
||||
{
|
||||
if (m_settings.time_mode != ETimeMode::Normal) {
|
||||
const Slic3r::PrintEstimatedStatistics& stats = gcode_result.print_statistics;
|
||||
bool force_normal_mode = static_cast<size_t>(m_settings.time_mode) >= stats.modes.size();
|
||||
if (!force_normal_mode) {
|
||||
const float normal_time = stats.modes[static_cast<uint8_t>(ETimeMode::Normal)].time;
|
||||
const float mode_time = stats.modes[static_cast<uint8_t>(m_settings.time_mode)].time;
|
||||
const float normal_time = stats.modes[static_cast<size_t>(ETimeMode::Normal)].time;
|
||||
const float mode_time = stats.modes[static_cast<size_t>(m_settings.time_mode)].time;
|
||||
force_normal_mode = mode_time == 0.0f ||
|
||||
short_time(get_time_dhms(mode_time)) == short_time(get_time_dhms(normal_time)); // TO CHECK -> Is this necessary ?
|
||||
}
|
||||
@ -516,39 +562,14 @@ void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const st
|
||||
m_settings.time_mode = ETimeMode::Normal;
|
||||
}
|
||||
|
||||
m_tool_colors.clear();
|
||||
if (m_settings.view_type == EViewType::Tool && !gcode_result.extruder_colors.empty())
|
||||
// update tool colors from config stored in the gcode
|
||||
decode_colors(gcode_result.extruder_colors, m_tool_colors);
|
||||
else
|
||||
// update tool colors
|
||||
decode_colors(str_tool_colors, m_tool_colors);
|
||||
|
||||
// ensure there are enough colors defined
|
||||
while (m_tool_colors.size() < std::max<size_t>(1, gcode_result.extruders_count)) {
|
||||
m_tool_colors.push_back(Default_Tool_Color);
|
||||
}
|
||||
|
||||
static unsigned int last_result_id = 0;
|
||||
if (last_result_id == gcode_result.id)
|
||||
return;
|
||||
|
||||
last_result_id = gcode_result.id;
|
||||
|
||||
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
m_cog_marker.reset();
|
||||
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
|
||||
reset();
|
||||
|
||||
m_vertices_map.reserve(2 * gcode_result.moves.size());
|
||||
m_vertices.reserve(2 * gcode_result.moves.size());
|
||||
uint32_t seams_count = 0;
|
||||
for (size_t i = 1; i < gcode_result.moves.size(); ++i) {
|
||||
const Slic3r::GCodeProcessorResult::MoveVertex& curr = gcode_result.moves[i];
|
||||
const Slic3r::GCodeProcessorResult::MoveVertex& prev = gcode_result.moves[i - 1];
|
||||
const EMoveType curr_type = valueof(curr.type);
|
||||
const EGCodeExtrusionRole curr_role = valueof(curr.extrusion_role);
|
||||
const EMoveType curr_type = convert(curr.type);
|
||||
const EGCodeExtrusionRole curr_role = convert(curr.extrusion_role);
|
||||
|
||||
if (curr_type == EMoveType::Seam)
|
||||
++seams_count;
|
||||
@ -1016,9 +1037,9 @@ void ViewerImpl::set_view_current_range(uint32_t min, uint32_t max)
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ViewerImpl::get_vertices_count() const
|
||||
size_t ViewerImpl::get_vertices_count() const
|
||||
{
|
||||
return static_cast<uint32_t>(m_vertices.size());
|
||||
return m_vertices.size();
|
||||
}
|
||||
|
||||
PathVertex ViewerImpl::get_current_vertex() const
|
||||
@ -1026,9 +1047,9 @@ PathVertex ViewerImpl::get_current_vertex() const
|
||||
return m_vertices[m_view_range.get_current_range()[1]];
|
||||
}
|
||||
|
||||
PathVertex ViewerImpl::get_vertex_at(uint32_t id) const
|
||||
PathVertex ViewerImpl::get_vertex_at(size_t id) const
|
||||
{
|
||||
return (id < static_cast<uint32_t>(m_vertices.size())) ? m_vertices[id] : PathVertex();
|
||||
return (id < m_vertices.size()) ? m_vertices[id] : PathVertex();
|
||||
}
|
||||
|
||||
std::vector<EGCodeExtrusionRole> ViewerImpl::get_extrusion_roles() const
|
||||
@ -1041,7 +1062,7 @@ float ViewerImpl::get_extrusion_role_time(EGCodeExtrusionRole role) const
|
||||
return m_extrusion_roles.get_time(role, m_settings.time_mode);
|
||||
}
|
||||
|
||||
uint32_t ViewerImpl::get_extrusion_roles_count() const
|
||||
size_t ViewerImpl::get_extrusion_roles_count() const
|
||||
{
|
||||
return m_extrusion_roles.get_roles_count();
|
||||
}
|
||||
@ -1071,6 +1092,16 @@ std::vector<float> ViewerImpl::get_layers_times(ETimeMode mode) const
|
||||
return (mode < ETimeMode::COUNT) ? m_layers_times[static_cast<size_t>(mode)] : std::vector<float>();
|
||||
}
|
||||
|
||||
size_t ViewerImpl::get_tool_colors_count() const
|
||||
{
|
||||
return m_tool_colors.size();
|
||||
}
|
||||
|
||||
const std::vector<Color>& ViewerImpl::get_tool_colors() const
|
||||
{
|
||||
return m_tool_colors;
|
||||
}
|
||||
|
||||
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
Vec3f ViewerImpl::get_cog_marker_position() const
|
||||
{
|
||||
@ -1111,7 +1142,15 @@ float ViewerImpl::get_tool_marker_alpha() const
|
||||
{
|
||||
return m_tool_marker.get_alpha();
|
||||
}
|
||||
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
|
||||
void ViewerImpl::set_tool_colors(const std::vector<Color>& colors)
|
||||
{
|
||||
m_tool_colors = colors;
|
||||
m_settings.update_colors = true;
|
||||
}
|
||||
|
||||
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
void ViewerImpl::set_cog_marker_scale_factor(float factor)
|
||||
{
|
||||
m_cog_marker_scale_factor = std::max(factor, 0.001f);
|
||||
@ -1148,52 +1187,6 @@ void ViewerImpl::set_tool_marker_alpha(float alpha)
|
||||
}
|
||||
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
|
||||
static void delete_textures(unsigned int& id)
|
||||
{
|
||||
if (id != 0) {
|
||||
glsafe(glDeleteTextures(1, &id));
|
||||
id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void delete_buffers(unsigned int& id)
|
||||
{
|
||||
if (id != 0) {
|
||||
glsafe(glDeleteBuffers(1, &id));
|
||||
id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerImpl::reset()
|
||||
{
|
||||
m_layers.reset();
|
||||
m_layers_range.reset();
|
||||
m_view_range.reset();
|
||||
m_old_current_range.reset();
|
||||
m_extrusion_roles.reset();
|
||||
m_travels_time = { 0.0f, 0.0f };
|
||||
m_vertices.clear();
|
||||
m_vertices_map.clear();
|
||||
m_valid_lines_bitset.clear();
|
||||
|
||||
m_layers_times = std::array<std::vector<float>, static_cast<size_t>(ETimeMode::COUNT)>();
|
||||
|
||||
delete_textures(m_enabled_options_tex_id);
|
||||
delete_buffers(m_enabled_options_buf_id);
|
||||
|
||||
delete_textures(m_enabled_segments_tex_id);
|
||||
delete_buffers(m_enabled_segments_buf_id);
|
||||
|
||||
delete_textures(m_colors_tex_id);
|
||||
delete_buffers(m_colors_buf_id);
|
||||
|
||||
delete_textures(m_heights_widths_angles_tex_id);
|
||||
delete_buffers(m_heights_widths_angles_buf_id);
|
||||
|
||||
delete_textures(m_positions_tex_id);
|
||||
delete_buffers(m_positions_buf_id);
|
||||
}
|
||||
|
||||
void ViewerImpl::update_view_global_range()
|
||||
{
|
||||
const std::array<uint32_t, 2>& layers_range = m_layers_range.get();
|
||||
|
@ -34,6 +34,8 @@ class Print;
|
||||
|
||||
namespace libvgcode {
|
||||
|
||||
struct GCodeInputData;
|
||||
|
||||
class ViewerImpl
|
||||
{
|
||||
public:
|
||||
@ -49,11 +51,16 @@ public:
|
||||
//
|
||||
void init();
|
||||
|
||||
//
|
||||
// Reset all caches and free gpu memory
|
||||
//
|
||||
void reset();
|
||||
|
||||
//
|
||||
// Setup all the variables used for visualization and coloring of the toolpaths
|
||||
// from the gcode moves contained in the given gcode_result.
|
||||
//
|
||||
void load(const Slic3r::GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
|
||||
void load(const Slic3r::GCodeProcessorResult& gcode_result, const GCodeInputData& gcode_data);
|
||||
|
||||
//
|
||||
// Update the visibility property of toolpaths
|
||||
@ -104,10 +111,10 @@ public:
|
||||
//
|
||||
// Properties getters
|
||||
//
|
||||
uint32_t get_vertices_count() const;
|
||||
size_t get_vertices_count() const;
|
||||
PathVertex get_current_vertex() const;
|
||||
PathVertex get_vertex_at(uint32_t id) const;
|
||||
uint32_t get_extrusion_roles_count() const;
|
||||
PathVertex get_vertex_at(size_t id) const;
|
||||
size_t get_extrusion_roles_count() const;
|
||||
std::vector<EGCodeExtrusionRole> get_extrusion_roles() const;
|
||||
float get_extrusion_role_time(EGCodeExtrusionRole role) const;
|
||||
float get_extrusion_role_time(EGCodeExtrusionRole role, ETimeMode mode) const;
|
||||
@ -115,6 +122,8 @@ public:
|
||||
float get_travels_time(ETimeMode mode) const;
|
||||
std::vector<float> get_layers_times() const;
|
||||
std::vector<float> get_layers_times(ETimeMode mode) const;
|
||||
size_t get_tool_colors_count() const;
|
||||
const std::vector<Color>& get_tool_colors() const;
|
||||
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
Vec3f get_cog_marker_position() const;
|
||||
float get_cog_marker_scale_factor() const;
|
||||
@ -129,6 +138,7 @@ public:
|
||||
//
|
||||
// Properties setters
|
||||
//
|
||||
void set_tool_colors(const std::vector<Color>& colors);
|
||||
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||
void set_cog_marker_scale_factor(float factor);
|
||||
void enable_tool_marker(bool value);
|
||||
@ -278,7 +288,6 @@ private:
|
||||
unsigned int m_enabled_options_buf_id{ 0 };
|
||||
unsigned int m_enabled_options_tex_id{ 0 };
|
||||
|
||||
void reset();
|
||||
void update_view_global_range();
|
||||
void update_color_ranges();
|
||||
Color select_color(const PathVertex& v) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user