New selection set as default
This commit is contained in:
parent
0d282896d0
commit
a15bf7cc25
16 changed files with 20 additions and 2149 deletions
|
@ -693,23 +693,12 @@ void ModelObject::center_around_origin()
|
|||
if (v->is_model_part())
|
||||
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
|
||||
Vec3d shift = -bb.center();
|
||||
shift(2) = -bb.min(2);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
this->translate(shift);
|
||||
this->origin_translation += shift;
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
// set z to zero, translation in z has already been done within the mesh
|
||||
shift(2) = 0.0;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (!this->instances.empty()) {
|
||||
for (ModelInstance *i : this->instances) {
|
||||
i->set_offset(i->get_offset() - shift);
|
||||
|
|
|
@ -17,9 +17,8 @@
|
|||
#define ENABLE_GIZMOS_RESET (1 && ENABLE_1_42_0)
|
||||
// Uses a unique opengl context
|
||||
#define ENABLE_USE_UNIQUE_GLCONTEXT (1 && ENABLE_1_42_0)
|
||||
// New selections
|
||||
#define ENABLE_EXTENDED_SELECTION (1 && ENABLE_1_42_0)
|
||||
#define DISABLE_INSTANCES_SYNCH (1 && ENABLE_EXTENDED_SELECTION)
|
||||
// Disable synchronization of unselected instances
|
||||
#define DISABLE_INSTANCES_SYNCH (1 && ENABLE_1_42_0)
|
||||
// Modified camera target behavior
|
||||
#define ENABLE_MODIFIED_CAMERA_TARGET (1 && ENABLE_1_42_0)
|
||||
// Add Geometry::Transformation class and use it into ModelInstance, ModelVolume and GLVolume
|
||||
|
|
|
@ -209,10 +209,6 @@ GLVolume::GLVolume(float r, float g, float b, float a)
|
|||
, m_transformed_convex_hull_bounding_box_dirty(true)
|
||||
, m_convex_hull(nullptr)
|
||||
, composite_id(-1)
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
, select_group_id(-1)
|
||||
, drag_group_id(-1)
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
, extruder_id(0)
|
||||
, selected(false)
|
||||
, is_active(true)
|
||||
|
@ -270,14 +266,11 @@ const Vec3d& GLVolume::get_rotation() const
|
|||
|
||||
void GLVolume::set_rotation(const Vec3d& rotation)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
static const double TWO_PI = 2.0 * (double)PI;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (m_rotation != rotation)
|
||||
{
|
||||
m_rotation = rotation;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
while (m_rotation(i) < 0.0)
|
||||
|
@ -289,7 +282,6 @@ void GLVolume::set_rotation(const Vec3d& rotation)
|
|||
m_rotation(i) -= TWO_PI;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
m_world_matrix_dirty = true;
|
||||
m_transformed_bounding_box_dirty = true;
|
||||
m_transformed_convex_hull_bounding_box_dirty = true;
|
||||
|
@ -312,12 +304,10 @@ void GLVolume::set_offset(const Vec3d& offset)
|
|||
}
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
|
@ -368,26 +358,6 @@ void GLVolume::set_convex_hull(const TriangleMesh& convex_hull)
|
|||
m_convex_hull = &convex_hull;
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void GLVolume::set_select_group_id(const std::string& select_by)
|
||||
{
|
||||
if (select_by == "object")
|
||||
select_group_id = object_idx() * 1000000;
|
||||
else if (select_by == "volume")
|
||||
select_group_id = object_idx() * 1000000 + volume_idx() * 1000;
|
||||
else if (select_by == "instance")
|
||||
select_group_id = composite_id;
|
||||
}
|
||||
|
||||
void GLVolume::set_drag_group_id(const std::string& drag_by)
|
||||
{
|
||||
if (drag_by == "object")
|
||||
drag_group_id = object_idx() * 1000;
|
||||
else if (drag_by == "instance")
|
||||
drag_group_id = object_idx() * 1000 + instance_idx();
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if !ENABLE_MODELVOLUME_TRANSFORM
|
||||
const Transform3f& GLVolume::world_matrix() const
|
||||
{
|
||||
|
@ -722,23 +692,12 @@ void GLVolume::generate_layer_height_texture(const PrintObject *print_object, bo
|
|||
#define LAYER_HEIGHT_TEXTURE_WIDTH 1024
|
||||
#define LAYER_HEIGHT_TEXTURE_HEIGHT 1024
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
std::vector<int> GLVolumeCollection::load_object(
|
||||
const ModelObject *model_object,
|
||||
int obj_idx,
|
||||
const std::vector<int> &instance_idxs,
|
||||
const std::string &color_by,
|
||||
bool use_VBOs)
|
||||
#else
|
||||
std::vector<int> GLVolumeCollection::load_object(
|
||||
const ModelObject *model_object,
|
||||
int obj_idx,
|
||||
const std::vector<int> &instance_idxs,
|
||||
const std::string &color_by,
|
||||
const std::string &select_by,
|
||||
const std::string &drag_by,
|
||||
bool use_VBOs)
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
static float colors[4][4] = {
|
||||
{ 1.0f, 1.0f, 0.0f, 1.f },
|
||||
|
@ -789,10 +748,6 @@ std::vector<int> GLVolumeCollection::load_object(
|
|||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
||||
v.composite_id = obj_idx * 1000000 + volume_idx * 1000 + instance_idx;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
v.set_select_group_id(select_by);
|
||||
v.set_drag_group_id(drag_by);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
if (model_volume->is_model_part())
|
||||
{
|
||||
v.set_convex_hull(model_volume->get_convex_hull());
|
||||
|
@ -884,10 +839,6 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
||||
v.composite_id = obj_idx * 1000000;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
v.select_group_id = obj_idx * 1000000;
|
||||
v.drag_group_id = obj_idx * 1000;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
v.is_wipe_tower = true;
|
||||
v.shader_outside_printer_detection_enabled = ! size_unknown;
|
||||
return int(this->volumes.size() - 1);
|
||||
|
@ -1083,26 +1034,6 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
|
|||
}
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void GLVolumeCollection::set_select_by(const std::string& select_by)
|
||||
{
|
||||
for (GLVolume *vol : this->volumes)
|
||||
{
|
||||
if (vol != nullptr)
|
||||
vol->set_select_group_id(select_by);
|
||||
}
|
||||
}
|
||||
|
||||
void GLVolumeCollection::set_drag_by(const std::string& drag_by)
|
||||
{
|
||||
for (GLVolume *vol : this->volumes)
|
||||
{
|
||||
if (vol != nullptr)
|
||||
vol->set_drag_group_id(drag_by);
|
||||
}
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
std::vector<double> GLVolumeCollection::get_current_print_zs(bool active_only) const
|
||||
{
|
||||
// Collect layer top positions of all volumes.
|
||||
|
@ -1874,23 +1805,6 @@ void _3DScene::reset_volumes(wxGLCanvas* canvas)
|
|||
s_canvas_mgr.reset_volumes(canvas);
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void _3DScene::deselect_volumes(wxGLCanvas* canvas)
|
||||
{
|
||||
s_canvas_mgr.deselect_volumes(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::select_volume(wxGLCanvas* canvas, unsigned int id)
|
||||
{
|
||||
s_canvas_mgr.select_volume(canvas, id);
|
||||
}
|
||||
|
||||
void _3DScene::update_volumes_selection(wxGLCanvas* canvas, const std::vector<int>& selections)
|
||||
{
|
||||
s_canvas_mgr.update_volumes_selection(canvas, selections);
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
int _3DScene::check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config)
|
||||
{
|
||||
return s_canvas_mgr.check_volumes_outside_state(canvas, config);
|
||||
|
@ -1906,17 +1820,10 @@ bool _3DScene::move_volume_down(wxGLCanvas* canvas, unsigned int id)
|
|||
return s_canvas_mgr.move_volume_down(canvas, id);
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
GUI::GLCanvas3D* _3DScene::get_canvas(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.get_canvas(canvas);
|
||||
}
|
||||
#else
|
||||
void _3DScene::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections)
|
||||
{
|
||||
s_canvas_mgr.set_objects_selections(canvas, selections);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void _3DScene::set_config(wxGLCanvas* canvas, DynamicPrintConfig* config)
|
||||
{
|
||||
|
@ -1963,23 +1870,6 @@ void _3DScene::set_color_by(wxGLCanvas* canvas, const std::string& value)
|
|||
s_canvas_mgr.set_color_by(canvas, value);
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void _3DScene::set_select_by(wxGLCanvas* canvas, const std::string& value)
|
||||
{
|
||||
s_canvas_mgr.set_select_by(canvas, value);
|
||||
}
|
||||
|
||||
void _3DScene::set_drag_by(wxGLCanvas* canvas, const std::string& value)
|
||||
{
|
||||
s_canvas_mgr.set_drag_by(canvas, value);
|
||||
}
|
||||
|
||||
std::string _3DScene::get_select_by(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.get_select_by(canvas);
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
bool _3DScene::is_layers_editing_enabled(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.is_layers_editing_enabled(canvas);
|
||||
|
@ -2157,12 +2047,10 @@ int _3DScene::get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx)
|
|||
return s_canvas_mgr.get_in_object_volume_id(canvas, scene_vol_idx);
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void _3DScene::mirror_selection(wxGLCanvas* canvas, Axis axis)
|
||||
{
|
||||
s_canvas_mgr.mirror_selection(canvas, axis);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void _3DScene::reload_scene(wxGLCanvas* canvas, bool force)
|
||||
{
|
||||
|
|
|
@ -290,12 +290,6 @@ public:
|
|||
float render_color[4];
|
||||
// An ID containing the object ID, volume ID and instance 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.
|
||||
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.
|
||||
int drag_group_id;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
// An ID containing the extruder ID (used to select color).
|
||||
int extruder_id;
|
||||
// Is this object selected?
|
||||
|
@ -365,9 +359,7 @@ public:
|
|||
const Vec3d& get_rotation() const;
|
||||
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);
|
||||
|
||||
const Vec3d& get_mirror() const;
|
||||
|
@ -381,11 +373,6 @@ public:
|
|||
|
||||
void set_convex_hull(const TriangleMesh& convex_hull);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void set_select_group_id(const std::string& select_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 volume_idx() const { return (this->composite_id / 1000) % 1000; }
|
||||
int instance_idx() const { return this->composite_id % 1000; }
|
||||
|
@ -450,9 +437,7 @@ public:
|
|||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
};
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
typedef std::vector<GLVolume*> GLVolumePtrs;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
class GLVolumeCollection
|
||||
{
|
||||
|
@ -461,32 +446,17 @@ class GLVolumeCollection
|
|||
float print_box_max[3];
|
||||
|
||||
public:
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
GLVolumePtrs volumes;
|
||||
#else
|
||||
std::vector<GLVolume*> volumes;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
GLVolumeCollection() {};
|
||||
~GLVolumeCollection() { clear(); };
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
std::vector<int> load_object(
|
||||
const ModelObject *model_object,
|
||||
int obj_idx,
|
||||
const std::vector<int> &instance_idxs,
|
||||
const std::string &color_by,
|
||||
bool use_VBOs);
|
||||
#else
|
||||
std::vector<int> load_object(
|
||||
const ModelObject *model_object,
|
||||
int obj_idx,
|
||||
const std::vector<int> &instance_idxs,
|
||||
const std::string &color_by,
|
||||
const std::string &select_by,
|
||||
const std::string &drag_by,
|
||||
bool use_VBOs);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
int load_wipe_tower_preview(
|
||||
int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs, bool size_unknown, float brim_width);
|
||||
|
@ -520,11 +490,6 @@ public:
|
|||
|
||||
void update_colors_by_extruder(const DynamicPrintConfig* config);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void set_select_by(const std::string& select_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
|
||||
std::vector<double> get_current_print_zs(bool active_only) const;
|
||||
|
||||
|
@ -552,20 +517,11 @@ public:
|
|||
|
||||
static unsigned int get_volumes_count(wxGLCanvas* canvas);
|
||||
static void reset_volumes(wxGLCanvas* canvas);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
static void deselect_volumes(wxGLCanvas* canvas);
|
||||
static void select_volume(wxGLCanvas* canvas, unsigned int id);
|
||||
static void update_volumes_selection(wxGLCanvas* canvas, const std::vector<int>& selections);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
static int check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config);
|
||||
static bool move_volume_up(wxGLCanvas* canvas, unsigned int id);
|
||||
static bool move_volume_down(wxGLCanvas* canvas, unsigned int id);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
static GUI::GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
||||
#else
|
||||
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_print(wxGLCanvas* canvas, Print* print);
|
||||
|
@ -581,12 +537,6 @@ public:
|
|||
static void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons);
|
||||
|
||||
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_drag_by(wxGLCanvas* canvas, const std::string& value);
|
||||
|
||||
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_allowed(wxGLCanvas* canvas);
|
||||
|
@ -628,9 +578,7 @@ public:
|
|||
static int get_first_volume_id(wxGLCanvas* canvas, int obj_idx);
|
||||
static int get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
static void mirror_selection(wxGLCanvas* canvas, Axis axis);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
static void reload_scene(wxGLCanvas* canvas, bool force);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -82,21 +82,7 @@ public:
|
|||
void set_bottom(float bottom);
|
||||
};
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, SimpleEvent);
|
||||
#else
|
||||
struct ObjectSelectEvent;
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, ObjectSelectEvent);
|
||||
struct ObjectSelectEvent : public ArrayEvent<ptrdiff_t, 2>
|
||||
{
|
||||
ObjectSelectEvent(ptrdiff_t object_id, ptrdiff_t volume_id, wxObject *origin = nullptr)
|
||||
: ArrayEvent(EVT_GLCANVAS_OBJECT_SELECT, {object_id, volume_id}, origin)
|
||||
{}
|
||||
|
||||
ptrdiff_t object_id() const { return data[0]; }
|
||||
ptrdiff_t volume_id() const { return data[1]; }
|
||||
};
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
using Vec2dEvent = Event<Vec2d>;
|
||||
template <size_t N> using Vec2dsEvent = ArrayEvent<Vec2d, N>;
|
||||
|
@ -106,30 +92,16 @@ template <size_t N> using Vec3dsEvent = ArrayEvent<Vec3d, N>;
|
|||
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_VIEWPORT_CHANGED, SimpleEvent);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_DOUBLE_CLICK, SimpleEvent);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, Vec2dEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_MODEL_UPDATE, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_ROTATE_OBJECT, Event<int>); // data: -1 => rotate left, +1 => rotate right
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_SCALE_UNIFORMLY, SimpleEvent);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_INCREASE_INSTANCES, Event<int>); // data: +1 => increase, -1 => decrease
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_MOVED, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
wxDECLARE_EVENT(EVT_GIZMO_SCALE, Vec3dEvent);
|
||||
wxDECLARE_EVENT(EVT_GIZMO_ROTATE, Vec3dEvent);
|
||||
wxDECLARE_EVENT(EVT_GIZMO_FLATTEN, Vec3dEvent);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
|
||||
class GLCanvas3D
|
||||
{
|
||||
struct GCodePreviewVolumeIndex
|
||||
|
@ -356,15 +328,7 @@ class GLCanvas3D
|
|||
|
||||
Point start_position_2D;
|
||||
Vec3d start_position_3D;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
Vec3d volume_center_offset;
|
||||
|
||||
bool move_with_shift;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
int move_volume_idx;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
int gizmo_volume_idx;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
public:
|
||||
Drag();
|
||||
|
@ -386,7 +350,6 @@ class GLCanvas3D
|
|||
bool is_start_position_3D_defined() const;
|
||||
};
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
public:
|
||||
class Selection
|
||||
{
|
||||
|
@ -529,8 +492,6 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
class Gizmos
|
||||
{
|
||||
static const float OverlayTexturesScale;
|
||||
|
@ -564,20 +525,13 @@ private:
|
|||
bool is_enabled() const;
|
||||
void set_enabled(bool enable);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
std::string 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);
|
||||
void update_on_off_state(const Selection& selection);
|
||||
#else
|
||||
void update_hover_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 set_hover_id(int id);
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void enable_grabber(EType type, unsigned int id, bool enable);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Vec2d& mouse_pos) const;
|
||||
bool grabber_contains_mouse() const;
|
||||
|
@ -591,19 +545,10 @@ private:
|
|||
bool is_running() const;
|
||||
|
||||
bool is_dragging() const;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void start_dragging(const Selection& selection);
|
||||
#else
|
||||
void start_dragging(const BoundingBoxf3& box);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
void stop_dragging();
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
Vec3d get_displacement() const;
|
||||
#else
|
||||
Vec3d get_position() const;
|
||||
void set_position(const Vec3d& position);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
Vec3d get_scale() const;
|
||||
void set_scale(const Vec3d& scale);
|
||||
|
@ -619,13 +564,8 @@ private:
|
|||
void clicked_on_object(const Vec2d& mouse_position);
|
||||
void delete_current_grabber(bool delete_all = false);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void render_current_gizmo(const Selection& selection) const;
|
||||
void render_current_gizmo_for_picking_pass(const Selection& selection) const;
|
||||
#else
|
||||
void render_current_gizmo(const BoundingBoxf3& box) const;
|
||||
void render_current_gizmo_for_picking_pass(const BoundingBoxf3& box) const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void render_overlay(const GLCanvas3D& canvas) const;
|
||||
|
||||
|
@ -633,11 +573,7 @@ private:
|
|||
void _reset();
|
||||
|
||||
void _render_overlay(const GLCanvas3D& canvas) const;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void _render_current_gizmo(const Selection& selection) const;
|
||||
#else
|
||||
void _render_current_gizmo(const BoundingBoxf3& box) const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
float _get_total_overlay_height() const;
|
||||
GLGizmoBase* _get_current() const;
|
||||
|
@ -697,9 +633,7 @@ private:
|
|||
mutable GLToolbar m_toolbar;
|
||||
|
||||
mutable GLVolumeCollection m_volumes;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
Selection m_selection;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
DynamicPrintConfig* m_config;
|
||||
Print* m_print;
|
||||
Model* m_model;
|
||||
|
@ -718,21 +652,11 @@ private:
|
|||
bool m_shader_enabled;
|
||||
bool m_dynamic_background_enabled;
|
||||
bool m_multisample_allowed;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
bool m_regenerate_volumes;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
std::string m_color_by;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::string m_select_by;
|
||||
std::string m_drag_by;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
bool m_reload_delayed;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::vector<std::vector<int>> m_objects_volumes_idxs;
|
||||
std::vector<int> m_objects_selections;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
GCodePreviewVolumeIndex m_gcode_preview_volume_index;
|
||||
|
||||
|
@ -759,27 +683,16 @@ public:
|
|||
|
||||
unsigned int get_volumes_count() const;
|
||||
void reset_volumes();
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void deselect_volumes();
|
||||
void select_volume(unsigned int id);
|
||||
void update_volumes_selection(const std::vector<int>& selections);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
int check_volumes_outside_state(const DynamicPrintConfig* config) const;
|
||||
bool move_volume_up(unsigned int id);
|
||||
bool move_volume_down(unsigned int id);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void set_objects_selections(const std::vector<int>& selections);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void set_config(DynamicPrintConfig* config);
|
||||
void set_print(Print* print);
|
||||
void set_model(Model* model);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const Selection& get_selection() const { return m_selection; }
|
||||
Selection& get_selection() { return m_selection; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// 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,
|
||||
|
@ -794,13 +707,6 @@ public:
|
|||
void set_cutting_plane(float z, const ExPolygons& polygons);
|
||||
|
||||
void set_color_by(const std::string& value);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void set_select_by(const std::string& value);
|
||||
void set_drag_by(const std::string& value);
|
||||
|
||||
const std::string& get_select_by() const;
|
||||
const std::string& get_drag_by() const;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
float get_camera_zoom() const;
|
||||
|
||||
|
@ -830,9 +736,7 @@ public:
|
|||
void zoom_to_bed();
|
||||
void zoom_to_volumes();
|
||||
#if ENABLE_MODIFIED_CAMERA_TARGET
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void zoom_to_selection();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#endif // ENABLE_MODIFIED_CAMERA_TARGET
|
||||
void select_view(const std::string& direction);
|
||||
void set_viewport_from_scene(const GLCanvas3D& other);
|
||||
|
@ -853,9 +757,7 @@ public:
|
|||
int get_first_volume_id(int obj_idx) const;
|
||||
int get_in_object_volume_id(int scene_vol_idx) const;
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void mirror_selection(Axis axis);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void reload_scene(bool force);
|
||||
|
||||
|
@ -893,9 +795,6 @@ private:
|
|||
void _resize(unsigned int w, unsigned int h);
|
||||
|
||||
BoundingBoxf3 _max_bounding_box() const;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
BoundingBoxf3 _selected_volumes_bounding_box() const;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
||||
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
||||
|
@ -909,9 +808,7 @@ private:
|
|||
void _render_bed(float theta) const;
|
||||
void _render_axes(bool depth_test) const;
|
||||
void _render_objects() const;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void _render_selection() const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
void _render_cutting_plane() const;
|
||||
void _render_warning_texture() const;
|
||||
void _render_legend_texture() const;
|
||||
|
@ -924,9 +821,7 @@ private:
|
|||
void _render_camera_target() const;
|
||||
#endif // ENABLE_SHOW_CAMERA_TARGET
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void _update_volumes_hover_state() const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
float _get_layers_editing_cursor_z_relative() const;
|
||||
void _perform_layer_editing_action(wxMouseEvent* evt = nullptr);
|
||||
|
@ -944,11 +839,6 @@ private:
|
|||
void _start_timer();
|
||||
void _stop_timer();
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
int _get_first_selected_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.
|
||||
// Adds a new Slic3r::GUI::3DScene::Volume to volumes.
|
||||
void _load_print_toolpaths();
|
||||
|
@ -977,18 +867,11 @@ private:
|
|||
void _update_toolpath_volumes_outside_state();
|
||||
void _show_warning_texture_if_needed();
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void _on_move();
|
||||
void _on_rotate();
|
||||
void _on_scale();
|
||||
void _on_flatten();
|
||||
void _on_mirror();
|
||||
#else
|
||||
void _on_move(const std::vector<int>& volume_idxs);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void _on_select(int volume_idx, int object_idx);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// generates the legend texture in dependence of the current shown view type
|
||||
void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
||||
|
|
|
@ -246,29 +246,6 @@ void GLCanvas3DManager::reset_volumes(wxGLCanvas* canvas)
|
|||
it->second->reset_volumes();
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void GLCanvas3DManager::deselect_volumes(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->deselect_volumes();
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::select_volume(wxGLCanvas* canvas, unsigned int id)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->select_volume(id);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::update_volumes_selection(wxGLCanvas* canvas, const std::vector<int>& selections)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->update_volumes_selection(selections);
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
int GLCanvas3DManager::check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
|
@ -287,20 +264,11 @@ bool GLCanvas3DManager::move_volume_down(wxGLCanvas* canvas, unsigned int id)
|
|||
return (it != m_canvases.end()) ? it->second->move_volume_down(id) : false;
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
GLCanvas3D* GLCanvas3DManager::get_canvas(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second : nullptr;
|
||||
}
|
||||
#else
|
||||
void GLCanvas3DManager::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->set_objects_selections(selections);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void GLCanvas3DManager::set_config(wxGLCanvas* canvas, DynamicPrintConfig* config)
|
||||
{
|
||||
|
@ -364,28 +332,6 @@ void GLCanvas3DManager::set_color_by(wxGLCanvas* canvas, const std::string& valu
|
|||
it->second->set_color_by(value);
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void GLCanvas3DManager::set_select_by(wxGLCanvas* canvas, const std::string& value)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->set_select_by(value);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::set_drag_by(wxGLCanvas* canvas, const std::string& value)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->set_drag_by(value);
|
||||
}
|
||||
|
||||
std::string GLCanvas3DManager::get_select_by(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->get_select_by() : "";
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
bool GLCanvas3DManager::is_layers_editing_enabled(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
|
@ -596,14 +542,12 @@ int GLCanvas3DManager::get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol
|
|||
return (it != m_canvases.end()) ? it->second->get_in_object_volume_id(scene_vol_idx) : -1;
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLCanvas3DManager::mirror_selection(wxGLCanvas* canvas, Axis axis)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->mirror_selection(axis);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void GLCanvas3DManager::reload_scene(wxGLCanvas* canvas, bool force)
|
||||
{
|
||||
|
|
|
@ -87,20 +87,11 @@ public:
|
|||
|
||||
unsigned int get_volumes_count(wxGLCanvas* canvas) const;
|
||||
void reset_volumes(wxGLCanvas* canvas);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void deselect_volumes(wxGLCanvas* canvas);
|
||||
void select_volume(wxGLCanvas* canvas, unsigned int id);
|
||||
void update_volumes_selection(wxGLCanvas* canvas, const std::vector<int>& selections);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
int check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config) const;
|
||||
bool move_volume_up(wxGLCanvas* canvas, unsigned int id);
|
||||
bool move_volume_down(wxGLCanvas* canvas, unsigned int id);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
||||
#else
|
||||
void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void set_config(wxGLCanvas* canvas, DynamicPrintConfig* config);
|
||||
void set_print(wxGLCanvas* canvas, Print* print);
|
||||
|
@ -116,12 +107,6 @@ public:
|
|||
void set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons);
|
||||
|
||||
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_drag_by(wxGLCanvas* canvas, const std::string& value);
|
||||
|
||||
std::string get_select_by(wxGLCanvas* canvas) const;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
||||
bool is_layers_editing_allowed(wxGLCanvas* canvas) const;
|
||||
|
@ -163,9 +148,7 @@ public:
|
|||
int get_first_volume_id(wxGLCanvas* canvas, int obj_idx) const;
|
||||
int get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx) const;
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void mirror_selection(wxGLCanvas* canvas, Axis axis);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void reload_scene(wxGLCanvas* canvas, bool force);
|
||||
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
#include "GUI.hpp"
|
||||
|
||||
#include "../../libslic3r/Utils.hpp"
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
#include "../../slic3r/GUI/GLCanvas3D.hpp"
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include "../../libslic3r/Geometry.hpp"
|
||||
|
@ -26,91 +23,6 @@ static const float AXES_COLOR[3][3] = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
// returns the intersection of the given ray with the plane parallel to plane XY and passing through the given center
|
||||
// coordinates are local to the plane
|
||||
Vec3d intersection_on_plane_xy(const Linef3& ray, const Vec3d& center)
|
||||
{
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.translate(-center);
|
||||
Vec2d mouse_pos_2d = to_2d(transform(ray, m).intersect_plane(0.0));
|
||||
return Vec3d(mouse_pos_2d(0), mouse_pos_2d(1), 0.0);
|
||||
}
|
||||
|
||||
// returns the intersection of the given ray with the plane parallel to plane XZ and passing through the given center
|
||||
// coordinates are local to the plane
|
||||
Vec3d intersection_on_plane_xz(const Linef3& ray, const Vec3d& center)
|
||||
{
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.rotate(Eigen::AngleAxisd(-0.5 * (double)PI, Vec3d::UnitX()));
|
||||
m.translate(-center);
|
||||
Vec2d mouse_pos_2d = to_2d(transform(ray, m).intersect_plane(0.0));
|
||||
return Vec3d(mouse_pos_2d(0), 0.0, mouse_pos_2d(1));
|
||||
}
|
||||
|
||||
// returns the intersection of the given ray with the plane parallel to plane YZ and passing through the given center
|
||||
// coordinates are local to the plane
|
||||
Vec3d intersection_on_plane_yz(const Linef3& ray, const Vec3d& center)
|
||||
{
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.rotate(Eigen::AngleAxisd(-0.5f * (double)PI, Vec3d::UnitY()));
|
||||
m.translate(-center);
|
||||
Vec2d mouse_pos_2d = to_2d(transform(ray, m).intersect_plane(0.0));
|
||||
|
||||
return Vec3d(0.0, mouse_pos_2d(1), -mouse_pos_2d(0));
|
||||
}
|
||||
|
||||
// return an index:
|
||||
// 0 for plane XY
|
||||
// 1 for plane XZ
|
||||
// 2 for plane YZ
|
||||
// which indicates which plane is best suited for intersecting the given unit vector
|
||||
// giving precedence to the plane with the given index
|
||||
unsigned int select_best_plane(const Vec3d& unit_vector, unsigned int preferred_plane)
|
||||
{
|
||||
unsigned int ret = preferred_plane;
|
||||
|
||||
// 1st checks if the given vector is not parallel to the given preferred plane
|
||||
double dot_to_normal = 0.0;
|
||||
switch (ret)
|
||||
{
|
||||
case 0: // plane xy
|
||||
{
|
||||
dot_to_normal = std::abs(unit_vector.dot(Vec3d::UnitZ()));
|
||||
break;
|
||||
}
|
||||
case 1: // plane xz
|
||||
{
|
||||
dot_to_normal = std::abs(unit_vector.dot(-Vec3d::UnitY()));
|
||||
break;
|
||||
}
|
||||
case 2: // plane yz
|
||||
{
|
||||
dot_to_normal = std::abs(unit_vector.dot(Vec3d::UnitX()));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if almost parallel, select the plane whose normal direction is closest to the given vector direction,
|
||||
// otherwise return the given preferred plane index
|
||||
if (dot_to_normal < 0.1)
|
||||
{
|
||||
typedef std::map<double, unsigned int> ProjsMap;
|
||||
ProjsMap projs_map;
|
||||
projs_map.insert(ProjsMap::value_type(std::abs(unit_vector.dot(Vec3d::UnitZ())), 0)); // plane xy
|
||||
projs_map.insert(ProjsMap::value_type(std::abs(unit_vector.dot(-Vec3d::UnitY())), 1)); // plane xz
|
||||
projs_map.insert(ProjsMap::value_type(std::abs(unit_vector.dot(Vec3d::UnitX())), 2)); // plane yz
|
||||
ret = projs_map.rbegin()->second;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
const float GLGizmoBase::Grabber::SizeFactor = 0.025f;
|
||||
const float GLGizmoBase::Grabber::MinHalfSize = 1.5f;
|
||||
const float GLGizmoBase::Grabber::DraggingScaleFactor = 1.25f;
|
||||
|
@ -262,11 +174,7 @@ void GLGizmoBase::disable_grabber(unsigned int id)
|
|||
on_disable_grabber(id);
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoBase::start_dragging(const GLCanvas3D::Selection& selection)
|
||||
#else
|
||||
void GLGizmoBase::start_dragging(const BoundingBoxf3& box)
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
m_dragging = true;
|
||||
|
||||
|
@ -275,11 +183,7 @@ void GLGizmoBase::start_dragging(const BoundingBoxf3& box)
|
|||
m_grabbers[i].dragging = (m_hover_id == i);
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
on_start_dragging(selection);
|
||||
#else
|
||||
on_start_dragging(box);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void GLGizmoBase::stop_dragging()
|
||||
|
@ -385,15 +289,9 @@ bool GLGizmoRotate::on_init()
|
|||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoRotate::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
#else
|
||||
void GLGizmoRotate::on_start_dragging(const BoundingBoxf3& box)
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
m_center = box.center();
|
||||
m_radius = Offset + box.radius();
|
||||
m_snap_coarse_in_radius = m_radius / 3.0f;
|
||||
|
@ -437,16 +335,11 @@ void GLGizmoRotate::on_update(const Linef3& mouse_ray, const Point* mouse_positi
|
|||
m_angle = theta;
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoRotate::on_render(const GLCanvas3D::Selection& selection) const
|
||||
#else
|
||||
void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
if (!m_grabbers[0].enabled)
|
||||
return;
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
bool single_instance = selection.is_single_full_instance();
|
||||
|
||||
|
@ -460,10 +353,6 @@ void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
|
|||
|
||||
if ((single_instance && (m_hover_id == 0)) || m_dragging)
|
||||
set_tooltip(axis + format((float)Geometry::rad2deg(m_angle), 4) + "\u00B0");
|
||||
#else
|
||||
if (m_dragging)
|
||||
set_tooltip(format(m_angle * 180.0f / (float)PI, 4));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
else
|
||||
{
|
||||
m_center = box.center();
|
||||
|
@ -501,22 +390,14 @@ void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
|
|||
::glPopMatrix();
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoRotate::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
#else
|
||||
void GLGizmoRotate::on_render_for_picking(const BoundingBoxf3& box) const
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
::glPushMatrix();
|
||||
|
||||
transform_to_local();
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
render_grabbers_for_picking(selection.get_bounding_box());
|
||||
#else
|
||||
render_grabbers_for_picking(box);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
::glPopMatrix();
|
||||
}
|
||||
|
@ -733,19 +614,11 @@ std::string GLGizmoRotate3D::on_get_name() const
|
|||
return L("Rotate");
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoRotate3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
{
|
||||
if ((0 <= m_hover_id) && (m_hover_id < 3))
|
||||
m_gizmos[m_hover_id].start_dragging(selection);
|
||||
}
|
||||
#else
|
||||
void GLGizmoRotate3D::on_start_dragging(const BoundingBoxf3& box)
|
||||
{
|
||||
if ((0 <= m_hover_id) && (m_hover_id < 3))
|
||||
m_gizmos[m_hover_id].start_dragging(box);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void GLGizmoRotate3D::on_stop_dragging()
|
||||
{
|
||||
|
@ -753,7 +626,6 @@ void GLGizmoRotate3D::on_stop_dragging()
|
|||
m_gizmos[m_hover_id].stop_dragging();
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoRotate3D::on_render(const GLCanvas3D::Selection& selection) const
|
||||
{
|
||||
if ((m_hover_id == -1) || (m_hover_id == 0))
|
||||
|
@ -765,24 +637,8 @@ void GLGizmoRotate3D::on_render(const GLCanvas3D::Selection& selection) const
|
|||
if ((m_hover_id == -1) || (m_hover_id == 2))
|
||||
m_gizmos[Z].render(selection);
|
||||
}
|
||||
#else
|
||||
void GLGizmoRotate3D::on_render(const BoundingBoxf3& box) const
|
||||
{
|
||||
if ((m_hover_id == -1) || (m_hover_id == 0))
|
||||
m_gizmos[X].render(box);
|
||||
|
||||
if ((m_hover_id == -1) || (m_hover_id == 1))
|
||||
m_gizmos[Y].render(box);
|
||||
|
||||
if ((m_hover_id == -1) || (m_hover_id == 2))
|
||||
m_gizmos[Z].render(box);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
const float GLGizmoScale3D::Offset = 5.0f;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
const Vec3d GLGizmoScale3D::OffsetVec = (double)GLGizmoScale3D::Offset * Vec3d::Ones();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent)
|
||||
: GLGizmoBase(parent)
|
||||
|
@ -830,20 +686,12 @@ std::string GLGizmoScale3D::on_get_name() const
|
|||
return L("Scale");
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoScale3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
#else
|
||||
void GLGizmoScale3D::on_start_dragging(const BoundingBoxf3& box)
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
{
|
||||
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
m_starting_box = selection.get_bounding_box();
|
||||
#else
|
||||
m_starting_box = BoundingBoxf3(box.min - OffsetVec, box.max + OffsetVec);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -867,13 +715,8 @@ void GLGizmoScale3D::on_process_double_click()
|
|||
}
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoScale3D::on_render(const GLCanvas3D::Selection& selection) const
|
||||
#else
|
||||
void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
bool single_instance = selection.is_single_full_instance();
|
||||
Vec3f scale = single_instance ? 100.0f * selection.get_volume(*selection.get_volume_idxs().begin())->get_scaling_factor().cast<float>() : 100.0f * m_scale.cast<float>();
|
||||
|
||||
|
@ -891,25 +734,9 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||
tooltip += "Z: " + format(scale(2), 4) + "%";
|
||||
set_tooltip(tooltip);
|
||||
}
|
||||
#else
|
||||
if (m_grabbers[0].dragging || m_grabbers[1].dragging)
|
||||
set_tooltip("X: " + format(100.0f * m_scale(0), 4) + "%");
|
||||
else if (m_grabbers[2].dragging || m_grabbers[3].dragging)
|
||||
set_tooltip("Y: " + format(100.0f * m_scale(1), 4) + "%");
|
||||
else if (m_grabbers[4].dragging || m_grabbers[5].dragging)
|
||||
set_tooltip("Z: " + format(100.0f * m_scale(2), 4) + "%");
|
||||
else if (m_grabbers[6].dragging || m_grabbers[7].dragging || m_grabbers[8].dragging || m_grabbers[9].dragging)
|
||||
{
|
||||
std::string tooltip = "X: " + format(100.0f * m_scale(0), 4) + "%\n";
|
||||
tooltip += "Y: " + format(100.0f * m_scale(1), 4) + "%\n";
|
||||
tooltip += "Z: " + format(100.0f * m_scale(2), 4) + "%";
|
||||
set_tooltip(tooltip);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
BoundingBoxf3 box;
|
||||
Transform3d transform = Transform3d::Identity();
|
||||
Vec3d angles = Vec3d::Zero();
|
||||
|
@ -942,74 +769,45 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||
box = selection.get_bounding_box();
|
||||
|
||||
m_box = box;
|
||||
#else
|
||||
m_box = BoundingBoxf3(box.min - OffsetVec, box.max + OffsetVec);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
const Vec3d& center = m_box.center();
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
Vec3d offset_x = offsets_transform * Vec3d((double)Offset, 0.0, 0.0);
|
||||
Vec3d offset_y = offsets_transform * Vec3d(0.0, (double)Offset, 0.0);
|
||||
Vec3d offset_z = offsets_transform * Vec3d(0.0, 0.0, (double)Offset);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// x axis
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
m_grabbers[0].center = transform * Vec3d(m_box.min(0), center(1), center(2)) - offset_x;
|
||||
m_grabbers[1].center = transform * Vec3d(m_box.max(0), center(1), center(2)) + offset_x;
|
||||
#else
|
||||
m_grabbers[0].center = Vec3d(m_box.min(0), center(1), center(2));
|
||||
m_grabbers[1].center = Vec3d(m_box.max(0), center(1), center(2));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
::memcpy((void*)m_grabbers[0].color, (const void*)&AXES_COLOR[0], 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[1].color, (const void*)&AXES_COLOR[0], 3 * sizeof(float));
|
||||
|
||||
// y axis
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
m_grabbers[2].center = transform * Vec3d(center(0), m_box.min(1), center(2)) - offset_y;
|
||||
m_grabbers[3].center = transform * Vec3d(center(0), m_box.max(1), center(2)) + offset_y;
|
||||
#else
|
||||
m_grabbers[2].center = Vec3d(center(0), m_box.min(1), center(2));
|
||||
m_grabbers[3].center = Vec3d(center(0), m_box.max(1), center(2));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
::memcpy((void*)m_grabbers[2].color, (const void*)&AXES_COLOR[1], 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[3].color, (const void*)&AXES_COLOR[1], 3 * sizeof(float));
|
||||
|
||||
// z axis
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
m_grabbers[4].center = transform * Vec3d(center(0), center(1), m_box.min(2)) - offset_z;
|
||||
m_grabbers[5].center = transform * Vec3d(center(0), center(1), m_box.max(2)) + offset_z;
|
||||
#else
|
||||
m_grabbers[4].center = Vec3d(center(0), center(1), m_box.min(2));
|
||||
m_grabbers[5].center = Vec3d(center(0), center(1), m_box.max(2));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
::memcpy((void*)m_grabbers[4].color, (const void*)&AXES_COLOR[2], 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[5].color, (const void*)&AXES_COLOR[2], 3 * sizeof(float));
|
||||
|
||||
// uniform
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
m_grabbers[6].center = transform * Vec3d(m_box.min(0), m_box.min(1), center(2)) - offset_x - offset_y;
|
||||
m_grabbers[7].center = transform * Vec3d(m_box.max(0), m_box.min(1), center(2)) + offset_x - offset_y;
|
||||
m_grabbers[8].center = transform * Vec3d(m_box.max(0), m_box.max(1), center(2)) + offset_x + offset_y;
|
||||
m_grabbers[9].center = transform * Vec3d(m_box.min(0), m_box.max(1), center(2)) - offset_x + offset_y;
|
||||
#else
|
||||
m_grabbers[6].center = Vec3d(m_box.min(0), m_box.min(1), center(2));
|
||||
m_grabbers[7].center = Vec3d(m_box.max(0), m_box.min(1), center(2));
|
||||
m_grabbers[8].center = Vec3d(m_box.max(0), m_box.max(1), center(2));
|
||||
m_grabbers[9].center = Vec3d(m_box.min(0), m_box.max(1), center(2));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
for (int i = 6; i < 10; ++i)
|
||||
{
|
||||
::memcpy((void*)m_grabbers[i].color, (const void*)m_highlight_color, 3 * sizeof(float));
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
// sets grabbers orientation
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
m_grabbers[i].angles = angles;
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f);
|
||||
|
||||
|
@ -1084,21 +882,12 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoScale3D::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
render_grabbers_for_picking(selection.get_bounding_box());
|
||||
}
|
||||
#else
|
||||
void GLGizmoScale3D::on_render_for_picking(const BoundingBoxf3& box) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
render_grabbers_for_picking(box);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void GLGizmoScale3D::render_grabbers_connection(unsigned int id_1, unsigned int id_2) const
|
||||
{
|
||||
|
@ -1114,11 +903,7 @@ void GLGizmoScale3D::render_grabbers_connection(unsigned int id_1, unsigned int
|
|||
|
||||
void GLGizmoScale3D::do_scale_x(const Linef3& mouse_ray)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
double ratio = calc_ratio(mouse_ray);
|
||||
#else
|
||||
double ratio = calc_ratio(1, mouse_ray, m_starting_box.center());
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (ratio > 0.0)
|
||||
m_scale(0) = m_starting_scale(0) * ratio;
|
||||
|
@ -1126,11 +911,7 @@ void GLGizmoScale3D::do_scale_x(const Linef3& mouse_ray)
|
|||
|
||||
void GLGizmoScale3D::do_scale_y(const Linef3& mouse_ray)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
double ratio = calc_ratio(mouse_ray);
|
||||
#else
|
||||
double ratio = calc_ratio(2, mouse_ray, m_starting_box.center());
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (ratio > 0.0)
|
||||
m_scale(1) = m_starting_scale(1) * ratio;
|
||||
|
@ -1138,11 +919,7 @@ void GLGizmoScale3D::do_scale_y(const Linef3& mouse_ray)
|
|||
|
||||
void GLGizmoScale3D::do_scale_z(const Linef3& mouse_ray)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
double ratio = calc_ratio(mouse_ray);
|
||||
#else
|
||||
double ratio = calc_ratio(1, mouse_ray, m_starting_box.center());
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (ratio > 0.0)
|
||||
m_scale(2) = m_starting_scale(2) * ratio;
|
||||
|
@ -1150,19 +927,12 @@ void GLGizmoScale3D::do_scale_z(const Linef3& mouse_ray)
|
|||
|
||||
void GLGizmoScale3D::do_scale_uniform(const Linef3& mouse_ray)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
double ratio = calc_ratio(mouse_ray);
|
||||
#else
|
||||
Vec3d center = m_starting_box.center();
|
||||
center(2) = m_box.min(2);
|
||||
double ratio = calc_ratio(0, mouse_ray, center);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (ratio > 0.0)
|
||||
m_scale = m_starting_scale * ratio;
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
double GLGizmoScale3D::calc_ratio(const Linef3& mouse_ray) const
|
||||
{
|
||||
double ratio = 0.0;
|
||||
|
@ -1189,53 +959,12 @@ double GLGizmoScale3D::calc_ratio(const Linef3& mouse_ray) const
|
|||
|
||||
return ratio;
|
||||
}
|
||||
#else
|
||||
double GLGizmoScale3D::calc_ratio(unsigned int preferred_plane_id, const Linef3& mouse_ray, const Vec3d& center) const
|
||||
{
|
||||
double ratio = 0.0;
|
||||
|
||||
Vec3d starting_vec = m_starting_drag_position - center;
|
||||
double len_starting_vec = starting_vec.norm();
|
||||
if (len_starting_vec == 0.0)
|
||||
return ratio;
|
||||
|
||||
Vec3d starting_vec_dir = starting_vec.normalized();
|
||||
Vec3d mouse_dir = mouse_ray.unit_vector();
|
||||
|
||||
unsigned int plane_id = select_best_plane(mouse_dir, preferred_plane_id);
|
||||
// ratio is given by the projection of the calculated intersection on the starting vector divided by the starting vector length
|
||||
switch (plane_id)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
ratio = starting_vec_dir.dot(intersection_on_plane_xy(mouse_ray, center)) / len_starting_vec;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
ratio = starting_vec_dir.dot(intersection_on_plane_xz(mouse_ray, center)) / len_starting_vec;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
ratio = starting_vec_dir.dot(intersection_on_plane_yz(mouse_ray, center)) / len_starting_vec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ratio;
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
const double GLGizmoMove3D::Offset = 10.0;
|
||||
|
||||
GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent)
|
||||
: GLGizmoBase(parent)
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
, m_displacement(Vec3d::Zero())
|
||||
#else
|
||||
, m_position(Vec3d::Zero())
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
, m_starting_drag_position(Vec3d::Zero())
|
||||
, m_starting_box_center(Vec3d::Zero())
|
||||
, m_starting_box_bottom_center(Vec3d::Zero())
|
||||
|
@ -1271,18 +1000,12 @@ std::string GLGizmoMove3D::on_get_name() const
|
|||
return L("Move");
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoMove3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
#else
|
||||
void GLGizmoMove3D::on_start_dragging(const BoundingBoxf3& box)
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
m_displacement = Vec3d::Zero();
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
||||
m_starting_box_center = box.center();
|
||||
m_starting_box_bottom_center = box.center();
|
||||
|
@ -1290,39 +1013,23 @@ void GLGizmoMove3D::on_start_dragging(const BoundingBoxf3& box)
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoMove3D::on_stop_dragging()
|
||||
{
|
||||
m_displacement = Vec3d::Zero();
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void GLGizmoMove3D::on_update(const Linef3& mouse_ray, const Point* mouse_pos)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (m_hover_id == 0)
|
||||
m_displacement(0) = calc_projection(mouse_ray);
|
||||
else if (m_hover_id == 1)
|
||||
m_displacement(1) = calc_projection(mouse_ray);
|
||||
else if (m_hover_id == 2)
|
||||
m_displacement(2) = calc_projection(mouse_ray);
|
||||
#else
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoMove3D::on_render(const GLCanvas3D::Selection& selection) const
|
||||
#else
|
||||
void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
bool show_position = selection.is_single_full_instance();
|
||||
const Vec3d& position = selection.get_bounding_box().center();
|
||||
|
||||
|
@ -1332,20 +1039,10 @@ void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
|||
set_tooltip("Y: " + format(show_position ? position(1) : m_displacement(1), 2));
|
||||
else if ((show_position && (m_hover_id == 2)) || m_grabbers[2].dragging)
|
||||
set_tooltip("Z: " + format(show_position ? position(2) : m_displacement(2), 2));
|
||||
#else
|
||||
if (m_grabbers[0].dragging)
|
||||
set_tooltip("X: " + format(m_position(0), 2));
|
||||
else if (m_grabbers[1].dragging)
|
||||
set_tooltip("Y: " + format(m_position(1), 2));
|
||||
else if (m_grabbers[2].dragging)
|
||||
set_tooltip("Z: " + format(m_position(2), 2));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
const Vec3d& center = box.center();
|
||||
|
||||
// x axis
|
||||
|
@ -1394,23 +1091,13 @@ void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoMove3D::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
render_grabbers_for_picking(selection.get_bounding_box());
|
||||
}
|
||||
#else
|
||||
void GLGizmoMove3D::on_render_for_picking(const BoundingBoxf3& box) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
render_grabbers_for_picking(box);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
double GLGizmoMove3D::calc_projection(const Linef3& mouse_ray) const
|
||||
{
|
||||
double projection = 0.0;
|
||||
|
@ -1433,43 +1120,6 @@ double GLGizmoMove3D::calc_projection(const Linef3& mouse_ray) const
|
|||
}
|
||||
return projection;
|
||||
}
|
||||
#else
|
||||
double GLGizmoMove3D::calc_projection(Axis axis, unsigned int preferred_plane_id, const Linef3& mouse_ray) const
|
||||
{
|
||||
double projection = 0.0;
|
||||
|
||||
Vec3d starting_vec = (axis == Z) ? m_starting_drag_position - m_starting_box_bottom_center : m_starting_drag_position - m_starting_box_center;
|
||||
double len_starting_vec = starting_vec.norm();
|
||||
if (len_starting_vec == 0.0)
|
||||
return projection;
|
||||
|
||||
Vec3d starting_vec_dir = starting_vec.normalized();
|
||||
Vec3d mouse_dir = mouse_ray.unit_vector();
|
||||
|
||||
unsigned int plane_id = select_best_plane(mouse_dir, preferred_plane_id);
|
||||
|
||||
switch (plane_id)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
projection = starting_vec_dir.dot(intersection_on_plane_xy(mouse_ray, (axis == Z) ? m_starting_box_bottom_center : m_starting_box_center));
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
projection = starting_vec_dir.dot(intersection_on_plane_xz(mouse_ray, (axis == Z) ? m_starting_box_bottom_center : m_starting_box_center));
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
projection = starting_vec_dir.dot(intersection_on_plane_yz(mouse_ray, (axis == Z) ? m_starting_box_bottom_center : m_starting_box_center));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return projection;
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent)
|
||||
: GLGizmoBase(parent)
|
||||
|
@ -1502,42 +1152,24 @@ std::string GLGizmoFlatten::on_get_name() const
|
|||
return L("Flatten");
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoFlatten::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||
#else
|
||||
void GLGizmoFlatten::on_start_dragging(const BoundingBoxf3& box)
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
{
|
||||
m_normal = m_planes[m_hover_id].normal;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
m_starting_center = selection.get_bounding_box().center();
|
||||
#else
|
||||
m_starting_center = box.center();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoFlatten::on_render(const GLCanvas3D::Selection& selection) const
|
||||
#else
|
||||
void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
// the dragged_offset is a vector measuring where was the object moved
|
||||
// with the gizmo being on. This is reset in set_flattening_data and
|
||||
// does not work correctly when there are multiple copies.
|
||||
Vec3d dragged_offset(Vec3d::Zero());
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (m_starting_center == Vec3d::Zero())
|
||||
m_starting_center = selection.get_bounding_box().center();
|
||||
dragged_offset = selection.get_bounding_box().center() - m_starting_center;
|
||||
#else
|
||||
if (m_starting_center == Vec3d::Zero())
|
||||
m_starting_center = box.center();
|
||||
dragged_offset = box.center() - m_starting_center;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
::glEnable(GL_BLEND);
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
@ -1549,7 +1181,6 @@ void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
|
|||
else
|
||||
::glColor4f(0.9f, 0.9f, 0.9f, 0.5f);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int instance_idx = selection.get_instance_idx();
|
||||
if ((instance_idx != -1) && (m_model_object != nullptr))
|
||||
{
|
||||
|
@ -1565,30 +1196,13 @@ void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
|
|||
::glEnd();
|
||||
::glPopMatrix();
|
||||
}
|
||||
#else
|
||||
for (const InstanceData& inst : m_instances) {
|
||||
Transform3d m = inst.matrix;
|
||||
m.pretranslate(dragged_offset);
|
||||
::glPushMatrix();
|
||||
::glMultMatrixd(m.data());
|
||||
::glBegin(GL_POLYGON);
|
||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||
::glVertex3dv(vertex.data());
|
||||
::glEnd();
|
||||
::glPopMatrix();
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
::glEnable(GL_CULL_FACE);
|
||||
::glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoFlatten::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
#else
|
||||
void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
{
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
::glDisable(GL_CULL_FACE);
|
||||
|
@ -1596,7 +1210,6 @@ void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const
|
|||
for (unsigned int i = 0; i < m_planes.size(); ++i)
|
||||
{
|
||||
::glColor3f(1.0f, 1.0f, picking_color_component(i));
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int instance_idx = selection.get_instance_idx();
|
||||
if ((instance_idx != -1) && (m_model_object != nullptr))
|
||||
{
|
||||
|
@ -1610,17 +1223,6 @@ void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const
|
|||
::glEnd();
|
||||
::glPopMatrix();
|
||||
}
|
||||
#else
|
||||
for (const InstanceData& inst : m_instances) {
|
||||
::glPushMatrix();
|
||||
::glMultMatrixd(inst.matrix.data());
|
||||
::glBegin(GL_POLYGON);
|
||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||
::glVertex3dv(vertex.data());
|
||||
::glEnd();
|
||||
::glPopMatrix();
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
::glEnable(GL_CULL_FACE);
|
||||
|
@ -1631,15 +1233,6 @@ void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object)
|
|||
m_starting_center = Vec3d::Zero();
|
||||
m_model_object = model_object;
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
// ...and save the updated positions of the object instances:
|
||||
if (m_model_object && !m_model_object->instances.empty()) {
|
||||
m_instances.clear();
|
||||
for (const auto* instance : m_model_object->instances)
|
||||
m_instances.emplace_back(instance->world_matrix());
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (is_plane_update_necessary())
|
||||
update_planes();
|
||||
}
|
||||
|
@ -1890,11 +1483,7 @@ void GLGizmoSlaSupports::set_model_object_ptr(ModelObject* model_object)
|
|||
update_mesh();
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoSlaSupports::on_render(const GLCanvas3D::Selection& selection) const
|
||||
#else
|
||||
void GLGizmoSlaSupports::on_render(const BoundingBoxf3& box) const
|
||||
#endif
|
||||
{
|
||||
::glEnable(GL_BLEND);
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
@ -1903,15 +1492,9 @@ void GLGizmoSlaSupports::on_render(const BoundingBoxf3& box) const
|
|||
// with the gizmo being on. This is reset in set_flattening_data and
|
||||
// does not work correctly when there are multiple copies.
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (m_starting_center == Vec3d::Zero())
|
||||
m_starting_center = selection.get_bounding_box().center();
|
||||
Vec3d dragged_offset = selection.get_bounding_box().center() - m_starting_center;
|
||||
#else
|
||||
if (m_starting_center == Vec3d::Zero())
|
||||
m_starting_center = box.center();
|
||||
Vec3d dragged_offset(box.center() - m_starting_center);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
for (auto& g : m_grabbers) {
|
||||
g.color[0] = 1.f;
|
||||
|
@ -1929,11 +1512,7 @@ void GLGizmoSlaSupports::on_render(const BoundingBoxf3& box) const
|
|||
}
|
||||
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void GLGizmoSlaSupports::on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
#else
|
||||
void GLGizmoSlaSupports::on_render_for_picking(const BoundingBoxf3& box) const
|
||||
#endif
|
||||
{
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
for (unsigned int i=0; i<m_grabbers.size(); ++i) {
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
#define slic3r_GLGizmo_hpp_
|
||||
|
||||
#include "../../slic3r/GUI/GLTexture.hpp"
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
#include "../../slic3r/GUI/GLCanvas3D.hpp"
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#include "../../libslic3r/Point.hpp"
|
||||
#include "../../libslic3r/BoundingBox.hpp"
|
||||
|
||||
|
@ -82,9 +80,7 @@ public:
|
|||
EState get_state() const { return m_state; }
|
||||
void set_state(EState state) { m_state = state; on_set_state(); }
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
unsigned int get_texture_id() const { return m_textures[m_state].get_id(); }
|
||||
int get_textures_size() const { return m_textures[Off].get_width(); }
|
||||
|
@ -97,11 +93,7 @@ public:
|
|||
void enable_grabber(unsigned int id);
|
||||
void disable_grabber(unsigned int id);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void start_dragging(const GLCanvas3D::Selection& selection);
|
||||
#else
|
||||
void start_dragging(const BoundingBoxf3& box);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
void stop_dragging();
|
||||
bool is_dragging() const { return m_dragging; }
|
||||
|
||||
|
@ -111,41 +103,25 @@ public:
|
|||
void process_double_click() { on_process_double_click(); }
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
|
||||
#if ENABLE_EXTENDED_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); }
|
||||
#else
|
||||
void render(const BoundingBoxf3& box) const { on_render(box); }
|
||||
void render_for_picking(const BoundingBoxf3& box) const { on_render_for_picking(box); }
|
||||
#endif // ENABLE_EXTENDED_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() {}
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return true; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_enable_grabber(unsigned int id) {}
|
||||
virtual void on_disable_grabber(unsigned int id) {}
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection) {}
|
||||
#else
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box) {}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_stop_dragging() {}
|
||||
virtual void on_update(const Linef3& mouse_ray, const Point* mouse_pos) = 0;
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
virtual void on_process_double_click() {}
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const = 0;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const = 0;
|
||||
#else
|
||||
virtual void on_render(const BoundingBoxf3& box) const = 0;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const = 0;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
float picking_color_component(unsigned int id) const;
|
||||
void render_grabbers(const BoundingBoxf3& box) const;
|
||||
|
@ -196,22 +172,13 @@ public:
|
|||
protected:
|
||||
virtual bool on_init();
|
||||
virtual std::string on_get_name() const { return ""; }
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
#else
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_update(const Linef3& mouse_ray, const Point* mouse_pos);
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
virtual void on_process_double_click() { m_angle = 0.0; }
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
#else
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
private:
|
||||
void render_circle() const;
|
||||
|
@ -253,9 +220,7 @@ protected:
|
|||
m_gizmos[i].set_hover_id((m_hover_id == i) ? 0 : -1);
|
||||
}
|
||||
}
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_enable_grabber(unsigned int id)
|
||||
{
|
||||
if ((0 <= id) && (id < 3))
|
||||
|
@ -266,11 +231,7 @@ protected:
|
|||
if ((0 <= id) && (id < 3))
|
||||
m_gizmos[id].disable_grabber(0);
|
||||
}
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
#else
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_stop_dragging();
|
||||
virtual void on_update(const Linef3& mouse_ray, const Point* mouse_pos)
|
||||
{
|
||||
|
@ -286,7 +247,6 @@ protected:
|
|||
m_gizmos[m_hover_id].process_double_click();
|
||||
}
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const
|
||||
{
|
||||
|
@ -295,24 +255,11 @@ protected:
|
|||
g.render_for_picking(selection);
|
||||
}
|
||||
}
|
||||
#else
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const
|
||||
{
|
||||
for (const GLGizmoRotate& g : m_gizmos)
|
||||
{
|
||||
g.render_for_picking(box);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
};
|
||||
|
||||
class GLGizmoScale3D : public GLGizmoBase
|
||||
{
|
||||
static const float Offset;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
static const Vec3d OffsetVec;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
mutable BoundingBoxf3 m_box;
|
||||
|
||||
|
@ -326,34 +273,19 @@ public:
|
|||
explicit GLGizmoScale3D(GLCanvas3D& parent);
|
||||
|
||||
const Vec3d& get_scale() const { return m_scale; }
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void set_scale(const Vec3d& scale) { m_starting_scale = scale; m_scale = scale; }
|
||||
#else
|
||||
void set_scale(const Vec3d& scale) { m_starting_scale = scale; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual std::string on_get_name() const;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
#else
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_update(const Linef3& mouse_ray, const Point* mouse_pos);
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
virtual void on_process_double_click();
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
#else
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
private:
|
||||
void render_grabbers_connection(unsigned int id_1, unsigned int id_2) const;
|
||||
|
@ -363,22 +295,14 @@ private:
|
|||
void do_scale_z(const Linef3& mouse_ray);
|
||||
void do_scale_uniform(const Linef3& mouse_ray);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
double calc_ratio(const Linef3& mouse_ray) const;
|
||||
#else
|
||||
double calc_ratio(unsigned int preferred_plane_id, const Linef3& mouse_ray, const Vec3d& center) const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
};
|
||||
|
||||
class GLGizmoMove3D : public GLGizmoBase
|
||||
{
|
||||
static const double Offset;
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
Vec3d m_displacement;
|
||||
#else
|
||||
Vec3d m_position;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
Vec3d m_starting_drag_position;
|
||||
Vec3d m_starting_box_center;
|
||||
Vec3d m_starting_box_bottom_center;
|
||||
|
@ -386,37 +310,19 @@ class GLGizmoMove3D : public GLGizmoBase
|
|||
public:
|
||||
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; }
|
||||
void set_position(const Vec3d& position) { m_position = position; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual std::string on_get_name() const;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
virtual void on_stop_dragging();
|
||||
#else
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_update(const Linef3& mouse_ray, const Point* mouse_pos);
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
#else
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
private:
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
double calc_projection(const Linef3& mouse_ray) const;
|
||||
#else
|
||||
double calc_projection(Axis axis, unsigned int preferred_plane_id, const Linef3& mouse_ray) const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
};
|
||||
|
||||
class GLGizmoFlatten : public GLGizmoBase
|
||||
|
@ -440,14 +346,6 @@ private:
|
|||
SourceDataSummary m_source_data;
|
||||
|
||||
std::vector<PlaneData> m_planes;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
struct InstanceData
|
||||
{
|
||||
Transform3d matrix;
|
||||
InstanceData(const Transform3d& matrix) : matrix(matrix) {}
|
||||
};
|
||||
std::vector<InstanceData> m_instances;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
mutable Vec3d m_starting_center;
|
||||
const ModelObject* m_model_object = nullptr;
|
||||
|
||||
|
@ -463,22 +361,11 @@ public:
|
|||
protected:
|
||||
virtual bool on_init();
|
||||
virtual std::string on_get_name() const;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return selection.is_single_full_instance(); }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||
#else
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_update(const Linef3& mouse_ray, const Point* mouse_pos) {}
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
#else
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_set_state()
|
||||
{
|
||||
if (m_state == On && is_plane_update_necessary())
|
||||
|
@ -515,13 +402,8 @@ public:
|
|||
private:
|
||||
bool on_init();
|
||||
void on_update(const Linef3& mouse_ray, const Point* mouse_pos);
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
virtual void on_render(const GLCanvas3D::Selection& selection) const;
|
||||
virtual void on_render_for_picking(const GLCanvas3D::Selection& selection) const;
|
||||
#else
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void render_grabbers(bool picking = false) const;
|
||||
void render_tooltip_texture() const;
|
||||
|
|
|
@ -25,13 +25,7 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_FEWER, SimpleEvent);
|
|||
wxDEFINE_EVENT(EVT_GLTOOLBAR_SPLIT_OBJECTS, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_SPLIT_VOLUMES, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_SETTINGS, SimpleEvent);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_LAYERSEDITING, SimpleEvent);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
wxDEFINE_EVENT(EVT_GLTOOLBAR_SELECTBYPARTS, SimpleEvent);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
|
||||
GLToolbarItem::Data::Data()
|
||||
|
|
|
@ -25,13 +25,7 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_FEWER, SimpleEvent);
|
|||
wxDECLARE_EVENT(EVT_GLTOOLBAR_SPLIT_OBJECTS, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLTOOLBAR_SPLIT_VOLUMES, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
wxDECLARE_EVENT(EVT_GLTOOLBAR_SETTINGS, SimpleEvent);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
wxDECLARE_EVENT(EVT_GLTOOLBAR_LAYERSEDITING, SimpleEvent);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
wxDECLARE_EVENT(EVT_GLTOOLBAR_SELECTBYPARTS, SimpleEvent);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
class GLToolbarItem
|
||||
{
|
||||
|
|
|
@ -960,10 +960,8 @@ void ObjectList::split(const bool split_part)
|
|||
m_parts_changed = true;
|
||||
parts_changed(m_selected_object_id);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
// restores selection
|
||||
_3DScene::get_canvas(wxGetApp().canvas3D())->get_selection().add_object(m_selected_object_id);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
bool ObjectList::get_volume_by_item(const bool split_part, const wxDataViewItem& item, ModelVolume*& volume)
|
||||
|
@ -1071,11 +1069,7 @@ void ObjectList::part_selection_changed()
|
|||
|
||||
m_selected_object_id = obj_idx;
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
wxGetApp().obj_manipul()->update_settings_value(_3DScene::get_canvas(wxGetApp().canvas3D())->get_selection());
|
||||
#else
|
||||
wxGetApp().obj_manipul()->update_values();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void ObjectList::update_manipulation_sizer(const bool is_simple_mode)
|
||||
|
@ -1094,9 +1088,6 @@ void ObjectList::add_object_to_list(size_t obj_idx)
|
|||
auto model_object = (*m_objects)[obj_idx];
|
||||
wxString item_name = model_object->name;
|
||||
auto item = m_objects_model->Add(item_name);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
/*Select*/select_item(item);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// Add error icon if detected auto-repaire
|
||||
auto stats = model_object->volumes[0]->mesh.stl.stats;
|
||||
|
@ -1224,7 +1215,6 @@ bool ObjectList::multiple_selection() const
|
|||
|
||||
void ObjectList::update_selections()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
auto& selection = _3DScene::get_canvas(wxGetApp().canvas3D())->get_selection();
|
||||
wxDataViewItemArray sels;
|
||||
|
||||
|
@ -1234,13 +1224,10 @@ void ObjectList::update_selections()
|
|||
sels.Add(m_objects_model->GetItemByVolumeId(gl_vol->object_idx(), gl_vol->volume_idx()));
|
||||
}
|
||||
select_items(sels);
|
||||
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void ObjectList::update_selections_on_canvas()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
auto& selection = _3DScene::get_canvas(wxGetApp().canvas3D())->get_selection();
|
||||
|
||||
const int sel_cnt = GetSelectedItemsCount();
|
||||
|
@ -1288,8 +1275,6 @@ void ObjectList::update_selections_on_canvas()
|
|||
add_to_selection(item, selection, false);
|
||||
|
||||
_3DScene::render(wxGetApp().canvas3D());
|
||||
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void ObjectList::select_item(const wxDataViewItem& item)
|
||||
|
|
|
@ -266,7 +266,6 @@ void ObjectManipulation::update_settings_list()
|
|||
parent->GetParent()->Layout();
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& selection)
|
||||
{
|
||||
if (selection.is_single_full_object())
|
||||
|
@ -344,7 +343,6 @@ void ObjectManipulation::reset_scale_value()
|
|||
m_og->set_value("scale_y", 100);
|
||||
m_og->set_value("scale_z", 100);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void ObjectManipulation::update_values()
|
||||
{
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
#include <wx/panel.h>
|
||||
|
||||
#include "Preset.hpp"
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
#include "GLCanvas3D.hpp"
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
class wxBoxSizer;
|
||||
|
||||
|
@ -16,7 +14,6 @@ namespace Slic3r {
|
|||
namespace GUI {
|
||||
class ConfigOptionsGroup;
|
||||
|
||||
|
||||
class OG_Settings
|
||||
{
|
||||
protected:
|
||||
|
@ -47,13 +44,11 @@ public:
|
|||
int ol_selection();
|
||||
void update_settings_list();
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void update_settings_value(const GLCanvas3D::Selection& selection);
|
||||
void reset_settings_value();
|
||||
void reset_position_value();
|
||||
void reset_rotation_value();
|
||||
void reset_scale_value();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void update_values();
|
||||
// update position values displacements or "gizmos"
|
||||
|
|
|
@ -754,18 +754,6 @@ std::vector<PresetComboBox*>& Sidebar::combos_filament()
|
|||
return p->combos_filament;
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
// Plater::Object
|
||||
|
||||
struct PlaterObject
|
||||
{
|
||||
std::string name;
|
||||
bool selected;
|
||||
|
||||
PlaterObject(std::string name) : name(std::move(name)), selected(false) {}
|
||||
};
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// Plater::DropTarget
|
||||
|
||||
class PlaterDropTarget : public wxFileDropTarget
|
||||
|
@ -817,9 +805,6 @@ struct Plater::priv
|
|||
Slic3r::Print print;
|
||||
Slic3r::Model model;
|
||||
Slic3r::GCodePreviewData gcode_preview_data;
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::vector<PlaterObject> objects;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// GUI elements
|
||||
wxNotebook *notebook;
|
||||
|
@ -835,9 +820,6 @@ struct Plater::priv
|
|||
|
||||
priv(Plater *q, MainFrame *main_frame);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::vector<int> collect_selections();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void update(bool force_autocenter = false);
|
||||
void select_view(const std::string& direction);
|
||||
void update_ui_from_settings();
|
||||
|
@ -849,30 +831,15 @@ 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);
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const GLCanvas3D::Selection& get_selection() const;
|
||||
GLCanvas3D::Selection& get_selection();
|
||||
int get_selected_object_idx() const;
|
||||
#else
|
||||
void select_object(optional<size_t> obj_idx);
|
||||
void select_object_from_cpp();
|
||||
optional<size_t> selected_object() const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
void selection_changed();
|
||||
void object_list_changed();
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void select_view();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void remove(size_t obj_idx);
|
||||
void reset();
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void rotate();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void mirror(Axis axis);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void scale();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void arrange();
|
||||
void split_object();
|
||||
void split_volume();
|
||||
|
@ -896,25 +863,12 @@ struct Plater::priv
|
|||
void on_action_split_objects(SimpleEvent&);
|
||||
void on_action_split_volumes(SimpleEvent&);
|
||||
void on_action_cut(SimpleEvent&);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void on_action_settings(SimpleEvent&);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void on_action_layersediting(SimpleEvent&);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void on_action_selectbyparts(SimpleEvent&);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void on_object_select(SimpleEvent&);
|
||||
#else
|
||||
void on_object_select(ObjectSelectEvent&);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
void on_viewport_changed(SimpleEvent&);
|
||||
void on_right_click(Vec2dEvent&);
|
||||
void on_model_update(SimpleEvent&);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void on_scale_uniformly(SimpleEvent&);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
void on_wipetower_moved(Vec3dEvent&);
|
||||
void on_enable_action_buttons(Event<bool>&);
|
||||
void on_update_geometry(Vec3dsEvent<2>&);
|
||||
|
@ -922,7 +876,6 @@ struct Plater::priv
|
|||
private:
|
||||
bool init_object_menu();
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
bool can_delete_object() const;
|
||||
bool can_increase_instances() const;
|
||||
bool can_decrease_instances() const;
|
||||
|
@ -933,7 +886,6 @@ private:
|
|||
bool can_delete_all() const;
|
||||
bool can_arrange() const;
|
||||
bool can_mirror() const;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
};
|
||||
|
||||
const std::regex Plater::priv::pattern_bundle(".*[.](amf|amf[.]xml|zip[.]amf|3mf|prusa)", std::regex::icase);
|
||||
|
@ -976,10 +928,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||
_3DScene::enable_picking(canvas3D, true);
|
||||
_3DScene::enable_moving(canvas3D, true);
|
||||
// XXX: more config from 3D.pm
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::set_select_by(canvas3D, "object");
|
||||
_3DScene::set_drag_by(canvas3D, "instance");
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::set_model(canvas3D, &model);
|
||||
_3DScene::set_print(canvas3D, &print);
|
||||
_3DScene::set_config(canvas3D, config);
|
||||
|
@ -1017,17 +965,10 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||
canvas3D->Bind(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, &priv::on_schedule_background_process, this);
|
||||
canvas3D->Bind(EVT_GLCANVAS_OBJECT_SELECT, &priv::on_object_select, this);
|
||||
canvas3D->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLCANVAS_DOUBLE_CLICK, [](SimpleEvent&) {}); // XXX: remove?
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLCANVAS_RIGHT_CLICK, &priv::on_right_click, this);
|
||||
canvas3D->Bind(EVT_GLCANVAS_MODEL_UPDATE, &priv::on_model_update, this);
|
||||
canvas3D->Bind(EVT_GLCANVAS_REMOVE_OBJECT, [q](SimpleEvent&) { q->remove_selected(); });
|
||||
canvas3D->Bind(EVT_GLCANVAS_ARRANGE, [this](SimpleEvent&) { arrange(); });
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLCANVAS_ROTATE_OBJECT, [this](Event<int> &evt) { /*TODO: call rotate */ });
|
||||
canvas3D->Bind(EVT_GLCANVAS_SCALE_UNIFORMLY, [this](SimpleEvent&) { this->scale(); });
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLCANVAS_INCREASE_INSTANCES, [q](Event<int> &evt) { evt.data == 1 ? q->increase_instances() : q->decrease_instances(); });
|
||||
canvas3D->Bind(EVT_GLCANVAS_INSTANCE_MOVED, [this](SimpleEvent&) { update(); });
|
||||
canvas3D->Bind(EVT_GLCANVAS_WIPETOWER_MOVED, &priv::on_wipetower_moved, this);
|
||||
|
@ -1043,13 +984,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||
canvas3D->Bind(EVT_GLTOOLBAR_SPLIT_OBJECTS, &priv::on_action_split_objects, this);
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_SPLIT_VOLUMES, &priv::on_action_split_volumes, this);
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_CUT, &priv::on_action_cut, this);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_SETTINGS, &priv::on_action_settings, this);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_LAYERSEDITING, &priv::on_action_layersediting, this);
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
canvas3D->Bind(EVT_GLTOOLBAR_SELECTBYPARTS, &priv::on_action_selectbyparts, this);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// Preview events:
|
||||
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
|
||||
|
@ -1064,17 +999,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
|
|||
q->Layout();
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::vector<int> Plater::priv::collect_selections()
|
||||
{
|
||||
std::vector<int> res;
|
||||
for (const auto &obj : objects) {
|
||||
res.push_back(obj.selected);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::update(bool force_autocenter)
|
||||
{
|
||||
wxWindowUpdateLocker freeze_guard(q);
|
||||
|
@ -1086,10 +1010,6 @@ void Plater::priv::update(bool force_autocenter)
|
|||
model.center_instances_around_point(bed_center);
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
const auto selections = collect_selections();
|
||||
_3DScene::set_objects_selections(canvas3D, selections);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::reload_scene(canvas3D, false);
|
||||
preview->reset_gcode_preview_data();
|
||||
preview->reload_print();
|
||||
|
@ -1261,19 +1181,12 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
|
|||
bool need_arrange = false;
|
||||
bool scaled_down = false;
|
||||
std::vector<size_t> obj_idxs;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
unsigned int obj_count = model.objects.size();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
for (ModelObject *model_object : model_objects) {
|
||||
auto *object = model.add_object(*model_object);
|
||||
std::string object_name = object->name.empty() ? fs::path(object->input_file).filename().string() : object->name;
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
obj_idxs.push_back(obj_count++);
|
||||
#else
|
||||
objects.emplace_back(std::move(object_name));
|
||||
obj_idxs.push_back(objects.size() - 1);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (model_object->instances.empty()) {
|
||||
// if object has no defined position(s) we need to rearrange everything after loading
|
||||
|
@ -1385,7 +1298,6 @@ std::unique_ptr<CheckboxFileDialog> Plater::priv::get_export_file(GUI::FileType
|
|||
return dlg;
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const GLCanvas3D::Selection& Plater::priv::get_selection() const
|
||||
{
|
||||
return _3DScene::get_canvas(canvas3D)->get_selection();
|
||||
|
@ -1401,43 +1313,9 @@ int Plater::priv::get_selected_object_idx() const
|
|||
int idx = get_selection().get_object_idx();
|
||||
return ((0 <= idx) && (idx < 1000)) ? idx : -1;
|
||||
}
|
||||
#else
|
||||
void Plater::priv::select_object(optional<size_t> obj_idx)
|
||||
{
|
||||
for (auto &obj : objects) {
|
||||
obj.selected = false;
|
||||
}
|
||||
|
||||
if (obj_idx) {
|
||||
objects[*obj_idx].selected = true;
|
||||
}
|
||||
|
||||
selection_changed();
|
||||
}
|
||||
|
||||
void Plater::priv::select_object_from_cpp()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
optional<size_t> Plater::priv::selected_object() const
|
||||
{
|
||||
for (size_t i = 0; i < objects.size(); i++) {
|
||||
if (objects[i].selected) { return i; }
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::selection_changed()
|
||||
{
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
const auto obj_idx = selected_object();
|
||||
const bool have_sel = !!obj_idx;
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::enable_toolbar_item(canvas3D, "delete", can_delete_object());
|
||||
_3DScene::enable_toolbar_item(canvas3D, "more", can_increase_instances());
|
||||
_3DScene::enable_toolbar_item(canvas3D, "fewer", can_decrease_instances());
|
||||
|
@ -1447,45 +1325,13 @@ void Plater::priv::selection_changed()
|
|||
_3DScene::enable_toolbar_item(canvas3D, "layersediting", layers_height_allowed());
|
||||
// forces a frame render to update the view (to avoid a missed update if, for example, the context menu appears)
|
||||
_3DScene::render(canvas3D);
|
||||
#else
|
||||
_3DScene::enable_toolbar_item(canvas3D, "fewer", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "splitobjects", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "splitvolumes", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "cut", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "settings", have_sel);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "layersediting", have_sel && config->opt_bool("variable_layer_height") && _3DScene::is_layers_editing_allowed(canvas3D));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = get_selected_object_idx();
|
||||
bool have_sel = (obj_idx != -1);
|
||||
#else
|
||||
bool can_select_by_parts = false;
|
||||
|
||||
if (have_sel) {
|
||||
const auto *model_object = model.objects[*obj_idx];
|
||||
// XXX: ?
|
||||
can_select_by_parts = *obj_idx < 1000 && model_object->volumes.size() > 1;
|
||||
_3DScene::enable_toolbar_item(canvas3D, "fewer", model_object->instances.size() > 1);
|
||||
}
|
||||
|
||||
if (can_select_by_parts) {
|
||||
// first disable to let the item in the toolbar to switch to the unpressed state // XXX: ?
|
||||
_3DScene::enable_toolbar_item(canvas3D, "selectbyparts", false);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "selectbyparts", true);
|
||||
} else {
|
||||
_3DScene::enable_toolbar_item(canvas3D, "selectbyparts", false);
|
||||
_3DScene::set_select_by(canvas3D, "object");
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
wxWindowUpdateLocker freeze_guard(sidebar);
|
||||
if (have_sel) {
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
const ModelObject* model_object = model.objects[obj_idx];
|
||||
#else
|
||||
const auto *model_object = model.objects[*obj_idx];
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
// FIXME print_info runs model fixing in two rounds, it is very slow, it should not be performed here!
|
||||
// # $model_object->print_info;
|
||||
|
||||
|
@ -1531,33 +1377,16 @@ void Plater::priv::selection_changed()
|
|||
void Plater::priv::object_list_changed()
|
||||
{
|
||||
// Enable/disable buttons depending on whether there are any objects on the platter.
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::enable_toolbar_item(canvas3D, "deleteall", can_delete_all());
|
||||
_3DScene::enable_toolbar_item(canvas3D, "arrange", can_arrange());
|
||||
#else
|
||||
const bool have_objects = !objects.empty();
|
||||
_3DScene::enable_toolbar_item(canvas3D, "deleteall", have_objects);
|
||||
_3DScene::enable_toolbar_item(canvas3D, "arrange", have_objects);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
const bool export_in_progress = this->background_process.is_export_scheduled(); // || ! send_gcode_file.empty());
|
||||
// XXX: is this right?
|
||||
const bool model_fits = _3DScene::check_volumes_outside_state(canvas3D, config) == ModelInstance::PVS_Inside;
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
sidebar->enable_buttons(!model.objects.empty() && !export_in_progress && model_fits);
|
||||
#else
|
||||
sidebar->enable_buttons(have_objects && !export_in_progress && model_fits);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::select_view()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::remove(size_t obj_idx)
|
||||
{
|
||||
// Prevent toolpaths preview from rendering while we modify the Print object
|
||||
|
@ -1566,19 +1395,12 @@ void Plater::priv::remove(size_t obj_idx)
|
|||
if (_3DScene::is_layers_editing_enabled(canvas3D))
|
||||
_3DScene::enable_layers_editing(canvas3D, false);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
objects.erase(objects.begin() + obj_idx);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
model.delete_object(obj_idx);
|
||||
// print.delete_object(obj_idx);
|
||||
// Delete object from Sidebar list
|
||||
sidebar->obj_list()->delete_object_from_list(obj_idx);
|
||||
|
||||
object_list_changed();
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
select_object(boost::none);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -1590,43 +1412,20 @@ void Plater::priv::reset()
|
|||
if (_3DScene::is_layers_editing_enabled(canvas3D))
|
||||
_3DScene::enable_layers_editing(canvas3D, false);
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
objects.clear();
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
model.clear_objects();
|
||||
// print.clear_objects();
|
||||
|
||||
// Delete all objects from list on c++ side
|
||||
sidebar->obj_list()->delete_all_objects_from_list();
|
||||
object_list_changed();
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
select_object(boost::none);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
update();
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::rotate()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::mirror(Axis axis)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::mirror_selection(canvas3D, axis);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::scale()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::arrange()
|
||||
{
|
||||
main_frame->app_controller()->arrange_model();
|
||||
|
@ -1639,7 +1438,6 @@ void Plater::priv::arrange()
|
|||
|
||||
void Plater::priv::split_object()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
@ -1683,7 +1481,6 @@ void Plater::priv::split_object()
|
|||
get_selection().add_object((unsigned int)idx, false);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void Plater::priv::split_volume()
|
||||
|
@ -1723,11 +1520,9 @@ void Plater::priv::async_apply_config()
|
|||
this->preview->reload_print();
|
||||
// We also need to reload 3D scene because of the wipe tower preview box
|
||||
if (this->config->opt_bool("wipe_tower")) {
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
std::vector<int> selections = this->collect_selections();
|
||||
Slic3r::_3DScene::set_objects_selections(this->canvas3D, selections);
|
||||
Slic3r::_3DScene::reload_scene(this->canvas3D, 1);
|
||||
#endif /* !ENABLE_EXTENDED_SELECTION */
|
||||
// std::vector<int> selections = this->collect_selections();
|
||||
// Slic3r::_3DScene::set_objects_selections(this->canvas3D, selections);
|
||||
// Slic3r::_3DScene::reload_scene(this->canvas3D, 1);
|
||||
}
|
||||
}
|
||||
if (invalidated != Print::APPLY_STATUS_UNCHANGED && this->get_config("background_processing") == "1" &&
|
||||
|
@ -1801,9 +1596,6 @@ void Plater::priv::on_notebook_changed(wxBookCtrlEvent&)
|
|||
const auto current_id = notebook->GetCurrentPage()->GetId();
|
||||
if (current_id == canvas3D->GetId()) {
|
||||
if (_3DScene::is_reload_delayed(canvas3D)) {
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
_3DScene::set_objects_selections(canvas3D, collect_selections());
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
_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)
|
||||
|
@ -1865,12 +1657,10 @@ void Plater::priv::on_update_print_preview(wxCommandEvent &)
|
|||
if (this->preview != nullptr)
|
||||
this->preview->reload_print();
|
||||
// in case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth:
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
auto selections = collect_selections();
|
||||
_3DScene::set_objects_selections(canvas3D, selections);
|
||||
if (canvas3D)
|
||||
_3DScene::reload_scene(canvas3D, true);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
// auto selections = collect_selections();
|
||||
// _3DScene::set_objects_selections(canvas3D, selections);
|
||||
// if (canvas3D)
|
||||
// _3DScene::reload_scene(canvas3D, true);
|
||||
}
|
||||
|
||||
void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
||||
|
@ -1942,13 +1732,6 @@ void Plater::priv::on_action_cut(SimpleEvent&)
|
|||
// TODO
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::on_action_settings(SimpleEvent&)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::on_action_layersediting(SimpleEvent&)
|
||||
{
|
||||
bool enable = !_3DScene::is_layers_editing_enabled(canvas3D);
|
||||
|
@ -1957,31 +1740,11 @@ void Plater::priv::on_action_layersediting(SimpleEvent&)
|
|||
_3DScene::enable_toolbar_item(canvas3D, "layersediting", false);
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::on_action_selectbyparts(SimpleEvent&)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::on_object_select(SimpleEvent& evt)
|
||||
{
|
||||
selection_changed();
|
||||
wxGetApp().obj_list()->update_selections();
|
||||
}
|
||||
#else
|
||||
void Plater::priv::on_object_select(ObjectSelectEvent &evt)
|
||||
{
|
||||
const auto obj_idx = evt.object_id();
|
||||
const auto vol_idx = evt.volume_id();
|
||||
|
||||
if (obj_idx >= 0 && obj_idx < 1000 && vol_idx == -1) {
|
||||
// Ignore the special objects (the wipe tower proxy and such).
|
||||
select_object(obj_idx);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::on_viewport_changed(SimpleEvent& evt)
|
||||
{
|
||||
|
@ -1994,16 +1757,12 @@ void Plater::priv::on_viewport_changed(SimpleEvent& evt)
|
|||
|
||||
void Plater::priv::on_right_click(Vec2dEvent& evt)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
if (q != nullptr)
|
||||
q->PopupMenu(&object_menu, (int)evt.data.x(), (int)evt.data.y());
|
||||
#else
|
||||
// TODO
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void Plater::priv::on_model_update(SimpleEvent&)
|
||||
|
@ -2011,42 +1770,6 @@ void Plater::priv::on_model_update(SimpleEvent&)
|
|||
// TODO
|
||||
}
|
||||
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
void Plater::priv::on_scale_uniformly(SimpleEvent&)
|
||||
{
|
||||
// my ($scale) = @_;
|
||||
|
||||
// my ($obj_idx, $object) = $self->selected_object;
|
||||
const auto obj_idx = selected_object();
|
||||
if (! obj_idx) { return; }
|
||||
// return if !defined $obj_idx;
|
||||
|
||||
// my $model_object = $self->{model}->objects->[$obj_idx];
|
||||
// my $model_instance = $model_object->instances->[0];
|
||||
|
||||
// my $variation = $scale / $model_instance->scaling_factor;
|
||||
// #FIXME Scale the layer height profile?
|
||||
// foreach my $range (@{ $model_object->layer_height_ranges }) {
|
||||
// $range->[0] *= $variation;
|
||||
// $range->[1] *= $variation;
|
||||
// }
|
||||
// $_->set_scaling_factor($scale) for @{ $model_object->instances };
|
||||
|
||||
// # Set object scale on c++ side
|
||||
// # Slic3r::GUI::set_object_scale($obj_idx, $model_object->instances->[0]->scaling_factor * 100);
|
||||
|
||||
// # $object->transform_thumbnail($self->{model}, $obj_idx);
|
||||
|
||||
// #update print and start background processing
|
||||
// $self->{print}->add_model_object($model_object, $obj_idx);
|
||||
|
||||
// $self->selection_changed(1); # refresh info (size, volume etc.)
|
||||
// $self->update;
|
||||
|
||||
this->schedule_background_process();
|
||||
}
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
|
||||
void Plater::priv::on_wipetower_moved(Vec3dEvent &evt)
|
||||
{
|
||||
DynamicPrintConfig cfg;
|
||||
|
@ -2102,7 +1825,6 @@ bool Plater::priv::init_object_menu()
|
|||
|
||||
wxMenuItem* item_split = append_submenu(&object_menu, split_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object")), "shape_ungroup.png");
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
// ui updates needs to be binded to the parent panel
|
||||
if (q != nullptr)
|
||||
{
|
||||
|
@ -2115,12 +1837,10 @@ bool Plater::priv::init_object_menu()
|
|||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_objects()); }, item_split_objects->GetId());
|
||||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_volumes()); }, item_split_volumes->GetId());
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
bool Plater::priv::can_delete_object() const
|
||||
{
|
||||
int obj_idx = get_selected_object_idx();
|
||||
|
@ -2177,7 +1897,6 @@ bool Plater::priv::can_mirror() const
|
|||
{
|
||||
return get_selection().is_from_single_instance();
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
// Plater / Public
|
||||
|
||||
|
@ -2218,51 +1937,28 @@ void Plater::remove(size_t obj_idx) { p->remove(obj_idx); }
|
|||
|
||||
void Plater::remove_selected()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx != -1)
|
||||
remove((size_t)obj_idx);
|
||||
#else
|
||||
const auto selected = p->selected_object();
|
||||
if (selected) {
|
||||
remove(*selected);
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
void Plater::increase_instances(size_t num)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
ModelInstance* model_instance = model_object->instances.back();
|
||||
#else
|
||||
const auto obj_idx = p->selected_object();
|
||||
if (! obj_idx) { return; }
|
||||
|
||||
auto *model_object = p->model.objects[*obj_idx];
|
||||
auto *model_instance = model_object->instances[model_object->instances.size() - 1];
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
float offset = 10.0;
|
||||
for (size_t i = 0; i < num; i++, offset += 10.0) {
|
||||
Vec3d offset_vec = model_instance->get_offset() + Vec3d(offset, offset, 0.0);
|
||||
model_object->add_instance(offset_vec, model_instance->get_scaling_factor(), model_instance->get_rotation());
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
// p->print.get_object(obj_idx)->add_copy(Slic3r::to_2d(offset_vec));
|
||||
#else
|
||||
// p->print.get_object(*obj_idx)->add_copy(Slic3r::to_2d(offset_vec));
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
sidebar().obj_list()->increase_object_instances(obj_idx, num);
|
||||
#else
|
||||
sidebar().obj_list()->increase_object_instances(*obj_idx, num);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (p->get_config("autocenter") == "1") {
|
||||
p->arrange();
|
||||
|
@ -2270,9 +1966,7 @@ void Plater::increase_instances(size_t num)
|
|||
p->update();
|
||||
}
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
p->get_selection().add_instance(obj_idx, (int)model_object->instances.size() - 1);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
p->selection_changed();
|
||||
|
||||
|
@ -2281,47 +1975,26 @@ void Plater::increase_instances(size_t num)
|
|||
|
||||
void Plater::decrease_instances(size_t num)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
#else
|
||||
const auto obj_idx = p->selected_object();
|
||||
if (! obj_idx) { return; }
|
||||
|
||||
auto *model_object = p->model.objects[*obj_idx];
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
if (model_object->instances.size() > num) {
|
||||
for (size_t i = 0; i < num; i++) {
|
||||
model_object->delete_last_instance();
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
// p->print.get_object(obj_idx)->delete_last_copy();
|
||||
#else
|
||||
// p->print.get_object(*obj_idx)->delete_last_copy();
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
sidebar().obj_list()->decrease_object_instances(obj_idx, num);
|
||||
#else
|
||||
sidebar().obj_list()->decrease_object_instances(*obj_idx, num);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
else {
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
remove(obj_idx);
|
||||
#else
|
||||
remove(*obj_idx);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
}
|
||||
|
||||
p->update();
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (!model_object->instances.empty())
|
||||
p->get_selection().add_instance(obj_idx, (int)model_object->instances.size() - 1);
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
p->selection_changed();
|
||||
this->p->schedule_background_process();
|
||||
|
@ -2329,18 +2002,11 @@ void Plater::decrease_instances(size_t num)
|
|||
|
||||
void Plater::set_number_of_copies(/*size_t num*/)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
#else
|
||||
const auto obj_idx = p->selected_object();
|
||||
if (! obj_idx) { return; }
|
||||
|
||||
auto *model_object = p->model.objects[*obj_idx];
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
const auto num = wxGetNumberFromUser( " ", _("Enter the number of copies:"),
|
||||
_("Copies of the selected object"), model_object->instances.size(), 0, 1000, this );
|
||||
|
@ -2356,13 +2022,8 @@ void Plater::set_number_of_copies(/*size_t num*/)
|
|||
|
||||
void Plater::export_gcode(fs::path output_path)
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (p->model.objects.empty())
|
||||
return;
|
||||
#else
|
||||
if (p->objects.empty())
|
||||
return;
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
if (this->p->background_process.is_export_scheduled()) {
|
||||
GUI::show_error(this, _(L("Another export job is currently running.")));
|
||||
|
@ -2414,11 +2075,7 @@ void Plater::export_gcode(fs::path output_path)
|
|||
|
||||
void Plater::export_stl()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (p->model.objects.empty()) { return; }
|
||||
#else
|
||||
if (p->objects.empty()) { return; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
auto dialog = p->get_export_file(FT_STL);
|
||||
if (! dialog) { return; }
|
||||
|
@ -2433,11 +2090,7 @@ void Plater::export_stl()
|
|||
|
||||
void Plater::export_amf()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (p->model.objects.empty()) { return; }
|
||||
#else
|
||||
if (p->objects.empty()) { return; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
auto dialog = p->get_export_file(FT_AMF);
|
||||
if (! dialog) { return; }
|
||||
|
@ -2456,11 +2109,7 @@ void Plater::export_amf()
|
|||
|
||||
void Plater::export_3mf()
|
||||
{
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
if (p->model.objects.empty()) { return; }
|
||||
#else
|
||||
if (p->objects.empty()) { return; }
|
||||
#endif // ENABLE_EXTENDED_SELECTION
|
||||
|
||||
auto dialog = p->get_export_file(FT_3MF);
|
||||
if (! dialog) { return; }
|
||||
|
@ -2600,11 +2249,6 @@ void Plater::changed_object(int obj_idx)
|
|||
// update print
|
||||
if (list->is_parts_changed() || list->is_part_settings_changed()) {
|
||||
this->p->schedule_background_process();
|
||||
#if !ENABLE_EXTENDED_SELECTION
|
||||
if (p->canvas3D) _3DScene::reload_scene(p->canvas3D, true);
|
||||
auto selections = p->collect_selections();
|
||||
_3DScene::set_objects_selections(p->canvas3D, selections);
|
||||
#endif // !ENABLE_EXTENDED_SELECTION
|
||||
#if !ENABLE_MODIFIED_CAMERA_TARGET
|
||||
_3DScene::zoom_to_volumes(p->canvas3D);
|
||||
#endif // !ENABLE_MODIFIED_CAMERA_TARGET
|
||||
|
|
Loading…
Reference in a new issue