Merge branch 'dev' of https://github.com/prusa3d/PrusaSlicer into et_new_camera_movements
This commit is contained in:
commit
72b8b75c4c
124 changed files with 4869 additions and 2162 deletions
|
@ -72,11 +72,10 @@
|
|||
|
||||
static constexpr const float TRACKBALLSIZE = 0.8f;
|
||||
|
||||
static constexpr const float DEFAULT_BG_DARK_COLOR[3] = { 0.478f, 0.478f, 0.478f };
|
||||
static constexpr const float DEFAULT_BG_LIGHT_COLOR[3] = { 0.753f, 0.753f, 0.753f };
|
||||
static constexpr const float ERROR_BG_DARK_COLOR[3] = { 0.478f, 0.192f, 0.039f };
|
||||
static constexpr const float ERROR_BG_LIGHT_COLOR[3] = { 0.753f, 0.192f, 0.039f };
|
||||
//static constexpr const float AXES_COLOR[3][3] = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } };
|
||||
static const Slic3r::ColorRGB DEFAULT_BG_DARK_COLOR = { 0.478f, 0.478f, 0.478f };
|
||||
static const Slic3r::ColorRGB DEFAULT_BG_LIGHT_COLOR = { 0.753f, 0.753f, 0.753f };
|
||||
static const Slic3r::ColorRGB ERROR_BG_DARK_COLOR = { 0.478f, 0.192f, 0.039f };
|
||||
static const Slic3r::ColorRGB ERROR_BG_LIGHT_COLOR = { 0.753f, 0.192f, 0.039f };
|
||||
|
||||
// Number of floats
|
||||
static constexpr const size_t MAX_VERTEX_BUFFER_SIZE = 131072 * 6; // 3.15MB
|
||||
|
@ -849,8 +848,8 @@ void GLCanvas3D::SequentialPrintClearance::set_polygons(const Polygons& polygons
|
|||
|
||||
void GLCanvas3D::SequentialPrintClearance::render()
|
||||
{
|
||||
std::array<float, 4> FILL_COLOR = { 1.0f, 0.0f, 0.0f, 0.5f };
|
||||
std::array<float, 4> NO_FILL_COLOR = { 1.0f, 1.0f, 1.0f, 0.75f };
|
||||
const ColorRGBA FILL_COLOR = { 1.0f, 0.0f, 0.0f, 0.5f };
|
||||
const ColorRGBA NO_FILL_COLOR = { 1.0f, 1.0f, 1.0f, 0.75f };
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader == nullptr)
|
||||
|
@ -2115,12 +2114,21 @@ void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, co
|
|||
request_extra_frame();
|
||||
}
|
||||
|
||||
#if ENABLE_PREVIEW_LAYOUT
|
||||
void GLCanvas3D::refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last)
|
||||
{
|
||||
m_gcode_viewer.refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last);
|
||||
set_as_dirty();
|
||||
request_extra_frame();
|
||||
}
|
||||
#else
|
||||
void GLCanvas3D::refresh_gcode_preview_render_paths()
|
||||
{
|
||||
m_gcode_viewer.refresh_render_paths();
|
||||
set_as_dirty();
|
||||
request_extra_frame();
|
||||
}
|
||||
#endif // ENABLE_PREVIEW_LAYOUT
|
||||
|
||||
void GLCanvas3D::load_sla_preview()
|
||||
{
|
||||
|
@ -2424,12 +2432,16 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
|||
case 'i': { _update_camera_zoom(1.0); break; }
|
||||
case 'K':
|
||||
case 'k': { wxGetApp().plater()->get_camera().select_next_type(); m_dirty = true; break; }
|
||||
case 'L':
|
||||
case 'l': {
|
||||
if (!m_main_toolbar.is_enabled()) {
|
||||
case 'L':
|
||||
case 'l': {
|
||||
if (!m_main_toolbar.is_enabled()) {
|
||||
#if ENABLE_PREVIEW_LAYOUT
|
||||
show_legend(!is_legend_shown());
|
||||
#else
|
||||
m_gcode_viewer.enable_legend(!m_gcode_viewer.is_legend_enabled());
|
||||
m_dirty = true;
|
||||
wxGetApp().plater()->update_preview_bottom_toolbar();
|
||||
#endif // ENABLE_PREVIEW_LAYOUT
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3812,6 +3824,9 @@ void GLCanvas3D::set_cursor(ECursorType type)
|
|||
|
||||
void GLCanvas3D::msw_rescale()
|
||||
{
|
||||
#if ENABLE_PREVIEW_LAYOUT
|
||||
m_gcode_viewer.invalidate_legend();
|
||||
#endif // ENABLE_PREVIEW_LAYOUT
|
||||
}
|
||||
|
||||
void GLCanvas3D::update_tooltip_for_settings_item_in_main_toolbar()
|
||||
|
@ -4041,8 +4056,11 @@ bool GLCanvas3D::_render_search_list(float pos_x)
|
|||
action_taken = true;
|
||||
else
|
||||
sidebar.jump_to_option(selected);*/
|
||||
if (selected != 9999)
|
||||
if (selected != 9999) {
|
||||
imgui->end(); // end imgui before the jump to option
|
||||
sidebar.jump_to_option(selected);
|
||||
return true;
|
||||
}
|
||||
action_taken = true;
|
||||
}
|
||||
|
||||
|
@ -4156,9 +4174,6 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
return ret;
|
||||
};
|
||||
|
||||
static const std::array<float, 4> orange = { 0.923f, 0.504f, 0.264f, 1.0f };
|
||||
static const std::array<float, 4> gray = { 0.64f, 0.64f, 0.64f, 1.0f };
|
||||
|
||||
GLVolumePtrs visible_volumes;
|
||||
|
||||
for (GLVolume* vol : volumes.volumes) {
|
||||
|
@ -4213,7 +4228,7 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
shader->set_uniform("emission_factor", 0.0f);
|
||||
|
||||
for (GLVolume* vol : visible_volumes) {
|
||||
shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : orange) : gray);
|
||||
shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : ColorRGBA::ORANGE()) : ColorRGBA::GRAY());
|
||||
// the volume may have been deactivated by an active gizmo
|
||||
bool is_active = vol->is_active;
|
||||
vol->is_active = true;
|
||||
|
@ -4944,19 +4959,20 @@ void GLCanvas3D::_picking_pass()
|
|||
int volume_id = -1;
|
||||
int gizmo_id = -1;
|
||||
|
||||
GLubyte color[4] = { 0, 0, 0, 0 };
|
||||
std::array<GLubyte, 4> color = { 0, 0, 0, 0 };
|
||||
const Size& cnv_size = get_canvas_size();
|
||||
bool inside = 0 <= m_mouse.position(0) && m_mouse.position(0) < cnv_size.get_width() && 0 <= m_mouse.position(1) && m_mouse.position(1) < cnv_size.get_height();
|
||||
if (inside) {
|
||||
glsafe(::glReadPixels(m_mouse.position(0), cnv_size.get_height() - m_mouse.position(1) - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color));
|
||||
glsafe(::glReadPixels(m_mouse.position(0), cnv_size.get_height() - m_mouse.position.y() - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color.data()));
|
||||
if (picking_checksum_alpha_channel(color[0], color[1], color[2]) == color[3]) {
|
||||
// Only non-interpolated colors are valid, those have their lowest three bits zeroed.
|
||||
// we reserve color = (0,0,0) for occluders (as the printbed)
|
||||
// volumes' id are shifted by 1
|
||||
// see: _render_volumes_for_picking()
|
||||
volume_id = color[0] + (color[1] << 8) + (color[2] << 16) - 1;
|
||||
unsigned int id = picking_encode(color[0], color[1], color[2]);
|
||||
volume_id = id - 1;
|
||||
// gizmos' id are instead properly encoded by the color
|
||||
gizmo_id = color[0] + (color[1] << 8) + (color[2] << 16);
|
||||
gizmo_id = id;
|
||||
}
|
||||
}
|
||||
if (0 <= volume_id && volume_id < (int)m_volumes.volumes.size()) {
|
||||
|
@ -5072,19 +5088,11 @@ void GLCanvas3D::_render_background() const
|
|||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
::glBegin(GL_QUADS);
|
||||
if (use_error_color)
|
||||
::glColor3fv(ERROR_BG_DARK_COLOR);
|
||||
else
|
||||
::glColor3fv(DEFAULT_BG_DARK_COLOR);
|
||||
|
||||
::glColor3fv(use_error_color ? ERROR_BG_DARK_COLOR.data(): DEFAULT_BG_DARK_COLOR.data());
|
||||
::glVertex2f(-1.0f, -1.0f);
|
||||
::glVertex2f(1.0f, -1.0f);
|
||||
|
||||
if (use_error_color)
|
||||
::glColor3fv(ERROR_BG_LIGHT_COLOR);
|
||||
else
|
||||
::glColor3fv(DEFAULT_BG_LIGHT_COLOR);
|
||||
|
||||
::glColor3fv(use_error_color ? ERROR_BG_LIGHT_COLOR.data() : DEFAULT_BG_LIGHT_COLOR.data());
|
||||
::glVertex2f(1.0f, 1.0f);
|
||||
::glVertex2f(-1.0f, 1.0f);
|
||||
glsafe(::glEnd());
|
||||
|
@ -5367,8 +5375,6 @@ void GLCanvas3D::_render_overlays()
|
|||
|
||||
void GLCanvas3D::_render_volumes_for_picking() const
|
||||
{
|
||||
static const GLfloat INV_255 = 1.0f / 255.0f;
|
||||
|
||||
// do not cull backfaces to show broken geometry, if any
|
||||
glsafe(::glDisable(GL_CULL_FACE));
|
||||
|
||||
|
@ -5383,13 +5389,9 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
|||
// Object picking mode. Render the object with a color encoding the object index.
|
||||
// we reserve color = (0,0,0) for occluders (as the printbed)
|
||||
// so we shift volumes' id by 1 to get the proper color
|
||||
unsigned int id = 1 + volume.second.first;
|
||||
unsigned int r = (id & (0x000000FF << 0)) << 0;
|
||||
unsigned int g = (id & (0x000000FF << 8)) >> 8;
|
||||
unsigned int b = (id & (0x000000FF << 16)) >> 16;
|
||||
unsigned int a = picking_checksum_alpha_channel(r, g, b);
|
||||
glsafe(::glColor4f((GLfloat)r * INV_255, (GLfloat)g * INV_255, (GLfloat)b * INV_255, (GLfloat)a * INV_255));
|
||||
volume.first->render();
|
||||
const unsigned int id = 1 + volume.second.first;
|
||||
glsafe(::glColor4fv(picking_decode(id).data()));
|
||||
volume.first->render();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5815,7 +5817,7 @@ void GLCanvas3D::_load_print_toolpaths(const BuildVolume &build_volume)
|
|||
if (!print->has_skirt() && !print->has_brim())
|
||||
return;
|
||||
|
||||
const std::array<float, 4> color = { 0.5f, 1.0f, 0.5f, 1.0f }; // greenish
|
||||
const ColorRGBA color = ColorRGBA::GREENISH();
|
||||
|
||||
// number of skirt layers
|
||||
size_t total_layer_count = 0;
|
||||
|
@ -5862,7 +5864,8 @@ void GLCanvas3D::_load_print_toolpaths(const BuildVolume &build_volume)
|
|||
|
||||
void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, const BuildVolume& build_volume, const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values)
|
||||
{
|
||||
std::vector<std::array<float, 4>> tool_colors = _parse_colors(str_tool_colors);
|
||||
std::vector<ColorRGBA> tool_colors;
|
||||
decode_colors(str_tool_colors, tool_colors);
|
||||
|
||||
struct Ctxt
|
||||
{
|
||||
|
@ -5871,20 +5874,20 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
bool has_perimeters;
|
||||
bool has_infill;
|
||||
bool has_support;
|
||||
const std::vector<std::array<float, 4>>* tool_colors;
|
||||
const std::vector<ColorRGBA>* tool_colors;
|
||||
bool is_single_material_print;
|
||||
int extruders_cnt;
|
||||
const std::vector<CustomGCode::Item>* color_print_values;
|
||||
|
||||
static const std::array<float, 4>& color_perimeters() { static std::array<float, 4> color = { 1.0f, 1.0f, 0.0f, 1.f }; return color; } // yellow
|
||||
static const std::array<float, 4>& color_infill() { static std::array<float, 4> color = { 1.0f, 0.5f, 0.5f, 1.f }; return color; } // redish
|
||||
static const std::array<float, 4>& color_support() { static std::array<float, 4> color = { 0.5f, 1.0f, 0.5f, 1.f }; return color; } // greenish
|
||||
static const std::array<float, 4>& color_pause_or_custom_code() { static std::array<float, 4> color = { 0.5f, 0.5f, 0.5f, 1.f }; return color; } // gray
|
||||
static ColorRGBA color_perimeters() { return ColorRGBA::YELLOW(); }
|
||||
static ColorRGBA color_infill() { return ColorRGBA::REDISH(); }
|
||||
static ColorRGBA color_support() { return ColorRGBA::GREENISH(); }
|
||||
static ColorRGBA color_pause_or_custom_code() { return ColorRGBA::GRAY(); }
|
||||
|
||||
// For cloring by a tool, return a parsed color.
|
||||
bool color_by_tool() const { return tool_colors != nullptr; }
|
||||
size_t number_tools() const { return color_by_tool() ? tool_colors->size() : 0; }
|
||||
const std::array<float, 4>& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
const ColorRGBA& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
|
||||
// For coloring by a color_print(M600), return a parsed color.
|
||||
bool color_by_color_print() const { return color_print_values!=nullptr; }
|
||||
|
@ -6024,7 +6027,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
//FIXME Improve the heuristics for a grain size.
|
||||
size_t grain_size = std::max(ctxt.layers.size() / 16, size_t(1));
|
||||
tbb::spin_mutex new_volume_mutex;
|
||||
auto new_volume = [this, &new_volume_mutex](const std::array<float, 4>& color) {
|
||||
auto new_volume = [this, &new_volume_mutex](const ColorRGBA& color) {
|
||||
// Allocate the volume before locking.
|
||||
GLVolume *volume = new GLVolume(color);
|
||||
volume->is_extrusion_path = true;
|
||||
|
@ -6165,21 +6168,22 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, con
|
|||
if (!print->is_step_done(psWipeTower))
|
||||
return;
|
||||
|
||||
std::vector<std::array<float, 4>> tool_colors = _parse_colors(str_tool_colors);
|
||||
std::vector<ColorRGBA> tool_colors;
|
||||
decode_colors(str_tool_colors, tool_colors);
|
||||
|
||||
struct Ctxt
|
||||
{
|
||||
const Print *print;
|
||||
const std::vector<std::array<float, 4>>* tool_colors;
|
||||
const std::vector<ColorRGBA>* tool_colors;
|
||||
Vec2f wipe_tower_pos;
|
||||
float wipe_tower_angle;
|
||||
|
||||
static const std::array<float, 4>& color_support() { static std::array<float, 4> color = { 0.5f, 1.0f, 0.5f, 1.f }; return color; } // greenish
|
||||
static ColorRGBA color_support() { return ColorRGBA::GREENISH(); }
|
||||
|
||||
// For cloring by a tool, return a parsed color.
|
||||
bool color_by_tool() const { return tool_colors != nullptr; }
|
||||
size_t number_tools() const { return this->color_by_tool() ? tool_colors->size() : 0; }
|
||||
const std::array<float, 4>& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
const ColorRGBA& color_tool(size_t tool) const { return (*tool_colors)[tool]; }
|
||||
int volume_idx(int tool, int feature) const {
|
||||
return this->color_by_tool() ? std::min<int>(this->number_tools() - 1, std::max<int>(tool, 0)) : feature;
|
||||
}
|
||||
|
@ -6211,7 +6215,7 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, con
|
|||
size_t n_items = print->wipe_tower_data().tool_changes.size() + (ctxt.priming.empty() ? 0 : 1);
|
||||
size_t grain_size = std::max(n_items / 128, size_t(1));
|
||||
tbb::spin_mutex new_volume_mutex;
|
||||
auto new_volume = [this, &new_volume_mutex](const std::array<float, 4>& color) {
|
||||
auto new_volume = [this, &new_volume_mutex](const ColorRGBA& color) {
|
||||
auto *volume = new GLVolume(color);
|
||||
volume->is_extrusion_path = true;
|
||||
tbb::spin_mutex::scoped_lock lock;
|
||||
|
@ -6330,7 +6334,7 @@ void GLCanvas3D::_load_sla_shells()
|
|||
return;
|
||||
|
||||
auto add_volume = [this](const SLAPrintObject &object, int volume_id, const SLAPrintObject::Instance& instance,
|
||||
const TriangleMesh& mesh, const std::array<float, 4>& color, bool outside_printer_detection_enabled) {
|
||||
const TriangleMesh& mesh, const ColorRGBA& color, bool outside_printer_detection_enabled) {
|
||||
m_volumes.volumes.emplace_back(new GLVolume(color));
|
||||
GLVolume& v = *m_volumes.volumes.back();
|
||||
#if ENABLE_SMOOTH_NORMALS
|
||||
|
@ -6392,28 +6396,6 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
|
|||
_set_warning_notification(warning, show);
|
||||
}
|
||||
|
||||
std::vector<std::array<float, 4>> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors)
|
||||
{
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
|
||||
std::vector<std::array<float, 4>> output(colors.size(), { 1.0f, 1.0f, 1.0f, 1.0f });
|
||||
for (size_t i = 0; i < colors.size(); ++i) {
|
||||
const std::string& color = colors[i];
|
||||
const char* c = color.data() + 1;
|
||||
if (color.size() == 7 && color.front() == '#') {
|
||||
for (size_t j = 0; j < 3; ++j) {
|
||||
int digit1 = hex_digit_to_int(*c++);
|
||||
int digit2 = hex_digit_to_int(*c++);
|
||||
if (digit1 == -1 || digit2 == -1)
|
||||
break;
|
||||
|
||||
output[i][j] = float(digit1 * 16 + digit2) * INV_255;
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
|
||||
{
|
||||
enum ErrorType{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue