mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
New feature: plate name
This commit is contained in:
parent
b243bac282
commit
f5c4cc9a54
15 changed files with 254 additions and 113 deletions
|
@ -249,6 +249,7 @@ static constexpr const char* OBJECT_ID_ATTR = "object_id";
|
|||
static constexpr const char* INSTANCEID_ATTR = "instance_id";
|
||||
static constexpr const char* ARRANGE_ORDER_ATTR = "arrange_order";
|
||||
static constexpr const char* PLATERID_ATTR = "plater_id";
|
||||
static constexpr const char* PLATER_NAME_ATTR = "plater_name";
|
||||
static constexpr const char* PLATE_IDX_ATTR = "index";
|
||||
static constexpr const char* SLICE_PREDICTION_ATTR = "prediction";
|
||||
static constexpr const char* SLICE_WEIGHT_ATTR = "weight";
|
||||
|
@ -1765,6 +1766,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
}
|
||||
plate_data_list[it->first-1]->locked = it->second->locked;
|
||||
plate_data_list[it->first-1]->plate_index = it->second->plate_index-1;
|
||||
plate_data_list[it->first-1]->plate_name = it->second->plate_name;
|
||||
plate_data_list[it->first-1]->obj_inst_map = it->second->obj_inst_map;
|
||||
plate_data_list[it->first-1]->gcode_file = (m_load_restore || it->second->gcode_file.empty()) ? it->second->gcode_file : m_backup_path + "/" + it->second->gcode_file;
|
||||
plate_data_list[it->first-1]->gcode_prediction = it->second->gcode_prediction;
|
||||
|
@ -3467,6 +3469,10 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
{
|
||||
m_curr_plater->plate_index = atoi(value.c_str());
|
||||
}
|
||||
else if(key == PLATER_NAME_ATTR)
|
||||
{
|
||||
m_curr_plater->plate_name = value;
|
||||
}
|
||||
else if (key == LOCK_ATTR)
|
||||
{
|
||||
std::istringstream(value) >> std::boolalpha >> m_curr_plater->locked;
|
||||
|
@ -6431,6 +6437,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
stream << " <" << PLATE_TAG << ">\n";
|
||||
//plate index
|
||||
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATERID_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->plate_index + 1 << "\"/>\n";
|
||||
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATER_NAME_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->plate_name << "\"/>\n";
|
||||
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << LOCK_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->locked<< "\"/>\n";
|
||||
ConfigOption* bed_type_opt = plate_data->config.option("curr_bed_type");
|
||||
t_config_enum_names bed_type_names = ConfigOptionEnum<BedType>::get_enum_names();
|
||||
|
|
|
@ -70,6 +70,7 @@ struct PlateData
|
|||
std::string pattern_bbox_file;
|
||||
std::string gcode_prediction;
|
||||
std::string gcode_weight;
|
||||
std::string plate_name;
|
||||
std::vector<FilamentInfo> slice_filaments_info;
|
||||
DynamicPrintConfig config;
|
||||
bool is_support_used {false};
|
||||
|
|
|
@ -1758,6 +1758,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
m_placeholder_parser.set("first_layer_temperature", new ConfigOptionInts(m_config.nozzle_temperature_initial_layer));
|
||||
m_placeholder_parser.set("max_print_height",new ConfigOptionInt(m_config.printable_height));
|
||||
m_placeholder_parser.set("z_offset", new ConfigOptionFloat(0.0f));
|
||||
m_placeholder_parser.set("plate_name", new ConfigOptionString(print.get_plate_name()));
|
||||
|
||||
//BBS: calculate the volumetric speed of outer wall. Ignore pre-object setting and multi-filament, and just use the default setting
|
||||
{
|
||||
|
|
|
@ -2152,6 +2152,8 @@ std::string Print::output_filename(const std::string &filename_base) const
|
|||
// These values will be just propagated into the output file name.
|
||||
DynamicConfig config = this->finished() ? this->print_statistics().config() : this->print_statistics().placeholders();
|
||||
config.set_key_value("num_filaments", new ConfigOptionInt((int)m_config.nozzle_diameter.size()));
|
||||
config.set_key_value("plate_name", new ConfigOptionString(get_plate_name()));
|
||||
|
||||
return this->PrintBase::output_filename(m_config.filename_format.value, ".gcode", filename_base, &config);
|
||||
}
|
||||
|
||||
|
|
|
@ -511,6 +511,9 @@ public:
|
|||
int get_plate_index() const { return m_plate_index; }
|
||||
void set_plate_index(int index) { m_plate_index = index; }
|
||||
|
||||
//SoftFever plate name
|
||||
std::string get_plate_name() const { return m_plate_name; }
|
||||
void set_plate_name(const std::string& name) { m_plate_name = name; }
|
||||
protected:
|
||||
friend class PrintObjectBase;
|
||||
friend class BackgroundSlicingProcess;
|
||||
|
@ -545,6 +548,9 @@ protected:
|
|||
//BBS: add plate id into print base
|
||||
int m_plate_index{ 0 };
|
||||
|
||||
// SoftFever: current plate name
|
||||
std::string m_plate_name;
|
||||
|
||||
// Callback to be evoked regularly to update state of the UI thread.
|
||||
status_callback_type m_status_callback;
|
||||
|
||||
|
|
|
@ -516,11 +516,9 @@ bool GLTexture::generate_from_text(const std::string &text_str, wxFont &font, wx
|
|||
// prepare buffer
|
||||
std::vector<unsigned char> data(4 * m_width * m_height, 0);
|
||||
const unsigned char* src = image.GetData();
|
||||
/* for debug use
|
||||
std::ofstream fout;
|
||||
fout.open(text_str+std::to_string(m_width)+"_"+std::to_string(m_height)+".rgb", std::ios::out);
|
||||
fout.write((const char*)src, 3 * m_width * m_height);
|
||||
fout.close();*/
|
||||
//for debug use
|
||||
//image.SaveFile(text_str+"_test.png", wxBITMAP_TYPE_PNG);
|
||||
|
||||
for (int h = 0; h < m_height; ++h) {
|
||||
unsigned char* dst = data.data() + 4 * h * m_width;
|
||||
for (int w = 0; w < m_width; ++w) {
|
||||
|
|
|
@ -74,7 +74,44 @@ std::array<float, 4> PartPlate::LINE_BOTTOM_COLOR = { 0.8f, 0.8f, 0.8f, 0.4f };
|
|||
std::array<float, 4> PartPlate::HEIGHT_LIMIT_TOP_COLOR = { 0.6f, 0.6f, 1.0f, 1.0f };
|
||||
std::array<float, 4> PartPlate::HEIGHT_LIMIT_BOTTOM_COLOR = { 0.4f, 0.4f, 1.0f, 1.0f };
|
||||
|
||||
// get text extent with wxMemoryDC
|
||||
void get_text_extent(const wxString &msg, wxCoord &w, wxCoord &h, wxFont *font)
|
||||
{
|
||||
wxMemoryDC memDC;
|
||||
if (font)
|
||||
memDC.SetFont(*font);
|
||||
memDC.GetTextExtent(msg, &w, &h);
|
||||
}
|
||||
|
||||
|
||||
wxFont* find_font(const std::string& text_str, int max_size = 32)
|
||||
{
|
||||
auto is_font_suitable = [](std::string str, wxFont &font, int max_size) {
|
||||
wxString msg(str);
|
||||
wxCoord w, h;
|
||||
get_text_extent(msg, w, h, &font);
|
||||
|
||||
if (w <= max_size)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
};
|
||||
wxFont *font = nullptr;
|
||||
if (is_font_suitable(text_str, Label::Head_24, max_size))
|
||||
font = &Label::Head_24;
|
||||
else if (is_font_suitable(text_str, Label::Head_20, max_size))
|
||||
font = &Label::Head_20;
|
||||
else if (is_font_suitable(text_str, Label::Head_18, max_size))
|
||||
font = &Label::Head_18;
|
||||
else if (is_font_suitable(text_str, Label::Head_16, max_size))
|
||||
font = &Label::Head_16;
|
||||
else if (is_font_suitable(text_str, Label::Head_14, max_size))
|
||||
font = &Label::Head_14;
|
||||
else
|
||||
font = &Label::Head_12;
|
||||
|
||||
return font;
|
||||
}
|
||||
void PartPlate::update_render_colors()
|
||||
{
|
||||
PartPlate::SELECT_COLOR = GLColor(RenderColor::colors[RenderCol_Plate_Selected]);
|
||||
|
@ -131,6 +168,7 @@ void PartPlate::init()
|
|||
|
||||
m_print_index = -1;
|
||||
m_print = nullptr;
|
||||
m_plate_name_vbo_id = 0;
|
||||
}
|
||||
|
||||
BedType PartPlate::get_bed_type() const
|
||||
|
@ -744,8 +782,33 @@ void PartPlate::render_icon_texture(int position_id, int tex_coords_id, const Ge
|
|||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
|
||||
}
|
||||
void PartPlate::render_plate_name_texture(int position_id, int tex_coords_id)
|
||||
{
|
||||
if (m_name_texture.get_id() == 0)
|
||||
generate_plate_name_texture();
|
||||
|
||||
void PartPlate::render_icons(bool bottom, int hover_id) const
|
||||
if (m_plate_name_vbo_id == 0 && m_plate_name_icon.get_vertices_data_size() > 0) {
|
||||
glsafe(::glGenBuffers(1, &m_plate_name_vbo_id));
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_plate_name_vbo_id));
|
||||
glsafe(::glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)m_plate_name_icon.get_vertices_data_size(), (const GLvoid*)m_plate_name_icon.get_vertices_data(), GL_STATIC_DRAW));
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
}
|
||||
|
||||
unsigned int stride = m_plate_name_icon.get_vertex_data_size();
|
||||
GLuint tex_id = (GLuint)m_name_texture.get_id();
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, tex_id));
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_plate_name_vbo_id));
|
||||
if (position_id != -1)
|
||||
glsafe(::glVertexAttribPointer(position_id, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)(intptr_t)m_plate_name_icon.get_position_offset()));
|
||||
if (tex_coords_id != -1)
|
||||
glsafe(::glVertexAttribPointer(tex_coords_id, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*)(intptr_t)m_plate_name_icon.get_tex_coords_offset()));
|
||||
glsafe(::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)m_plate_name_icon.get_vertices_count()));
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
|
||||
}
|
||||
|
||||
void PartPlate::render_icons(bool bottom, bool only_name, int hover_id)
|
||||
{
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("printbed");
|
||||
if (shader != nullptr) {
|
||||
|
@ -766,54 +829,69 @@ void PartPlate::render_icons(bool bottom, int hover_id) const
|
|||
if (tex_coords_id != -1) {
|
||||
glsafe(::glEnableVertexAttribArray(tex_coords_id));
|
||||
}
|
||||
|
||||
if (hover_id == 1)
|
||||
render_icon_texture(position_id, tex_coords_id, m_del_icon, m_partplate_list->m_del_hovered_texture, m_del_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_del_icon, m_partplate_list->m_del_texture, m_del_vbo_id);
|
||||
|
||||
if (hover_id == 2)
|
||||
render_icon_texture(position_id, tex_coords_id, m_orient_icon, m_partplate_list->m_orient_hovered_texture, m_orient_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_orient_icon, m_partplate_list->m_orient_texture, m_orient_vbo_id);
|
||||
|
||||
if (hover_id == 3)
|
||||
render_icon_texture(position_id, tex_coords_id, m_arrange_icon, m_partplate_list->m_arrange_hovered_texture, m_arrange_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_arrange_icon, m_partplate_list->m_arrange_texture, m_arrange_vbo_id);
|
||||
|
||||
if (hover_id == 4) {
|
||||
if (this->is_locked())
|
||||
render_icon_texture(position_id, tex_coords_id, m_lock_icon, m_partplate_list->m_locked_hovered_texture, m_lock_vbo_id);
|
||||
if (!only_name) {
|
||||
if (hover_id == 1)
|
||||
render_icon_texture(position_id, tex_coords_id, m_del_icon, m_partplate_list->m_del_hovered_texture,
|
||||
m_del_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_lock_icon, m_partplate_list->m_lockopen_hovered_texture, m_lock_vbo_id);
|
||||
}
|
||||
else {
|
||||
if (this->is_locked())
|
||||
render_icon_texture(position_id, tex_coords_id, m_lock_icon, m_partplate_list->m_locked_texture, m_lock_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_lock_icon, m_partplate_list->m_lockopen_texture, m_lock_vbo_id);
|
||||
}
|
||||
render_icon_texture(position_id, tex_coords_id, m_del_icon, m_partplate_list->m_del_texture,
|
||||
m_del_vbo_id);
|
||||
|
||||
if (m_partplate_list->render_plate_settings) {
|
||||
if (hover_id == 5) {
|
||||
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);
|
||||
if (hover_id == 2)
|
||||
render_icon_texture(position_id, tex_coords_id, m_orient_icon,
|
||||
m_partplate_list->m_orient_hovered_texture, m_orient_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_orient_icon, m_partplate_list->m_orient_texture,
|
||||
m_orient_vbo_id);
|
||||
|
||||
if (hover_id == 3)
|
||||
render_icon_texture(position_id, tex_coords_id, m_arrange_icon,
|
||||
m_partplate_list->m_arrange_hovered_texture, m_arrange_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_arrange_icon, m_partplate_list->m_arrange_texture,
|
||||
m_arrange_vbo_id);
|
||||
|
||||
if (hover_id == 4) {
|
||||
if (this->is_locked())
|
||||
render_icon_texture(position_id, tex_coords_id, m_lock_icon,
|
||||
m_partplate_list->m_locked_hovered_texture, m_lock_vbo_id);
|
||||
else
|
||||
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);
|
||||
render_icon_texture(position_id, tex_coords_id, m_lock_icon,
|
||||
m_partplate_list->m_lockopen_hovered_texture, m_lock_vbo_id);
|
||||
} else {
|
||||
if (this->is_locked())
|
||||
render_icon_texture(position_id, tex_coords_id, m_lock_icon, m_partplate_list->m_locked_texture,
|
||||
m_lock_vbo_id);
|
||||
else
|
||||
render_icon_texture(position_id, tex_coords_id, m_lock_icon, m_partplate_list->m_lockopen_texture,
|
||||
m_lock_vbo_id);
|
||||
}
|
||||
else {
|
||||
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_plate_settings_icon, m_partplate_list->m_plate_settings_changed_texture, m_plate_settings_vbo_id);
|
||||
|
||||
if (m_partplate_list->render_plate_settings) {
|
||||
if (hover_id == 5) {
|
||||
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_plate_settings_icon,
|
||||
m_partplate_list->m_plate_settings_changed_hovered_texture,
|
||||
m_plate_settings_vbo_id);
|
||||
} else {
|
||||
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_plate_settings_icon,
|
||||
m_partplate_list->m_plate_settings_changed_texture, m_plate_settings_vbo_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_plate_index >= 0 && m_plate_index < MAX_PLATE_COUNT) {
|
||||
render_icon_texture(position_id, tex_coords_id, m_plate_idx_icon,
|
||||
m_partplate_list->m_idx_textures[m_plate_index], m_plate_idx_vbo_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_plate_index >=0 && m_plate_index < MAX_PLATE_COUNT) {
|
||||
render_icon_texture(position_id, tex_coords_id, m_plate_idx_icon, m_partplate_list->m_idx_textures[m_plate_index], m_plate_idx_vbo_id);
|
||||
}
|
||||
|
||||
render_plate_name_texture(position_id, tex_coords_id);
|
||||
if (tex_coords_id != -1)
|
||||
glsafe(::glDisableVertexAttribArray(tex_coords_id));
|
||||
|
||||
|
@ -1190,6 +1268,10 @@ void PartPlate::release_opengl_resource()
|
|||
glsafe(::glDeleteBuffers(1, &m_plate_idx_vbo_id));
|
||||
m_plate_idx_vbo_id = 0;
|
||||
}
|
||||
if (m_plate_name_vbo_id > 0) {
|
||||
glsafe(::glDeleteBuffers(1, &m_plate_name_vbo_id));
|
||||
m_plate_name_vbo_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> PartPlate::get_extruders(bool conside_custom_gcode) const
|
||||
|
@ -1385,7 +1467,7 @@ void PartPlate::clear(bool clear_sliced_result)
|
|||
m_ready_for_slice = true;
|
||||
update_slice_result_valid_state(false);
|
||||
}
|
||||
|
||||
m_name_texture.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1473,6 +1555,50 @@ Vec3d PartPlate::get_center_origin()
|
|||
return origin;
|
||||
}
|
||||
|
||||
void PartPlate::generate_plate_name_texture()
|
||||
{
|
||||
// generate m_name_texture texture from m_name with generate_from_text_string
|
||||
m_name_texture.reset();
|
||||
auto text = m_name.empty()? _L("Untitled") : m_name;
|
||||
wxCoord w, h;
|
||||
auto* font = &Label::Head_48;
|
||||
wxColour foreground(0x0, 0x96, 0x88, 0xff);
|
||||
if (!m_name_texture.generate_from_text_string(text.ToStdString(), *font, *wxBLACK, foreground))
|
||||
BOOST_LOG_TRIVIAL(error) << "PartPlate::generate_plate_name_texture(): generate_from_text_string() failed";
|
||||
auto bed_ext = get_extents(m_shape);
|
||||
auto factor = bed_ext.size()(1) / 200.0;
|
||||
ExPolygon poly;
|
||||
float offset_x = 1;
|
||||
w = int(factor * (m_name_texture.get_width() * 16) / m_name_texture.get_height());
|
||||
h = int(factor * 16);
|
||||
Vec2d p = m_shape[3] + Vec2d(0, h*0.6);
|
||||
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP_LEFT + offset_x), scale_(p(1) - h + PARTPLATE_TEXT_OFFSET_Y) });
|
||||
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP_LEFT + w - offset_x), scale_(p(1) - h + PARTPLATE_TEXT_OFFSET_Y) });
|
||||
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP_LEFT + w - offset_x), scale_(p(1) - PARTPLATE_TEXT_OFFSET_Y)});
|
||||
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP_LEFT + offset_x), scale_(p(1) - PARTPLATE_TEXT_OFFSET_Y) });
|
||||
|
||||
auto triangles = triangulate_expolygon_2f(poly, NORMALS_UP);
|
||||
if (!m_plate_name_icon.set_from_triangles(triangles, GROUND_Z))
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to generate geometry buffers for icons\n";
|
||||
|
||||
if (m_plate_name_vbo_id > 0) {
|
||||
glsafe(::glDeleteBuffers(1, &m_plate_name_vbo_id));
|
||||
m_plate_name_vbo_id = 0;
|
||||
}
|
||||
}
|
||||
void PartPlate::set_plate_name(const std::string& name)
|
||||
{
|
||||
// compare if name equal to m_name, case sensitive
|
||||
if (boost::equals(m_name, name))
|
||||
return;
|
||||
|
||||
m_name = name;
|
||||
if (m_print != nullptr)
|
||||
m_print->set_plate_name(name);
|
||||
|
||||
generate_plate_name_texture();
|
||||
}
|
||||
|
||||
//get the print's object, result and index
|
||||
void PartPlate::get_print(PrintBase** print, GCodeResult** result, int* index)
|
||||
{
|
||||
|
@ -2100,6 +2226,8 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve
|
|||
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);
|
||||
// calc vertex for plate name
|
||||
generate_plate_name_texture();
|
||||
}
|
||||
|
||||
calc_height_limit();
|
||||
|
@ -2172,35 +2300,8 @@ void PartPlate::render(bool bottom, bool only_body, bool force_background_color,
|
|||
|
||||
render_height_limit(mode);
|
||||
|
||||
if (!only_body) {
|
||||
/*float render_color[4];
|
||||
::memcpy((void*)m_grabber_color, (const void*)DEFAULT_HIGHLIGHT_COLOR, 4 * sizeof(float));
|
||||
|
||||
render_color[0] = 1.0f - m_grabber_color[0];
|
||||
render_color[1] = 1.0f - m_grabber_color[1];
|
||||
render_color[2] = 1.0f - m_grabber_color[2];
|
||||
render_color[3] = m_grabber_color[3];
|
||||
|
||||
|
||||
if (m_hover_id == 0)
|
||||
render_grabber(m_grabber_color, true);
|
||||
else
|
||||
render_grabber(render_color, true);
|
||||
|
||||
if (m_selected) {
|
||||
if (m_hover_id == 1)
|
||||
render_left_arrow(m_grabber_color, true);
|
||||
else
|
||||
render_left_arrow(render_color, true);
|
||||
|
||||
if (m_hover_id == 2)
|
||||
render_right_arrow(m_grabber_color, true);
|
||||
else
|
||||
render_right_arrow(render_color, true);
|
||||
}*/
|
||||
render_icons(bottom, hover_id);
|
||||
}
|
||||
else if (!force_background_color){
|
||||
render_icons(bottom, only_body, hover_id);
|
||||
if (!force_background_color){
|
||||
render_only_numbers(bottom);
|
||||
}
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
|
@ -2666,32 +2767,9 @@ void PartPlateList::generate_icon_textures()
|
|||
}
|
||||
}
|
||||
|
||||
auto is_font_suitable = [](std::string text_str, wxFont& font, int max_size) {
|
||||
wxMemoryDC memDC;
|
||||
wxCoord w, h;
|
||||
wxString msg(text_str);
|
||||
memDC.SetFont(font);
|
||||
memDC.GetMultiLineTextExtent(msg, &w, &h);
|
||||
if (w <= max_size)
|
||||
return true;
|
||||
else
|
||||
return false;;
|
||||
};
|
||||
wxFont* font = nullptr;
|
||||
|
||||
std::string text_str = "01";
|
||||
int max_size = 32;
|
||||
if (is_font_suitable(text_str, Label::Head_24, max_size))
|
||||
font = &Label::Head_24;
|
||||
else if (is_font_suitable(text_str, Label::Head_20, max_size))
|
||||
font = &Label::Head_20;
|
||||
else if (is_font_suitable(text_str, Label::Head_18, max_size))
|
||||
font = &Label::Head_18;
|
||||
else if (is_font_suitable(text_str, Label::Head_16, max_size))
|
||||
font = &Label::Head_16;
|
||||
else if (is_font_suitable(text_str, Label::Head_14, max_size))
|
||||
font = &Label::Head_14;
|
||||
else
|
||||
font = &Label::Head_12;
|
||||
wxFont* font = find_font(text_str,32);
|
||||
|
||||
for (int i = 0; i < MAX_PLATE_COUNT; i++) {
|
||||
if (m_idx_textures[i].get_id() == 0) {
|
||||
|
@ -2701,7 +2779,7 @@ void PartPlateList::generate_icon_textures()
|
|||
else
|
||||
file_name = std::to_string(i+1);
|
||||
|
||||
wxColour foreground(0x0, 0xae, 0x42, 0xff);
|
||||
wxColour foreground(0x0, 0x96, 0x88, 0xff);
|
||||
if (!m_idx_textures[i].generate_from_text_string(file_name, *font, *wxBLACK, foreground)) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
|
||||
}
|
||||
|
@ -4409,6 +4487,7 @@ int PartPlateList::store_to_3mf_structure(PlateDataPtrs& plate_data_list, bool w
|
|||
PlateData* plate_data_item = new PlateData();
|
||||
plate_data_item->locked = m_plate_list[i]->m_locked;
|
||||
plate_data_item->plate_index = m_plate_list[i]->m_plate_index;
|
||||
plate_data_item->plate_name = m_plate_list[i]->get_plate_name();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": plate %1% before load, width %2%, height %3%, size %4%!")
|
||||
%(i+1) %m_plate_list[i]->thumbnail_data.width %m_plate_list[i]->thumbnail_data.height %m_plate_list[i]->thumbnail_data.pixels.size();
|
||||
plate_data_item->plate_thumbnail.load_from(m_plate_list[i]->thumbnail_data);
|
||||
|
@ -4482,6 +4561,7 @@ int PartPlateList::load_from_3mf_structure(PlateDataPtrs& plate_data_list)
|
|||
int index = create_plate(false);
|
||||
m_plate_list[index]->m_locked = plate_data_list[i]->locked;
|
||||
m_plate_list[index]->config()->apply(plate_data_list[i]->config);
|
||||
m_plate_list[index]->set_plate_name(plate_data_list[i]->plate_name);
|
||||
if (plate_data_list[i]->plate_index != index)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(":plate index %1% seems invalid, skip it")% plate_data_list[i]->plate_index;
|
||||
|
|
|
@ -148,6 +148,15 @@ private:
|
|||
// BBS
|
||||
DynamicPrintConfig m_config;
|
||||
|
||||
// SoftFever
|
||||
// part plate name
|
||||
std::string m_name;
|
||||
GeometryBuffer m_plate_name_icon;
|
||||
mutable unsigned int m_plate_name_vbo_id{ 0 };
|
||||
GLTexture m_name_texture;
|
||||
wxCoord m_name_texture_width;
|
||||
wxCoord m_name_texture_height;
|
||||
|
||||
void init();
|
||||
bool valid_instance(int obj_id, int instance_id);
|
||||
void generate_print_polygon(ExPolygon &print_polygon);
|
||||
|
@ -161,6 +170,8 @@ private:
|
|||
void calc_vertex_for_number(int index, bool one_number, GeometryBuffer &buffer);
|
||||
void calc_vertex_for_icons(int index, GeometryBuffer &buffer);
|
||||
void calc_vertex_for_icons_background(int icon_count, GeometryBuffer &buffer);
|
||||
//void calc_vertex_for_name_tex(GeometryBuffer &buffer);
|
||||
|
||||
void render_background(bool force_default_color = false) const;
|
||||
void render_logo(bool bottom) const;
|
||||
void render_logo_texture(GLTexture& logo_texture, const GeometryBuffer& logo_buffer, bool bottom, unsigned int vbo_id) const;
|
||||
|
@ -175,8 +186,9 @@ private:
|
|||
void render_left_arrow(const float* render_color, bool use_lighting) const;
|
||||
void render_right_arrow(const float* render_color, bool use_lighting) const;
|
||||
void render_icon_texture(int position_id, int tex_coords_id, const GeometryBuffer &buffer, GLTexture &texture, unsigned int &vbo_id) const;
|
||||
void render_icons(bool bottom, int hover_id = -1) const;
|
||||
void render_icons(bool bottom, bool only_name = false, int hover_id = -1);
|
||||
void render_only_numbers(bool bottom) const;
|
||||
void render_plate_name_texture(int position_id, int tex_coords_id);
|
||||
void render_rectangle_for_picking(const GeometryBuffer &buffer, const float* render_color) const;
|
||||
void on_render_for_picking() const;
|
||||
std::array<float, 4> picking_color_component(int idx) const;
|
||||
|
@ -242,6 +254,13 @@ public:
|
|||
//get the plate's index
|
||||
int get_index() { return m_plate_index; }
|
||||
|
||||
// SoftFever
|
||||
//get the plate's name
|
||||
std::string get_plate_name() { return m_name; }
|
||||
void generate_plate_name_texture();
|
||||
//set the plate's name
|
||||
void set_plate_name(const std::string& name);
|
||||
|
||||
//get the print's object, result and index
|
||||
void get_print(PrintBase **print, GCodeResult **result, int *index);
|
||||
|
||||
|
|
|
@ -23,14 +23,19 @@ PlateSettingsDialog::PlateSettingsDialog(wxWindow* parent, wxWindowID id, const
|
|||
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)) {
|
||||
bool is_bbl = wxGetApp().preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(wxGetApp().preset_bundle);
|
||||
if (is_bbl) {
|
||||
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));
|
||||
}
|
||||
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 );
|
||||
|
@ -43,6 +48,12 @@ PlateSettingsDialog::PlateSettingsDialog(wxWindow* parent, wxWindowID id, const
|
|||
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));
|
||||
|
||||
auto plate_name_txt = new wxStaticText(this, wxID_ANY, _L("Plate name"));
|
||||
plate_name_txt->SetFont(Label::Body_14);
|
||||
m_ti_plate_name = new TextInput(this, wxString::FromDouble(0.0), "", "", wxDefaultPosition, wxSize(FromDIP(240),-1), wxTE_PROCESS_ENTER);
|
||||
top_sizer->Add(plate_name_txt, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT |wxALL, FromDIP(5));
|
||||
top_sizer->Add(m_ti_plate_name, 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);
|
||||
|
@ -155,4 +166,10 @@ void PlateSettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||
m_button_cancel->Rescale();
|
||||
}
|
||||
|
||||
wxString PlateSettingsDialog::get_plate_name() const {
|
||||
return m_ti_plate_name->GetTextCtrl()->GetValue();
|
||||
}
|
||||
|
||||
void PlateSettingsDialog::set_plate_name(const wxString &name) { m_ti_plate_name->GetTextCtrl()->SetValue(name); }
|
||||
|
||||
}} // namespace Slic3r::GUI
|
|
@ -49,11 +49,15 @@ public:
|
|||
return choice;
|
||||
};
|
||||
|
||||
wxString get_plate_name() const;
|
||||
void set_plate_name(const wxString& name);
|
||||
|
||||
protected:
|
||||
ComboBox* m_print_seq_choice { nullptr };
|
||||
ComboBox* m_bed_type_choice { nullptr };
|
||||
Button* m_button_ok;
|
||||
Button* m_button_cancel;
|
||||
TextInput *m_ti_plate_name;
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
@ -11508,6 +11508,8 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click)
|
|||
else
|
||||
dlg.sync_print_seq(0);
|
||||
|
||||
dlg.set_plate_name(curr_plate->get_plate_name());
|
||||
|
||||
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();
|
||||
|
@ -11531,6 +11533,7 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click)
|
|||
wxGetApp().plater()->config_change_notification(plate_config, std::string("print_sequence"));
|
||||
});
|
||||
dlg.ShowModal();
|
||||
curr_plate->set_plate_name(dlg.get_plate_name().ToStdString());
|
||||
|
||||
this->schedule_background_process();
|
||||
}
|
||||
|
|
|
@ -1647,7 +1647,7 @@ void Tab::on_presets_changed()
|
|||
if (is_bbl_vendor_preset)
|
||||
wxGetApp().plater()->get_partplate_list().set_render_option(true, true);
|
||||
else
|
||||
wxGetApp().plater()->get_partplate_list().set_render_option(false, false);
|
||||
wxGetApp().plater()->get_partplate_list().set_render_option(false, true);
|
||||
|
||||
// Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors.
|
||||
for (auto t: m_dependent_tabs)
|
||||
|
|
|
@ -21,6 +21,7 @@ wxFont Label::sysFont(int size, bool bold)
|
|||
}
|
||||
return font;
|
||||
}
|
||||
wxFont Label::Head_48;
|
||||
wxFont Label::Head_24;
|
||||
wxFont Label::Head_20;
|
||||
wxFont Label::Head_18;
|
||||
|
@ -64,6 +65,7 @@ void Label::initSysFont()
|
|||
Head_12 = Label::sysFont(12, true);
|
||||
Head_10 = Label::sysFont(10, true);
|
||||
|
||||
Head_48 = Label::sysFont(48, true);
|
||||
Body_16 = Label::sysFont(16, false);
|
||||
Body_15 = Label::sysFont(15, false);
|
||||
Body_14 = Label::sysFont(14, false);
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
static wxFont Head_12;
|
||||
static wxFont Head_10;
|
||||
|
||||
static wxFont Head_48;
|
||||
static wxFont Body_16;
|
||||
static wxFont Body_15;
|
||||
static wxFont Body_14;
|
||||
|
|
|
@ -302,7 +302,7 @@ void TabCtrl::doRender(wxDC& dc)
|
|||
#else
|
||||
dc.SetPen(wxPen(border_color.colorForStates(states), border_width));
|
||||
dc.DrawLine(0, size.y - BS2, size.x, size.y - BS2);
|
||||
wxColor c(0x42AE00);
|
||||
wxColor c(0x968800);
|
||||
dc.SetPen(wxPen(c, 1));
|
||||
dc.SetBrush(c);
|
||||
dc.DrawRoundedRectangle(x1 - radius, size.y - BS2 - border_width * 3, x2 + radius * 2 - x1, border_width * 3, radius);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue