mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 04:02:02 +08:00
New gcode visualization: render in gray color layers containing pause print or custom gcode options when in Color Print view
This commit is contained in:
parent
e484726a98
commit
0764d9ffda
@ -969,7 +969,7 @@ private:
|
|||||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
#if ENABLE_NEW_GCODE_VIEWER
|
#if ENABLE_NEW_GCODE_VIEWER
|
||||||
libvgcode::Viewer m_new_viewer;
|
libvgcode::Viewer m_new_viewer;
|
||||||
bool m_use_new_viewer{ false };
|
bool m_use_new_viewer{ true };
|
||||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
///|/
|
///|/
|
||||||
#include "Layers.hpp"
|
#include "Layers.hpp"
|
||||||
|
|
||||||
|
#include "PathVertex.hpp"
|
||||||
|
|
||||||
//################################################################################################################################
|
//################################################################################################################################
|
||||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||||
#if ENABLE_NEW_GCODE_VIEWER
|
#if ENABLE_NEW_GCODE_VIEWER
|
||||||
@ -18,33 +20,46 @@
|
|||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
|
|
||||||
void Layers::update(uint32_t layer_id, uint32_t vertex_id)
|
static bool is_colorprint_option(const PathVertex& v)
|
||||||
{
|
{
|
||||||
if (m_ranges.empty() || layer_id == m_ranges.size()) {
|
return v.type == EMoveType::PausePrint || v.type == EMoveType::CustomGCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layers::update(const PathVertex& vertex, uint32_t vertex_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (m_items.empty() || vertex.layer_id == m_items.size()) {
|
||||||
// this code assumes that gcode paths are sent sequentially, one layer after the other
|
// this code assumes that gcode paths are sent sequentially, one layer after the other
|
||||||
assert(layer_id == static_cast<uint32_t>(m_ranges.size()));
|
assert(vertex.layer_id == static_cast<uint32_t>(m_items.size()));
|
||||||
Range& range = m_ranges.emplace_back(Range());
|
Item& item = m_items.emplace_back(Item());
|
||||||
range.set(vertex_id, vertex_id);
|
item.range.set(vertex_id, vertex_id);
|
||||||
|
item.contains_colorprint_options |= is_colorprint_option(vertex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Range& range = m_ranges.back();
|
Item& item = m_items.back();
|
||||||
range.set(range.get()[0], vertex_id);
|
item.range.set(item.range.get()[0], vertex_id);
|
||||||
|
item.contains_colorprint_options |= is_colorprint_option(vertex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layers::reset()
|
void Layers::reset()
|
||||||
{
|
{
|
||||||
m_ranges.clear();
|
m_items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Layers::empty() const
|
bool Layers::empty() const
|
||||||
{
|
{
|
||||||
return m_ranges.empty();
|
return m_items.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Layers::size() const
|
size_t Layers::get_layers_count() const
|
||||||
{
|
{
|
||||||
return m_ranges.size();
|
return m_items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Layers::layer_contains_colorprint_options(uint32_t layer_id) const
|
||||||
|
{
|
||||||
|
return (layer_id < static_cast<uint32_t>(m_items.size())) ? m_items[layer_id].contains_colorprint_options : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace libvgcode
|
} // namespace libvgcode
|
||||||
|
@ -16,17 +16,29 @@
|
|||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
|
|
||||||
|
struct PathVertex;
|
||||||
|
|
||||||
class Layers
|
class Layers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void update(uint32_t layer_id, uint32_t vertex_id);
|
void update(const PathVertex& vertex, uint32_t vertex_id);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
size_t size() const;
|
size_t get_layers_count() const;
|
||||||
|
|
||||||
|
bool layer_contains_colorprint_options(uint32_t layer_id) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Range> m_ranges;
|
struct Item
|
||||||
|
{
|
||||||
|
Range range;
|
||||||
|
bool contains_colorprint_options{ false };
|
||||||
|
|
||||||
|
Item() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Item> m_items;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace libvgcode
|
} // namespace libvgcode
|
||||||
|
@ -607,7 +607,7 @@ void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const GC
|
|||||||
static_cast<uint32_t>(curr.layer_id) };
|
static_cast<uint32_t>(curr.layer_id) };
|
||||||
m_vertices_map.emplace_back(static_cast<uint32_t>(i) - seams_count);
|
m_vertices_map.emplace_back(static_cast<uint32_t>(i) - seams_count);
|
||||||
m_vertices.emplace_back(vertex);
|
m_vertices.emplace_back(vertex);
|
||||||
m_layers.update(static_cast<uint32_t>(curr.layer_id), static_cast<uint32_t>(m_vertices.size()));
|
m_layers.update(vertex, static_cast<uint32_t>(m_vertices.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,7 +616,7 @@ void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const GC
|
|||||||
static_cast<uint8_t>(curr.cp_color_id), static_cast<uint32_t>(curr.layer_id) };
|
static_cast<uint8_t>(curr.cp_color_id), static_cast<uint32_t>(curr.layer_id) };
|
||||||
m_vertices_map.emplace_back(static_cast<uint32_t>(i) - seams_count);
|
m_vertices_map.emplace_back(static_cast<uint32_t>(i) - seams_count);
|
||||||
m_vertices.emplace_back(vertex);
|
m_vertices.emplace_back(vertex);
|
||||||
m_layers.update(static_cast<uint32_t>(curr.layer_id), static_cast<uint32_t>(m_vertices.size()));
|
m_layers.update(vertex, static_cast<uint32_t>(m_vertices.size()));
|
||||||
|
|
||||||
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
|
||||||
// updates calculation for center of gravity
|
// updates calculation for center of gravity
|
||||||
@ -738,7 +738,7 @@ void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const GC
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_layers.empty())
|
if (!m_layers.empty())
|
||||||
set_layers_range(0, static_cast<uint32_t>(m_layers.size() - 1));
|
set_layers_range(0, static_cast<uint32_t>(m_layers.get_layers_count() - 1));
|
||||||
update_view_global_range();
|
update_view_global_range();
|
||||||
m_settings.update_colors = true;
|
m_settings.update_colors = true;
|
||||||
}
|
}
|
||||||
@ -833,8 +833,7 @@ void ViewerImpl::update_colors()
|
|||||||
const uint32_t top_layer_id = m_settings.top_layer_only_view ? m_layers_range.get()[1] : 0;
|
const uint32_t top_layer_id = m_settings.top_layer_only_view ? m_layers_range.get()[1] : 0;
|
||||||
std::vector<float> colors(m_vertices.size());
|
std::vector<float> colors(m_vertices.size());
|
||||||
for (size_t i = 0; i < m_vertices.size(); i++) {
|
for (size_t i = 0; i < m_vertices.size(); i++) {
|
||||||
colors[i] = (m_vertices[i].layer_id < top_layer_id) ?
|
colors[i] = (m_vertices[i].layer_id < top_layer_id) ? encode_color(Dummy_Color) : encode_color(select_color(m_vertices[i]));
|
||||||
encode_color(Dummy_Color) : encode_color(select_color(m_vertices[i]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update gpu buffer for colors
|
// update gpu buffer for colors
|
||||||
@ -1332,7 +1331,7 @@ Color ViewerImpl::select_color(const PathVertex& v) const
|
|||||||
}
|
}
|
||||||
case EViewType::ColorPrint:
|
case EViewType::ColorPrint:
|
||||||
{
|
{
|
||||||
return m_tool_colors[v.color_id % m_tool_colors.size()];
|
return m_layers.layer_contains_colorprint_options(v.layer_id) ? Dummy_Color : m_tool_colors[v.color_id % m_tool_colors.size()];
|
||||||
}
|
}
|
||||||
default: { break; }
|
default: { break; }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user