NEW: render cali lines for X1 series printer

Change-Id: I0edbe9cac3be837702e0b03d66766291b012b4b8
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2023-06-14 15:38:38 +08:00 committed by Lane.Wei
parent f84d38bea1
commit 2910014887
8 changed files with 125 additions and 17 deletions

View file

@ -1891,7 +1891,7 @@ void GLCanvas3D::render(bool only_init)
if (!no_partplate)
_render_bed(!camera.is_looking_downward(), show_axes);
if (!no_partplate) //BBS: add outline logic
_render_platelist(!camera.is_looking_downward(), only_current, only_body, hover_id);
_render_platelist(!camera.is_looking_downward(), only_current, only_body, hover_id, true);
_render_objects(GLVolumeCollection::ERenderType::Transparent, !m_gizmos.is_running());
}
/* preview render */
@ -6677,9 +6677,9 @@ void GLCanvas3D::_render_bed_for_picking(bool bottom)
//m_bed.render_for_picking(*this, bottom, scale_factor);
}
void GLCanvas3D::_render_platelist(bool bottom, bool only_current, bool only_body, int hover_id) const
void GLCanvas3D::_render_platelist(bool bottom, bool only_current, bool only_body, int hover_id, bool render_cali) const
{
wxGetApp().plater()->get_partplate_list().render(bottom, only_current, only_body, hover_id);
wxGetApp().plater()->get_partplate_list().render(bottom, only_current, only_body, hover_id, render_cali);
}
void GLCanvas3D::_render_plates_for_picking() const

View file

@ -1106,7 +1106,7 @@ private:
void _render_bed(bool bottom, bool show_axes);
void _render_bed_for_picking(bool bottom);
//BBS: add part plate related logic
void _render_platelist(bool bottom, bool only_current, bool only_body = false, int hover_id = -1) const;
void _render_platelist(bool bottom, bool only_current, bool only_body = false, int hover_id = -1, bool render_cali = false) const;
void _render_plates_for_picking() const;
//BBS: add outline drawing logic
void _render_objects(GLVolumeCollection::ERenderType type, bool with_outline = true);

View file

@ -557,7 +557,7 @@ void PartPlate::render_logo_texture(GLTexture &logo_texture, const GeometryBuffe
}
}
void PartPlate::render_logo(bool bottom) const
void PartPlate::render_logo(bool bottom, bool render_cali) const
{
if (!m_partplate_list->render_bedtype_logo) {
// render third-party printer texture logo
@ -636,6 +636,7 @@ void PartPlate::render_logo(bool bottom) const
}
m_partplate_list->load_bedtype_textures();
m_partplate_list->load_cali_textures();
// btDefault should be skipped
auto curr_bed_type = get_bed_type();
@ -645,6 +646,7 @@ void PartPlate::render_logo(bool bottom) const
curr_bed_type = proj_cfg.opt_enum<BedType>(std::string("curr_bed_type"));
}
int bed_type_idx = (int)curr_bed_type;
// render bed textures
for (auto &part : m_partplate_list->bed_texture_info[bed_type_idx].parts) {
if (part.texture) {
if (part.buffer && part.buffer->get_vertices_count() > 0
@ -661,6 +663,24 @@ void PartPlate::render_logo(bool bottom) const
}
}
}
// render cali texture
if (render_cali) {
for (auto& part : m_partplate_list->cali_texture_info.parts) {
if (part.texture) {
if (part.buffer && part.buffer->get_vertices_count() > 0) {
if (part.offset.x() != m_origin.x() || part.offset.y() != m_origin.y()) {
part.offset = Vec2d(m_origin.x(), m_origin.y());
part.update_buffer();
}
render_logo_texture(*(part.texture),
*(part.buffer),
bottom,
part.vbo_id);
}
}
}
}
}
void PartPlate::render_exclude_area(bool force_default_color) const {
@ -2301,7 +2321,7 @@ bool PartPlate::intersects(const BoundingBoxf3& bb) const
return print_volume.intersects(bb);
}
void PartPlate::render(bool bottom, bool only_body, bool force_background_color, HeightLimitMode mode, int hover_id)
void PartPlate::render(bool bottom, bool only_body, bool force_background_color, HeightLimitMode mode, int hover_id, bool render_cali)
{
glsafe(::glEnable(GL_DEPTH_TEST));
glsafe(::glEnable(GL_BLEND));
@ -2318,7 +2338,10 @@ void PartPlate::render(bool bottom, bool only_body, bool force_background_color,
render_grid(bottom);
if (!bottom && m_selected && !force_background_color) {
render_logo(bottom);
if (m_partplate_list)
render_logo(bottom, m_partplate_list->render_cali_logo && render_cali);
else
render_logo(bottom);
}
render_height_limit(mode);
@ -2860,6 +2883,7 @@ void PartPlateList::release_icon_textures()
}
//reset
PartPlateList::is_load_bedtype_textures = false;
PartPlateList::is_load_cali_texture = false;
for (int i = 0; i < btCount; i++) {
for (auto& part: bed_texture_info[i].parts) {
if (part.texture) {
@ -4124,7 +4148,7 @@ void PartPlateList::postprocess_arrange_polygon(arrangement::ArrangePolygon& arr
/*rendering related functions*/
//render
void PartPlateList::render(bool bottom, bool only_current, bool only_body, int hover_id)
void PartPlateList::render(bool bottom, bool only_current, bool only_body, int hover_id, bool render_cali)
{
const std::lock_guard<std::mutex> local_lock(m_plates_mutex);
std::vector<PartPlate*>::iterator it = m_plate_list.begin();
@ -4149,15 +4173,15 @@ void PartPlateList::render(bool bottom, bool only_current, bool only_body, int h
if (current_index == m_current_plate) {
PartPlate::HeightLimitMode height_mode = (only_current)?PartPlate::HEIGHT_LIMIT_NONE:m_height_limit_mode;
if (plate_hover_index == current_index)
(*it)->render(bottom, only_body, false, height_mode, plate_hover_action);
(*it)->render(bottom, only_body, false, height_mode, plate_hover_action, render_cali);
else
(*it)->render(bottom, only_body, false, height_mode, -1);
(*it)->render(bottom, only_body, false, height_mode, -1, render_cali);
}
else {
if (plate_hover_index == current_index)
(*it)->render(bottom, only_body, false, PartPlate::HEIGHT_LIMIT_NONE, plate_hover_action);
(*it)->render(bottom, only_body, false, PartPlate::HEIGHT_LIMIT_NONE, plate_hover_action, render_cali);
else
(*it)->render(bottom, only_body, false, PartPlate::HEIGHT_LIMIT_NONE, -1);
(*it)->render(bottom, only_body, false, PartPlate::HEIGHT_LIMIT_NONE, -1, render_cali);
}
}
}
@ -4747,6 +4771,7 @@ void PartPlateList::print() const
}
bool PartPlateList::is_load_bedtype_textures = false;
bool PartPlateList::is_load_cali_texture = false;
void PartPlateList::BedTextureInfo::TexturePart::update_buffer()
{
@ -4837,5 +4862,39 @@ void PartPlateList::load_bedtype_textures()
PartPlateList::is_load_bedtype_textures = true;
}
void PartPlateList::init_cali_texture_info()
{
BedTextureInfo::TexturePart cali_line(1, -3, 256, 70, "bbl_cali_lines.svg");
cali_texture_info.parts.push_back(cali_line);
for (int j = 0; j < cali_texture_info.parts.size(); j++) {
cali_texture_info.parts[j].update_buffer();
}
}
void PartPlateList::load_cali_textures()
{
if (PartPlateList::is_load_cali_texture) return;
init_cali_texture_info();
GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size();
GLint logo_tex_size = (max_tex_size < 2048) ? max_tex_size : 2048;
for (int i = 0; i < (unsigned int)btCount; ++i) {
for (int j = 0; j < cali_texture_info.parts.size(); j++) {
std::string filename = resources_dir() + "/images/" + cali_texture_info.parts[j].filename;
if (boost::filesystem::exists(filename)) {
PartPlateList::cali_texture_info.parts[j].texture = new GLTexture();
if (!PartPlateList::cali_texture_info.parts[j].texture->load_from_svg_file(filename, true, true, true, logo_tex_size)) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load cali texture from %1% failed!") % filename;
}
}
else {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load cali texture from %1% failed!") % filename;
}
}
}
PartPlateList::is_load_cali_texture = true;
}
}//end namespace GUI
}//end namespace slic3r

View file

@ -170,7 +170,7 @@ private:
void calc_vertex_for_icons(int index, GeometryBuffer &buffer);
void calc_vertex_for_icons_background(int icon_count, GeometryBuffer &buffer);
void render_background(bool force_default_color = false) const;
void render_logo(bool bottom) const;
void render_logo(bool bottom, bool render_cali = true) const;
void render_logo_texture(GLTexture& logo_texture, const GeometryBuffer& logo_buffer, bool bottom, unsigned int vbo_id) const;
void render_exclude_area(bool force_default_color) const;
//void render_background_for_picking(const float* render_color) const;
@ -338,7 +338,7 @@ public:
bool contains(const BoundingBoxf3& bb) const;
bool intersects(const BoundingBoxf3& bb) const;
void render(bool bottom, bool only_body = false, bool force_background_color = false, HeightLimitMode mode = HEIGHT_LIMIT_NONE, int hover_id = -1);
void render(bool bottom, bool only_body = false, bool force_background_color = false, HeightLimitMode mode = HEIGHT_LIMIT_NONE, int hover_id = -1, bool render_cali = false);
void render_for_picking() const { on_render_for_picking(); }
void set_selected();
void set_unselected();
@ -522,6 +522,7 @@ class PartPlateList : public ObjectBase
// set render option
bool render_bedtype_logo = true;
bool render_plate_settings = true;
bool render_cali_logo = true;
bool m_is_dark = false;
@ -585,6 +586,7 @@ public:
static const unsigned int MAX_PLATES_COUNT = MAX_PLATE_COUNT;
static GLTexture bed_textures[(unsigned int)btCount];
static bool is_load_bedtype_textures;
static bool is_load_cali_texture;
PartPlateList(int width, int depth, int height, Plater* platerObj, Model* modelObj, PrinterTechnology tech = ptFFF);
PartPlateList(Plater* platerObj, Model* modelObj, PrinterTechnology tech = ptFFF);
@ -725,9 +727,10 @@ public:
/*rendering related functions*/
void on_change_color_mode(bool is_dark) { m_is_dark = is_dark; }
void render(bool bottom, bool only_current = false, bool only_body = false, int hover_id = -1);
void render(bool bottom, bool only_current = false, bool only_body = false, int hover_id = -1, bool render_cali = false);
void render_for_picking_pass();
void set_render_option(bool bedtype_texture, bool plate_settings);
void set_render_cali(bool value = true) { render_cali_logo = value; }
BoundingBoxf3& get_bounding_box() { return m_bounding_box; }
//int select_plate_by_hover_id(int hover_id);
int select_plate_by_obj(int obj_index, int instance_index);
@ -785,7 +788,12 @@ public:
void init_bed_type_info();
void load_bedtype_textures();
void show_cali_texture(bool show = true);
void init_cali_texture_info();
void load_cali_textures();
BedTextureInfo bed_texture_info[btCount];
BedTextureInfo cali_texture_info;
};
} // namespace GUI

View file

@ -1643,10 +1643,17 @@ void Tab::on_presets_changed()
wxGetApp().plater()->sidebar().update_presets(m_type);
bool is_bbl_vendor_preset = wxGetApp().preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(wxGetApp().preset_bundle);
if (is_bbl_vendor_preset)
if (is_bbl_vendor_preset) {
wxGetApp().plater()->get_partplate_list().set_render_option(true, true);
else
if (wxGetApp().preset_bundle->printers.get_edited_preset().has_cali_lines(wxGetApp().preset_bundle)) {
wxGetApp().plater()->get_partplate_list().set_render_cali(true);
} else {
wxGetApp().plater()->get_partplate_list().set_render_cali(false);
}
} else {
wxGetApp().plater()->get_partplate_list().set_render_option(false, false);
wxGetApp().plater()->get_partplate_list().set_render_cali(false);
}
// Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors.
for (auto t: m_dependent_tabs)