mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-19 12:47:50 -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
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "slic3r/Utils/FixModelByWin10.hpp"
|
||||
#include "libslic3r/Format/bbs_3mf.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include "wx/uiaction.h"
|
||||
|
@ -1397,8 +1398,21 @@ void ObjectList::key_event(wxKeyEvent& event)
|
|||
|
||||
void ObjectList::OnBeginDrag(wxDataViewEvent &event)
|
||||
{
|
||||
bool sequential_print = (wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_enum<PrintSequence>("print_sequence") == PrintSequence::ByObject);
|
||||
if (!sequential_print) {
|
||||
int curr_obj_id = m_objects_model->GetIdByItem(event.GetItem());
|
||||
PartPlateList& partplate_list = wxGetApp().plater()->get_partplate_list();
|
||||
int from_plate = partplate_list.find_instance(curr_obj_id, 0);
|
||||
if (from_plate == -1) {
|
||||
event.Veto();
|
||||
return;
|
||||
}
|
||||
auto curr_plate_seq = partplate_list.get_plate(from_plate)->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;
|
||||
}
|
||||
|
||||
if (curr_plate_seq != PrintSequence::ByObject) {
|
||||
//drag forbidden under bylayer mode
|
||||
event.Veto();
|
||||
return;
|
||||
|
|
|
@ -582,7 +582,9 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
|
|||
m_layers_slider->SetSelectionSpan(idx_low, idx_high);
|
||||
m_layers_slider->SetTicksValues(ticks_info_from_model);
|
||||
|
||||
bool sequential_print = (wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_enum<PrintSequence>("print_sequence") == PrintSequence::ByObject);
|
||||
auto curr_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate();
|
||||
auto curr_print_seq = curr_plate->get_real_print_seq();
|
||||
bool sequential_print = (curr_print_seq == PrintSequence::ByObject);
|
||||
m_layers_slider->SetDrawMode(sequential_print);
|
||||
|
||||
auto print_mode_stat = m_gcode_result->print_statistics.modes.front();
|
||||
|
|
|
@ -597,8 +597,10 @@ void IMSlider::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model,
|
|||
|
||||
UseDefaultColors(m_mode == SingleExtruder);
|
||||
|
||||
DynamicPrintConfig config = wxGetApp().preset_bundle->full_config();
|
||||
if (config.opt_enum<PrintSequence>("print_sequence") == PrintSequence::ByObject)
|
||||
auto curr_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate();
|
||||
auto curr_print_seq = curr_plate->get_real_print_seq();
|
||||
|
||||
if (curr_print_seq == PrintSequence::ByObject)
|
||||
m_is_wipe_tower = false;
|
||||
else
|
||||
m_is_wipe_tower = m_mode != SingleExtruder;
|
||||
|
|
|
@ -335,6 +335,7 @@ void ArrangeJob::prepare_partplate() {
|
|||
return;
|
||||
}
|
||||
|
||||
params.is_seq_print = plate->get_real_print_seq() == PrintSequence::ByObject;
|
||||
Model& model = m_plater->model();
|
||||
|
||||
// Go through the objects and check if inside the selection
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -133,15 +133,12 @@ private:
|
|||
mutable unsigned int m_orient_vbo_id{ 0 };
|
||||
GeometryBuffer m_lock_icon;
|
||||
mutable unsigned int m_lock_vbo_id{ 0 };
|
||||
GeometryBuffer m_bedtype_icon;
|
||||
mutable unsigned int m_bedtype_vbo_id{ 0 };
|
||||
GeometryBuffer m_plate_settings_icon;
|
||||
mutable unsigned int m_plate_settings_vbo_id{ 0 };
|
||||
GeometryBuffer m_plate_idx_icon;
|
||||
mutable unsigned int m_plate_idx_vbo_id{ 0 };
|
||||
GLTexture m_texture;
|
||||
|
||||
// plate render option
|
||||
bool is_same_bedtype_with_global = true;
|
||||
|
||||
mutable float m_grabber_color[4];
|
||||
float m_scale_factor{ 1.0f };
|
||||
GLUquadricObject* m_quadric;
|
||||
|
@ -213,11 +210,21 @@ public:
|
|||
//clear alll the instances in plate
|
||||
void clear(bool clear_sliced_result = true);
|
||||
|
||||
BedType get_bed_type(bool check_global = true) const;
|
||||
BedType get_bed_type() const;
|
||||
void set_bed_type(BedType bed_type);
|
||||
void reset_bed_type();
|
||||
DynamicPrintConfig* config() { return &m_config; }
|
||||
|
||||
// set print sequence per plate
|
||||
//bool print_seq_same_global = true;
|
||||
void set_print_seq(PrintSequence print_seq = PrintSequence::ByDefault);
|
||||
PrintSequence get_print_seq() const;
|
||||
// Get the real effective print sequence of current plate.
|
||||
// If curr_plate's print_seq is ByDefault, use the global sequence
|
||||
// @return PrintSequence::{ByLayer,ByObject}
|
||||
PrintSequence get_real_print_seq() const;
|
||||
|
||||
|
||||
//static const int plate_x_offset = 20; //mm
|
||||
//static const double plate_x_gap = 0.2;
|
||||
ThumbnailData thumbnail_data;
|
||||
|
@ -484,14 +491,14 @@ class PartPlateList : public ObjectBase
|
|||
GLTexture m_locked_hovered_texture;
|
||||
GLTexture m_lockopen_texture;
|
||||
GLTexture m_lockopen_hovered_texture;
|
||||
GLTexture m_bedtype_texture;
|
||||
GLTexture m_bedtype_changed_texture;
|
||||
GLTexture m_bedtype_hovered_texture;
|
||||
GLTexture m_bedtype_changed_hovered_texture;
|
||||
GLTexture m_plate_settings_texture;
|
||||
GLTexture m_plate_settings_changed_texture;
|
||||
GLTexture m_plate_settings_hovered_texture;
|
||||
GLTexture m_plate_settings_changed_hovered_texture;
|
||||
GLTexture m_idx_textures[MAX_PLATE_COUNT];
|
||||
// set render option
|
||||
bool render_bedtype_logo = true;
|
||||
bool render_bedtype_setting = true;
|
||||
bool render_plate_settings = true;
|
||||
|
||||
bool m_is_dark = false;
|
||||
|
||||
|
@ -685,7 +692,7 @@ public:
|
|||
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_for_picking_pass();
|
||||
void set_render_option(bool bedtype_texture, bool bedtype_settings);
|
||||
void set_render_option(bool bedtype_texture, bool plate_settings);
|
||||
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);
|
||||
|
|
158
src/slic3r/GUI/PlateSettingsDialog.cpp
Normal file
158
src/slic3r/GUI/PlateSettingsDialog.cpp
Normal file
|
@ -0,0 +1,158 @@
|
|||
#include "PlateSettingsDialog.hpp"
|
||||
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_SET_BED_TYPE_CONFIRM, wxCommandEvent);
|
||||
|
||||
PlateSettingsDialog::PlateSettingsDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
|
||||
:DPIDialog(parent, id, title, pos, size, style)
|
||||
{
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(400), -1));
|
||||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
|
||||
|
||||
wxFlexGridSizer* top_sizer = new wxFlexGridSizer(0, 2, FromDIP(5), 0);
|
||||
top_sizer->AddGrowableCol(0,1);
|
||||
top_sizer->SetFlexibleDirection(wxBOTH);
|
||||
top_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
||||
|
||||
m_bed_type_choice = new ComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(240),-1), 0, NULL, wxCB_READONLY );
|
||||
for (BedType i = btDefault; i < btCount; i = BedType(int(i) + 1)) {
|
||||
m_bed_type_choice->Append(to_bed_type_name(i));
|
||||
}
|
||||
wxStaticText* m_bed_type_txt = new wxStaticText(this, wxID_ANY, _L("Bed type"));
|
||||
m_bed_type_txt->SetFont(Label::Body_14);
|
||||
top_sizer->Add(m_bed_type_txt, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, FromDIP(5));
|
||||
top_sizer->Add(m_bed_type_choice, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT |wxALL, FromDIP(5));
|
||||
|
||||
wxBoxSizer* m_sizer_selectbox = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_print_seq_choice = new ComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(240),-1), 0, NULL, wxCB_READONLY );
|
||||
m_print_seq_choice->Append(_L("Same as Global Print Sequence"));
|
||||
for (auto i = PrintSequence::ByLayer; i < PrintSequence::ByDefault; i = PrintSequence(int(i) + 1)) {
|
||||
m_print_seq_choice->Append(to_print_sequence_name(i));
|
||||
}
|
||||
wxStaticText* m_print_seq_txt = new wxStaticText(this, wxID_ANY, _L("Print sequence"));
|
||||
m_print_seq_txt->SetFont(Label::Body_14);
|
||||
top_sizer->Add(m_print_seq_txt, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT |wxALL, FromDIP(5));
|
||||
top_sizer->Add(m_print_seq_choice, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT |wxALL, FromDIP(5));
|
||||
|
||||
m_sizer_main->Add(top_sizer, 0, wxEXPAND | wxALL, FromDIP(30));
|
||||
|
||||
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
|
||||
|
||||
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
|
||||
|
||||
m_button_ok = new Button(this, _L("OK"));
|
||||
m_button_ok->SetBackgroundColor(btn_bg_green);
|
||||
m_button_ok->SetBorderColor(*wxWHITE);
|
||||
m_button_ok->SetTextColor(wxColour("#FFFFFE"));
|
||||
m_button_ok->SetFont(Label::Body_12);
|
||||
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_ok->SetCornerRadius(FromDIP(12));
|
||||
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
wxCommandEvent evt(EVT_SET_BED_TYPE_CONFIRM, GetId());
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
if (this->IsModal())
|
||||
EndModal(wxID_YES);
|
||||
else
|
||||
this->Close();
|
||||
});
|
||||
|
||||
m_button_cancel = new Button(this, _L("Cancel"));
|
||||
m_button_cancel->SetBackgroundColor(btn_bg_white);
|
||||
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
|
||||
m_button_cancel->SetFont(Label::Body_12);
|
||||
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetCornerRadius(FromDIP(12));
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
if (this->IsModal())
|
||||
EndModal(wxID_NO);
|
||||
else
|
||||
this->Close();
|
||||
});
|
||||
|
||||
sizer_button->AddStretchSpacer();
|
||||
sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
|
||||
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
|
||||
sizer_button->Add(FromDIP(30),0, 0, 0);
|
||||
|
||||
m_sizer_main->Add(sizer_button, 0, wxEXPAND, FromDIP(20));
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
Layout();
|
||||
m_sizer_main->Fit(this);
|
||||
|
||||
CenterOnParent();
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
PlateSettingsDialog::~PlateSettingsDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PlateSettingsDialog::sync_bed_type(BedType type)
|
||||
{
|
||||
if (m_bed_type_choice != nullptr) {
|
||||
m_bed_type_choice->SetSelection(int(type));
|
||||
}
|
||||
}
|
||||
|
||||
void PlateSettingsDialog::sync_print_seq(int print_seq)
|
||||
{
|
||||
if (m_print_seq_choice != nullptr) {
|
||||
m_print_seq_choice->SetSelection(print_seq);
|
||||
}
|
||||
}
|
||||
|
||||
wxString PlateSettingsDialog::to_bed_type_name(BedType bed_type) {
|
||||
switch (bed_type) {
|
||||
case btDefault:
|
||||
return _L("Same as Global Bed Type");
|
||||
case btPC:
|
||||
return _L("Cool Plate");
|
||||
case btEP:
|
||||
return _L("Engineering Plate");
|
||||
case btPEI:
|
||||
return _L("High Temp Plate");
|
||||
case btPTE:
|
||||
return _L("Textured PEI Plate");
|
||||
default:
|
||||
return _L("Same as Global Bed Type");
|
||||
}
|
||||
return _L("Same as Global Bed Type");
|
||||
}
|
||||
|
||||
wxString PlateSettingsDialog::to_print_sequence_name(PrintSequence print_seq) {
|
||||
switch (print_seq) {
|
||||
case PrintSequence::ByLayer:
|
||||
return _L("By Layer");
|
||||
case PrintSequence::ByObject:
|
||||
return _L("By Object");
|
||||
default:
|
||||
return _L("By Layer");
|
||||
}
|
||||
return _L("By Layer");
|
||||
}
|
||||
|
||||
void PlateSettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
m_button_ok->Rescale();
|
||||
m_button_cancel->Rescale();
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
61
src/slic3r/GUI/PlateSettingsDialog.hpp
Normal file
61
src/slic3r/GUI/PlateSettingsDialog.hpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#ifndef slic3r_GUI_PlateSettingsDialog_hpp_
|
||||
#define slic3r_GUI_PlateSettingsDialog_hpp_
|
||||
|
||||
#include "Plater.hpp"
|
||||
#include "PartPlate.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/RadioBox.hpp"
|
||||
#include "Widgets/ComboBox.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDECLARE_EVENT(EVT_SET_BED_TYPE_CONFIRM, wxCommandEvent);
|
||||
|
||||
class PlateSettingsDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
enum ButtonStyle {
|
||||
ONLY_CONFIRM = 0,
|
||||
CONFIRM_AND_CANCEL = 1,
|
||||
MAX_STYLE_NUM = 2
|
||||
};
|
||||
PlateSettingsDialog(
|
||||
wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxString& title = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxCLOSE_BOX | wxCAPTION
|
||||
);
|
||||
|
||||
~PlateSettingsDialog();
|
||||
void sync_bed_type(BedType type);
|
||||
void sync_print_seq(int print_seq = 0);
|
||||
wxString to_bed_type_name(BedType bed_type);
|
||||
wxString to_print_sequence_name(PrintSequence print_seq);
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
|
||||
int get_print_seq_choice() {
|
||||
int choice = 0;
|
||||
if (m_print_seq_choice != nullptr)
|
||||
choice = m_print_seq_choice->GetSelection();
|
||||
return choice;
|
||||
};
|
||||
|
||||
int get_bed_type_choice() {
|
||||
int choice = 0;
|
||||
if (m_bed_type_choice != nullptr)
|
||||
choice = m_bed_type_choice->GetSelection();
|
||||
return choice;
|
||||
};
|
||||
|
||||
protected:
|
||||
ComboBox* m_print_seq_choice { nullptr };
|
||||
ComboBox* m_bed_type_choice { nullptr };
|
||||
Button* m_button_ok;
|
||||
Button* m_button_cancel;
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif
|
|
@ -128,7 +128,7 @@
|
|||
|
||||
#include "PhysicalPrinterDialog.hpp"
|
||||
#include "PrintHostDialogs.hpp"
|
||||
#include "SetBedTypeDialog.hpp"
|
||||
#include "PlateSettingsDialog.hpp"
|
||||
|
||||
using boost::optional;
|
||||
namespace fs = boost::filesystem;
|
||||
|
@ -5487,7 +5487,7 @@ void Plater::priv::on_select_bed_type(wxCommandEvent &evt)
|
|||
//update slice status
|
||||
auto plate_list = partplate_list.get_plate_list();
|
||||
for (auto plate : plate_list) {
|
||||
if (plate->get_bed_type(false) == btDefault) {
|
||||
if (plate->get_bed_type() == btDefault) {
|
||||
plate->update_slice_result_valid_state(false);
|
||||
}
|
||||
}
|
||||
|
@ -5570,12 +5570,9 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
Slic3r::put_other_changes();
|
||||
|
||||
// update slice state and set bedtype default for 3rd-party printer
|
||||
bool is_bbl_vendor_preset = wxGetApp().preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(wxGetApp().preset_bundle);
|
||||
auto plate_list = partplate_list.get_plate_list();
|
||||
for (auto plate : plate_list) {
|
||||
plate->update_slice_result_valid_state(false);
|
||||
if (!is_bbl_vendor_preset)
|
||||
plate->set_bed_type(btDefault);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6415,7 +6412,9 @@ PlateBBoxData Plater::priv::generate_first_layer_bbox()
|
|||
std::vector<BBoxData>& id_bboxes = bboxdata.bbox_objs;
|
||||
BoundingBoxf bbox_all;
|
||||
auto print = this->background_process.m_fff_print;
|
||||
bboxdata.is_seq_print = (print->config().print_sequence == PrintSequence::ByObject);
|
||||
auto curr_plate = this->partplate_list.get_curr_plate();
|
||||
auto curr_plate_seq = curr_plate->get_real_print_seq();
|
||||
bboxdata.is_seq_print = (curr_plate_seq == PrintSequence::ByObject);
|
||||
bboxdata.first_extruder = print->get_tool_ordering().first_extruder();
|
||||
bboxdata.bed_type = bed_type_to_gcode_string(print->config().curr_bed_type.value);
|
||||
// get nozzle diameter
|
||||
|
@ -10071,6 +10070,24 @@ bool Plater::update_filament_colors_in_full_config()
|
|||
return true;
|
||||
}
|
||||
|
||||
void Plater::config_change_notification(const DynamicPrintConfig &config, const std::string& key)
|
||||
{
|
||||
GLCanvas3D* view3d_canvas = get_view3D_canvas3D();
|
||||
if (key == std::string("print_sequence")) {
|
||||
auto seq_print = config.option<ConfigOptionEnum<PrintSequence>>("print_sequence");
|
||||
if (seq_print && view3d_canvas && view3d_canvas->is_initialized() && view3d_canvas->is_rendering_enabled()) {
|
||||
NotificationManager* notify_manager = get_notification_manager();
|
||||
if (seq_print->value == PrintSequence::ByObject) {
|
||||
std::string info_text = _u8L("Print By Object: \nSuggest to use auto-arrange to avoid collisions when printing.");
|
||||
notify_manager->bbl_show_seqprintinfo_notification(info_text);
|
||||
}
|
||||
else
|
||||
notify_manager->bbl_close_seqprintinfo_notification();
|
||||
}
|
||||
}
|
||||
// notification for more options
|
||||
}
|
||||
|
||||
void Plater::on_config_change(const DynamicPrintConfig &config)
|
||||
{
|
||||
bool update_scheduled = false;
|
||||
|
@ -10148,20 +10165,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
|
|||
if (bed_shape_changed)
|
||||
set_bed_shape();
|
||||
|
||||
GLCanvas3D* view3d_canvas = get_view3D_canvas3D();
|
||||
auto seq_print = config.option<ConfigOptionEnum<PrintSequence>>("print_sequence");
|
||||
if ( seq_print && view3d_canvas && view3d_canvas->is_initialized() && view3d_canvas->is_rendering_enabled() ) {
|
||||
NotificationManager *notify_manager = get_notification_manager();
|
||||
if (seq_print->value == PrintSequence::ByObject) {
|
||||
std::string info_text = _u8L("Print By Object: \nSuggest to use auto-arrange to avoid collisions when printing.");
|
||||
notify_manager->bbl_show_seqprintinfo_notification(info_text);
|
||||
//always show label when switch to sequence print
|
||||
//if (print_sequence_changed)
|
||||
// this->show_view3D_labels(true);
|
||||
}
|
||||
else
|
||||
notify_manager->bbl_close_seqprintinfo_notification();
|
||||
}
|
||||
config_change_notification(config, std::string("print_sequence"));
|
||||
|
||||
if (update_scheduled)
|
||||
update();
|
||||
|
@ -11034,18 +11038,38 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click)
|
|||
//set the plate type
|
||||
ret = select_plate(plate_index);
|
||||
if (!ret) {
|
||||
SetBedTypeDialog dlg(this, wxID_ANY, _L("Select Bed Type"));
|
||||
PlateSettingsDialog dlg(this, wxID_ANY, _L("Plate Settings"));
|
||||
PartPlate* curr_plate = p->partplate_list.get_curr_plate();
|
||||
dlg.sync_bed_type(curr_plate->get_bed_type(false));
|
||||
dlg.Bind(EVT_SET_BED_TYPE_CONFIRM, [this, plate_index](wxCommandEvent& e) {
|
||||
dlg.sync_bed_type(curr_plate->get_bed_type());
|
||||
|
||||
auto curr_print_seq = curr_plate->get_print_seq();
|
||||
if (curr_print_seq != PrintSequence::ByDefault) {
|
||||
dlg.sync_print_seq(int(curr_print_seq) + 1);
|
||||
}
|
||||
else
|
||||
dlg.sync_print_seq(0);
|
||||
|
||||
dlg.Bind(EVT_SET_BED_TYPE_CONFIRM, [this, plate_index, &dlg](wxCommandEvent& e) {
|
||||
PartPlate *curr_plate = p->partplate_list.get_curr_plate();
|
||||
BedType old_bed_type = curr_plate->get_bed_type(false);
|
||||
auto type = (BedType)(e.GetInt());
|
||||
if (old_bed_type != type) {
|
||||
curr_plate->set_bed_type(type);
|
||||
BedType old_bed_type = curr_plate->get_bed_type();
|
||||
auto bt_sel = BedType(dlg.get_bed_type_choice());
|
||||
if (old_bed_type != bt_sel) {
|
||||
curr_plate->set_bed_type(bt_sel);
|
||||
update_project_dirty_from_presets();
|
||||
set_plater_dirty(true);
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("select bed type %1% for plate %2% at plate side")%type %plate_index;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("select bed type %1% for plate %2% at plate side")%bt_sel %plate_index;
|
||||
|
||||
int ps_sel = dlg.get_print_seq_choice();
|
||||
if (ps_sel != 0)
|
||||
curr_plate->set_print_seq(PrintSequence(ps_sel - 1));
|
||||
else
|
||||
curr_plate->set_print_seq(PrintSequence::ByDefault);
|
||||
update_project_dirty_from_presets();
|
||||
set_plater_dirty(true);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("select print sequence %1% for plate %2% at plate side")%ps_sel %plate_index;
|
||||
auto plate_config = *(curr_plate->config());
|
||||
wxGetApp().plater()->config_change_notification(plate_config, std::string("print_sequence"));
|
||||
});
|
||||
dlg.ShowModal();
|
||||
|
||||
|
|
|
@ -381,6 +381,7 @@ public:
|
|||
// BBS
|
||||
void on_bed_type_change(BedType bed_type);
|
||||
bool update_filament_colors_in_full_config();
|
||||
void config_change_notification(const DynamicPrintConfig &config, const std::string& key);
|
||||
void on_config_change(const DynamicPrintConfig &config);
|
||||
void force_filament_colors_update();
|
||||
void force_print_bed_update();
|
||||
|
|
|
@ -1,154 +0,0 @@
|
|||
#include "SetBedTypeDialog.hpp"
|
||||
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_SET_BED_TYPE_CONFIRM, wxCommandEvent);
|
||||
|
||||
SetBedTypeDialog::SetBedTypeDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
|
||||
:DPIDialog(parent, id, title, pos, size, style)
|
||||
{
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(300), -1));
|
||||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
|
||||
|
||||
wxBoxSizer* m_sizer_radiobutton = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_rb_default_plate = create_item_radiobox(_L("Same as Global Bed Type"), this, wxEmptyString, FromDIP(5), btDefault);
|
||||
m_sizer_radiobutton->Add(m_rb_default_plate->GetParent(), 1, wxALL, FromDIP(5));
|
||||
m_rb_cool_plate = create_item_radiobox(_L("Cool Plate"), this, wxEmptyString, FromDIP(5), btPC);
|
||||
m_sizer_radiobutton->Add(m_rb_cool_plate->GetParent(), 1, wxALL, FromDIP(5));
|
||||
m_rb_eng_plate = create_item_radiobox(_L("Engineering Plate"), this, wxEmptyString, FromDIP(5), btEP);
|
||||
m_sizer_radiobutton->Add(m_rb_eng_plate->GetParent(), 1, wxALL, FromDIP(5) );
|
||||
m_rb_high_temp_plate = create_item_radiobox(_L("High Temp Plate"), this, wxEmptyString, FromDIP(5), btPEI);
|
||||
m_sizer_radiobutton->Add(m_rb_high_temp_plate->GetParent(), 1, wxALL, FromDIP(5));
|
||||
m_rb_texture_pei_plate = create_item_radiobox(_L("Textured PEI Plate"), this, wxEmptyString, FromDIP(5), btPTE);
|
||||
m_sizer_radiobutton->Add(m_rb_texture_pei_plate->GetParent(), 1, wxALL, FromDIP(5));
|
||||
|
||||
m_sizer_main->Add(m_sizer_radiobutton, 0, wxEXPAND | wxALL, FromDIP(10));
|
||||
|
||||
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
|
||||
|
||||
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
|
||||
|
||||
m_button_ok = new Button(this, _L("OK"));
|
||||
m_button_ok->SetBackgroundColor(btn_bg_green);
|
||||
m_button_ok->SetBorderColor(*wxWHITE);
|
||||
m_button_ok->SetTextColor(wxColour("#FFFFFE"));
|
||||
m_button_ok->SetFont(Label::Body_12);
|
||||
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_ok->SetCornerRadius(FromDIP(12));
|
||||
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
int len = radio_buttons.size();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (radio_buttons[i]->GetValue()) {
|
||||
wxCommandEvent evt(EVT_SET_BED_TYPE_CONFIRM, GetId());
|
||||
evt.SetInt(radio_buttons[i]->GetBedType());
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this->IsModal())
|
||||
EndModal(wxID_YES);
|
||||
else
|
||||
this->Close();
|
||||
});
|
||||
|
||||
m_button_cancel = new Button(this, _L("Cancel"));
|
||||
m_button_cancel->SetBackgroundColor(btn_bg_white);
|
||||
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
|
||||
m_button_cancel->SetFont(Label::Body_12);
|
||||
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetCornerRadius(FromDIP(12));
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
if (this->IsModal())
|
||||
EndModal(wxID_NO);
|
||||
else
|
||||
this->Close();
|
||||
});
|
||||
|
||||
sizer_button->AddStretchSpacer();
|
||||
sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
|
||||
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
|
||||
|
||||
m_sizer_main->Add(sizer_button, 0, wxEXPAND, FromDIP(20));
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
Layout();
|
||||
m_sizer_main->Fit(this);
|
||||
|
||||
CenterOnParent();
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
SetBedTypeDialog::~SetBedTypeDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BedTypeRadioBox* SetBedTypeDialog::create_item_radiobox(wxString title, wxWindow* parent, wxString tooltip, int padding_left, BedType bed_type)
|
||||
{
|
||||
wxWindow *item = new wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(-1, FromDIP(28)));
|
||||
item->SetBackgroundColour(*wxWHITE);
|
||||
|
||||
BedTypeRadioBox* radiobox = new BedTypeRadioBox(item, bed_type);
|
||||
radiobox->SetPosition(wxPoint(padding_left, (item->GetSize().GetHeight() - radiobox->GetSize().GetHeight()) / 2));
|
||||
radio_buttons.push_back(radiobox);
|
||||
int btn_idx = radio_buttons.size() - 1;
|
||||
radiobox->Bind(wxEVT_LEFT_DOWN, [this, btn_idx](wxMouseEvent &e) {
|
||||
SetBedTypeDialog::select_curr_radiobox(btn_idx);
|
||||
});
|
||||
|
||||
wxStaticText *text = new wxStaticText(item, wxID_ANY, title, wxDefaultPosition, wxDefaultSize);
|
||||
text->SetPosition(wxPoint(padding_left + radiobox->GetSize().GetWidth() + 10, (item->GetSize().GetHeight() - text->GetSize().GetHeight()) / 2));
|
||||
text->SetFont(Label::Body_14);
|
||||
text->SetForegroundColour(0x686868);
|
||||
text->Bind(wxEVT_LEFT_DOWN, [this, btn_idx](wxMouseEvent &e) {
|
||||
SetBedTypeDialog::select_curr_radiobox(btn_idx);
|
||||
});
|
||||
|
||||
radiobox->SetToolTip(tooltip);
|
||||
text->SetToolTip(tooltip);
|
||||
return radiobox;
|
||||
}
|
||||
|
||||
void SetBedTypeDialog::select_curr_radiobox(int btn_idx)
|
||||
{
|
||||
int len = radio_buttons.size();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (i == btn_idx)
|
||||
radio_buttons[i]->SetValue(true);
|
||||
else
|
||||
radio_buttons[i]->SetValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SetBedTypeDialog::sync_bed_type(BedType type)
|
||||
{
|
||||
for (auto radio_box : radio_buttons) {
|
||||
if (radio_box->GetBedType() == type)
|
||||
radio_box->SetValue(true);
|
||||
else
|
||||
radio_box->SetValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SetBedTypeDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
|
@ -1,62 +0,0 @@
|
|||
#ifndef slic3r_GUI_SetBedTypeDialog_hpp_
|
||||
#define slic3r_GUI_SetBedTypeDialog_hpp_
|
||||
|
||||
#include "Plater.hpp"
|
||||
#include "PartPlate.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/RadioBox.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDECLARE_EVENT(EVT_SET_BED_TYPE_CONFIRM, wxCommandEvent);
|
||||
|
||||
class BedTypeRadioBox : public RadioBox
|
||||
{
|
||||
public:
|
||||
BedTypeRadioBox(wxWindow* parent, BedType bed_type) : RadioBox(parent), m_bed_type(bed_type) {}
|
||||
|
||||
void SetBedType(BedType bed_type) { m_bed_type = bed_type; }
|
||||
BedType GetBedType() { return m_bed_type; }
|
||||
|
||||
private:
|
||||
BedType m_bed_type{ BedType::btCount };
|
||||
};
|
||||
|
||||
class SetBedTypeDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
enum ButtonStyle {
|
||||
ONLY_CONFIRM = 0,
|
||||
CONFIRM_AND_CANCEL = 1,
|
||||
MAX_STYLE_NUM = 2
|
||||
};
|
||||
SetBedTypeDialog(
|
||||
wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxString& title = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxCLOSE_BOX | wxCAPTION
|
||||
);
|
||||
|
||||
~SetBedTypeDialog();
|
||||
void sync_bed_type(BedType type);
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
|
||||
protected:
|
||||
BedTypeRadioBox* m_rb_default_plate{ nullptr };
|
||||
BedTypeRadioBox* m_rb_cool_plate{ nullptr };
|
||||
BedTypeRadioBox* m_rb_eng_plate{ nullptr };
|
||||
BedTypeRadioBox* m_rb_high_temp_plate{ nullptr };
|
||||
BedTypeRadioBox* m_rb_texture_pei_plate{ nullptr };
|
||||
Button* m_button_ok;
|
||||
Button* m_button_cancel;
|
||||
std::vector<BedTypeRadioBox*> radio_buttons;
|
||||
|
||||
BedTypeRadioBox* create_item_radiobox(wxString title, wxWindow* parent, wxString tooltip, int padding_left, BedType bed_type);
|
||||
void select_curr_radiobox(int btn_idx);
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue