WIP: Duplicated the SLA gizmo for the FDM, removed what was not needed

Clipping plane and the m_model_object pointer keeping was duplicated
This commit is contained in:
Lukas Matena 2019-09-20 12:42:08 +02:00
parent a48a79603c
commit 7afe7326b6
8 changed files with 548 additions and 13 deletions

View file

@ -94,11 +94,13 @@ bool GLGizmosManager::init()
m_gizmos.emplace_back(new GLGizmoCut(m_parent, "cut.svg", 4));
m_gizmos.emplace_back(new GLGizmoHollow(m_parent, "hollow.svg", 5));
m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", 6));
m_gizmos.emplace_back(new GLGizmoFdmSupports(m_parent, "sla_supports.svg", 7));
m_common_gizmos_data.reset(new CommonGizmosData());
dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get())->set_common_data_ptr(m_common_gizmos_data.get());
dynamic_cast<GLGizmoSlaSupports*>(m_gizmos[SlaSupports].get())->set_common_data_ptr(m_common_gizmos_data.get());
for (auto& gizmo : m_gizmos) {
if (! gizmo->init()) {
m_gizmos.clear();
@ -204,6 +206,7 @@ void GLGizmosManager::update_data()
ModelObject* model_object = selection.get_model()->objects[selection.get_object_idx()];
set_flattening_data(model_object);
set_sla_support_data(model_object);
set_fdm_support_data(model_object);
}
else if (selection.is_single_volume() || selection.is_single_modifier())
{
@ -212,6 +215,7 @@ void GLGizmosManager::update_data()
set_rotation(Vec3d::Zero());
set_flattening_data(nullptr);
set_sla_support_data(nullptr);
set_fdm_support_data(nullptr);
}
else if (is_wipe_tower)
{
@ -220,6 +224,7 @@ void GLGizmosManager::update_data()
set_rotation(Vec3d(0., 0., (M_PI/180.) * dynamic_cast<const ConfigOptionFloat*>(config.option("wipe_tower_rotation_angle"))->value));
set_flattening_data(nullptr);
set_sla_support_data(nullptr);
set_fdm_support_data(nullptr);
}
else
{
@ -227,6 +232,7 @@ void GLGizmosManager::update_data()
set_rotation(Vec3d::Zero());
set_flattening_data(selection.is_from_single_object() ? selection.get_model()->objects[selection.get_object_idx()] : nullptr);
set_sla_support_data(nullptr);
set_fdm_support_data(nullptr);
}
}
@ -366,6 +372,14 @@ void GLGizmosManager::set_sla_support_data(ModelObject* model_object)
gizmo_hollow->set_sla_support_data(model_object, m_parent.get_selection());
}
void GLGizmosManager::set_fdm_support_data(ModelObject* model_object)
{
if (!m_enabled || m_gizmos.empty())
return;
dynamic_cast<GLGizmoFdmSupports*>(m_gizmos[FdmSupports].get())->set_fdm_support_data(model_object, m_parent.get_selection());
}
// Returns true if the gizmo used the event to do something, false otherwise.
bool GLGizmosManager::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down)
{
@ -379,15 +393,17 @@ bool GLGizmosManager::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_p
return false;
}
ClippingPlane GLGizmosManager::get_sla_clipping_plane() const
ClippingPlane GLGizmosManager::get_clipping_plane() const
{
if (!m_enabled || (m_current != SlaSupports && m_current != Hollow) || m_gizmos.empty())
if (!m_enabled || (m_current != SlaSupports && m_current != Hollow && m_current != FdmSupports) || m_gizmos.empty())
return ClippingPlane::ClipsNothing();
if (m_current == SlaSupports)
return dynamic_cast<GLGizmoSlaSupports*>(m_gizmos[SlaSupports].get())->get_sla_clipping_plane();
else
else if (m_current == Hollow)
return dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get())->get_sla_clipping_plane();
else
return dynamic_cast<GLGizmoFdmSupports*>(m_gizmos[FdmSupports].get())->get_fdm_clipping_plane();
}
bool GLGizmosManager::wants_reslice_supports_on_undo() const
@ -407,6 +423,7 @@ void GLGizmosManager::render_current_gizmo() const
void GLGizmosManager::render_current_gizmo_for_picking_pass() const
{
if (! m_enabled || m_current == Undefined)
return;
m_gizmos[m_current]->render_for_picking();