mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
1st installment of new selections (disabled)
This commit is contained in:
parent
04e193011c
commit
384cfa0e6d
14 changed files with 1204 additions and 32 deletions
|
@ -707,16 +707,23 @@ void ModelObject::center_around_origin()
|
||||||
if (v->is_model_part())
|
if (v->is_model_part())
|
||||||
bb.merge(v->mesh.bounding_box());
|
bb.merge(v->mesh.bounding_box());
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
// Shift is the vector from the center of the bounding box to the origin
|
||||||
|
Vec3d shift = -bb.center();
|
||||||
|
#else
|
||||||
// Shift is the vector from the center of the bottom face of the bounding box to the origin
|
// Shift is the vector from the center of the bottom face of the bounding box to the origin
|
||||||
Vec3d shift = -bb.center();
|
Vec3d shift = -bb.center();
|
||||||
shift(2) = -bb.min(2);
|
shift(2) = -bb.min(2);
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
this->translate(shift);
|
this->translate(shift);
|
||||||
this->origin_translation += shift;
|
this->origin_translation += shift;
|
||||||
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
// set z to zero, translation in z has already been done within the mesh
|
// set z to zero, translation in z has already been done within the mesh
|
||||||
shift(2) = 0.0;
|
shift(2) = 0.0;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
|
|
||||||
if (!this->instances.empty()) {
|
if (!this->instances.empty()) {
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#define ENABLE_GIZMOS_RESET (1 && ENABLE_1_42_0)
|
#define ENABLE_GIZMOS_RESET (1 && ENABLE_1_42_0)
|
||||||
// Uses a unique opengl context
|
// Uses a unique opengl context
|
||||||
#define ENABLE_USE_UNIQUE_GLCONTEXT (1 && ENABLE_1_42_0)
|
#define ENABLE_USE_UNIQUE_GLCONTEXT (1 && ENABLE_1_42_0)
|
||||||
|
// New selections
|
||||||
|
#define ENABLE_EXTENDED_SELECTION (0 && ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM)
|
||||||
|
|
||||||
#endif // _technologies_h_
|
#endif // _technologies_h_
|
||||||
|
|
||||||
|
|
|
@ -209,8 +209,10 @@ GLVolume::GLVolume(float r, float g, float b, float a)
|
||||||
, m_transformed_convex_hull_bounding_box_dirty(true)
|
, m_transformed_convex_hull_bounding_box_dirty(true)
|
||||||
, m_convex_hull(nullptr)
|
, m_convex_hull(nullptr)
|
||||||
, composite_id(-1)
|
, composite_id(-1)
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
, select_group_id(-1)
|
, select_group_id(-1)
|
||||||
, drag_group_id(-1)
|
, drag_group_id(-1)
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
, extruder_id(0)
|
, extruder_id(0)
|
||||||
, selected(false)
|
, selected(false)
|
||||||
, is_active(true)
|
, is_active(true)
|
||||||
|
@ -311,6 +313,13 @@ void GLVolume::set_offset(const Vec3d& offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
const Vec3d& GLVolume::get_scaling_factor() const
|
||||||
|
{
|
||||||
|
return m_scaling_factor;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
void GLVolume::set_scaling_factor(const Vec3d& scaling_factor)
|
void GLVolume::set_scaling_factor(const Vec3d& scaling_factor)
|
||||||
{
|
{
|
||||||
if (m_scaling_factor != scaling_factor)
|
if (m_scaling_factor != scaling_factor)
|
||||||
|
@ -339,6 +348,7 @@ void GLVolume::set_convex_hull(const TriangleMesh& convex_hull)
|
||||||
m_convex_hull = &convex_hull;
|
m_convex_hull = &convex_hull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void GLVolume::set_select_group_id(const std::string& select_by)
|
void GLVolume::set_select_group_id(const std::string& select_by)
|
||||||
{
|
{
|
||||||
if (select_by == "object")
|
if (select_by == "object")
|
||||||
|
@ -356,6 +366,7 @@ void GLVolume::set_drag_group_id(const std::string& drag_by)
|
||||||
else if (drag_by == "instance")
|
else if (drag_by == "instance")
|
||||||
drag_group_id = object_idx() * 1000 + instance_idx();
|
drag_group_id = object_idx() * 1000 + instance_idx();
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
const Transform3f& GLVolume::world_matrix() const
|
const Transform3f& GLVolume::world_matrix() const
|
||||||
{
|
{
|
||||||
|
@ -740,8 +751,10 @@ std::vector<int> GLVolumeCollection::load_object(
|
||||||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||||
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
||||||
v.composite_id = obj_idx * 1000000 + volume_idx * 1000 + instance_idx;
|
v.composite_id = obj_idx * 1000000 + volume_idx * 1000 + instance_idx;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
v.set_select_group_id(select_by);
|
v.set_select_group_id(select_by);
|
||||||
v.set_drag_group_id(drag_by);
|
v.set_drag_group_id(drag_by);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
if (model_volume->is_model_part())
|
if (model_volume->is_model_part())
|
||||||
{
|
{
|
||||||
v.set_convex_hull(model_volume->get_convex_hull());
|
v.set_convex_hull(model_volume->get_convex_hull());
|
||||||
|
@ -834,8 +847,10 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
||||||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||||
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
||||||
v.composite_id = obj_idx * 1000000;
|
v.composite_id = obj_idx * 1000000;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
v.select_group_id = obj_idx * 1000000;
|
v.select_group_id = obj_idx * 1000000;
|
||||||
v.drag_group_id = obj_idx * 1000;
|
v.drag_group_id = obj_idx * 1000;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
v.is_wipe_tower = true;
|
v.is_wipe_tower = true;
|
||||||
v.shader_outside_printer_detection_enabled = ! size_unknown;
|
v.shader_outside_printer_detection_enabled = ! size_unknown;
|
||||||
return int(this->volumes.size() - 1);
|
return int(this->volumes.size() - 1);
|
||||||
|
@ -1031,6 +1046,7 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void GLVolumeCollection::set_select_by(const std::string& select_by)
|
void GLVolumeCollection::set_select_by(const std::string& select_by)
|
||||||
{
|
{
|
||||||
for (GLVolume *vol : this->volumes)
|
for (GLVolume *vol : this->volumes)
|
||||||
|
@ -1048,6 +1064,7 @@ void GLVolumeCollection::set_drag_by(const std::string& drag_by)
|
||||||
vol->set_drag_group_id(drag_by);
|
vol->set_drag_group_id(drag_by);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
std::vector<double> GLVolumeCollection::get_current_print_zs(bool active_only) const
|
std::vector<double> GLVolumeCollection::get_current_print_zs(bool active_only) const
|
||||||
{
|
{
|
||||||
|
@ -1850,10 +1867,12 @@ bool _3DScene::move_volume_down(wxGLCanvas* canvas, unsigned int id)
|
||||||
return s_canvas_mgr.move_volume_down(canvas, id);
|
return s_canvas_mgr.move_volume_down(canvas, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void _3DScene::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections)
|
void _3DScene::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections)
|
||||||
{
|
{
|
||||||
s_canvas_mgr.set_objects_selections(canvas, selections);
|
s_canvas_mgr.set_objects_selections(canvas, selections);
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
void _3DScene::set_config(wxGLCanvas* canvas, DynamicPrintConfig* config)
|
void _3DScene::set_config(wxGLCanvas* canvas, DynamicPrintConfig* config)
|
||||||
{
|
{
|
||||||
|
@ -1900,6 +1919,7 @@ void _3DScene::set_color_by(wxGLCanvas* canvas, const std::string& value)
|
||||||
s_canvas_mgr.set_color_by(canvas, value);
|
s_canvas_mgr.set_color_by(canvas, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void _3DScene::set_select_by(wxGLCanvas* canvas, const std::string& value)
|
void _3DScene::set_select_by(wxGLCanvas* canvas, const std::string& value)
|
||||||
{
|
{
|
||||||
s_canvas_mgr.set_select_by(canvas, value);
|
s_canvas_mgr.set_select_by(canvas, value);
|
||||||
|
@ -1914,6 +1934,7 @@ std::string _3DScene::get_select_by(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
return s_canvas_mgr.get_select_by(canvas);
|
return s_canvas_mgr.get_select_by(canvas);
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
bool _3DScene::is_layers_editing_enabled(wxGLCanvas* canvas)
|
bool _3DScene::is_layers_editing_enabled(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
|
|
|
@ -292,10 +292,12 @@ public:
|
||||||
float render_color[4];
|
float render_color[4];
|
||||||
// An ID containing the object ID, volume ID and instance ID.
|
// An ID containing the object ID, volume ID and instance ID.
|
||||||
int composite_id;
|
int composite_id;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
// An ID for group selection. It may be the same for all meshes of all object instances, or for just a single object instance.
|
// An ID for group selection. It may be the same for all meshes of all object instances, or for just a single object instance.
|
||||||
int select_group_id;
|
int select_group_id;
|
||||||
// An ID for group dragging. It may be the same for all meshes of all object instances, or for just a single object instance.
|
// An ID for group dragging. It may be the same for all meshes of all object instances, or for just a single object instance.
|
||||||
int drag_group_id;
|
int drag_group_id;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
// An ID containing the extruder ID (used to select color).
|
// An ID containing the extruder ID (used to select color).
|
||||||
int extruder_id;
|
int extruder_id;
|
||||||
// Is this object selected?
|
// Is this object selected?
|
||||||
|
@ -338,6 +340,9 @@ public:
|
||||||
const Vec3d& get_rotation() const;
|
const Vec3d& get_rotation() const;
|
||||||
void set_rotation(const Vec3d& rotation);
|
void set_rotation(const Vec3d& rotation);
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
const Vec3d& get_scaling_factor() const;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
void set_scaling_factor(const Vec3d& scaling_factor);
|
void set_scaling_factor(const Vec3d& scaling_factor);
|
||||||
#else
|
#else
|
||||||
double get_rotation() const;
|
double get_rotation() const;
|
||||||
|
@ -351,8 +356,10 @@ public:
|
||||||
|
|
||||||
void set_convex_hull(const TriangleMesh& convex_hull);
|
void set_convex_hull(const TriangleMesh& convex_hull);
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void set_select_group_id(const std::string& select_by);
|
void set_select_group_id(const std::string& select_by);
|
||||||
void set_drag_group_id(const std::string& drag_by);
|
void set_drag_group_id(const std::string& drag_by);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
int object_idx() const { return this->composite_id / 1000000; }
|
int object_idx() const { return this->composite_id / 1000000; }
|
||||||
int volume_idx() const { return (this->composite_id / 1000) % 1000; }
|
int volume_idx() const { return (this->composite_id / 1000) % 1000; }
|
||||||
|
@ -410,6 +417,10 @@ public:
|
||||||
void reset_layer_height_texture_data() { layer_height_texture_data.reset(); }
|
void reset_layer_height_texture_data() { layer_height_texture_data.reset(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
typedef std::vector<GLVolume*> GLVolumePtrs;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
class GLVolumeCollection
|
class GLVolumeCollection
|
||||||
{
|
{
|
||||||
// min and max vertex of the print box volume
|
// min and max vertex of the print box volume
|
||||||
|
@ -417,8 +428,12 @@ class GLVolumeCollection
|
||||||
float print_box_max[3];
|
float print_box_max[3];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
GLVolumePtrs volumes;
|
||||||
|
#else
|
||||||
std::vector<GLVolume*> volumes;
|
std::vector<GLVolume*> volumes;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
GLVolumeCollection() {};
|
GLVolumeCollection() {};
|
||||||
~GLVolumeCollection() { clear(); };
|
~GLVolumeCollection() { clear(); };
|
||||||
|
|
||||||
|
@ -463,8 +478,10 @@ public:
|
||||||
|
|
||||||
void update_colors_by_extruder(const DynamicPrintConfig* config);
|
void update_colors_by_extruder(const DynamicPrintConfig* config);
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void set_select_by(const std::string& select_by);
|
void set_select_by(const std::string& select_by);
|
||||||
void set_drag_by(const std::string& drag_by);
|
void set_drag_by(const std::string& drag_by);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
// Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection
|
// Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection
|
||||||
std::vector<double> get_current_print_zs(bool active_only) const;
|
std::vector<double> get_current_print_zs(bool active_only) const;
|
||||||
|
@ -500,7 +517,9 @@ public:
|
||||||
static bool move_volume_up(wxGLCanvas* canvas, unsigned int id);
|
static bool move_volume_up(wxGLCanvas* canvas, unsigned int id);
|
||||||
static bool move_volume_down(wxGLCanvas* canvas, unsigned int id);
|
static bool move_volume_down(wxGLCanvas* canvas, unsigned int id);
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
static void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections);
|
static void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
static void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
static void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
||||||
static void set_print(wxGLCanvas* canvas, Print* print);
|
static void set_print(wxGLCanvas* canvas, Print* print);
|
||||||
|
@ -516,10 +535,12 @@ public:
|
||||||
static void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons);
|
static void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons);
|
||||||
|
|
||||||
static void set_color_by(wxGLCanvas* canvas, const std::string& value);
|
static void set_color_by(wxGLCanvas* canvas, const std::string& value);
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
static void set_select_by(wxGLCanvas* canvas, const std::string& value);
|
static void set_select_by(wxGLCanvas* canvas, const std::string& value);
|
||||||
static void set_drag_by(wxGLCanvas* canvas, const std::string& value);
|
static void set_drag_by(wxGLCanvas* canvas, const std::string& value);
|
||||||
|
|
||||||
static std::string get_select_by(wxGLCanvas* canvas);
|
static std::string get_select_by(wxGLCanvas* canvas);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
static bool is_layers_editing_enabled(wxGLCanvas* canvas);
|
static bool is_layers_editing_enabled(wxGLCanvas* canvas);
|
||||||
static bool is_layers_editing_allowed(wxGLCanvas* canvas);
|
static bool is_layers_editing_allowed(wxGLCanvas* canvas);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -346,11 +346,15 @@ class GLCanvas3D
|
||||||
|
|
||||||
Point start_position_2D;
|
Point start_position_2D;
|
||||||
Vec3d start_position_3D;
|
Vec3d start_position_3D;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
Vec3d volume_center_offset;
|
Vec3d volume_center_offset;
|
||||||
|
|
||||||
bool move_with_shift;
|
bool move_with_shift;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
int move_volume_idx;
|
int move_volume_idx;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
int gizmo_volume_idx;
|
int gizmo_volume_idx;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Drag();
|
Drag();
|
||||||
|
@ -372,6 +376,104 @@ class GLCanvas3D
|
||||||
bool is_start_position_3D_defined() const;
|
bool is_start_position_3D_defined() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
public:
|
||||||
|
class Selection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::set<unsigned int> IndicesList;
|
||||||
|
|
||||||
|
enum EMode : unsigned char
|
||||||
|
{
|
||||||
|
Volume,
|
||||||
|
Instance,
|
||||||
|
Object
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct VolumeCache
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
Transform3d m_rotation_matrix;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Vec3d position;
|
||||||
|
Vec3d rotation;
|
||||||
|
Vec3d scaling_factor;
|
||||||
|
|
||||||
|
VolumeCache();
|
||||||
|
VolumeCache(const Vec3d& position, const Vec3d& rotation, const Vec3d& scaling_factor);
|
||||||
|
|
||||||
|
const Transform3d& get_rotation_matrix() const { return m_rotation_matrix; }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<unsigned int, VolumeCache> VolumesCache;
|
||||||
|
|
||||||
|
struct Cache
|
||||||
|
{
|
||||||
|
VolumesCache volumes_data;
|
||||||
|
Vec3d dragging_center;
|
||||||
|
};
|
||||||
|
|
||||||
|
GLVolumePtrs* m_volumes;
|
||||||
|
Model* m_model;
|
||||||
|
|
||||||
|
bool m_valid;
|
||||||
|
EMode m_mode;
|
||||||
|
IndicesList m_list;
|
||||||
|
Cache m_cache;
|
||||||
|
mutable BoundingBoxf3 m_bounding_box;
|
||||||
|
mutable bool m_bounding_box_dirty;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Selection();
|
||||||
|
|
||||||
|
void set_volumes(GLVolumePtrs* volumes);
|
||||||
|
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 clear();
|
||||||
|
|
||||||
|
bool is_empty() const { return m_list.empty(); }
|
||||||
|
bool is_wipe_tower() const { return m_valid && (m_list.size() == 1) && (*m_volumes)[*m_list.begin()]->is_wipe_tower; }
|
||||||
|
bool is_modifier() const { return m_valid && (m_list.size() == 1) && (*m_volumes)[*m_list.begin()]->is_modifier; }
|
||||||
|
bool is_single_full_instance(int& object_idx_out, int& instance_idx_out) const;
|
||||||
|
bool is_single_full_object(int& object_idx_out) const;
|
||||||
|
bool is_from_single_instance(int& object_idx_out, int& instance_idx_out) const;
|
||||||
|
bool is_from_single_object(int& object_idx_out) const;
|
||||||
|
|
||||||
|
const IndicesList& get_volume_idxs() const { return m_list; }
|
||||||
|
const GLVolume* get_volume(unsigned int volume_idx) const;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
void render() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void update_valid();
|
||||||
|
void set_caches();
|
||||||
|
void add_volume(unsigned int volume_idx);
|
||||||
|
void add_instance(unsigned int volume_idx);
|
||||||
|
void add_object(unsigned int volume_idx);
|
||||||
|
void remove_volume(unsigned int volume_idx);
|
||||||
|
void remove_instance(unsigned int volume_idx);
|
||||||
|
void remove_object(unsigned int volume_idx);
|
||||||
|
void calc_bounding_box() const;
|
||||||
|
void render_bounding_box(const BoundingBoxf3& box, float* color) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
class Gizmos
|
class Gizmos
|
||||||
{
|
{
|
||||||
static const float OverlayTexturesScale;
|
static const float OverlayTexturesScale;
|
||||||
|
@ -404,11 +506,20 @@ class GLCanvas3D
|
||||||
bool is_enabled() const;
|
bool is_enabled() const;
|
||||||
void set_enabled(bool enable);
|
void set_enabled(bool enable);
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
void update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
||||||
|
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
||||||
|
#else
|
||||||
void update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos);
|
void update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos);
|
||||||
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos);
|
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos);
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
void reset_all_states();
|
void reset_all_states();
|
||||||
|
|
||||||
void set_hover_id(int id);
|
void set_hover_id(int id);
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
void enable_grabber(EType type, unsigned int id);
|
||||||
|
void disable_grabber(EType type, unsigned int id);
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Vec2d& mouse_pos) const;
|
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Vec2d& mouse_pos) const;
|
||||||
bool grabber_contains_mouse() const;
|
bool grabber_contains_mouse() const;
|
||||||
|
@ -425,8 +536,12 @@ class GLCanvas3D
|
||||||
void start_dragging(const BoundingBoxf3& box);
|
void start_dragging(const BoundingBoxf3& box);
|
||||||
void stop_dragging();
|
void stop_dragging();
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
Vec3d get_displacement() const;
|
||||||
|
#else
|
||||||
Vec3d get_position() const;
|
Vec3d get_position() const;
|
||||||
void set_position(const Vec3d& position);
|
void set_position(const Vec3d& position);
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
Vec3d get_scale() const;
|
Vec3d get_scale() const;
|
||||||
|
@ -517,6 +632,9 @@ class GLCanvas3D
|
||||||
mutable GLToolbar m_toolbar;
|
mutable GLToolbar m_toolbar;
|
||||||
|
|
||||||
mutable GLVolumeCollection m_volumes;
|
mutable GLVolumeCollection m_volumes;
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
Selection m_selection;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
DynamicPrintConfig* m_config;
|
DynamicPrintConfig* m_config;
|
||||||
Print* m_print;
|
Print* m_print;
|
||||||
Model* m_model;
|
Model* m_model;
|
||||||
|
@ -535,14 +653,21 @@ class GLCanvas3D
|
||||||
bool m_shader_enabled;
|
bool m_shader_enabled;
|
||||||
bool m_dynamic_background_enabled;
|
bool m_dynamic_background_enabled;
|
||||||
bool m_multisample_allowed;
|
bool m_multisample_allowed;
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
bool m_regenerate_volumes;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
std::string m_color_by;
|
std::string m_color_by;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
std::string m_select_by;
|
std::string m_select_by;
|
||||||
std::string m_drag_by;
|
std::string m_drag_by;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
bool m_reload_delayed;
|
bool m_reload_delayed;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
std::vector<std::vector<int>> m_objects_volumes_idxs;
|
std::vector<std::vector<int>> m_objects_volumes_idxs;
|
||||||
std::vector<int> m_objects_selections;
|
std::vector<int> m_objects_selections;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
GCodePreviewVolumeIndex m_gcode_preview_volume_index;
|
GCodePreviewVolumeIndex m_gcode_preview_volume_index;
|
||||||
|
|
||||||
|
@ -575,12 +700,18 @@ public:
|
||||||
bool move_volume_up(unsigned int id);
|
bool move_volume_up(unsigned int id);
|
||||||
bool move_volume_down(unsigned int id);
|
bool move_volume_down(unsigned int id);
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void set_objects_selections(const std::vector<int>& selections);
|
void set_objects_selections(const std::vector<int>& selections);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
void set_config(DynamicPrintConfig* config);
|
void set_config(DynamicPrintConfig* config);
|
||||||
void set_print(Print* print);
|
void set_print(Print* print);
|
||||||
void set_model(Model* model);
|
void set_model(Model* model);
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
const Selection& get_selection() const { return m_selection; }
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
// Set the bed shape to a single closed 2D polygon(array of two element arrays),
|
// Set the bed shape to a single closed 2D polygon(array of two element arrays),
|
||||||
// triangulate the bed and store the triangles into m_bed.m_triangles,
|
// triangulate the bed and store the triangles into m_bed.m_triangles,
|
||||||
// fills the m_bed.m_grid_lines and sets m_bed.m_origin.
|
// fills the m_bed.m_grid_lines and sets m_bed.m_origin.
|
||||||
|
@ -594,11 +725,13 @@ public:
|
||||||
void set_cutting_plane(float z, const ExPolygons& polygons);
|
void set_cutting_plane(float z, const ExPolygons& polygons);
|
||||||
|
|
||||||
void set_color_by(const std::string& value);
|
void set_color_by(const std::string& value);
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void set_select_by(const std::string& value);
|
void set_select_by(const std::string& value);
|
||||||
void set_drag_by(const std::string& value);
|
void set_drag_by(const std::string& value);
|
||||||
|
|
||||||
const std::string& get_select_by() const;
|
const std::string& get_select_by() const;
|
||||||
const std::string& get_drag_by() const;
|
const std::string& get_drag_by() const;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
float get_camera_zoom() const;
|
float get_camera_zoom() const;
|
||||||
|
|
||||||
|
@ -680,7 +813,9 @@ private:
|
||||||
void _resize(unsigned int w, unsigned int h);
|
void _resize(unsigned int w, unsigned int h);
|
||||||
|
|
||||||
BoundingBoxf3 _max_bounding_box() const;
|
BoundingBoxf3 _max_bounding_box() const;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
BoundingBoxf3 _selected_volumes_bounding_box() const;
|
BoundingBoxf3 _selected_volumes_bounding_box() const;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
||||||
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
||||||
|
@ -694,6 +829,9 @@ private:
|
||||||
void _render_bed(float theta) const;
|
void _render_bed(float theta) const;
|
||||||
void _render_axes(bool depth_test) const;
|
void _render_axes(bool depth_test) const;
|
||||||
void _render_objects() const;
|
void _render_objects() const;
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
void _render_selection() const;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
void _render_cutting_plane() const;
|
void _render_cutting_plane() const;
|
||||||
void _render_warning_texture() const;
|
void _render_warning_texture() const;
|
||||||
void _render_legend_texture() const;
|
void _render_legend_texture() const;
|
||||||
|
@ -703,6 +841,10 @@ private:
|
||||||
void _render_gizmos_overlay() const;
|
void _render_gizmos_overlay() const;
|
||||||
void _render_toolbar() const;
|
void _render_toolbar() const;
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
void _update_volumes_hover_state() const;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
float _get_layers_editing_cursor_z_relative() const;
|
float _get_layers_editing_cursor_z_relative() const;
|
||||||
void _perform_layer_editing_action(wxMouseEvent* evt = nullptr);
|
void _perform_layer_editing_action(wxMouseEvent* evt = nullptr);
|
||||||
|
|
||||||
|
@ -719,8 +861,10 @@ private:
|
||||||
void _start_timer();
|
void _start_timer();
|
||||||
void _stop_timer();
|
void _stop_timer();
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
int _get_first_selected_object_id() const;
|
int _get_first_selected_object_id() const;
|
||||||
int _get_first_selected_volume_id(int object_id) const;
|
int _get_first_selected_volume_id(int object_id) const;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
// Create 3D thick extrusion lines for a skirt and brim.
|
// Create 3D thick extrusion lines for a skirt and brim.
|
||||||
// Adds a new Slic3r::GUI::3DScene::Volume to volumes.
|
// Adds a new Slic3r::GUI::3DScene::Volume to volumes.
|
||||||
|
@ -750,7 +894,11 @@ private:
|
||||||
void _update_toolpath_volumes_outside_state();
|
void _update_toolpath_volumes_outside_state();
|
||||||
void _show_warning_texture_if_needed();
|
void _show_warning_texture_if_needed();
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
void _on_move();
|
||||||
|
#else
|
||||||
void _on_move(const std::vector<int>& volume_idxs);
|
void _on_move(const std::vector<int>& volume_idxs);
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
void _on_select(int volume_idx, int object_idx);
|
void _on_select(int volume_idx, int object_idx);
|
||||||
|
|
||||||
// generates the legend texture in dependence of the current shown view type
|
// generates the legend texture in dependence of the current shown view type
|
||||||
|
|
|
@ -285,12 +285,14 @@ bool GLCanvas3DManager::move_volume_down(wxGLCanvas* canvas, unsigned int id)
|
||||||
return (it != m_canvases.end()) ? it->second->move_volume_down(id) : false;
|
return (it != m_canvases.end()) ? it->second->move_volume_down(id) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void GLCanvas3DManager::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections)
|
void GLCanvas3DManager::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections)
|
||||||
{
|
{
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
if (it != m_canvases.end())
|
if (it != m_canvases.end())
|
||||||
it->second->set_objects_selections(selections);
|
it->second->set_objects_selections(selections);
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
void GLCanvas3DManager::set_config(wxGLCanvas* canvas, DynamicPrintConfig* config)
|
void GLCanvas3DManager::set_config(wxGLCanvas* canvas, DynamicPrintConfig* config)
|
||||||
{
|
{
|
||||||
|
@ -354,6 +356,7 @@ void GLCanvas3DManager::set_color_by(wxGLCanvas* canvas, const std::string& valu
|
||||||
it->second->set_color_by(value);
|
it->second->set_color_by(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void GLCanvas3DManager::set_select_by(wxGLCanvas* canvas, const std::string& value)
|
void GLCanvas3DManager::set_select_by(wxGLCanvas* canvas, const std::string& value)
|
||||||
{
|
{
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
@ -373,6 +376,7 @@ std::string GLCanvas3DManager::get_select_by(wxGLCanvas* canvas) const
|
||||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||||
return (it != m_canvases.end()) ? it->second->get_select_by() : "";
|
return (it != m_canvases.end()) ? it->second->get_select_by() : "";
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
bool GLCanvas3DManager::is_layers_editing_enabled(wxGLCanvas* canvas) const
|
bool GLCanvas3DManager::is_layers_editing_enabled(wxGLCanvas* canvas) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,9 @@ public:
|
||||||
bool move_volume_up(wxGLCanvas* canvas, unsigned int id);
|
bool move_volume_up(wxGLCanvas* canvas, unsigned int id);
|
||||||
bool move_volume_down(wxGLCanvas* canvas, unsigned int id);
|
bool move_volume_down(wxGLCanvas* canvas, unsigned int id);
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections);
|
void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
||||||
void set_print(wxGLCanvas* canvas, Print* print);
|
void set_print(wxGLCanvas* canvas, Print* print);
|
||||||
|
@ -110,10 +112,12 @@ public:
|
||||||
void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons);
|
void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons);
|
||||||
|
|
||||||
void set_color_by(wxGLCanvas* canvas, const std::string& value);
|
void set_color_by(wxGLCanvas* canvas, const std::string& value);
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
void set_select_by(wxGLCanvas* canvas, const std::string& value);
|
void set_select_by(wxGLCanvas* canvas, const std::string& value);
|
||||||
void set_drag_by(wxGLCanvas* canvas, const std::string& value);
|
void set_drag_by(wxGLCanvas* canvas, const std::string& value);
|
||||||
|
|
||||||
std::string get_select_by(wxGLCanvas* canvas) const;
|
std::string get_select_by(wxGLCanvas* canvas) const;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
||||||
bool is_layers_editing_allowed(wxGLCanvas* canvas) const;
|
bool is_layers_editing_allowed(wxGLCanvas* canvas) const;
|
||||||
|
|
|
@ -216,6 +216,9 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent)
|
||||||
: m_parent(parent)
|
: m_parent(parent)
|
||||||
, m_group_id(-1)
|
, m_group_id(-1)
|
||||||
, m_state(Off)
|
, m_state(Off)
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
, m_accept_wipe_tower(false)
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
, m_hover_id(-1)
|
, m_hover_id(-1)
|
||||||
, m_dragging(false)
|
, m_dragging(false)
|
||||||
{
|
{
|
||||||
|
@ -1050,7 +1053,11 @@ const double GLGizmoMove3D::Offset = 10.0;
|
||||||
|
|
||||||
GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent)
|
GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent)
|
||||||
: GLGizmoBase(parent)
|
: GLGizmoBase(parent)
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
, m_displacement(Vec3d::Zero())
|
||||||
|
#else
|
||||||
, m_position(Vec3d::Zero())
|
, m_position(Vec3d::Zero())
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
, m_starting_drag_position(Vec3d::Zero())
|
, m_starting_drag_position(Vec3d::Zero())
|
||||||
, m_starting_box_center(Vec3d::Zero())
|
, m_starting_box_center(Vec3d::Zero())
|
||||||
, m_starting_box_bottom_center(Vec3d::Zero())
|
, m_starting_box_bottom_center(Vec3d::Zero())
|
||||||
|
@ -1078,6 +1085,10 @@ bool GLGizmoMove3D::on_init()
|
||||||
m_grabbers.push_back(Grabber());
|
m_grabbers.push_back(Grabber());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
m_accept_wipe_tower = true;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,6 +1096,9 @@ void GLGizmoMove3D::on_start_dragging(const BoundingBoxf3& box)
|
||||||
{
|
{
|
||||||
if (m_hover_id != -1)
|
if (m_hover_id != -1)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
m_displacement = Vec3d::Zero();
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
||||||
m_starting_box_center = box.center();
|
m_starting_box_center = box.center();
|
||||||
m_starting_box_bottom_center = box.center();
|
m_starting_box_bottom_center = box.center();
|
||||||
|
@ -1094,22 +1108,40 @@ void GLGizmoMove3D::on_start_dragging(const BoundingBoxf3& box)
|
||||||
|
|
||||||
void GLGizmoMove3D::on_update(const Linef3& mouse_ray)
|
void GLGizmoMove3D::on_update(const Linef3& mouse_ray)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
if (m_hover_id == 0)
|
||||||
|
m_displacement(0) = calc_projection(X, 1, mouse_ray) - (m_starting_drag_position(0) - m_starting_box_center(0));
|
||||||
|
else if (m_hover_id == 1)
|
||||||
|
m_displacement(1) = calc_projection(Y, 2, mouse_ray) - (m_starting_drag_position(1) - m_starting_box_center(1));
|
||||||
|
else if (m_hover_id == 2)
|
||||||
|
m_displacement(2) = calc_projection(Z, 1, mouse_ray) - (m_starting_drag_position(2) - m_starting_box_bottom_center(2));
|
||||||
|
#else
|
||||||
if (m_hover_id == 0)
|
if (m_hover_id == 0)
|
||||||
m_position(0) = 2.0 * m_starting_box_center(0) + calc_projection(X, 1, mouse_ray) - m_starting_drag_position(0);
|
m_position(0) = 2.0 * m_starting_box_center(0) + calc_projection(X, 1, mouse_ray) - m_starting_drag_position(0);
|
||||||
else if (m_hover_id == 1)
|
else if (m_hover_id == 1)
|
||||||
m_position(1) = 2.0 * m_starting_box_center(1) + calc_projection(Y, 2, mouse_ray) - m_starting_drag_position(1);
|
m_position(1) = 2.0 * m_starting_box_center(1) + calc_projection(Y, 2, mouse_ray) - m_starting_drag_position(1);
|
||||||
else if (m_hover_id == 2)
|
else if (m_hover_id == 2)
|
||||||
m_position(2) = 2.0 * m_starting_box_bottom_center(2) + calc_projection(Z, 1, mouse_ray) - m_starting_drag_position(2);
|
m_position(2) = 2.0 * m_starting_box_bottom_center(2) + calc_projection(Z, 1, mouse_ray) - m_starting_drag_position(2);
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
||||||
{
|
{
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
if (m_grabbers[0].dragging)
|
||||||
|
set_tooltip("X: " + format(m_displacement(0), 2));
|
||||||
|
else if (m_grabbers[1].dragging)
|
||||||
|
set_tooltip("Y: " + format(m_displacement(1), 2));
|
||||||
|
else if (m_grabbers[2].dragging)
|
||||||
|
set_tooltip("Z: " + format(m_displacement(2), 2));
|
||||||
|
#else
|
||||||
if (m_grabbers[0].dragging)
|
if (m_grabbers[0].dragging)
|
||||||
set_tooltip("X: " + format(m_position(0), 2));
|
set_tooltip("X: " + format(m_position(0), 2));
|
||||||
else if (m_grabbers[1].dragging)
|
else if (m_grabbers[1].dragging)
|
||||||
set_tooltip("Y: " + format(m_position(1), 2));
|
set_tooltip("Y: " + format(m_position(1), 2));
|
||||||
else if (m_grabbers[2].dragging)
|
else if (m_grabbers[2].dragging)
|
||||||
set_tooltip("Z: " + format(m_position(2), 2));
|
set_tooltip("Z: " + format(m_position(2), 2));
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
::glEnable(GL_DEPTH_TEST);
|
::glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ protected:
|
||||||
|
|
||||||
int m_group_id;
|
int m_group_id;
|
||||||
EState m_state;
|
EState m_state;
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
bool m_accept_wipe_tower;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
// textures are assumed to be square and all with the same size in pixels, no internal check is done
|
// textures are assumed to be square and all with the same size in pixels, no internal check is done
|
||||||
GLTexture m_textures[Num_States];
|
GLTexture m_textures[Num_States];
|
||||||
int m_hover_id;
|
int m_hover_id;
|
||||||
|
@ -77,6 +80,11 @@ public:
|
||||||
EState get_state() const { return m_state; }
|
EState get_state() const { return m_state; }
|
||||||
void set_state(EState state) { m_state = state; on_set_state(); }
|
void set_state(EState state) { m_state = state; on_set_state(); }
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
bool get_accept_wipe_tower() { return m_accept_wipe_tower; }
|
||||||
|
void set_accept_wipe_tower(bool accept) { m_accept_wipe_tower = accept; }
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
unsigned int get_texture_id() const { return m_textures[m_state].get_id(); }
|
unsigned int get_texture_id() const { return m_textures[m_state].get_id(); }
|
||||||
int get_textures_size() const { return m_textures[Off].get_width(); }
|
int get_textures_size() const { return m_textures[Off].get_width(); }
|
||||||
|
|
||||||
|
@ -318,7 +326,11 @@ class GLGizmoMove3D : public GLGizmoBase
|
||||||
{
|
{
|
||||||
static const double Offset;
|
static const double Offset;
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
Vec3d m_displacement;
|
||||||
|
#else
|
||||||
Vec3d m_position;
|
Vec3d m_position;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
Vec3d m_starting_drag_position;
|
Vec3d m_starting_drag_position;
|
||||||
Vec3d m_starting_box_center;
|
Vec3d m_starting_box_center;
|
||||||
Vec3d m_starting_box_bottom_center;
|
Vec3d m_starting_box_bottom_center;
|
||||||
|
@ -326,8 +338,12 @@ class GLGizmoMove3D : public GLGizmoBase
|
||||||
public:
|
public:
|
||||||
explicit GLGizmoMove3D(GLCanvas3D& parent);
|
explicit GLGizmoMove3D(GLCanvas3D& parent);
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
const Vec3d& get_displacement() const { return m_displacement; }
|
||||||
|
#else
|
||||||
const Vec3d& get_position() const { return m_position; }
|
const Vec3d& get_position() const { return m_position; }
|
||||||
void set_position(const Vec3d& position) { m_position = position; }
|
void set_position(const Vec3d& position) { m_position = position; }
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_init();
|
virtual bool on_init();
|
||||||
|
|
|
@ -1036,7 +1036,9 @@ void ObjectList::add_object_to_list(const std::string &name, ModelObject* model_
|
||||||
{
|
{
|
||||||
wxString item_name = name;
|
wxString item_name = name;
|
||||||
auto item = m_objects_model->Add(item_name, model_object->instances.size());
|
auto item = m_objects_model->Add(item_name, model_object->instances.size());
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
m_objects_ctrl->Select(item);
|
m_objects_ctrl->Select(item);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
// Add error icon if detected auto-repaire
|
// Add error icon if detected auto-repaire
|
||||||
auto stats = model_object->volumes[0]->mesh.stl.stats;
|
auto stats = model_object->volumes[0]->mesh.stl.stats;
|
||||||
|
|
|
@ -262,6 +262,51 @@ void ObjectManipulation::update_settings_list()
|
||||||
/*wxGetApp().sidebar().*/parent->GetParent()->Layout();
|
/*wxGetApp().sidebar().*/parent->GetParent()->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& selection)
|
||||||
|
{
|
||||||
|
int object_idx = -1;
|
||||||
|
int instance_idx = -1;
|
||||||
|
if (selection.is_single_full_instance(object_idx, instance_idx))
|
||||||
|
{
|
||||||
|
// all volumes in the selection belongs to the same instance, any of them contains the needed data, so we take the first
|
||||||
|
const GLCanvas3D::Selection::IndicesList& idxs = selection.get_volume_idxs();
|
||||||
|
update_position_values(selection.get_volume(*idxs.begin())->get_offset());
|
||||||
|
m_og->enable();
|
||||||
|
}
|
||||||
|
else if (selection.is_wipe_tower())
|
||||||
|
{
|
||||||
|
// the selection contains a single volume
|
||||||
|
const GLCanvas3D::Selection::IndicesList& idxs = selection.get_volume_idxs();
|
||||||
|
update_position_values(selection.get_volume(*idxs.begin())->get_offset());
|
||||||
|
m_og->enable();
|
||||||
|
}
|
||||||
|
else if (selection.is_modifier())
|
||||||
|
{
|
||||||
|
// the selection contains a single volume
|
||||||
|
const GLCanvas3D::Selection::IndicesList& idxs = selection.get_volume_idxs();
|
||||||
|
update_position_values(selection.get_volume(*idxs.begin())->get_offset());
|
||||||
|
m_og->enable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reset_settings_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectManipulation::reset_settings_value()
|
||||||
|
{
|
||||||
|
m_og->set_value("position_x", 0);
|
||||||
|
m_og->set_value("position_y", 0);
|
||||||
|
m_og->set_value("position_z", 0);
|
||||||
|
m_og->set_value("scale_x", 0);
|
||||||
|
m_og->set_value("scale_y", 0);
|
||||||
|
m_og->set_value("scale_z", 0);
|
||||||
|
m_og->set_value("rotation_x", 0);
|
||||||
|
m_og->set_value("rotation_y", 0);
|
||||||
|
m_og->set_value("rotation_z", 0);
|
||||||
|
m_og->disable();
|
||||||
|
}
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
void ObjectManipulation::update_values()
|
void ObjectManipulation::update_values()
|
||||||
{
|
{
|
||||||
int selection = ol_selection();
|
int selection = ol_selection();
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
|
|
||||||
#include "Preset.hpp"
|
#include "Preset.hpp"
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
#include "GLCanvas3D.hpp"
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
class wxBoxSizer;
|
class wxBoxSizer;
|
||||||
|
|
||||||
|
@ -44,6 +47,11 @@ public:
|
||||||
int ol_selection();
|
int ol_selection();
|
||||||
void update_settings_list();
|
void update_settings_list();
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
void update_settings_value(const GLCanvas3D::Selection& selection);
|
||||||
|
void reset_settings_value();
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
void update_values();
|
void update_values();
|
||||||
// update position values displacements or "gizmos"
|
// update position values displacements or "gizmos"
|
||||||
void update_position_values();
|
void update_position_values();
|
||||||
|
|
|
@ -617,7 +617,9 @@ struct Plater::priv
|
||||||
|
|
||||||
priv(Plater *q, MainFrame *main_frame);
|
priv(Plater *q, MainFrame *main_frame);
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
std::vector<int> collect_selections();
|
std::vector<int> collect_selections();
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
void update(bool force_autocenter = false);
|
void update(bool force_autocenter = false);
|
||||||
void update_ui_from_settings();
|
void update_ui_from_settings();
|
||||||
ProgressStatusBar* statusbar();
|
ProgressStatusBar* statusbar();
|
||||||
|
@ -671,8 +673,10 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
||||||
_3DScene::enable_picking(canvas3D, true);
|
_3DScene::enable_picking(canvas3D, true);
|
||||||
_3DScene::enable_moving(canvas3D, true);
|
_3DScene::enable_moving(canvas3D, true);
|
||||||
// XXX: more config from 3D.pm
|
// XXX: more config from 3D.pm
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
_3DScene::set_select_by(canvas3D, "object");
|
_3DScene::set_select_by(canvas3D, "object");
|
||||||
_3DScene::set_drag_by(canvas3D, "instance");
|
_3DScene::set_drag_by(canvas3D, "instance");
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
_3DScene::set_model(canvas3D, &model);
|
_3DScene::set_model(canvas3D, &model);
|
||||||
_3DScene::set_print(canvas3D, &print);
|
_3DScene::set_print(canvas3D, &print);
|
||||||
_3DScene::set_config(canvas3D, config);
|
_3DScene::set_config(canvas3D, config);
|
||||||
|
@ -735,6 +739,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
||||||
q->Layout();
|
q->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
std::vector<int> Plater::priv::collect_selections()
|
std::vector<int> Plater::priv::collect_selections()
|
||||||
{
|
{
|
||||||
std::vector<int> res;
|
std::vector<int> res;
|
||||||
|
@ -743,6 +748,7 @@ std::vector<int> Plater::priv::collect_selections()
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
void Plater::priv::update(bool force_autocenter)
|
void Plater::priv::update(bool force_autocenter)
|
||||||
{
|
{
|
||||||
|
@ -758,8 +764,10 @@ void Plater::priv::update(bool force_autocenter)
|
||||||
// stop_background_process(); // TODO
|
// stop_background_process(); // TODO
|
||||||
print.reload_model_instances();
|
print.reload_model_instances();
|
||||||
|
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
const auto selections = collect_selections();
|
const auto selections = collect_selections();
|
||||||
_3DScene::set_objects_selections(canvas3D, selections);
|
_3DScene::set_objects_selections(canvas3D, selections);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
_3DScene::reload_scene(canvas3D, false);
|
_3DScene::reload_scene(canvas3D, false);
|
||||||
preview->reset_gcode_preview_data();
|
preview->reset_gcode_preview_data();
|
||||||
preview->reload_print();
|
preview->reload_print();
|
||||||
|
@ -999,7 +1007,9 @@ void Plater::priv::on_notebook_changed(wxBookCtrlEvent&)
|
||||||
const auto current_id = notebook->GetCurrentPage()->GetId();
|
const auto current_id = notebook->GetCurrentPage()->GetId();
|
||||||
if (current_id == canvas3D->GetId()) {
|
if (current_id == canvas3D->GetId()) {
|
||||||
if (_3DScene::is_reload_delayed(canvas3D)) {
|
if (_3DScene::is_reload_delayed(canvas3D)) {
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
_3DScene::set_objects_selections(canvas3D, collect_selections());
|
_3DScene::set_objects_selections(canvas3D, collect_selections());
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
_3DScene::reload_scene(canvas3D, true);
|
_3DScene::reload_scene(canvas3D, true);
|
||||||
}
|
}
|
||||||
// sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
|
// sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue