Object updated by rotate gizmo
This commit is contained in:
parent
a3949b9f01
commit
b9ce19b07c
10 changed files with 180 additions and 36 deletions
|
@ -14,6 +14,7 @@ use Wx qw(:button :colour :cursor :dialog :filedialog :keycode :icon :font :id :
|
||||||
use Wx::Event qw(EVT_BUTTON EVT_TOGGLEBUTTON EVT_COMMAND EVT_KEY_DOWN EVT_LIST_ITEM_ACTIVATED
|
use Wx::Event qw(EVT_BUTTON EVT_TOGGLEBUTTON EVT_COMMAND EVT_KEY_DOWN EVT_LIST_ITEM_ACTIVATED
|
||||||
EVT_LIST_ITEM_DESELECTED EVT_LIST_ITEM_SELECTED EVT_LEFT_DOWN EVT_MOUSE_EVENTS EVT_PAINT EVT_TOOL
|
EVT_LIST_ITEM_DESELECTED EVT_LIST_ITEM_SELECTED EVT_LEFT_DOWN EVT_MOUSE_EVENTS EVT_PAINT EVT_TOOL
|
||||||
EVT_CHOICE EVT_COMBOBOX EVT_TIMER EVT_NOTEBOOK_PAGE_CHANGED);
|
EVT_CHOICE EVT_COMBOBOX EVT_TIMER EVT_NOTEBOOK_PAGE_CHANGED);
|
||||||
|
use Slic3r::Geometry qw(PI);
|
||||||
use base 'Wx::Panel';
|
use base 'Wx::Panel';
|
||||||
|
|
||||||
use constant TB_ADD => &Wx::NewId;
|
use constant TB_ADD => &Wx::NewId;
|
||||||
|
@ -134,6 +135,12 @@ sub new {
|
||||||
$self->schedule_background_process;
|
$self->schedule_background_process;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# callback to react to gizmo rotate
|
||||||
|
my $on_gizmo_rotate = sub {
|
||||||
|
my ($angle_z) = @_;
|
||||||
|
$self->rotate(rad2deg($angle_z), Z, 'absolute');
|
||||||
|
};
|
||||||
|
|
||||||
# Initialize 3D plater
|
# Initialize 3D plater
|
||||||
if ($Slic3r::GUI::have_OpenGL) {
|
if ($Slic3r::GUI::have_OpenGL) {
|
||||||
$self->{canvas3D} = Slic3r::GUI::Plater::3D->new($self->{preview_notebook}, $self->{objects}, $self->{model}, $self->{print}, $self->{config});
|
$self->{canvas3D} = Slic3r::GUI::Plater::3D->new($self->{preview_notebook}, $self->{objects}, $self->{model}, $self->{print}, $self->{config});
|
||||||
|
@ -151,6 +158,7 @@ sub new {
|
||||||
Slic3r::GUI::_3DScene::register_on_instance_moved_callback($self->{canvas3D}, $on_instances_moved);
|
Slic3r::GUI::_3DScene::register_on_instance_moved_callback($self->{canvas3D}, $on_instances_moved);
|
||||||
Slic3r::GUI::_3DScene::register_on_enable_action_buttons_callback($self->{canvas3D}, $enable_action_buttons);
|
Slic3r::GUI::_3DScene::register_on_enable_action_buttons_callback($self->{canvas3D}, $enable_action_buttons);
|
||||||
Slic3r::GUI::_3DScene::register_on_gizmo_scale_uniformly_callback($self->{canvas3D}, $on_gizmo_scale_uniformly);
|
Slic3r::GUI::_3DScene::register_on_gizmo_scale_uniformly_callback($self->{canvas3D}, $on_gizmo_scale_uniformly);
|
||||||
|
Slic3r::GUI::_3DScene::register_on_gizmo_rotate_callback($self->{canvas3D}, $on_gizmo_rotate);
|
||||||
Slic3r::GUI::_3DScene::enable_gizmos($self->{canvas3D}, 1);
|
Slic3r::GUI::_3DScene::enable_gizmos($self->{canvas3D}, 1);
|
||||||
Slic3r::GUI::_3DScene::enable_shader($self->{canvas3D}, 1);
|
Slic3r::GUI::_3DScene::enable_shader($self->{canvas3D}, 1);
|
||||||
Slic3r::GUI::_3DScene::enable_force_zoom_to_bed($self->{canvas3D}, 1);
|
Slic3r::GUI::_3DScene::enable_force_zoom_to_bed($self->{canvas3D}, 1);
|
||||||
|
@ -1060,7 +1068,17 @@ sub rotate {
|
||||||
|
|
||||||
if ($axis == Z) {
|
if ($axis == Z) {
|
||||||
my $new_angle = deg2rad($angle);
|
my $new_angle = deg2rad($angle);
|
||||||
$_->set_rotation(($relative ? $_->rotation : 0.) + $new_angle) for @{ $model_object->instances };
|
foreach my $inst (@{ $model_object->instances }) {
|
||||||
|
my $rotation = ($relative ? $inst->rotation : 0.) + $new_angle;
|
||||||
|
while ($rotation > 2.0 * PI) {
|
||||||
|
$rotation -= 2.0 * PI;
|
||||||
|
}
|
||||||
|
while ($rotation < 0.0) {
|
||||||
|
$rotation += 2.0 * PI;
|
||||||
|
}
|
||||||
|
$inst->set_rotation($rotation);
|
||||||
|
Slic3r::GUI::_3DScene::update_gizmos_data($self->{canvas3D}) if ($self->{canvas3D});
|
||||||
|
}
|
||||||
$object->transform_thumbnail($self->{model}, $obj_idx);
|
$object->transform_thumbnail($self->{model}, $obj_idx);
|
||||||
} else {
|
} else {
|
||||||
# rotation around X and Y needs to be performed on mesh
|
# rotation around X and Y needs to be performed on mesh
|
||||||
|
|
|
@ -1948,6 +1948,11 @@ void _3DScene::update_volumes_colors_by_extruder(wxGLCanvas* canvas)
|
||||||
s_canvas_mgr.update_volumes_colors_by_extruder(canvas);
|
s_canvas_mgr.update_volumes_colors_by_extruder(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _3DScene::update_gizmos_data(wxGLCanvas* canvas)
|
||||||
|
{
|
||||||
|
s_canvas_mgr.update_gizmos_data(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
void _3DScene::render(wxGLCanvas* canvas)
|
void _3DScene::render(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
s_canvas_mgr.render(canvas);
|
s_canvas_mgr.render(canvas);
|
||||||
|
@ -2043,6 +2048,11 @@ void _3DScene::register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, vo
|
||||||
s_canvas_mgr.register_on_gizmo_scale_uniformly_callback(canvas, callback);
|
s_canvas_mgr.register_on_gizmo_scale_uniformly_callback(canvas, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _3DScene::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback)
|
||||||
|
{
|
||||||
|
s_canvas_mgr.register_on_gizmo_rotate_callback(canvas, callback);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int hex_digit_to_int(const char c)
|
static inline int hex_digit_to_int(const char c)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
|
|
@ -568,6 +568,7 @@ public:
|
||||||
static void set_viewport_from_scene(wxGLCanvas* canvas, wxGLCanvas* other);
|
static void set_viewport_from_scene(wxGLCanvas* canvas, wxGLCanvas* other);
|
||||||
|
|
||||||
static void update_volumes_colors_by_extruder(wxGLCanvas* canvas);
|
static void update_volumes_colors_by_extruder(wxGLCanvas* canvas);
|
||||||
|
static void update_gizmos_data(wxGLCanvas* canvas);
|
||||||
|
|
||||||
static void render(wxGLCanvas* canvas);
|
static void render(wxGLCanvas* canvas);
|
||||||
|
|
||||||
|
@ -590,6 +591,7 @@ public:
|
||||||
static void register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback);
|
static void register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback);
|
||||||
static void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
static void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
||||||
static void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
static void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
||||||
|
static void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
||||||
|
|
||||||
static std::vector<int> load_object(wxGLCanvas* canvas, const ModelObject* model_object, int obj_idx, std::vector<int> instance_idxs);
|
static std::vector<int> load_object(wxGLCanvas* canvas, const ModelObject* model_object, int obj_idx, std::vector<int> instance_idxs);
|
||||||
static std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
|
static std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
|
||||||
|
|
|
@ -1263,14 +1263,9 @@ void GLCanvas3D::Gizmos::update(const Pointf& mouse_pos)
|
||||||
curr->update(mouse_pos);
|
curr->update(mouse_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::Gizmos::update_data(float scale)
|
GLCanvas3D::Gizmos::EType GLCanvas3D::Gizmos::get_current_type() const
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
return m_current;
|
||||||
return;
|
|
||||||
|
|
||||||
GizmosMap::const_iterator it = m_gizmos.find(Scale);
|
|
||||||
if (it != m_gizmos.end())
|
|
||||||
reinterpret_cast<GLGizmoScale*>(it->second)->set_scale(scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3D::Gizmos::is_running() const
|
bool GLCanvas3D::Gizmos::is_running() const
|
||||||
|
@ -1309,6 +1304,35 @@ float GLCanvas3D::Gizmos::get_scale() const
|
||||||
return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoScale*>(it->second)->get_scale() : 1.0f;
|
return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoScale*>(it->second)->get_scale() : 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::Gizmos::set_scale(float scale)
|
||||||
|
{
|
||||||
|
if (!m_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GizmosMap::const_iterator it = m_gizmos.find(Scale);
|
||||||
|
if (it != m_gizmos.end())
|
||||||
|
reinterpret_cast<GLGizmoScale*>(it->second)->set_scale(scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
float GLCanvas3D::Gizmos::get_angle_z() const
|
||||||
|
{
|
||||||
|
if (!m_enabled)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
GizmosMap::const_iterator it = m_gizmos.find(Rotate);
|
||||||
|
return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoRotate*>(it->second)->get_angle_z() : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::Gizmos::set_angle_z(float angle_z)
|
||||||
|
{
|
||||||
|
if (!m_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GizmosMap::const_iterator it = m_gizmos.find(Rotate);
|
||||||
|
if (it != m_gizmos.end())
|
||||||
|
reinterpret_cast<GLGizmoRotate*>(it->second)->set_angle_z(angle_z);
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::Gizmos::render(const GLCanvas3D& canvas, const BoundingBoxf3& box) const
|
void GLCanvas3D::Gizmos::render(const GLCanvas3D& canvas, const BoundingBoxf3& box) const
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
|
@ -1823,6 +1847,38 @@ void GLCanvas3D::update_volumes_colors_by_extruder()
|
||||||
m_volumes.update_colors_by_extruder(m_config);
|
m_volumes.update_colors_by_extruder(m_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::update_gizmos_data()
|
||||||
|
{
|
||||||
|
if (!m_gizmos.is_running())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int id = _get_first_selected_object_id();
|
||||||
|
if ((id != -1) && (m_model != nullptr))
|
||||||
|
{
|
||||||
|
ModelObject* model_object = m_model->objects[id];
|
||||||
|
if (model_object != nullptr)
|
||||||
|
{
|
||||||
|
ModelInstance* model_instance = model_object->instances[0];
|
||||||
|
if (model_instance != nullptr)
|
||||||
|
{
|
||||||
|
switch (m_gizmos.get_current_type())
|
||||||
|
{
|
||||||
|
case Gizmos::Scale:
|
||||||
|
{
|
||||||
|
m_gizmos.set_scale(model_instance->scaling_factor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Gizmos::Rotate:
|
||||||
|
{
|
||||||
|
m_gizmos.set_angle_z(model_instance->rotation);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::render()
|
void GLCanvas3D::render()
|
||||||
{
|
{
|
||||||
if (m_canvas == nullptr)
|
if (m_canvas == nullptr)
|
||||||
|
@ -1930,6 +1986,7 @@ void GLCanvas3D::reload_scene(bool force)
|
||||||
m_objects_volumes_idxs.push_back(load_object(*m_model, obj_idx));
|
m_objects_volumes_idxs.push_back(load_object(*m_model, obj_idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_gizmos_data();
|
||||||
update_volumes_selection(m_objects_selections);
|
update_volumes_selection(m_objects_selections);
|
||||||
|
|
||||||
if (m_config->has("nozzle_diameter"))
|
if (m_config->has("nozzle_diameter"))
|
||||||
|
@ -2477,6 +2534,12 @@ void GLCanvas3D::register_on_gizmo_scale_uniformly_callback(void* callback)
|
||||||
m_on_gizmo_scale_uniformly_callback.register_callback(callback);
|
m_on_gizmo_scale_uniformly_callback.register_callback(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::register_on_gizmo_rotate_callback(void* callback)
|
||||||
|
{
|
||||||
|
if (callback != nullptr)
|
||||||
|
m_on_gizmo_rotate_callback.register_callback(callback);
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::bind_event_handlers()
|
void GLCanvas3D::bind_event_handlers()
|
||||||
{
|
{
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
|
@ -2694,13 +2757,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
}
|
}
|
||||||
else if ((selected_object_idx != -1) && gizmos_overlay_contains_mouse)
|
else if ((selected_object_idx != -1) && gizmos_overlay_contains_mouse)
|
||||||
{
|
{
|
||||||
|
update_gizmos_data();
|
||||||
m_gizmos.update_on_off_state(*this, m_mouse.position);
|
m_gizmos.update_on_off_state(*this, m_mouse.position);
|
||||||
_update_gizmos_data();
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
else if ((selected_object_idx != -1) && m_gizmos.grabber_contains_mouse())
|
else if ((selected_object_idx != -1) && m_gizmos.grabber_contains_mouse())
|
||||||
{
|
{
|
||||||
_update_gizmos_data();
|
update_gizmos_data();
|
||||||
m_gizmos.start_dragging();
|
m_gizmos.start_dragging();
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
@ -2726,9 +2789,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_gizmos.is_running())
|
update_gizmos_data();
|
||||||
_update_gizmos_data();
|
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2821,7 +2882,21 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
const Pointf3& cur_pos = _mouse_to_bed_3d(pos);
|
const Pointf3& cur_pos = _mouse_to_bed_3d(pos);
|
||||||
m_gizmos.update(Pointf(cur_pos.x, cur_pos.y));
|
m_gizmos.update(Pointf(cur_pos.x, cur_pos.y));
|
||||||
|
|
||||||
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
|
switch (m_gizmos.get_current_type())
|
||||||
|
{
|
||||||
|
case Gizmos::Scale:
|
||||||
|
{
|
||||||
|
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Gizmos::Rotate:
|
||||||
|
{
|
||||||
|
m_on_gizmo_rotate_callback.call((double)m_gizmos.get_angle_z());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
else if (evt.Dragging() && !gizmos_overlay_contains_mouse)
|
else if (evt.Dragging() && !gizmos_overlay_contains_mouse)
|
||||||
|
@ -3164,6 +3239,7 @@ void GLCanvas3D::_deregister_callbacks()
|
||||||
m_on_wipe_tower_moved_callback.deregister_callback();
|
m_on_wipe_tower_moved_callback.deregister_callback();
|
||||||
m_on_enable_action_buttons_callback.deregister_callback();
|
m_on_enable_action_buttons_callback.deregister_callback();
|
||||||
m_on_gizmo_scale_uniformly_callback.deregister_callback();
|
m_on_gizmo_scale_uniformly_callback.deregister_callback();
|
||||||
|
m_on_gizmo_rotate_callback.deregister_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_mark_volumes_for_layer_height() const
|
void GLCanvas3D::_mark_volumes_for_layer_height() const
|
||||||
|
@ -4264,21 +4340,6 @@ void GLCanvas3D::_on_select(int volume_idx)
|
||||||
m_on_select_object_callback.call(id);
|
m_on_select_object_callback.call(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_update_gizmos_data()
|
|
||||||
{
|
|
||||||
int id = _get_first_selected_object_id();
|
|
||||||
if ((id != -1) && (m_model != nullptr))
|
|
||||||
{
|
|
||||||
ModelObject* model_object = m_model->objects[id];
|
|
||||||
if (model_object != nullptr)
|
|
||||||
{
|
|
||||||
ModelInstance* model_instance = model_object->instances[0];
|
|
||||||
if (model_instance != nullptr)
|
|
||||||
m_gizmos.update_data(model_instance->scaling_factor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<float> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors)
|
std::vector<float> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors)
|
||||||
{
|
{
|
||||||
static const float INV_255 = 1.0f / 255.0f;
|
static const float INV_255 = 1.0f / 255.0f;
|
||||||
|
|
|
@ -360,14 +360,20 @@ public:
|
||||||
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Pointf& mouse_pos) const;
|
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Pointf& mouse_pos) const;
|
||||||
bool grabber_contains_mouse() const;
|
bool grabber_contains_mouse() const;
|
||||||
void update(const Pointf& mouse_pos);
|
void update(const Pointf& mouse_pos);
|
||||||
void update_data(float scale);
|
|
||||||
|
EType get_current_type() const;
|
||||||
|
|
||||||
bool is_running() const;
|
bool is_running() const;
|
||||||
|
|
||||||
bool is_dragging() const;
|
bool is_dragging() const;
|
||||||
void start_dragging();
|
void start_dragging();
|
||||||
void stop_dragging();
|
void stop_dragging();
|
||||||
|
|
||||||
float get_scale() const;
|
float get_scale() const;
|
||||||
|
void set_scale(float scale);
|
||||||
|
|
||||||
|
float get_angle_z() const;
|
||||||
|
void set_angle_z(float angle_z);
|
||||||
|
|
||||||
void render(const GLCanvas3D& canvas, const BoundingBoxf3& box) const;
|
void render(const GLCanvas3D& canvas, const BoundingBoxf3& box) const;
|
||||||
void render_current_gizmo_for_picking_pass(const BoundingBoxf3& box) const;
|
void render_current_gizmo_for_picking_pass(const BoundingBoxf3& box) const;
|
||||||
|
@ -442,6 +448,7 @@ private:
|
||||||
PerlCallback m_on_wipe_tower_moved_callback;
|
PerlCallback m_on_wipe_tower_moved_callback;
|
||||||
PerlCallback m_on_enable_action_buttons_callback;
|
PerlCallback m_on_enable_action_buttons_callback;
|
||||||
PerlCallback m_on_gizmo_scale_uniformly_callback;
|
PerlCallback m_on_gizmo_scale_uniformly_callback;
|
||||||
|
PerlCallback m_on_gizmo_rotate_callback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
|
GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
|
||||||
|
@ -510,6 +517,7 @@ public:
|
||||||
void set_viewport_from_scene(const GLCanvas3D& other);
|
void set_viewport_from_scene(const GLCanvas3D& other);
|
||||||
|
|
||||||
void update_volumes_colors_by_extruder();
|
void update_volumes_colors_by_extruder();
|
||||||
|
void update_gizmos_data();
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
@ -548,6 +556,7 @@ public:
|
||||||
void register_on_wipe_tower_moved_callback(void* callback);
|
void register_on_wipe_tower_moved_callback(void* callback);
|
||||||
void register_on_enable_action_buttons_callback(void* callback);
|
void register_on_enable_action_buttons_callback(void* callback);
|
||||||
void register_on_gizmo_scale_uniformly_callback(void* callback);
|
void register_on_gizmo_scale_uniformly_callback(void* callback);
|
||||||
|
void register_on_gizmo_rotate_callback(void* callback);
|
||||||
|
|
||||||
void bind_event_handlers();
|
void bind_event_handlers();
|
||||||
void unbind_event_handlers();
|
void unbind_event_handlers();
|
||||||
|
@ -628,8 +637,6 @@ private:
|
||||||
void _on_move(const std::vector<int>& volume_idxs);
|
void _on_move(const std::vector<int>& volume_idxs);
|
||||||
void _on_select(int volume_idx);
|
void _on_select(int volume_idx);
|
||||||
|
|
||||||
void _update_gizmos_data();
|
|
||||||
|
|
||||||
static std::vector<float> _parse_colors(const std::vector<std::string>& colors);
|
static std::vector<float> _parse_colors(const std::vector<std::string>& colors);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -494,6 +494,13 @@ void GLCanvas3DManager::update_volumes_colors_by_extruder(wxGLCanvas* canvas)
|
||||||
it->second->update_volumes_colors_by_extruder();
|
it->second->update_volumes_colors_by_extruder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3DManager::update_gizmos_data(wxGLCanvas* canvas)
|
||||||
|
{
|
||||||
|
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||||
|
if (it != m_canvases.end())
|
||||||
|
it->second->update_gizmos_data();
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3DManager::render(wxGLCanvas* canvas) const
|
void GLCanvas3DManager::render(wxGLCanvas* canvas) const
|
||||||
{
|
{
|
||||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||||
|
@ -685,6 +692,13 @@ void GLCanvas3DManager::register_on_gizmo_scale_uniformly_callback(wxGLCanvas* c
|
||||||
it->second->register_on_gizmo_scale_uniformly_callback(callback);
|
it->second->register_on_gizmo_scale_uniformly_callback(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3DManager::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback)
|
||||||
|
{
|
||||||
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
if (it != m_canvases.end())
|
||||||
|
it->second->register_on_gizmo_rotate_callback(callback);
|
||||||
|
}
|
||||||
|
|
||||||
GLCanvas3DManager::CanvasesMap::iterator GLCanvas3DManager::_get_canvas(wxGLCanvas* canvas)
|
GLCanvas3DManager::CanvasesMap::iterator GLCanvas3DManager::_get_canvas(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
return (canvas == nullptr) ? m_canvases.end() : m_canvases.find(canvas);
|
return (canvas == nullptr) ? m_canvases.end() : m_canvases.find(canvas);
|
||||||
|
|
|
@ -121,6 +121,7 @@ public:
|
||||||
void set_viewport_from_scene(wxGLCanvas* canvas, wxGLCanvas* other);
|
void set_viewport_from_scene(wxGLCanvas* canvas, wxGLCanvas* other);
|
||||||
|
|
||||||
void update_volumes_colors_by_extruder(wxGLCanvas* canvas);
|
void update_volumes_colors_by_extruder(wxGLCanvas* canvas);
|
||||||
|
void update_gizmos_data(wxGLCanvas* canvas);
|
||||||
|
|
||||||
void render(wxGLCanvas* canvas) const;
|
void render(wxGLCanvas* canvas) const;
|
||||||
|
|
||||||
|
@ -153,6 +154,7 @@ public:
|
||||||
void register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback);
|
void register_on_wipe_tower_moved_callback(wxGLCanvas* canvas, void* callback);
|
||||||
void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
||||||
void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
||||||
|
void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas);
|
CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas);
|
||||||
|
|
|
@ -140,7 +140,7 @@ void GLGizmoBase::on_start_dragging()
|
||||||
|
|
||||||
void GLGizmoBase::render_grabbers() const
|
void GLGizmoBase::render_grabbers() const
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i)
|
for (int i = 0; i < (int)m_grabbers.size(); ++i)
|
||||||
{
|
{
|
||||||
m_grabbers[i].render(m_hover_id == i);
|
m_grabbers[i].render(m_hover_id == i);
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,19 @@ GLGizmoRotate::GLGizmoRotate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GLGizmoRotate::get_angle_z() const
|
||||||
|
{
|
||||||
|
return m_angle_z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLGizmoRotate::set_angle_z(float angle_z)
|
||||||
|
{
|
||||||
|
if (std::abs(angle_z - 2.0f * PI) < EPSILON)
|
||||||
|
angle_z = 0.0f;
|
||||||
|
|
||||||
|
m_angle_z = angle_z;
|
||||||
|
}
|
||||||
|
|
||||||
bool GLGizmoRotate::on_init()
|
bool GLGizmoRotate::on_init()
|
||||||
{
|
{
|
||||||
std::string path = resources_dir() + "/icons/overlay/";
|
std::string path = resources_dir() + "/icons/overlay/";
|
||||||
|
@ -194,6 +207,7 @@ void GLGizmoRotate::on_update(const Pointf& mouse_pos)
|
||||||
if (cross(orig_dir, new_dir) < 0.0)
|
if (cross(orig_dir, new_dir) < 0.0)
|
||||||
theta = 2.0 * (coordf_t)PI - theta;
|
theta = 2.0 * (coordf_t)PI - theta;
|
||||||
|
|
||||||
|
// snap
|
||||||
if (length(m_center.vector_to(mouse_pos)) < 2.0 * (double)m_radius / 3.0)
|
if (length(m_center.vector_to(mouse_pos)) < 2.0 * (double)m_radius / 3.0)
|
||||||
{
|
{
|
||||||
coordf_t step = 2.0 * (coordf_t)PI / (coordf_t)SnapRegionsCount;
|
coordf_t step = 2.0 * (coordf_t)PI / (coordf_t)SnapRegionsCount;
|
||||||
|
@ -202,7 +216,7 @@ void GLGizmoRotate::on_update(const Pointf& mouse_pos)
|
||||||
|
|
||||||
if (theta == 2.0 * (coordf_t)PI)
|
if (theta == 2.0 * (coordf_t)PI)
|
||||||
theta = 0.0;
|
theta = 0.0;
|
||||||
|
|
||||||
m_angle_z = (float)theta;
|
m_angle_z = (float)theta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,9 @@ class GLGizmoRotate : public GLGizmoBase
|
||||||
public:
|
public:
|
||||||
GLGizmoRotate();
|
GLGizmoRotate();
|
||||||
|
|
||||||
|
float get_angle_z() const;
|
||||||
|
void set_angle_z(float angle_z);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_init();
|
virtual bool on_init();
|
||||||
virtual void on_update(const Pointf& mouse_pos);
|
virtual void on_update(const Pointf& mouse_pos);
|
||||||
|
@ -120,9 +123,9 @@ class GLGizmoScale : public GLGizmoBase
|
||||||
static const float Offset;
|
static const float Offset;
|
||||||
|
|
||||||
float m_scale;
|
float m_scale;
|
||||||
|
float m_starting_scale;
|
||||||
|
|
||||||
Pointf m_starting_drag_position;
|
Pointf m_starting_drag_position;
|
||||||
float m_starting_scale;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLGizmoScale();
|
GLGizmoScale();
|
||||||
|
|
|
@ -470,6 +470,12 @@ update_volumes_colors_by_extruder(canvas)
|
||||||
CODE:
|
CODE:
|
||||||
_3DScene::update_volumes_colors_by_extruder((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
_3DScene::update_volumes_colors_by_extruder((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||||
|
|
||||||
|
void
|
||||||
|
update_gizmos_data(canvas)
|
||||||
|
SV *canvas;
|
||||||
|
CODE:
|
||||||
|
_3DScene::update_gizmos_data((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||||
|
|
||||||
void
|
void
|
||||||
render(canvas)
|
render(canvas)
|
||||||
SV *canvas;
|
SV *canvas;
|
||||||
|
@ -605,6 +611,13 @@ register_on_gizmo_scale_uniformly_callback(canvas, callback)
|
||||||
CODE:
|
CODE:
|
||||||
_3DScene::register_on_gizmo_scale_uniformly_callback((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), (void*)callback);
|
_3DScene::register_on_gizmo_scale_uniformly_callback((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), (void*)callback);
|
||||||
|
|
||||||
|
void
|
||||||
|
register_on_gizmo_rotate_callback(canvas, callback)
|
||||||
|
SV *canvas;
|
||||||
|
SV *callback;
|
||||||
|
CODE:
|
||||||
|
_3DScene::register_on_gizmo_rotate_callback((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), (void*)callback);
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
finalize_legend_texture()
|
finalize_legend_texture()
|
||||||
CODE:
|
CODE:
|
||||||
|
|
Loading…
Reference in a new issue