Fixed differences after rebase with master

This commit is contained in:
enricoturri1966 2022-06-06 14:55:38 +02:00
parent 00878fb330
commit c99e93c357
9 changed files with 80 additions and 77 deletions

View file

@ -408,14 +408,14 @@ class Transformation
public:
#if ENABLE_WORLD_COORDINATE
Transformation() = default;
explicit Transformation(const Transform3d & transform) : m_matrix(transform) {}
explicit Transformation(const Transform3d& transform) : m_matrix(transform) {}
Vec3d get_offset() const { return m_matrix.translation(); }
double get_offset(Axis axis) const { return get_offset()[axis]; }
Transform3d get_offset_matrix() const;
void set_offset(const Vec3d & offset) { m_matrix.translation() = offset; }
void set_offset(const Vec3d& offset) { m_matrix.translation() = offset; }
void set_offset(Axis axis, double offset) { m_matrix.translation()[axis] = offset; }
Vec3d get_rotation() const;
@ -424,12 +424,12 @@ public:
Transform3d get_rotation_matrix() const;
#else
Transformation();
explicit Transformation(const Transform3d & transform);
explicit Transformation(const Transform3d& transform);
const Vec3d& get_offset() const { return m_offset; }
double get_offset(Axis axis) const { return m_offset(axis); }
void set_offset(const Vec3d & offset);
void set_offset(const Vec3d& offset);
void set_offset(Axis axis, double offset);
const Vec3d& get_rotation() const { return m_rotation; }

View file

@ -7433,11 +7433,13 @@ bool GLCanvas3D::_is_any_volume_outside() const
void GLCanvas3D::_update_selection_from_hover()
{
bool ctrl_pressed = wxGetKeyState(WXK_CONTROL);
if (m_hover_volume_idxs.empty()) {
if (!ctrl_pressed && m_rectangle_selection.get_state() == GLSelectionRectangle::EState::Select)
m_selection.remove_all();
bool selection_changed = false;
return;
if (m_hover_volume_idxs.empty()) {
if (!ctrl_pressed && m_rectangle_selection.get_state() == GLSelectionRectangle::EState::Select) {
selection_changed = ! m_selection.is_empty();
m_selection.remove_all();
}
}
GLSelectionRectangle::EState state = m_rectangle_selection.get_state();
@ -7450,7 +7452,6 @@ void GLCanvas3D::_update_selection_from_hover()
}
}
bool selection_changed = false;
#if ENABLE_NEW_RECTANGLE_SELECTION
if (!m_rectangle_selection.is_empty()) {
#endif // ENABLE_NEW_RECTANGLE_SELECTION

View file

@ -57,16 +57,15 @@ public:
/// Detect reduction of move for wipetover on selection change
/// </summary>
void data_changed() override;
protected:
virtual bool on_init() override;
virtual std::string on_get_name() const override;
virtual bool on_is_activable() const override;
virtual void on_start_dragging() override;
virtual void on_stop_dragging() override;
virtual void on_dragging(const UpdateData& data) override;
virtual void on_render() override;
virtual void on_render_for_picking() override;
bool on_init() override;
std::string on_get_name() const override;
bool on_is_activable() const override;
void on_start_dragging() override;
void on_stop_dragging() override;
void on_dragging(const UpdateData& data) override;
void on_render() override;
void on_render_for_picking() override;
private:
double calc_projection(const UpdateData& data) const;
@ -79,10 +78,16 @@ private:
void calc_selection_box_and_center();
#endif // ENABLE_WORLD_COORDINATE
#if !ENABLE_GIZMO_GRABBER_REFACTOR
#if ENABLE_WORLD_COORDINATE && ENABLE_GL_SHADERS_ATTRIBUTES
void render_grabber_extension(Axis axis, const Transform3d& base_matrix, const BoundingBoxf3& box, bool picking);
#else
void render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking);
#endif // ENABLE_WORLD_COORDINATE && ENABLE_GL_SHADERS_ATTRIBUTES
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
};
} // namespace GUI
} // namespace Slic3r

View file

@ -393,7 +393,7 @@ void GLGizmoRotate::render_circle() const
#else
::glBegin(GL_LINE_LOOP);
for (unsigned int i = 0; i < ScaleStepsCount; ++i) {
const float angle = (float)i * ScaleStepRad;
const float angle = float(i) * ScaleStepRad;
const float x = ::cos(angle) * m_radius;
const float y = ::sin(angle) * m_radius;
const float z = 0.0f;
@ -595,7 +595,7 @@ void GLGizmoRotate::render_angle() const
#else
::glBegin(GL_LINE_STRIP);
for (unsigned int i = 0; i <= AngleResolution; ++i) {
const float angle = (float)i * step_angle;
const float angle = float(i) * step_angle;
const float x = ::cos(angle) * ex_radius;
const float y = ::sin(angle) * ex_radius;
const float z = 0.0f;

View file

@ -137,7 +137,7 @@ public:
GLGizmoRotate3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
Vec3d get_rotation() const { return Vec3d(m_gizmos[X].get_angle(), m_gizmos[Y].get_angle(), m_gizmos[Z].get_angle()); }
void set_rotation(const Vec3d& rotation) { m_gizmos[X].set_angle(rotation(0)); m_gizmos[Y].set_angle(rotation(1)); m_gizmos[Z].set_angle(rotation(2)); }
void set_rotation(const Vec3d& rotation) { m_gizmos[X].set_angle(rotation.x()); m_gizmos[Y].set_angle(rotation.y()); m_gizmos[Z].set_angle(rotation.z()); }
std::string get_tooltip() const override {
std::string tooltip = m_gizmos[X].get_tooltip();

View file

@ -11,7 +11,7 @@
#include <GL/glew.h>
#include <wx/utils.h>
#include <wx/utils.h>
namespace Slic3r {
namespace GUI {
@ -166,26 +166,25 @@ bool GLGizmoScale3D::on_is_activable() const
void GLGizmoScale3D::on_start_dragging()
{
if (m_hover_id != -1) {
m_starting.ctrl_down = wxGetKeyState(WXK_CONTROL);
assert(m_hover_id != -1);
m_starting.ctrl_down = wxGetKeyState(WXK_CONTROL);
#if ENABLE_WORLD_COORDINATE
m_starting.drag_position = m_grabbers_transform * m_grabbers[m_hover_id].center;
m_starting.box = m_bounding_box;
m_starting.center = m_center;
m_starting.instance_center = m_instance_center;
m_starting.drag_position = m_grabbers_transform * m_grabbers[m_hover_id].center;
m_starting.box = m_bounding_box;
m_starting.center = m_center;
m_starting.instance_center = m_instance_center;
#else
m_starting.drag_position = m_grabbers[m_hover_id].center;
m_starting.box = (m_starting.ctrl_down && m_hover_id < 6) ? m_bounding_box : m_parent.get_selection().get_bounding_box();
m_starting.drag_position = m_grabbers[m_hover_id].center;
m_starting.box = (m_starting.ctrl_down && m_hover_id < 6) ? m_bounding_box : m_parent.get_selection().get_bounding_box();
const Vec3d center = m_starting.box.center();
m_starting.pivots[0] = m_transform * Vec3d(m_starting.box.max.x(), center.y(), center.z());
m_starting.pivots[1] = m_transform * Vec3d(m_starting.box.min.x(), center.y(), center.z());
m_starting.pivots[2] = m_transform * Vec3d(center.x(), m_starting.box.max.y(), center.z());
m_starting.pivots[3] = m_transform * Vec3d(center.x(), m_starting.box.min.y(), center.z());
m_starting.pivots[4] = m_transform * Vec3d(center.x(), center.y(), m_starting.box.max.z());
m_starting.pivots[5] = m_transform * Vec3d(center.x(), center.y(), m_starting.box.min.z());
const Vec3d& center = m_starting.box.center();
m_starting.pivots[0] = m_transform * Vec3d(m_starting.box.max.x(), center.y(), center.z());
m_starting.pivots[1] = m_transform * Vec3d(m_starting.box.min.x(), center.y(), center.z());
m_starting.pivots[2] = m_transform * Vec3d(center.x(), m_starting.box.max.y(), center.z());
m_starting.pivots[3] = m_transform * Vec3d(center.x(), m_starting.box.min.y(), center.z());
m_starting.pivots[4] = m_transform * Vec3d(center.x(), center.y(), m_starting.box.max.z());
m_starting.pivots[5] = m_transform * Vec3d(center.x(), center.y(), m_starting.box.min.z());
#endif // ENABLE_WORLD_COORDINATE
}
}
void GLGizmoScale3D::on_stop_dragging() {
@ -230,11 +229,7 @@ void GLGizmoScale3D::on_render()
const Selection::IndicesList& idxs = selection.get_volume_idxs();
for (unsigned int idx : idxs) {
const GLVolume& v = *selection.get_volume(idx);
#if ENABLE_WORLD_COORDINATE
m_bounding_box.merge(v.transformed_convex_hull_bounding_box(v.get_volume_transformation().get_matrix()));
#else
m_bounding_box.merge(v.transformed_convex_hull_bounding_box(v.get_volume_transformation().get_matrix()));
#endif // ENABLE_WORLD_COORDINATE
}
#if ENABLE_WORLD_COORDINATE
@ -303,7 +298,7 @@ void GLGizmoScale3D::on_render()
const Vec3d offset_y = offsets_transform * Vec3d(0.0, (double)Offset, 0.0);
const Vec3d offset_z = offsets_transform * Vec3d(0.0, 0.0, (double)Offset);
bool ctrl_down = m_dragging && m_starting.ctrl_down || !m_dragging && wxGetKeyState(WXK_CONTROL);
const bool ctrl_down = (m_dragging && m_starting.ctrl_down) || (!m_dragging && wxGetKeyState(WXK_CONTROL));
#endif // ENABLE_WORLD_COORDINATE
#if ENABLE_WORLD_COORDINATE
@ -361,6 +356,7 @@ void GLGizmoScale3D::on_render()
m_grabbers[7].center = m_transform * Vec3d(m_bounding_box.max.x(), m_bounding_box.min.y(), center.z()) + offset_x - offset_y;
m_grabbers[8].center = m_transform * Vec3d(m_bounding_box.max.x(), m_bounding_box.max.y(), center.z()) + offset_x + offset_y;
m_grabbers[9].center = m_transform * Vec3d(m_bounding_box.min.x(), m_bounding_box.max.y(), center.z()) - offset_x + offset_y;
for (int i = 6; i < 10; ++i) {
m_grabbers[i].color = m_highlight_color;
}
@ -383,7 +379,7 @@ void GLGizmoScale3D::on_render()
transform_to_local(selection);
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
float grabber_mean_size = (float)((m_bounding_box.size().x() + m_bounding_box.size().y() + m_bounding_box.size().z()) / 3.0);
const float grabber_mean_size = (float)((m_bounding_box.size().x() + m_bounding_box.size().y() + m_bounding_box.size().z()) / 3.0);
#else
const BoundingBoxf3& selection_box = selection.get_bounding_box();
const float grabber_mean_size = (float)((selection_box.size().x() + selection_box.size().y() + selection_box.size().z()) / 3.0);
@ -597,7 +593,9 @@ void GLGizmoScale3D::on_render()
}
#if ENABLE_WORLD_COORDINATE
#if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix());
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#endif // ENABLE_WORLD_COORDINATE
}
@ -621,7 +619,7 @@ void GLGizmoScale3D::on_render_for_picking()
#else
render_grabbers_for_picking(m_parent.get_selection().get_bounding_box());
#endif // ENABLE_WORLD_COORDINATE
}
}
#if ENABLE_LEGACY_OPENGL_REMOVAL
void GLGizmoScale3D::render_grabbers_connection(unsigned int id_1, unsigned int id_2, const ColorRGBA& color)

View file

@ -3,7 +3,9 @@
#include "GLGizmoBase.hpp"
#if !ENABLE_WORLD_COORDINATE
#include "libslic3r/BoundingBox.hpp"
#endif // !ENABLE_WORLD_COORDINATE
namespace Slic3r {
namespace GUI {
@ -73,12 +75,6 @@ public:
void set_scale(const Vec3d& scale) { m_starting.scale = scale; m_scale = scale; }
#endif // ENABLE_WORLD_COORDINATE
#if ENABLE_WORLD_COORDINATE_SCALE_REVISITED
const Vec3d& get_starting_scale() const { return m_starting.scale; }
#endif // ENABLE_WORLD_COORDINATE_SCALE_REVISITED
const Vec3d& get_offset() const { return m_offset; }
std::string get_tooltip() const override;
/// <summary>

View file

@ -408,7 +408,8 @@ bool GLGizmosManager::gizmos_toolbar_on_mouse(const wxMouseEvent &mouse_event) {
// at this moment is enebled to process mouse move under gizmo
// tools bar e.g. Do not interupt dragging.
return false;
} else if (mc.exist_tooltip) {
}
else if (mc.exist_tooltip) {
// first move out of gizmo tool bar - unselect tooltip
mc.exist_tooltip = false;
update_hover_state(Undefined);
@ -423,10 +424,12 @@ bool GLGizmosManager::gizmos_toolbar_on_mouse(const wxMouseEvent &mouse_event) {
mc.left = true;
open_gizmo(gizmo);
return true;
} else if (mouse_event.RightDown()) {
}
else if (mouse_event.RightDown()) {
mc.right = true;
return true;
} else if (mouse_event.MiddleDown()) {
}
else if (mouse_event.MiddleDown()) {
mc.middle = true;
return true;
}
@ -441,14 +444,17 @@ bool GLGizmosManager::gizmos_toolbar_on_mouse(const wxMouseEvent &mouse_event) {
update_hover_state(Undefined);
}
// draging start on toolbar so no propagation into scene
return true;
} else if (mc.left && mouse_event.LeftUp()) {
return true;
}
else if (mc.left && mouse_event.LeftUp()) {
mc.left = false;
return true;
} else if (mc.right && mouse_event.RightUp()) {
}
else if (mc.right && mouse_event.RightUp()) {
mc.right = false;
return true;
} else if (mc.middle && mouse_event.MiddleUp()) {
}
else if (mc.middle && mouse_event.MiddleUp()) {
mc.middle = false;
return true;
}

View file

@ -9,7 +9,6 @@
#include "GUI_ObjectList.hpp"
#include "Camera.hpp"
#include "Plater.hpp"
#if ENABLE_WORLD_COORDINATE
#include "MsgDialog.hpp"
#endif // ENABLE_WORLD_COORDINATE
@ -786,7 +785,7 @@ void Selection::translate(const Vec3d& displacement, TransformationType transfor
assert(false);
}
else {
const Vec3d offset = transformation_type.local() ?
const Vec3d offset = transformation_type.local() ?
(Vec3d)(volume_data.get_volume_transform().get_rotation_matrix() * displacement) : displacement;
transform_volume_relative(v, volume_data, transformation_type, Geometry::translation_transform(offset));
}
@ -966,7 +965,6 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
const double z_diff = Geometry::rotation_diff_z(m_cache.volumes_data[i].get_instance_rotation(), new_rotation);
volume.set_instance_offset(m_cache.dragging_center + Eigen::AngleAxisd(z_diff, Vec3d::UnitZ()) * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
}
volume.set_instance_rotation(new_rotation);
object_instance_first[volume.object_idx()] = i;
}
@ -1048,7 +1046,7 @@ void Selection::flattening_rotate(const Vec3d& normal)
#else
const auto& voldata = m_cache.volumes_data[i];
Vec3d tnormal = (Geometry::assemble_transform(
Vec3d::Zero(), voldata.get_instance_rotation(),
Vec3d::Zero(), voldata.get_instance_rotation(),
voldata.get_instance_scaling_factor().cwiseInverse(), voldata.get_instance_mirror()) * normal).normalized();
// Additional rotation to align tnormal with the down vector in the world coordinate space.
auto extra_rotation = Eigen::Quaterniond().setFromTwoVectors(tnormal, -Vec3d::UnitZ());
@ -1897,6 +1895,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
render_sidebar_scale_hints(sidebar_field, *shader, base_matrix * orient_matrix);
else if (boost::starts_with(sidebar_field, "layer"))
render_sidebar_layers_hints(sidebar_field, *shader);
#if ENABLE_WORLD_COORDINATE
if (!boost::starts_with(sidebar_field, "layer")) {
if (!wxGetApp().obj_manipul()->is_world_coordinates())
@ -2014,8 +2013,7 @@ std::vector<unsigned int> Selection::get_volume_idxs_from_object(unsigned int ob
{
std::vector<unsigned int> idxs;
for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i)
{
for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i) {
if ((*m_volumes)[i]->object_idx() == (int)object_idx)
idxs.push_back(i);
}
@ -2027,10 +2025,9 @@ std::vector<unsigned int> Selection::get_volume_idxs_from_instance(unsigned int
{
std::vector<unsigned int> idxs;
for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i)
{
for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i) {
const GLVolume* v = (*m_volumes)[i];
if ((v->object_idx() == (int)object_idx) && (v->instance_idx() == (int)instance_idx))
if (v->object_idx() == (int)object_idx && v->instance_idx() == (int)instance_idx)
idxs.push_back(i);
}
@ -2044,9 +2041,8 @@ std::vector<unsigned int> Selection::get_volume_idxs_from_volume(unsigned int ob
for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i)
{
const GLVolume* v = (*m_volumes)[i];
if ((v->object_idx() == (int)object_idx) && (v->volume_idx() == (int)volume_idx))
{
if (((int)instance_idx != -1) && (v->instance_idx() == (int)instance_idx))
if (v->object_idx() == (int)object_idx && v->volume_idx() == (int)volume_idx) {
if ((int)instance_idx != -1 && v->instance_idx() == (int)instance_idx)
idxs.push_back(i);
}
}
@ -2058,8 +2054,7 @@ std::vector<unsigned int> Selection::get_missing_volume_idxs_from(const std::vec
{
std::vector<unsigned int> idxs;
for (unsigned int i : m_list)
{
for (unsigned int i : m_list) {
std::vector<unsigned int>::const_iterator it = std::find(volume_idxs.begin(), volume_idxs.end(), i);
if (it == volume_idxs.end())
idxs.push_back(i);
@ -2105,7 +2100,8 @@ void Selection::update_type()
if (!m_valid)
m_type = Invalid;
else {
else
{
if (m_list.empty())
m_type = Empty;
else if (m_list.size() == 1) {
@ -2203,8 +2199,7 @@ void Selection::update_type()
int object_idx = get_object_idx();
int instance_idx = get_instance_idx();
for (GLVolume* v : *m_volumes)
{
for (GLVolume* v : *m_volumes) {
v->disabled = requires_disable ? (v->object_idx() != object_idx) || (v->instance_idx() != instance_idx) : false;
}
@ -2393,7 +2388,7 @@ void Selection::render_synchronized_volumes()
if (coordinates_type == ECoordinatesType::World) {
box = v.transformed_convex_hull_bounding_box();
trafo = Transform3d::Identity();
}
}
else if (coordinates_type == ECoordinatesType::Local) {
box = v.bounding_box();
trafo = v.world_matrix();
@ -2437,6 +2432,7 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
#if ENABLE_LEGACY_OPENGL_REMOVAL
const BoundingBoxf3& curr_box = m_box.get_bounding_box();
if (!m_box.is_initialized() || !is_approx(box.min, curr_box.min) || !is_approx(box.max, curr_box.max)) {
m_box.reset();
@ -3046,10 +3042,11 @@ void Selection::synchronize_unselected_instances(SyncRotationType sync_rotation_
const Geometry::Transformation& curr_inst_trafo_j = volume_j->get_instance_transformation();
const Vec3d curr_inst_rotation_j = curr_inst_trafo_j.get_rotation();
Vec3d new_inst_offset_j = curr_inst_trafo_j.get_offset();
Vec3d new_inst_rotation_j = curr_inst_rotation_j;
Vec3d new_inst_rotation_j = curr_inst_rotation_j;
#else
assert(is_rotation_xy_synchronized(m_cache.volumes_data[i].get_instance_rotation(), m_cache.volumes_data[j].get_instance_rotation()));
#endif // ENABLE_WORLD_COORDINATE
switch (sync_rotation_type) {
case SyncRotationType::NONE: {
// z only rotation -> synch instance z