mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
NEW: add print sequence setting to plate
Change-Id: Ic4acb68743442a49dee04702e7a8073b6641bc39
This commit is contained in:
parent
a2431d7965
commit
688084c475
31 changed files with 493 additions and 395 deletions
|
@ -133,7 +133,7 @@ void PartPlate::init()
|
|||
m_print = nullptr;
|
||||
}
|
||||
|
||||
BedType PartPlate::get_bed_type(bool check_global/*= true*/) const
|
||||
BedType PartPlate::get_bed_type() const
|
||||
{
|
||||
std::string bed_type_key = "curr_bed_type";
|
||||
|
||||
|
@ -141,32 +141,26 @@ BedType PartPlate::get_bed_type(bool check_global/*= true*/) const
|
|||
assert(m_plater != nullptr);
|
||||
if (m_config.has(bed_type_key)) {
|
||||
BedType bed_type = m_config.opt_enum<BedType>(bed_type_key);
|
||||
if (bed_type != btDefault)
|
||||
return bed_type;
|
||||
return bed_type;
|
||||
}
|
||||
|
||||
if (!check_global)
|
||||
return btDefault;
|
||||
|
||||
if (m_plater) {
|
||||
// In GUI mode
|
||||
DynamicConfig& proj_cfg = wxGetApp().preset_bundle->project_config;
|
||||
if (proj_cfg.has(bed_type_key))
|
||||
return proj_cfg.opt_enum<BedType>(bed_type_key);
|
||||
}
|
||||
|
||||
return BedType::btPC;
|
||||
return btDefault;
|
||||
}
|
||||
|
||||
void PartPlate::set_bed_type(BedType bed_type)
|
||||
{
|
||||
std::string bed_type_key = "curr_bed_type";
|
||||
std::string bed_type_key = "curr_bed_type";
|
||||
|
||||
// should be called in GUI context
|
||||
assert(m_plater != nullptr);
|
||||
// should be called in GUI context
|
||||
assert(m_plater != nullptr);
|
||||
|
||||
// update slice state
|
||||
BedType old_real_bed_type = get_bed_type();
|
||||
if (old_real_bed_type == btDefault) {
|
||||
DynamicConfig& proj_cfg = wxGetApp().preset_bundle->project_config;
|
||||
if (proj_cfg.has(bed_type_key))
|
||||
old_real_bed_type = proj_cfg.opt_enum<BedType>(bed_type_key);
|
||||
}
|
||||
BedType new_real_bed_type = bed_type;
|
||||
if (bed_type == BedType::btDefault) {
|
||||
DynamicConfig& proj_cfg = wxGetApp().preset_bundle->project_config;
|
||||
|
@ -177,18 +171,74 @@ void PartPlate::set_bed_type(BedType bed_type)
|
|||
update_slice_result_valid_state(false);
|
||||
}
|
||||
|
||||
if (bed_type == BedType::btDefault)
|
||||
m_config.erase(bed_type_key);
|
||||
else
|
||||
m_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(bed_type));
|
||||
|
||||
if (m_plater)
|
||||
m_plater->update_project_dirty_from_presets();
|
||||
if (bed_type == BedType::btDefault)
|
||||
m_config.erase(bed_type_key);
|
||||
else
|
||||
m_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(bed_type));
|
||||
}
|
||||
|
||||
void PartPlate::reset_bed_type()
|
||||
{
|
||||
m_config.erase("curr_bed_type");
|
||||
m_config.erase("curr_bed_type");
|
||||
}
|
||||
|
||||
void PartPlate::set_print_seq(PrintSequence print_seq)
|
||||
{
|
||||
std::string print_seq_key = "print_sequence";
|
||||
|
||||
// should be called in GUI context
|
||||
assert(m_plater != nullptr);
|
||||
|
||||
// update slice state
|
||||
PrintSequence old_real_print_seq = get_print_seq();
|
||||
if (old_real_print_seq == PrintSequence::ByDefault) {
|
||||
auto curr_preset_config = wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
if (curr_preset_config.has(print_seq_key))
|
||||
old_real_print_seq = curr_preset_config.option<ConfigOptionEnum<PrintSequence>>(print_seq_key)->value;
|
||||
}
|
||||
|
||||
PrintSequence new_real_print_seq = print_seq;
|
||||
|
||||
if (print_seq == PrintSequence::ByDefault) {
|
||||
auto curr_preset_config = wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
if (curr_preset_config.has(print_seq_key))
|
||||
new_real_print_seq = curr_preset_config.option<ConfigOptionEnum<PrintSequence>>(print_seq_key)->value;
|
||||
}
|
||||
|
||||
if (old_real_print_seq != new_real_print_seq) {
|
||||
update_slice_result_valid_state(false);
|
||||
}
|
||||
|
||||
//print_seq_same_global = same_global;
|
||||
if (print_seq == PrintSequence::ByDefault)
|
||||
m_config.erase(print_seq_key);
|
||||
else
|
||||
m_config.set_key_value(print_seq_key, new ConfigOptionEnum<PrintSequence>(print_seq));
|
||||
}
|
||||
|
||||
PrintSequence PartPlate::get_print_seq() const
|
||||
{
|
||||
std::string print_seq_key = "print_sequence";
|
||||
|
||||
// should be called in GUI context
|
||||
assert(m_plater != nullptr);
|
||||
|
||||
if (m_config.has(print_seq_key)) {
|
||||
PrintSequence print_seq = m_config.opt_enum<PrintSequence>(print_seq_key);
|
||||
return print_seq;
|
||||
}
|
||||
|
||||
return PrintSequence::ByDefault;
|
||||
}
|
||||
|
||||
PrintSequence PartPlate::get_real_print_seq() const
|
||||
{
|
||||
PrintSequence curr_plate_seq = get_print_seq();
|
||||
if (curr_plate_seq == PrintSequence::ByDefault) {
|
||||
auto curr_preset_config = wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
if (curr_preset_config.has("print_sequence")) curr_plate_seq = curr_preset_config.option<ConfigOptionEnum<PrintSequence>>("print_sequence")->value;
|
||||
}
|
||||
return curr_plate_seq;
|
||||
}
|
||||
|
||||
bool PartPlate::valid_instance(int obj_id, int instance_id)
|
||||
|
@ -561,7 +611,13 @@ void PartPlate::render_logo(bool bottom) const
|
|||
m_partplate_list->load_bedtype_textures();
|
||||
|
||||
// btDefault should be skipped
|
||||
int bed_type_idx = (int)get_bed_type();
|
||||
auto curr_bed_type = get_bed_type();
|
||||
if (curr_bed_type == btDefault) {
|
||||
DynamicConfig& proj_cfg = wxGetApp().preset_bundle->project_config;
|
||||
if (proj_cfg.has(std::string("curr_bed_type")))
|
||||
curr_bed_type = proj_cfg.opt_enum<BedType>(std::string("curr_bed_type"));
|
||||
}
|
||||
int bed_type_idx = (int)curr_bed_type;
|
||||
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
|
||||
|
@ -739,18 +795,18 @@ void PartPlate::render_icons(bool bottom, int hover_id) const
|
|||
render_icon_texture(position_id, tex_coords_id, m_lock_icon, m_partplate_list->m_lockopen_texture, m_lock_vbo_id);
|
||||
}
|
||||
|
||||
if (m_partplate_list->render_bedtype_setting) {
|
||||
if (m_partplate_list->render_plate_settings) {
|
||||
if (hover_id == 5) {
|
||||
if (get_bed_type(false) == BedType::btDefault)
|
||||
render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_hovered_texture, m_bedtype_vbo_id);
|
||||
if (get_bed_type() == BedType::btDefault && get_print_seq() == PrintSequence::ByDefault)
|
||||
render_icon_texture(position_id, tex_coords_id, m_plate_settings_icon, m_partplate_list->m_plate_settings_hovered_texture, m_plate_settings_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_changed_hovered_texture, m_bedtype_vbo_id);
|
||||
render_icon_texture(position_id, tex_coords_id, m_plate_settings_icon, m_partplate_list->m_plate_settings_changed_hovered_texture, m_plate_settings_vbo_id);
|
||||
}
|
||||
else {
|
||||
if (get_bed_type(false) == BedType::btDefault)
|
||||
render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_texture, m_bedtype_vbo_id);
|
||||
if (get_bed_type() == BedType::btDefault && get_print_seq() == PrintSequence::ByDefault)
|
||||
render_icon_texture(position_id, tex_coords_id, m_plate_settings_icon, m_partplate_list->m_plate_settings_texture, m_plate_settings_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_changed_texture, m_bedtype_vbo_id);
|
||||
render_icon_texture(position_id, tex_coords_id, m_plate_settings_icon, m_partplate_list->m_plate_settings_changed_texture, m_plate_settings_vbo_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1088,8 +1144,8 @@ void PartPlate::on_render_for_picking() const {
|
|||
m_grabber_color[1] = color[1];
|
||||
m_grabber_color[2] = color[2];
|
||||
m_grabber_color[3] = color[3];
|
||||
if (m_partplate_list->render_bedtype_setting)
|
||||
render_rectangle_for_picking(m_bedtype_icon, m_grabber_color);
|
||||
if (m_partplate_list->render_plate_settings)
|
||||
render_rectangle_for_picking(m_plate_settings_icon, m_grabber_color);
|
||||
}
|
||||
|
||||
std::array<float, 4> PartPlate::picking_color_component(int idx) const
|
||||
|
@ -1126,9 +1182,9 @@ void PartPlate::release_opengl_resource()
|
|||
glsafe(::glDeleteBuffers(1, &m_lock_vbo_id));
|
||||
m_lock_vbo_id = 0;
|
||||
}
|
||||
if (m_bedtype_vbo_id > 0) {
|
||||
glsafe(::glDeleteBuffers(1, &m_bedtype_vbo_id));
|
||||
m_bedtype_vbo_id = 0;
|
||||
if (m_plate_settings_vbo_id > 0) {
|
||||
glsafe(::glDeleteBuffers(1, &m_plate_settings_vbo_id));
|
||||
m_plate_settings_vbo_id = 0;
|
||||
}
|
||||
if (m_plate_idx_vbo_id > 0) {
|
||||
glsafe(::glDeleteBuffers(1, &m_plate_idx_vbo_id));
|
||||
|
@ -2003,7 +2059,7 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve
|
|||
calc_vertex_for_icons(1, m_orient_icon);
|
||||
calc_vertex_for_icons(2, m_arrange_icon);
|
||||
calc_vertex_for_icons(3, m_lock_icon);
|
||||
calc_vertex_for_icons(4, m_bedtype_icon);
|
||||
calc_vertex_for_icons(4, m_plate_settings_icon);
|
||||
//calc_vertex_for_number(0, (m_plate_index < 9), m_plate_idx_icon);
|
||||
calc_vertex_for_number(0, false, m_plate_idx_icon);
|
||||
}
|
||||
|
@ -2221,10 +2277,13 @@ int PartPlate::load_gcode_from_file(const std::string& filename)
|
|||
int ret = 0;
|
||||
|
||||
// process gcode
|
||||
m_print->apply(*m_model, wxGetApp().preset_bundle->full_config());
|
||||
DynamicPrintConfig full_config = wxGetApp().preset_bundle->full_config();
|
||||
full_config.apply(m_config, true);
|
||||
m_print->apply(*m_model, full_config);
|
||||
//BBS: need to apply two times, for after the first apply, the m_print got its object,
|
||||
//which will affect the config when new_full_config.normalize_fdm(used_filaments);
|
||||
m_print->apply(*m_model, wxGetApp().preset_bundle->full_config());
|
||||
m_print->apply(*m_model, full_config);
|
||||
|
||||
// BBS: use backup path to save temp gcode
|
||||
// auto path = get_tmp_gcode_path();
|
||||
// if (boost::filesystem::exists(boost::filesystem::path(path))) {
|
||||
|
@ -2522,32 +2581,32 @@ void PartPlateList::generate_icon_textures()
|
|||
|
||||
//if (m_bedtype_texture.get_id() == 0)
|
||||
{
|
||||
file_name = path + (m_is_dark ? "plate_set_bedtype_dark.svg" : "plate_set_bedtype.svg");
|
||||
if (!m_bedtype_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
|
||||
file_name = path + (m_is_dark ? "plate_settings_dark.svg" : "plate_settings.svg");
|
||||
if (!m_plate_settings_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
|
||||
}
|
||||
}
|
||||
|
||||
//if (m_bedtype_changed_texture.get_id() == 0)
|
||||
{
|
||||
file_name = path + (m_is_dark ? "plate_set_bedtype_changed_dark.svg" : "plate_set_bedtype_changed.svg");
|
||||
if (!m_bedtype_changed_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
|
||||
file_name = path + (m_is_dark ? "plate_settings_changed_dark.svg" : "plate_settings_changed.svg");
|
||||
if (!m_plate_settings_changed_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
|
||||
}
|
||||
}
|
||||
|
||||
//if (m_bedtype_hovered_texture.get_id() == 0)
|
||||
{
|
||||
file_name = path + (m_is_dark ? "plate_set_bedtype_hover_dark.svg" : "plate_set_bedtype_hover.svg");
|
||||
if (!m_bedtype_hovered_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
|
||||
file_name = path + (m_is_dark ? "plate_settings_hover_dark.svg" : "plate_settings_hover.svg");
|
||||
if (!m_plate_settings_hovered_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
|
||||
}
|
||||
}
|
||||
|
||||
//if (m_bedtype_changed_hovered_texture.get_id() == 0)
|
||||
{
|
||||
file_name = path + (m_is_dark ? "plate_set_bedtype_changed_hover_dark.svg" : "plate_set_bedtype_changed_hover.svg");
|
||||
if (!m_bedtype_changed_hovered_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
|
||||
file_name = path + (m_is_dark ? "plate_settings_changed_hover_dark.svg" : "plate_settings_changed_hover.svg");
|
||||
if (!m_plate_settings_changed_hovered_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
|
||||
}
|
||||
}
|
||||
|
@ -2608,10 +2667,10 @@ void PartPlateList::release_icon_textures()
|
|||
m_locked_hovered_texture.reset();
|
||||
m_lockopen_texture.reset();
|
||||
m_lockopen_hovered_texture.reset();
|
||||
m_bedtype_texture.reset();
|
||||
m_bedtype_changed_texture.reset();
|
||||
m_bedtype_hovered_texture.reset();
|
||||
m_bedtype_changed_hovered_texture.reset();
|
||||
m_plate_settings_texture.reset();
|
||||
m_plate_settings_texture.reset();
|
||||
m_plate_settings_texture.reset();
|
||||
m_plate_settings_hovered_texture.reset();
|
||||
|
||||
for (int i = 0;i < MAX_PLATE_COUNT; i++) {
|
||||
m_idx_textures[i].reset();
|
||||
|
@ -3919,10 +3978,10 @@ void PartPlateList::render_for_picking_pass()
|
|||
return 0;
|
||||
}*/
|
||||
|
||||
void PartPlateList::set_render_option(bool bedtype_texture, bool bedtype_setting)
|
||||
void PartPlateList::set_render_option(bool bedtype_texture, bool plate_settings)
|
||||
{
|
||||
render_bedtype_logo = bedtype_texture;
|
||||
render_bedtype_setting = bedtype_setting;
|
||||
render_bedtype_logo = bedtype_texture;
|
||||
render_plate_settings = plate_settings;
|
||||
}
|
||||
|
||||
int PartPlateList::select_plate_by_obj(int obj_index, int instance_index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue