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

@ -0,0 +1,24 @@
<svg width="256" height="70" viewBox="0 0 256 70" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M178.576 40.0344H43.8497V41.3404H178.576V40.0344Z" fill="#B3B3B3"/>
<path d="M178.562 42.022H43.933V43.328H178.562V42.022Z" fill="#B3B3B3"/>
<path d="M178.416 44.1306H43.8799V45.4366H178.416V44.1306Z" fill="#B3B3B3"/>
<path d="M223.542 47.9301H43.9619V49.2361H223.542V47.9301Z" fill="#B3B3B3"/>
<path d="M183.565 45.9712H33.9326V47.2771H183.565V45.9712Z" fill="#B3B3B3"/>
<path d="M238.999 62.5596H17V63.8747H238.999V62.5596Z" fill="#B3B3B3"/>
<path d="M239 53.4697H237.468V63.5133H239V53.4697Z" fill="#B3B3B3"/>
<path d="M27.6041 20.2649H26.6425V45.5898H27.6041V20.2649Z" fill="#B3B3B3"/>
<path d="M47.0404 15.8464H46.6343V44.5883H47.0404V15.8464Z" fill="#B3B3B3"/>
<path d="M30.0787 44.9425H27.5988V45.3311H30.0787V44.9425Z" fill="#F9F9F9"/>
<path d="M28.9687 24.0892H28.6613V44.5313H28.9687V24.0892Z" fill="#B3B3B3"/>
<path d="M49.095 23.7244H28.661V24.1004H49.095V23.7244Z" fill="#B3B3B3"/>
<path d="M48.6729 30.6637H28.6616V31.0397H48.6729V30.6637Z" fill="#B3B3B3"/>
<path d="M29.9891 45.2491H26.8853V45.681H29.9891V45.2491Z" fill="#B3B3B3"/>
<path d="M47.0394 44.4747H28.6613V44.9073H47.0394V44.4747Z" fill="#B3B3B3"/>
<path d="M49.0951 23.9406H48.673V31.0389H49.0951V23.9406Z" fill="#B3B3B3"/>
<path d="M36.56 15.7522H29.7357V16.0479H36.56V15.7522Z" fill="#B3B3B3"/>
<path d="M46.8804 15.8461H41.167V16.1635H46.8804V15.8461Z" fill="#B3B3B3"/>
<path d="M41.5974 5.16251H41.1652V16.1644H41.5974V5.16251Z" fill="#B3B3B3"/>
<path d="M36.56 5.22787H36.1172V16.0273H36.56V5.22787Z" fill="#B3B3B3"/>
<path d="M41.5948 5H36.1172V5.25065H41.5948V5Z" fill="#B3B3B3"/>
<path d="M30.0794 16.0375H29.7361V45.7827H30.0794V16.0375Z" fill="#B3B3B3"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -704,6 +704,15 @@ bool Preset::is_bbl_vendor_preset(PresetBundle *preset_bundle)
return is_bbl_vendor_preset;
}
bool Preset::has_cali_lines(PresetBundle* preset_bundle)
{
std::string model_id = this->get_printer_type(preset_bundle);
if (model_id == "BL-P001" || model_id == "BL-P002") {
return true;
}
return false;
}
static std::vector<std::string> s_Preset_print_options {
"layer_height", "initial_layer_print_height", "wall_loops", "slice_closing_radius", "spiral_mode", "slicing_mode",
"top_shell_layers", "top_shell_thickness", "bottom_shell_layers", "bottom_shell_thickness",

View file

@ -303,6 +303,7 @@ public:
bool is_custom_defined();
bool is_bbl_vendor_preset(PresetBundle *preset_bundle);
bool has_cali_lines(PresetBundle* preset_bundle);

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)