Tech ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES merged into tech ENABLE_WORLD_COORDINATE

Fixed conflicts during rebase with master
This commit is contained in:
enricoturri1966 2022-02-14 11:06:16 +01:00
parent cd4704e493
commit 90e54e5821
10 changed files with 85 additions and 297 deletions

View file

@ -73,8 +73,6 @@
#define ENABLE_WORLD_COORDINATE (1 && ENABLE_2_5_0_ALPHA1)
// Enable showing world coordinates of volumes' offset relative to the instance containing them
#define ENABLE_WORLD_COORDINATE_VOLUMES_LOCAL_OFFSET (1 && ENABLE_WORLD_COORDINATE)
// Enable editing instance coordinates of volumes
#define ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES (1 && ENABLE_WORLD_COORDINATE)
// Enable modified camera control using mouse
#define ENABLE_NEW_CAMERA_MOVEMENTS (1 && ENABLE_2_5_0_ALPHA1)
// Enable modified rectangle selection

View file

@ -4,7 +4,7 @@
namespace Slic3r {
namespace GUI {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
enum class ECoordinatesType : unsigned char
{
World,
@ -72,7 +72,8 @@ private:
Enum m_value;
};
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
} // namespace Slic3r
} // namespace GUI

View file

@ -52,7 +52,7 @@ static choice_ctrl* create_word_local_combo(wxWindow *parent)
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
temp->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::World));
temp->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Instance));
temp->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Local));
@ -62,7 +62,7 @@ static choice_ctrl* create_word_local_combo(wxWindow *parent)
temp->Append(_L("Local coordinates"));
temp->SetSelection(0);
temp->SetValue(temp->GetString(0));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
temp->SetToolTip(_L("Select coordinate space, in which the transformation will be performed."));
return temp;
@ -88,14 +88,14 @@ void msw_rescale_word_local_combo(choice_ctrl* combo)
// Set rescaled size
combo->SetSize(size);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
combo->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::World));
combo->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Instance));
combo->Append(ObjectManipulation::coordinate_type_str(ECoordinatesType::Local));
#else
combo->Append(_L("World coordinates"));
combo->Append(_L("Local coordinates"));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
combo->SetValue(selection);
#else
@ -171,12 +171,12 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
// Add world local combobox
m_word_local_combo = create_word_local_combo(parent);
m_word_local_combo->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent& evt) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
this->set_coordinates_type(evt.GetString());
#else
this->set_world_coordinates(evt.GetSelection() != 1);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
}), m_word_local_combo->GetId());
#endif // ENABLE_WORLD_COORDINATE
}), m_word_local_combo->GetId());
// Small trick to correct layouting in different view_mode :
// Show empty string of a same height as a m_word_local_combo, when m_word_local_combo is hidden
@ -353,11 +353,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
if (selection.is_single_volume_or_modifier()) {
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
const double min_z = get_volume_min_z(*volume);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!is_world_coordinates()) {
#else
if (!m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const Vec3d diff = m_cache.position - volume->get_instance_transformation().get_matrix(true).inverse() * (min_z * Vec3d::UnitZ());
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Drop to bed"));
@ -383,11 +379,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
else if (selection.is_single_full_instance()) {
#if ENABLE_WORLD_COORDINATE
const double min_z = selection.get_scaled_instance_bounding_box().min.z();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!is_world_coordinates()) {
#else
if (!m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
const Vec3d diff = m_cache.position - volume->get_instance_transformation().get_matrix(true).inverse() * (min_z * Vec3d::UnitZ());
@ -513,7 +505,6 @@ void ObjectManipulation::Show(const bool show)
#if ENABLE_WORLD_COORDINATE
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
bool show_world_local_combo = wxGetApp().get_mode() != comSimple && (selection.is_single_full_instance() || selection.is_single_volume_or_modifier());
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_volume_or_modifier() && m_word_local_combo->GetCount() < 3) {
#ifdef __linux__
m_word_local_combo->Insert(coordinate_type_str(ECoordinatesType::Instance), 1);
@ -528,7 +519,6 @@ void ObjectManipulation::Show(const bool show)
m_word_local_combo->Select((int)ECoordinatesType::World);
this->set_coordinates_type(m_word_local_combo->GetString(m_word_local_combo->GetSelection()));
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else
bool show_world_local_combo = wxGetApp().plater()->canvas3D()->get_selection().is_single_full_instance() && wxGetApp().get_mode() != comSimple;
#endif // ENABLE_WORLD_COORDINATE
@ -609,10 +599,10 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
m_new_rotate_label_string = L("Rotation");
m_new_scale_label_string = L("Scale factors");
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if !ENABLE_WORLD_COORDINATE
if (wxGetApp().get_mode() == comSimple)
m_world_coordinates = true;
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // !ENABLE_WORLD_COORDINATE
ObjectList* obj_list = wxGetApp().obj_list();
if (selection.is_single_full_instance()) {
@ -623,29 +613,25 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
#endif // !ENABLE_WORLD_COORDINATE
// Verify whether the instance rotation is multiples of 90 degrees, so that the scaling in world coordinates is possible.
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
if (is_world_coordinates() && !m_uniform_scale &&
#else
if (m_world_coordinates && ! m_uniform_scale &&
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
! Geometry::is_rotation_ninety_degrees(volume->get_instance_rotation())) {
// Manipulating an instance in the world coordinate system, rotation is not multiples of ninety degrees, therefore enforce uniform scaling.
m_uniform_scale = true;
m_lock_bnt->SetLock(true);
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
if (is_world_coordinates()) {
#else
if (m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
m_new_position = volume->get_instance_offset();
#endif // ENABLE_WORLD_COORDINATE
m_new_rotate_label_string = L("Rotate");
#if ENABLE_WORLD_COORDINATE
m_new_rotation = volume->get_instance_rotation() * (180.0 / M_PI);
#else
if (m_world_coordinates) {
m_new_rotate_label_string = L("Rotate");
m_new_rotation = Vec3d::Zero();
#endif // ENABLE_WORLD_COORDINATE
m_new_size = selection.get_scaled_instance_bounding_box().size();
@ -682,11 +668,7 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
// the selection contains a single volume
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (is_world_coordinates()) {
#else
if (m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const Geometry::Transformation trafo(volume->world_matrix());
#if ENABLE_WORLD_COORDINATE_VOLUMES_LOCAL_OFFSET
@ -701,27 +683,23 @@ void ObjectManipulation::update_settings_value(const Selection& selection)
m_new_size = volume->transformed_convex_hull_bounding_box(trafo.get_matrix()).size();
m_new_scale = m_new_size.cwiseProduct(volume->transformed_convex_hull_bounding_box(volume->get_instance_transformation().get_matrix() * volume->get_volume_transformation().get_matrix(false, false, true, false)).size().cwiseInverse()) * 100.0;
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (is_local_coordinates()) {
m_new_position = Vec3d::Zero();
m_new_rotation = Vec3d::Zero();
m_new_scale = volume->get_volume_scaling_factor() * 100.0;
m_new_size = volume->get_volume_scaling_factor().cwiseProduct(volume->bounding_box().size());
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else {
#endif // ENABLE_WORLD_COORDINATE
m_new_position = volume->get_volume_offset();
m_new_rotation = volume->get_volume_rotation() * (180.0 / M_PI);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
m_new_size = volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix()).size();
m_new_scale = m_new_size.cwiseProduct(volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix(false, false, true, false)).size().cwiseInverse()) * 100.0;
#if ENABLE_WORLD_COORDINATE
m_new_size = volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix()).size();
m_new_scale = m_new_size.cwiseProduct(volume->transformed_convex_hull_bounding_box(volume->get_volume_transformation().get_matrix(false, false, true, false)).size().cwiseInverse()) * 100.0;
}
#else
m_new_scale = volume->get_volume_scaling_factor() * 100.0;
m_new_size = volume->get_instance_scaling_factor().cwiseProduct(volume->get_volume_scaling_factor().cwiseProduct(volume->bounding_box().size()));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
}
#endif // ENABLE_WORLD_COORDINATE
m_new_enabled = true;
}
@ -788,15 +766,14 @@ void ObjectManipulation::update_if_dirty()
update(m_cache.rotation, m_cache.rotation_rounded, meRotation, m_new_rotation);
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
Selection::EUniformScaleRequiredReason reason;
if (selection.requires_uniform_scale(&reason)) {
#else
if (selection.requires_uniform_scale()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
m_lock_bnt->SetLock(true);
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
wxString tooltip;
if (selection.is_single_volume_or_modifier()) {
if (reason == Selection::EUniformScaleRequiredReason::VolumeNotAxisAligned_Instance)
@ -814,9 +791,6 @@ void ObjectManipulation::update_if_dirty()
tooltip = _L("You cannot use non-uniform scaling mode for multiple objects/parts selection");
m_lock_bnt->SetToolTip(tooltip);
#else
m_lock_bnt->SetToolTip(_L("You cannot use non-uniform scaling mode for multiple objects/parts selection or non axis-aligned objects/parts"));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else
m_lock_bnt->SetToolTip(_L("You cannot use non-uniform scaling mode for multiple objects/parts selection"));
#endif // ENABLE_WORLD_COORDINATE
@ -828,13 +802,13 @@ void ObjectManipulation::update_if_dirty()
m_lock_bnt->enable();
}
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if !ENABLE_WORLD_COORDINATE
{
int new_selection = m_world_coordinates ? 0 : 1;
if (m_word_local_combo->GetSelection() != new_selection)
m_word_local_combo->SetSelection(new_selection);
}
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // !ENABLE_WORLD_COORDINATE
if (m_new_enabled)
m_og->enable();
@ -863,11 +837,7 @@ void ObjectManipulation::update_reset_buttons_visibility()
bool show_drop_to_bed = false;
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (m_coordinates_type != ECoordinatesType::Local && (selection.is_single_full_instance() || selection.is_single_volume_or_modifier())) {
#else
if (selection.is_single_full_instance() || selection.is_single_volume_or_modifier()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
Vec3d rotation = Vec3d::Zero();
Vec3d scale = Vec3d::Ones();
@ -925,11 +895,11 @@ void ObjectManipulation::update_mirror_buttons_visibility()
Selection& selection = canvas->get_selection();
std::array<MirrorButtonState, 3> new_states = {mbHidden, mbHidden, mbHidden};
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
if (is_local_coordinates()) {
#else
if (!m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
#if ENABLE_WORLD_COORDINATE
if (selection.is_single_full_instance() || selection.is_single_volume_or_modifier()) {
#else
@ -999,7 +969,7 @@ void ObjectManipulation::update_warning_icon_state(const MeshErrorsInfo& warning
m_fix_throught_netfab_bitmap->SetToolTip(tooltip);
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
wxString ObjectManipulation::coordinate_type_str(ECoordinatesType type)
{
switch (type)
@ -1010,7 +980,7 @@ wxString ObjectManipulation::coordinate_type_str(ECoordinatesType type)
default: { assert(false); return _L("Unknown"); }
}
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
void ObjectManipulation::reset_settings_value()
{
@ -1036,11 +1006,7 @@ void ObjectManipulation::change_position_value(int axis, double value)
Selection& selection = canvas->get_selection();
selection.setup_cache();
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
selection.translate(position - m_cache.position, get_coordinates_type());
#else
selection.translate(position - m_cache.position, !m_world_coordinates);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else
selection.translate(position - m_cache.position, selection.requires_local_axes());
#endif // ENABLE_WORLD_COORDINATE
@ -1067,11 +1033,7 @@ void ObjectManipulation::change_rotation_value(int axis, double value)
if (selection.is_single_full_instance())
transformation_type.set_independent();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!is_world_coordinates()) {
#else
if (!m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
//FIXME Selection::rotate() does not process absolute rotations correctly: It does not recognize the axis index, which was changed.
// transformation_type.set_absolute();
transformation_type.set_local();
@ -1144,11 +1106,11 @@ void ObjectManipulation::change_size_value(int axis, double value)
ref_size = Vec3d::Ones();
}
else if (selection.is_single_full_instance())
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
ref_size = is_world_coordinates() ?
#else
ref_size = m_world_coordinates ?
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
selection.get_unscaled_instance_bounding_box().size() :
wxGetApp().model().objects[selection.get_volume(*selection.get_volume_idxs().begin())->object_idx()]->raw_mesh_bounding_box().size();
@ -1168,21 +1130,13 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const
#if ENABLE_WORLD_COORDINATE
TransformationType transformation_type;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!is_world_coordinates())
#else
if (!m_world_coordinates)
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
transformation_type.set_local();
bool uniform_scale = m_uniform_scale || selection.requires_uniform_scale();
Vec3d scaling_factor = uniform_scale ? scale(axis) * Vec3d::Ones() : scale;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!uniform_scale && is_world_coordinates()) {
#else
if (!uniform_scale && m_world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance())
scaling_factor = (Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse() * scaling_factor).cwiseAbs();
else if (selection.is_single_volume_or_modifier()) {
@ -1245,11 +1199,11 @@ void ObjectManipulation::on_change(const std::string& opt_key, int axis, double
void ObjectManipulation::set_uniform_scaling(const bool new_value)
{
const Selection &selection = wxGetApp().plater()->canvas3D()->get_selection();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
if (selection.is_single_full_instance() && is_world_coordinates() && !new_value) {
#else
if (selection.is_single_full_instance() && m_world_coordinates && !new_value) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
// Verify whether the instance rotation is multiples of 90 degrees, so that the scaling in world coordinates is possible.
// all volumes in the selection belongs to the same instance, any of them contains the needed instance data, so we take the first one
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
@ -1282,7 +1236,6 @@ void ObjectManipulation::set_uniform_scaling(const bool new_value)
}
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
void ObjectManipulation::set_coordinates_type(ECoordinatesType type)
{
if (wxGetApp().get_mode() == comSimple)
@ -1298,24 +1251,6 @@ void ObjectManipulation::set_coordinates_type(ECoordinatesType type)
canvas->set_as_dirty();
canvas->request_extra_frame();
}
#else
void ObjectManipulation::set_world_coordinates(const bool world_coordinates)
{
m_world_coordinates = world_coordinates;
this->UpdateAndShow(true);
GLCanvas3D* canvas = wxGetApp().plater()->canvas3D();
canvas->get_gizmos_manager().update_data();
canvas->set_as_dirty();
canvas->request_extra_frame();
}
bool ObjectManipulation::get_world_coordinates() const
{
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
return wxGetApp().get_mode() != comSimple && (selection.is_single_full_instance() || selection.is_single_volume() || selection.is_single_modifier()) ?
m_world_coordinates : true;
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
void ObjectManipulation::msw_rescale()
@ -1381,7 +1316,7 @@ void ObjectManipulation::sys_color_changed()
m_mirror_buttons[id].first->msw_rescale();
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
void ObjectManipulation::set_coordinates_type(const wxString& type_string)
{
ECoordinatesType type = ECoordinatesType::World;
@ -1392,7 +1327,7 @@ void ObjectManipulation::set_coordinates_type(const wxString& type_string)
this->set_coordinates_type(type);
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
static const char axes[] = { 'x', 'y', 'z' };
ManipulationEditor::ManipulationEditor(ObjectManipulation* parent,

View file

@ -5,9 +5,9 @@
#include "GUI_ObjectSettings.hpp"
#include "GUI_ObjectList.hpp"
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
#include "GUI_Geometry.hpp"
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
#include "libslic3r/Point.hpp"
#include <float.h>
@ -151,12 +151,12 @@ private:
Vec3d m_new_size;
bool m_new_enabled {true};
bool m_uniform_scale {true};
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
ECoordinatesType m_coordinates_type{ ECoordinatesType::World };
#else
// Does the object manipulation panel work in World or Local coordinates?
bool m_world_coordinates = true;
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
LockButton* m_lock_bnt{ nullptr };
choice_ctrl* m_word_local_combo { nullptr };
@ -199,17 +199,11 @@ public:
void set_uniform_scaling(const bool uniform_scale);
bool get_uniform_scaling() const { return m_uniform_scale; }
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
void set_coordinates_type(ECoordinatesType type);
ECoordinatesType get_coordinates_type() const { return m_coordinates_type; }
bool is_world_coordinates() const { return m_coordinates_type == ECoordinatesType::World; }
bool is_instance_coordinates() const { return m_coordinates_type == ECoordinatesType::Instance; }
bool is_local_coordinates() const { return m_coordinates_type == ECoordinatesType::Local; }
#else
// Does the object manipulation panel work in World or Local coordinates?
void set_world_coordinates(const bool world_coordinates);
bool get_world_coordinates() const;
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else
// Does the object manipulation panel work in World or Local coordinates?
void set_world_coordinates(const bool world_coordinates) { m_world_coordinates = world_coordinates; this->UpdateAndShow(true); }
@ -243,9 +237,9 @@ public:
ManipulationEditor* get_focused_editor() { return m_focused_editor; }
#endif // ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
static wxString coordinate_type_str(ECoordinatesType type);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
private:
void reset_settings_value();
@ -263,9 +257,9 @@ private:
void change_size_value(int axis, double value);
void do_scale(int axis, const Vec3d &scale) const;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
void set_coordinates_type(const wxString& type_string);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
};
}}

View file

@ -94,19 +94,13 @@ void GLGizmoMove3D::on_start_dragging()
m_displacement = Vec3d::Zero();
#if ENABLE_WORLD_COORDINATE
const Selection& selection = m_parent.get_selection();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World)
#else
if (wxGetApp().obj_manipul()->get_world_coordinates())
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
m_starting_drag_position = m_center + m_grabbers[m_hover_id].center;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_starting_drag_position = m_center + Geometry::assemble_transform(Vec3d::Zero(), v.get_instance_rotation()) * Geometry::assemble_transform(Vec3d::Zero(), v.get_volume_rotation()) * m_grabbers[m_hover_id].center;
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_starting_drag_position = m_center + Geometry::assemble_transform(Vec3d::Zero(), v.get_instance_rotation()) * m_grabbers[m_hover_id].center;
@ -464,7 +458,6 @@ void GLGizmoMove3D::transform_to_local(const Selection& selection) const
{
glsafe(::glTranslated(m_center.x(), m_center.y(), m_center.z()));
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!wxGetApp().obj_manipul()->is_world_coordinates()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
Transform3d orient_matrix = v.get_instance_transformation().get_matrix(true, false, true, true);
@ -472,33 +465,21 @@ void GLGizmoMove3D::transform_to_local(const Selection& selection) const
orient_matrix = orient_matrix * v.get_volume_transformation().get_matrix(true, false, true, true);
glsafe(::glMultMatrixd(orient_matrix.data()));
}
#else
if (!wxGetApp().obj_manipul()->get_world_coordinates()) {
const Transform3d orient_matrix = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(true, false, true, true);
glsafe(::glMultMatrixd(orient_matrix.data()));
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
}
void GLGizmoMove3D::calc_selection_box_and_center()
{
const Selection& selection = m_parent.get_selection();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World) {
#else
if (wxGetApp().obj_manipul()->get_world_coordinates()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
m_bounding_box = selection.get_bounding_box();
m_center = m_bounding_box.center();
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_bounding_box = v.transformed_convex_hull_bounding_box(v.get_instance_transformation().get_matrix(true, true, false, true) * v.get_volume_transformation().get_matrix(true, true, false, true));
m_center = v.world_matrix() * m_bounding_box.center();
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else {
m_bounding_box.reset();
const Selection::IndicesList& ids = selection.get_volume_idxs();
@ -509,7 +490,7 @@ void GLGizmoMove3D::calc_selection_box_and_center()
m_bounding_box = m_bounding_box.transformed(selection.get_volume(*ids.begin())->get_instance_transformation().get_matrix(true, true, false, true));
m_center = selection.get_volume(*ids.begin())->get_instance_transformation().get_matrix(false, false, true, false) * m_bounding_box.center();
}
}
}
#endif // ENABLE_WORLD_COORDINATE
} // namespace GUI

View file

@ -287,22 +287,16 @@ void GLGizmoRotate::on_render_for_picking()
#if ENABLE_WORLD_COORDINATE
void GLGizmoRotate::init_data_from_selection(const Selection& selection)
{
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World) {
#else
if (wxGetApp().obj_manipul()->get_world_coordinates()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
m_bounding_box = selection.get_bounding_box();
m_center = m_bounding_box.center();
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_bounding_box = v.transformed_convex_hull_bounding_box(v.get_instance_transformation().get_matrix(true, true, false, true) * v.get_volume_transformation().get_matrix(true, true, false, true));
m_center = v.world_matrix() * m_bounding_box.center();
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else {
m_bounding_box.reset();
const Selection::IndicesList& ids = selection.get_volume_idxs();
@ -320,7 +314,6 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection)
m_snap_fine_in_radius = m_radius;
m_snap_fine_out_radius = m_snap_fine_in_radius + m_radius * ScaleLongTooth;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (coordinates_type == ECoordinatesType::World)
m_orient_matrix = Transform3d::Identity();
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
@ -331,12 +324,6 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection)
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_orient_matrix = v.get_instance_transformation().get_matrix(true, false, true, true);
}
#else
if (wxGetApp().obj_manipul()->get_world_coordinates())
m_orient_matrix = Transform3d::Identity();
else
m_orient_matrix = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(true, false, true, true);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
}
#endif // ENABLE_WORLD_COORDINATE

View file

@ -197,12 +197,7 @@ void GLGizmoScale3D::on_render()
m_grabbers_transform = Transform3d::Identity();
m_center = Vec3d::Zero();
m_instance_center = Vec3d::Zero();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) {
#else
bool world_coordinates = wxGetApp().obj_manipul()->get_world_coordinates();
if (selection.is_single_full_instance() && !world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else
m_transform = Transform3d::Identity();
// Transforms grabbers' offsets to world refefence system
@ -233,6 +228,8 @@ void GLGizmoScale3D::on_render()
m_grabbers_transform = v.get_instance_transformation().get_matrix(false, false, true) * Geometry::assemble_transform(m_bounding_box.center());
m_center = selection.get_volume(*idxs.begin())->get_instance_transformation().get_matrix(false, false, true, false) * m_bounding_box.center();
m_instance_center = v.get_instance_offset();
}
else if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_instance_coordinates()) {
#else
m_transform = v.get_instance_transformation().get_matrix();
@ -241,32 +238,18 @@ void GLGizmoScale3D::on_render()
// consider rotation+mirror only components of the transform for offsets
offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v.get_instance_mirror());
m_offsets_transform = offsets_transform;
#endif // ENABLE_WORLD_COORDINATE
}
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_instance_coordinates()) {
#else
else if (selection.is_single_volume_or_modifier() && !world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else
else if (selection.is_single_modifier() || selection.is_single_volume()) {
#endif // ENABLE_WORLD_COORDINATE
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
m_bounding_box.merge(v.transformed_convex_hull_bounding_box(v.get_instance_transformation().get_matrix(true, true, false, true) * v.get_volume_transformation().get_matrix(true, false, false, true)));
Geometry::Transformation trafo(v.get_instance_transformation().get_matrix(true, false, true, true));
#else
m_bounding_box.merge(v.transformed_convex_hull_bounding_box(v.get_instance_transformation().get_matrix(true, true, false, true) * v.get_volume_transformation().get_matrix(true, true, false, true)));
Geometry::Transformation trafo(v.get_instance_transformation().get_matrix(true, false, true) * v.get_volume_transformation().get_matrix(true, false, true));
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
trafo.set_offset(v.world_matrix().translation());
m_grabbers_transform = trafo.get_matrix();
m_center = v.world_matrix() * m_bounding_box.center();
m_instance_center = m_center;
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_local_coordinates()) {
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
m_bounding_box.merge(v.transformed_convex_hull_bounding_box(v.get_instance_transformation().get_matrix(true, true, false, true) * v.get_volume_transformation().get_matrix(true, true, false, true)));
@ -276,7 +259,6 @@ void GLGizmoScale3D::on_render()
m_center = v.world_matrix() * m_bounding_box.center();
m_instance_center = m_center;
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else {
m_bounding_box = selection.get_bounding_box();
m_grabbers_transform = Geometry::assemble_transform(m_bounding_box.center());
@ -645,13 +627,8 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data)
Vec3d curr_scale = m_scale;
Vec3d starting_scale = m_starting.scale;
const Selection& selection = m_parent.get_selection();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World) {
#else
const bool world_coordinates = wxGetApp().obj_manipul()->get_world_coordinates();
if (world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance()) {
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation());
curr_scale = (m * curr_scale).cwiseAbs();
@ -668,11 +645,7 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data)
curr_scale(axis) = starting_scale(axis) * ratio;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (coordinates_type == ECoordinatesType::World) {
#else
if (world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance())
m_scale = (Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse() * curr_scale).cwiseAbs();
else if (selection.is_single_volume_or_modifier()) {
@ -702,11 +675,7 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data)
#if ENABLE_WORLD_COORDINATE
Vec3d center_offset = m_starting.instance_center - m_starting.center;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance() && coordinates_type != ECoordinatesType::World) {
#else
if (selection.is_single_full_instance() && !world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse();
center_offset = m * center_offset;
}
@ -720,14 +689,6 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data)
case Z: { m_offset = local_offset * Vec3d::UnitZ(); break; }
default: { m_offset = Vec3d::Zero(); break; }
}
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_volume_or_modifier() && !world_coordinates) {
const Transform3d mv = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_volume_rotation());
const Transform3d mi = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_scaling_factor()).inverse();
m_offset = mv * mi * m_offset;
}
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#else
Vec3d local_offset_vec;
switch (axis)
@ -761,29 +722,14 @@ void GLGizmoScale3D::do_scale_uniform(const UpdateData& data)
m_offset.y() *= -1.0;
const Selection& selection = m_parent.get_selection();
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const bool world_coordinates = wxGetApp().obj_manipul()->get_world_coordinates();
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
Vec3d center_offset = m_starting.instance_center - m_starting.center;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) {
#else
if (selection.is_single_full_instance() && !world_coordinates) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_rotation()).inverse();
center_offset = m * center_offset;
}
m_offset += (ratio - 1.0) * center_offset;
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_volume_or_modifier() && !world_coordinates) {
const Transform3d mv = Geometry::assemble_transform(Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_volume_rotation());
const Transform3d mi = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_scaling_factor()).inverse();
m_offset = mv * mi * m_offset;
}
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
}
else
#endif // ENABLE_WORLD_COORDINATE
@ -831,17 +777,9 @@ void GLGizmoScale3D::transform_to_local(const Selection& selection) const
{
glsafe(::glTranslated(m_center.x(), m_center.y(), m_center.z()));
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (!wxGetApp().obj_manipul()->is_world_coordinates()) {
#else
if (!wxGetApp().obj_manipul()->get_world_coordinates()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
Transform3d orient_matrix = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(true, false, true, true);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_local_coordinates())
#else
if (selection.is_single_volume_or_modifier())
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
orient_matrix = orient_matrix * selection.get_volume(*selection.get_volume_idxs().begin())->get_volume_transformation().get_matrix(true, false, true, true);
glsafe(::glMultMatrixd(orient_matrix.data()));
}

View file

@ -57,9 +57,9 @@
#include "GUI_ObjectManipulation.hpp"
#include "GUI_ObjectLayers.hpp"
#include "GUI_Utils.hpp"
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
#include "GUI_Geometry.hpp"
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
#include "GUI_Factories.hpp"
#include "wxExtensions.hpp"
#include "MainFrame.hpp"
@ -1517,10 +1517,10 @@ void Sidebar::update_mode()
wxWindowUpdateLocker noUpdates(this);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
if (m_mode == comSimple)
p->object_manipulation->set_coordinates_type(ECoordinatesType::World);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
p->object_list->get_sizer()->Show(m_mode > comSimple);

View file

@ -591,19 +591,15 @@ bool Selection::matches(const std::vector<unsigned int>& volume_idxs) const
return count == (unsigned int)m_list.size();
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
bool Selection::requires_uniform_scale(EUniformScaleRequiredReason* reason) const
#else
bool Selection::requires_uniform_scale() const
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
{
#if ENABLE_WORLD_COORDINATE
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
ECoordinatesType coord_type = wxGetApp().obj_manipul()->get_coordinates_type();
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (is_single_volume_or_modifier())
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
{
if (is_single_volume_or_modifier()) {
if (coord_type == ECoordinatesType::World) {
if (!Geometry::is_rotation_ninety_degrees(Geometry::Transformation(get_volume(*m_list.begin())->world_matrix()).get_rotation())) {
if (reason != nullptr)
@ -620,11 +616,7 @@ bool Selection::requires_uniform_scale() const
}
return false;
}
#else
return !Geometry::is_rotation_ninety_degrees(Geometry::Transformation(get_volume(*m_list.begin())->world_matrix()).get_rotation());
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else if (is_single_full_instance()) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (coord_type == ECoordinatesType::World) {
if (!Geometry::is_rotation_ninety_degrees(get_volume(*m_list.begin())->get_instance_rotation())) {
if (reason != nullptr)
@ -656,11 +648,6 @@ bool Selection::requires_uniform_scale() const
if (reason != nullptr)
*reason = EUniformScaleRequiredReason::MultipleSelection;
#else
return wxGetApp().obj_manipul()->get_world_coordinates() ?
!Geometry::is_rotation_ninety_degrees(get_volume(*m_list.begin())->get_instance_rotation()) : false;
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
return true;
#else
@ -758,11 +745,11 @@ void Selection::setup_cache()
set_caches();
}
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
void Selection::translate(const Vec3d& displacement, ECoordinatesType type)
#else
void Selection::translate(const Vec3d& displacement, bool local)
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
{
if (!m_valid)
return;
@ -772,19 +759,19 @@ void Selection::translate(const Vec3d& displacement, bool local)
for (unsigned int i : m_list) {
GLVolume& v = *(*m_volumes)[i];
if (m_mode == Volume || v.is_wipe_tower) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
if (type == ECoordinatesType::Instance)
#else
if (local)
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + displacement);
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
else if (type == ECoordinatesType::Local) {
const VolumeCache& volume_data = m_cache.volumes_data[i];
const Vec3d local_displacement = volume_data.get_volume_rotation_matrix() * displacement;
v.set_volume_offset(volume_data.get_volume_position() + local_displacement);
}
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
else {
#if ENABLE_WORLD_COORDINATE
const VolumeCache& volume_data = m_cache.volumes_data[i];
@ -799,15 +786,9 @@ void Selection::translate(const Vec3d& displacement, bool local)
else if (m_mode == Instance) {
#if ENABLE_WORLD_COORDINATE
if (is_from_fully_selected_instance(i)) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (type == ECoordinatesType::Local) {
const VolumeCache& volume_data = m_cache.volumes_data[i];
const Vec3d world_displacement = volume_data.get_instance_rotation_matrix() * displacement;
#else
if (local) {
const VolumeCache& volume_data = m_cache.volumes_data[i];
const Vec3d world_displacement = (volume_data.get_instance_rotation_matrix() * volume_data.get_instance_mirror_matrix()) * displacement;
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
v.set_instance_offset(volume_data.get_instance_position() + world_displacement);
}
else
@ -919,7 +900,6 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
rotate_instance(v, i);
#if ENABLE_WORLD_COORDINATE
else if (is_single_volume_or_modifier()) {
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (transformation_type.local()) {
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
v.set_volume_rotation(Geometry::extract_euler_angles(m_cache.volumes_data[i].get_volume_rotation_matrix() * m));
@ -928,10 +908,6 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
v.set_volume_rotation(Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix()));
}
#else
if (transformation_type.local())
v.set_volume_rotation(m_cache.volumes_data[i].get_volume_rotation() + rotation);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
else {
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
m = m * m_cache.volumes_data[i].get_instance_rotation_matrix();
@ -1524,11 +1500,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
#else
const Vec3d& center = get_bounding_box().center();
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
if (is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) {
#else
if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates()) {
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glTranslated(center.x(), center.y(), center.z()));
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
@ -1749,8 +1721,7 @@ std::vector<unsigned int> Selection::get_unselected_volume_idxs_from(const std::
{
std::vector<unsigned int> idxs;
for (unsigned int i : volume_idxs)
{
for (unsigned int i : volume_idxs) {
if (m_list.find(i) == m_list.end())
idxs.push_back(i);
}
@ -1768,8 +1739,7 @@ void Selection::update_type()
m_cache.content.clear();
m_type = Mixed;
for (unsigned int i : m_list)
{
for (unsigned int i : m_list) {
const GLVolume* volume = (*m_volumes)[i];
int obj_idx = volume->object_idx();
int inst_idx = volume->instance_idx();
@ -1784,27 +1754,22 @@ 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)
{
else if (m_list.size() == 1) {
const GLVolume* first = (*m_volumes)[*m_list.begin()];
if (first->is_wipe_tower)
m_type = WipeTower;
else if (first->is_modifier)
{
else if (first->is_modifier) {
m_type = SingleModifier;
requires_disable = true;
}
else
{
else {
const ModelObject* model_object = m_model->objects[first->object_idx()];
unsigned int volumes_count = (unsigned int)model_object->volumes.size();
unsigned int instances_count = (unsigned int)model_object->instances.size();
if (volumes_count * instances_count == 1)
{
if (volumes_count * instances_count == 1) {
m_type = SingleFullObject;
// ensures the correct mode is selected
m_mode = Instance;
@ -1815,15 +1780,13 @@ void Selection::update_type()
// ensures the correct mode is selected
m_mode = Instance;
}
else
{
else {
m_type = SingleVolume;
requires_disable = true;
}
}
}
else
{
else {
unsigned int sla_volumes_count = 0;
// Note: sla_volumes_count is a count of the selected sla_volumes per object instead of per instance, like a model_volumes_count is
for (unsigned int i : m_list) {
@ -1838,25 +1801,20 @@ void Selection::update_type()
unsigned int instances_count = (unsigned int)model_object->instances.size();
unsigned int selected_instances_count = (unsigned int)m_cache.content.begin()->second.size();
if (model_volumes_count * instances_count + sla_volumes_count == (unsigned int)m_list.size())
{
if (model_volumes_count * instances_count + sla_volumes_count == (unsigned int)m_list.size()) {
m_type = SingleFullObject;
// ensures the correct mode is selected
m_mode = Instance;
}
else if (selected_instances_count == 1)
{
if (model_volumes_count + sla_volumes_count == (unsigned int)m_list.size())
{
else if (selected_instances_count == 1) {
if (model_volumes_count + sla_volumes_count == (unsigned int)m_list.size()) {
m_type = SingleFullInstance;
// ensures the correct mode is selected
m_mode = Instance;
}
else
{
else {
unsigned int modifiers_count = 0;
for (unsigned int i : m_list)
{
for (unsigned int i : m_list) {
if ((*m_volumes)[i]->is_modifier)
++modifiers_count;
}
@ -1869,25 +1827,21 @@ void Selection::update_type()
requires_disable = true;
}
}
else if ((selected_instances_count > 1) && (selected_instances_count * model_volumes_count + sla_volumes_count == (unsigned int)m_list.size()))
{
else if (selected_instances_count > 1 && selected_instances_count * model_volumes_count + sla_volumes_count == (unsigned int)m_list.size()) {
m_type = MultipleFullInstance;
// ensures the correct mode is selected
m_mode = Instance;
}
}
else
{
else {
unsigned int sels_cntr = 0;
for (ObjectIdxsToInstanceIdxsMap::iterator it = m_cache.content.begin(); it != m_cache.content.end(); ++it)
{
for (ObjectIdxsToInstanceIdxsMap::iterator it = m_cache.content.begin(); it != m_cache.content.end(); ++it) {
const ModelObject* model_object = m_model->objects[it->first];
unsigned int volumes_count = (unsigned int)model_object->volumes.size();
unsigned int instances_count = (unsigned int)model_object->instances.size();
sels_cntr += volumes_count * instances_count;
}
if (sels_cntr + sla_volumes_count == (unsigned int)m_list.size())
{
if (sels_cntr + sla_volumes_count == (unsigned int)m_list.size()) {
m_type = MultipleFullObject;
// ensures the correct mode is selected
m_mode = Instance;

View file

@ -2,9 +2,9 @@
#define slic3r_GUI_Selection_hpp_
#include "libslic3r/Geometry.hpp"
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
#include "slic3r/GUI/GUI_Geometry.hpp"
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
#include "GLModel.hpp"
#include <set>
@ -27,7 +27,7 @@ using ModelObjectPtrs = std::vector<ModelObject*>;
namespace GUI {
#if !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if !ENABLE_WORLD_COORDINATE
class TransformationType
{
public:
@ -80,7 +80,7 @@ private:
Enum m_value;
};
#endif // !ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // !ENABLE_WORLD_COORDINATE
class Selection
{
@ -307,7 +307,7 @@ public:
// returns true if the selection contains all and only the given indices
bool matches(const std::vector<unsigned int>& volume_idxs) const;
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
enum class EUniformScaleRequiredReason : unsigned char
{
NotRequired,
@ -319,7 +319,7 @@ public:
bool requires_uniform_scale(EUniformScaleRequiredReason* reason = nullptr) const;
#else
bool requires_uniform_scale() const;
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
// Returns the the object id if the selection is from a single object, otherwise is -1
int get_object_idx() const;
@ -343,11 +343,11 @@ public:
void setup_cache();
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#if ENABLE_WORLD_COORDINATE
void translate(const Vec3d& displacement, ECoordinatesType type = ECoordinatesType::World);
#else
void translate(const Vec3d& displacement, bool local = false);
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
#endif // ENABLE_WORLD_COORDINATE
void rotate(const Vec3d& rotation, TransformationType transformation_type);
void flattening_rotate(const Vec3d& normal);
void scale(const Vec3d& scale, TransformationType transformation_type);