Improve quality of bed name / number texture (#9535)
* init * update * update * update * update * update * Update PartPlate.cpp
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="43" height="43" viewBox="0 0 43 43"><rect x="10" y="12" width="27" height="27" rx="3.115" style="fill:#e9e9e9"/><path d="M31.672,13.328a2.828,2.828,0,0,1,4,4L19.5,33.5h-4v-4Z" style="fill:none;stroke:#545454;stroke-linecap:round;stroke-linejoin:round"/><path d="M25.5,12.5h-13a2,2,0,0,0-2,2v22a2,2,0,0,0,2,2h22a2,2,0,0,0,2-2v-13" style="fill:none;stroke:#545454;stroke-linecap:round;stroke-linejoin:round"/></svg>
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" width="43" height="43" viewBox="0 0 43 43"><rect x="10" y="4" width="29" height="29" rx="3.11" ry="3.11" style="fill:#e9e9e9;"/><path d="M33.67,5.33c1.1-1.1,2.9-1.1,4,0,1.1,1.1,1.1,2.9,0,4h0l-18.17,18.17h-4v-4L33.67,5.33Z" style="fill:none; stroke:#545454; stroke-linecap:round; stroke-linejoin:round;"/><path d="M25.5,4.5h-13c-1.1,0-2,.9-2,2v24c0,1.1.9,2,2,2h24c1.1,0,2-.9,2-2v-13" style="fill:none; stroke:#545454; stroke-linecap:round; stroke-linejoin:round;"/></svg>
|
Before Width: | Height: | Size: 460 B After Width: | Height: | Size: 555 B |
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="43" height="43" viewBox="0 0 43 43"><rect x="10" y="12" width="27" height="27" rx="3.115" style="fill:#54545a"/><path d="M31.672,13.328a2.828,2.828,0,0,1,4,4L19.5,33.5h-4v-4Z" style="fill:none;stroke:#c4c4c4;stroke-linecap:round;stroke-linejoin:round"/><path d="M25.5,12.5h-13a2,2,0,0,0-2,2v22a2,2,0,0,0,2,2h22a2,2,0,0,0,2-2v-13" style="fill:none;stroke:#c4c4c4;stroke-linecap:round;stroke-linejoin:round"/></svg>
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" width="43" height="43" viewBox="0 0 43 43"><rect x="10" y="4" width="29" height="29" rx="3.11" ry="3.11" style="fill:#54545a;"/><path d="M33.67,5.33c1.1-1.1,2.9-1.1,4,0,1.1,1.1,1.1,2.9,0,4h0l-18.17,18.17h-4v-4L33.67,5.33Z" style="fill:none; stroke:#c4c4c4; stroke-linecap:round; stroke-linejoin:round;"/><path d="M25.5,4.5h-13c-1.1,0-2,.9-2,2v24c0,1.1.9,2,2,2h24c1.1,0,2-.9,2-2v-13" style="fill:none; stroke:#c4c4c4; stroke-linecap:round; stroke-linejoin:round;"/></svg>
|
Before Width: | Height: | Size: 460 B After Width: | Height: | Size: 555 B |
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="43" height="43" viewBox="0 0 43 43"><rect x="10" y="12" width="27" height="27" rx="3.115" style="fill:#e9e9e9"/><path d="M31.672,13.328a2.828,2.828,0,0,1,4,4L19.5,33.5h-4v-4Z" style="fill:none;stroke:#009688;stroke-linecap:round;stroke-linejoin:round"/><path d="M25.5,12.5h-13a2,2,0,0,0-2,2v22a2,2,0,0,0,2,2h22a2,2,0,0,0,2-2v-13" style="fill:none;stroke:#009688;stroke-linecap:round;stroke-linejoin:round"/></svg>
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" width="43" height="43" viewBox="0 0 43 43"><rect x="10" y="4" width="29" height="29" rx="3.11" ry="3.11" style="fill:#e9e9e9;"/><path d="M33.67,5.33c1.1-1.1,2.9-1.1,4,0,1.1,1.1,1.1,2.9,0,4h0l-18.17,18.17h-4v-4L33.67,5.33Z" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><path d="M25.5,4.5h-13c-1.1,0-2,.9-2,2v24c0,1.1.9,2,2,2h24c1.1,0,2-.9,2-2v-13" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/></svg>
|
Before Width: | Height: | Size: 460 B After Width: | Height: | Size: 555 B |
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="43" height="43" viewBox="0 0 43 43"><rect x="10" y="12" width="27" height="27" rx="3.115" style="fill:#54545a"/><path d="M31.672,13.328a2.828,2.828,0,0,1,4,4L19.5,33.5h-4v-4Z" style="fill:none;stroke:#009688;stroke-linecap:round;stroke-linejoin:round"/><path d="M25.5,12.5h-13a2,2,0,0,0-2,2v22a2,2,0,0,0,2,2h22a2,2,0,0,0,2-2v-13" style="fill:none;stroke:#009688;stroke-linecap:round;stroke-linejoin:round"/></svg>
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" width="43" height="43" viewBox="0 0 43 43"><rect x="10" y="4" width="29" height="29" rx="3.11" ry="3.11" style="fill:#54545a;"/><path d="M33.67,5.33c1.1-1.1,2.9-1.1,4,0,1.1,1.1,1.1,2.9,0,4h0l-18.17,18.17h-4v-4L33.67,5.33Z" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><path d="M25.5,4.5h-13c-1.1,0-2,.9-2,2v24c0,1.1.9,2,2,2h24c1.1,0,2-.9,2-2v-13" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/></svg>
|
Before Width: | Height: | Size: 460 B After Width: | Height: | Size: 555 B |
@ -53,7 +53,7 @@ static unsigned int GLOBAL_PLATE_INDEX = 0;
|
||||
|
||||
static const double LOGICAL_PART_PLATE_GAP = 1. / 5.;
|
||||
static const int PARTPLATE_ICON_SIZE = 16;
|
||||
static const int PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE = 12;
|
||||
static const int PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE = 9; // ORCA this also scales height of plate name
|
||||
static const int PARTPLATE_ICON_GAP_TOP = 3;
|
||||
static const int PARTPLATE_ICON_GAP_LEFT = 3;
|
||||
static const int PARTPLATE_ICON_GAP_Y = 5;
|
||||
@ -570,21 +570,25 @@ void PartPlate::calc_vertex_for_plate_name_edit_icon(GLTexture *texture, int ind
|
||||
ExPolygon poly;
|
||||
auto bed_ext = get_extents(m_shape);
|
||||
Vec2d p = bed_ext[3];
|
||||
auto factor = bed_ext.size()(1) / 200.0;
|
||||
float width = 0.f;
|
||||
float height = PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE * factor;
|
||||
float offset_x = 1 * factor;
|
||||
float offset_y = PARTPLATE_TEXT_OFFSET_Y * factor;
|
||||
float factor = bed_ext.size()(1) / 200.0;
|
||||
float icon_sz = factor * PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE;
|
||||
float width = icon_sz;
|
||||
float height = icon_sz;
|
||||
float offset_y = factor * PARTPLATE_TEXT_OFFSET_Y;
|
||||
|
||||
float name_width;
|
||||
if (texture && texture->get_width() > 0 && texture->get_height())
|
||||
width = int(factor * (texture->get_original_width() * 16) / texture->get_height());
|
||||
// original width give correct ratio in here since rendering width can be much higher because of next_highest_power_of_2 for rendering
|
||||
name_width = icon_sz * texture->m_original_width / texture->get_height();
|
||||
|
||||
p += Vec2d(width + offset_x, offset_y + height);
|
||||
//if (m_plater && m_plater->get_build_volume_type() == BuildVolume_Type::Circle)
|
||||
// px = scale_(bed_ext.center()(0)) + m_name_texture_width * 0.50 - height * 0.50;
|
||||
p += Vec2d(name_width, offset_y);
|
||||
|
||||
poly.contour.append({ scale_(p(0)) , scale_(p(1) - height) });
|
||||
poly.contour.append({ scale_(p(0) + height), scale_(p(1) - height) });
|
||||
poly.contour.append({ scale_(p(0) + height), scale_(p(1)) });
|
||||
poly.contour.append({ scale_(p(0)) , scale_(p(1)) });
|
||||
poly.contour.append({ scale_(p(0) ), scale_(p(1) ) });
|
||||
poly.contour.append({ scale_(p(0) + width), scale_(p(1) ) });
|
||||
poly.contour.append({ scale_(p(0) + width), scale_(p(1) + height) });
|
||||
poly.contour.append({ scale_(p(0) ), scale_(p(1) + height) });
|
||||
|
||||
if (!init_model_from_poly(model.model, poly, GROUND_Z))
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to generate geometry buffers for icons\n";
|
||||
@ -1869,25 +1873,34 @@ 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") : from_u8(m_name);
|
||||
wxCoord w, h;
|
||||
|
||||
auto* font = &Label::Head_32;
|
||||
// ORCA also scale font size to prevent low res texture
|
||||
int size = wxGetApp().em_unit() * PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE;
|
||||
auto l = Label::sysFont(size, true);
|
||||
wxFont* font = &l;
|
||||
|
||||
wxColour foreground(0xf2, 0x75, 0x4e, 0xff);
|
||||
if (!m_name_texture.generate_from_text_string(text.ToUTF8().data(), *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 * factor;
|
||||
float offset_y = PARTPLATE_TEXT_OFFSET_Y * factor;
|
||||
w = int(factor * (m_name_texture.get_width() * 16) / m_name_texture.get_height());
|
||||
h = int(factor * 16);
|
||||
Vec2d p = bed_ext[3] + Vec2d(0, 1 + h * m_name_texture.m_original_height / m_name_texture.get_height());
|
||||
poly.contour.append({ scale_(p(0) + offset_x) , scale_(p(1) - h + offset_y) });
|
||||
poly.contour.append({ scale_(p(0) + w - offset_x), scale_(p(1) - h + offset_y) });
|
||||
poly.contour.append({ scale_(p(0) + w - offset_x), scale_(p(1) - offset_y) });
|
||||
poly.contour.append({ scale_(p(0) + offset_x) , scale_(p(1) - offset_y) });
|
||||
auto bed_ext = get_extents(m_shape);
|
||||
Vec2d p = bed_ext[3];
|
||||
float factor = bed_ext.size()(1) / 200.0;
|
||||
float icon_sz = factor * PARTPLATE_EDIT_PLATE_NAME_ICON_SIZE;
|
||||
float width = icon_sz * m_name_texture.get_width() / m_name_texture.get_height(); // icon size * text_bb_ratio
|
||||
float height = icon_sz; // scale with icon size to preserve ratio while system scaling
|
||||
float offset_y = factor * PARTPLATE_TEXT_OFFSET_Y;
|
||||
|
||||
//if (m_plater && m_plater->get_build_volume_type() == BuildVolume_Type::Circle)
|
||||
// px = scale_(bed_ext.center()(0)) - (width + height) / 2.00;
|
||||
|
||||
p += Vec2d(0, offset_y);
|
||||
|
||||
poly.contour.append({ scale_(p(0) ), scale_(p(1) ) });
|
||||
poly.contour.append({ scale_(p(0) + width), scale_(p(1) ) });
|
||||
poly.contour.append({ scale_(p(0) + width), scale_(p(1) + height) });
|
||||
poly.contour.append({ scale_(p(0) ), scale_(p(1) + height) });
|
||||
|
||||
if (!init_model_from_poly(m_plate_name_icon, poly, GROUND_Z))
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to generate geometry buffers for icons\n";
|
||||
@ -3367,7 +3380,10 @@ void PartPlateList::generate_icon_textures()
|
||||
}
|
||||
|
||||
std::string text_str = "01";
|
||||
wxFont* font = find_font(text_str,32);
|
||||
// ORCA also scale font size to prevent low res texture
|
||||
int size = wxGetApp().em_unit() * PARTPLATE_ICON_SIZE;
|
||||
auto l = Label::sysFont(int(size), true);
|
||||
wxFont* font = &l;
|
||||
|
||||
for (int i = 0; i < MAX_PLATE_COUNT; i++) {
|
||||
if (m_idx_textures[i].get_id() == 0) {
|
||||
|