GLCanvas3D::Selection as a standalone class
This commit is contained in:
parent
ca623b9a83
commit
80c1a8d8e4
23 changed files with 2111 additions and 2069 deletions
|
@ -28,6 +28,8 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/GLCanvas3D.cpp
|
||||
GUI/GLCanvas3DManager.hpp
|
||||
GUI/GLCanvas3DManager.cpp
|
||||
GUI/Selection.hpp
|
||||
GUI/Selection.cpp
|
||||
GUI/Gizmos/GLGizmoBase.cpp
|
||||
GUI/Gizmos/GLGizmoBase.hpp
|
||||
GUI/Gizmos/GLGizmoMove.cpp
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,12 +4,12 @@
|
|||
#include <stddef.h>
|
||||
#include <memory>
|
||||
|
||||
#include "libslic3r/Technologies.hpp"
|
||||
#include "3DScene.hpp"
|
||||
#include "GLToolbar.hpp"
|
||||
#include "Event.hpp"
|
||||
#include "3DBed.hpp"
|
||||
#include "Camera.hpp"
|
||||
#include "Selection.hpp"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
|
@ -334,293 +334,6 @@ class GLCanvas3D
|
|||
};
|
||||
|
||||
public:
|
||||
class TransformationType
|
||||
{
|
||||
public:
|
||||
enum Enum {
|
||||
// Transforming in a world coordinate system
|
||||
World = 0,
|
||||
// Transforming in a local coordinate system
|
||||
Local = 1,
|
||||
// Absolute transformations, allowed in local coordinate system only.
|
||||
Absolute = 0,
|
||||
// Relative transformations, allowed in both local and world coordinate system.
|
||||
Relative = 2,
|
||||
// For group selection, the transformation is performed as if the group made a single solid body.
|
||||
Joint = 0,
|
||||
// For group selection, the transformation is performed on each object independently.
|
||||
Independent = 4,
|
||||
|
||||
World_Relative_Joint = World | Relative | Joint,
|
||||
World_Relative_Independent = World | Relative | Independent,
|
||||
Local_Absolute_Joint = Local | Absolute | Joint,
|
||||
Local_Absolute_Independent = Local | Absolute | Independent,
|
||||
Local_Relative_Joint = Local | Relative | Joint,
|
||||
Local_Relative_Independent = Local | Relative | Independent,
|
||||
};
|
||||
|
||||
TransformationType() : m_value(World) {}
|
||||
TransformationType(Enum value) : m_value(value) {}
|
||||
TransformationType& operator=(Enum value) { m_value = value; return *this; }
|
||||
|
||||
Enum operator()() const { return m_value; }
|
||||
bool has(Enum v) const { return ((unsigned int)m_value & (unsigned int)v) != 0; }
|
||||
|
||||
void set_world() { this->remove(Local); }
|
||||
void set_local() { this->add(Local); }
|
||||
void set_absolute() { this->remove(Relative); }
|
||||
void set_relative() { this->add(Relative); }
|
||||
void set_joint() { this->remove(Independent); }
|
||||
void set_independent() { this->add(Independent); }
|
||||
|
||||
bool world() const { return ! this->has(Local); }
|
||||
bool local() const { return this->has(Local); }
|
||||
bool absolute() const { return ! this->has(Relative); }
|
||||
bool relative() const { return this->has(Relative); }
|
||||
bool joint() const { return ! this->has(Independent); }
|
||||
bool independent() const { return this->has(Independent); }
|
||||
|
||||
private:
|
||||
void add(Enum v) { m_value = Enum((unsigned int)m_value | (unsigned int)v); }
|
||||
void remove(Enum v) { m_value = Enum((unsigned int)m_value & (~(unsigned int)v)); }
|
||||
|
||||
Enum m_value;
|
||||
};
|
||||
|
||||
class Selection
|
||||
{
|
||||
public:
|
||||
typedef std::set<unsigned int> IndicesList;
|
||||
|
||||
enum EMode : unsigned char
|
||||
{
|
||||
Volume,
|
||||
Instance
|
||||
};
|
||||
|
||||
enum EType : unsigned char
|
||||
{
|
||||
Invalid,
|
||||
Empty,
|
||||
WipeTower,
|
||||
SingleModifier,
|
||||
MultipleModifier,
|
||||
SingleVolume,
|
||||
MultipleVolume,
|
||||
SingleFullObject,
|
||||
MultipleFullObject,
|
||||
SingleFullInstance,
|
||||
MultipleFullInstance,
|
||||
Mixed
|
||||
};
|
||||
|
||||
private:
|
||||
struct VolumeCache
|
||||
{
|
||||
private:
|
||||
struct TransformCache
|
||||
{
|
||||
Vec3d position;
|
||||
Vec3d rotation;
|
||||
Vec3d scaling_factor;
|
||||
Vec3d mirror;
|
||||
Transform3d rotation_matrix;
|
||||
Transform3d scale_matrix;
|
||||
Transform3d mirror_matrix;
|
||||
Transform3d full_matrix;
|
||||
|
||||
TransformCache();
|
||||
explicit TransformCache(const Geometry::Transformation& transform);
|
||||
};
|
||||
|
||||
TransformCache m_volume;
|
||||
TransformCache m_instance;
|
||||
|
||||
public:
|
||||
VolumeCache() {}
|
||||
VolumeCache(const Geometry::Transformation& volume_transform, const Geometry::Transformation& instance_transform);
|
||||
|
||||
const Vec3d& get_volume_position() const { return m_volume.position; }
|
||||
const Vec3d& get_volume_rotation() const { return m_volume.rotation; }
|
||||
const Vec3d& get_volume_scaling_factor() const { return m_volume.scaling_factor; }
|
||||
const Vec3d& get_volume_mirror() const { return m_volume.mirror; }
|
||||
const Transform3d& get_volume_rotation_matrix() const { return m_volume.rotation_matrix; }
|
||||
const Transform3d& get_volume_scale_matrix() const { return m_volume.scale_matrix; }
|
||||
const Transform3d& get_volume_mirror_matrix() const { return m_volume.mirror_matrix; }
|
||||
const Transform3d& get_volume_full_matrix() const { return m_volume.full_matrix; }
|
||||
|
||||
const Vec3d& get_instance_position() const { return m_instance.position; }
|
||||
const Vec3d& get_instance_rotation() const { return m_instance.rotation; }
|
||||
const Vec3d& get_instance_scaling_factor() const { return m_instance.scaling_factor; }
|
||||
const Vec3d& get_instance_mirror() const { return m_instance.mirror; }
|
||||
const Transform3d& get_instance_rotation_matrix() const { return m_instance.rotation_matrix; }
|
||||
const Transform3d& get_instance_scale_matrix() const { return m_instance.scale_matrix; }
|
||||
const Transform3d& get_instance_mirror_matrix() const { return m_instance.mirror_matrix; }
|
||||
const Transform3d& get_instance_full_matrix() const { return m_instance.full_matrix; }
|
||||
};
|
||||
|
||||
typedef std::map<unsigned int, VolumeCache> VolumesCache;
|
||||
typedef std::set<int> InstanceIdxsList;
|
||||
typedef std::map<int, InstanceIdxsList> ObjectIdxsToInstanceIdxsMap;
|
||||
|
||||
struct Cache
|
||||
{
|
||||
// Cache of GLVolume derived transformation matrices, valid during mouse dragging.
|
||||
VolumesCache volumes_data;
|
||||
// Center of the dragged selection, valid during mouse dragging.
|
||||
Vec3d dragging_center;
|
||||
// Map from indices of ModelObject instances in Model::objects
|
||||
// to a set of indices of ModelVolume instances in ModelObject::instances
|
||||
// Here the index means a position inside the respective std::vector, not ModelID.
|
||||
ObjectIdxsToInstanceIdxsMap content;
|
||||
};
|
||||
|
||||
// Volumes owned by GLCanvas3D.
|
||||
GLVolumePtrs* m_volumes;
|
||||
// Model, not owned.
|
||||
Model* m_model;
|
||||
|
||||
bool m_valid;
|
||||
EMode m_mode;
|
||||
EType m_type;
|
||||
// set of indices to m_volumes
|
||||
IndicesList m_list;
|
||||
Cache m_cache;
|
||||
mutable BoundingBoxf3 m_bounding_box;
|
||||
mutable bool m_bounding_box_dirty;
|
||||
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
GLUquadricObj* m_quadric;
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
mutable GLArrow m_arrow;
|
||||
mutable GLCurvedArrow m_curved_arrow;
|
||||
|
||||
mutable float m_scale_factor;
|
||||
|
||||
public:
|
||||
Selection();
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
~Selection();
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
|
||||
void set_volumes(GLVolumePtrs* volumes);
|
||||
bool init(bool useVBOs);
|
||||
|
||||
Model* get_model() const { return m_model; }
|
||||
void set_model(Model* model);
|
||||
|
||||
EMode get_mode() const { return m_mode; }
|
||||
void set_mode(EMode mode) { m_mode = mode; }
|
||||
|
||||
void add(unsigned int volume_idx, bool as_single_selection = true);
|
||||
void remove(unsigned int volume_idx);
|
||||
|
||||
void add_object(unsigned int object_idx, bool as_single_selection = true);
|
||||
void remove_object(unsigned int object_idx);
|
||||
|
||||
void add_instance(unsigned int object_idx, unsigned int instance_idx, bool as_single_selection = true);
|
||||
void remove_instance(unsigned int object_idx, unsigned int instance_idx);
|
||||
|
||||
void add_volume(unsigned int object_idx, unsigned int volume_idx, int instance_idx, bool as_single_selection = true);
|
||||
void remove_volume(unsigned int object_idx, unsigned int volume_idx);
|
||||
|
||||
void add_all();
|
||||
|
||||
// Update the selection based on the map from old indices to new indices after m_volumes changed.
|
||||
// If the current selection is by instance, this call may select newly added volumes, if they belong to already selected instances.
|
||||
void volumes_changed(const std::vector<size_t> &map_volume_old_to_new);
|
||||
void clear();
|
||||
|
||||
bool is_empty() const { return m_type == Empty; }
|
||||
bool is_wipe_tower() const { return m_type == WipeTower; }
|
||||
bool is_modifier() const { return (m_type == SingleModifier) || (m_type == MultipleModifier); }
|
||||
bool is_single_modifier() const { return m_type == SingleModifier; }
|
||||
bool is_multiple_modifier() const { return m_type == MultipleModifier; }
|
||||
bool is_single_full_instance() const;
|
||||
bool is_multiple_full_instance() const { return m_type == MultipleFullInstance; }
|
||||
bool is_single_full_object() const { return m_type == SingleFullObject; }
|
||||
bool is_multiple_full_object() const { return m_type == MultipleFullObject; }
|
||||
bool is_single_volume() const { return m_type == SingleVolume; }
|
||||
bool is_multiple_volume() const { return m_type == MultipleVolume; }
|
||||
bool is_mixed() const { return m_type == Mixed; }
|
||||
bool is_from_single_instance() const { return get_instance_idx() != -1; }
|
||||
bool is_from_single_object() const;
|
||||
|
||||
bool contains_volume(unsigned int volume_idx) const { return std::find(m_list.begin(), m_list.end(), volume_idx) != m_list.end(); }
|
||||
bool requires_uniform_scale() const;
|
||||
|
||||
// Returns the the object id if the selection is from a single object, otherwise is -1
|
||||
int get_object_idx() const;
|
||||
// Returns the instance id if the selection is from a single object and from a single instance, otherwise is -1
|
||||
int get_instance_idx() const;
|
||||
// Returns the indices of selected instances.
|
||||
// Can only be called if selection is from a single object.
|
||||
const InstanceIdxsList& get_instance_idxs() const;
|
||||
|
||||
const IndicesList& get_volume_idxs() const { return m_list; }
|
||||
const GLVolume* get_volume(unsigned int volume_idx) const;
|
||||
|
||||
const ObjectIdxsToInstanceIdxsMap& get_content() const { return m_cache.content; }
|
||||
|
||||
unsigned int volumes_count() const { return (unsigned int)m_list.size(); }
|
||||
const BoundingBoxf3& get_bounding_box() const;
|
||||
|
||||
void start_dragging();
|
||||
|
||||
void translate(const Vec3d& displacement, bool local = false);
|
||||
void rotate(const Vec3d& rotation, TransformationType transformation_type);
|
||||
void flattening_rotate(const Vec3d& normal);
|
||||
void scale(const Vec3d& scale, bool local);
|
||||
void mirror(Axis axis);
|
||||
|
||||
void translate(unsigned int object_idx, const Vec3d& displacement);
|
||||
void translate(unsigned int object_idx, unsigned int instance_idx, const Vec3d& displacement);
|
||||
|
||||
void erase();
|
||||
|
||||
void render(float scale_factor = 1.0) const;
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
void render_center() const;
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
void render_sidebar_hints(const std::string& sidebar_field) const;
|
||||
|
||||
bool requires_local_axes() const;
|
||||
|
||||
private:
|
||||
void _update_valid();
|
||||
void _update_type();
|
||||
void _set_caches();
|
||||
void _add_volume(unsigned int volume_idx);
|
||||
void _add_instance(unsigned int object_idx, unsigned int instance_idx);
|
||||
void _add_object(unsigned int object_idx);
|
||||
void _remove_volume(unsigned int volume_idx);
|
||||
void _remove_instance(unsigned int object_idx, unsigned int instance_idx);
|
||||
void _remove_object(unsigned int object_idx);
|
||||
void _calc_bounding_box() const;
|
||||
void _render_selected_volumes() const;
|
||||
void _render_synchronized_volumes() const;
|
||||
void _render_bounding_box(const BoundingBoxf3& box, float* color) const;
|
||||
void _render_sidebar_position_hints(const std::string& sidebar_field) const;
|
||||
void _render_sidebar_rotation_hints(const std::string& sidebar_field) const;
|
||||
void _render_sidebar_scale_hints(const std::string& sidebar_field) const;
|
||||
void _render_sidebar_size_hints(const std::string& sidebar_field) const;
|
||||
void _render_sidebar_position_hint(Axis axis) const;
|
||||
void _render_sidebar_rotation_hint(Axis axis) const;
|
||||
void _render_sidebar_scale_hint(Axis axis) const;
|
||||
void _render_sidebar_size_hint(Axis axis, double length) const;
|
||||
enum SyncRotationType {
|
||||
// Do not synchronize rotation. Either not rotating at all, or rotating by world Z axis.
|
||||
SYNC_ROTATION_NONE = 0,
|
||||
// Synchronize fully. Used from "place on bed" feature.
|
||||
SYNC_ROTATION_FULL = 1,
|
||||
// Synchronize after rotation by an axis not parallel with Z.
|
||||
SYNC_ROTATION_GENERAL = 2,
|
||||
};
|
||||
void _synchronize_unselected_instances(SyncRotationType sync_rotation_type);
|
||||
void _synchronize_unselected_volumes();
|
||||
void _ensure_on_bed();
|
||||
};
|
||||
|
||||
class ClippingPlane
|
||||
{
|
||||
double m_data[4];
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "libslic3r/Model.hpp"
|
||||
#include "LambdaObjectDialog.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
#include "Selection.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "slic3r/Utils/FixModelByWin10.hpp"
|
||||
|
@ -1275,7 +1276,7 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
|
|||
if (obj_idx < 0)
|
||||
return;
|
||||
|
||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
assert(obj_idx == selection.get_object_idx());
|
||||
|
||||
/** Any changes of the Object's composition is duplicated for all Object's Instances
|
||||
|
@ -1563,7 +1564,7 @@ bool ObjectList::selected_instances_of_same_object()
|
|||
|
||||
bool ObjectList::can_split_instances()
|
||||
{
|
||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
return selection.is_multiple_full_instance() || selection.is_single_full_instance();
|
||||
}
|
||||
|
||||
|
@ -1873,7 +1874,7 @@ bool ObjectList::multiple_selection() const
|
|||
|
||||
void ObjectList::update_selections()
|
||||
{
|
||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
wxDataViewItemArray sels;
|
||||
|
||||
// We doesn't update selection if SettingsItem for the current object/part is selected
|
||||
|
@ -1971,7 +1972,7 @@ void ObjectList::update_selections()
|
|||
|
||||
void ObjectList::update_selections_on_canvas()
|
||||
{
|
||||
GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
|
||||
const int sel_cnt = GetSelectedItemsCount();
|
||||
if (sel_cnt == 0) {
|
||||
|
@ -1980,8 +1981,8 @@ void ObjectList::update_selections_on_canvas()
|
|||
return;
|
||||
}
|
||||
|
||||
auto add_to_selection = [this](const wxDataViewItem& item, GLCanvas3D::Selection& selection, bool as_single_selection)
|
||||
{
|
||||
auto add_to_selection = [this](const wxDataViewItem& item, Selection& selection, bool as_single_selection)
|
||||
{
|
||||
if (m_objects_model->GetParent(item) == wxDataViewItem(0)) {
|
||||
selection.add_object(m_objects_model->GetIdByItem(item), as_single_selection);
|
||||
return;
|
||||
|
@ -2240,7 +2241,7 @@ void ObjectList::instances_to_separated_object(const int obj_idx, const std::set
|
|||
|
||||
void ObjectList::split_instances()
|
||||
{
|
||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
const int obj_idx = selection.get_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "PresetBundle.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/Geometry.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
#include "Selection.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
|
@ -155,7 +157,7 @@ void ObjectManipulation::UpdateAndShow(const bool show)
|
|||
OG_Settings::UpdateAndShow(show);
|
||||
}
|
||||
|
||||
void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& selection)
|
||||
void ObjectManipulation::update_settings_value(const Selection& selection)
|
||||
{
|
||||
m_new_move_label_string = L("Position");
|
||||
m_new_rotate_label_string = L("Rotation");
|
||||
|
@ -348,7 +350,7 @@ void ObjectManipulation::reset_settings_value()
|
|||
void ObjectManipulation::change_position_value(const Vec3d& position)
|
||||
{
|
||||
auto canvas = wxGetApp().plater()->canvas3D();
|
||||
GLCanvas3D::Selection& selection = canvas->get_selection();
|
||||
Selection& selection = canvas->get_selection();
|
||||
selection.start_dragging();
|
||||
selection.translate(position - m_cache.position, selection.requires_local_axes());
|
||||
canvas->do_move();
|
||||
|
@ -359,10 +361,10 @@ void ObjectManipulation::change_position_value(const Vec3d& position)
|
|||
void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
|
||||
{
|
||||
GLCanvas3D* canvas = wxGetApp().plater()->canvas3D();
|
||||
const GLCanvas3D::Selection& selection = canvas->get_selection();
|
||||
const Selection& selection = canvas->get_selection();
|
||||
|
||||
GLCanvas3D::TransformationType transformation_type(GLCanvas3D::TransformationType::World_Relative_Joint);
|
||||
if (selection.is_single_full_instance() || selection.requires_local_axes())
|
||||
TransformationType transformation_type(TransformationType::World_Relative_Joint);
|
||||
if (selection.is_single_full_instance() || selection.requires_local_axes())
|
||||
transformation_type.set_independent();
|
||||
if (selection.is_single_full_instance()) {
|
||||
//FIXME GLCanvas3D::Selection::rotate() does not process absoulte rotations correctly: It does not recognize the axis index, which was changed.
|
||||
|
@ -384,7 +386,7 @@ void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
|
|||
void ObjectManipulation::change_scale_value(const Vec3d& scale)
|
||||
{
|
||||
Vec3d scaling_factor = scale;
|
||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
if (m_uniform_scale || selection.requires_uniform_scale())
|
||||
{
|
||||
Vec3d abs_scale_diff = (scale - m_cache.scale).cwiseAbs();
|
||||
|
@ -418,7 +420,7 @@ void ObjectManipulation::change_scale_value(const Vec3d& scale)
|
|||
|
||||
void ObjectManipulation::change_size_value(const Vec3d& size)
|
||||
{
|
||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
|
||||
Vec3d ref_size = m_cache.size;
|
||||
if (selection.is_single_volume() || selection.is_single_modifier())
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <memory>
|
||||
|
||||
#include "GUI_ObjectSettings.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
|
||||
class wxStaticText;
|
||||
class PrusaLockButton;
|
||||
|
@ -12,6 +11,7 @@ class PrusaLockButton;
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class Selection;
|
||||
|
||||
class ObjectManipulation : public OG_Settings
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ public:
|
|||
bool IsShown() override;
|
||||
void UpdateAndShow(const bool show) override;
|
||||
|
||||
void update_settings_value(const GLCanvas3D::Selection& selection);
|
||||
void update_settings_value(const Selection& selection);
|
||||
|
||||
// Called from the App to update the UI if dirty.
|
||||
void update_if_dirty();
|
||||
|
|
|
@ -184,7 +184,7 @@ void GLGizmoBase::disable_grabber(unsigned int id)
|
|||
on_disable_grabber(id);
|
||||
}
|
||||
|
||||
void GLGizmoBase::start_dragging(const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoBase::start_dragging(const Selection& selection)
|
||||
{
|
||||
m_dragging = true;
|
||||
|
||||
|
@ -208,7 +208,7 @@ void GLGizmoBase::stop_dragging()
|
|||
on_stop_dragging();
|
||||
}
|
||||
|
||||
void GLGizmoBase::update(const UpdateData& data, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoBase::update(const UpdateData& data, const Selection& selection)
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
on_update(data, selection);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/GUI/Selection.hpp"
|
||||
|
||||
|
||||
class wxWindow;
|
||||
|
@ -126,7 +127,7 @@ public:
|
|||
const std::string& get_icon_filename() const { return m_icon_filename; }
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
||||
bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); }
|
||||
bool is_activable(const Selection& selection) const { return on_is_activable(selection); }
|
||||
bool is_selectable() const { return on_is_selectable(); }
|
||||
|
||||
unsigned int get_sprite_id() const { return m_sprite_id; }
|
||||
|
@ -139,31 +140,31 @@ public:
|
|||
void enable_grabber(unsigned int id);
|
||||
void disable_grabber(unsigned int id);
|
||||
|
||||
void start_dragging(const GLCanvas3D::Selection& selection);
|
||||
void start_dragging(const Selection& selection);
|
||||
void stop_dragging();
|
||||
bool is_dragging() const { return m_dragging; }
|
||||
|
||||
void update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
||||
void update(const UpdateData& data, const Selection& selection);
|
||||
|
||||
void render(const GLCanvas3D::Selection& selection) const { on_render(selection); }
|
||||
void render_for_picking(const GLCanvas3D::Selection& selection) const { on_render_for_picking(selection); }
|
||||
void render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection) { on_render_input_window(x, y, bottom_limit, selection); }
|
||||
void render(const Selection& selection) const { on_render(selection); }
|
||||
void render_for_picking(const Selection& selection) const { on_render_for_picking(selection); }
|
||||
void render_input_window(float x, float y, float bottom_limit, const Selection& selection) { on_render_input_window(x, y, bottom_limit, selection); }
|
||||
|
||||
protected:
|
||||
virtual bool on_init() = 0;
|
||||
virtual std::string on_get_name() const = 0;
|
||||
virtual void on_set_state() {}
|
||||
virtual void on_set_hover_id() {}
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return true; }
|
||||
virtual bool on_is_activable(const Selection& selection) const { return true; }
|
||||
virtual bool on_is_selectable() const { return true; }
|
||||
virtual void on_enable_grabber(unsigned int id) {}
|
||||
virtual void on_disable_grabber(unsigned int id) {}
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection) {}
|
||||
virtual void on_start_dragging(const Selection& selection) {}
|
||||
virtual void on_stop_dragging() {}
|
||||
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection) = 0;
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const = 0;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const = 0;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection) {}
|
||||
virtual void on_update(const UpdateData& data, const Selection& selection) = 0;
|
||||
virtual void on_render(const Selection& selection) const = 0;
|
||||
virtual void on_render_for_picking(const Selection& selection) const = 0;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const Selection& selection) {}
|
||||
|
||||
// Returns the picking color for the given id, based on the BASE_ID constant
|
||||
// No check is made for clashing with other picking color (i.e. GLVolumes)
|
||||
|
|
|
@ -101,12 +101,12 @@ void GLGizmoCut::on_set_state()
|
|||
}
|
||||
}
|
||||
|
||||
bool GLGizmoCut::on_is_activable(const GLCanvas3D::Selection& selection) const
|
||||
bool GLGizmoCut::on_is_activable(const Selection& selection) const
|
||||
{
|
||||
return selection.is_single_full_instance() && !selection.is_wipe_tower();
|
||||
}
|
||||
|
||||
void GLGizmoCut::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoCut::on_start_dragging(const Selection& selection)
|
||||
{
|
||||
if (m_hover_id == -1) { return; }
|
||||
|
||||
|
@ -118,14 +118,14 @@ void GLGizmoCut::on_start_dragging(const GLCanvas3D::Selection& selection)
|
|||
m_drag_center(2) = m_cut_z;
|
||||
}
|
||||
|
||||
void GLGizmoCut::on_update(const UpdateData& data, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoCut::on_update(const UpdateData& data, const Selection& selection)
|
||||
{
|
||||
if (m_hover_id != -1) {
|
||||
set_cut_z(m_start_z + calc_projection(data.mouse_ray));
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoCut::on_render(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoCut::on_render(const Selection& selection) const
|
||||
{
|
||||
if (m_grabbers[0].dragging) {
|
||||
set_tooltip("Z: " + format(m_cut_z, 2));
|
||||
|
@ -176,14 +176,14 @@ void GLGizmoCut::on_render(const GLCanvas3D::Selection& selection) const
|
|||
m_grabbers[0].render(m_hover_id == 0, box.max_size());
|
||||
}
|
||||
|
||||
void GLGizmoCut::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoCut::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
render_grabbers_for_picking(selection.get_bounding_box());
|
||||
}
|
||||
|
||||
void GLGizmoCut::on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoCut::on_render_input_window(float x, float y, float bottom_limit, const Selection& selection)
|
||||
{
|
||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||
m_imgui->set_next_window_bg_alpha(0.5f);
|
||||
|
@ -207,7 +207,7 @@ void GLGizmoCut::on_render_input_window(float x, float y, float bottom_limit, co
|
|||
}
|
||||
}
|
||||
|
||||
void GLGizmoCut::update_max_z(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoCut::update_max_z(const Selection& selection) const
|
||||
{
|
||||
m_max_z = selection.get_bounding_box().size()(2);
|
||||
set_cut_z(m_cut_z);
|
||||
|
@ -219,7 +219,7 @@ void GLGizmoCut::set_cut_z(double cut_z) const
|
|||
m_cut_z = std::max(0.0, std::min(m_max_z, cut_z));
|
||||
}
|
||||
|
||||
void GLGizmoCut::perform_cut(const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoCut::perform_cut(const Selection& selection)
|
||||
{
|
||||
const auto instance_idx = selection.get_instance_idx();
|
||||
const auto object_idx = selection.get_object_idx();
|
||||
|
|
|
@ -33,17 +33,17 @@ protected:
|
|||
virtual bool on_init();
|
||||
virtual std::string on_get_name() const;
|
||||
virtual void on_set_state();
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection);
|
||||
virtual bool on_is_activable(const Selection& selection) const;
|
||||
virtual void on_start_dragging(const Selection& selection);
|
||||
virtual void on_update(const UpdateData& data, const Selection& selection);
|
||||
virtual void on_render(const Selection& selection) const;
|
||||
virtual void on_render_for_picking(const Selection& selection) const;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const Selection& selection);
|
||||
|
||||
private:
|
||||
void update_max_z(const GLCanvas3D::Selection& selection) const;
|
||||
void update_max_z(const Selection& selection) const;
|
||||
void set_cut_z(double cut_z) const;
|
||||
void perform_cut(const GLCanvas3D::Selection& selection);
|
||||
void perform_cut(const Selection& selection);
|
||||
double calc_projection(const Linef3& mouse_ray) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ std::string GLGizmoFlatten::on_get_name() const
|
|||
return L("Place on face [F]");
|
||||
}
|
||||
|
||||
bool GLGizmoFlatten::on_is_activable(const GLCanvas3D::Selection& selection) const
|
||||
bool GLGizmoFlatten::on_is_activable(const Selection& selection) const
|
||||
{
|
||||
return selection.is_single_full_instance();
|
||||
}
|
||||
|
||||
void GLGizmoFlatten::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoFlatten::on_start_dragging(const Selection& selection)
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ void GLGizmoFlatten::on_start_dragging(const GLCanvas3D::Selection& selection)
|
|||
}
|
||||
}
|
||||
|
||||
void GLGizmoFlatten::on_render(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoFlatten::on_render(const Selection& selection) const
|
||||
{
|
||||
::glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
@ -83,7 +83,7 @@ void GLGizmoFlatten::on_render(const GLCanvas3D::Selection& selection) const
|
|||
::glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void GLGizmoFlatten::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoFlatten::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
::glDisable(GL_BLEND);
|
||||
|
|
|
@ -49,11 +49,11 @@ public:
|
|||
protected:
|
||||
virtual bool on_init();
|
||||
virtual std::string on_get_name() const;
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection) {}
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
virtual bool on_is_activable(const Selection& selection) const;
|
||||
virtual void on_start_dragging(const Selection& selection);
|
||||
virtual void on_update(const UpdateData& data, const Selection& selection) {}
|
||||
virtual void on_render(const Selection& selection) const;
|
||||
virtual void on_render_for_picking(const Selection& selection) const;
|
||||
virtual void on_set_state()
|
||||
{
|
||||
if (m_state == On && is_plane_update_necessary())
|
||||
|
|
|
@ -51,7 +51,7 @@ std::string GLGizmoMove3D::on_get_name() const
|
|||
return L("Move [M]");
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoMove3D::on_start_dragging(const Selection& selection)
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ void GLGizmoMove3D::on_stop_dragging()
|
|||
m_displacement = Vec3d::Zero();
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_update(const UpdateData& data, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoMove3D::on_update(const UpdateData& data, const Selection& selection)
|
||||
{
|
||||
if (m_hover_id == 0)
|
||||
m_displacement(0) = calc_projection(data);
|
||||
|
@ -79,7 +79,7 @@ void GLGizmoMove3D::on_update(const UpdateData& data, const GLCanvas3D::Selectio
|
|||
m_displacement(2) = calc_projection(data);
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_render(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoMove3D::on_render(const Selection& selection) const
|
||||
{
|
||||
bool show_position = selection.is_single_full_instance();
|
||||
const Vec3d& position = selection.get_bounding_box().center();
|
||||
|
@ -155,7 +155,7 @@ void GLGizmoMove3D::on_render(const GLCanvas3D::Selection& selection) const
|
|||
}
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoMove3D::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
@ -166,7 +166,7 @@ void GLGizmoMove3D::on_render_for_picking(const GLCanvas3D::Selection& selection
|
|||
render_grabber_extension(Z, box, true);
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoMove3D::on_render_input_window(float x, float y, float bottom_limit, const Selection& selection)
|
||||
{
|
||||
#if !DISABLE_MOVE_ROTATE_SCALE_GIZMOS_IMGUI
|
||||
bool show_position = selection.is_single_full_instance();
|
||||
|
|
|
@ -37,12 +37,12 @@ public:
|
|||
protected:
|
||||
virtual bool on_init();
|
||||
virtual std::string on_get_name() const;
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
virtual void on_start_dragging(const Selection& selection);
|
||||
virtual void on_stop_dragging();
|
||||
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection);
|
||||
virtual void on_update(const UpdateData& data, const Selection& selection);
|
||||
virtual void on_render(const Selection& selection) const;
|
||||
virtual void on_render_for_picking(const Selection& selection) const;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const Selection& selection);
|
||||
|
||||
private:
|
||||
double calc_projection(const UpdateData& data) const;
|
||||
|
|
|
@ -80,7 +80,7 @@ bool GLGizmoRotate::on_init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void GLGizmoRotate::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoRotate::on_start_dragging(const Selection& selection)
|
||||
{
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
m_center = box.center();
|
||||
|
@ -91,7 +91,7 @@ void GLGizmoRotate::on_start_dragging(const GLCanvas3D::Selection& selection)
|
|||
m_snap_fine_out_radius = m_snap_fine_in_radius + m_radius * ScaleLongTooth;
|
||||
}
|
||||
|
||||
void GLGizmoRotate::on_update(const UpdateData& data, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoRotate::on_update(const UpdateData& data, const Selection& selection)
|
||||
{
|
||||
Vec2d mouse_pos = to_2d(mouse_position_in_local_plane(data.mouse_ray, selection));
|
||||
|
||||
|
@ -126,7 +126,7 @@ void GLGizmoRotate::on_update(const UpdateData& data, const GLCanvas3D::Selectio
|
|||
m_angle = theta;
|
||||
}
|
||||
|
||||
void GLGizmoRotate::on_render(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoRotate::on_render(const Selection& selection) const
|
||||
{
|
||||
if (!m_grabbers[0].enabled)
|
||||
return;
|
||||
|
@ -183,7 +183,7 @@ void GLGizmoRotate::on_render(const GLCanvas3D::Selection& selection) const
|
|||
::glPopMatrix();
|
||||
}
|
||||
|
||||
void GLGizmoRotate::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoRotate::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
@ -347,7 +347,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
|||
::glDisable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
void GLGizmoRotate::transform_to_local(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoRotate::transform_to_local(const Selection& selection) const
|
||||
{
|
||||
::glTranslated(m_center(0), m_center(1), m_center(2));
|
||||
|
||||
|
@ -380,7 +380,7 @@ void GLGizmoRotate::transform_to_local(const GLCanvas3D::Selection& selection) c
|
|||
}
|
||||
}
|
||||
|
||||
Vec3d GLGizmoRotate::mouse_position_in_local_plane(const Linef3& mouse_ray, const GLCanvas3D::Selection& selection) const
|
||||
Vec3d GLGizmoRotate::mouse_position_in_local_plane(const Linef3& mouse_ray, const Selection& selection) const
|
||||
{
|
||||
double half_pi = 0.5 * (double)PI;
|
||||
|
||||
|
@ -457,7 +457,7 @@ std::string GLGizmoRotate3D::on_get_name() const
|
|||
return L("Rotate [R]");
|
||||
}
|
||||
|
||||
void GLGizmoRotate3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoRotate3D::on_start_dragging(const Selection& selection)
|
||||
{
|
||||
if ((0 <= m_hover_id) && (m_hover_id < 3))
|
||||
m_gizmos[m_hover_id].start_dragging(selection);
|
||||
|
@ -469,7 +469,7 @@ void GLGizmoRotate3D::on_stop_dragging()
|
|||
m_gizmos[m_hover_id].stop_dragging();
|
||||
}
|
||||
|
||||
void GLGizmoRotate3D::on_render(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoRotate3D::on_render(const Selection& selection) const
|
||||
{
|
||||
::glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
@ -483,7 +483,7 @@ void GLGizmoRotate3D::on_render(const GLCanvas3D::Selection& selection) const
|
|||
m_gizmos[Z].render(selection);
|
||||
}
|
||||
|
||||
void GLGizmoRotate3D::on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoRotate3D::on_render_input_window(float x, float y, float bottom_limit, const Selection& selection)
|
||||
{
|
||||
#if !DISABLE_MOVE_ROTATE_SCALE_GIZMOS_IMGUI
|
||||
Vec3d rotation(Geometry::rad2deg(m_gizmos[0].get_angle()), Geometry::rad2deg(m_gizmos[1].get_angle()), Geometry::rad2deg(m_gizmos[2].get_angle()));
|
||||
|
|
|
@ -52,10 +52,10 @@ public:
|
|||
protected:
|
||||
virtual bool on_init();
|
||||
virtual std::string on_get_name() const { return ""; }
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_start_dragging(const Selection& selection);
|
||||
virtual void on_update(const UpdateData& data, const Selection& selection);
|
||||
virtual void on_render(const Selection& selection) const;
|
||||
virtual void on_render_for_picking(const Selection& selection) const;
|
||||
|
||||
private:
|
||||
void render_circle() const;
|
||||
|
@ -66,9 +66,9 @@ private:
|
|||
void render_grabber(const BoundingBoxf3& box) const;
|
||||
void render_grabber_extension(const BoundingBoxf3& box, bool picking) const;
|
||||
|
||||
void transform_to_local(const GLCanvas3D::Selection& selection) const;
|
||||
void transform_to_local(const Selection& selection) const;
|
||||
// returns the intersection of the mouse ray with the plane perpendicular to the gizmo axis, in local coordinate
|
||||
Vec3d mouse_position_in_local_plane(const Linef3& mouse_ray, const GLCanvas3D::Selection& selection) const;
|
||||
Vec3d mouse_position_in_local_plane(const Linef3& mouse_ray, const Selection& selection) const;
|
||||
};
|
||||
|
||||
class GLGizmoRotate3D : public GLGizmoBase
|
||||
|
@ -102,7 +102,7 @@ protected:
|
|||
m_gizmos[i].set_hover_id((m_hover_id == i) ? 0 : -1);
|
||||
}
|
||||
}
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); }
|
||||
virtual bool on_is_activable(const Selection& selection) const { return !selection.is_wipe_tower(); }
|
||||
virtual void on_enable_grabber(unsigned int id)
|
||||
{
|
||||
if ((0 <= id) && (id < 3))
|
||||
|
@ -113,17 +113,17 @@ protected:
|
|||
if ((0 <= id) && (id < 3))
|
||||
m_gizmos[id].disable_grabber(0);
|
||||
}
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
virtual void on_start_dragging(const Selection& selection);
|
||||
virtual void on_stop_dragging();
|
||||
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection)
|
||||
virtual void on_update(const UpdateData& data, const Selection& selection)
|
||||
{
|
||||
for (GLGizmoRotate& g : m_gizmos)
|
||||
{
|
||||
g.update(data, selection);
|
||||
}
|
||||
}
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
virtual void on_render(const Selection& selection) const;
|
||||
virtual void on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
for (const GLGizmoRotate& g : m_gizmos)
|
||||
{
|
||||
|
@ -131,7 +131,7 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection);
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const Selection& selection);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ std::string GLGizmoScale3D::on_get_name() const
|
|||
return L("Scale [S]");
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoScale3D::on_start_dragging(const Selection& selection)
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ void GLGizmoScale3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
|||
}
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::on_update(const UpdateData& data, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoScale3D::on_update(const UpdateData& data, const Selection& selection)
|
||||
{
|
||||
if ((m_hover_id == 0) || (m_hover_id == 1))
|
||||
do_scale_x(data);
|
||||
|
@ -72,7 +72,7 @@ void GLGizmoScale3D::on_update(const UpdateData& data, const GLCanvas3D::Selecti
|
|||
do_scale_uniform(data);
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::on_render(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoScale3D::on_render(const Selection& selection) const
|
||||
{
|
||||
bool single_instance = selection.is_single_full_instance();
|
||||
bool single_volume = selection.is_single_modifier() || selection.is_single_volume();
|
||||
|
@ -121,7 +121,7 @@ void GLGizmoScale3D::on_render(const GLCanvas3D::Selection& selection) const
|
|||
if (single_instance)
|
||||
{
|
||||
// calculate bounding box in instance local reference system
|
||||
const GLCanvas3D::Selection::IndicesList& idxs = selection.get_volume_idxs();
|
||||
const Selection::IndicesList& idxs = selection.get_volume_idxs();
|
||||
for (unsigned int idx : idxs)
|
||||
{
|
||||
const GLVolume* vol = selection.get_volume(idx);
|
||||
|
@ -267,14 +267,14 @@ void GLGizmoScale3D::on_render(const GLCanvas3D::Selection& selection) const
|
|||
}
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoScale3D::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
render_grabbers_for_picking(selection.get_bounding_box());
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoScale3D::on_render_input_window(float x, float y, float bottom_limit, const Selection& selection)
|
||||
{
|
||||
#if !DISABLE_MOVE_ROTATE_SCALE_GIZMOS_IMGUI
|
||||
bool single_instance = selection.is_single_full_instance();
|
||||
|
|
|
@ -37,12 +37,12 @@ public:
|
|||
protected:
|
||||
virtual bool on_init();
|
||||
virtual std::string on_get_name() const;
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); }
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
virtual void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection);
|
||||
virtual bool on_is_activable(const Selection& selection) const { return !selection.is_wipe_tower(); }
|
||||
virtual void on_start_dragging(const Selection& selection);
|
||||
virtual void on_update(const UpdateData& data, const Selection& selection);
|
||||
virtual void on_render(const Selection& selection) const;
|
||||
virtual void on_render_for_picking(const Selection& selection) const;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const Selection& selection);
|
||||
|
||||
private:
|
||||
void render_grabbers_connection(unsigned int id_1, unsigned int id_2) const;
|
||||
|
|
|
@ -42,7 +42,7 @@ bool GLGizmoSlaSupports::on_init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const Selection& selection)
|
||||
{
|
||||
m_starting_center = Vec3d::Zero();
|
||||
m_old_model_object = m_model_object;
|
||||
|
@ -72,7 +72,7 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const G
|
|||
}
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::on_render(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoSlaSupports::on_render(const Selection& selection) const
|
||||
{
|
||||
::glEnable(GL_BLEND);
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
@ -123,14 +123,14 @@ void GLGizmoSlaSupports::render_selection_rectangle() const
|
|||
::glPopAttrib(); // restore former MatrixMode
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
void GLGizmoSlaSupports::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
||||
render_points(selection, true);
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::render_points(const GLCanvas3D::Selection& selection, bool picking) const
|
||||
void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) const
|
||||
{
|
||||
if (m_quadric == nullptr || !selection.is_from_single_instance())
|
||||
return;
|
||||
|
@ -276,7 +276,7 @@ std::pair<Vec3f, Vec3f> GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse
|
|||
|
||||
igl::Hit hit;
|
||||
|
||||
const GLCanvas3D::Selection& selection = m_parent.get_selection();
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
double z_offset = volume->get_sla_shift_z();
|
||||
|
||||
|
@ -380,7 +380,7 @@ bool GLGizmoSlaSupports::mouse_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
GLdouble projection_matrix[16];
|
||||
::glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix);
|
||||
|
||||
const GLCanvas3D::Selection& selection = m_parent.get_selection();
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
double z_offset = volume->get_sla_shift_z();
|
||||
|
||||
|
@ -484,7 +484,7 @@ void GLGizmoSlaSupports::delete_selected_points(bool force)
|
|||
//m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::on_update(const UpdateData& data, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoSlaSupports::on_update(const UpdateData& data, const Selection& selection)
|
||||
{
|
||||
if (m_editing_mode && m_hover_id != -1 && data.mouse_pos && (!m_editing_mode_cache[m_hover_id].support_point.is_new_island || !m_lock_unique_islands)) {
|
||||
std::pair<Vec3f, Vec3f> pos_and_normal;
|
||||
|
@ -542,7 +542,7 @@ void GLGizmoSlaSupports::update_cache_entry_normal(unsigned int i) const
|
|||
|
||||
|
||||
|
||||
void GLGizmoSlaSupports::on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoSlaSupports::on_render_input_window(float x, float y, float bottom_limit, const Selection& selection)
|
||||
{
|
||||
if (!m_model_object)
|
||||
return;
|
||||
|
@ -686,14 +686,14 @@ RENDER_AGAIN:
|
|||
m_parent.set_as_dirty();
|
||||
}
|
||||
|
||||
bool GLGizmoSlaSupports::on_is_activable(const GLCanvas3D::Selection& selection) const
|
||||
bool GLGizmoSlaSupports::on_is_activable(const Selection& selection) const
|
||||
{
|
||||
if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA
|
||||
|| !selection.is_from_single_instance())
|
||||
return false;
|
||||
|
||||
// Check that none of the selected volumes is outside.
|
||||
const GLCanvas3D::Selection::IndicesList& list = selection.get_volume_idxs();
|
||||
const Selection::IndicesList& list = selection.get_volume_idxs();
|
||||
for (const auto& idx : list)
|
||||
if (selection.get_volume(idx)->is_outside)
|
||||
return false;
|
||||
|
@ -750,7 +750,7 @@ void GLGizmoSlaSupports::on_set_state()
|
|||
|
||||
|
||||
|
||||
void GLGizmoSlaSupports::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
void GLGizmoSlaSupports::on_start_dragging(const Selection& selection)
|
||||
{
|
||||
if (m_hover_id != -1) {
|
||||
select_point(NoPoints);
|
||||
|
|
|
@ -58,19 +58,19 @@ public:
|
|||
GLGizmoSlaSupports(GLCanvas3D& parent, unsigned int sprite_id);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
virtual ~GLGizmoSlaSupports();
|
||||
void set_sla_support_data(ModelObject* model_object, const GLCanvas3D::Selection& selection);
|
||||
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
|
||||
bool mouse_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down);
|
||||
void delete_selected_points(bool force = false);
|
||||
std::pair<float, float> get_sla_clipping_plane() const;
|
||||
|
||||
private:
|
||||
bool on_init();
|
||||
void on_update(const UpdateData& data, const GLCanvas3D::Selection& selection);
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
void on_update(const UpdateData& data, const Selection& selection);
|
||||
virtual void on_render(const Selection& selection) const;
|
||||
virtual void on_render_for_picking(const Selection& selection) const;
|
||||
|
||||
void render_selection_rectangle() const;
|
||||
void render_points(const GLCanvas3D::Selection& selection, bool picking = false) const;
|
||||
void render_points(const Selection& selection, bool picking = false) const;
|
||||
bool is_mesh_update_necessary() const;
|
||||
void update_mesh();
|
||||
void update_cache_entry_normal(unsigned int i) const;
|
||||
|
@ -113,11 +113,11 @@ private:
|
|||
|
||||
protected:
|
||||
void on_set_state() override;
|
||||
void on_start_dragging(const GLCanvas3D::Selection& selection) override;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const GLCanvas3D::Selection& selection) override;
|
||||
void on_start_dragging(const Selection& selection) override;
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit, const Selection& selection) override;
|
||||
|
||||
virtual std::string on_get_name() const;
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const;
|
||||
virtual bool on_is_activable(const Selection& selection) const;
|
||||
virtual bool on_is_selectable() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "MainFrame.hpp"
|
||||
#include "3DScene.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
#include "Selection.hpp"
|
||||
#include "GLToolbar.hpp"
|
||||
#include "GUI_Preview.hpp"
|
||||
#include "3DBed.hpp"
|
||||
|
@ -1153,8 +1154,8 @@ struct Plater::priv
|
|||
std::vector<size_t> load_model_objects(const ModelObjectPtrs &model_objects);
|
||||
std::unique_ptr<CheckboxFileDialog> get_export_file(GUI::FileType file_type);
|
||||
|
||||
const GLCanvas3D::Selection& get_selection() const;
|
||||
GLCanvas3D::Selection& get_selection();
|
||||
const Selection& get_selection() const;
|
||||
Selection& get_selection();
|
||||
int get_selected_object_idx() const;
|
||||
int get_selected_volume_idx() const;
|
||||
void selection_changed();
|
||||
|
@ -1641,7 +1642,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
// automatic selection of added objects
|
||||
if (!obj_idxs.empty() && (view3D != nullptr))
|
||||
{
|
||||
GLCanvas3D::Selection& selection = view3D->get_canvas3d()->get_selection();
|
||||
Selection& selection = view3D->get_canvas3d()->get_selection();
|
||||
selection.clear();
|
||||
for (size_t idx : obj_idxs)
|
||||
{
|
||||
|
@ -1790,12 +1791,12 @@ std::unique_ptr<CheckboxFileDialog> Plater::priv::get_export_file(GUI::FileType
|
|||
return dlg;
|
||||
}
|
||||
|
||||
const GLCanvas3D::Selection& Plater::priv::get_selection() const
|
||||
const Selection& Plater::priv::get_selection() const
|
||||
{
|
||||
return view3D->get_canvas3d()->get_selection();
|
||||
}
|
||||
|
||||
GLCanvas3D::Selection& Plater::priv::get_selection()
|
||||
Selection& Plater::priv::get_selection()
|
||||
{
|
||||
return view3D->get_canvas3d()->get_selection();
|
||||
}
|
||||
|
|
1670
src/slic3r/GUI/Selection.cpp
Normal file
1670
src/slic3r/GUI/Selection.cpp
Normal file
File diff suppressed because it is too large
Load diff
301
src/slic3r/GUI/Selection.hpp
Normal file
301
src/slic3r/GUI/Selection.hpp
Normal file
|
@ -0,0 +1,301 @@
|
|||
#ifndef slic3r_GUI_Selection_hpp_
|
||||
#define slic3r_GUI_Selection_hpp_
|
||||
|
||||
#include <set>
|
||||
#include "libslic3r/Geometry.hpp"
|
||||
#include "3DScene.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class TransformationType
|
||||
{
|
||||
public:
|
||||
enum Enum {
|
||||
// Transforming in a world coordinate system
|
||||
World = 0,
|
||||
// Transforming in a local coordinate system
|
||||
Local = 1,
|
||||
// Absolute transformations, allowed in local coordinate system only.
|
||||
Absolute = 0,
|
||||
// Relative transformations, allowed in both local and world coordinate system.
|
||||
Relative = 2,
|
||||
// For group selection, the transformation is performed as if the group made a single solid body.
|
||||
Joint = 0,
|
||||
// For group selection, the transformation is performed on each object independently.
|
||||
Independent = 4,
|
||||
|
||||
World_Relative_Joint = World | Relative | Joint,
|
||||
World_Relative_Independent = World | Relative | Independent,
|
||||
Local_Absolute_Joint = Local | Absolute | Joint,
|
||||
Local_Absolute_Independent = Local | Absolute | Independent,
|
||||
Local_Relative_Joint = Local | Relative | Joint,
|
||||
Local_Relative_Independent = Local | Relative | Independent,
|
||||
};
|
||||
|
||||
TransformationType() : m_value(World) {}
|
||||
TransformationType(Enum value) : m_value(value) {}
|
||||
TransformationType& operator=(Enum value) { m_value = value; return *this; }
|
||||
|
||||
Enum operator()() const { return m_value; }
|
||||
bool has(Enum v) const { return ((unsigned int)m_value & (unsigned int)v) != 0; }
|
||||
|
||||
void set_world() { this->remove(Local); }
|
||||
void set_local() { this->add(Local); }
|
||||
void set_absolute() { this->remove(Relative); }
|
||||
void set_relative() { this->add(Relative); }
|
||||
void set_joint() { this->remove(Independent); }
|
||||
void set_independent() { this->add(Independent); }
|
||||
|
||||
bool world() const { return !this->has(Local); }
|
||||
bool local() const { return this->has(Local); }
|
||||
bool absolute() const { return !this->has(Relative); }
|
||||
bool relative() const { return this->has(Relative); }
|
||||
bool joint() const { return !this->has(Independent); }
|
||||
bool independent() const { return this->has(Independent); }
|
||||
|
||||
private:
|
||||
void add(Enum v) { m_value = Enum((unsigned int)m_value | (unsigned int)v); }
|
||||
void remove(Enum v) { m_value = Enum((unsigned int)m_value & (~(unsigned int)v)); }
|
||||
|
||||
Enum m_value;
|
||||
};
|
||||
|
||||
class Selection
|
||||
{
|
||||
public:
|
||||
typedef std::set<unsigned int> IndicesList;
|
||||
|
||||
enum EMode : unsigned char
|
||||
{
|
||||
Volume,
|
||||
Instance
|
||||
};
|
||||
|
||||
enum EType : unsigned char
|
||||
{
|
||||
Invalid,
|
||||
Empty,
|
||||
WipeTower,
|
||||
SingleModifier,
|
||||
MultipleModifier,
|
||||
SingleVolume,
|
||||
MultipleVolume,
|
||||
SingleFullObject,
|
||||
MultipleFullObject,
|
||||
SingleFullInstance,
|
||||
MultipleFullInstance,
|
||||
Mixed
|
||||
};
|
||||
|
||||
private:
|
||||
struct VolumeCache
|
||||
{
|
||||
private:
|
||||
struct TransformCache
|
||||
{
|
||||
Vec3d position;
|
||||
Vec3d rotation;
|
||||
Vec3d scaling_factor;
|
||||
Vec3d mirror;
|
||||
Transform3d rotation_matrix;
|
||||
Transform3d scale_matrix;
|
||||
Transform3d mirror_matrix;
|
||||
Transform3d full_matrix;
|
||||
|
||||
TransformCache();
|
||||
explicit TransformCache(const Geometry::Transformation& transform);
|
||||
};
|
||||
|
||||
TransformCache m_volume;
|
||||
TransformCache m_instance;
|
||||
|
||||
public:
|
||||
VolumeCache() {}
|
||||
VolumeCache(const Geometry::Transformation& volume_transform, const Geometry::Transformation& instance_transform);
|
||||
|
||||
const Vec3d& get_volume_position() const { return m_volume.position; }
|
||||
const Vec3d& get_volume_rotation() const { return m_volume.rotation; }
|
||||
const Vec3d& get_volume_scaling_factor() const { return m_volume.scaling_factor; }
|
||||
const Vec3d& get_volume_mirror() const { return m_volume.mirror; }
|
||||
const Transform3d& get_volume_rotation_matrix() const { return m_volume.rotation_matrix; }
|
||||
const Transform3d& get_volume_scale_matrix() const { return m_volume.scale_matrix; }
|
||||
const Transform3d& get_volume_mirror_matrix() const { return m_volume.mirror_matrix; }
|
||||
const Transform3d& get_volume_full_matrix() const { return m_volume.full_matrix; }
|
||||
|
||||
const Vec3d& get_instance_position() const { return m_instance.position; }
|
||||
const Vec3d& get_instance_rotation() const { return m_instance.rotation; }
|
||||
const Vec3d& get_instance_scaling_factor() const { return m_instance.scaling_factor; }
|
||||
const Vec3d& get_instance_mirror() const { return m_instance.mirror; }
|
||||
const Transform3d& get_instance_rotation_matrix() const { return m_instance.rotation_matrix; }
|
||||
const Transform3d& get_instance_scale_matrix() const { return m_instance.scale_matrix; }
|
||||
const Transform3d& get_instance_mirror_matrix() const { return m_instance.mirror_matrix; }
|
||||
const Transform3d& get_instance_full_matrix() const { return m_instance.full_matrix; }
|
||||
};
|
||||
|
||||
typedef std::map<unsigned int, VolumeCache> VolumesCache;
|
||||
typedef std::set<int> InstanceIdxsList;
|
||||
typedef std::map<int, InstanceIdxsList> ObjectIdxsToInstanceIdxsMap;
|
||||
|
||||
struct Cache
|
||||
{
|
||||
// Cache of GLVolume derived transformation matrices, valid during mouse dragging.
|
||||
VolumesCache volumes_data;
|
||||
// Center of the dragged selection, valid during mouse dragging.
|
||||
Vec3d dragging_center;
|
||||
// Map from indices of ModelObject instances in Model::objects
|
||||
// to a set of indices of ModelVolume instances in ModelObject::instances
|
||||
// Here the index means a position inside the respective std::vector, not ModelID.
|
||||
ObjectIdxsToInstanceIdxsMap content;
|
||||
};
|
||||
|
||||
// Volumes owned by GLCanvas3D.
|
||||
GLVolumePtrs* m_volumes;
|
||||
// Model, not owned.
|
||||
Model* m_model;
|
||||
|
||||
bool m_valid;
|
||||
EMode m_mode;
|
||||
EType m_type;
|
||||
// set of indices to m_volumes
|
||||
IndicesList m_list;
|
||||
Cache m_cache;
|
||||
mutable BoundingBoxf3 m_bounding_box;
|
||||
mutable bool m_bounding_box_dirty;
|
||||
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
GLUquadricObj* m_quadric;
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
mutable GLArrow m_arrow;
|
||||
mutable GLCurvedArrow m_curved_arrow;
|
||||
|
||||
mutable float m_scale_factor;
|
||||
|
||||
public:
|
||||
Selection();
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
~Selection();
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
|
||||
void set_volumes(GLVolumePtrs* volumes);
|
||||
bool init(bool useVBOs);
|
||||
|
||||
Model* get_model() const { return m_model; }
|
||||
void set_model(Model* model);
|
||||
|
||||
EMode get_mode() const { return m_mode; }
|
||||
void set_mode(EMode mode) { m_mode = mode; }
|
||||
|
||||
void add(unsigned int volume_idx, bool as_single_selection = true);
|
||||
void remove(unsigned int volume_idx);
|
||||
|
||||
void add_object(unsigned int object_idx, bool as_single_selection = true);
|
||||
void remove_object(unsigned int object_idx);
|
||||
|
||||
void add_instance(unsigned int object_idx, unsigned int instance_idx, bool as_single_selection = true);
|
||||
void remove_instance(unsigned int object_idx, unsigned int instance_idx);
|
||||
|
||||
void add_volume(unsigned int object_idx, unsigned int volume_idx, int instance_idx, bool as_single_selection = true);
|
||||
void remove_volume(unsigned int object_idx, unsigned int volume_idx);
|
||||
|
||||
void add_all();
|
||||
|
||||
// Update the selection based on the map from old indices to new indices after m_volumes changed.
|
||||
// If the current selection is by instance, this call may select newly added volumes, if they belong to already selected instances.
|
||||
void volumes_changed(const std::vector<size_t> &map_volume_old_to_new);
|
||||
void clear();
|
||||
|
||||
bool is_empty() const { return m_type == Empty; }
|
||||
bool is_wipe_tower() const { return m_type == WipeTower; }
|
||||
bool is_modifier() const { return (m_type == SingleModifier) || (m_type == MultipleModifier); }
|
||||
bool is_single_modifier() const { return m_type == SingleModifier; }
|
||||
bool is_multiple_modifier() const { return m_type == MultipleModifier; }
|
||||
bool is_single_full_instance() const;
|
||||
bool is_multiple_full_instance() const { return m_type == MultipleFullInstance; }
|
||||
bool is_single_full_object() const { return m_type == SingleFullObject; }
|
||||
bool is_multiple_full_object() const { return m_type == MultipleFullObject; }
|
||||
bool is_single_volume() const { return m_type == SingleVolume; }
|
||||
bool is_multiple_volume() const { return m_type == MultipleVolume; }
|
||||
bool is_mixed() const { return m_type == Mixed; }
|
||||
bool is_from_single_instance() const { return get_instance_idx() != -1; }
|
||||
bool is_from_single_object() const;
|
||||
|
||||
bool contains_volume(unsigned int volume_idx) const { return std::find(m_list.begin(), m_list.end(), volume_idx) != m_list.end(); }
|
||||
bool requires_uniform_scale() const;
|
||||
|
||||
// Returns the the object id if the selection is from a single object, otherwise is -1
|
||||
int get_object_idx() const;
|
||||
// Returns the instance id if the selection is from a single object and from a single instance, otherwise is -1
|
||||
int get_instance_idx() const;
|
||||
// Returns the indices of selected instances.
|
||||
// Can only be called if selection is from a single object.
|
||||
const InstanceIdxsList& get_instance_idxs() const;
|
||||
|
||||
const IndicesList& get_volume_idxs() const { return m_list; }
|
||||
const GLVolume* get_volume(unsigned int volume_idx) const;
|
||||
|
||||
const ObjectIdxsToInstanceIdxsMap& get_content() const { return m_cache.content; }
|
||||
|
||||
unsigned int volumes_count() const { return (unsigned int)m_list.size(); }
|
||||
const BoundingBoxf3& get_bounding_box() const;
|
||||
|
||||
void start_dragging();
|
||||
|
||||
void translate(const Vec3d& displacement, bool local = false);
|
||||
void rotate(const Vec3d& rotation, TransformationType transformation_type);
|
||||
void flattening_rotate(const Vec3d& normal);
|
||||
void scale(const Vec3d& scale, bool local);
|
||||
void mirror(Axis axis);
|
||||
|
||||
void translate(unsigned int object_idx, const Vec3d& displacement);
|
||||
void translate(unsigned int object_idx, unsigned int instance_idx, const Vec3d& displacement);
|
||||
|
||||
void erase();
|
||||
|
||||
void render(float scale_factor = 1.0) const;
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
void render_center() const;
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
void render_sidebar_hints(const std::string& sidebar_field) const;
|
||||
|
||||
bool requires_local_axes() const;
|
||||
|
||||
private:
|
||||
void _update_valid();
|
||||
void _update_type();
|
||||
void _set_caches();
|
||||
void _add_volume(unsigned int volume_idx);
|
||||
void _add_instance(unsigned int object_idx, unsigned int instance_idx);
|
||||
void _add_object(unsigned int object_idx);
|
||||
void _remove_volume(unsigned int volume_idx);
|
||||
void _remove_instance(unsigned int object_idx, unsigned int instance_idx);
|
||||
void _remove_object(unsigned int object_idx);
|
||||
void _calc_bounding_box() const;
|
||||
void _render_selected_volumes() const;
|
||||
void _render_synchronized_volumes() const;
|
||||
void _render_bounding_box(const BoundingBoxf3& box, float* color) const;
|
||||
void _render_sidebar_position_hints(const std::string& sidebar_field) const;
|
||||
void _render_sidebar_rotation_hints(const std::string& sidebar_field) const;
|
||||
void _render_sidebar_scale_hints(const std::string& sidebar_field) const;
|
||||
void _render_sidebar_size_hints(const std::string& sidebar_field) const;
|
||||
void _render_sidebar_position_hint(Axis axis) const;
|
||||
void _render_sidebar_rotation_hint(Axis axis) const;
|
||||
void _render_sidebar_scale_hint(Axis axis) const;
|
||||
void _render_sidebar_size_hint(Axis axis, double length) const;
|
||||
enum SyncRotationType {
|
||||
// Do not synchronize rotation. Either not rotating at all, or rotating by world Z axis.
|
||||
SYNC_ROTATION_NONE = 0,
|
||||
// Synchronize fully. Used from "place on bed" feature.
|
||||
SYNC_ROTATION_FULL = 1,
|
||||
// Synchronize after rotation by an axis not parallel with Z.
|
||||
SYNC_ROTATION_GENERAL = 2,
|
||||
};
|
||||
void _synchronize_unselected_instances(SyncRotationType sync_rotation_type);
|
||||
void _synchronize_unselected_volumes();
|
||||
void _ensure_on_bed();
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_GUI_Selection_hpp_
|
Loading…
Reference in a new issue