OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
libvgcode::ViewerImpl Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libvgcode/src/ViewerImpl.hpp>

Collaboration diagram for libvgcode::ViewerImpl:

Classes

struct  SegmentsUniforms
struct  LayerColorsUniforms
struct  TranslucentTargets

Public Member Functions

 ViewerImpl ()
 ~ViewerImpl ()
 ViewerImpl (const ViewerImpl &other)=delete
 ViewerImpl (ViewerImpl &&other)=delete
ViewerImpl & operator= (const ViewerImpl &other)=delete
ViewerImpl & operator= (ViewerImpl &&other)=delete
void init (const std::string &opengl_context_version)
void shutdown ()
void reset ()
void load (GCodeInputData &&gcode_data)
void update_enabled_entities ()
void update_colors ()
void update_colors_texture ()
void render (const Mat4x4 &view_matrix, const Mat4x4 &projection_matrix)
void render_translucent (const Mat4x4 &view_matrix, const Mat4x4 &projection_matrix)
bool has_translucent_toolpaths () const
void render_shadow_casters (const Mat4x4 &view_matrix, const Mat4x4 &projection_matrix, const Vec3 &light_position)
void set_shadow_map (int texture_unit, const Mat4x4 &light_view_projection, float intensity, float texel_size)
void set_tone (float exposure, float saturation)
void set_clipping_plane (const std::array< float, 4 > &plane)
void set_light_top_dir (const Vec3 &direction)
void set_gloss (bool gloss)
EViewType get_view_type () const
void set_view_type (EViewType type)
ETimeMode get_time_mode () const
void set_time_mode (ETimeMode mode)
const Interval & get_layers_view_range () const
void set_layers_view_range (const Interval &range)
void set_layers_view_range (Interval::value_type min, Interval::value_type max)
bool is_top_layer_only_view_range () const
void toggle_top_layer_only_view_range ()
bool is_dim_previous_layers () const
void set_dim_previous_layers (bool value)
float get_dim_previous_layers_brightness () const
void set_dim_previous_layers_brightness (float value)
bool is_translucent_filaments () const
void set_translucent_filaments (bool value)
bool is_spiral_vase_mode () const
std::vector< ETimeMode > get_time_modes () const
size_t get_layers_count () const
float get_layer_z (size_t layer_id) const
std::vector< float > get_layers_zs () const
size_t get_layer_id_at (float z) const
size_t get_used_extruders_count () const
std::vector< uint8_t > get_used_extruders_ids () const
size_t get_color_prints_count (uint8_t extruder_id) const
std::vector< ColorPrint > get_color_prints (uint8_t extruder_id) const
AABox get_bounding_box (const std::vector< EMoveType > &types={ EMoveType::Retract, EMoveType::Unretract, EMoveType::Seam, EMoveType::ToolChange, EMoveType::ColorChange, EMoveType::PausePrint, EMoveType::CustomGCode, EMoveType::Travel, EMoveType::Wipe, EMoveType::Extrude }) const
AABox get_extrusion_bounding_box (const std::vector< EGCodeExtrusionRole > &roles={ EGCodeExtrusionRole::Perimeter, EGCodeExtrusionRole::ExternalPerimeter, EGCodeExtrusionRole::OverhangPerimeter, EGCodeExtrusionRole::InternalInfill, EGCodeExtrusionRole::SolidInfill, EGCodeExtrusionRole::TopSolidInfill, EGCodeExtrusionRole::Ironing, EGCodeExtrusionRole::BridgeInfill, EGCodeExtrusionRole::GapFill, EGCodeExtrusionRole::Skirt, EGCodeExtrusionRole::SupportMaterial, EGCodeExtrusionRole::SupportMaterialInterface, EGCodeExtrusionRole::WipeTower, EGCodeExtrusionRole::Custom, EGCodeExtrusionRole::BottomSurface, EGCodeExtrusionRole::InternalBridgeInfill, EGCodeExtrusionRole::Brim, EGCodeExtrusionRole::SupportTransition, EGCodeExtrusionRole::Mixed }) const
bool is_option_visible (EOptionType type) const
void toggle_option_visibility (EOptionType type)
bool is_extrusion_role_visible (EGCodeExtrusionRole role) const
void toggle_extrusion_role_visibility (EGCodeExtrusionRole role)
const Interval & get_view_full_range () const
const Interval & get_view_enabled_range () const
const Interval & get_view_visible_range () const
void set_view_visible_range (Interval::value_type min, Interval::value_type max)
size_t get_vertices_count () const
const PathVertex & get_current_vertex () const
size_t get_current_vertex_id () const
const PathVertex & get_vertex_at (size_t id) const
float get_estimated_time () const
float get_estimated_time_at (size_t id) const
Color get_vertex_color (const PathVertex &vertex) const
size_t get_extrusion_roles_count () const
std::vector< EGCodeExtrusionRole > get_extrusion_roles () const
float get_extrusion_role_estimated_time (EGCodeExtrusionRole role) const
size_t get_options_count () const
const std::vector< EOptionType > & get_options () const
float get_travels_estimated_time () const
std::vector< float > get_layers_estimated_times () const
size_t get_tool_colors_count () const
const PaletteWithAlpha & get_tool_colors () const
void set_tool_colors (const PaletteWithAlpha &colors)
size_t get_color_print_colors_count () const
const PaletteWithAlpha & get_color_print_colors () const
void set_color_print_colors (const PaletteWithAlpha &colors)
const Color & get_extrusion_role_color (EGCodeExtrusionRole role) const
void set_extrusion_role_color (EGCodeExtrusionRole role, const Color &color)
void reset_default_extrusion_roles_colors ()
const Color & get_option_color (EOptionType type) const
void set_option_color (EOptionType type, const Color &color)
void reset_default_options_colors ()
const ColorRange & get_color_range (EViewType type) const
void set_color_range_palette (EViewType type, const Palette &palette)
float get_travels_radius () const
void set_travels_radius (float radius)
float get_wipes_radius () const
void set_wipes_radius (float radius)
size_t get_used_cpu_memory () const
size_t get_used_gpu_memory () const

Private Member Functions

void apply_pending_updates ()
void update_view_full_range ()
void update_color_ranges ()
void update_heights_widths ()
uint8_t get_vertex_alpha (const PathVertex &v) const
void render_segments (const Mat4x4 &view_matrix, const Mat4x4 &projection_matrix, const Vec3 &camera_position, bool translucent=false)
void render_options (const Mat4x4 &view_matrix, const Mat4x4 &projection_matrix)
void render_translucent_segments (const Mat4x4 &view_matrix, const Mat4x4 &projection_matrix, const Vec3 &camera_position)
void set_layer_colors (const LayerColorsUniforms &uni) const

Private Attributes

Settings m_settings
Layers m_layers
ExtrusionRoles m_extrusion_roles
std::vector< EOptionType > m_options
std::map< uint8_t, std::vector< ColorPrint > > m_used_extruders
ViewRange m_view_range
std::array< float, TIME_MODES_COUNT > m_total_time { 0.0f, 0.0f }
std::array< std::vector< float >, TIME_MODES_COUNT > m_layer_start_times
std::vector< uint32_t > m_layer_first_vertex
bool m_layers_in_vertex_order { false }
std::array< float, TIME_MODES_COUNT > m_travels_time { 0.0f, 0.0f }
float m_travels_radius { DEFAULT_TRAVELS_RADIUS_MM }
float m_wipes_radius { DEFAULT_WIPES_RADIUS_MM }
std::array< Color, size_t(EGCodeExtrusionRole::COUNT)> m_extrusion_roles_colors
std::array< Color, size_t(EOptionType::COUNT)> m_options_colors
bool m_initialized { false }
SegmentTemplate m_segment_template
OptionTemplate m_option_template
std::vector< PathVertex > m_vertices
std::vector< ColorWithAlpha > m_vertices_colors
bool m_has_translucent_colors { false }
size_t m_enabled_translucent_segments_count { 0 }
BitSet m_valid_lines_bitset
std::optional< Settings > m_settings_used_for_ranges
ColorRange m_height_range
ColorRange m_width_range
ColorRange m_speed_range
ColorRange m_actual_speed_range
ColorRange m_fan_speed_range
ColorRange m_temperature_range
ColorRange m_pressure_advance_range
ColorRange m_acceleration_range
ColorRange m_jerk_range
ColorRange m_volumetric_rate_range
ColorRange m_actual_volumetric_rate_range
std::array< ColorRange, COLOR_RANGE_TYPES_COUNT > m_layer_time_range
PaletteWithAlpha m_tool_colors
PaletteWithAlpha m_color_print_colors
unsigned int m_segments_shader_id { 0 }
unsigned int m_segments_caster_shader_id { 0 }
unsigned int m_segments_caster_vao_id { 0 }
unsigned int m_options_shader_id { 0 }
SegmentsUniforms m_uni_segments
SegmentsUniforms m_uni_segments_caster
int m_uni_segments_shadow_map_id { -1 }
int m_uni_segments_shadow_light_vp_id { -1 }
int m_uni_segments_shadow_intensity_id { -1 }
int m_uni_segments_shadow_map_texel_id { -1 }
int m_uni_segments_exposure_id { -1 }
int m_uni_segments_saturation_id { -1 }
int m_uni_segments_light_top_dir_id { -1 }
int m_uni_segments_gloss_id { -1 }
LayerColorsUniforms m_uni_segments_layer_colors
int m_uni_options_view_matrix_id { -1 }
int m_uni_options_projection_matrix_id { -1 }
int m_uni_options_positions_tex_id { -1 }
int m_uni_options_height_width_angle_tex_id { -1 }
int m_uni_options_colors_tex_id { -1 }
int m_uni_options_segment_index_tex_id { -1 }
int m_uni_options_clipping_plane_id { -1 }
LayerColorsUniforms m_uni_options_layer_colors
unsigned int m_positions_buf_id { 0 }
unsigned int m_positions_tex_id { 0 }
unsigned int m_heights_widths_angles_buf_id { 0 }
unsigned int m_heights_widths_angles_tex_id { 0 }
unsigned int m_colors_buf_id { 0 }
unsigned int m_colors_tex_id { 0 }
unsigned int m_enabled_segments_buf_id { 0 }
unsigned int m_enabled_segments_tex_id { 0 }
size_t m_enabled_segments_count { 0 }
unsigned int m_enabled_options_buf_id { 0 }
unsigned int m_enabled_options_tex_id { 0 }
size_t m_enabled_options_count { 0 }
size_t m_positions_tex_size { 0 }
size_t m_height_width_angle_tex_size { 0 }
size_t m_colors_tex_size { 0 }
size_t m_enabled_segments_tex_size { 0 }
size_t m_enabled_options_tex_size { 0 }
int m_shadow_map_texture_unit { 4 }
Mat4x4 m_shadow_light_vp { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }
float m_shadow_intensity { 0.0f }
float m_shadow_map_texel { 0.0f }
bool m_rendering_shadow_casters { false }
float m_exposure { 1.0f }
float m_saturation { 1.0f }
Vec3 m_light_top_dir { -0.4574957f, 0.4574957f, 0.7624929f }
bool m_gloss { true }
std::array< float, 4 > m_clipping_plane { 0.0f, 0.0f, 0.0f, 1.0f }
AABox m_extrusions_box { Vec3{ 0.0f, 0.0f, 0.0f }, Vec3{ 0.0f, 0.0f, 0.0f } }
TranslucentTargets m_translucent_targets
unsigned int m_translucent_composite_shader_id { 0 }
int m_uni_translucent_composite_accum_tex_id { -1 }
int m_uni_translucent_composite_reveal_tex_id { -1 }
int m_uni_translucent_composite_front_tex_id { -1 }
int m_uni_translucent_composite_origin_id { -1 }
int m_uni_segments_oit_pass_id { -1 }
int m_uni_segments_opaque_depth_id { -1 }
int m_uni_segments_front_depth_id { -1 }
int m_uni_segments_oit_depth_range_id { -1 }
unsigned int m_segments_depth_shader_id { 0 }
SegmentsUniforms m_uni_segments_depth
int m_uni_segments_depth_opaque_depth_id { -1 }
std::array< float, 2 > m_oit_depth_range { 0.0f, 1.0f }
int m_translucent_pass { 0 }

Detailed Description

Constructor & Destructor Documentation

◆ ViewerImpl() [1/3]

libvgcode::ViewerImpl::ViewerImpl ( )
769{
772}
void reset_default_extrusion_roles_colors()
Definition ViewerImpl.cpp:1867
void reset_default_options_colors()
Definition ViewerImpl.cpp:1883

References reset_default_extrusion_roles_colors(), and reset_default_options_colors().

Referenced by ViewerImpl(), ViewerImpl(), operator=(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~ViewerImpl()

libvgcode::ViewerImpl::~ViewerImpl ( )
inline
40{ shutdown(); }
void shutdown()
Definition ViewerImpl.cpp:935

References shutdown().

Here is the call graph for this function:

◆ ViewerImpl() [2/3]

libvgcode::ViewerImpl::ViewerImpl ( const ViewerImpl & other)
delete

References ViewerImpl().

Here is the call graph for this function:

◆ ViewerImpl() [3/3]

libvgcode::ViewerImpl::ViewerImpl ( ViewerImpl && other)
delete

References ViewerImpl().

Here is the call graph for this function:

Member Function Documentation

◆ apply_pending_updates()

void libvgcode::ViewerImpl::apply_pending_updates ( )
private
1497{
1498 if (m_settings.update_view_full_range)
1500
1501 // ORCA: the colors first, which decide the order of the enabled segments
1502 if (m_settings.update_colors)
1503 update_colors();
1504
1505 if (m_settings.update_enabled_entities)
1507}
void update_view_full_range()
Definition ViewerImpl.cpp:2022
void update_colors()
Definition ViewerImpl.cpp:1458
Settings m_settings
Definition ViewerImpl.hpp:245
void update_enabled_entities()
Definition ViewerImpl.cpp:1300

References m_settings, update_colors(), update_enabled_entities(), and update_view_full_range().

Referenced by render(), render_shadow_casters(), and render_translucent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_bounding_box()

1644{
1645 Vec3 min = { FLT_MAX, FLT_MAX, FLT_MAX };
1646 Vec3 max = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
1647 for (const PathVertex& v : m_vertices) {
1648 if (std::find(types.begin(), types.end(), v.type) != types.end()) {
1649 for (int j = 0; j < 3; ++j) {
1650 min[j] = std::min(min[j], v.position[j]);
1651 max[j] = std::max(max[j], v.position[j]);
1652 }
1653 }
1654 }
1655 return { min, max };
1656}
std::vector< PathVertex > m_vertices
Definition ViewerImpl.hpp:331
std::array< float, 3 > Vec3
Definition Types.hpp:40

References m_vertices.

Referenced by load().

Here is the caller graph for this function:

◆ get_color_print_colors()

const PaletteWithAlpha & libvgcode::ViewerImpl::get_color_print_colors ( ) const
inline
198{ return m_color_print_colors; }
PaletteWithAlpha m_color_print_colors
Definition ViewerImpl.hpp:365

References m_color_print_colors.

◆ get_color_print_colors_count()

size_t libvgcode::ViewerImpl::get_color_print_colors_count ( ) const
inline
197{ return m_color_print_colors.size(); }

References m_color_print_colors.

◆ get_color_prints()

std::vector< ColorPrint > libvgcode::ViewerImpl::get_color_prints ( uint8_t extruder_id) const
1638{
1639 const auto it = m_used_extruders.find(extruder_id);
1640 return (it == m_used_extruders.end()) ? std::vector<ColorPrint>() : it->second;
1641}
std::map< uint8_t, std::vector< ColorPrint > > m_used_extruders
Definition ViewerImpl.hpp:261

References m_used_extruders.

◆ get_color_prints_count()

size_t libvgcode::ViewerImpl::get_color_prints_count ( uint8_t extruder_id) const
1632{
1633 const auto it = m_used_extruders.find(extruder_id);
1634 return (it == m_used_extruders.end()) ? 0 : it->second.size();
1635}

References m_used_extruders.

◆ get_color_range()

const ColorRange & libvgcode::ViewerImpl::get_color_range ( EViewType type) const
1889{
1890 switch (type)
1891 {
1892 case EViewType::Height: { return m_height_range; }
1893 case EViewType::Width: { return m_width_range; }
1894 case EViewType::Speed: { return m_speed_range; }
1896 case EViewType::FanSpeed: { return m_fan_speed_range; }
1898// ORCA: Add Pressure Advance visualization support
1900 // ORCA: Add Acceleration visualization support
1902 // ORCA: Add Jerk visualization support
1903 case EViewType::Jerk: { return m_jerk_range; }
1908 default: { return ColorRange::DUMMY_COLOR_RANGE; }
1909 }
1910}
static const ColorRange DUMMY_COLOR_RANGE
Definition ColorRange.hpp:77
std::array< ColorRange, COLOR_RANGE_TYPES_COUNT > m_layer_time_range
Definition ViewerImpl.hpp:361
ColorRange m_height_range
Definition ViewerImpl.hpp:347
ColorRange m_pressure_advance_range
Definition ViewerImpl.hpp:354
ColorRange m_fan_speed_range
Definition ViewerImpl.hpp:351
ColorRange m_volumetric_rate_range
Definition ViewerImpl.hpp:359
ColorRange m_actual_speed_range
Definition ViewerImpl.hpp:350
ColorRange m_speed_range
Definition ViewerImpl.hpp:349
ColorRange m_width_range
Definition ViewerImpl.hpp:348
ColorRange m_temperature_range
Definition ViewerImpl.hpp:352
ColorRange m_acceleration_range
Definition ViewerImpl.hpp:356
ColorRange m_actual_volumetric_rate_range
Definition ViewerImpl.hpp:360
ColorRange m_jerk_range
Definition ViewerImpl.hpp:358
@ Width
Definition Types.hpp:98
@ Acceleration
Definition Types.hpp:108
@ Speed
Definition Types.hpp:95
@ ActualVolumetricFlowRate
Definition Types.hpp:100
@ LayerTimeLogarithmic
Definition Types.hpp:102
@ PressureAdvance
Definition Types.hpp:106
@ ActualSpeed
Definition Types.hpp:96
@ Jerk
Definition Types.hpp:110
@ LayerTimeLinear
Definition Types.hpp:101
@ FanSpeed
Definition Types.hpp:103
@ VolumetricFlowRate
Definition Types.hpp:99
@ Temperature
Definition Types.hpp:104
@ Height
Definition Types.hpp:97

References libvgcode::Acceleration, libvgcode::ActualSpeed, libvgcode::ActualVolumetricFlowRate, libvgcode::ColorRange::DUMMY_COLOR_RANGE, libvgcode::FanSpeed, libvgcode::Height, libvgcode::Jerk, libvgcode::LayerTimeLinear, libvgcode::LayerTimeLogarithmic, m_acceleration_range, m_actual_speed_range, m_actual_volumetric_rate_range, m_fan_speed_range, m_height_range, m_jerk_range, m_layer_time_range, m_pressure_advance_range, m_speed_range, m_temperature_range, m_volumetric_rate_range, m_width_range, libvgcode::PressureAdvance, libvgcode::Speed, libvgcode::Temperature, libvgcode::VolumetricFlowRate, and libvgcode::Width.

◆ get_current_vertex()

const PathVertex & libvgcode::ViewerImpl::get_current_vertex ( ) const
inline
size_t get_current_vertex_id() const
Definition ViewerImpl.hpp:175
const PathVertex & get_vertex_at(size_t id) const
Definition ViewerImpl.hpp:176

References get_current_vertex_id(), and get_vertex_at().

Here is the call graph for this function:

◆ get_current_vertex_id()

size_t libvgcode::ViewerImpl::get_current_vertex_id ( ) const
inline
175{ return static_cast<size_t>(m_view_range.get_visible()[1]); }
ViewRange m_view_range
Definition ViewerImpl.hpp:265

References m_view_range.

Referenced by get_current_vertex().

Here is the caller graph for this function:

◆ get_dim_previous_layers_brightness()

float libvgcode::ViewerImpl::get_dim_previous_layers_brightness ( ) const
inline
124{ return m_settings.dim_previous_layers_brightness; }

References m_settings.

◆ get_estimated_time()

float libvgcode::ViewerImpl::get_estimated_time ( ) const
inline
179{ return m_total_time[static_cast<size_t>(m_settings.time_mode)]; }
std::array< float, TIME_MODES_COUNT > m_total_time
Definition ViewerImpl.hpp:269

References m_settings, and m_total_time.

◆ get_estimated_time_at()

float libvgcode::ViewerImpl::get_estimated_time_at ( size_t id) const
1718{
1719 const size_t mode = static_cast<size_t>(m_settings.time_mode);
1720 if (mode >= TIME_MODES_COUNT || id >= m_vertices.size())
1721 return 0.0f;
1722 size_t first = 0;
1723 float time = 0.0f;
1724 const size_t layer = static_cast<size_t>(m_vertices[id].layer_id);
1725 if (layer < m_layer_first_vertex.size() && m_layer_first_vertex[layer] <= id) {
1726 first = m_layer_first_vertex[layer];
1727 time = m_layer_start_times[mode][layer];
1728 }
1729 for (size_t i = first; i <= id; ++i)
1730 time += m_vertices[i].times[mode];
1731 return time;
1732}
std::array< std::vector< float >, TIME_MODES_COUNT > m_layer_start_times
Definition ViewerImpl.hpp:274
std::vector< uint32_t > m_layer_first_vertex
Definition ViewerImpl.hpp:279
static constexpr std::size_t TIME_MODES_COUNT
Definition Types.hpp:206

References m_layer_first_vertex, m_layer_start_times, m_settings, m_vertices, and libvgcode::TIME_MODES_COUNT.

◆ get_extrusion_bounding_box()

1659{
1660 Vec3 min = { FLT_MAX, FLT_MAX, FLT_MAX };
1661 Vec3 max = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
1662 for (const PathVertex& v : m_vertices) {
1663 if (v.is_extrusion() && std::find(roles.begin(), roles.end(), v.role) != roles.end()) {
1664 for (int j = 0; j < 3; ++j) {
1665 min[j] = std::min(min[j], v.position[j]);
1666 max[j] = std::max(max[j], v.position[j]);
1667 }
1668 }
1669 }
1670 return { min, max };
1671}

References m_vertices.

◆ get_extrusion_role_color()

const Color & libvgcode::ViewerImpl::get_extrusion_role_color ( EGCodeExtrusionRole role) const
1857{
1858 return m_extrusion_roles_colors[size_t(role)];
1859}
std::array< Color, size_t(EGCodeExtrusionRole::COUNT)> m_extrusion_roles_colors
Definition ViewerImpl.hpp:300

References m_extrusion_roles_colors.

Referenced by get_vertex_color().

Here is the caller graph for this function:

◆ get_extrusion_role_estimated_time()

float libvgcode::ViewerImpl::get_extrusion_role_estimated_time ( EGCodeExtrusionRole role) const
inline
185{ return m_extrusion_roles.get_time(role, m_settings.time_mode); }
ExtrusionRoles m_extrusion_roles
Definition ViewerImpl.hpp:253

References m_extrusion_roles, and m_settings.

◆ get_extrusion_roles()

std::vector< EGCodeExtrusionRole > libvgcode::ViewerImpl::get_extrusion_roles ( ) const
inline
184{ return m_extrusion_roles.get_roles(); }

References m_extrusion_roles.

◆ get_extrusion_roles_count()

size_t libvgcode::ViewerImpl::get_extrusion_roles_count ( ) const
inline
183{ return m_extrusion_roles.get_roles_count(); }

References m_extrusion_roles.

◆ get_layer_id_at()

size_t libvgcode::ViewerImpl::get_layer_id_at ( float z) const
inline
139{ return m_layers.get_layer_id_at(z); }
Layers m_layers
Definition ViewerImpl.hpp:249

References m_layers.

◆ get_layer_z()

float libvgcode::ViewerImpl::get_layer_z ( size_t layer_id) const
inline
136{ return m_layers.get_layer_z(layer_id); }

References m_layers.

◆ get_layers_count()

size_t libvgcode::ViewerImpl::get_layers_count ( ) const
inline
135{ return m_layers.count(); }

References m_layers.

◆ get_layers_estimated_times()

std::vector< float > libvgcode::ViewerImpl::get_layers_estimated_times ( ) const
inline
191{ return m_layers.get_times(m_settings.time_mode); }

References m_layers, and m_settings.

◆ get_layers_view_range()

const Interval & libvgcode::ViewerImpl::get_layers_view_range ( ) const
inline
111{ return m_layers.get_view_range(); }

References m_layers.

◆ get_layers_zs()

std::vector< float > libvgcode::ViewerImpl::get_layers_zs ( ) const
inline
137{ return m_layers.get_zs(); }

References m_layers.

◆ get_option_color()

const Color & libvgcode::ViewerImpl::get_option_color ( EOptionType type) const
1873{
1874 return m_options_colors[size_t(type)];
1875}
std::array< Color, size_t(EOptionType::COUNT)> m_options_colors
Definition ViewerImpl.hpp:304

References m_options_colors.

Referenced by get_vertex_color().

Here is the caller graph for this function:

◆ get_options()

const std::vector< EOptionType > & libvgcode::ViewerImpl::get_options ( ) const
inline
188{ return m_options; }
std::vector< EOptionType > m_options
Definition ViewerImpl.hpp:257

References m_options.

◆ get_options_count()

size_t libvgcode::ViewerImpl::get_options_count ( ) const
inline
187{ return m_options.size(); }

References m_options.

◆ get_time_mode()

ETimeMode libvgcode::ViewerImpl::get_time_mode ( ) const
inline
108{ return m_settings.time_mode; }

References m_settings.

◆ get_time_modes()

std::vector< ETimeMode > libvgcode::ViewerImpl::get_time_modes ( ) const
1611{
1612 std::vector<ETimeMode> ret;
1613 for (size_t i = 0; i < TIME_MODES_COUNT; ++i) {
1614 if (std::accumulate(m_vertices.begin(), m_vertices.end(), 0.0f,
1615 [i](float a, const PathVertex& v) { return a + v.times[i]; }) > 0.0f)
1616 ret.push_back(static_cast<ETimeMode>(i));
1617 }
1618 return ret;
1619}
ETimeMode
Definition Types.hpp:200

References m_vertices, and libvgcode::TIME_MODES_COUNT.

◆ get_tool_colors()

const PaletteWithAlpha & libvgcode::ViewerImpl::get_tool_colors ( ) const
inline
194{ return m_tool_colors; }
PaletteWithAlpha m_tool_colors
Definition ViewerImpl.hpp:364

References m_tool_colors.

◆ get_tool_colors_count()

size_t libvgcode::ViewerImpl::get_tool_colors_count ( ) const
inline
193{ return m_tool_colors.size(); }

References m_tool_colors.

◆ get_travels_estimated_time()

float libvgcode::ViewerImpl::get_travels_estimated_time ( ) const
inline
190{ return m_travels_time[static_cast<size_t>(m_settings.time_mode)]; }
std::array< float, TIME_MODES_COUNT > m_travels_time
Definition ViewerImpl.hpp:288

References m_settings, and m_travels_time.

◆ get_travels_radius()

float libvgcode::ViewerImpl::get_travels_radius ( ) const
inline
212{ return m_travels_radius; }
float m_travels_radius
Definition ViewerImpl.hpp:292

References m_travels_radius.

◆ get_used_cpu_memory()

size_t libvgcode::ViewerImpl::get_used_cpu_memory ( ) const
1950{
1951 size_t ret = sizeof(*this);
1952 ret += m_layers.size_in_bytes_cpu();
1954 ret += m_used_extruders.size() * sizeof(std::map<uint8_t, ColorPrint>::value_type);
1955 ret += sizeof(m_extrusion_roles_colors);
1956 ret += sizeof(m_options_colors);
1957 ret += STDVEC_MEMSIZE(m_vertices, PathVertex);
1959 for (const std::vector<float>& times : m_layer_start_times)
1960 ret += STDVEC_MEMSIZE(times, float);
1961 ret += STDVEC_MEMSIZE(m_layer_first_vertex, uint32_t);
1962 ret += m_valid_lines_bitset.size_in_bytes_cpu();
1963 ret += m_height_range.size_in_bytes_cpu();
1964 ret += m_width_range.size_in_bytes_cpu();
1965 ret += m_speed_range.size_in_bytes_cpu();
1966 ret += m_actual_speed_range.size_in_bytes_cpu();
1967 ret += m_fan_speed_range.size_in_bytes_cpu();
1968 ret += m_temperature_range.size_in_bytes_cpu();
1969 // ORCA: Add Pressure Advance visualization support
1970 ret += m_pressure_advance_range.size_in_bytes_cpu();
1971 // ORCA: Add Acceleration visualization support
1972 ret += m_acceleration_range.size_in_bytes_cpu();
1973 // ORCA: Add Jerk visualization support
1974 ret += m_jerk_range.size_in_bytes_cpu();
1975 ret += m_volumetric_rate_range.size_in_bytes_cpu();
1976 ret += m_actual_volumetric_rate_range.size_in_bytes_cpu();
1977 for (size_t i = 0; i < COLOR_RANGE_TYPES_COUNT; ++i) {
1978 ret += m_layer_time_range[i].size_in_bytes_cpu();
1979 }
1982 return ret;
1983}
std::vector< ColorWithAlpha > m_vertices_colors
Definition ViewerImpl.hpp:334
BitSet m_valid_lines_bitset
Definition ViewerImpl.hpp:342
#define STDVEC_MEMSIZE(NAME, TYPE)
|/ Copyright (c) Prusa Research 2023 Enrico Turri @enricoturri1966 |/ |/ libvgcode is released under ...
Definition Utils.hpp:15
static constexpr std::size_t COLOR_RANGE_TYPES_COUNT
Definition Types.hpp:218
EOptionType
Definition Types.hpp:175
std::array< uint8_t, 4 > ColorWithAlpha
Definition Types.hpp:70

References libvgcode::COLOR_RANGE_TYPES_COUNT, m_acceleration_range, m_actual_speed_range, m_actual_volumetric_rate_range, m_color_print_colors, m_extrusion_roles_colors, m_fan_speed_range, m_height_range, m_jerk_range, m_layer_first_vertex, m_layer_start_times, m_layer_time_range, m_layers, m_options, m_options_colors, m_pressure_advance_range, m_speed_range, m_temperature_range, m_tool_colors, m_used_extruders, m_valid_lines_bitset, m_vertices, m_vertices_colors, m_volumetric_rate_range, m_width_range, and STDVEC_MEMSIZE.

◆ get_used_extruders_count()

size_t libvgcode::ViewerImpl::get_used_extruders_count ( ) const
inline
141{ return m_used_extruders.size(); }

References m_used_extruders.

◆ get_used_extruders_ids()

std::vector< uint8_t > libvgcode::ViewerImpl::get_used_extruders_ids ( ) const
1622{
1623 std::vector<uint8_t> ret;
1624 ret.reserve(m_used_extruders.size());
1625 for (const auto& [id, colors] : m_used_extruders) {
1626 ret.emplace_back(id);
1627 }
1628 return ret;
1629}

References m_used_extruders.

◆ get_used_gpu_memory()

size_t libvgcode::ViewerImpl::get_used_gpu_memory ( ) const
1986{
1987 size_t ret = 0;
1988 ret += m_segment_template.size_in_bytes_gpu();
1989 ret += m_option_template.size_in_bytes_gpu();
1990#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
1991 ret += m_tool_marker.size_in_bytes_gpu();
1992 ret += m_cog_marker.size_in_bytes_gpu();
1993#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
1994#ifdef ENABLE_OPENGL_ES
1995 ret += m_texture_data.get_used_gpu_memory();
1996#else
1997 ret += m_positions_tex_size;
1999 ret += m_colors_tex_size;
2002 ret += m_translucent_targets.size_in_bytes();
2003#endif // ENABLE_OPENGL_ES
2004 return ret;
2005}
SegmentTemplate m_segment_template
Definition ViewerImpl.hpp:311
TranslucentTargets m_translucent_targets
Definition ViewerImpl.hpp:616
OptionTemplate m_option_template
Definition ViewerImpl.hpp:315
size_t m_enabled_segments_tex_size
Definition ViewerImpl.hpp:559
size_t m_enabled_options_tex_size
Definition ViewerImpl.hpp:560
size_t m_colors_tex_size
Definition ViewerImpl.hpp:558
size_t m_positions_tex_size
Definition ViewerImpl.hpp:556
size_t m_height_width_angle_tex_size
Definition ViewerImpl.hpp:557

References m_colors_tex_size, m_enabled_options_tex_size, m_enabled_segments_tex_size, m_height_width_angle_tex_size, m_option_template, m_positions_tex_size, m_segment_template, and m_translucent_targets.

◆ get_vertex_alpha()

uint8_t libvgcode::ViewerImpl::get_vertex_alpha ( const PathVertex & v) const
private
1827{
1828 if (!m_settings.translucent_filaments || !v.is_extrusion())
1829 return 255;
1830
1831 switch (m_settings.view_type)
1832 {
1833 case EViewType::Tool:
1834 return m_tool_colors[v.extruder_id][3];
1835 case EViewType::Summary:
1837 return m_layers.layer_contains_colorprint_options(static_cast<size_t>(v.layer_id)) ? 255 :
1838 m_color_print_colors[static_cast<size_t>(v.color_id) % m_color_print_colors.size()][3];
1839 default:
1840 return 255;
1841 }
1842}
@ ColorPrint
Definition Types.hpp:94
@ Summary
Definition Types.hpp:92
@ Tool
Definition Types.hpp:111

References libvgcode::PathVertex::color_id, libvgcode::ColorPrint, libvgcode::PathVertex::extruder_id, libvgcode::PathVertex::is_extrusion(), libvgcode::PathVertex::layer_id, m_color_print_colors, m_layers, m_settings, m_tool_colors, libvgcode::Summary, and libvgcode::Tool.

Referenced by update_colors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_vertex_at()

const PathVertex & libvgcode::ViewerImpl::get_vertex_at ( size_t id) const
inline
176 {
177 return (id < m_vertices.size()) ? m_vertices[id] : PathVertex::DUMMY_PATH_VERTEX;
178 }
static const PathVertex DUMMY_PATH_VERTEX
Definition PathVertex.hpp:137

References libvgcode::PathVertex::DUMMY_PATH_VERTEX, and m_vertices.

Referenced by get_current_vertex().

Here is the caller graph for this function:

◆ get_vertex_color()

Color libvgcode::ViewerImpl::get_vertex_color ( const PathVertex & vertex) const
1735{
1736 if (v.type == EMoveType::Noop)
1737 return DUMMY_COLOR;
1738
1739 if ((v.is_wipe() && (m_settings.view_type != EViewType::Speed && m_settings.view_type != EViewType::ActualSpeed && m_settings.view_type != EViewType::Acceleration && m_settings.view_type != EViewType::Jerk)) || v.is_option())
1740 return get_option_color(move_type_to_option(v.type));
1741
1742 switch (m_settings.view_type)
1743 {
1745 {
1746 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : get_extrusion_role_color(v.role);
1747 }
1748 case EViewType::Height:
1749 {
1750 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_height_range.get_color_at(v.height);
1751 }
1752 case EViewType::Width:
1753 {
1754 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_width_range.get_color_at(v.width);
1755 }
1756 case EViewType::Speed:
1757 {
1758 return m_speed_range.get_color_at(v.feedrate);
1759 }
1761 {
1762 return m_actual_speed_range.get_color_at(v.actual_feedrate);
1763 }
1765 {
1766 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_fan_speed_range.get_color_at(v.fan_speed);
1767 }
1769 {
1770 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_temperature_range.get_color_at(v.temperature);
1771 }
1772// ORCA: Add Pressure Advance visualization support
1774 {
1775 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_pressure_advance_range.get_color_at(v.pressure_advance);
1776 }
1777 // ORCA: Add Acceleration visualization support
1779 {
1780 return m_acceleration_range.get_color_at(v.acceleration);
1781 }
1782 // ORCA: Add Jerk visualization support
1783 case EViewType::Jerk:
1784 {
1785 return m_jerk_range.get_color_at(v.jerk);
1786 }
1788 {
1789 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_volumetric_rate_range.get_color_at(v.volumetric_rate());
1790 }
1792 {
1793 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) : m_actual_volumetric_rate_range.get_color_at(v.actual_volumetric_rate());
1794 }
1796 {
1797 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) :
1798 m_layer_time_range[0].get_color_at(m_layers.get_layer_time(m_settings.time_mode, static_cast<size_t>(v.layer_id)));
1799 }
1801 {
1802 return v.is_travel() ? get_option_color(move_type_to_option(v.type)) :
1803 m_layer_time_range[1].get_color_at(m_layers.get_layer_time(m_settings.time_mode, static_cast<size_t>(v.layer_id)));
1804 }
1805 case EViewType::Tool:
1806 {
1807 assert(static_cast<size_t>(v.extruder_id) < m_tool_colors.size());
1808 const ColorWithAlpha& color = m_tool_colors[v.extruder_id];
1809 return { color[0], color[1], color[2] };
1810 }
1811 case EViewType::Summary: // ORCA
1813 {
1814 if (m_layers.layer_contains_colorprint_options(static_cast<size_t>(v.layer_id)))
1815 return DUMMY_COLOR;
1816 const ColorWithAlpha& color = m_color_print_colors[static_cast<size_t>(v.color_id) % m_color_print_colors.size()];
1817 return { color[0], color[1], color[2] };
1818 }
1819 default: { break; }
1820 }
1821
1822 return DUMMY_COLOR;
1823}
const Color & get_extrusion_role_color(EGCodeExtrusionRole role) const
Definition ViewerImpl.cpp:1856
const Color & get_option_color(EOptionType type) const
Definition ViewerImpl.cpp:1872
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185
zaa_minimize_perimeter_height pressure_advance((ConfigOptionBools, adaptive_pressure_advance))((ConfigOptionBools
EOptionType move_type_to_option(EMoveType type)
Definition Types.cpp:13
@ Noop
Definition Types.hpp:122
static const Color DUMMY_COLOR
Definition Types.hpp:223
@ FeatureType
Definition Types.hpp:93

References libvgcode::Acceleration, libvgcode::PathVertex::acceleration, libvgcode::PathVertex::actual_feedrate, libvgcode::PathVertex::actual_volumetric_rate(), libvgcode::ActualSpeed, libvgcode::ActualVolumetricFlowRate, libvgcode::PathVertex::color_id, libvgcode::ColorPrint, libvgcode::DUMMY_COLOR, libvgcode::PathVertex::extruder_id, libvgcode::PathVertex::fan_speed, libvgcode::FanSpeed, libvgcode::FeatureType, libvgcode::PathVertex::feedrate, get_extrusion_role_color(), get_option_color(), libvgcode::Height, libvgcode::PathVertex::height, libvgcode::PathVertex::is_option(), libvgcode::PathVertex::is_travel(), libvgcode::PathVertex::is_wipe(), libvgcode::Jerk, libvgcode::PathVertex::jerk, libvgcode::PathVertex::layer_id, libvgcode::LayerTimeLinear, libvgcode::LayerTimeLogarithmic, m_acceleration_range, m_actual_speed_range, m_actual_volumetric_rate_range, m_color_print_colors, m_fan_speed_range, m_height_range, m_jerk_range, m_layer_time_range, m_layers, m_pressure_advance_range, m_settings, m_speed_range, m_temperature_range, m_tool_colors, m_volumetric_rate_range, m_width_range, libvgcode::move_type_to_option(), libvgcode::Noop, libvgcode::PathVertex::pressure_advance, libvgcode::PressureAdvance, libvgcode::PathVertex::role, libvgcode::Speed, libvgcode::Summary, libvgcode::Temperature, libvgcode::PathVertex::temperature, libvgcode::Tool, libvgcode::PathVertex::type, libvgcode::PathVertex::volumetric_rate(), libvgcode::VolumetricFlowRate, libvgcode::Width, and libvgcode::PathVertex::width.

Referenced by update_colors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_vertices_count()

size_t libvgcode::ViewerImpl::get_vertices_count ( ) const
inline
173{ return m_vertices.size(); }

References m_vertices.

◆ get_view_enabled_range()

const Interval & libvgcode::ViewerImpl::get_view_enabled_range ( ) const
inline
169{ return m_view_range.get_enabled(); }

References m_view_range.

◆ get_view_full_range()

const Interval & libvgcode::ViewerImpl::get_view_full_range ( ) const
inline
168{ return m_view_range.get_full(); }

References m_view_range.

◆ get_view_type()

EViewType libvgcode::ViewerImpl::get_view_type ( ) const
inline
105{ return m_settings.view_type; }

References m_settings.

◆ get_view_visible_range()

const Interval & libvgcode::ViewerImpl::get_view_visible_range ( ) const
inline
170{ return m_view_range.get_visible(); }

References m_view_range.

◆ get_wipes_radius()

float libvgcode::ViewerImpl::get_wipes_radius ( ) const
inline
214{ return m_wipes_radius; }
float m_wipes_radius
Definition ViewerImpl.hpp:296

References m_wipes_radius.

◆ has_translucent_toolpaths()

bool libvgcode::ViewerImpl::has_translucent_toolpaths ( ) const
inline
size_t m_enabled_translucent_segments_count
Definition ViewerImpl.hpp:337

References m_enabled_translucent_segments_count.

◆ init()

void libvgcode::ViewerImpl::init ( const std::string & opengl_context_version)
791{
792 if (m_initialized)
793 return;
794
795 if (!OpenGLWrapper::load_opengl(opengl_context_version)) {
797 throw std::runtime_error("LibVGCode was unable to initialize the GLAD library.\n");
798 else {
799#ifdef ENABLE_OPENGL_ES
800 throw std::runtime_error("LibVGCode requires an OpenGL ES context based on OpenGL ES 3.0 or higher.\n");
801#else
802 throw std::runtime_error("LibVGCode requires an OpenGL context based on OpenGL 3.2 or higher.\n");
803#endif // ENABLE_OPENGL_ES
804 }
805 }
806
807 // segments shader
808#ifdef ENABLE_OPENGL_ES
810#else
811 m_segments_shader_id = init_shader("segments", Segments_Vertex_Shader, Segments_Fragment_Shader, { "fragment_color", "oit_reveal", "oit_front" });
821 const std::string depth_vs = with_define(Segments_Vertex_Shader, "DEPTH_ONLY");
822 const std::string depth_fs = with_define(Segments_Fragment_Shader, "DEPTH_ONLY");
823 m_segments_depth_shader_id = init_shader("segments_depth", depth_vs.c_str(), depth_fs.c_str(), { "fragment_color", "oit_reveal", "oit_front" });
826#endif // ENABLE_OPENGL_ES
827
829 // ORCA: realistic view
839 glcheck();
840 assert(m_uni_segments.view_matrix != -1 &&
841 m_uni_segments.projection_matrix != -1 &&
842 m_uni_segments.camera_position != -1 &&
843 m_uni_segments.positions_tex != -1 &&
844 m_uni_segments.height_width_angle_tex != -1 &&
845 m_uni_segments.colors_tex != -1 &&
846 m_uni_segments.segment_index_tex != -1 &&
847 m_uni_segments.reverse_order != -1 &&
848 m_uni_segments.instances_count != -1);
849
850 // ORCA: realistic view
851#ifdef ENABLE_OPENGL_ES
853#else
855#endif // ENABLE_OPENGL_ES
857 // The caster pulls its vertices from gl_VertexID, but a core profile needs a vertex array bound to draw.
859 glcheck();
860
861 m_segment_template.init();
862
863 // options shader
864#ifdef ENABLE_OPENGL_ES
866#else
868#endif // ENABLE_OPENGL_ES
869
876 // ORCA: section view
879 glcheck();
880 assert(m_uni_options_view_matrix_id != -1 &&
886
887 m_option_template.init(16);
888
889#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
890 // cog marker shader
891#ifdef ENABLE_OPENGL_ES
892 m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader_ES, Cog_Marker_Fragment_Shader_ES);
893#else
894 m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader, Cog_Marker_Fragment_Shader);
895#endif // ENABLE_OPENGL_ES
896
897 m_uni_cog_marker_world_center_position = glGetUniformLocation(m_cog_marker_shader_id, "world_center_position");
898 m_uni_cog_marker_scale_factor = glGetUniformLocation(m_cog_marker_shader_id, "scale_factor");
899 m_uni_cog_marker_view_matrix = glGetUniformLocation(m_cog_marker_shader_id, "view_matrix");
900 m_uni_cog_marker_projection_matrix = glGetUniformLocation(m_cog_marker_shader_id, "projection_matrix");
901 glcheck();
902 assert(m_uni_cog_marker_world_center_position != -1 &&
903 m_uni_cog_marker_scale_factor != -1 &&
904 m_uni_cog_marker_view_matrix != -1 &&
905 m_uni_cog_marker_projection_matrix != -1);
906
907 m_cog_marker.init(32, 1.0f);
908
909 // tool marker shader
910#ifdef ENABLE_OPENGL_ES
911 m_tool_marker_shader_id = init_shader("tool_marker", Tool_Marker_Vertex_Shader_ES, Tool_Marker_Fragment_Shader_ES);
912#else
913 m_tool_marker_shader_id = init_shader("tool_marker", Tool_Marker_Vertex_Shader, Tool_Marker_Fragment_Shader);
914#endif // ENABLE_OPENGL_ES
915
916 m_uni_tool_marker_world_origin = glGetUniformLocation(m_tool_marker_shader_id, "world_origin");
917 m_uni_tool_marker_scale_factor = glGetUniformLocation(m_tool_marker_shader_id, "scale_factor");
918 m_uni_tool_marker_view_matrix = glGetUniformLocation(m_tool_marker_shader_id, "view_matrix");
919 m_uni_tool_marker_projection_matrix = glGetUniformLocation(m_tool_marker_shader_id, "projection_matrix");
920 m_uni_tool_marker_color_base = glGetUniformLocation(m_tool_marker_shader_id, "color_base");
921
922 glcheck();
923 assert(m_uni_tool_marker_world_origin != -1 &&
924 m_uni_tool_marker_scale_factor != -1 &&
925 m_uni_tool_marker_view_matrix != -1 &&
926 m_uni_tool_marker_projection_matrix != -1 &&
927 m_uni_tool_marker_color_base != -1);
928
929 m_tool_marker.init(32, 2.0f, 4.0f, 1.0f, 8.0f);
930#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
931
932 m_initialized = true;
933}
#define glcheck()
Definition OpenGLUtils.hpp:26
#define glsafe(cmd)
Definition OpenGLUtils.hpp:25
static bool is_valid_context()
Definition OpenGLUtils.hpp:38
static bool load_opengl(const std::string &context_version)
Definition OpenGLUtils.cpp:49
int m_uni_translucent_composite_reveal_tex_id
Definition ViewerImpl.hpp:619
int m_uni_options_segment_index_tex_id
Definition ViewerImpl.hpp:427
int m_uni_segments_exposure_id
Definition ViewerImpl.hpp:404
int m_uni_translucent_composite_front_tex_id
Definition ViewerImpl.hpp:620
int m_uni_options_clipping_plane_id
Definition ViewerImpl.hpp:428
int m_uni_segments_shadow_map_texel_id
Definition ViewerImpl.hpp:403
int m_uni_options_projection_matrix_id
Definition ViewerImpl.hpp:423
unsigned int m_options_shader_id
Definition ViewerImpl.hpp:373
LayerColorsUniforms m_uni_segments_layer_colors
Definition ViewerImpl.hpp:418
int m_uni_options_height_width_angle_tex_id
Definition ViewerImpl.hpp:425
int m_uni_segments_gloss_id
Definition ViewerImpl.hpp:407
int m_uni_translucent_composite_accum_tex_id
Definition ViewerImpl.hpp:618
int m_uni_segments_front_depth_id
Definition ViewerImpl.hpp:624
unsigned int m_segments_depth_shader_id
Definition ViewerImpl.hpp:627
SegmentsUniforms m_uni_segments_caster
Definition ViewerImpl.hpp:399
LayerColorsUniforms m_uni_options_layer_colors
Definition ViewerImpl.hpp:429
int m_uni_segments_depth_opaque_depth_id
Definition ViewerImpl.hpp:629
int m_uni_options_positions_tex_id
Definition ViewerImpl.hpp:424
unsigned int m_segments_caster_shader_id
Definition ViewerImpl.hpp:371
unsigned int m_segments_caster_vao_id
Definition ViewerImpl.hpp:372
bool m_initialized
Definition ViewerImpl.hpp:306
int m_uni_segments_light_top_dir_id
Definition ViewerImpl.hpp:406
int m_uni_segments_oit_pass_id
Definition ViewerImpl.hpp:622
int m_uni_segments_shadow_light_vp_id
Definition ViewerImpl.hpp:401
int m_uni_segments_shadow_intensity_id
Definition ViewerImpl.hpp:402
int m_uni_segments_shadow_map_id
Definition ViewerImpl.hpp:400
unsigned int m_segments_shader_id
Definition ViewerImpl.hpp:369
int m_uni_translucent_composite_origin_id
Definition ViewerImpl.hpp:621
SegmentsUniforms m_uni_segments
Definition ViewerImpl.hpp:398
int m_uni_segments_oit_depth_range_id
Definition ViewerImpl.hpp:625
int m_uni_segments_saturation_id
Definition ViewerImpl.hpp:405
int m_uni_segments_opaque_depth_id
Definition ViewerImpl.hpp:623
int m_uni_options_view_matrix_id
Definition ViewerImpl.hpp:422
int m_uni_options_colors_tex_id
Definition ViewerImpl.hpp:426
unsigned int m_translucent_composite_shader_id
Definition ViewerImpl.hpp:617
SegmentsUniforms m_uni_segments_depth
Definition ViewerImpl.hpp:628
#define glGetUniformLocation
Definition gl.h:4049
#define glGenVertexArrays
Definition gl.h:3791
static const char * Segments_Vertex_Shader_ES
Definition ShadersES.hpp:13
static const char * Options_Vertex_Shader_ES
Definition ShadersES.hpp:462
static const char * Options_Vertex_Shader
Definition Shaders.hpp:522
static const char * Segments_Vertex_Shader
Definition Shaders.hpp:13
static const char * Segments_Shadow_Caster_Vertex_Shader
Definition Shaders.hpp:243
static std::string with_define(const char *source, const char *define)
Definition ViewerImpl.cpp:307
static const char * Segments_Shadow_Caster_Fragment_Shader_ES
Definition ShadersES.hpp:284
unsigned int init_shader(const std::string &shader_name, const char *vertex_shader, const char *fragment_shader, const std::vector< const char * > &fragment_outputs={})
Definition ViewerImpl.cpp:235
static const char * Segments_Shadow_Caster_Fragment_Shader
Definition Shaders.hpp:286
static const char * Options_Fragment_Shader_ES
Definition ShadersES.hpp:534
static const char * Translucent_Composite_Vertex_Shader
Definition Shaders.hpp:495
static const char * Translucent_Composite_Fragment_Shader
Definition Shaders.hpp:502
static const char * Segments_Fragment_Shader
Definition Shaders.hpp:303
static const char * Options_Fragment_Shader
Definition Shaders.hpp:596
static const char * Segments_Shadow_Caster_Vertex_Shader_ES
Definition ShadersES.hpp:232
static const char * Segments_Fragment_Shader_ES
Definition ShadersES.hpp:303

References glcheck, glGenVertexArrays, glGetUniformLocation, glsafe, libvgcode::init_shader(), libvgcode::OpenGLWrapper::is_valid_context(), libvgcode::OpenGLWrapper::load_opengl(), m_initialized, m_option_template, m_options_shader_id, m_segment_template, m_segments_caster_shader_id, m_segments_caster_vao_id, m_segments_depth_shader_id, m_segments_shader_id, m_translucent_composite_shader_id, m_uni_options_clipping_plane_id, m_uni_options_colors_tex_id, m_uni_options_height_width_angle_tex_id, m_uni_options_layer_colors, m_uni_options_positions_tex_id, m_uni_options_projection_matrix_id, m_uni_options_segment_index_tex_id, m_uni_options_view_matrix_id, m_uni_segments, m_uni_segments_caster, m_uni_segments_depth, m_uni_segments_depth_opaque_depth_id, m_uni_segments_exposure_id, m_uni_segments_front_depth_id, m_uni_segments_gloss_id, m_uni_segments_layer_colors, m_uni_segments_light_top_dir_id, m_uni_segments_oit_depth_range_id, m_uni_segments_oit_pass_id, m_uni_segments_opaque_depth_id, m_uni_segments_saturation_id, m_uni_segments_shadow_intensity_id, m_uni_segments_shadow_light_vp_id, m_uni_segments_shadow_map_id, m_uni_segments_shadow_map_texel_id, m_uni_translucent_composite_accum_tex_id, m_uni_translucent_composite_front_tex_id, m_uni_translucent_composite_origin_id, m_uni_translucent_composite_reveal_tex_id, libvgcode::Options_Fragment_Shader, libvgcode::Options_Fragment_Shader_ES, libvgcode::Options_Vertex_Shader, libvgcode::Options_Vertex_Shader_ES, libvgcode::Segments_Fragment_Shader, libvgcode::Segments_Fragment_Shader_ES, libvgcode::Segments_Shadow_Caster_Fragment_Shader, libvgcode::Segments_Shadow_Caster_Fragment_Shader_ES, libvgcode::Segments_Shadow_Caster_Vertex_Shader, libvgcode::Segments_Shadow_Caster_Vertex_Shader_ES, libvgcode::Segments_Vertex_Shader, libvgcode::Segments_Vertex_Shader_ES, libvgcode::Translucent_Composite_Fragment_Shader, libvgcode::Translucent_Composite_Vertex_Shader, and libvgcode::with_define().

Here is the call graph for this function:

◆ is_dim_previous_layers()

bool libvgcode::ViewerImpl::is_dim_previous_layers ( ) const
inline
122{ return m_settings.dim_previous_layers; }

References m_settings.

◆ is_extrusion_role_visible()

bool libvgcode::ViewerImpl::is_extrusion_role_visible ( EGCodeExtrusionRole role) const
1696{
1697 return m_settings.extrusion_roles_visibility[size_t(role)];
1698}

References m_settings.

◆ is_option_visible()

bool libvgcode::ViewerImpl::is_option_visible ( EOptionType type) const
1674{
1675 return m_settings.options_visibility[size_t(type)];
1676}

References m_settings.

◆ is_spiral_vase_mode()

bool libvgcode::ViewerImpl::is_spiral_vase_mode ( ) const
inline
131{ return m_settings.spiral_vase_mode; }

References m_settings.

◆ is_top_layer_only_view_range()

bool libvgcode::ViewerImpl::is_top_layer_only_view_range ( ) const
inline
115{ return m_settings.top_layer_only_view_range; }

References m_settings.

◆ is_translucent_filaments()

bool libvgcode::ViewerImpl::is_translucent_filaments ( ) const
inline
128{ return m_settings.translucent_filaments; }

References m_settings.

◆ load()

void libvgcode::ViewerImpl::load ( GCodeInputData && gcode_data)
1122{
1123 if (!m_initialized)
1124 return;
1125
1126 if (gcode_data.vertices.empty())
1127 return;
1128
1129 reset();
1130
1131 m_vertices = std::move(gcode_data.vertices);
1132 m_tool_colors = std::move(gcode_data.tools_colors);
1133 m_color_print_colors = std::move(gcode_data.color_print_colors);
1134 m_vertices_colors.resize(m_vertices.size());
1135
1136 m_settings.spiral_vase_mode = gcode_data.spiral_vase_mode;
1137
1139 for (size_t i = 0; i < m_vertices.size(); ++i) {
1140 const PathVertex& v = m_vertices[i];
1141
1142 m_layers.update(v, static_cast<uint32_t>(i));
1143
1144 for (size_t j = 0; j < TIME_MODES_COUNT; ++j) {
1145 m_total_time[j] += v.times[j];
1146 if (v.type == EMoveType::Travel)
1147 m_travels_time[j] += v.times[j];
1148 }
1149
1150 const EOptionType option_type = move_type_to_option(v.type);
1151 if (option_type != EOptionType::COUNT)
1152 m_options.emplace_back(option_type);
1153
1154 if (v.type == EMoveType::Extrude) {
1155 m_extrusion_roles.add(v.role, v.times);
1156
1157 auto estruder_it = m_used_extruders.find(v.extruder_id);
1158 if (estruder_it == m_used_extruders.end())
1159 estruder_it = m_used_extruders.insert({ v.extruder_id, std::vector<ColorPrint>() }).first;
1160 if (estruder_it->second.empty() || estruder_it->second.back().color_id != v.color_id) {
1161 const ColorPrint cp = { v.extruder_id, v.color_id, v.layer_id, m_total_time };
1162 estruder_it->second.emplace_back(cp);
1163 }
1164 }
1165
1166 if (i > 0) {
1167#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
1168 // updates calculation for center of gravity
1169 if (v.type == EMoveType::Extrude &&
1170 v.role != EGCodeExtrusionRole::Skirt &&
1174 v.role != EGCodeExtrusionRole::Custom &&
1175 v.role != EGCodeExtrusionRole::Brim &&
1177 m_cog_marker.update(0.5f * (v.position + m_vertices[i - 1].position), v.weight);
1178 }
1179#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
1180 }
1181 }
1182
1183 // Populate layer_duration for each vertex from the accumulated layer times
1184 for (PathVertex& v : m_vertices) {
1185 v.layer_duration = m_layers.get_layer_time(m_settings.time_mode, static_cast<size_t>(v.layer_id));
1186 }
1187
1188 // Index of the first vertex of each layer, walked back to front so that a layer with no
1189 // vertex of its own inherits the next layer's index and the array stays non-decreasing.
1190 if (!m_layers.empty()) {
1191 const uint32_t vertices_count = static_cast<uint32_t>(m_vertices.size());
1192 m_layer_first_vertex.assign(m_layers.count(), vertices_count);
1193 for (uint32_t i = vertices_count; i > 0; --i) {
1194 const uint32_t layer_id = m_vertices[i - 1].layer_id;
1195 if (layer_id < m_layer_first_vertex.size())
1196 m_layer_first_vertex[layer_id] = i - 1;
1197 }
1198 for (size_t i = m_layer_first_vertex.size() - 1; i > 0; --i)
1200 m_layers_in_vertex_order = std::is_sorted(m_vertices.begin(), m_vertices.end(),
1201 [](const PathVertex& a, const PathVertex& b) { return a.layer_id < b.layer_id; });
1202
1203 // the running time at each layer's first vertex, summed in vertex order so that
1204 // get_estimated_time_at() matches a full accumulation exactly
1205 std::array<float, TIME_MODES_COUNT> running{};
1206 for (std::vector<float>& times : m_layer_start_times)
1207 times.assign(m_layer_first_vertex.size(), 0.0f);
1208 size_t layer = 0;
1209 for (size_t i = 0; i <= m_vertices.size(); ++i) {
1210 for (; layer < m_layer_first_vertex.size() && m_layer_first_vertex[layer] == i; ++layer) {
1211 for (size_t j = 0; j < TIME_MODES_COUNT; ++j)
1212 m_layer_start_times[j][layer] = running[j];
1213 }
1214 if (i < m_vertices.size()) {
1215 for (size_t j = 0; j < TIME_MODES_COUNT; ++j)
1216 running[j] += m_vertices[i].times[j];
1217 }
1218 }
1219 }
1220
1221 if (!m_layers.empty())
1222 m_layers.set_view_range(0, static_cast<uint32_t>(m_layers.count()) - 1);
1223
1224 std::sort(m_options.begin(), m_options.end());
1225 m_options.erase(std::unique(m_options.begin(), m_options.end()), m_options.end());
1226 m_options.shrink_to_fit();
1227
1228 // reset segments visibility bitset
1229 m_valid_lines_bitset = BitSet<>(m_vertices.size());
1230 m_valid_lines_bitset.setAll();
1231
1232 if (m_settings.time_mode != ETimeMode::Normal && m_total_time[static_cast<size_t>(m_settings.time_mode)] == 0.0f)
1233 m_settings.time_mode = ETimeMode::Normal;
1234
1235 // buffers to send to gpu
1236 // the last component is a dummy float to comply with GL_RGBA32F format
1237 std::vector<Vec4> positions;
1238 std::vector<Vec4> heights_widths_angles;
1239 positions.reserve(m_vertices.size());
1240 heights_widths_angles.reserve(m_vertices.size());
1241 extract_pos_and_or_hwa(m_vertices, m_travels_radius, m_wipes_radius, m_valid_lines_bitset, &positions, &heights_widths_angles, true);
1242
1243 if (!positions.empty()) {
1244#ifdef ENABLE_OPENGL_ES
1245 m_texture_data.init(positions.size());
1246 // create and fill position textures
1247 m_texture_data.set_positions(positions);
1248 // create and fill height, width and angle textures
1249 m_texture_data.set_heights_widths_angles(heights_widths_angles);
1250#else
1251 m_positions_tex_size = positions.size() * sizeof(Vec3);
1252 m_height_width_angle_tex_size = heights_widths_angles.size() * sizeof(Vec3);
1253
1254 int old_bound_texture = 0;
1255 glsafe(glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, &old_bound_texture));
1256
1257 // create and fill positions buffer
1260 glsafe(glBufferData(GL_TEXTURE_BUFFER, positions.size() * sizeof(Vec4), positions.data(), GL_STATIC_DRAW));
1263
1264 // create and fill height, width and angles buffer
1267 glsafe(glBufferData(GL_TEXTURE_BUFFER, heights_widths_angles.size() * sizeof(Vec4), heights_widths_angles.data(), GL_DYNAMIC_DRAW));
1270
1271 // create (but do not fill) colors buffer (data is set in update_colors())
1276
1277 // create (but do not fill) enabled segments buffer (data is set in update_enabled_entities())
1282
1283 // create (but do not fill) enabled options buffer (data is set in update_enabled_entities())
1288
1290 glsafe(glBindTexture(GL_TEXTURE_BUFFER, old_bound_texture));
1291#endif // ENABLE_OPENGL_ES
1292 }
1293
1295 m_view_range.set_visible(m_view_range.get_enabled());
1296 update_colors();
1298}
unsigned int m_heights_widths_angles_buf_id
Definition ViewerImpl.hpp:534
unsigned int m_heights_widths_angles_tex_id
Definition ViewerImpl.hpp:535
unsigned int m_enabled_options_buf_id
Definition ViewerImpl.hpp:550
unsigned int m_enabled_options_tex_id
Definition ViewerImpl.hpp:551
AABox get_bounding_box(const std::vector< EMoveType > &types={ EMoveType::Retract, EMoveType::Unretract, EMoveType::Seam, EMoveType::ToolChange, EMoveType::ColorChange, EMoveType::PausePrint, EMoveType::CustomGCode, EMoveType::Travel, EMoveType::Wipe, EMoveType::Extrude }) const
Definition ViewerImpl.cpp:1643
unsigned int m_colors_buf_id
Definition ViewerImpl.hpp:539
unsigned int m_positions_tex_id
Definition ViewerImpl.hpp:530
AABox m_extrusions_box
Definition ViewerImpl.hpp:590
unsigned int m_positions_buf_id
Definition ViewerImpl.hpp:529
void reset()
Definition ViewerImpl.cpp:974
unsigned int m_colors_tex_id
Definition ViewerImpl.hpp:540
bool m_layers_in_vertex_order
Definition ViewerImpl.hpp:284
unsigned int m_enabled_segments_tex_id
Definition ViewerImpl.hpp:545
unsigned int m_enabled_segments_buf_id
Definition ViewerImpl.hpp:544
#define glGenBuffers
Definition gl.h:3769
#define glBindBuffer
Definition gl.h:3267
#define glGetIntegerv
Definition gl.h:3873
#define GL_TEXTURE_BUFFER
Definition gl.h:1763
#define GL_TEXTURE_BINDING_BUFFER
Definition gl.h:1754
#define glGenTextures
Definition gl.h:3787
#define glBufferData
Definition gl.h:3339
#define glBindTexture
Definition gl.h:3299
#define GL_STATIC_DRAW
Definition gl.h:1633
#define GL_DYNAMIC_DRAW
Definition gl.h:627
@ Travel
Definition Types.hpp:130
@ Extrude
Definition Types.hpp:132
static void extract_pos_and_or_hwa(const std::vector< PathVertex > &vertices, float travels_radius, float wipes_radius, BitSet<> &valid_lines_bitset, std::vector< Vec4 > *positions=nullptr, std::vector< Vec4 > *heights_widths_angles=nullptr, bool update_bitset=false)
Definition ViewerImpl.cpp:1048
@ Brim
Definition Types.hpp:163
@ SupportTransition
Definition Types.hpp:164
@ SupportMaterialInterface
Definition Types.hpp:157
@ Custom
Definition Types.hpp:159
@ WipeTower
Definition Types.hpp:158
@ Skirt
Definition Types.hpp:155
@ SupportMaterial
Definition Types.hpp:156
@ COUNT
Definition Types.hpp:191
std::array< float, 4 > Vec4
Definition Types.hpp:42
@ Normal
Definition Types.hpp:201

References libvgcode::Brim, libvgcode::PathVertex::color_id, libvgcode::COUNT, libvgcode::Custom, libvgcode::extract_pos_and_or_hwa(), libvgcode::Extrude, libvgcode::PathVertex::extruder_id, get_bounding_box(), GL_DYNAMIC_DRAW, GL_STATIC_DRAW, GL_TEXTURE_BINDING_BUFFER, GL_TEXTURE_BUFFER, glBindBuffer, glBindTexture, glBufferData, glGenBuffers, glGenTextures, glGetIntegerv, glsafe, libvgcode::PathVertex::layer_id, m_color_print_colors, m_colors_buf_id, m_colors_tex_id, m_enabled_options_buf_id, m_enabled_options_tex_id, m_enabled_segments_buf_id, m_enabled_segments_tex_id, m_extrusion_roles, m_extrusions_box, m_height_width_angle_tex_size, m_heights_widths_angles_buf_id, m_heights_widths_angles_tex_id, m_initialized, m_layer_first_vertex, m_layer_start_times, m_layers, m_layers_in_vertex_order, m_options, m_positions_buf_id, m_positions_tex_id, m_positions_tex_size, m_settings, m_tool_colors, m_total_time, m_travels_radius, m_travels_time, m_used_extruders, m_valid_lines_bitset, m_vertices, m_vertices_colors, m_view_range, m_wipes_radius, libvgcode::move_type_to_option(), libvgcode::Normal, libvgcode::PathVertex::position, reset(), libvgcode::PathVertex::role, libvgcode::Skirt, libvgcode::SupportMaterial, libvgcode::SupportMaterialInterface, libvgcode::SupportTransition, libvgcode::TIME_MODES_COUNT, libvgcode::PathVertex::times, libvgcode::Travel, libvgcode::PathVertex::type, update_colors(), update_enabled_entities(), update_view_full_range(), and libvgcode::WipeTower.

Here is the call graph for this function:

◆ operator=() [1/2]

ViewerImpl & libvgcode::ViewerImpl::operator= ( const ViewerImpl & other)
delete

References ViewerImpl().

Here is the call graph for this function:

◆ operator=() [2/2]

ViewerImpl & libvgcode::ViewerImpl::operator= ( ViewerImpl && other)
delete

References ViewerImpl().

Here is the call graph for this function:

◆ render()

void libvgcode::ViewerImpl::render ( const Mat4x4 & view_matrix,
const Mat4x4 & projection_matrix )
1510{
1512
1513 const Mat4x4 inv_view_matrix = inverse(view_matrix);
1514 const Vec3 camera_position = { inv_view_matrix[12], inv_view_matrix[13], inv_view_matrix[14] };
1515 render_segments(view_matrix, projection_matrix, camera_position);
1516 render_options(view_matrix, projection_matrix);
1517
1518#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
1519 if (m_settings.options_visibility[size_t(EOptionType::ToolMarker)])
1520 render_tool_marker(view_matrix, projection_matrix);
1521 if (m_settings.options_visibility[size_t(EOptionType::CenterOfGravity)])
1522 render_cog_marker(view_matrix, projection_matrix);
1523#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
1524}
void apply_pending_updates()
Definition ViewerImpl.cpp:1496
void render_segments(const Mat4x4 &view_matrix, const Mat4x4 &projection_matrix, const Vec3 &camera_position, bool translucent=false)
Definition ViewerImpl.cpp:2218
void render_options(const Mat4x4 &view_matrix, const Mat4x4 &projection_matrix)
Definition ViewerImpl.cpp:2399
std::array< float, 16 > Mat4x4
Definition Types.hpp:51
static Mat4x4 inverse(const Mat4x4 &m)
Definition ViewerImpl.cpp:77

References apply_pending_updates(), libvgcode::inverse(), m_settings, render_options(), and render_segments().

Here is the call graph for this function:

◆ render_options()

void libvgcode::ViewerImpl::render_options ( const Mat4x4 & view_matrix,
const Mat4x4 & projection_matrix )
private
2400{
2401 if (m_options_shader_id == 0)
2402 return;
2403
2404#ifdef ENABLE_OPENGL_ES
2405 if (m_texture_data.get_enabled_options_count() == 0)
2406#else
2407 if (m_enabled_options_count == 0)
2408#endif // ENABLE_OPENGL_ES
2409 return;
2410
2411 int curr_active_texture = 0;
2412 glsafe(glGetIntegerv(GL_ACTIVE_TEXTURE, &curr_active_texture));
2413 int curr_shader;
2414 glsafe(glGetIntegerv(GL_CURRENT_PROGRAM, &curr_shader));
2415 const bool curr_cull_face = glIsEnabled(GL_CULL_FACE);
2416 glcheck();
2417
2419
2428
2430
2431#ifdef ENABLE_OPENGL_ES
2432 int curr_bound_texture = 0;
2433 glsafe(glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_bound_texture));
2434
2435 for (size_t i = 0; i < m_texture_data.get_count(); ++i) {
2436 const auto [id, count] = m_texture_data.get_enabled_options_tex_id(i);
2437 if (count == 0)
2438 continue;
2440 glsafe(glBindTexture(GL_TEXTURE_2D, m_texture_data.get_positions_tex_id(i).first));
2442 glsafe(glBindTexture(GL_TEXTURE_2D, m_texture_data.get_heights_widths_angles_tex_id(i).first));
2444 glsafe(glBindTexture(GL_TEXTURE_2D, m_texture_data.get_colors_tex_id(i).first));
2447 m_option_template.render(count);
2448 }
2449#else
2450 std::array<int, 4> curr_bound_texture = { 0, 0, 0, 0 };
2451 for (int i = 0; i < curr_bound_texture.size(); ++i) {
2453 glsafe(glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, &curr_bound_texture[i]));
2454 //assert(curr_bound_texture[i] == 0);
2455 }
2456
2469
2471#endif // ENABLE_OPENGL_ES
2472
2473 if (!curr_cull_face)
2475
2476 glsafe(glUseProgram(curr_shader));
2477#ifdef ENABLE_OPENGL_ES
2478 glsafe(glBindTexture(GL_TEXTURE_2D, curr_bound_texture));
2479#else
2480 for (int i = 0; i < curr_bound_texture.size(); ++i) {
2482 glsafe(glBindTexture(GL_TEXTURE_BUFFER, curr_bound_texture[i]));
2483 }
2484#endif // ENABLE_OPENGL_ES
2485 glsafe(glActiveTexture(curr_active_texture));
2486}
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246
size_t m_enabled_options_count
Definition ViewerImpl.hpp:552
std::array< float, 4 > m_clipping_plane
Definition ViewerImpl.hpp:587
void set_layer_colors(const LayerColorsUniforms &uni) const
Definition ViewerImpl.cpp:1429
#define GL_TEXTURE2
Definition gl.h:1717
#define GL_TEXTURE3
Definition gl.h:1728
#define GL_R32UI
Definition gl.h:1397
#define GL_TEXTURE0
Definition gl.h:1705
#define GL_TEXTURE1
Definition gl.h:1706
#define glUniformMatrix4fv
Definition gl.h:5069
#define GL_CURRENT_PROGRAM
Definition gl.h:508
#define glUniform4fv
Definition gl.h:5031
#define GL_RGBA8
Definition gl.h:1505
#define glEnable
Definition gl.h:3667
#define glTexBuffer
Definition gl.h:4787
#define GL_ACTIVE_TEXTURE
Definition gl.h:204
#define GL_CULL_FACE
Definition gl.h:500
#define GL_FALSE
Definition gl.h:648
#define glUniform1i
Definition gl.h:4985
#define glIsEnabled
Definition gl.h:4165
#define GL_RGBA32F
Definition gl.h:1501
#define GL_TEXTURE_2D
Definition gl.h:1739
#define glUseProgram
Definition gl.h:5085
#define glDisable
Definition gl.h:3607
#define GL_TEXTURE_BINDING_2D
Definition gl.h:1749
#define glActiveTexture
Definition gl.h:3245

References count, GL_ACTIVE_TEXTURE, GL_CULL_FACE, GL_CURRENT_PROGRAM, GL_FALSE, GL_R32UI, GL_RGBA32F, GL_RGBA8, GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_TEXTURE3, GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D, GL_TEXTURE_BINDING_BUFFER, GL_TEXTURE_BUFFER, glActiveTexture, glBindTexture, glcheck, glDisable, glEnable, glGetIntegerv, glIsEnabled, glsafe, glTexBuffer, glUniform1i, glUniform4fv, glUniformMatrix4fv, glUseProgram, m_clipping_plane, m_colors_buf_id, m_colors_tex_id, m_enabled_options_buf_id, m_enabled_options_count, m_enabled_options_tex_id, m_heights_widths_angles_buf_id, m_heights_widths_angles_tex_id, m_option_template, m_options_shader_id, m_positions_buf_id, m_positions_tex_id, m_uni_options_clipping_plane_id, m_uni_options_colors_tex_id, m_uni_options_height_width_angle_tex_id, m_uni_options_layer_colors, m_uni_options_positions_tex_id, m_uni_options_projection_matrix_id, m_uni_options_segment_index_tex_id, m_uni_options_view_matrix_id, and set_layer_colors().

Referenced by render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_segments()

void libvgcode::ViewerImpl::render_segments ( const Mat4x4 & view_matrix,
const Mat4x4 & projection_matrix,
const Vec3 & camera_position,
bool translucent = false )
private
2219{
2220 // ORCA: realistic view. The shadow caster pass draws depth only, as does the first order independent pass.
2221#ifndef ENABLE_OPENGL_ES
2222 const bool depth_only = m_translucent_pass == 1;
2225#else
2226 const bool depth_only = false;
2229#endif // ENABLE_OPENGL_ES
2230 if (shader_id == 0)
2231 return;
2232
2233#ifdef ENABLE_OPENGL_ES
2234 if (m_texture_data.get_enabled_segments_count() == 0)
2235#else
2236 if (m_enabled_segments_count == 0)
2237#endif // ENABLE_OPENGL_ES
2238 return;
2239
2240 int curr_active_texture = 0;
2241 glsafe(glGetIntegerv(GL_ACTIVE_TEXTURE, &curr_active_texture));
2242 int curr_shader;
2243 glsafe(glGetIntegerv(GL_CURRENT_PROGRAM, &curr_shader));
2244 const bool curr_cull_face = glIsEnabled(GL_CULL_FACE);
2245 glcheck();
2246
2247 glsafe(glUseProgram(shader_id));
2248
2249 glsafe(glUniform1i(uni.positions_tex, 0));
2250 glsafe(glUniform1i(uni.height_width_angle_tex, 1));
2251 glsafe(glUniform1i(uni.colors_tex, 2));
2252 glsafe(glUniform1i(uni.segment_index_tex, 3));
2253 glsafe(glUniformMatrix4fv(uni.view_matrix, 1, GL_FALSE, view_matrix.data()));
2254 glsafe(glUniformMatrix4fv(uni.projection_matrix, 1, GL_FALSE, projection_matrix.data()));
2255 glsafe(glUniform3fv(uni.camera_position, 1, camera_position.data()));
2256 // ORCA: view_matrix(2,2) > 0 is looking down, where the last segments printed are the nearest.
2257 // Blending goes the other way, from the farthest.
2258 const bool reverse_order = (view_matrix[10] > 0.0f) != translucent;
2259 glsafe(glUniform1i(uni.reverse_order, reverse_order ? 1 : 0));
2260 glsafe(glUniform4fv(uni.clipping_plane, 1, m_clipping_plane.data()));
2261#ifndef ENABLE_OPENGL_ES
2262 if (depth_only)
2264#endif // ENABLE_OPENGL_ES
2265 if (!m_rendering_shadow_casters && !depth_only) {
2266 // ORCA: realistic view
2276#ifndef ENABLE_OPENGL_ES
2281#endif // ENABLE_OPENGL_ES
2282 }
2283
2284 // ORCA: the translucent segments neither hide each other nor what is drawn after them. Drawn late in the
2285 // frame, they cannot count on the depth test the toolpaths left on, which hides them behind opaque ones.
2286 const bool curr_blend = glIsEnabled(GL_BLEND);
2287 const bool curr_depth_test = glIsEnabled(GL_DEPTH_TEST);
2288 std::array<int, 4> curr_blend_func = { 0, 0, 0, 0 };
2289 std::array<int, 2> curr_blend_equation = { 0, 0 };
2290 GLboolean curr_depth_mask = GL_TRUE;
2291 if (translucent) {
2293 glsafe(glGetIntegerv(GL_BLEND_SRC_RGB, &curr_blend_func[0]));
2294 glsafe(glGetIntegerv(GL_BLEND_DST_RGB, &curr_blend_func[1]));
2295 glsafe(glGetIntegerv(GL_BLEND_SRC_ALPHA, &curr_blend_func[2]));
2296 glsafe(glGetIntegerv(GL_BLEND_DST_ALPHA, &curr_blend_func[3]));
2297 glsafe(glGetIntegerv(GL_BLEND_EQUATION_RGB, &curr_blend_equation[0]));
2298 glsafe(glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &curr_blend_equation[1]));
2299 glsafe(glGetBooleanv(GL_DEPTH_WRITEMASK, &curr_depth_mask));
2301 // premultiplied, the highlights are not scaled by the opacity; the nearest depth, then sums,
2302 // in the passes of render_translucent_segments()
2306 }
2307
2309
2310 // ORCA: of the count enabled segments, the last translucent_count are the translucent ones
2311 auto draw = [this, &uni, translucent](size_t count, size_t translucent_count) {
2312 const size_t first = translucent ? count - translucent_count : 0;
2314 count = translucent ? translucent_count : count - translucent_count;
2315 if (count == 0)
2316 return;
2317 glsafe(glUniform1i(uni.instances_count, static_cast<int>(count)));
2318 glsafe(glUniform1i(uni.first_instance, static_cast<int>(first)));
2320 m_segment_template.render(count);
2321 return;
2322 }
2323 // ORCA: realistic view. 6 vertices per caster ribbon.
2324 int curr_vertex_array = 0;
2325 glsafe(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &curr_vertex_array));
2327 glsafe(glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(6 * count)));
2328 glsafe(glBindVertexArray(curr_vertex_array));
2329 };
2330
2331#ifdef ENABLE_OPENGL_ES
2332 int curr_bound_texture = 0;
2333 glsafe(glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_bound_texture));
2334
2335 const size_t tex_count = m_texture_data.get_count();
2336 for (size_t n = 0; n < tex_count; ++n) {
2337 const size_t i = reverse_order ? tex_count - 1 - n : n;
2338 const auto [id, count] = m_texture_data.get_enabled_segments_tex_id(i);
2339 if (count == 0)
2340 continue;
2342 glsafe(glBindTexture(GL_TEXTURE_2D, m_texture_data.get_positions_tex_id(i).first));
2344 glsafe(glBindTexture(GL_TEXTURE_2D, m_texture_data.get_heights_widths_angles_tex_id(i).first));
2346 glsafe(glBindTexture(GL_TEXTURE_2D, m_texture_data.get_colors_tex_id(i).first));
2349 draw(count, m_texture_data.get_enabled_translucent_segments_count(i));
2350 }
2351#else
2352 std::array<int, 4> curr_bound_texture = { 0, 0, 0, 0 };
2353 for (int i = 0; i < curr_bound_texture.size(); ++i) {
2355 glsafe(glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, &curr_bound_texture[i]));
2356 //assert(curr_bound_texture[i] == 0);
2357 }
2358
2371
2373#endif // ENABLE_OPENGL_ES
2374
2375 if (curr_cull_face)
2377 if (translucent) {
2378 if (!curr_depth_test)
2380 glsafe(glDepthMask(curr_depth_mask));
2381 glsafe(glBlendEquationSeparate(curr_blend_equation[0], curr_blend_equation[1]));
2382 glsafe(glBlendFuncSeparate(curr_blend_func[0], curr_blend_func[1], curr_blend_func[2], curr_blend_func[3]));
2383 if (!curr_blend)
2385 }
2386
2387 glsafe(glUseProgram(curr_shader));
2388#ifdef ENABLE_OPENGL_ES
2389 glsafe(glBindTexture(GL_TEXTURE_2D, curr_bound_texture));
2390#else
2391 for (int i = 0; i < curr_bound_texture.size(); ++i) {
2393 glsafe(glBindTexture(GL_TEXTURE_BUFFER, curr_bound_texture[i]));
2394 }
2395#endif // ENABLE_OPENGL_ES
2396 glsafe(glActiveTexture(curr_active_texture));
2397}
Mat4x4 m_shadow_light_vp
Definition ViewerImpl.hpp:570
float m_shadow_map_texel
Definition ViewerImpl.hpp:572
int m_translucent_pass
Definition ViewerImpl.hpp:634
bool m_gloss
Definition ViewerImpl.hpp:584
std::array< float, 2 > m_oit_depth_range
Definition ViewerImpl.hpp:630
int m_shadow_map_texture_unit
Definition ViewerImpl.hpp:569
Vec3 m_light_top_dir
Definition ViewerImpl.hpp:582
float m_shadow_intensity
Definition ViewerImpl.hpp:571
bool m_rendering_shadow_casters
Definition ViewerImpl.hpp:573
float m_saturation
Definition ViewerImpl.hpp:580
float m_exposure
Definition ViewerImpl.hpp:579
size_t m_enabled_segments_count
Definition ViewerImpl.hpp:546
#define GL_TRUE
Definition gl.h:1892
#define GL_BLEND_DST_ALPHA
Definition gl.h:278
#define glUniform1f
Definition gl.h:4981
#define glBlendFuncSeparate
Definition gl.h:3327
#define glUniform3fv
Definition gl.h:5015
#define GL_BLEND_EQUATION_RGB
Definition gl.h:282
#define glBindVertexArray
Definition gl.h:3307
#define GL_DEPTH_TEST
Definition gl.h:574
#define glBlendEquation
Definition gl.h:3317
#define GL_TRIANGLES
Definition gl.h:1887
#define GL_BLEND_EQUATION_ALPHA
Definition gl.h:281
#define glDrawArrays
Definition gl.h:3621
#define glUniform2fv
Definition gl.h:4999
int GLsizei
Definition gl.h:2065
#define glDepthMask
Definition gl.h:3595
#define GL_DEPTH_WRITEMASK
Definition gl.h:576
#define GL_MIN
Definition gl.h:1178
unsigned char GLboolean
Definition gl.h:2055
#define GL_BLEND
Definition gl.h:275
#define GL_ONE_MINUS_SRC_ALPHA
Definition gl.h:1239
#define GL_ONE
Definition gl.h:1232
#define glGetBooleanv
Definition gl.h:3825
#define GL_BLEND_DST_RGB
Definition gl.h:279
#define GL_BLEND_SRC_RGB
Definition gl.h:285
#define glBlendEquationSeparate
Definition gl.h:3319
#define GL_BLEND_SRC_ALPHA
Definition gl.h:284
#define GL_FUNC_ADD
Definition gl.h:766
#define glBlendFunc
Definition gl.h:3325
#define GL_VERTEX_ARRAY_BINDING
Definition gl.h:1989
void draw(const IconManager::Icon &icon, const ImVec2 &size, const ImVec4 &tint_col, const ImVec4 &border_col)
Draw imgui image with icon.
Definition IconManager.cpp:373
static constexpr int TRANSLUCENT_TEXTURE_UNIT
Definition ViewerImpl.cpp:304
Definition ViewerImpl.hpp:383

References libvgcode::ViewerImpl::SegmentsUniforms::camera_position, libvgcode::ViewerImpl::SegmentsUniforms::clipping_plane, libvgcode::ViewerImpl::SegmentsUniforms::colors_tex, count, libvgcode::ViewerImpl::SegmentsUniforms::first_instance, GL_ACTIVE_TEXTURE, GL_BLEND, GL_BLEND_DST_ALPHA, GL_BLEND_DST_RGB, GL_BLEND_EQUATION_ALPHA, GL_BLEND_EQUATION_RGB, GL_BLEND_SRC_ALPHA, GL_BLEND_SRC_RGB, GL_CULL_FACE, GL_CURRENT_PROGRAM, GL_DEPTH_TEST, GL_DEPTH_WRITEMASK, GL_FALSE, GL_FUNC_ADD, GL_MIN, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_R32UI, GL_RGBA32F, GL_RGBA8, GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_TEXTURE3, GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D, GL_TEXTURE_BINDING_BUFFER, GL_TEXTURE_BUFFER, GL_TRIANGLES, GL_TRUE, GL_VERTEX_ARRAY_BINDING, glActiveTexture, glBindTexture, glBindVertexArray, glBlendEquation, glBlendEquationSeparate, glBlendFunc, glBlendFuncSeparate, glcheck, glDepthMask, glDisable, glDrawArrays, glEnable, glGetBooleanv, glGetIntegerv, glIsEnabled, glsafe, glTexBuffer, glUniform1f, glUniform1i, glUniform2fv, glUniform3fv, glUniform4fv, glUniformMatrix4fv, glUseProgram, libvgcode::ViewerImpl::SegmentsUniforms::height_width_angle_tex, libvgcode::ViewerImpl::SegmentsUniforms::instances_count, m_clipping_plane, m_colors_buf_id, m_colors_tex_id, m_enabled_segments_buf_id, m_enabled_segments_count, m_enabled_segments_tex_id, m_enabled_translucent_segments_count, m_exposure, m_gloss, m_heights_widths_angles_buf_id, m_heights_widths_angles_tex_id, m_light_top_dir, m_oit_depth_range, m_positions_buf_id, m_positions_tex_id, m_rendering_shadow_casters, m_saturation, m_segment_template, m_segments_caster_shader_id, m_segments_caster_vao_id, m_segments_depth_shader_id, m_segments_shader_id, m_shadow_intensity, m_shadow_light_vp, m_shadow_map_texel, m_shadow_map_texture_unit, m_translucent_pass, m_uni_segments, m_uni_segments_caster, m_uni_segments_depth, m_uni_segments_depth_opaque_depth_id, m_uni_segments_exposure_id, m_uni_segments_front_depth_id, m_uni_segments_gloss_id, m_uni_segments_layer_colors, m_uni_segments_light_top_dir_id, m_uni_segments_oit_depth_range_id, m_uni_segments_oit_pass_id, m_uni_segments_opaque_depth_id, m_uni_segments_saturation_id, m_uni_segments_shadow_intensity_id, m_uni_segments_shadow_light_vp_id, m_uni_segments_shadow_map_id, m_uni_segments_shadow_map_texel_id, libvgcode::ViewerImpl::SegmentsUniforms::positions_tex, libvgcode::ViewerImpl::SegmentsUniforms::projection_matrix, libvgcode::ViewerImpl::SegmentsUniforms::reverse_order, libvgcode::ViewerImpl::SegmentsUniforms::segment_index_tex, set_layer_colors(), libvgcode::TRANSLUCENT_TEXTURE_UNIT, and libvgcode::ViewerImpl::SegmentsUniforms::view_matrix.

Referenced by render(), render_shadow_casters(), and render_translucent_segments().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_shadow_casters()

void libvgcode::ViewerImpl::render_shadow_casters ( const Mat4x4 & view_matrix,
const Mat4x4 & projection_matrix,
const Vec3 & light_position )
1527{
1529
1530 // Only the extrusions and travels cast: the option markers are indicators, not material.
1532 render_segments(view_matrix, projection_matrix, light_position);
1534}

References apply_pending_updates(), m_rendering_shadow_casters, and render_segments().

Here is the call graph for this function:

◆ render_translucent()

void libvgcode::ViewerImpl::render_translucent ( const Mat4x4 & view_matrix,
const Mat4x4 & projection_matrix )
2569{
2572 return;
2573
2574 const Mat4x4 inv_view_matrix = inverse(view_matrix);
2575 render_translucent_segments(view_matrix, projection_matrix, { inv_view_matrix[12], inv_view_matrix[13], inv_view_matrix[14] });
2576}
void render_translucent_segments(const Mat4x4 &view_matrix, const Mat4x4 &projection_matrix, const Vec3 &camera_position)
Definition ViewerImpl.cpp:2578

References apply_pending_updates(), libvgcode::inverse(), m_enabled_translucent_segments_count, and render_translucent_segments().

Here is the call graph for this function:

◆ render_translucent_segments()

void libvgcode::ViewerImpl::render_translucent_segments ( const Mat4x4 & view_matrix,
const Mat4x4 & projection_matrix,
const Vec3 & camera_position )
private
2579{
2580#ifndef ENABLE_OPENGL_ES
2581 // ORCA: the order independent path, whose targets are as large as the canvas: the nearest translucent surface
2582 // over the weighted blended order independent transparency (McGuire and Bavoil, 2013) of the others. Blended in
2583 // print order, even one color shows the order, its surfaces being shaded apart.
2584 std::array<int, 4> viewport = { 0, 0, 0, 0 };
2585 int draw_fbo = 0;
2586 int read_fbo = 0;
2587 int samples = 0;
2588 glsafe(glGetIntegerv(GL_VIEWPORT, viewport.data()));
2591 glsafe(glGetIntegerv(GL_SAMPLES, &samples));
2592 // the depth of a multisampled framebuffer object cannot be copied into a texture
2593 if ((read_fbo != 0 && samples > 0) || !m_translucent_targets.update(viewport[2], viewport[3])) {
2594 render_segments(view_matrix, projection_matrix, camera_position, true);
2595 return;
2596 }
2598 const int width = viewport[2];
2599 const int height = viewport[3];
2600
2601 int curr_active_texture = 0;
2602 std::array<int, 3> curr_textures = { 0, 0, 0 };
2603 glsafe(glGetIntegerv(GL_ACTIVE_TEXTURE, &curr_active_texture));
2604 for (int i = 0; i < 3; ++i) {
2606 glsafe(glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_textures[i]));
2607 }
2608
2609 // the opaque scene, to hide the translucent segments behind it
2611 glsafe(glBindTexture(GL_TEXTURE_2D, targets.depth_tex));
2612 glsafe(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport[0], viewport[1], width, height));
2613
2614 // the weights fall with the depth across the extrusions
2615 float near_z = FLT_MAX;
2616 float far_z = -FLT_MAX;
2617 for (int i = 0; i < 8; ++i) {
2618 const Vec3 p = { m_extrusions_box[i & 1][0], m_extrusions_box[(i >> 1) & 1][1], m_extrusions_box[(i >> 2) & 1][2] };
2619 const float z = -(view_matrix[2] * p[0] + view_matrix[6] * p[1] + view_matrix[10] * p[2] + view_matrix[14]);
2620 near_z = std::min(near_z, z);
2621 far_z = std::max(far_z, z);
2622 }
2623 m_oit_depth_range = { near_z, std::max(far_z, near_z + 1.0f) };
2624
2625 // the depth of the nearest translucent surface, as the fragments see it, kept by GL_MIN
2626 const std::array<float, 4> zero = { 0.0f, 0.0f, 0.0f, 0.0f };
2627 const std::array<float, 4> one = { 1.0f, 1.0f, 1.0f, 1.0f };
2628 glsafe(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targets.front_depth_fbo));
2629 glsafe(glViewport(0, 0, width, height));
2630 glsafe(glClearBufferfv(GL_COLOR, 0, one.data()));
2632 render_segments(view_matrix, projection_matrix, camera_position, true);
2634 glsafe(glBindTexture(GL_TEXTURE_2D, targets.front_depth_tex));
2635
2636 // that surface apart, the others summed
2638 for (int i = 0; i < 3; ++i)
2639 glsafe(glClearBufferfv(GL_COLOR, i, zero.data()));
2641 render_segments(view_matrix, projection_matrix, camera_position, true);
2643
2646 glsafe(glViewport(viewport[0], viewport[1], width, height));
2647
2648 // composite over the scene
2649 int curr_shader = 0;
2650 int curr_vertex_array = 0;
2651 std::array<int, 4> curr_blend_func = { 0, 0, 0, 0 };
2652 GLboolean curr_depth_mask = GL_TRUE;
2653 const bool curr_blend = glIsEnabled(GL_BLEND);
2654 const bool curr_depth_test = glIsEnabled(GL_DEPTH_TEST);
2655 glsafe(glGetIntegerv(GL_CURRENT_PROGRAM, &curr_shader));
2656 glsafe(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &curr_vertex_array));
2657 glsafe(glGetIntegerv(GL_BLEND_SRC_RGB, &curr_blend_func[0]));
2658 glsafe(glGetIntegerv(GL_BLEND_DST_RGB, &curr_blend_func[1]));
2659 glsafe(glGetIntegerv(GL_BLEND_SRC_ALPHA, &curr_blend_func[2]));
2660 glsafe(glGetIntegerv(GL_BLEND_DST_ALPHA, &curr_blend_func[3]));
2661 glsafe(glGetBooleanv(GL_DEPTH_WRITEMASK, &curr_depth_mask));
2662
2667 glsafe(glUniform2i(m_uni_translucent_composite_origin_id, viewport[0], viewport[1]));
2669 glsafe(glBindTexture(GL_TEXTURE_2D, targets.accum_tex));
2671 glsafe(glBindTexture(GL_TEXTURE_2D, targets.reveal_tex));
2673 glsafe(glBindTexture(GL_TEXTURE_2D, targets.front_tex));
2680
2681 glsafe(glBindVertexArray(curr_vertex_array));
2682 glsafe(glDepthMask(curr_depth_mask));
2683 if (curr_depth_test)
2685 glsafe(glBlendFuncSeparate(curr_blend_func[0], curr_blend_func[1], curr_blend_func[2], curr_blend_func[3]));
2686 if (!curr_blend)
2688 glsafe(glUseProgram(curr_shader));
2689 for (int i = 0; i < 3; ++i) {
2691 glsafe(glBindTexture(GL_TEXTURE_2D, curr_textures[i]));
2692 }
2693 glsafe(glActiveTexture(curr_active_texture));
2694#else
2695 render_segments(view_matrix, projection_matrix, camera_position, true);
2696#endif // ENABLE_OPENGL_ES
2697}
#define GL_SAMPLES
Definition gl.h:1536
#define GL_COLOR
Definition gl.h:353
#define glCopyTexSubImage2D
Definition gl.h:3521
#define glBindFramebuffer
Definition gl.h:3281
#define GL_DRAW_FRAMEBUFFER
Definition gl.h:617
#define glUniform2i
Definition gl.h:5001
#define GL_VIEWPORT
Definition gl.h:2021
#define GL_DRAW_FRAMEBUFFER_BINDING
Definition gl.h:618
#define glViewport
Definition gl.h:5333
#define GL_READ_FRAMEBUFFER
Definition gl.h:1405
#define glClearBufferfv
Definition gl.h:3367
#define GL_READ_FRAMEBUFFER_BINDING
Definition gl.h:1406
Definition ViewerImpl.hpp:597

References libvgcode::ViewerImpl::TranslucentTargets::accum_tex, libvgcode::ViewerImpl::TranslucentTargets::depth_tex, libvgcode::ViewerImpl::TranslucentTargets::fbo, libvgcode::ViewerImpl::TranslucentTargets::front_depth_fbo, libvgcode::ViewerImpl::TranslucentTargets::front_depth_tex, libvgcode::ViewerImpl::TranslucentTargets::front_tex, GL_ACTIVE_TEXTURE, GL_BLEND, GL_BLEND_DST_ALPHA, GL_BLEND_DST_RGB, GL_BLEND_SRC_ALPHA, GL_BLEND_SRC_RGB, GL_COLOR, GL_CURRENT_PROGRAM, GL_DEPTH_TEST, GL_DEPTH_WRITEMASK, GL_DRAW_FRAMEBUFFER, GL_DRAW_FRAMEBUFFER_BINDING, GL_FALSE, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_READ_FRAMEBUFFER, GL_READ_FRAMEBUFFER_BINDING, GL_SAMPLES, GL_TEXTURE0, GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D, GL_TRIANGLES, GL_TRUE, GL_VERTEX_ARRAY_BINDING, GL_VIEWPORT, glActiveTexture, glBindFramebuffer, glBindTexture, glBindVertexArray, glBlendFunc, glBlendFuncSeparate, glClearBufferfv, glCopyTexSubImage2D, glDepthMask, glDisable, glDrawArrays, glEnable, glGetBooleanv, glGetIntegerv, glIsEnabled, glsafe, glUniform1i, glUniform2i, glUseProgram, glViewport, m_extrusions_box, m_oit_depth_range, m_segments_caster_vao_id, m_translucent_composite_shader_id, m_translucent_pass, m_translucent_targets, m_uni_translucent_composite_accum_tex_id, m_uni_translucent_composite_front_tex_id, m_uni_translucent_composite_origin_id, m_uni_translucent_composite_reveal_tex_id, render_segments(), libvgcode::ViewerImpl::TranslucentTargets::reveal_tex, and libvgcode::TRANSLUCENT_TEXTURE_UNIT.

Referenced by render_translucent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void libvgcode::ViewerImpl::reset ( )
975{
976 m_layers.reset();
977 m_view_range.reset();
978 m_extrusion_roles.reset();
979 m_options.clear();
980 m_used_extruders.clear();
981 m_total_time = { 0.0f, 0.0f };
982 m_travels_time = { 0.0f, 0.0f };
983 // swap rather than clear: these are sized by the print, and a reset means the memory
984 // should go back, not sit reserved until the next load
985 std::vector<PathVertex>().swap(m_vertices);
986 std::vector<ColorWithAlpha>().swap(m_vertices_colors);
989 m_extrusions_box = { Vec3{ 0.0f, 0.0f, 0.0f }, Vec3{ 0.0f, 0.0f, 0.0f } };
990 for (std::vector<float>& times : m_layer_start_times)
991 std::vector<float>().swap(times);
992 std::vector<uint32_t>().swap(m_layer_first_vertex);
994 // BitSet::clear() only zeroes the bits, it keeps the blocks allocated; load() builds a new
995 // bitset anyway and it is never read while m_vertices is empty
996 m_valid_lines_bitset = BitSet<>();
997#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
998 m_cog_marker.reset();
999#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
1000
1001#ifdef ENABLE_OPENGL_ES
1002 m_texture_data.reset();
1003#else
1006
1007 m_settings_used_for_ranges = std::nullopt;
1008
1019 m_translucent_targets.release();
1020#endif // ENABLE_OPENGL_ES
1021}
bool m_has_translucent_colors
Definition ViewerImpl.hpp:336
std::optional< Settings > m_settings_used_for_ranges
Definition ViewerImpl.hpp:346
static void delete_textures(unsigned int &id)
Definition ViewerImpl.cpp:285
static void delete_buffers(unsigned int &id)
Definition ViewerImpl.cpp:293

References libvgcode::delete_buffers(), libvgcode::delete_textures(), m_colors_buf_id, m_colors_tex_id, m_enabled_options_buf_id, m_enabled_options_count, m_enabled_options_tex_id, m_enabled_segments_buf_id, m_enabled_segments_count, m_enabled_segments_tex_id, m_enabled_translucent_segments_count, m_extrusion_roles, m_extrusions_box, m_has_translucent_colors, m_heights_widths_angles_buf_id, m_heights_widths_angles_tex_id, m_layer_first_vertex, m_layer_start_times, m_layers, m_layers_in_vertex_order, m_options, m_positions_buf_id, m_positions_tex_id, m_settings_used_for_ranges, m_total_time, m_translucent_targets, m_travels_time, m_used_extruders, m_valid_lines_bitset, m_vertices, m_vertices_colors, and m_view_range.

Referenced by load(), and shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_default_extrusion_roles_colors()

void libvgcode::ViewerImpl::reset_default_extrusion_roles_colors ( )
1868{
1870}
static const std::array< Color, size_t(EGCodeExtrusionRole::COUNT)> DEFAULT_EXTRUSION_ROLES_COLORS
Definition ViewerImpl.cpp:315

References libvgcode::DEFAULT_EXTRUSION_ROLES_COLORS, and m_extrusion_roles_colors.

Referenced by ViewerImpl().

Here is the caller graph for this function:

◆ reset_default_options_colors()

void libvgcode::ViewerImpl::reset_default_options_colors ( )
1884{
1886}
static const std::array< Color, size_t(EOptionType::COUNT)> DEFAULT_OPTIONS_COLORS
Definition ViewerImpl.cpp:339

References libvgcode::DEFAULT_OPTIONS_COLORS, and m_options_colors.

Referenced by ViewerImpl().

Here is the caller graph for this function:

◆ set_clipping_plane()

void libvgcode::ViewerImpl::set_clipping_plane ( const std::array< float, 4 > & plane)
inline
101{ m_clipping_plane = plane; }

References m_clipping_plane.

◆ set_color_print_colors()

void libvgcode::ViewerImpl::set_color_print_colors ( const PaletteWithAlpha & colors)
1851{
1852 m_color_print_colors = colors;
1853 m_settings.update_colors = true;
1854}

References m_color_print_colors, and m_settings.

◆ set_color_range_palette()

void libvgcode::ViewerImpl::set_color_range_palette ( EViewType type,
const Palette & palette )
1913{
1914 switch (type)
1915 {
1916 case EViewType::Height: { m_height_range.set_palette(palette); break; }
1917 case EViewType::Width: { m_width_range.set_palette(palette); break; }
1918 case EViewType::Speed: { m_speed_range.set_palette(palette); break; }
1919 case EViewType::ActualSpeed: { m_actual_speed_range.set_palette(palette); break; }
1920 case EViewType::FanSpeed: { m_fan_speed_range.set_palette(palette); break; }
1921 case EViewType::Temperature: { m_temperature_range.set_palette(palette); break; }
1922// ORCA: Add Pressure Advance visualization support
1923 case EViewType::PressureAdvance: { m_pressure_advance_range.set_palette(palette); break; }
1924 // ORCA: Add Acceleration visualization support
1925 case EViewType::Acceleration: { m_acceleration_range.set_palette(palette); break; }
1926 // ORCA: Add Jerk visualization support
1927 case EViewType::Jerk: { m_jerk_range.set_palette(palette); break; }
1928 case EViewType::VolumetricFlowRate: { m_volumetric_rate_range.set_palette(palette); break; }
1929 case EViewType::ActualVolumetricFlowRate: { m_actual_volumetric_rate_range.set_palette(palette); break; }
1930 case EViewType::LayerTimeLinear: { m_layer_time_range[0].set_palette(palette); break; }
1931 case EViewType::LayerTimeLogarithmic: { m_layer_time_range[1].set_palette(palette); break; }
1932 default: { break; }
1933 }
1934 m_settings.update_colors = true;
1935}

References libvgcode::Acceleration, libvgcode::ActualSpeed, libvgcode::ActualVolumetricFlowRate, libvgcode::FanSpeed, libvgcode::Height, libvgcode::Jerk, libvgcode::LayerTimeLinear, libvgcode::LayerTimeLogarithmic, m_acceleration_range, m_actual_speed_range, m_actual_volumetric_rate_range, m_fan_speed_range, m_height_range, m_jerk_range, m_layer_time_range, m_pressure_advance_range, m_settings, m_speed_range, m_temperature_range, m_volumetric_rate_range, m_width_range, libvgcode::PressureAdvance, libvgcode::Speed, libvgcode::Temperature, libvgcode::VolumetricFlowRate, and libvgcode::Width.

◆ set_dim_previous_layers()

void libvgcode::ViewerImpl::set_dim_previous_layers ( bool value)
1587{
1588 if (m_settings.dim_previous_layers == value)
1589 return;
1590 m_settings.dim_previous_layers = value;
1591}

References m_settings.

◆ set_dim_previous_layers_brightness()

void libvgcode::ViewerImpl::set_dim_previous_layers_brightness ( float value)
1603{
1604 value = std::clamp(value, 0.0f, 1.0f);
1605 if (m_settings.dim_previous_layers_brightness == value)
1606 return;
1607 m_settings.dim_previous_layers_brightness = value;
1608}

References m_settings.

◆ set_extrusion_role_color()

void libvgcode::ViewerImpl::set_extrusion_role_color ( EGCodeExtrusionRole role,
const Color & color )
1862{
1863 m_extrusion_roles_colors[size_t(role)] = color;
1864 m_settings.update_colors = true;
1865}

References m_extrusion_roles_colors, and m_settings.

◆ set_gloss()

void libvgcode::ViewerImpl::set_gloss ( bool gloss)
inline
103{ m_gloss = gloss; }

References m_gloss.

◆ set_layer_colors()

void libvgcode::ViewerImpl::set_layer_colors ( const LayerColorsUniforms & uni) const
private
1430{
1431 const size_t top_layer_id = m_settings.top_layer_only_view_range ? m_layers.get_view_range()[1] : 0;
1432 const bool color_top_layer_only = m_view_range.get_full()[1] != m_view_range.get_visible()[1];
1433
1434 // ORCA: when dim_previous_layers is enabled, darken every layer (keeping its color) except the
1435 // one(s) the layer slider is being scrubbed to, so that only those are shown at full brightness.
1436 // A slider thumb marks a layer as inspected only once it is moved away from
1437 // its end of the print: the upper one while it is below the last layer (or while the moves
1438 // slider is not at the end of the layer), the lower one while it is above the first layer, so
1439 // trimming the print from the bottom lights up the lowest visible layer and using the slider as
1440 // a range lights up both ends. When neither thumb is moved the whole print is rendered normally.
1441 // Gated on top-layer-only mode, which the greying path below also keys off of, so that the moves
1442 // slider still animates normally across all layers when that mode is disabled.
1443 const Interval& layers_range = m_layers.get_view_range();
1444 const bool inspecting_top_layer = layers_range[1] + 1 < m_layers.count() || color_top_layer_only;
1445 const bool inspecting_bottom_layer = layers_range[0] > 0;
1446 const bool dim_previous_layers = m_settings.dim_previous_layers && m_settings.top_layer_only_view_range &&
1447 !m_layers.empty() && (inspecting_top_layer || inspecting_bottom_layer);
1448
1449 // Without dimming, the layers below the top one go dark grey while the moves slider is short of
1450 // the end. Neither touches the inspected layers, nor the first vertex of a spiral vase layer.
1451 glsafe(glUniform2i(uni.lit_layers, dim_previous_layers && inspecting_bottom_layer ? static_cast<int>(layers_range[0]) : -1,
1452 dim_previous_layers && inspecting_top_layer ? static_cast<int>(layers_range[1]) : -1));
1453 glsafe(glUniform1i(uni.grey_below_layer, color_top_layer_only ? static_cast<int>(top_layer_id) : 0));
1454 glsafe(glUniform1f(uni.dim_brightness, dim_previous_layers ? m_settings.dim_previous_layers_brightness : -1.0f));
1455 glsafe(glUniform1i(uni.kept_vertex, m_settings.spiral_vase_mode ? static_cast<int>(m_view_range.get_enabled()[0]) : -1));
1456}
std::array< std::size_t, 2 > Interval
Definition Types.hpp:85

References libvgcode::ViewerImpl::LayerColorsUniforms::dim_brightness, glsafe, glUniform1f, glUniform1i, glUniform2i, libvgcode::ViewerImpl::LayerColorsUniforms::grey_below_layer, libvgcode::ViewerImpl::LayerColorsUniforms::kept_vertex, libvgcode::ViewerImpl::LayerColorsUniforms::lit_layers, m_layers, m_settings, and m_view_range.

Referenced by render_options(), and render_segments().

Here is the caller graph for this function:

◆ set_layers_view_range() [1/2]

void libvgcode::ViewerImpl::set_layers_view_range ( const Interval & range)
inline
112{ set_layers_view_range(range[0], range[1]); }
void set_layers_view_range(const Interval &range)
Definition ViewerImpl.hpp:112

References set_layers_view_range().

Referenced by set_layers_view_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_layers_view_range() [2/2]

void libvgcode::ViewerImpl::set_layers_view_range ( Interval::value_type min,
Interval::value_type max )
1567{
1568 min = std::clamp<Interval::value_type>(min, 0, m_layers.count() - 1);
1569 max = std::clamp<Interval::value_type>(max, 0, m_layers.count() - 1);
1570 m_layers.set_view_range(min, max);
1571 // force immediate update of the full range
1573 m_view_range.set_visible(m_view_range.get_enabled());
1574 m_settings.update_enabled_entities = true;
1575}

References m_layers, m_settings, m_view_range, and update_view_full_range().

Here is the call graph for this function:

◆ set_light_top_dir()

void libvgcode::ViewerImpl::set_light_top_dir ( const Vec3 & direction)
inline
102{ m_light_top_dir = direction; }

References m_light_top_dir.

◆ set_option_color()

void libvgcode::ViewerImpl::set_option_color ( EOptionType type,
const Color & color )
1878{
1879 m_options_colors[size_t(type)] = color;
1880 m_settings.update_colors = true;
1881}

References m_options_colors, and m_settings.

◆ set_shadow_map()

void libvgcode::ViewerImpl::set_shadow_map ( int texture_unit,
const Mat4x4 & light_view_projection,
float intensity,
float texel_size )
1537{
1538 m_shadow_map_texture_unit = texture_unit;
1539 m_shadow_light_vp = light_view_projection;
1540 m_shadow_intensity = intensity;
1541 m_shadow_map_texel = texel_size;
1542}

References m_shadow_intensity, m_shadow_light_vp, m_shadow_map_texel, and m_shadow_map_texture_unit.

◆ set_time_mode()

void libvgcode::ViewerImpl::set_time_mode ( ETimeMode mode)
1557{
1558 m_settings.time_mode = mode;
1559 m_settings.update_colors = true;
1560 // Update layer_duration for all vertices based on the new time mode
1561 for (PathVertex& v : m_vertices) {
1562 v.layer_duration = m_layers.get_layer_time(mode, static_cast<size_t>(v.layer_id));
1563 }
1564}

References m_layers, m_settings, and m_vertices.

◆ set_tone()

void libvgcode::ViewerImpl::set_tone ( float exposure,
float saturation )
1545{
1546 m_exposure = exposure;
1547 m_saturation = saturation;
1548}

References m_exposure, and m_saturation.

◆ set_tool_colors()

void libvgcode::ViewerImpl::set_tool_colors ( const PaletteWithAlpha & colors)
1845{
1846 m_tool_colors = colors;
1847 m_settings.update_colors = true;
1848}

References m_settings, and m_tool_colors.

◆ set_translucent_filaments()

void libvgcode::ViewerImpl::set_translucent_filaments ( bool value)
1594{
1595 if (m_settings.translucent_filaments == value)
1596 return;
1597 m_settings.translucent_filaments = value;
1598 m_settings.update_colors = true;
1599}

References m_settings.

◆ set_travels_radius()

void libvgcode::ViewerImpl::set_travels_radius ( float radius)
1938{
1941}
void update_heights_widths()
Definition ViewerImpl.cpp:2185
static constexpr float MAX_TRAVELS_RADIUS_MM
Definition Types.hpp:24
static constexpr float MIN_TRAVELS_RADIUS_MM
Definition Types.hpp:23

References m_travels_radius, libvgcode::MAX_TRAVELS_RADIUS_MM, libvgcode::MIN_TRAVELS_RADIUS_MM, and update_heights_widths().

Here is the call graph for this function:

◆ set_view_type()

void libvgcode::ViewerImpl::set_view_type ( EViewType type)
1551{
1552 m_settings.view_type = type;
1553 m_settings.update_colors = true;
1554}

References m_settings.

◆ set_view_visible_range()

void libvgcode::ViewerImpl::set_view_visible_range ( Interval::value_type min,
Interval::value_type max )
1709{
1710 // force update of the full range, to avoid clamping the visible range with full old values
1711 // when calling m_view_range.set_visible()
1713 m_view_range.set_visible(min, max);
1715}

References m_view_range, update_enabled_entities(), and update_view_full_range().

Here is the call graph for this function:

◆ set_wipes_radius()

void libvgcode::ViewerImpl::set_wipes_radius ( float radius)
1944{
1947}
static constexpr float MIN_WIPES_RADIUS_MM
Definition Types.hpp:30
static constexpr float MAX_WIPES_RADIUS_MM
Definition Types.hpp:31

References m_wipes_radius, libvgcode::MAX_WIPES_RADIUS_MM, libvgcode::MIN_WIPES_RADIUS_MM, and update_heights_widths().

Here is the call graph for this function:

◆ shutdown()

void libvgcode::ViewerImpl::shutdown ( )
936{
937 reset();
938#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
939 m_tool_marker.shutdown();
940 m_cog_marker.shutdown();
941#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
942 m_option_template.shutdown();
943 m_segment_template.shutdown();
944 if (m_options_shader_id != 0) {
947 }
948 if (m_segments_shader_id != 0) {
951 }
955 }
956 if (m_segments_caster_vao_id != 0) {
959 }
960#ifndef ENABLE_OPENGL_ES
964 }
968 }
969#endif // ENABLE_OPENGL_ES
970 m_initialized = false;
972}
static void unload_opengl()
Definition OpenGLUtils.cpp:90
#define glDeleteVertexArrays
Definition gl.h:3591
#define glDeleteProgram
Definition gl.h:3571

References glDeleteProgram, glDeleteVertexArrays, glsafe, m_initialized, m_option_template, m_options_shader_id, m_segment_template, m_segments_caster_shader_id, m_segments_caster_vao_id, m_segments_depth_shader_id, m_segments_shader_id, m_translucent_composite_shader_id, reset(), and libvgcode::OpenGLWrapper::unload_opengl().

Referenced by ~ViewerImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toggle_extrusion_role_visibility()

void libvgcode::ViewerImpl::toggle_extrusion_role_visibility ( EGCodeExtrusionRole role)
1701{
1702 m_settings.extrusion_roles_visibility[size_t(role)] = ! m_settings.extrusion_roles_visibility[size_t(role)];
1704 m_settings.update_enabled_entities = true;
1705 m_settings.update_colors = true;
1706}

References m_settings, and update_view_full_range().

Here is the call graph for this function:

◆ toggle_option_visibility()

void libvgcode::ViewerImpl::toggle_option_visibility ( EOptionType type)
1679{
1680 m_settings.options_visibility[size_t(type)] = ! m_settings.options_visibility[size_t(type)];
1681 const Interval old_enabled_range = m_view_range.get_enabled();
1683 const Interval& new_enabled_range = m_view_range.get_enabled();
1684 if (old_enabled_range != new_enabled_range) {
1685 const Interval& visible_range = m_view_range.get_visible();
1686 if (old_enabled_range == visible_range)
1687 m_view_range.set_visible(new_enabled_range);
1688 else if (m_settings.top_layer_only_view_range && new_enabled_range[0] < visible_range[0])
1689 m_view_range.set_visible(new_enabled_range[0], visible_range[1]);
1690 }
1691 m_settings.update_enabled_entities = true;
1692 m_settings.update_colors = true;
1693}

References m_settings, m_view_range, and update_view_full_range().

Here is the call graph for this function:

◆ toggle_top_layer_only_view_range()

void libvgcode::ViewerImpl::toggle_top_layer_only_view_range ( )
1578{
1579 m_settings.top_layer_only_view_range = !m_settings.top_layer_only_view_range;
1581 m_view_range.set_visible(m_view_range.get_enabled());
1582 m_settings.update_enabled_entities = true;
1583}

References m_settings, m_view_range, and update_view_full_range().

Here is the call graph for this function:

◆ update_color_ranges()

void libvgcode::ViewerImpl::update_color_ranges ( )
private
2123{
2124 // Color ranges do not need to be recalculated that often. If the following settings are the same
2125 // as last time, the current ranges are still valid. The recalculation is quite expensive.
2126 if (m_settings_used_for_ranges.has_value() &&
2127 m_settings.extrusion_roles_visibility == m_settings_used_for_ranges->extrusion_roles_visibility &&
2128 m_settings.options_visibility == m_settings_used_for_ranges->options_visibility)
2129 return;
2130
2131 m_width_range.reset();
2132 m_height_range.reset();
2133 m_speed_range.reset();
2134 m_actual_speed_range.reset();
2135 m_fan_speed_range.reset();
2136 m_temperature_range.reset();
2137 // ORCA: Add Pressure Advance visualization support
2139 // ORCA: Add Acceleration visualization support
2140 m_acceleration_range.reset();
2141 // ORCA: Add Jerk visualization support
2142 m_jerk_range.reset();
2145 m_layer_time_range[0].reset(); // ColorRange::EType::Linear
2146 m_layer_time_range[1].reset(); // ColorRange::EType::Logarithmic
2147
2148 for (size_t i = 0; i < m_vertices.size(); i++) {
2149 const PathVertex& v = m_vertices[i];
2150 if (v.is_extrusion()) {
2151 m_height_range.update(round_to_bin(v.height));
2152 if (!v.is_custom_gcode() || m_settings.extrusion_roles_visibility[size_t(EGCodeExtrusionRole::Custom)]) {
2153 m_width_range.update(round_to_bin(v.width));
2154 m_volumetric_rate_range.update(round_to_bin(v.volumetric_rate()));
2155 m_actual_volumetric_rate_range.update(round_to_bin(v.actual_volumetric_rate()));
2156 }
2157 m_fan_speed_range.update(round_to_bin(v.fan_speed));
2158 m_temperature_range.update(round_to_bin(v.temperature));
2159 // ORCA: Add Pressure Advance visualization support
2160 if (v.pressure_advance >= 0.0f)
2161 m_pressure_advance_range.update(v.pressure_advance);
2162 }
2163 if ((v.is_travel() && m_settings.options_visibility[size_t(EOptionType::Travels)]) ||
2164 (v.is_wipe() && m_settings.options_visibility[size_t(EOptionType::Wipes)]) ||
2165 v.is_extrusion()) {
2166 m_speed_range.update(v.feedrate);
2167 m_actual_speed_range.update(v.actual_feedrate);
2168 // ORCA: Add Acceleration visualization support
2169 m_acceleration_range.update(v.acceleration);
2170 // ORCA: Add Jerk visualization support
2171 m_jerk_range.update(v.jerk);
2172 }
2173 }
2174
2175 const std::vector<float> times = m_layers.get_times(m_settings.time_mode);
2176 for (size_t i = 0; i < m_layer_time_range.size(); ++i) {
2177 for (float t : times) {
2178 m_layer_time_range[i].update(t);
2179 }
2180 }
2181
2183}
@ Wipes
Definition Types.hpp:179
@ Travels
Definition Types.hpp:178
static float round_to_bin(const float value)
Definition ViewerImpl.cpp:59

References libvgcode::PathVertex::acceleration, libvgcode::PathVertex::actual_feedrate, libvgcode::PathVertex::actual_volumetric_rate(), libvgcode::Custom, libvgcode::PathVertex::fan_speed, libvgcode::PathVertex::feedrate, libvgcode::PathVertex::height, libvgcode::PathVertex::is_custom_gcode(), libvgcode::PathVertex::is_extrusion(), libvgcode::PathVertex::is_travel(), libvgcode::PathVertex::is_wipe(), libvgcode::PathVertex::jerk, m_acceleration_range, m_actual_speed_range, m_actual_volumetric_rate_range, m_fan_speed_range, m_height_range, m_jerk_range, m_layer_time_range, m_layers, m_pressure_advance_range, m_settings, m_settings_used_for_ranges, m_speed_range, m_temperature_range, m_vertices, m_volumetric_rate_range, m_width_range, libvgcode::PathVertex::pressure_advance, libvgcode::round_to_bin(), libvgcode::PathVertex::temperature, libvgcode::Travels, libvgcode::PathVertex::volumetric_rate(), libvgcode::PathVertex::width, and libvgcode::Wipes.

Referenced by update_colors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_colors()

void libvgcode::ViewerImpl::update_colors ( )
1459{
1460
1461
1462 if (!m_used_extruders.empty()) {
1463 // ensure that the number of defined tool colors matches the max id of the used extruders
1464 const size_t max_used_extruder_id = 1 + static_cast<size_t>(m_used_extruders.rbegin()->first);
1465 const size_t tool_colors_size = m_tool_colors.size();
1466 if (m_tool_colors.size() < max_used_extruder_id) {
1467 for (size_t i = 0; i < max_used_extruder_id - tool_colors_size; ++i) {
1468 m_tool_colors.push_back({ DUMMY_COLOR[0], DUMMY_COLOR[1], DUMMY_COLOR[2], 255 });
1469 }
1470 }
1471 }
1472
1474
1475 // Recalculate "normal" colors of all the vertices for current view settings.
1476 // If some part of the preview should be rendered in dark grey, it is taken
1477 // care of in the shaders, see set_layer_colors(). That is to avoid the need to recalculate
1478 // the "normal" color on every slider move.
1479 const bool had_translucent_colors = m_has_translucent_colors;
1481 for (size_t i = 0; i < m_vertices.size(); ++i) {
1482 const Color color = get_vertex_color(m_vertices[i]);
1483 const uint8_t alpha = get_vertex_alpha(m_vertices[i]);
1484 m_vertices_colors[i] = { color[0], color[1], color[2], alpha };
1485 m_has_translucent_colors |= alpha < 255;
1486 }
1487
1489 m_settings.update_colors = false;
1490
1491 // ORCA: the enabled segments are sorted by opacity
1492 if (had_translucent_colors || m_has_translucent_colors)
1493 m_settings.update_enabled_entities = true;
1494}
void update_colors_texture()
Definition ViewerImpl.cpp:1398
void update_color_ranges()
Definition ViewerImpl.cpp:2122
Color get_vertex_color(const PathVertex &vertex) const
Definition ViewerImpl.cpp:1734
uint8_t get_vertex_alpha(const PathVertex &v) const
Definition ViewerImpl.cpp:1826
std::array< uint8_t, 3 > Color
Definition Types.hpp:59

References libvgcode::DUMMY_COLOR, get_vertex_alpha(), get_vertex_color(), m_has_translucent_colors, m_settings, m_tool_colors, m_used_extruders, m_vertices, m_vertices_colors, update_color_ranges(), and update_colors_texture().

Referenced by apply_pending_updates(), and load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_colors_texture()

void libvgcode::ViewerImpl::update_colors_texture ( )
1399{
1400#if !defined(ENABLE_OPENGL_ES)
1401 if (m_colors_buf_id == 0)
1402 return;
1403#endif // ENABLE_OPENGL_ES
1404
1405 // ORCA: the colors of the vertices alone; the layers greyed or dimmed around the one the sliders
1406 // show are left to the shaders, see set_layer_colors(), so that a slider step uploads nothing.
1407 #ifdef ENABLE_OPENGL_ES
1408 if (!m_vertices_colors.empty())
1409 // update gpu buffer for colors
1410 m_texture_data.set_colors(m_vertices_colors);
1411 #else
1413
1414 // update gpu buffer for colors
1418 #endif // ENABLE_OPENGL_ES
1419}

References GL_STATIC_DRAW, GL_TEXTURE_BUFFER, glBindBuffer, glBufferData, glsafe, m_colors_buf_id, m_colors_tex_size, and m_vertices_colors.

Referenced by update_colors().

Here is the caller graph for this function:

◆ update_enabled_entities()

void libvgcode::ViewerImpl::update_enabled_entities ( )
1301{
1302 if (m_vertices.empty())
1303 return;
1304
1305 std::vector<uint32_t> enabled_segments;
1306 std::vector<uint32_t> enabled_options;
1307 Interval range = m_view_range.get_visible();
1308
1309 // when top layer only visualization is enabled, we need to render
1310 // all the toolpaths in the other layers as grayed, so extend the range
1311 // to contain them
1312 if (m_settings.top_layer_only_view_range)
1313 range[0] = m_view_range.get_full()[0];
1314
1315 // to show the options at the current tool marker position we need to extend the range by one extra step
1316 if (m_vertices[range[1]].is_option() && range[1] < static_cast<uint32_t>(m_vertices.size()) - 1)
1317 ++range[1];
1318
1319 if (m_settings.spiral_vase_mode) {
1320 // when spiral vase mode is enabled and only one layer is shown, extend the range by one step
1321 const Interval& layers_range = m_layers.get_view_range();
1322 if (layers_range[0] > 0 && layers_range[0] == layers_range[1])
1323 --range[0];
1324 }
1325
1326 for (size_t i = range[0]; i < range[1]; ++i) {
1327 const PathVertex& v = m_vertices[i];
1328
1329 if (!m_valid_lines_bitset[i] && !v.is_option())
1330 continue;
1331 if (v.is_travel()) {
1332 if (!m_settings.options_visibility[size_t(EOptionType::Travels)])
1333 continue;
1334 }
1335 else if (v.is_wipe()) {
1336 if (!m_settings.options_visibility[size_t(EOptionType::Wipes)])
1337 continue;
1338 }
1339 else if (v.is_option()) {
1340 if (!m_settings.options_visibility[size_t(move_type_to_option(v.type))])
1341 continue;
1342 }
1343 else if (v.is_extrusion()) {
1344 if (!m_settings.extrusion_roles_visibility[size_t(v.role)])
1345 continue;
1346 }
1347 else
1348 continue;
1349
1350 if (v.is_option())
1351 enabled_options.push_back(static_cast<uint32_t>(i));
1352 else
1353 enabled_segments.push_back(static_cast<uint32_t>(i));
1354 }
1355
1356 // ORCA: so that each pass of render() draws only its own segments, in print order
1358#ifdef ENABLE_OPENGL_ES
1359 m_texture_data.set_enabled_segments(enabled_segments, m_vertices_colors, m_has_translucent_colors);
1360 for (size_t i = 0; i < m_texture_data.get_count(); ++i)
1361 m_enabled_translucent_segments_count += m_texture_data.get_enabled_translucent_segments_count(i);
1362 m_texture_data.set_enabled_options(enabled_options);
1363#else
1365 const auto is_opaque = [this](uint32_t id) { return m_vertices_colors[id][3] == 255; };
1366 const auto translucent_begin = std::stable_partition(enabled_segments.begin(), enabled_segments.end(), is_opaque);
1367 m_enabled_translucent_segments_count = static_cast<size_t>(std::distance(translucent_begin, enabled_segments.end()));
1368 }
1369
1370 m_enabled_segments_count = enabled_segments.size();
1371 m_enabled_options_count = enabled_options.size();
1372
1373 m_enabled_segments_tex_size = enabled_segments.size() * sizeof(uint32_t);
1374 m_enabled_options_tex_size = enabled_options.size() * sizeof(uint32_t);
1375
1376 // update gpu buffer for enabled segments
1377 assert(m_enabled_segments_buf_id > 0);
1379 if (!enabled_segments.empty())
1380 glsafe(glBufferData(GL_TEXTURE_BUFFER, enabled_segments.size() * sizeof(uint32_t), enabled_segments.data(), GL_STATIC_DRAW));
1381 else
1383
1384 // update gpu buffer for enabled options
1385 assert(m_enabled_options_buf_id > 0);
1387 if (!enabled_options.empty())
1388 glsafe(glBufferData(GL_TEXTURE_BUFFER, enabled_options.size() * sizeof(uint32_t), enabled_options.data(), GL_STATIC_DRAW));
1389 else
1391
1393#endif // ENABLE_OPENGL_ES
1394
1395 m_settings.update_enabled_entities = false;
1396}
auto range(Cont &&cont)
Definition libslic3r.h:405

References GL_STATIC_DRAW, GL_TEXTURE_BUFFER, glBindBuffer, glBufferData, glsafe, libvgcode::PathVertex::is_extrusion(), libvgcode::PathVertex::is_option(), libvgcode::PathVertex::is_travel(), libvgcode::PathVertex::is_wipe(), m_enabled_options_buf_id, m_enabled_options_count, m_enabled_options_tex_size, m_enabled_segments_buf_id, m_enabled_segments_count, m_enabled_segments_tex_size, m_enabled_translucent_segments_count, m_has_translucent_colors, m_layers, m_settings, m_valid_lines_bitset, m_vertices, m_vertices_colors, m_view_range, libvgcode::move_type_to_option(), libvgcode::PathVertex::role, libvgcode::Travels, libvgcode::PathVertex::type, and libvgcode::Wipes.

Referenced by apply_pending_updates(), load(), and set_view_visible_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_heights_widths()

void libvgcode::ViewerImpl::update_heights_widths ( )
private
2186{
2187#ifdef ENABLE_OPENGL_ES
2188 std::vector<Vec4> heights_widths_angles;
2189 heights_widths_angles.reserve(m_vertices.size());
2191 m_texture_data.set_heights_widths_angles(heights_widths_angles);
2192#else
2194 return;
2195
2197
2198 Vec3* buffer = static_cast<Vec3*>(glMapBuffer(GL_TEXTURE_BUFFER, GL_WRITE_ONLY));
2199 glcheck();
2200
2201 for (size_t i = 0; i < m_vertices.size(); ++i) {
2202 const PathVertex& v = m_vertices[i];
2203 if (v.is_travel()) {
2204 buffer[i][0] = m_travels_radius;
2205 buffer[i][1] = m_travels_radius;
2206 }
2207 else if (v.is_wipe()) {
2208 buffer[i][0] = m_wipes_radius;
2209 buffer[i][1] = m_wipes_radius;
2210 }
2211 }
2212
2215#endif // ENABLE_OPENGL_ES
2216}
#define glMapBuffer
Definition gl.h:4243
#define GL_WRITE_ONLY
Definition gl.h:2045
#define glUnmapBuffer
Definition gl.h:5081

References libvgcode::extract_pos_and_or_hwa(), GL_TEXTURE_BUFFER, GL_WRITE_ONLY, glBindBuffer, glcheck, glMapBuffer, glsafe, glUnmapBuffer, libvgcode::PathVertex::is_travel(), libvgcode::PathVertex::is_wipe(), m_heights_widths_angles_buf_id, m_travels_radius, m_valid_lines_bitset, m_vertices, and m_wipes_radius.

Referenced by set_travels_radius(), and set_wipes_radius().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_view_full_range()

void libvgcode::ViewerImpl::update_view_full_range ( )
private
2023{
2024 const Interval& layers_range = m_layers.get_view_range();
2025 const bool travels_visible = m_settings.options_visibility[size_t(EOptionType::Travels)];
2026 const bool wipes_visible = m_settings.options_visibility[size_t(EOptionType::Wipes)];
2027
2028 // every vertex before m_layer_first_vertex[layers_range[0]] has a smaller layer_id, so the loop
2029 // below would skip all of them anyway
2030 auto first_it = m_vertices.begin();
2031 if (layers_range[0] < m_layer_first_vertex.size())
2032 first_it += m_layer_first_vertex[layers_range[0]];
2033 while (first_it != m_vertices.end() &&
2034 (first_it->layer_id < layers_range[0] || !is_visible(*first_it, m_settings))) {
2035 ++first_it;
2036 }
2037
2038 // If the first vertex is an extrusion, add an extra step to properly detect the first segment
2039 if (first_it != m_vertices.begin() && first_it != m_vertices.end() && first_it->type == EMoveType::Extrude)
2040 --first_it;
2041
2042 if (first_it == m_vertices.end())
2043 m_view_range.set_full(Range());
2044 else {
2045 if (travels_visible || wipes_visible) {
2046 // if the global range starts with a travel/wipe move, extend it to the travel/wipe start
2047 while (first_it != m_vertices.begin() &&
2048 ((travels_visible && first_it->is_travel()) ||
2049 (wipes_visible && first_it->is_wipe()))) {
2050 --first_it;
2051 }
2052 }
2053
2054 auto last_it = first_it;
2055 // ORCA: skip straight to the layer above the range rather than walking there
2056 if (m_layers_in_vertex_order && layers_range[1] + 1 < m_layer_first_vertex.size())
2057 last_it = std::max(first_it, m_vertices.begin() + m_layer_first_vertex[layers_range[1] + 1]);
2058 else if (m_layers_in_vertex_order)
2059 last_it = m_vertices.end();
2060 while (last_it != m_vertices.end() && last_it->layer_id <= layers_range[1]) {
2061 ++last_it;
2062 }
2063 if (last_it != first_it)
2064 --last_it;
2065
2066 // remove disabled trailing options, if any
2067 auto rev_first_it = std::make_reverse_iterator(first_it);
2068 if (rev_first_it != m_vertices.rbegin())
2069 --rev_first_it;
2070 auto rev_last_it = std::make_reverse_iterator(last_it);
2071 if (rev_last_it != m_vertices.rbegin())
2072 --rev_last_it;
2073
2074 bool reduced = false;
2075 while (rev_last_it != rev_first_it && !is_visible(*rev_last_it, m_settings)) {
2076 ++rev_last_it;
2077 reduced = true;
2078 }
2079
2080 if (reduced && rev_last_it != m_vertices.rend())
2081 last_it = rev_last_it.base() - 1;
2082
2083 if (travels_visible || wipes_visible) {
2084 // if the global range ends with a travel/wipe move, extend it to the travel/wipe end
2085 while (last_it != m_vertices.end() && last_it + 1 != m_vertices.end() &&
2086 ((travels_visible && last_it->is_travel() && (last_it + 1)->is_travel()) ||
2087 (wipes_visible && last_it->is_wipe() && (last_it + 1)->is_wipe()))) {
2088 ++last_it;
2089 }
2090 }
2091
2092 if (first_it != last_it)
2093 m_view_range.set_full(std::distance(m_vertices.begin(), first_it), std::distance(m_vertices.begin(), last_it));
2094 else
2095 m_view_range.set_full(Range());
2096
2097 if (m_settings.top_layer_only_view_range) {
2098 const Interval& full_range = m_view_range.get_full();
2099 const auto range_first_it = m_vertices.begin() + full_range[0];
2100 auto top_first_it = range_first_it;
2101 // ORCA: skip straight to the top layer rather than walking there
2103 top_first_it = std::max(top_first_it, m_vertices.begin() + m_layer_first_vertex[layers_range[1]]);
2104 while (top_first_it != m_vertices.end() && (top_first_it->layer_id < layers_range[1] || !is_visible(*top_first_it, m_settings)))
2105 ++top_first_it;
2106 const bool shortened = top_first_it != range_first_it;
2107 if (shortened)
2108 --top_first_it;
2109
2110 // when spiral vase mode is enabled and only one layer is shown, extend the range by one step
2111 if (m_settings.spiral_vase_mode && layers_range[0] > 0 && layers_range[0] == layers_range[1])
2112 --top_first_it;
2113 m_view_range.set_enabled(std::distance(m_vertices.begin(), top_first_it), full_range[1]);
2114 }
2115 else
2116 m_view_range.set_enabled(m_view_range.get_full());
2117 }
2118
2119 m_settings.update_view_full_range = false;
2120}
static bool is_visible(const PathVertex &v, const Settings &settings)
Definition ViewerImpl.cpp:2007

References libvgcode::Extrude, libvgcode::is_visible(), m_layer_first_vertex, m_layers, m_layers_in_vertex_order, m_settings, m_vertices, m_view_range, libvgcode::Travels, and libvgcode::Wipes.

Referenced by apply_pending_updates(), load(), set_layers_view_range(), set_view_visible_range(), toggle_extrusion_role_visibility(), toggle_option_visibility(), and toggle_top_layer_only_view_range().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_acceleration_range

ColorRange libvgcode::ViewerImpl::m_acceleration_range
private

◆ m_actual_speed_range

ColorRange libvgcode::ViewerImpl::m_actual_speed_range
private

◆ m_actual_volumetric_rate_range

ColorRange libvgcode::ViewerImpl::m_actual_volumetric_rate_range
private

◆ m_clipping_plane

std::array<float, 4> libvgcode::ViewerImpl::m_clipping_plane { 0.0f, 0.0f, 0.0f, 1.0f }
private
587{ 0.0f, 0.0f, 0.0f, 1.0f };

Referenced by render_options(), render_segments(), and set_clipping_plane().

◆ m_color_print_colors

◆ m_colors_buf_id

unsigned int libvgcode::ViewerImpl::m_colors_buf_id { 0 }
private

◆ m_colors_tex_id

unsigned int libvgcode::ViewerImpl::m_colors_tex_id { 0 }
private
540{ 0 };

Referenced by load(), render_options(), render_segments(), and reset().

◆ m_colors_tex_size

size_t libvgcode::ViewerImpl::m_colors_tex_size { 0 }
private
558{ 0 };

Referenced by get_used_gpu_memory(), and update_colors_texture().

◆ m_enabled_options_buf_id

unsigned int libvgcode::ViewerImpl::m_enabled_options_buf_id { 0 }
private
550{ 0 };

Referenced by load(), render_options(), reset(), and update_enabled_entities().

◆ m_enabled_options_count

size_t libvgcode::ViewerImpl::m_enabled_options_count { 0 }
private
552{ 0 };

Referenced by render_options(), reset(), and update_enabled_entities().

◆ m_enabled_options_tex_id

unsigned int libvgcode::ViewerImpl::m_enabled_options_tex_id { 0 }
private
551{ 0 };

Referenced by load(), render_options(), and reset().

◆ m_enabled_options_tex_size

size_t libvgcode::ViewerImpl::m_enabled_options_tex_size { 0 }
private
560{ 0 };

Referenced by get_used_gpu_memory(), and update_enabled_entities().

◆ m_enabled_segments_buf_id

unsigned int libvgcode::ViewerImpl::m_enabled_segments_buf_id { 0 }
private
544{ 0 };

Referenced by load(), render_segments(), reset(), and update_enabled_entities().

◆ m_enabled_segments_count

size_t libvgcode::ViewerImpl::m_enabled_segments_count { 0 }
private
546{ 0 };

Referenced by render_segments(), reset(), and update_enabled_entities().

◆ m_enabled_segments_tex_id

unsigned int libvgcode::ViewerImpl::m_enabled_segments_tex_id { 0 }
private
545{ 0 };

Referenced by load(), render_segments(), and reset().

◆ m_enabled_segments_tex_size

size_t libvgcode::ViewerImpl::m_enabled_segments_tex_size { 0 }
private
559{ 0 };

Referenced by get_used_gpu_memory(), and update_enabled_entities().

◆ m_enabled_translucent_segments_count

size_t libvgcode::ViewerImpl::m_enabled_translucent_segments_count { 0 }
private

◆ m_exposure

float libvgcode::ViewerImpl::m_exposure { 1.0f }
private
579{ 1.0f };

Referenced by render_segments(), and set_tone().

◆ m_extrusion_roles

ExtrusionRoles libvgcode::ViewerImpl::m_extrusion_roles
private

◆ m_extrusion_roles_colors

std::array<Color, size_t(EGCodeExtrusionRole::COUNT)> libvgcode::ViewerImpl::m_extrusion_roles_colors
private

◆ m_extrusions_box

AABox libvgcode::ViewerImpl::m_extrusions_box { Vec3{ 0.0f, 0.0f, 0.0f }, Vec3{ 0.0f, 0.0f, 0.0f } }
private
590{ Vec3{ 0.0f, 0.0f, 0.0f }, Vec3{ 0.0f, 0.0f, 0.0f } };

Referenced by load(), render_translucent_segments(), and reset().

◆ m_fan_speed_range

ColorRange libvgcode::ViewerImpl::m_fan_speed_range
private

◆ m_gloss

bool libvgcode::ViewerImpl::m_gloss { true }
private
584{ true };

Referenced by render_segments(), and set_gloss().

◆ m_has_translucent_colors

bool libvgcode::ViewerImpl::m_has_translucent_colors { false }
private
336{ false };

Referenced by reset(), update_colors(), and update_enabled_entities().

◆ m_height_range

ColorRange libvgcode::ViewerImpl::m_height_range
private

◆ m_height_width_angle_tex_size

size_t libvgcode::ViewerImpl::m_height_width_angle_tex_size { 0 }
private
557{ 0 };

Referenced by get_used_gpu_memory(), and load().

◆ m_heights_widths_angles_buf_id

unsigned int libvgcode::ViewerImpl::m_heights_widths_angles_buf_id { 0 }
private

◆ m_heights_widths_angles_tex_id

unsigned int libvgcode::ViewerImpl::m_heights_widths_angles_tex_id { 0 }
private
535{ 0 };

Referenced by load(), render_options(), render_segments(), and reset().

◆ m_initialized

bool libvgcode::ViewerImpl::m_initialized { false }
private
306{ false };

Referenced by init(), load(), and shutdown().

◆ m_jerk_range

◆ m_layer_first_vertex

std::vector<uint32_t> libvgcode::ViewerImpl::m_layer_first_vertex
private

◆ m_layer_start_times

std::array<std::vector<float>, TIME_MODES_COUNT> libvgcode::ViewerImpl::m_layer_start_times
private

◆ m_layer_time_range

std::array<ColorRange, COLOR_RANGE_TYPES_COUNT> libvgcode::ViewerImpl::m_layer_time_range
private

◆ m_layers

◆ m_layers_in_vertex_order

bool libvgcode::ViewerImpl::m_layers_in_vertex_order { false }
private
284{ false };

Referenced by load(), reset(), and update_view_full_range().

◆ m_light_top_dir

Vec3 libvgcode::ViewerImpl::m_light_top_dir { -0.4574957f, 0.4574957f, 0.7624929f }
private
582{ -0.4574957f, 0.4574957f, 0.7624929f };

Referenced by render_segments(), and set_light_top_dir().

◆ m_oit_depth_range

std::array<float, 2> libvgcode::ViewerImpl::m_oit_depth_range { 0.0f, 1.0f }
private
630{ 0.0f, 1.0f };

Referenced by render_segments(), and render_translucent_segments().

◆ m_option_template

OptionTemplate libvgcode::ViewerImpl::m_option_template
private

◆ m_options

std::vector<EOptionType> libvgcode::ViewerImpl::m_options
private

◆ m_options_colors

std::array<Color, size_t(EOptionType::COUNT)> libvgcode::ViewerImpl::m_options_colors
private

◆ m_options_shader_id

unsigned int libvgcode::ViewerImpl::m_options_shader_id { 0 }
private
373{ 0 };

Referenced by init(), render_options(), and shutdown().

◆ m_positions_buf_id

unsigned int libvgcode::ViewerImpl::m_positions_buf_id { 0 }
private
529{ 0 };

Referenced by load(), render_options(), render_segments(), and reset().

◆ m_positions_tex_id

unsigned int libvgcode::ViewerImpl::m_positions_tex_id { 0 }
private
530{ 0 };

Referenced by load(), render_options(), render_segments(), and reset().

◆ m_positions_tex_size

size_t libvgcode::ViewerImpl::m_positions_tex_size { 0 }
private
556{ 0 };

Referenced by get_used_gpu_memory(), and load().

◆ m_pressure_advance_range

ColorRange libvgcode::ViewerImpl::m_pressure_advance_range
private

◆ m_rendering_shadow_casters

bool libvgcode::ViewerImpl::m_rendering_shadow_casters { false }
private
573{ false };

Referenced by render_segments(), and render_shadow_casters().

◆ m_saturation

float libvgcode::ViewerImpl::m_saturation { 1.0f }
private
580{ 1.0f };

Referenced by render_segments(), and set_tone().

◆ m_segment_template

SegmentTemplate libvgcode::ViewerImpl::m_segment_template
private

◆ m_segments_caster_shader_id

unsigned int libvgcode::ViewerImpl::m_segments_caster_shader_id { 0 }
private
371{ 0 };

Referenced by init(), render_segments(), and shutdown().

◆ m_segments_caster_vao_id

unsigned int libvgcode::ViewerImpl::m_segments_caster_vao_id { 0 }
private

◆ m_segments_depth_shader_id

unsigned int libvgcode::ViewerImpl::m_segments_depth_shader_id { 0 }
private
627{ 0 };

Referenced by init(), render_segments(), and shutdown().

◆ m_segments_shader_id

unsigned int libvgcode::ViewerImpl::m_segments_shader_id { 0 }
private
369{ 0 };

Referenced by init(), render_segments(), and shutdown().

◆ m_settings

◆ m_settings_used_for_ranges

std::optional<Settings> libvgcode::ViewerImpl::m_settings_used_for_ranges
private

Referenced by reset(), and update_color_ranges().

◆ m_shadow_intensity

float libvgcode::ViewerImpl::m_shadow_intensity { 0.0f }
private
571{ 0.0f };

Referenced by render_segments(), and set_shadow_map().

◆ m_shadow_light_vp

Mat4x4 libvgcode::ViewerImpl::m_shadow_light_vp { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }
private
570{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f };

Referenced by render_segments(), and set_shadow_map().

◆ m_shadow_map_texel

float libvgcode::ViewerImpl::m_shadow_map_texel { 0.0f }
private
572{ 0.0f };

Referenced by render_segments(), and set_shadow_map().

◆ m_shadow_map_texture_unit

int libvgcode::ViewerImpl::m_shadow_map_texture_unit { 4 }
private
569{ 4 };

Referenced by render_segments(), and set_shadow_map().

◆ m_speed_range

ColorRange libvgcode::ViewerImpl::m_speed_range
private

◆ m_temperature_range

ColorRange libvgcode::ViewerImpl::m_temperature_range
private

◆ m_tool_colors

◆ m_total_time

std::array<float, TIME_MODES_COUNT> libvgcode::ViewerImpl::m_total_time { 0.0f, 0.0f }
private
269{ 0.0f, 0.0f };

Referenced by get_estimated_time(), load(), and reset().

◆ m_translucent_composite_shader_id

unsigned int libvgcode::ViewerImpl::m_translucent_composite_shader_id { 0 }
private
617{ 0 };

Referenced by init(), render_translucent_segments(), and shutdown().

◆ m_translucent_pass

int libvgcode::ViewerImpl::m_translucent_pass { 0 }
private
634{ 0 };

Referenced by render_segments(), and render_translucent_segments().

◆ m_translucent_targets

TranslucentTargets libvgcode::ViewerImpl::m_translucent_targets
private

◆ m_travels_radius

float libvgcode::ViewerImpl::m_travels_radius { DEFAULT_TRAVELS_RADIUS_MM }
private
static constexpr float DEFAULT_TRAVELS_RADIUS_MM
Definition Types.hpp:22

Referenced by get_travels_radius(), load(), set_travels_radius(), and update_heights_widths().

◆ m_travels_time

std::array<float, TIME_MODES_COUNT> libvgcode::ViewerImpl::m_travels_time { 0.0f, 0.0f }
private
288{ 0.0f, 0.0f };

Referenced by get_travels_estimated_time(), load(), and reset().

◆ m_uni_options_clipping_plane_id

int libvgcode::ViewerImpl::m_uni_options_clipping_plane_id { -1 }
private
428{ -1 };

Referenced by init(), and render_options().

◆ m_uni_options_colors_tex_id

int libvgcode::ViewerImpl::m_uni_options_colors_tex_id { -1 }
private
426{ -1 };

Referenced by init(), and render_options().

◆ m_uni_options_height_width_angle_tex_id

int libvgcode::ViewerImpl::m_uni_options_height_width_angle_tex_id { -1 }
private
425{ -1 };

Referenced by init(), and render_options().

◆ m_uni_options_layer_colors

LayerColorsUniforms libvgcode::ViewerImpl::m_uni_options_layer_colors
private

Referenced by init(), and render_options().

◆ m_uni_options_positions_tex_id

int libvgcode::ViewerImpl::m_uni_options_positions_tex_id { -1 }
private
424{ -1 };

Referenced by init(), and render_options().

◆ m_uni_options_projection_matrix_id

int libvgcode::ViewerImpl::m_uni_options_projection_matrix_id { -1 }
private
423{ -1 };

Referenced by init(), and render_options().

◆ m_uni_options_segment_index_tex_id

int libvgcode::ViewerImpl::m_uni_options_segment_index_tex_id { -1 }
private
427{ -1 };

Referenced by init(), and render_options().

◆ m_uni_options_view_matrix_id

int libvgcode::ViewerImpl::m_uni_options_view_matrix_id { -1 }
private
422{ -1 };

Referenced by init(), and render_options().

◆ m_uni_segments

SegmentsUniforms libvgcode::ViewerImpl::m_uni_segments
private

Referenced by init(), and render_segments().

◆ m_uni_segments_caster

SegmentsUniforms libvgcode::ViewerImpl::m_uni_segments_caster
private

Referenced by init(), and render_segments().

◆ m_uni_segments_depth

SegmentsUniforms libvgcode::ViewerImpl::m_uni_segments_depth
private

Referenced by init(), and render_segments().

◆ m_uni_segments_depth_opaque_depth_id

int libvgcode::ViewerImpl::m_uni_segments_depth_opaque_depth_id { -1 }
private
629{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_exposure_id

int libvgcode::ViewerImpl::m_uni_segments_exposure_id { -1 }
private
404{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_front_depth_id

int libvgcode::ViewerImpl::m_uni_segments_front_depth_id { -1 }
private
624{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_gloss_id

int libvgcode::ViewerImpl::m_uni_segments_gloss_id { -1 }
private
407{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_layer_colors

LayerColorsUniforms libvgcode::ViewerImpl::m_uni_segments_layer_colors
private

Referenced by init(), and render_segments().

◆ m_uni_segments_light_top_dir_id

int libvgcode::ViewerImpl::m_uni_segments_light_top_dir_id { -1 }
private
406{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_oit_depth_range_id

int libvgcode::ViewerImpl::m_uni_segments_oit_depth_range_id { -1 }
private
625{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_oit_pass_id

int libvgcode::ViewerImpl::m_uni_segments_oit_pass_id { -1 }
private
622{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_opaque_depth_id

int libvgcode::ViewerImpl::m_uni_segments_opaque_depth_id { -1 }
private
623{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_saturation_id

int libvgcode::ViewerImpl::m_uni_segments_saturation_id { -1 }
private
405{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_shadow_intensity_id

int libvgcode::ViewerImpl::m_uni_segments_shadow_intensity_id { -1 }
private
402{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_shadow_light_vp_id

int libvgcode::ViewerImpl::m_uni_segments_shadow_light_vp_id { -1 }
private
401{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_shadow_map_id

int libvgcode::ViewerImpl::m_uni_segments_shadow_map_id { -1 }
private
400{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_segments_shadow_map_texel_id

int libvgcode::ViewerImpl::m_uni_segments_shadow_map_texel_id { -1 }
private
403{ -1 };

Referenced by init(), and render_segments().

◆ m_uni_translucent_composite_accum_tex_id

int libvgcode::ViewerImpl::m_uni_translucent_composite_accum_tex_id { -1 }
private
618{ -1 };

Referenced by init(), and render_translucent_segments().

◆ m_uni_translucent_composite_front_tex_id

int libvgcode::ViewerImpl::m_uni_translucent_composite_front_tex_id { -1 }
private
620{ -1 };

Referenced by init(), and render_translucent_segments().

◆ m_uni_translucent_composite_origin_id

int libvgcode::ViewerImpl::m_uni_translucent_composite_origin_id { -1 }
private
621{ -1 };

Referenced by init(), and render_translucent_segments().

◆ m_uni_translucent_composite_reveal_tex_id

int libvgcode::ViewerImpl::m_uni_translucent_composite_reveal_tex_id { -1 }
private
619{ -1 };

Referenced by init(), and render_translucent_segments().

◆ m_used_extruders

std::map<uint8_t, std::vector<ColorPrint> > libvgcode::ViewerImpl::m_used_extruders
private

◆ m_valid_lines_bitset

BitSet libvgcode::ViewerImpl::m_valid_lines_bitset
private

◆ m_vertices

◆ m_vertices_colors

std::vector<ColorWithAlpha> libvgcode::ViewerImpl::m_vertices_colors
private

◆ m_view_range

◆ m_volumetric_rate_range

ColorRange libvgcode::ViewerImpl::m_volumetric_rate_range
private

◆ m_width_range

ColorRange libvgcode::ViewerImpl::m_width_range
private

◆ m_wipes_radius

float libvgcode::ViewerImpl::m_wipes_radius { DEFAULT_WIPES_RADIUS_MM }
private
static constexpr float DEFAULT_WIPES_RADIUS_MM
Definition Types.hpp:29

Referenced by get_wipes_radius(), load(), set_wipes_radius(), and update_heights_widths().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libvgcode/src/ViewerImpl.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libvgcode/src/ViewerImpl.cpp