diff options
author | bubnikv <bubnikv@gmail.com> | 2018-08-17 16:53:43 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2018-08-17 16:53:43 +0300 |
commit | 65011f93827a6e10757faef3d14ee068d9da8c94 (patch) | |
tree | 987d53bee4ebfa5d5dddbc3a14811c26953b2aa1 /xs/src/slic3r/GUI | |
parent | 1ba64da3fee97433d6b580aae8fc8e9875143a66 (diff) |
Removed the x(), y(), z() Point/Pointf/Point3/Pointf3 accessors.
Diffstat (limited to 'xs/src/slic3r/GUI')
-rw-r--r-- | xs/src/slic3r/GUI/2DBed.cpp | 64 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/3DScene.cpp | 96 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/3DScene.hpp | 20 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/BedShapeDialog.cpp | 20 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/Field.cpp | 12 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/GLCanvas3D.cpp | 148 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/GLGizmo.cpp | 68 |
7 files changed, 214 insertions, 214 deletions
diff --git a/xs/src/slic3r/GUI/2DBed.cpp b/xs/src/slic3r/GUI/2DBed.cpp index 03791bdb2..5f087a881 100644 --- a/xs/src/slic3r/GUI/2DBed.cpp +++ b/xs/src/slic3r/GUI/2DBed.cpp @@ -34,15 +34,15 @@ void Bed_2D::repaint() auto cbb = BoundingBoxf(Pointf(0, 0),Pointf(cw, ch)); // leave space for origin point - cbb.min.x() += 4; + cbb.min(0) += 4; cbb.max -= Vec2d(4., 4.); // leave space for origin label - cbb.max.y() -= 13; + cbb.max(1) -= 13; // read new size - cw = cbb.size().x(); - ch = cbb.size().y(); + cw = cbb.size()(0); + ch = cbb.size()(1); auto ccenter = cbb.center(); @@ -51,19 +51,19 @@ void Bed_2D::repaint() 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 - auto bw = bb.size().x(); - auto bh = bb.size().y(); + 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( - ccenter.x() - bcenter.x() * sfactor, - ccenter.y() - bcenter.y() * sfactor + ccenter(0) - bcenter(0) * sfactor, + ccenter(1) - bcenter(1) * sfactor ); m_scale_factor = sfactor; - m_shift = Pointf(shift.x() + cbb.min.x(), - shift.y() - (cbb.max.y() - GetSize().GetHeight())); + m_shift = Pointf(shift(0) + cbb.min(0), + shift(1) - (cbb.max(1) - GetSize().GetHeight())); // draw bed fill dc.SetBrush(wxBrush(wxColour(255, 255, 255), wxSOLID)); @@ -71,19 +71,19 @@ void Bed_2D::repaint() for (auto pt: m_bed_shape) { Point pt_pix = to_pixels(pt); - pt_list.push_back(new wxPoint(pt_pix.x(), pt_pix.y())); + pt_list.push_back(new wxPoint(pt_pix(0), pt_pix(1))); } dc.DrawPolygon(&pt_list, 0, 0); // draw grid auto step = 10; // 1cm grid Polylines polylines; - for (auto x = bb.min.x() - fmod(bb.min.x(), step) + step; x < bb.max.x(); x += step) { - Polyline pl = Polyline::new_scale({ Pointf(x, bb.min.y()), Pointf(x, bb.max.y()) }); + for (auto x = bb.min(0) - fmod(bb.min(0), step) + step; x < bb.max(0); x += step) { + Polyline pl = Polyline::new_scale({ Pointf(x, bb.min(1)), Pointf(x, bb.max(1)) }); polylines.push_back(pl); } - for (auto y = bb.min.y() - fmod(bb.min.y(), step) + step; y < bb.max.y(); y += step) { - polylines.push_back(Polyline::new_scale({ Pointf(bb.min.x(), y), Pointf(bb.max.x(), y) })); + 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 = intersection_pl(polylines, bed_polygon); @@ -93,7 +93,7 @@ void Bed_2D::repaint() for (size_t i = 0; i < pl.points.size()-1; i++){ Point pt1 = to_pixels(Pointf::new_unscale(pl.points[i])); Point pt2 = to_pixels(Pointf::new_unscale(pl.points[i+1])); - dc.DrawLine(pt1.x(), pt1.y(), pt2.x(), pt2.y()); + dc.DrawLine(pt1(0), pt1(1), pt2(0), pt2(1)); } } @@ -109,36 +109,36 @@ void Bed_2D::repaint() 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.x() + axes_len, origin_px.y()); - dc.DrawLine(wxPoint(origin_px.x(), origin_px.y()), wxPoint(x_end.x(), x_end.y())); + auto x_end = Pointf(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 = x_end; - end.x() -= arrow_len; + end(0) -= arrow_len; end.rotate(angle, x_end); - dc.DrawLine(wxPoint(x_end.x(), x_end.y()), wxPoint(end.x(), end.y())); + dc.DrawLine(wxPoint(x_end(0), x_end(1)), wxPoint(end(0), end(1))); } dc.SetPen(wxPen(wxColour(0, 255, 0), 2, wxSOLID)); // green - auto y_end = Pointf(origin_px.x(), origin_px.y() - axes_len); - dc.DrawLine(wxPoint(origin_px.x(), origin_px.y()), wxPoint(y_end.x(), y_end.y())); + auto y_end = Pointf(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 = y_end; - end.y() += arrow_len; + end(1) += arrow_len; end.rotate(angle, y_end); - dc.DrawLine(wxPoint(y_end.x(), y_end.y()), wxPoint(end.x(), end.y())); + dc.DrawLine(wxPoint(y_end(0), y_end(1)), wxPoint(end(0), end(1))); } // draw origin dc.SetPen(wxPen(wxColour(0, 0, 0), 1, wxSOLID)); dc.SetBrush(wxBrush(wxColour(0, 0, 0), wxSOLID)); - dc.DrawCircle(origin_px.x(), origin_px.y(), 3); + dc.DrawCircle(origin_px(0), origin_px(1), 3); static const auto origin_label = wxString("(0,0)"); dc.SetTextForeground(wxColour(0, 0, 0)); dc.SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL)); auto extent = dc.GetTextExtent(origin_label); - const auto origin_label_x = origin_px.x() <= cw / 2 ? origin_px.x() + 1 : origin_px.x() - 1 - extent.GetWidth(); - const auto origin_label_y = origin_px.y() <= ch / 2 ? origin_px.y() + 1 : origin_px.y() - 1 - extent.GetHeight(); + const auto origin_label_x = origin_px(0) <= cw / 2 ? origin_px(0) + 1 : origin_px(0) - 1 - extent.GetWidth(); + const auto origin_label_y = origin_px(1) <= ch / 2 ? origin_px(1) + 1 : origin_px(1) - 1 - extent.GetHeight(); dc.DrawText(origin_label, origin_label_x, origin_label_y); // draw current position @@ -146,10 +146,10 @@ void Bed_2D::repaint() auto pos_px = to_pixels(m_pos); dc.SetPen(wxPen(wxColour(200, 0, 0), 2, wxSOLID)); dc.SetBrush(wxBrush(wxColour(200, 0, 0), wxTRANSPARENT)); - dc.DrawCircle(pos_px.x(), pos_px.y(), 5); + dc.DrawCircle(pos_px(0), pos_px(1), 5); - dc.DrawLine(pos_px.x() - 15, pos_px.y(), pos_px.x() + 15, pos_px.y()); - dc.DrawLine(pos_px.x(), pos_px.y() - 15, pos_px.x(), pos_px.y() + 15); + dc.DrawLine(pos_px(0) - 15, pos_px(1), pos_px(0) + 15, pos_px(1)); + dc.DrawLine(pos_px(0), pos_px(1) - 15, pos_px(0), pos_px(1) + 15); } m_painted = true; @@ -158,7 +158,7 @@ void Bed_2D::repaint() // convert G - code coordinates into pixels Point Bed_2D::to_pixels(Pointf point){ auto p = point * m_scale_factor + m_shift; - return Point(p.x(), GetSize().GetHeight() - p.y()); + return Point(p(0), GetSize().GetHeight() - p(1)); } void Bed_2D::mouse_event(wxMouseEvent event){ @@ -176,7 +176,7 @@ void Bed_2D::mouse_event(wxMouseEvent event){ // convert pixels into G - code coordinates Pointf Bed_2D::to_units(Point point){ - return (Pointf(point.x(), GetSize().GetHeight() - point.y()) - m_shift) * (1. / m_scale_factor); + return (Pointf(point(0), GetSize().GetHeight() - point(1)) - m_shift) * (1. / m_scale_factor); } void Bed_2D::set_pos(Pointf pos){ diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 68e11e378..03d997ae6 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -279,7 +279,7 @@ const Transform3f& GLVolume::world_matrix() const if (m_dirty) { m_world_mat = Transform3f::Identity(); - m_world_mat.translate(Vec3f(m_origin.x(), m_origin.y(), 0)); + m_world_mat.translate(Vec3f(m_origin(0), m_origin(1), 0)); m_world_mat.rotate(Eigen::AngleAxisf(m_angle_z, Vec3f::UnitZ())); m_world_mat.scale(m_scale_factor); m_dirty = false; @@ -338,7 +338,7 @@ void GLVolume::render() const ::glCullFace(GL_BACK); ::glPushMatrix(); - ::glTranslated(m_origin.x(), m_origin.y(), m_origin.z()); + ::glTranslated(m_origin(0), m_origin(1), m_origin(2)); ::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f); ::glScalef(m_scale_factor, m_scale_factor, m_scale_factor); if (this->indexed_vertex_array.indexed()) @@ -372,7 +372,7 @@ void GLVolume::render_using_layer_height() const glUniform1f(z_texture_row_to_normalized_id, (GLfloat)(1.0f / layer_height_texture_height())); if (z_cursor_id >= 0) - glUniform1f(z_cursor_id, (GLfloat)(layer_height_texture_data.print_object->model_object()->bounding_box().max.z() * layer_height_texture_data.z_cursor_relative)); + glUniform1f(z_cursor_id, (GLfloat)(layer_height_texture_data.print_object->model_object()->bounding_box().max(2) * layer_height_texture_data.z_cursor_relative)); if (z_cursor_band_width_id >= 0) glUniform1f(z_cursor_band_width_id, (GLfloat)layer_height_texture_data.edit_band_width); @@ -464,7 +464,7 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c ::glNormalPointer(GL_FLOAT, 6 * sizeof(float), nullptr); ::glPushMatrix(); - ::glTranslated(m_origin.x(), m_origin.y(), m_origin.z()); + ::glTranslated(m_origin(0), m_origin(1), m_origin(2)); ::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f); ::glScalef(m_scale_factor, m_scale_factor, m_scale_factor); @@ -509,7 +509,7 @@ void GLVolume::render_legacy() const ::glNormalPointer(GL_FLOAT, 6 * sizeof(float), indexed_vertex_array.vertices_and_normals_interleaved.data()); ::glPushMatrix(); - ::glTranslated(m_origin.x(), m_origin.y(), m_origin.z()); + ::glTranslated(m_origin(0), m_origin(1), m_origin(2)); ::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f); ::glScalef(m_scale_factor, m_scale_factor, m_scale_factor); @@ -524,7 +524,7 @@ void GLVolume::render_legacy() const double GLVolume::layer_height_texture_z_to_row_id() const { - return (this->layer_height_texture.get() == nullptr) ? 0.0 : double(this->layer_height_texture->cells - 1) / (double(this->layer_height_texture->width) * this->layer_height_texture_data.print_object->model_object()->bounding_box().max.z()); + return (this->layer_height_texture.get() == nullptr) ? 0.0 : double(this->layer_height_texture->cells - 1) / (double(this->layer_height_texture->width) * this->layer_height_texture_data.print_object->model_object()->bounding_box().max(2)); } void GLVolume::generate_layer_height_texture(PrintObject *print_object, bool force) @@ -628,7 +628,7 @@ std::vector<int> GLVolumeCollection::load_object( } v.is_modifier = model_volume->modifier; v.outside_printer_detection_enabled = !model_volume->modifier; - v.set_origin(Pointf3(instance->offset.x(), instance->offset.y(), 0.0)); + v.set_origin(Pointf3(instance->offset(0), instance->offset(1), 0.0)); v.set_angle_z(instance->rotation); v.set_scale_factor(instance->scaling_factor); } @@ -742,9 +742,9 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M return false; BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); - BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x()), unscale(bed_box_2D.min.y()), 0.0), Pointf3(unscale(bed_box_2D.max.x()), unscale(bed_box_2D.max.y()), config->opt_float("max_print_height"))); + BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min(0)), unscale(bed_box_2D.min(1)), 0.0), Pointf3(unscale(bed_box_2D.max(0)), unscale(bed_box_2D.max(1)), config->opt_float("max_print_height"))); // Allow the objects to protrude below the print bed - print_volume.min.z() = -1e10; + print_volume.min(2) = -1e10; ModelInstance::EPrintVolumeState state = ModelInstance::PVS_Inside; bool all_contained = true; @@ -939,8 +939,8 @@ static void thick_lines_to_indexed_vertex_array( Pointf b2 = b; { double dist = 0.5 * width; // scaled - double dx = dist * v.x(); - double dy = dist * v.y(); + double dx = dist * v(0); + double dy = dist * v(1); a1 += Vectorf(+dy, -dx); a2 += Vectorf(-dy, +dx); b1 += Vectorf(+dy, -dx); @@ -949,7 +949,7 @@ static void thick_lines_to_indexed_vertex_array( // calculate new XY normals Vector n = line.normal(); - Vectorf3 xy_right_normal = Vectorf3::new_unscale(n.x(), n.y(), 0); + Vectorf3 xy_right_normal = Vectorf3::new_unscale(n(0), n(1), 0); xy_right_normal *= inv_len; int idx_a[4]; @@ -968,7 +968,7 @@ static void thick_lines_to_indexed_vertex_array( // Share top / bottom vertices if possible. if (is_first) { idx_a[TOP] = idx_last++; - volume.push_geometry(a.x(), a.y(), top_z , 0., 0., 1.); + volume.push_geometry(a(0), a(1), top_z , 0., 0., 1.); } else { idx_a[TOP] = idx_prev[TOP]; } @@ -976,11 +976,11 @@ static void thick_lines_to_indexed_vertex_array( if (is_first || bottom_z_different) { // Start of the 1st line segment or a change of the layer thickness while maintaining the print_z. idx_a[BOTTOM] = idx_last ++; - volume.push_geometry(a.x(), a.y(), bottom_z, 0., 0., -1.); + volume.push_geometry(a(0), a(1), bottom_z, 0., 0., -1.); idx_a[LEFT ] = idx_last ++; - volume.push_geometry(a2.x(), a2.y(), middle_z, -xy_right_normal.x(), -xy_right_normal.y(), -xy_right_normal.z()); + volume.push_geometry(a2(0), a2(1), middle_z, -xy_right_normal(0), -xy_right_normal(1), -xy_right_normal(2)); idx_a[RIGHT] = idx_last ++; - volume.push_geometry(a1.x(), a1.y(), middle_z, xy_right_normal.x(), xy_right_normal.y(), xy_right_normal.z()); + volume.push_geometry(a1(0), a1(1), middle_z, xy_right_normal(0), xy_right_normal(1), xy_right_normal(2)); } else { idx_a[BOTTOM] = idx_prev[BOTTOM]; @@ -1001,9 +1001,9 @@ static void thick_lines_to_indexed_vertex_array( { // Allocate new left / right points for the start of this segment as these points will receive their own normals to indicate a sharp turn. idx_a[RIGHT] = idx_last++; - volume.push_geometry(a1.x(), a1.y(), middle_z, xy_right_normal.x(), xy_right_normal.y(), xy_right_normal.z()); + volume.push_geometry(a1(0), a1(1), middle_z, xy_right_normal(0), xy_right_normal(1), xy_right_normal(2)); idx_a[LEFT] = idx_last++; - volume.push_geometry(a2.x(), a2.y(), middle_z, -xy_right_normal.x(), -xy_right_normal.y(), -xy_right_normal.z()); + volume.push_geometry(a2(0), a2(1), middle_z, -xy_right_normal(0), -xy_right_normal(1), -xy_right_normal(2)); } } if (v_dot > 0.9) { @@ -1029,17 +1029,17 @@ static void thick_lines_to_indexed_vertex_array( float *p_left_prev = n_left_prev + 3; float *n_right_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6; float *p_right_prev = n_right_prev + 3; - p_left_prev [0] = float(a2.x()); - p_left_prev [1] = float(a2.y()); - p_right_prev[0] = float(a1.x()); - p_right_prev[1] = float(a1.y()); - xy_right_normal.x() += n_right_prev[0]; - xy_right_normal.y() += n_right_prev[1]; + p_left_prev [0] = float(a2(0)); + p_left_prev [1] = float(a2(1)); + p_right_prev[0] = float(a1(0)); + p_right_prev[1] = float(a1(1)); + xy_right_normal(0) += n_right_prev[0]; + xy_right_normal(1) += n_right_prev[1]; xy_right_normal *= 1. / xy_right_normal.norm(); - n_left_prev [0] = float(-xy_right_normal.x()); - n_left_prev [1] = float(-xy_right_normal.y()); - n_right_prev[0] = float( xy_right_normal.x()); - n_right_prev[1] = float( xy_right_normal.y()); + n_left_prev [0] = float(-xy_right_normal(0)); + n_left_prev [1] = float(-xy_right_normal(1)); + n_right_prev[0] = float( xy_right_normal(0)); + n_right_prev[1] = float( xy_right_normal(1)); idx_a[LEFT ] = idx_prev[LEFT ]; idx_a[RIGHT] = idx_prev[RIGHT]; } @@ -1080,20 +1080,20 @@ static void thick_lines_to_indexed_vertex_array( idx_b[TOP] = idx_initial[TOP]; } else { idx_b[TOP] = idx_last ++; - volume.push_geometry(b.x(), b.y(), top_z , 0., 0., 1.); + volume.push_geometry(b(0), b(1), top_z , 0., 0., 1.); } if (is_closing && (width == width_initial) && (bottom_z == bottom_z_initial)) { idx_b[BOTTOM] = idx_initial[BOTTOM]; } else { idx_b[BOTTOM] = idx_last ++; - volume.push_geometry(b.x(), b.y(), bottom_z, 0., 0., -1.); + volume.push_geometry(b(0), b(1), bottom_z, 0., 0., -1.); } // Generate new vertices for the end of this line segment. idx_b[LEFT ] = idx_last ++; - volume.push_geometry(b2.x(), b2.y(), middle_z, -xy_right_normal.x(), -xy_right_normal.y(), -xy_right_normal.z()); + volume.push_geometry(b2(0), b2(1), middle_z, -xy_right_normal(0), -xy_right_normal(1), -xy_right_normal(2)); idx_b[RIGHT ] = idx_last ++; - volume.push_geometry(b1.x(), b1.y(), middle_z, xy_right_normal.x(), xy_right_normal.y(), xy_right_normal.z()); + volume.push_geometry(b1(0), b1(1), middle_z, xy_right_normal(0), xy_right_normal(1), xy_right_normal(2)); memcpy(idx_prev, idx_b, 4 * sizeof(int)); bottom_z_prev = bottom_z; @@ -1178,10 +1178,10 @@ static void thick_lines_to_indexed_vertex_array(const Lines3& lines, Vectorf3 n_right; Vectorf3 unit_positive_z(0.0, 0.0, 1.0); - if ((line.a.x() == line.b.x()) && (line.a.y() == line.b.y())) + if ((line.a(0) == line.b(0)) && (line.a(1) == line.b(1))) { // vertical segment - n_right = (line.a.z() < line.b.z()) ? Vectorf3(-1.0, 0.0, 0.0) : Vectorf3(1.0, 0.0, 0.0); + n_right = (line.a(2) < line.b(2)) ? Vectorf3(-1.0, 0.0, 0.0) : Vectorf3(1.0, 0.0, 0.0); n_top = Vectorf3(0.0, 1.0, 0.0); } else @@ -1212,8 +1212,8 @@ static void thick_lines_to_indexed_vertex_array(const Lines3& lines, int idx_b[4]; int idx_last = int(volume.vertices_and_normals_interleaved.size() / 6); - bool z_different = (z_prev != l_a.z()); - z_prev = l_b.z(); + bool z_different = (z_prev != l_a(2)); + z_prev = l_b(2); // Share top / bottom vertices if possible. if (ii == 0) @@ -1282,25 +1282,25 @@ static void thick_lines_to_indexed_vertex_array(const Lines3& lines, // updates previous line normals float* normal_left_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[LEFT] * 6; - normal_left_prev[0] = float(average_n_left.x()); - normal_left_prev[1] = float(average_n_left.y()); - normal_left_prev[2] = float(average_n_left.z()); + normal_left_prev[0] = float(average_n_left(0)); + normal_left_prev[1] = float(average_n_left(1)); + normal_left_prev[2] = float(average_n_left(2)); float* normal_right_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6; - normal_right_prev[0] = float(average_n_right.x()); - normal_right_prev[1] = float(average_n_right.y()); - normal_right_prev[2] = float(average_n_right.z()); + normal_right_prev[0] = float(average_n_right(0)); + normal_right_prev[1] = float(average_n_right(1)); + normal_right_prev[2] = float(average_n_right(2)); // updates previous line's vertices around b float* b_left_prev = normal_left_prev + 3; - b_left_prev[0] = float(a[LEFT].x()); - b_left_prev[1] = float(a[LEFT].y()); - b_left_prev[2] = float(a[LEFT].z()); + b_left_prev[0] = float(a[LEFT](0)); + b_left_prev[1] = float(a[LEFT](1)); + b_left_prev[2] = float(a[LEFT](2)); float* b_right_prev = normal_right_prev + 3; - b_right_prev[0] = float(a[RIGHT].x()); - b_right_prev[1] = float(a[RIGHT].y()); - b_right_prev[2] = float(a[RIGHT].z()); + b_right_prev[0] = float(a[RIGHT](0)); + b_right_prev[1] = float(a[RIGHT](1)); + b_right_prev[2] = float(a[RIGHT](2)); idx_a[LEFT] = idx_prev[LEFT]; idx_a[RIGHT] = idx_prev[RIGHT]; diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 1d56f2f73..d0e78b9b7 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -120,7 +120,7 @@ public: } inline void push_geometry(const Pointf3& p, const Vectorf3& n) { - push_geometry(p.x(), p.y(), p.z(), n.x(), n.y(), n.z()); + push_geometry(p(0), p(1), p(2), n(0), n(1), n(2)); } inline void push_triangle(int idx1, int idx2, int idx3) { @@ -176,17 +176,17 @@ public: BoundingBoxf3 bbox; if (! this->vertices_and_normals_interleaved.empty()) { bbox.defined = true; - bbox.min.x() = bbox.max.x() = this->vertices_and_normals_interleaved[3]; - bbox.min.y() = bbox.max.y() = this->vertices_and_normals_interleaved[4]; - bbox.min.z() = bbox.max.z() = this->vertices_and_normals_interleaved[5]; + bbox.min(0) = bbox.max(0) = this->vertices_and_normals_interleaved[3]; + bbox.min(1) = bbox.max(1) = this->vertices_and_normals_interleaved[4]; + bbox.min(2) = bbox.max(2) = this->vertices_and_normals_interleaved[5]; for (size_t i = 9; i < this->vertices_and_normals_interleaved.size(); i += 6) { const float *verts = this->vertices_and_normals_interleaved.data() + i; - bbox.min.x() = std::min<coordf_t>(bbox.min.x(), verts[0]); - bbox.min.y() = std::min<coordf_t>(bbox.min.y(), verts[1]); - bbox.min.z() = std::min<coordf_t>(bbox.min.z(), verts[2]); - bbox.max.x() = std::max<coordf_t>(bbox.max.x(), verts[0]); - bbox.max.y() = std::max<coordf_t>(bbox.max.y(), verts[1]); - bbox.max.z() = std::max<coordf_t>(bbox.max.z(), verts[2]); + bbox.min(0) = std::min<coordf_t>(bbox.min(0), verts[0]); + bbox.min(1) = std::min<coordf_t>(bbox.min(1), verts[1]); + bbox.min(2) = std::min<coordf_t>(bbox.min(2), verts[2]); + bbox.max(0) = std::max<coordf_t>(bbox.max(0), verts[0]); + bbox.max(1) = std::max<coordf_t>(bbox.max(1), verts[1]); + bbox.max(2) = std::max<coordf_t>(bbox.max(2), verts[2]); } } return bbox; diff --git a/xs/src/slic3r/GUI/BedShapeDialog.cpp b/xs/src/slic3r/GUI/BedShapeDialog.cpp index 0cdc1df43..0f2e84754 100644 --- a/xs/src/slic3r/GUI/BedShapeDialog.cpp +++ b/xs/src/slic3r/GUI/BedShapeDialog.cpp @@ -148,13 +148,13 @@ void BedShapePanel::set_shape(ConfigOptionPoints* points) // find origin // the || 0 hack prevents "-0" which might confuse the user int x_min, x_max, y_min, y_max; - x_max = x_min = points->values[0].x(); - y_max = y_min = points->values[0].y(); + x_max = x_min = points->values[0](0); + y_max = y_min = points->values[0](1); for (auto pt : points->values){ - if (x_min > pt.x()) x_min = pt.x(); - if (x_max < pt.x()) x_max = pt.x(); - if (y_min > pt.y()) y_min = pt.y(); - if (y_max < pt.y()) y_max = pt.y(); + if (x_min > pt(0)) x_min = pt(0); + if (x_max < pt(0)) x_max = pt(0); + if (y_min > pt(1)) y_min = pt(1); + if (y_max < pt(1)) y_max = pt(1); } if (x_min < 0) x_min = 0; if (x_max < 0) x_max = 0; @@ -242,8 +242,8 @@ void BedShapePanel::update_shape() catch (const std::exception &e){ return;} - auto x = rect_size.x(); - auto y = rect_size.y(); + auto x = rect_size(0); + auto y = rect_size(1); // empty strings or '-' or other things if (x == 0 || y == 0) return; double x0 = 0.0; @@ -251,8 +251,8 @@ void BedShapePanel::update_shape() double x1 = x; double y1 = y; - auto dx = rect_origin.x(); - auto dy = rect_origin.y(); + auto dx = rect_origin(0); + auto dy = rect_origin(1); x0 -= dx; x1 -= dx; diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 4efda6398..8892583a2 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -629,9 +629,9 @@ void PointCtrl::BUILD() wxSize field_size(40, -1); auto default_pt = static_cast<ConfigOptionPoints*>(m_opt.default_value)->values.at(0); - double val = default_pt.x(); + double val = default_pt(0); wxString X = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None); - val = default_pt.y(); + val = default_pt(1); wxString Y = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None); x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size); @@ -656,9 +656,9 @@ void PointCtrl::set_value(const Pointf& value, bool change_event) { m_disable_change_event = !change_event; - double val = value.x(); + double val = value(0); x_textctrl->SetValue(val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None)); - val = value.y(); + val = value(1); y_textctrl->SetValue(val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None)); m_disable_change_event = false; @@ -683,9 +683,9 @@ boost::any& PointCtrl::get_value() Pointf ret_point; double val; x_textctrl->GetValue().ToDouble(&val); - ret_point.x() = val; + ret_point(0) = val; y_textctrl->GetValue().ToDouble(&val); - ret_point.y() = val; + ret_point(1) = val; return m_value = ret_point; } diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 91a8ea890..8d82d1111 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -68,8 +68,8 @@ bool GeometryBuffer::set_from_triangles(const Polygons& triangles, float z, bool if (generate_tex_coords) m_tex_coords = std::vector<float>(t_size, 0.0f); - float min_x = (float)unscale(triangles[0].points[0].x()); - float min_y = (float)unscale(triangles[0].points[0].y()); + float min_x = (float)unscale(triangles[0].points[0](0)); + float min_y = (float)unscale(triangles[0].points[0](1)); float max_x = min_x; float max_y = min_y; @@ -80,8 +80,8 @@ bool GeometryBuffer::set_from_triangles(const Polygons& triangles, float z, bool for (unsigned int v = 0; v < 3; ++v) { const Point& p = t.points[v]; - float x = (float)unscale(p.x()); - float y = (float)unscale(p.y()); + float x = (float)unscale(p(0)); + float y = (float)unscale(p(1)); m_vertices[v_coord++] = x; m_vertices[v_coord++] = y; @@ -134,11 +134,11 @@ bool GeometryBuffer::set_from_lines(const Lines& lines, float z) unsigned int coord = 0; for (const Line& l : lines) { - m_vertices[coord++] = (float)unscale(l.a.x()); - m_vertices[coord++] = (float)unscale(l.a.y()); + m_vertices[coord++] = (float)unscale(l.a(0)); + m_vertices[coord++] = (float)unscale(l.a(1)); m_vertices[coord++] = z; - m_vertices[coord++] = (float)unscale(l.b.x()); - m_vertices[coord++] = (float)unscale(l.b.y()); + m_vertices[coord++] = (float)unscale(l.b(0)); + m_vertices[coord++] = (float)unscale(l.b(1)); m_vertices[coord++] = z; } @@ -312,7 +312,7 @@ void GLCanvas3D::Bed::set_shape(const Pointfs& shape) ExPolygon poly; for (const Pointf& p : m_shape) { - poly.contour.append(Point(scale_(p.x()), scale_(p.y()))); + poly.contour.append(Point(scale_(p(0)), scale_(p(1)))); } _calc_triangles(poly); @@ -366,7 +366,7 @@ void GLCanvas3D::Bed::_calc_bounding_box() m_bounding_box = BoundingBoxf3(); for (const Pointf& p : m_shape) { - m_bounding_box.merge(Pointf3(p.x(), p.y(), 0.0)); + m_bounding_box.merge(Pointf3(p(0), p(1), 0.0)); } } @@ -382,18 +382,18 @@ void GLCanvas3D::Bed::_calc_triangles(const ExPolygon& poly) void GLCanvas3D::Bed::_calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox) { Polylines axes_lines; - for (coord_t x = bed_bbox.min.x(); x <= bed_bbox.max.x(); x += scale_(10.0)) + for (coord_t x = bed_bbox.min(0); x <= bed_bbox.max(0); x += scale_(10.0)) { Polyline line; - line.append(Point(x, bed_bbox.min.y())); - line.append(Point(x, bed_bbox.max.y())); + line.append(Point(x, bed_bbox.min(1))); + line.append(Point(x, bed_bbox.max(1))); axes_lines.push_back(line); } - for (coord_t y = bed_bbox.min.y(); y <= bed_bbox.max.y(); y += scale_(10.0)) + for (coord_t y = bed_bbox.min(1); y <= bed_bbox.max(1); y += scale_(10.0)) { Polyline line; - line.append(Point(bed_bbox.min.x(), y)); - line.append(Point(bed_bbox.max.x(), y)); + line.append(Point(bed_bbox.min(0), y)); + line.append(Point(bed_bbox.max(0), y)); axes_lines.push_back(line); } @@ -597,12 +597,12 @@ void GLCanvas3D::Axes::render(bool depth_test) const ::glBegin(GL_LINES); // draw line for x axis ::glColor3f(1.0f, 0.0f, 0.0f); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y(), (GLfloat)origin.z()); - ::glVertex3f((GLfloat)origin.x() + length, (GLfloat)origin.y(), (GLfloat)origin.z()); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2)); + ::glVertex3f((GLfloat)origin(0) + length, (GLfloat)origin(1), (GLfloat)origin(2)); // draw line for y axis ::glColor3f(0.0f, 1.0f, 0.0f); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y(), (GLfloat)origin.z()); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y() + length, (GLfloat)origin.z()); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2)); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1) + length, (GLfloat)origin(2)); ::glEnd(); // draw line for Z axis // (re-enable depth test so that axis is correctly shown when objects are behind it) @@ -611,8 +611,8 @@ void GLCanvas3D::Axes::render(bool depth_test) const ::glBegin(GL_LINES); ::glColor3f(0.0f, 0.0f, 1.0f); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y(), (GLfloat)origin.z()); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y(), (GLfloat)origin.z() + length); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2)); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2) + length); ::glEnd(); } @@ -646,10 +646,10 @@ void GLCanvas3D::CuttingPlane::_render_plane(const BoundingBoxf3& bb) const ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); float margin = 20.0f; - float min_x = bb.min.x() - margin; - float max_x = bb.max.x() + margin; - float min_y = bb.min.y() - margin; - float max_y = bb.max.y() + margin; + float min_x = bb.min(0) - margin; + float max_x = bb.max(0) + margin; + float min_y = bb.min(1) - margin; + float max_y = bb.max(1) + margin; ::glBegin(GL_QUADS); ::glColor4f(0.8f, 0.8f, 0.8f, 0.5f); @@ -860,8 +860,8 @@ float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas) { const Point& mouse_pos = canvas.get_local_mouse_position(); const Rect& rect = get_bar_rect_screen(canvas); - float x = (float)mouse_pos.x(); - float y = (float)mouse_pos.y(); + float x = (float)mouse_pos(0); + float y = (float)mouse_pos(1); float t = rect.get_top(); float b = rect.get_bottom(); @@ -970,7 +970,7 @@ void GLCanvas3D::LayersEditing::_render_reset_texture(const Rect& reset_rect) co void GLCanvas3D::LayersEditing::_render_active_object_annotations(const GLCanvas3D& canvas, const GLVolume& volume, const PrintObject& print_object, const Rect& bar_rect) const { - float max_z = print_object.model_object()->bounding_box().max.z(); + float max_z = print_object.model_object()->bounding_box().max(2); m_shader.start_using(); @@ -1031,7 +1031,7 @@ void GLCanvas3D::LayersEditing::_render_profile(const PrintObject& print_object, // Make the vertical bar a bit wider so the layer height curve does not touch the edge of the bar region. layer_height_max *= 1.12; - coordf_t max_z = unscale(print_object.size.z()); + coordf_t max_z = unscale(print_object.size(2)); double layer_height = dynamic_cast<const ConfigOptionFloat*>(print_object.config.option("layer_height"))->value; float l = bar_rect.get_left(); float w = bar_rect.get_right() - l; @@ -1951,15 +1951,15 @@ void GLCanvas3D::set_auto_bed_shape() Pointfs bed_shape; bed_shape.reserve(4); - bed_shape.emplace_back(center.x() - max_size, center.y() - max_size); - bed_shape.emplace_back(center.x() + max_size, center.y() - max_size); - bed_shape.emplace_back(center.x() + max_size, center.y() + max_size); - bed_shape.emplace_back(center.x() - max_size, center.y() + max_size); + bed_shape.emplace_back(center(0) - max_size, center(1) - max_size); + bed_shape.emplace_back(center(0) + max_size, center(1) - max_size); + bed_shape.emplace_back(center(0) + max_size, center(1) + max_size); + bed_shape.emplace_back(center(0) - max_size, center(1) + max_size); set_bed_shape(bed_shape); // Set the origin for painting of the coordinate system axes. - m_axes.origin = Pointf3(center.x(), center.y(), (coordf_t)GROUND_Z); + m_axes.origin = Pointf3(center(0), center(1), (coordf_t)GROUND_Z); } void GLCanvas3D::set_axes_length(float length) @@ -2283,7 +2283,7 @@ void GLCanvas3D::reload_scene(bool force) if ((extruders_count > 1) && semm && wt && !co) { // Height of a print (Show at least a slab) - coordf_t height = std::max(m_model->bounding_box().max.z(), 10.0); + coordf_t height = std::max(m_model->bounding_box().max(2), 10.0); float x = dynamic_cast<const ConfigOptionFloat*>(m_config->option("wipe_tower_x"))->value; float y = dynamic_cast<const ConfigOptionFloat*>(m_config->option("wipe_tower_y"))->value; @@ -3031,14 +3031,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // on a volume or not. int volume_idx = m_hover_volume_id; m_layers_editing.state = LayersEditing::Unknown; - if ((layer_editing_object_idx != -1) && m_layers_editing.bar_rect_contains(*this, pos.x(), pos.y())) + if ((layer_editing_object_idx != -1) && m_layers_editing.bar_rect_contains(*this, pos(0), pos(1))) { // A volume is selected and the mouse is inside the layer thickness bar. // Start editing the layer height. m_layers_editing.state = LayersEditing::Editing; _perform_layer_editing_action(&evt); } - else if ((layer_editing_object_idx != -1) && m_layers_editing.reset_rect_contains(*this, pos.x(), pos.y())) + else if ((layer_editing_object_idx != -1) && m_layers_editing.reset_rect_contains(*this, pos(0), pos(1))) { if (evt.LeftDown()) { @@ -3121,7 +3121,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) { // if right clicking on volume, propagate event through callback if (m_volumes.volumes[volume_idx]->hover) - m_on_right_click_callback.call(pos.x(), pos.y()); + m_on_right_click_callback.call(pos(0), pos(1)); } } } @@ -3133,16 +3133,16 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // Get new position at the same Z of the initial click point. float z0 = 0.0f; float z1 = 1.0f; - Pointf3 cur_pos = Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D.z()); + Pointf3 cur_pos = Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D(2)); // Clip the new position, so the object center remains close to the bed. cur_pos += m_mouse.drag.volume_center_offset; - Point cur_pos2(scale_(cur_pos.x()), scale_(cur_pos.y())); + Point cur_pos2(scale_(cur_pos(0)), scale_(cur_pos(1))); if (!m_bed.contains(cur_pos2)) { Point ip = m_bed.point_projection(cur_pos2); - cur_pos.x() = unscale(ip.x()); - cur_pos.y() = unscale(ip.y()); + cur_pos(0) = unscale(ip(0)); + cur_pos(1) = unscale(ip(1)); } cur_pos -= m_mouse.drag.volume_center_offset; @@ -3169,7 +3169,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // Apply new temporary volume origin and ignore Z. for (GLVolume* v : volumes) - v->set_origin(v->get_origin() + Vectorf3(vector.x(), vector.y(), 0.0)); + v->set_origin(v->get_origin() + Vectorf3(vector(0), vector(1), 0.0)); m_mouse.drag.start_position_3D = cur_pos; m_gizmos.refresh(); @@ -3181,7 +3181,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_mouse.dragging = true; const Pointf3& cur_pos = _mouse_to_bed_3d(pos); - m_gizmos.update(Pointf(cur_pos.x(), cur_pos.y())); + m_gizmos.update(Pointf(cur_pos(0), cur_pos(1))); std::vector<GLVolume*> volumes; if (m_mouse.drag.gizmo_volume_idx != -1) @@ -3230,7 +3230,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) { const BoundingBoxf3& bb = volumes[0]->transformed_bounding_box(); const Pointf3& size = bb.size(); - m_on_update_geometry_info_callback.call(size.x(), size.y(), size.z(), m_gizmos.get_scale()); + m_on_update_geometry_info_callback.call(size(0), size(1), size(2), m_gizmos.get_scale()); } if ((m_gizmos.get_current_type() != Gizmos::Rotate) && (volumes.size() > 1)) @@ -3253,14 +3253,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (m_mouse.is_start_position_3D_defined()) { const Pointf3& orig = m_mouse.drag.start_position_3D; - m_camera.phi += (((float)pos.x() - (float)orig.x()) * TRACKBALLSIZE); - m_camera.set_theta(m_camera.get_theta() - ((float)pos.y() - (float)orig.y()) * TRACKBALLSIZE); + m_camera.phi += (((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE); + m_camera.set_theta(m_camera.get_theta() - ((float)pos(1) - (float)orig(1)) * TRACKBALLSIZE); m_on_viewport_changed_callback.call(); m_dirty = true; } - m_mouse.drag.start_position_3D = Pointf3((coordf_t)pos.x(), (coordf_t)pos.y(), 0.0); + m_mouse.drag.start_position_3D = Pointf3((coordf_t)pos(0), (coordf_t)pos(1), 0.0); } else if (evt.MiddleIsDown() || evt.RightIsDown()) { @@ -3349,7 +3349,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } else if (evt.Moving()) { - m_mouse.position = Pointf((coordf_t)pos.x(), (coordf_t)pos.y()); + m_mouse.position = Pointf((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; @@ -3547,13 +3547,13 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co std::vector<Pointf3> vertices; vertices.reserve(8); vertices.push_back(bb_min); - vertices.emplace_back(bb_max.x(), bb_min.y(), bb_min.z()); - vertices.emplace_back(bb_max.x(), bb_max.y(), bb_min.z()); - vertices.emplace_back(bb_min.x(), bb_max.y(), bb_min.z()); - vertices.emplace_back(bb_min.x(), bb_min.y(), bb_max.z()); - vertices.emplace_back(bb_max.x(), bb_min.y(), bb_max.z()); + vertices.emplace_back(bb_max(0), bb_min(1), bb_min(2)); + vertices.emplace_back(bb_max(0), bb_max(1), bb_min(2)); + vertices.emplace_back(bb_min(0), bb_max(1), bb_min(2)); + vertices.emplace_back(bb_min(0), bb_min(1), bb_max(2)); + vertices.emplace_back(bb_max(0), bb_min(1), bb_max(2)); vertices.push_back(bb_max); - vertices.emplace_back(bb_min.x(), bb_max.y(), bb_max.z()); + vertices.emplace_back(bb_min(0), bb_max(1), bb_max(2)); coordf_t max_x = 0.0; coordf_t max_y = 0.0; @@ -3564,7 +3564,7 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co for (const Pointf3 v : vertices) { // project vertex on the plane perpendicular to camera forward axis - Pointf3 pos(v.x() - bb_center.x(), v.y() - bb_center.y(), v.z() - bb_center.z()); + Pointf3 pos(v(0) - bb_center(0), v(1) - bb_center(1), v(2) - bb_center(2)); Pointf3 proj_on_plane = pos - pos.dot(forward) * forward; // calculates vertex coordinate along camera xy axes @@ -3648,7 +3648,7 @@ void GLCanvas3D::_camera_tranform() const ::glRotatef(m_camera.phi, 0.0f, 0.0f, 1.0f); // yaw Pointf3 neg_target = - m_camera.target; - ::glTranslatef((GLfloat)neg_target.x(), (GLfloat)neg_target.y(), (GLfloat)neg_target.z()); + ::glTranslatef((GLfloat)neg_target(0), (GLfloat)neg_target(1), (GLfloat)neg_target(2)); } void GLCanvas3D::_picking_pass() const @@ -3678,7 +3678,7 @@ void GLCanvas3D::_picking_pass() const const Size& cnv_size = get_canvas_size(); GLubyte color[4]; - ::glReadPixels(pos.x(), cnv_size.get_height() - pos.y() - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color); + ::glReadPixels(pos(0), cnv_size.get_height() - pos(1) - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color); int volume_id = color[0] + color[1] * 256 + color[2] * 256 * 256; m_hover_volume_id = -1; @@ -3773,7 +3773,7 @@ void GLCanvas3D::_render_objects() const if (m_config != nullptr) { const BoundingBoxf3& bed_bb = m_bed.get_bounding_box(); - m_volumes.set_print_box((float)bed_bb.min.x(), (float)bed_bb.min.y(), 0.0f, (float)bed_bb.max.x(), (float)bed_bb.max.y(), (float)m_config->opt_float("max_print_height")); + m_volumes.set_print_box((float)bed_bb.min(0), (float)bed_bb.min(1), 0.0f, (float)bed_bb.max(0), (float)bed_bb.max(1), (float)m_config->opt_float("max_print_height")); m_volumes.check_outside_state(m_config, nullptr); } // do not cull backfaces to show broken geometry, if any @@ -3980,7 +3980,7 @@ void GLCanvas3D::_perform_layer_editing_action(wxMouseEvent* evt) { const Rect& rect = LayersEditing::get_bar_rect_screen(*this); float b = rect.get_bottom(); - m_layers_editing.last_z = unscale(selected_obj->size.z()) * (b - evt->GetY() - 1.0f) / (b - rect.get_top()); + m_layers_editing.last_z = unscale(selected_obj->size(2)) * (b - evt->GetY() - 1.0f) / (b - rect.get_top()); m_layers_editing.last_action = evt->ShiftDown() ? (evt->RightIsDown() ? 3 : 2) : (evt->RightIsDown() ? 0 : 1); } @@ -4024,15 +4024,15 @@ Pointf3 GLCanvas3D::_mouse_to_3d(const Point& mouse_pos, float* z) GLdouble projection_matrix[16]; ::glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix); - GLint y = viewport[3] - (GLint)mouse_pos.y(); + GLint y = viewport[3] - (GLint)mouse_pos(1); GLfloat mouse_z; if (z == nullptr) - ::glReadPixels((GLint)mouse_pos.x(), y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, (void*)&mouse_z); + ::glReadPixels((GLint)mouse_pos(0), y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, (void*)&mouse_z); else mouse_z = *z; GLdouble out_x, out_y, out_z; - ::gluUnProject((GLdouble)mouse_pos.x(), (GLdouble)y, (GLdouble)mouse_z, modelview_matrix, projection_matrix, viewport, &out_x, &out_y, &out_z); + ::gluUnProject((GLdouble)mouse_pos(0), (GLdouble)y, (GLdouble)mouse_z, modelview_matrix, projection_matrix, viewport, &out_x, &out_y, &out_z); return Pointf3((coordf_t)out_x, (coordf_t)out_y, (coordf_t)out_z); } @@ -4383,7 +4383,7 @@ bool GLCanvas3D::_travel_paths_by_type(const GCodePreviewData& preview_data) TypesList::iterator type = std::find(types.begin(), types.end(), Type(polyline.type)); if (type != types.end()) { - type->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min.z())); + type->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min(2))); type->volume->offsets.push_back(type->volume->indexed_vertex_array.quad_indices.size()); type->volume->offsets.push_back(type->volume->indexed_vertex_array.triangle_indices.size()); @@ -4449,7 +4449,7 @@ bool GLCanvas3D::_travel_paths_by_feedrate(const GCodePreviewData& preview_data) FeedratesList::iterator feedrate = std::find(feedrates.begin(), feedrates.end(), Feedrate(polyline.feedrate)); if (feedrate != feedrates.end()) { - feedrate->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min.z())); + feedrate->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min(2))); feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.quad_indices.size()); feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.triangle_indices.size()); @@ -4515,7 +4515,7 @@ bool GLCanvas3D::_travel_paths_by_tool(const GCodePreviewData& preview_data, con ToolsList::iterator tool = std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id)); if (tool != tools.end()) { - tool->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min.z())); + tool->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min(2))); tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.quad_indices.size()); tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.triangle_indices.size()); @@ -4540,11 +4540,11 @@ void GLCanvas3D::_load_gcode_retractions(const GCodePreviewData& preview_data) m_volumes.volumes.emplace_back(volume); GCodePreviewData::Retraction::PositionsList copy(preview_data.retraction.positions); - std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position.z() < p2.position.z(); }); + std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position(2) < p2.position(2); }); for (const GCodePreviewData::Retraction::Position& position : copy) { - volume->print_zs.push_back(unscale(position.position.z())); + volume->print_zs.push_back(unscale(position.position(2))); volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size()); volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size()); @@ -4571,11 +4571,11 @@ void GLCanvas3D::_load_gcode_unretractions(const GCodePreviewData& preview_data) m_volumes.volumes.emplace_back(volume); GCodePreviewData::Retraction::PositionsList copy(preview_data.unretraction.positions); - std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position.z() < p2.position.z(); }); + std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position(2) < p2.position(2); }); for (const GCodePreviewData::Retraction::Position& position : copy) { - volume->print_zs.push_back(unscale(position.position.z())); + volume->print_zs.push_back(unscale(position.position(2))); volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size()); volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size()); @@ -4615,7 +4615,7 @@ void GLCanvas3D::_load_shells() } // adds wipe tower's volume - coordf_t max_z = m_print->objects[0]->model_object()->get_model()->bounding_box().max.z(); + coordf_t max_z = m_print->objects[0]->model_object()->get_model()->bounding_box().max(2); const PrintConfig& config = m_print->config; unsigned int extruders_count = config.nozzle_diameter.size(); if ((extruders_count > 1) && config.single_extruder_multi_material && config.wipe_tower && !config.complete_objects) { @@ -4710,7 +4710,7 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs) // Move a regular object. ModelObject* model_object = m_model->objects[obj_idx]; const Pointf3& origin = volume->get_origin(); - model_object->instances[instance_idx]->offset = Pointf(origin.x(), origin.y()); + model_object->instances[instance_idx]->offset = Pointf(origin(0), origin(1)); model_object->invalidate_bounding_box(); object_moved = true; } @@ -4723,7 +4723,7 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs) m_on_instance_moved_callback.call(); if (wipe_tower_origin != Pointf3(0.0, 0.0, 0.0)) - m_on_wipe_tower_moved_callback.call(wipe_tower_origin.x(), wipe_tower_origin.y()); + m_on_wipe_tower_moved_callback.call(wipe_tower_origin(0), wipe_tower_origin(1)); } void GLCanvas3D::_on_select(int volume_idx) diff --git a/xs/src/slic3r/GUI/GLGizmo.cpp b/xs/src/slic3r/GUI/GLGizmo.cpp index c52230c61..f4f947d9c 100644 --- a/xs/src/slic3r/GUI/GLGizmo.cpp +++ b/xs/src/slic3r/GUI/GLGizmo.cpp @@ -35,7 +35,7 @@ void GLGizmoBase::Grabber::render(bool hover) const float angle_z_in_deg = angle_z * 180.0f / (float)PI; ::glPushMatrix(); - ::glTranslatef((GLfloat)center.x(), (GLfloat)center.y(), 0.0f); + ::glTranslatef((GLfloat)center(0), (GLfloat)center(1), 0.0f); ::glRotatef((GLfloat)angle_z_in_deg, 0.0f, 0.0f, 1.0f); ::glDisable(GL_CULL_FACE); @@ -266,7 +266,7 @@ void GLGizmoRotate::on_render(const BoundingBoxf3& box) const m_center = box.center().xy(); if (!m_keep_radius) { - m_radius = Offset + ::sqrt(sqr(0.5f * size.x()) + sqr(0.5f * size.y())); + m_radius = Offset + ::sqrt(sqr(0.5f * size(0)) + sqr(0.5f * size(1))); m_keep_radius = true; } @@ -299,8 +299,8 @@ void GLGizmoRotate::_render_circle() const for (unsigned int i = 0; i < ScaleStepsCount; ++i) { float angle = (float)i * ScaleStepRad; - float x = m_center.x() + ::cos(angle) * m_radius; - float y = m_center.y() + ::sin(angle) * m_radius; + float x = m_center(0) + ::cos(angle) * m_radius; + float y = m_center(1) + ::sin(angle) * m_radius; ::glVertex3f((GLfloat)x, (GLfloat)y, 0.0f); } ::glEnd(); @@ -317,10 +317,10 @@ void GLGizmoRotate::_render_scale() const float angle = (float)i * ScaleStepRad; float cosa = ::cos(angle); float sina = ::sin(angle); - float in_x = m_center.x() + cosa * m_radius; - float in_y = m_center.y() + sina * m_radius; - float out_x = (i % ScaleLongEvery == 0) ? m_center.x() + cosa * out_radius_long : m_center.x() + cosa * out_radius_short; - float out_y = (i % ScaleLongEvery == 0) ? m_center.y() + sina * out_radius_long : m_center.y() + sina * out_radius_short; + float in_x = m_center(0) + cosa * m_radius; + float in_y = m_center(1) + sina * m_radius; + float out_x = (i % ScaleLongEvery == 0) ? m_center(0) + cosa * out_radius_long : m_center(0) + cosa * out_radius_short; + float out_y = (i % ScaleLongEvery == 0) ? m_center(1) + sina * out_radius_long : m_center(1) + sina * out_radius_short; ::glVertex3f((GLfloat)in_x, (GLfloat)in_y, 0.0f); ::glVertex3f((GLfloat)out_x, (GLfloat)out_y, 0.0f); } @@ -340,10 +340,10 @@ void GLGizmoRotate::_render_snap_radii() const float angle = (float)i * step; float cosa = ::cos(angle); float sina = ::sin(angle); - float in_x = m_center.x() + cosa * in_radius; - float in_y = m_center.y() + sina * in_radius; - float out_x = m_center.x() + cosa * out_radius; - float out_y = m_center.y() + sina * out_radius; + float in_x = m_center(0) + cosa * in_radius; + float in_y = m_center(1) + sina * in_radius; + float out_x = m_center(0) + cosa * out_radius; + float out_y = m_center(1) + sina * out_radius; ::glVertex3f((GLfloat)in_x, (GLfloat)in_y, 0.0f); ::glVertex3f((GLfloat)out_x, (GLfloat)out_y, 0.0f); } @@ -353,8 +353,8 @@ void GLGizmoRotate::_render_snap_radii() const void GLGizmoRotate::_render_reference_radius() const { ::glBegin(GL_LINES); - ::glVertex3f((GLfloat)m_center.x(), (GLfloat)m_center.y(), 0.0f); - ::glVertex3f((GLfloat)m_center.x() + m_radius + GrabberOffset, (GLfloat)m_center.y(), 0.0f); + ::glVertex3f((GLfloat)m_center(0), (GLfloat)m_center(1), 0.0f); + ::glVertex3f((GLfloat)m_center(0) + m_radius + GrabberOffset, (GLfloat)m_center(1), 0.0f); ::glEnd(); } @@ -367,8 +367,8 @@ void GLGizmoRotate::_render_angle_z() const for (unsigned int i = 0; i <= AngleResolution; ++i) { float angle = (float)i * step_angle; - float x = m_center.x() + ::cos(angle) * ex_radius; - float y = m_center.y() + ::sin(angle) * ex_radius; + float x = m_center(0) + ::cos(angle) * ex_radius; + float y = m_center(1) + ::sin(angle) * ex_radius; ::glVertex3f((GLfloat)x, (GLfloat)y, 0.0f); } ::glEnd(); @@ -377,14 +377,14 @@ void GLGizmoRotate::_render_angle_z() const void GLGizmoRotate::_render_grabber() const { float grabber_radius = m_radius + GrabberOffset; - m_grabbers[0].center.x() = m_center.x() + ::cos(m_angle_z) * grabber_radius; - m_grabbers[0].center.y() = m_center.y() + ::sin(m_angle_z) * grabber_radius; + m_grabbers[0].center(0) = m_center(0) + ::cos(m_angle_z) * grabber_radius; + m_grabbers[0].center(1) = m_center(1) + ::sin(m_angle_z) * grabber_radius; m_grabbers[0].angle_z = m_angle_z; ::glColor3fv(BaseColor); ::glBegin(GL_LINES); - ::glVertex3f((GLfloat)m_center.x(), (GLfloat)m_center.y(), 0.0f); - ::glVertex3f((GLfloat)m_grabbers[0].center.x(), (GLfloat)m_grabbers[0].center.y(), 0.0f); + ::glVertex3f((GLfloat)m_center(0), (GLfloat)m_center(1), 0.0f); + ::glVertex3f((GLfloat)m_grabbers[0].center(0), (GLfloat)m_grabbers[0].center(1), 0.0f); ::glEnd(); ::memcpy((void*)m_grabbers[0].color, (const void*)HighlightColor, 3 * sizeof(float)); @@ -442,7 +442,7 @@ void GLGizmoScale::on_start_dragging() void GLGizmoScale::on_update(const Pointf& mouse_pos) { - Pointf center(0.5 * (m_grabbers[1].center.x() + m_grabbers[0].center.x()), 0.5 * (m_grabbers[3].center.y() + m_grabbers[0].center.y())); + 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))); coordf_t orig_len = (m_starting_drag_position - center).norm(); coordf_t new_len = (mouse_pos - center).norm(); @@ -455,19 +455,19 @@ void GLGizmoScale::on_render(const BoundingBoxf3& box) const { ::glDisable(GL_DEPTH_TEST); - coordf_t min_x = box.min.x() - (coordf_t)Offset; - coordf_t max_x = box.max.x() + (coordf_t)Offset; - coordf_t min_y = box.min.y() - (coordf_t)Offset; - coordf_t max_y = box.max.y() + (coordf_t)Offset; + coordf_t min_x = box.min(0) - (coordf_t)Offset; + coordf_t max_x = box.max(0) + (coordf_t)Offset; + coordf_t min_y = box.min(1) - (coordf_t)Offset; + coordf_t max_y = box.max(1) + (coordf_t)Offset; - m_grabbers[0].center.x() = min_x; - m_grabbers[0].center.y() = min_y; - m_grabbers[1].center.x() = max_x; - m_grabbers[1].center.y() = min_y; - m_grabbers[2].center.x() = max_x; - m_grabbers[2].center.y() = max_y; - m_grabbers[3].center.x() = min_x; - m_grabbers[3].center.y() = max_y; + m_grabbers[0].center(0) = min_x; + m_grabbers[0].center(1) = min_y; + m_grabbers[1].center(0) = max_x; + m_grabbers[1].center(1) = min_y; + m_grabbers[2].center(0) = max_x; + m_grabbers[2].center(1) = max_y; + m_grabbers[3].center(0) = min_x; + m_grabbers[3].center(1) = max_y; ::glLineWidth(2.0f); ::glColor3fv(BaseColor); @@ -475,7 +475,7 @@ void GLGizmoScale::on_render(const BoundingBoxf3& box) const ::glBegin(GL_LINE_LOOP); for (unsigned int i = 0; i < 4; ++i) { - ::glVertex3f((GLfloat)m_grabbers[i].center.x(), (GLfloat)m_grabbers[i].center.y(), 0.0f); + ::glVertex3f((GLfloat)m_grabbers[i].center(0), (GLfloat)m_grabbers[i].center(1), 0.0f); } ::glEnd(); |