mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-05 19:42:47 +00:00
Small refactor for BedShapeHint
This commit is contained in:
@@ -51,6 +51,9 @@ class BedShapeHint {
|
||||
BedShape_u() {}
|
||||
} m_bed;
|
||||
|
||||
// Reset the type, allocate m_bed properly
|
||||
void reset(BedShapes type);
|
||||
|
||||
public:
|
||||
|
||||
BedShapeHint(){}
|
||||
@@ -81,45 +84,8 @@ public:
|
||||
BedShapeHint(const BedShapeHint &cpy) { *this = cpy; }
|
||||
BedShapeHint(BedShapeHint &&cpy) { *this = std::move(cpy); }
|
||||
|
||||
BedShapeHint &operator=(const BedShapeHint &cpy)
|
||||
{
|
||||
if (m_type != cpy.m_type) {
|
||||
if (m_type == bsIrregular)
|
||||
m_bed.polygon.Slic3r::Polyline::~Polyline();
|
||||
else if (cpy.m_type == bsIrregular)
|
||||
::new (&m_bed.polygon) Polyline();
|
||||
}
|
||||
m_type = cpy.m_type;
|
||||
switch(m_type) {
|
||||
case bsBox: m_bed.box = cpy.m_bed.box; break;
|
||||
case bsCircle: m_bed.circ = cpy.m_bed.circ; break;
|
||||
case bsIrregular: m_bed.polygon = cpy.m_bed.polygon; break;
|
||||
case bsInfinite: m_bed.infbed = cpy.m_bed.infbed; break;
|
||||
case bsUnknown: break;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BedShapeHint& operator=(BedShapeHint &&cpy)
|
||||
{
|
||||
if (m_type != cpy.m_type) {
|
||||
if (m_type == bsIrregular)
|
||||
m_bed.polygon.Slic3r::Polyline::~Polyline();
|
||||
else if (cpy.m_type == bsIrregular)
|
||||
::new (&m_bed.polygon) Polyline();
|
||||
}
|
||||
m_type = cpy.m_type;
|
||||
switch(m_type) {
|
||||
case bsBox: m_bed.box = std::move(cpy.m_bed.box); break;
|
||||
case bsCircle: m_bed.circ = std::move(cpy.m_bed.circ); break;
|
||||
case bsIrregular: m_bed.polygon = std::move(cpy.m_bed.polygon); break;
|
||||
case bsInfinite: m_bed.infbed = std::move(cpy.m_bed.infbed); break;
|
||||
case bsUnknown: break;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
BedShapeHint &operator=(const BedShapeHint &cpy);
|
||||
BedShapeHint& operator=(BedShapeHint &&cpy);
|
||||
|
||||
BedShapes get_type() const { return m_type; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user