mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 17:21:11 -06:00
Eradicated the Pointf class, replaced with Eigen Vector3d
This commit is contained in:
parent
cae0806112
commit
0b5b02e002
51 changed files with 267 additions and 293 deletions
|
|
@ -32,7 +32,7 @@ void Bed_2D::repaint()
|
|||
cw--;
|
||||
ch--;
|
||||
|
||||
auto cbb = BoundingBoxf(Pointf(0, 0),Pointf(cw, ch));
|
||||
auto cbb = BoundingBoxf(Vec2d(0, 0),Vec2d(cw, ch));
|
||||
// leave space for origin point
|
||||
cbb.min(0) += 4;
|
||||
cbb.max -= Vec2d(4., 4.);
|
||||
|
|
@ -50,19 +50,19 @@ void Bed_2D::repaint()
|
|||
auto bed_shape = m_bed_shape;
|
||||
auto bed_polygon = Polygon::new_scale(m_bed_shape);
|
||||
auto bb = BoundingBoxf(m_bed_shape);
|
||||
bb.merge(Pointf(0, 0)); // origin needs to be in the visible area
|
||||
bb.merge(Vec2d(0, 0)); // origin needs to be in the visible area
|
||||
auto bw = bb.size()(0);
|
||||
auto bh = bb.size()(1);
|
||||
auto bcenter = bb.center();
|
||||
|
||||
// calculate the scaling factor for fitting bed shape in canvas area
|
||||
auto sfactor = std::min(cw/bw, ch/bh);
|
||||
auto shift = Pointf(
|
||||
auto shift = Vec2d(
|
||||
ccenter(0) - bcenter(0) * sfactor,
|
||||
ccenter(1) - bcenter(1) * sfactor
|
||||
);
|
||||
m_scale_factor = sfactor;
|
||||
m_shift = Pointf(shift(0) + cbb.min(0),
|
||||
m_shift = Vec2d(shift(0) + cbb.min(0),
|
||||
shift(1) - (cbb.max(1) - GetSize().GetHeight()));
|
||||
|
||||
// draw bed fill
|
||||
|
|
@ -79,10 +79,10 @@ void Bed_2D::repaint()
|
|||
auto step = 10; // 1cm grid
|
||||
Polylines polylines;
|
||||
for (auto x = bb.min(0) - fmod(bb.min(0), step) + step; x < bb.max(0); x += step) {
|
||||
polylines.push_back(Polyline::new_scale({ Pointf(x, bb.min(1)), Pointf(x, bb.max(1)) }));
|
||||
polylines.push_back(Polyline::new_scale({ Vec2d(x, bb.min(1)), Vec2d(x, bb.max(1)) }));
|
||||
}
|
||||
for (auto y = bb.min(1) - fmod(bb.min(1), step) + step; y < bb.max(1); y += step) {
|
||||
polylines.push_back(Polyline::new_scale({ Pointf(bb.min(0), y), Pointf(bb.max(0), y) }));
|
||||
polylines.push_back(Polyline::new_scale({ Vec2d(bb.min(0), y), Vec2d(bb.max(0), y) }));
|
||||
}
|
||||
polylines = intersection_pl(polylines, bed_polygon);
|
||||
|
||||
|
|
@ -101,14 +101,14 @@ void Bed_2D::repaint()
|
|||
dc.SetBrush(wxBrush(wxColour(0, 0, 0), wxTRANSPARENT));
|
||||
dc.DrawPolygon(&pt_list, 0, 0);
|
||||
|
||||
auto origin_px = to_pixels(Pointf(0, 0));
|
||||
auto origin_px = to_pixels(Vec2d(0, 0));
|
||||
|
||||
// draw axes
|
||||
auto axes_len = 50;
|
||||
auto arrow_len = 6;
|
||||
auto arrow_angle = Geometry::deg2rad(45.0);
|
||||
dc.SetPen(wxPen(wxColour(255, 0, 0), 2, wxSOLID)); // red
|
||||
auto x_end = Pointf(origin_px(0) + axes_len, origin_px(1));
|
||||
auto x_end = Vec2d(origin_px(0) + axes_len, origin_px(1));
|
||||
dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(x_end(0), x_end(1)));
|
||||
for (auto angle : { -arrow_angle, arrow_angle }){
|
||||
auto end = Eigen::Translation2d(x_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- x_end) * Eigen::Vector2d(x_end(0) - arrow_len, x_end(1));
|
||||
|
|
@ -116,7 +116,7 @@ void Bed_2D::repaint()
|
|||
}
|
||||
|
||||
dc.SetPen(wxPen(wxColour(0, 255, 0), 2, wxSOLID)); // green
|
||||
auto y_end = Pointf(origin_px(0), origin_px(1) - axes_len);
|
||||
auto y_end = Vec2d(origin_px(0), origin_px(1) - axes_len);
|
||||
dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(y_end(0), y_end(1)));
|
||||
for (auto angle : { -arrow_angle, arrow_angle }) {
|
||||
auto end = Eigen::Translation2d(y_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- y_end) * Eigen::Vector2d(y_end(0), y_end(1) + arrow_len);
|
||||
|
|
@ -137,7 +137,7 @@ void Bed_2D::repaint()
|
|||
dc.DrawText(origin_label, origin_label_x, origin_label_y);
|
||||
|
||||
// draw current position
|
||||
if (m_pos!= Pointf(0, 0)) {
|
||||
if (m_pos!= Vec2d(0, 0)) {
|
||||
auto pos_px = to_pixels(m_pos);
|
||||
dc.SetPen(wxPen(wxColour(200, 0, 0), 2, wxSOLID));
|
||||
dc.SetBrush(wxBrush(wxColour(200, 0, 0), wxTRANSPARENT));
|
||||
|
|
@ -151,7 +151,7 @@ void Bed_2D::repaint()
|
|||
}
|
||||
|
||||
// convert G - code coordinates into pixels
|
||||
Point Bed_2D::to_pixels(Pointf point){
|
||||
Point Bed_2D::to_pixels(Vec2d point){
|
||||
auto p = point * m_scale_factor + m_shift;
|
||||
return Point(p(0), GetSize().GetHeight() - p(1));
|
||||
}
|
||||
|
|
@ -170,11 +170,11 @@ void Bed_2D::mouse_event(wxMouseEvent event){
|
|||
}
|
||||
|
||||
// convert pixels into G - code coordinates
|
||||
Pointf Bed_2D::to_units(Point point){
|
||||
return (Pointf(point(0), GetSize().GetHeight() - point(1)) - m_shift) * (1. / m_scale_factor);
|
||||
Vec2d Bed_2D::to_units(Point point){
|
||||
return (Vec2d(point(0), GetSize().GetHeight() - point(1)) - m_shift) * (1. / m_scale_factor);
|
||||
}
|
||||
|
||||
void Bed_2D::set_pos(Pointf pos){
|
||||
void Bed_2D::set_pos(Vec2d pos){
|
||||
m_pos = pos;
|
||||
Refresh();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ class Bed_2D : public wxPanel
|
|||
bool m_painted = false;
|
||||
bool m_interactive = false;
|
||||
double m_scale_factor;
|
||||
Pointf m_shift = Vec2d::Zero();
|
||||
Pointf m_pos = Vec2d::Zero();
|
||||
std::function<void(Pointf)> m_on_move = nullptr;
|
||||
Vec2d m_shift = Vec2d::Zero();
|
||||
Vec2d m_pos = Vec2d::Zero();
|
||||
std::function<void(Vec2d)> m_on_move = nullptr;
|
||||
|
||||
Point to_pixels(Pointf point);
|
||||
Pointf to_units(Point point);
|
||||
Point to_pixels(Vec2d point);
|
||||
Vec2d to_units(Point point);
|
||||
void repaint();
|
||||
void mouse_event(wxMouseEvent event);
|
||||
void set_pos(Pointf pos);
|
||||
void set_pos(Vec2d pos);
|
||||
|
||||
public:
|
||||
Bed_2D(wxWindow* parent)
|
||||
|
|
@ -41,7 +41,7 @@ public:
|
|||
}
|
||||
~Bed_2D(){}
|
||||
|
||||
std::vector<Pointf> m_bed_shape;
|
||||
std::vector<Vec2d> m_bed_shape;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -952,8 +952,8 @@ static void thick_lines_to_indexed_vertex_array(
|
|||
// right, left, top, bottom
|
||||
int idx_prev[4] = { -1, -1, -1, -1 };
|
||||
double bottom_z_prev = 0.;
|
||||
Pointf b1_prev(Vec2d::Zero());
|
||||
Vectorf v_prev(Vec2d::Zero());
|
||||
Vec2d b1_prev(Vec2d::Zero());
|
||||
Vec2d v_prev(Vec2d::Zero());
|
||||
int idx_initial[4] = { -1, -1, -1, -1 };
|
||||
double width_initial = 0.;
|
||||
double bottom_z_initial = 0.0;
|
||||
|
|
@ -973,23 +973,23 @@ static void thick_lines_to_indexed_vertex_array(
|
|||
bool is_last = (ii == lines_end - 1);
|
||||
bool is_closing = closed && is_last;
|
||||
|
||||
Vectorf v = unscale(line.vector());
|
||||
Vec2d v = unscale(line.vector());
|
||||
v *= inv_len;
|
||||
|
||||
Pointf a = unscale(line.a);
|
||||
Pointf b = unscale(line.b);
|
||||
Pointf a1 = a;
|
||||
Pointf a2 = a;
|
||||
Pointf b1 = b;
|
||||
Pointf b2 = b;
|
||||
Vec2d a = unscale(line.a);
|
||||
Vec2d b = unscale(line.b);
|
||||
Vec2d a1 = a;
|
||||
Vec2d a2 = a;
|
||||
Vec2d b1 = b;
|
||||
Vec2d b2 = b;
|
||||
{
|
||||
double dist = 0.5 * width; // scaled
|
||||
double dx = dist * v(0);
|
||||
double dy = dist * v(1);
|
||||
a1 += Vectorf(+dy, -dx);
|
||||
a2 += Vectorf(-dy, +dx);
|
||||
b1 += Vectorf(+dy, -dx);
|
||||
b2 += Vectorf(-dy, +dx);
|
||||
a1 += Vec2d(+dy, -dx);
|
||||
a2 += Vec2d(-dy, +dx);
|
||||
b1 += Vec2d(+dy, -dx);
|
||||
b2 += Vec2d(-dy, +dx);
|
||||
}
|
||||
|
||||
// calculate new XY normals
|
||||
|
|
@ -1064,7 +1064,7 @@ static void thick_lines_to_indexed_vertex_array(
|
|||
{
|
||||
// Create a sharp corner with an overshot and average the left / right normals.
|
||||
// At the crease angle of 45 degrees, the overshot at the corner will be less than (1-1/cos(PI/8)) = 8.2% over an arc.
|
||||
Pointf intersection(Vec2d::Zero());
|
||||
Vec2d intersection(Vec2d::Zero());
|
||||
Geometry::ray_ray_intersection(b1_prev, v_prev, a1, v, intersection);
|
||||
a1 = intersection;
|
||||
a2 = 2. * a - intersection;
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ void BedShapePanel::build_panel(ConfigOptionPoints* default_pt)
|
|||
auto optgroup = init_shape_options_page(_(L("Rectangular")));
|
||||
ConfigOptionDef def;
|
||||
def.type = coPoints;
|
||||
def.default_value = new ConfigOptionPoints{ Pointf(200, 200) };
|
||||
def.default_value = new ConfigOptionPoints{ Vec2d(200, 200) };
|
||||
def.label = L("Size");
|
||||
def.tooltip = L("Size in X and Y of the rectangular plate.");
|
||||
Option option(def, "rect_size");
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
def.type = coPoints;
|
||||
def.default_value = new ConfigOptionPoints{ Pointf(0, 0) };
|
||||
def.default_value = new ConfigOptionPoints{ Vec2d(0, 0) };
|
||||
def.label = L("Origin");
|
||||
def.tooltip = L("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle.");
|
||||
option = Option(def, "rect_origin");
|
||||
|
|
@ -159,11 +159,11 @@ void BedShapePanel::set_shape(ConfigOptionPoints* points)
|
|||
y_max = std::max(y_max, pt(1));
|
||||
}
|
||||
|
||||
auto origin = new ConfigOptionPoints{ Pointf(-x_min, -y_min) };
|
||||
auto origin = new ConfigOptionPoints{ Vec2d(-x_min, -y_min) };
|
||||
|
||||
m_shape_options_book->SetSelection(SHAPE_RECTANGULAR);
|
||||
auto optgroup = m_optgroups[SHAPE_RECTANGULAR];
|
||||
optgroup->set_value("rect_size", new ConfigOptionPoints{ Pointf(x_max - x_min, y_max - y_min) });//[x_max - x_min, y_max - y_min]);
|
||||
optgroup->set_value("rect_size", new ConfigOptionPoints{ Vec2d(x_max - x_min, y_max - y_min) });//[x_max - x_min, y_max - y_min]);
|
||||
optgroup->set_value("rect_origin", origin);
|
||||
update_shape();
|
||||
return;
|
||||
|
|
@ -206,8 +206,8 @@ void BedShapePanel::set_shape(ConfigOptionPoints* points)
|
|||
// Invalid polygon.Revert to default bed dimensions.
|
||||
m_shape_options_book->SetSelection(SHAPE_RECTANGULAR);
|
||||
auto optgroup = m_optgroups[SHAPE_RECTANGULAR];
|
||||
optgroup->set_value("rect_size", new ConfigOptionPoints{ Pointf(200, 200) });
|
||||
optgroup->set_value("rect_origin", new ConfigOptionPoints{ Pointf(0, 0) });
|
||||
optgroup->set_value("rect_size", new ConfigOptionPoints{ Vec2d(200, 200) });
|
||||
optgroup->set_value("rect_origin", new ConfigOptionPoints{ Vec2d(0, 0) });
|
||||
update_shape();
|
||||
return;
|
||||
}
|
||||
|
|
@ -230,15 +230,15 @@ void BedShapePanel::update_shape()
|
|||
{
|
||||
auto page_idx = m_shape_options_book->GetSelection();
|
||||
if (page_idx == SHAPE_RECTANGULAR) {
|
||||
Pointf rect_size(Vec2d::Zero());
|
||||
Pointf rect_origin(Vec2d::Zero());
|
||||
Vec2d rect_size(Vec2d::Zero());
|
||||
Vec2d rect_origin(Vec2d::Zero());
|
||||
try{
|
||||
rect_size = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_size")); }
|
||||
rect_size = boost::any_cast<Vec2d>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_size")); }
|
||||
catch (const std::exception &e){
|
||||
return;
|
||||
}
|
||||
try{
|
||||
rect_origin = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_origin"));
|
||||
rect_origin = boost::any_cast<Vec2d>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_origin"));
|
||||
}
|
||||
catch (const std::exception &e){
|
||||
return;}
|
||||
|
|
@ -259,10 +259,10 @@ void BedShapePanel::update_shape()
|
|||
x1 -= dx;
|
||||
y0 -= dy;
|
||||
y1 -= dy;
|
||||
m_canvas->m_bed_shape = { Pointf(x0, y0),
|
||||
Pointf(x1, y0),
|
||||
Pointf(x1, y1),
|
||||
Pointf(x0, y1)};
|
||||
m_canvas->m_bed_shape = { Vec2d(x0, y0),
|
||||
Vec2d(x1, y0),
|
||||
Vec2d(x1, y1),
|
||||
Vec2d(x0, y1)};
|
||||
}
|
||||
else if(page_idx == SHAPE_CIRCULAR) {
|
||||
double diameter;
|
||||
|
|
@ -276,10 +276,10 @@ void BedShapePanel::update_shape()
|
|||
auto r = diameter / 2;
|
||||
auto twopi = 2 * PI;
|
||||
auto edges = 60;
|
||||
std::vector<Pointf> points;
|
||||
std::vector<Vec2d> points;
|
||||
for (size_t i = 1; i <= 60; ++i){
|
||||
auto angle = i * twopi / edges;
|
||||
points.push_back(Pointf(r*cos(angle), r*sin(angle)));
|
||||
points.push_back(Vec2d(r*cos(angle), r*sin(angle)));
|
||||
}
|
||||
m_canvas->m_bed_shape = points;
|
||||
}
|
||||
|
|
@ -332,7 +332,7 @@ void BedShapePanel::load_stl()
|
|||
}
|
||||
|
||||
auto polygon = expolygons[0].contour;
|
||||
std::vector<Pointf> points;
|
||||
std::vector<Vec2d> points;
|
||||
for (auto pt : polygon.points)
|
||||
points.push_back(unscale(pt));
|
||||
m_canvas->m_bed_shape = points;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public:
|
|||
void load_stl();
|
||||
|
||||
// Returns the resulting bed shape polygon. This value will be stored to the ini file.
|
||||
std::vector<Pointf> GetValue() { return m_canvas->m_bed_shape; }
|
||||
std::vector<Vec2d> GetValue() { return m_canvas->m_bed_shape; }
|
||||
};
|
||||
|
||||
class BedShapeDialog : public wxDialog
|
||||
|
|
@ -46,7 +46,7 @@ public:
|
|||
~BedShapeDialog(){ }
|
||||
|
||||
void build_dialog(ConfigOptionPoints* default_pt);
|
||||
std::vector<Pointf> GetValue() { return m_panel->GetValue(); }
|
||||
std::vector<Vec2d> GetValue() { return m_panel->GetValue(); }
|
||||
};
|
||||
|
||||
} // GUI
|
||||
|
|
|
|||
|
|
@ -653,7 +653,7 @@ void PointCtrl::BUILD()
|
|||
y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y));
|
||||
}
|
||||
|
||||
void PointCtrl::set_value(const Pointf& value, bool change_event)
|
||||
void PointCtrl::set_value(const Vec2d& value, bool change_event)
|
||||
{
|
||||
m_disable_change_event = !change_event;
|
||||
|
||||
|
|
@ -667,8 +667,8 @@ void PointCtrl::set_value(const Pointf& value, bool change_event)
|
|||
|
||||
void PointCtrl::set_value(const boost::any& value, bool change_event)
|
||||
{
|
||||
Pointf pt(Vec2d::Zero());
|
||||
const Pointf *ptf = boost::any_cast<Pointf>(&value);
|
||||
Vec2d pt(Vec2d::Zero());
|
||||
const Vec2d *ptf = boost::any_cast<Vec2d>(&value);
|
||||
if (!ptf)
|
||||
{
|
||||
ConfigOptionPoints* pts = boost::any_cast<ConfigOptionPoints*>(value);
|
||||
|
|
@ -684,7 +684,7 @@ boost::any& PointCtrl::get_value()
|
|||
double x, y;
|
||||
x_textctrl->GetValue().ToDouble(&x);
|
||||
y_textctrl->GetValue().ToDouble(&y);
|
||||
return m_value = Pointf(x, y);
|
||||
return m_value = Vec2d(x, y);
|
||||
}
|
||||
|
||||
void StaticText::BUILD()
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ public:
|
|||
|
||||
void BUILD() override;
|
||||
|
||||
void set_value(const Pointf& value, bool change_event = false);
|
||||
void set_value(const Vec2d& value, bool change_event = false);
|
||||
void set_value(const boost::any& value, bool change_event = false);
|
||||
boost::any& get_value() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ bool GLCanvas3D::Bed::set_shape(const Pointfs& shape)
|
|||
_calc_bounding_box();
|
||||
|
||||
ExPolygon poly;
|
||||
for (const Pointf& p : m_shape)
|
||||
for (const Vec2d& p : m_shape)
|
||||
{
|
||||
poly.contour.append(Point(scale_(p(0)), scale_(p(1))));
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ void GLCanvas3D::Bed::render(float theta) const
|
|||
void GLCanvas3D::Bed::_calc_bounding_box()
|
||||
{
|
||||
m_bounding_box = BoundingBoxf3();
|
||||
for (const Pointf& p : m_shape)
|
||||
for (const Vec2d& p : m_shape)
|
||||
{
|
||||
m_bounding_box.merge(Vec3d(p(0), p(1), 0.0));
|
||||
}
|
||||
|
|
@ -1168,7 +1168,7 @@ void GLCanvas3D::Gizmos::set_enabled(bool enable)
|
|||
m_enabled = enable;
|
||||
}
|
||||
|
||||
void GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Pointf& mouse_pos)
|
||||
void GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos)
|
||||
{
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
|
@ -1187,14 +1187,14 @@ void GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Poin
|
|||
// we currently use circular icons for gizmo, so we check the radius
|
||||
if (it->second->get_state() != GLGizmoBase::On)
|
||||
{
|
||||
bool inside = (mouse_pos - Pointf(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size;
|
||||
bool inside = (mouse_pos - Vec2d(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size;
|
||||
it->second->set_state(inside ? GLGizmoBase::Hover : GLGizmoBase::Off);
|
||||
}
|
||||
top_y += (tex_size + OverlayGapY);
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::Gizmos::update_on_off_state(const GLCanvas3D& canvas, const Pointf& mouse_pos)
|
||||
void GLCanvas3D::Gizmos::update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos)
|
||||
{
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
|
@ -1211,7 +1211,7 @@ void GLCanvas3D::Gizmos::update_on_off_state(const GLCanvas3D& canvas, const Poi
|
|||
float half_tex_size = 0.5f * tex_size;
|
||||
|
||||
// we currently use circular icons for gizmo, so we check the radius
|
||||
if ((mouse_pos - Pointf(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size)
|
||||
if ((mouse_pos - Vec2d(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size)
|
||||
{
|
||||
if ((it->second->get_state() == GLGizmoBase::On))
|
||||
{
|
||||
|
|
@ -1260,7 +1260,7 @@ void GLCanvas3D::Gizmos::set_hover_id(int id)
|
|||
}
|
||||
}
|
||||
|
||||
bool GLCanvas3D::Gizmos::overlay_contains_mouse(const GLCanvas3D& canvas, const Pointf& mouse_pos) const
|
||||
bool GLCanvas3D::Gizmos::overlay_contains_mouse(const GLCanvas3D& canvas, const Vec2d& mouse_pos) const
|
||||
{
|
||||
if (!m_enabled)
|
||||
return false;
|
||||
|
|
@ -1277,7 +1277,7 @@ bool GLCanvas3D::Gizmos::overlay_contains_mouse(const GLCanvas3D& canvas, const
|
|||
float half_tex_size = 0.5f * tex_size;
|
||||
|
||||
// we currently use circular icons for gizmo, so we check the radius
|
||||
if ((mouse_pos - Pointf(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size)
|
||||
if ((mouse_pos - Vec2d(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size)
|
||||
return true;
|
||||
|
||||
top_y += (tex_size + OverlayGapY);
|
||||
|
|
@ -1295,7 +1295,7 @@ bool GLCanvas3D::Gizmos::grabber_contains_mouse() const
|
|||
return (curr != nullptr) ? (curr->get_hover_id() != -1) : false;
|
||||
}
|
||||
|
||||
void GLCanvas3D::Gizmos::update(const Pointf& mouse_pos)
|
||||
void GLCanvas3D::Gizmos::update(const Vec2d& mouse_pos)
|
||||
{
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
|
@ -2719,7 +2719,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
else if (evt.Leaving())
|
||||
{
|
||||
// to remove hover on objects when the mouse goes out of this canvas
|
||||
m_mouse.position = Pointf(-1.0, -1.0);
|
||||
m_mouse.position = Vec2d(-1.0, -1.0);
|
||||
m_dirty = true;
|
||||
}
|
||||
else if (evt.LeftDClick() && (m_hover_volume_id != -1))
|
||||
|
|
@ -2880,7 +2880,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
m_mouse.dragging = true;
|
||||
|
||||
const Vec3d& cur_pos = _mouse_to_bed_3d(pos);
|
||||
m_gizmos.update(Pointf(cur_pos(0), cur_pos(1)));
|
||||
m_gizmos.update(Vec2d(cur_pos(0), cur_pos(1)));
|
||||
|
||||
std::vector<GLVolume*> volumes;
|
||||
if (m_mouse.drag.gizmo_volume_idx != -1)
|
||||
|
|
@ -3052,7 +3052,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
}
|
||||
else if (evt.Moving())
|
||||
{
|
||||
m_mouse.position = Pointf((coordf_t)pos(0), (coordf_t)pos(1));
|
||||
m_mouse.position = Vec2d((coordf_t)pos(0), (coordf_t)pos(1));
|
||||
// Only refresh if picking is enabled, in that case the objects may get highlighted if the mouse cursor hovers over.
|
||||
if (m_picking_enabled)
|
||||
m_dirty = true;
|
||||
|
|
@ -3396,9 +3396,9 @@ void GLCanvas3D::_camera_tranform() const
|
|||
|
||||
void GLCanvas3D::_picking_pass() const
|
||||
{
|
||||
const Pointf& pos = m_mouse.position;
|
||||
const Vec2d& pos = m_mouse.position;
|
||||
|
||||
if (m_picking_enabled && !m_mouse.dragging && (pos != Pointf(DBL_MAX, DBL_MAX)))
|
||||
if (m_picking_enabled && !m_mouse.dragging && (pos != Vec2d(DBL_MAX, DBL_MAX)))
|
||||
{
|
||||
// Render the object for picking.
|
||||
// FIXME This cannot possibly work in a multi - sampled context as the color gets mangled by the anti - aliasing.
|
||||
|
|
@ -4870,7 +4870,7 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs)
|
|||
// Move a regular object.
|
||||
ModelObject* model_object = m_model->objects[obj_idx];
|
||||
const Vec3d& origin = volume->get_origin();
|
||||
model_object->instances[instance_idx]->offset = Pointf(origin(0), origin(1));
|
||||
model_object->instances[instance_idx]->offset = Vec2d(origin(0), origin(1));
|
||||
model_object->invalidate_bounding_box();
|
||||
object_moved = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ public:
|
|||
};
|
||||
|
||||
bool dragging;
|
||||
Pointf position;
|
||||
Vec2d position;
|
||||
Drag drag;
|
||||
|
||||
Mouse();
|
||||
|
|
@ -357,15 +357,15 @@ public:
|
|||
bool is_enabled() const;
|
||||
void set_enabled(bool enable);
|
||||
|
||||
void update_hover_state(const GLCanvas3D& canvas, const Pointf& mouse_pos);
|
||||
void update_on_off_state(const GLCanvas3D& canvas, const Pointf& mouse_pos);
|
||||
void update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos);
|
||||
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos);
|
||||
void reset_all_states();
|
||||
|
||||
void set_hover_id(int id);
|
||||
|
||||
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Pointf& mouse_pos) const;
|
||||
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Vec2d& mouse_pos) const;
|
||||
bool grabber_contains_mouse() const;
|
||||
void update(const Pointf& mouse_pos);
|
||||
void update(const Vec2d& mouse_pos);
|
||||
void refresh();
|
||||
|
||||
EType get_current_type() const;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const float GLGizmoBase::BaseColor[3] = { 1.0f, 1.0f, 1.0f };
|
|||
const float GLGizmoBase::HighlightColor[3] = { 1.0f, 0.38f, 0.0f };
|
||||
|
||||
GLGizmoBase::Grabber::Grabber()
|
||||
: center(Pointf(0.0, 0.0))
|
||||
: center(Vec2d(0.0, 0.0))
|
||||
, angle_z(0.0f)
|
||||
{
|
||||
color[0] = 1.0f;
|
||||
|
|
@ -124,7 +124,7 @@ void GLGizmoBase::stop_dragging()
|
|||
on_stop_dragging();
|
||||
}
|
||||
|
||||
void GLGizmoBase::update(const Pointf& mouse_pos)
|
||||
void GLGizmoBase::update(const Vec2d& mouse_pos)
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
on_update(mouse_pos);
|
||||
|
|
@ -187,7 +187,7 @@ const float GLGizmoRotate::GrabberOffset = 5.0f;
|
|||
GLGizmoRotate::GLGizmoRotate()
|
||||
: GLGizmoBase()
|
||||
, m_angle_z(0.0f)
|
||||
, m_center(Pointf(0.0, 0.0))
|
||||
, m_center(Vec2d(0.0, 0.0))
|
||||
, m_radius(0.0f)
|
||||
, m_keep_radius(false)
|
||||
{
|
||||
|
|
@ -232,10 +232,10 @@ void GLGizmoRotate::on_set_state()
|
|||
m_keep_radius = (m_state == On) ? false : true;
|
||||
}
|
||||
|
||||
void GLGizmoRotate::on_update(const Pointf& mouse_pos)
|
||||
void GLGizmoRotate::on_update(const Vec2d& mouse_pos)
|
||||
{
|
||||
Vectorf orig_dir(1.0, 0.0);
|
||||
Vectorf new_dir = (mouse_pos - m_center).normalized();
|
||||
Vec2d orig_dir(1.0, 0.0);
|
||||
Vec2d new_dir = (mouse_pos - m_center).normalized();
|
||||
coordf_t theta = ::acos(clamp(-1.0, 1.0, new_dir.dot(orig_dir)));
|
||||
if (cross2(orig_dir, new_dir) < 0.0)
|
||||
theta = 2.0 * (coordf_t)PI - theta;
|
||||
|
|
@ -440,9 +440,9 @@ void GLGizmoScale::on_start_dragging()
|
|||
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
||||
}
|
||||
|
||||
void GLGizmoScale::on_update(const Pointf& mouse_pos)
|
||||
void GLGizmoScale::on_update(const Vec2d& mouse_pos)
|
||||
{
|
||||
Pointf center(0.5 * (m_grabbers[1].center(0) + m_grabbers[0].center(0)), 0.5 * (m_grabbers[3].center(1) + m_grabbers[0].center(1)));
|
||||
Vec2d center(0.5 * (m_grabbers[1].center(0) + m_grabbers[0].center(0)), 0.5 * (m_grabbers[3].center(1) + m_grabbers[0].center(1)));
|
||||
|
||||
coordf_t orig_len = (m_starting_drag_position - center).norm();
|
||||
coordf_t new_len = (mouse_pos - center).norm();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ protected:
|
|||
static const float HalfSize;
|
||||
static const float HoverOffset;
|
||||
|
||||
Pointf center;
|
||||
Vec2d center;
|
||||
float angle_z;
|
||||
float color[3];
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ public:
|
|||
|
||||
void start_dragging();
|
||||
void stop_dragging();
|
||||
void update(const Pointf& mouse_pos);
|
||||
void update(const Vec2d& mouse_pos);
|
||||
void refresh();
|
||||
|
||||
void render(const BoundingBoxf3& box) const;
|
||||
|
|
@ -75,7 +75,7 @@ protected:
|
|||
virtual void on_set_state();
|
||||
virtual void on_start_dragging();
|
||||
virtual void on_stop_dragging();
|
||||
virtual void on_update(const Pointf& mouse_pos) = 0;
|
||||
virtual void on_update(const Vec2d& mouse_pos) = 0;
|
||||
virtual void on_refresh();
|
||||
virtual void on_render(const BoundingBoxf3& box) const = 0;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const = 0;
|
||||
|
|
@ -98,7 +98,7 @@ class GLGizmoRotate : public GLGizmoBase
|
|||
|
||||
float m_angle_z;
|
||||
|
||||
mutable Pointf m_center;
|
||||
mutable Vec2d m_center;
|
||||
mutable float m_radius;
|
||||
mutable bool m_keep_radius;
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ public:
|
|||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_set_state();
|
||||
virtual void on_update(const Pointf& mouse_pos);
|
||||
virtual void on_update(const Vec2d& mouse_pos);
|
||||
virtual void on_refresh();
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
|
|
@ -132,7 +132,7 @@ class GLGizmoScale : public GLGizmoBase
|
|||
float m_scale;
|
||||
float m_starting_scale;
|
||||
|
||||
Pointf m_starting_drag_position;
|
||||
Vec2d m_starting_drag_position;
|
||||
|
||||
public:
|
||||
GLGizmoScale();
|
||||
|
|
@ -143,7 +143,7 @@ public:
|
|||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_start_dragging();
|
||||
virtual void on_update(const Pointf& mouse_pos);
|
||||
virtual void on_update(const Vec2d& mouse_pos);
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -608,10 +608,10 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
|
|||
break;
|
||||
case coPoints:{
|
||||
if (opt_key.compare("bed_shape") == 0){
|
||||
config.option<ConfigOptionPoints>(opt_key)->values = boost::any_cast<std::vector<Pointf>>(value);
|
||||
config.option<ConfigOptionPoints>(opt_key)->values = boost::any_cast<std::vector<Vec2d>>(value);
|
||||
break;
|
||||
}
|
||||
ConfigOptionPoints* vec_new = new ConfigOptionPoints{ boost::any_cast<Pointf>(value) };
|
||||
ConfigOptionPoints* vec_new = new ConfigOptionPoints{ boost::any_cast<Vec2d>(value) };
|
||||
config.option<ConfigOptionPoints>(opt_key)->set_at(vec_new, opt_index, 0);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue