mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-03 18:20:36 +08:00
Top layer only coloring for neww gcode visualization
This commit is contained in:
parent
f0a25c8ee0
commit
717bc821e3
@ -14,8 +14,6 @@
|
|||||||
#if ENABLE_NEW_GCODE_VIEWER
|
#if ENABLE_NEW_GCODE_VIEWER
|
||||||
//################################################################################################################################
|
//################################################################################################################################
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
|
|
||||||
const std::array<uint32_t, 2>& ViewRange::get_current_range() const
|
const std::array<uint32_t, 2>& ViewRange::get_current_range() const
|
||||||
@ -36,6 +34,7 @@ void ViewRange::set_current_range(const std::array<uint32_t, 2>& range)
|
|||||||
void ViewRange::set_current_range(uint32_t min, uint32_t max)
|
void ViewRange::set_current_range(uint32_t min, uint32_t max)
|
||||||
{
|
{
|
||||||
m_current.set(min, max);
|
m_current.set(min, max);
|
||||||
|
// force the current range to stay inside the modified global range
|
||||||
m_global.clamp(m_current);
|
m_global.clamp(m_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,14 +55,20 @@ void ViewRange::set_global_range(const std::array<uint32_t, 2>& range)
|
|||||||
|
|
||||||
void ViewRange::set_global_range(uint32_t min, uint32_t max)
|
void ViewRange::set_global_range(uint32_t min, uint32_t max)
|
||||||
{
|
{
|
||||||
|
// is the global range being extended ?
|
||||||
|
const bool new_max = max > m_global.get()[1];
|
||||||
m_global.set(min, max);
|
m_global.set(min, max);
|
||||||
|
// force the current range to stay inside the modified global range
|
||||||
m_global.clamp(m_current);
|
m_global.clamp(m_current);
|
||||||
|
if (new_max)
|
||||||
|
// force the current range to fill the extended global range
|
||||||
|
m_current.set(m_current.get()[0], max);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewRange::reset()
|
void ViewRange::reset()
|
||||||
{
|
{
|
||||||
m_global.reset();
|
m_global.reset();
|
||||||
m_global.reset();
|
m_current.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace libvgcode
|
} // namespace libvgcode
|
||||||
|
@ -745,8 +745,11 @@ void ViewerImpl::update_enabled_entities()
|
|||||||
std::vector<uint32_t> enabled_segments;
|
std::vector<uint32_t> enabled_segments;
|
||||||
std::vector<uint32_t> enabled_options;
|
std::vector<uint32_t> enabled_options;
|
||||||
|
|
||||||
const std::array<uint32_t, 2>& current_range = m_view_range.get_current_range();
|
std::array<uint32_t, 2> range = m_view_range.get_current_range();
|
||||||
for (uint32_t i = current_range[0]; i < current_range[1]; ++i) {
|
if (m_settings.top_layer_only_view)
|
||||||
|
range[0] = m_view_range.get_global_range()[0];
|
||||||
|
|
||||||
|
for (uint32_t i = range[0]; i < range[1]; ++i) {
|
||||||
const PathVertex& v = m_vertices[i];
|
const PathVertex& v = m_vertices[i];
|
||||||
|
|
||||||
if (!m_valid_lines_bitset[i] && !v.is_option())
|
if (!m_valid_lines_bitset[i] && !v.is_option())
|
||||||
@ -820,8 +823,8 @@ 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
|
||||||
@ -929,6 +932,7 @@ void ViewerImpl::set_layers_range(uint32_t min, uint32_t max)
|
|||||||
m_layers_range.set(min, max);
|
m_layers_range.set(min, max);
|
||||||
m_settings.update_view_global_range = true;
|
m_settings.update_view_global_range = true;
|
||||||
m_settings.update_enabled_entities = true;
|
m_settings.update_enabled_entities = true;
|
||||||
|
m_settings.update_colors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerImpl::set_top_layer_only_view(bool top_layer_only_view)
|
void ViewerImpl::set_top_layer_only_view(bool top_layer_only_view)
|
||||||
@ -1584,6 +1588,7 @@ void ViewerImpl::render_debug_window()
|
|||||||
|
|
||||||
imgui.end();
|
imgui.end();
|
||||||
|
|
||||||
|
/*
|
||||||
auto to_string = [](EMoveType type) {
|
auto to_string = [](EMoveType type) {
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -1623,6 +1628,7 @@ void ViewerImpl::render_debug_window()
|
|||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
imgui.end();
|
imgui.end();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
#endif // ENABLE_NEW_GCODE_VIEWER_DEBUG
|
#endif // ENABLE_NEW_GCODE_VIEWER_DEBUG
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user