void GLCanvas3D::update_gizmos_data() moved into void GLGizmosManager::update_data(GLCanvas3D& canvas)
This commit is contained in:
parent
47c39f51e5
commit
fee0a6b6b5
4 changed files with 54 additions and 51 deletions
|
@ -2015,7 +2015,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
m_selection.volumes_changed(map_glvolume_old_to_new);
|
||||
}
|
||||
|
||||
update_gizmos_data();
|
||||
m_gizmos.update_data(*this);
|
||||
|
||||
// Update the toolbar
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
|
||||
|
@ -2604,7 +2604,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
if (curr_idxs != m_selection.get_volume_idxs())
|
||||
{
|
||||
m_gizmos.refresh_on_off_state(m_selection);
|
||||
update_gizmos_data();
|
||||
m_gizmos.update_data(*this);
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
|
||||
m_dirty = true;
|
||||
}
|
||||
|
@ -2748,7 +2748,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
m_selection.set_mode(Selection::Instance);
|
||||
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
||||
m_gizmos.reset_all_states();
|
||||
update_gizmos_data();
|
||||
m_gizmos.update_data(*this);
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
|
||||
}
|
||||
}
|
||||
|
@ -2769,7 +2769,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
m_selection.add(m_hover_volume_id);
|
||||
m_gizmos.refresh_on_off_state(m_selection);
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
|
||||
update_gizmos_data();
|
||||
m_gizmos.update_data(*this);
|
||||
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
||||
// forces a frame render to update the view before the context menu is shown
|
||||
render();
|
||||
|
@ -3113,7 +3113,7 @@ void GLCanvas3D::set_camera_zoom(float zoom)
|
|||
void GLCanvas3D::update_gizmos_on_off_state()
|
||||
{
|
||||
set_as_dirty();
|
||||
update_gizmos_data();
|
||||
m_gizmos.update_data(*this);
|
||||
m_gizmos.refresh_on_off_state(get_selection());
|
||||
}
|
||||
|
||||
|
@ -3148,46 +3148,6 @@ void GLCanvas3D::update_ui_from_settings()
|
|||
#endif
|
||||
}
|
||||
|
||||
void GLCanvas3D::update_gizmos_data()
|
||||
{
|
||||
if (!m_gizmos.is_enabled())
|
||||
return;
|
||||
|
||||
bool enable_move_z = !m_selection.is_wipe_tower();
|
||||
m_gizmos.enable_grabber(GLGizmosManager::Move, 2, enable_move_z);
|
||||
bool enable_scale_xyz = m_selection.is_single_full_instance() || m_selection.is_single_volume() || m_selection.is_single_modifier();
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
m_gizmos.enable_grabber(GLGizmosManager::Scale, i, enable_scale_xyz);
|
||||
}
|
||||
|
||||
if (m_selection.is_single_full_instance())
|
||||
{
|
||||
// all volumes in the selection belongs to the same instance, any of them contains the needed data, so we take the first
|
||||
const GLVolume* volume = m_volumes.volumes[*m_selection.get_volume_idxs().begin()];
|
||||
m_gizmos.set_scale(volume->get_instance_scaling_factor());
|
||||
m_gizmos.set_rotation(Vec3d::Zero());
|
||||
ModelObject* model_object = m_model->objects[m_selection.get_object_idx()];
|
||||
m_gizmos.set_flattening_data(model_object);
|
||||
m_gizmos.set_sla_support_data(model_object, m_selection);
|
||||
}
|
||||
else if (m_selection.is_single_volume() || m_selection.is_single_modifier())
|
||||
{
|
||||
const GLVolume* volume = m_volumes.volumes[*m_selection.get_volume_idxs().begin()];
|
||||
m_gizmos.set_scale(volume->get_volume_scaling_factor());
|
||||
m_gizmos.set_rotation(Vec3d::Zero());
|
||||
m_gizmos.set_flattening_data(nullptr);
|
||||
m_gizmos.set_sla_support_data(nullptr, m_selection);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gizmos.set_scale(Vec3d::Ones());
|
||||
m_gizmos.set_rotation(Vec3d::Zero());
|
||||
m_gizmos.set_flattening_data(m_selection.is_from_single_object() ? m_model->objects[m_selection.get_object_idx()] : nullptr);
|
||||
m_gizmos.set_sla_support_data(nullptr, m_selection);
|
||||
}
|
||||
}
|
||||
|
||||
Linef3 GLCanvas3D::mouse_ray(const Point& mouse_pos)
|
||||
{
|
||||
float z0 = 0.0f;
|
||||
|
|
|
@ -464,6 +464,7 @@ public:
|
|||
void set_config(const DynamicPrintConfig* config);
|
||||
void set_process(BackgroundSlicingProcess* process);
|
||||
void set_model(Model* model);
|
||||
Model* get_model() { return m_model; }
|
||||
|
||||
const Selection& get_selection() const { return m_selection; }
|
||||
Selection& get_selection() { return m_selection; }
|
||||
|
@ -564,8 +565,6 @@ public:
|
|||
|
||||
float get_view_toolbar_height() const { return m_view_toolbar.get_height(); }
|
||||
|
||||
void update_gizmos_data();
|
||||
|
||||
int get_move_volume_id() const { return m_mouse.drag.move_volume_idx; }
|
||||
|
||||
// Returns the view ray line, in world coordinate, at the given mouse position.
|
||||
|
|
|
@ -257,6 +257,48 @@ void GLGizmosManager::update(const Linef3& mouse_ray, const Selection& selection
|
|||
curr->update(GLGizmoBase::UpdateData(mouse_ray, mouse_pos, shift_down), selection);
|
||||
}
|
||||
|
||||
void GLGizmosManager::update_data(GLCanvas3D& canvas)
|
||||
{
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
||||
const Selection& selection = canvas.get_selection();
|
||||
|
||||
bool enable_move_z = !selection.is_wipe_tower();
|
||||
enable_grabber(Move, 2, enable_move_z);
|
||||
bool enable_scale_xyz = selection.is_single_full_instance() || selection.is_single_volume() || selection.is_single_modifier();
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
enable_grabber(Scale, i, enable_scale_xyz);
|
||||
}
|
||||
|
||||
if (selection.is_single_full_instance())
|
||||
{
|
||||
// all volumes in the selection belongs to the same instance, any of them contains the needed data, so we take the first
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
set_scale(volume->get_instance_scaling_factor());
|
||||
set_rotation(Vec3d::Zero());
|
||||
ModelObject* model_object = canvas.get_model()->objects[selection.get_object_idx()];
|
||||
set_flattening_data(model_object);
|
||||
set_sla_support_data(model_object, selection);
|
||||
}
|
||||
else if (selection.is_single_volume() || selection.is_single_modifier())
|
||||
{
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
set_scale(volume->get_volume_scaling_factor());
|
||||
set_rotation(Vec3d::Zero());
|
||||
set_flattening_data(nullptr);
|
||||
set_sla_support_data(nullptr, selection);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_scale(Vec3d::Ones());
|
||||
set_rotation(Vec3d::Zero());
|
||||
set_flattening_data(selection.is_from_single_object() ? canvas.get_model()->objects[selection.get_object_idx()] : nullptr);
|
||||
set_sla_support_data(nullptr, selection);
|
||||
}
|
||||
}
|
||||
|
||||
bool GLGizmosManager::is_running() const
|
||||
{
|
||||
if (!m_enabled)
|
||||
|
@ -509,7 +551,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas)
|
|||
processed = true;
|
||||
else if (!selection.is_empty() && grabber_contains_mouse())
|
||||
{
|
||||
canvas.update_gizmos_data();
|
||||
update_data(canvas);
|
||||
selection.start_dragging();
|
||||
start_dragging(selection);
|
||||
|
||||
|
@ -603,7 +645,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas)
|
|||
}
|
||||
|
||||
stop_dragging();
|
||||
canvas.update_gizmos_data();
|
||||
update_data(canvas);
|
||||
|
||||
wxGetApp().obj_manipul()->update_settings_value(selection);
|
||||
// Let the platter know that the dragging finished, so a delayed refresh
|
||||
|
@ -633,7 +675,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas)
|
|||
if (!selection.is_empty())
|
||||
{
|
||||
update_on_off_state(canvas, mouse_pos, selection);
|
||||
canvas.update_gizmos_data();
|
||||
update_data(canvas);
|
||||
canvas.set_as_dirty();
|
||||
}
|
||||
}
|
||||
|
@ -733,7 +775,7 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas)
|
|||
{
|
||||
if (handle_shortcut(keyCode, canvas.get_selection()))
|
||||
{
|
||||
canvas.update_gizmos_data();
|
||||
update_data(canvas);
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,6 +120,8 @@ public:
|
|||
void enable_grabber(EType type, unsigned int id, bool enable);
|
||||
|
||||
void update(const Linef3& mouse_ray, const Selection& selection, bool shift_down, const Point* mouse_pos = nullptr);
|
||||
void update_data(GLCanvas3D& canvas);
|
||||
|
||||
Rect get_reset_rect_viewport(const GLCanvas3D& canvas) const;
|
||||
EType get_current_type() const { return m_current; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue