optimize icon position for circle bed

This commit is contained in:
SoftFever 2023-04-10 18:55:14 +08:00
parent cb22560d38
commit ef3614a21a
12 changed files with 99 additions and 67 deletions

View file

@ -131,6 +131,9 @@ public:
// Was the model generated procedurally?
bool is_custom() const { return m_type == Type::Custom; }
// get the bed shape type
BuildVolume_Type get_build_volume_type() const { return m_build_volume.type(); }
// Bounding box around the print bed, axes and model, for rendering.
const BoundingBoxf3& extended_bounding_box() const { return m_extended_bounding_box; }

View file

@ -1414,14 +1414,14 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
state = BuildVolume::ObjectState::Below;
else {
switch (plate_build_volume.type()) {
case BuildVolume::Type::Rectangle:
case BuildVolume_Type::Rectangle:
//FIXME this test does not evaluate collision of a build volume bounding box with non-convex objects.
state = plate_build_volume.volume_state_bbox(bb);
break;
case BuildVolume::Type::Circle:
case BuildVolume::Type::Convex:
case BuildVolume_Type::Circle:
case BuildVolume_Type::Convex:
//FIXME doing test on convex hull until we learn to do test on non-convex polygons efficiently.
case BuildVolume::Type::Custom:
case BuildVolume_Type::Custom:
state = plate_build_volume.object_state(volume_convex_mesh(*volume).its, volume->world_matrix().cast<float>(), volume_sinking(*volume));
break;
default:

View file

@ -88,11 +88,11 @@ wxString BedShape::get_name(PageType type)
BedShape::PageType BedShape::get_page_type()
{
switch (m_build_volume.type()) {
case BuildVolume::Type::Rectangle:
case BuildVolume::Type::Invalid: return PageType::Rectangle;
case BuildVolume::Type::Circle: return PageType::Circle;
case BuildVolume::Type::Convex:
case BuildVolume::Type::Custom: return PageType::Custom;
case BuildVolume_Type::Rectangle:
case BuildVolume_Type::Invalid: return PageType::Rectangle;
case BuildVolume_Type::Circle: return PageType::Circle;
case BuildVolume_Type::Convex:
case BuildVolume_Type::Custom: return PageType::Custom;
}
// make visual studio happy
assert(false);
@ -103,7 +103,7 @@ wxString BedShape::get_full_name_with_params()
{
wxString out = _L("Shape") + ": " + get_name(this->get_page_type());
switch (m_build_volume.type()) {
case BuildVolume::Type::Circle:
case BuildVolume_Type::Circle:
out += "\n" + _L(get_option_label(Parameter::Diameter)) + ": [" + double_to_string(2. * unscaled<double>(m_build_volume.circle().radius)) + "]";
break;
default:
@ -118,7 +118,7 @@ wxString BedShape::get_full_name_with_params()
void BedShape::apply_optgroup_values(ConfigOptionsGroupShp optgroup)
{
switch (m_build_volume.type()) {
case BuildVolume::Type::Circle:
case BuildVolume_Type::Circle:
optgroup->set_value("diameter", double_to_string(2. * unscaled<double>(m_build_volume.circle().radius)));
break;
default:

View file

@ -35,7 +35,7 @@ struct BedShape
BedShape(const ConfigOptionPoints& points);
bool is_custom() { return m_build_volume.type() == BuildVolume::Type::Convex || m_build_volume.type() == BuildVolume::Type::Custom; }
bool is_custom() { return m_build_volume.type() == BuildVolume_Type::Convex || m_build_volume.type() == BuildVolume_Type::Custom; }
static void append_option_line(ConfigOptionsGroupShp optgroup, Parameter param);
static wxString get_name(PageType type);

View file

@ -116,7 +116,7 @@ RetinaHelper::~RetinaHelper() {}
float RetinaHelper::get_scale_factor() { return float(m_window->GetContentScaleFactor()); }
#endif // __WXGTK3__
// Fixed the collision between BuildVolume::Type::Convex and macro Convex defined inside /usr/include/X11/X.h that is included by WxWidgets 3.0.
// Fixed the collision between BuildVolume_Type::Convex and macro Convex defined inside /usr/include/X11/X.h that is included by WxWidgets 3.0.
#if defined(__linux__) && defined(Convex)
#undef Convex
#endif
@ -6542,22 +6542,22 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
if (const BuildVolume &build_volume = m_bed.build_volume(); build_volume.valid()) {
switch (build_volume.type()) {
case BuildVolume::Type::Rectangle: {
case BuildVolume_Type::Rectangle: {
const BoundingBox3Base<Vec3d> bed_bb = build_volume.bounding_volume().inflated(BuildVolume::SceneEpsilon);
m_volumes.set_print_volume({ 0, // Rectangle
{ float(bed_bb.min.x()), float(bed_bb.min.y()), float(bed_bb.max.x()), float(bed_bb.max.y()) },
{ 0.0f, float(build_volume.printable_height()) } });
break;
}
case BuildVolume::Type::Circle: {
case BuildVolume_Type::Circle: {
m_volumes.set_print_volume({ 1, // Circle
{ unscaled<float>(build_volume.circle().center.x()), unscaled<float>(build_volume.circle().center.y()), unscaled<float>(build_volume.circle().radius + BuildVolume::SceneEpsilon), 0.0f },
{ 0.0f, float(build_volume.printable_height() + BuildVolume::SceneEpsilon) } });
break;
}
default:
case BuildVolume::Type::Convex:
case BuildVolume::Type::Custom: {
case BuildVolume_Type::Convex:
case BuildVolume_Type::Custom: {
m_volumes.set_print_volume({ static_cast<int>(type),
{ -FLT_MAX, -FLT_MAX, FLT_MAX, FLT_MAX },
{ -FLT_MAX, FLT_MAX } }

View file

@ -437,7 +437,8 @@ void PartPlate::calc_vertex_for_number(int index, bool one_number, GeometryBuffe
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP + PARTPLATE_ICON_SIZE - offset_x), scale_(p(1) - index * (PARTPLATE_ICON_SIZE + PARTPLATE_ICON_GAP)- PARTPLATE_ICON_GAP - PARTPLATE_TEXT_OFFSET_Y)});
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP + offset_x), scale_(p(1) - index * (PARTPLATE_ICON_SIZE + PARTPLATE_ICON_GAP)- PARTPLATE_ICON_GAP - PARTPLATE_TEXT_OFFSET_Y) });
#else //in the bottom
Vec2d& p = m_shape[1];
auto bed_ext = get_extents(m_shape);
Vec2d p = bed_ext[1];
float offset_x = one_number?PARTPLATE_TEXT_OFFSET_X1: PARTPLATE_TEXT_OFFSET_X2;
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP_LEFT + offset_x), scale_(p(1) + PARTPLATE_TEXT_OFFSET_Y) });
@ -453,7 +454,11 @@ void PartPlate::calc_vertex_for_number(int index, bool one_number, GeometryBuffe
void PartPlate::calc_vertex_for_icons(int index, GeometryBuffer &buffer)
{
ExPolygon poly;
Vec2d& p = m_shape[2];
auto bed_ext = get_extents(m_shape);
Vec2d p = bed_ext[2];
if (m_plater->get_build_volume_type() == BuildVolume_Type::Circle)
p[1] -= std::max(
0.0, (bed_ext.size()(1) - 5 * PARTPLATE_ICON_SIZE - 4 * PARTPLATE_ICON_GAP_Y - PARTPLATE_ICON_GAP_TOP) / 2);
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP_LEFT), scale_(p(1) - index * (PARTPLATE_ICON_SIZE + PARTPLATE_ICON_GAP_Y) - PARTPLATE_ICON_GAP_TOP - PARTPLATE_ICON_SIZE) });
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP_LEFT + PARTPLATE_ICON_SIZE), scale_(p(1) - index * (PARTPLATE_ICON_SIZE + PARTPLATE_ICON_GAP_Y)- PARTPLATE_ICON_GAP_TOP - PARTPLATE_ICON_SIZE) });
@ -468,7 +473,8 @@ void PartPlate::calc_vertex_for_icons(int index, GeometryBuffer &buffer)
void PartPlate::calc_vertex_for_icons_background(int icon_count, GeometryBuffer &buffer)
{
ExPolygon poly;
Vec2d& p = m_shape[2];
auto bed_ext = get_extents(m_shape);
Vec2d p = bed_ext[2];
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP_LEFT), scale_(p(1) - icon_count * (PARTPLATE_ICON_SIZE + PARTPLATE_ICON_GAP_Y) - PARTPLATE_ICON_GAP_TOP) });
poly.contour.append({ scale_(p(0) + PARTPLATE_ICON_GAP_LEFT + PARTPLATE_ICON_SIZE), scale_(p(1) - icon_count * (PARTPLATE_ICON_SIZE + PARTPLATE_ICON_GAP_Y)- PARTPLATE_ICON_GAP_TOP) });
@ -1576,7 +1582,7 @@ void PartPlate::generate_plate_name_texture()
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);
Vec2d p = bed_ext[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)});

View file

@ -6862,8 +6862,8 @@ bool Plater::priv::has_assemble_view() const
#if ENABLE_ENHANCED_PRINT_VOLUME_FIT
bool Plater::priv::can_scale_to_print_volume() const
{
const BuildVolume::Type type = this->bed.build_volume().type();
return !view3D->get_canvas3d()->get_selection().is_empty() && (type == BuildVolume::Type::Rectangle || type == BuildVolume::Type::Circle);
const BuildVolume_Type type = this->bed.build_volume().type();
return !view3D->get_canvas3d()->get_selection().is_empty() && (type == BuildVolume_Type::Rectangle || type == BuildVolume_Type::Circle);
}
#endif // ENABLE_ENHANCED_PRINT_VOLUME_FIT
@ -8369,6 +8369,7 @@ void Plater::calib_VFA(const Calib_Params& params)
p->background_process.fff_print()->set_calib_params(params);
}
BuildVolume_Type Plater::get_build_volume_type() const { return p->bed.get_build_volume_type(); }
void Plater::import_sl1_archive()
{
if (!p->m_ui_jobs.is_any_running())

View file

@ -38,6 +38,7 @@ class Button;
namespace Slic3r {
class BuildVolume;
enum class BuildVolume_Type : unsigned char;
class Model;
class ModelObject;
enum class ModelObjectCutAttribute : int;
@ -236,6 +237,8 @@ public:
void calib_max_vol_speed(const Calib_Params& params);
void calib_VFA(const Calib_Params& params);
BuildVolume_Type get_build_volume_type() const;
//BBS: add only gcode mode
bool only_gcode_mode() { return m_only_gcode; }
void set_only_gcode(bool only_gcode) { m_only_gcode = only_gcode; }

View file

@ -1234,8 +1234,8 @@ void Selection::scale_to_fit_print_volume(const BuildVolume& volume)
switch (volume.type())
{
case BuildVolume::Type::Rectangle: { fit_rectangle(volume); break; }
case BuildVolume::Type::Circle: { fit_circle(volume); break; }
case BuildVolume_Type::Rectangle: { fit_rectangle(volume); break; }
case BuildVolume_Type::Circle: { fit_circle(volume); break; }
default: { break; }
}
}