SLA support points (better backend->frontend synchronization and more)
- backend to frontend data synchronization to inform the gizmo that new points have been generated - fixed the inadvertent cancellation of background processing caused by the SLA gizmo touching frontend data during the process - inactive instances of the object are hidden when the SLA gizmo is active - fix of imgui combobox rendering
This commit is contained in:
parent
fb6f3d8431
commit
9fc75d7b34
6 changed files with 19 additions and 14 deletions
|
@ -4238,10 +4238,11 @@ void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible)
|
||||||
m_render_sla_auxiliaries = visible;
|
m_render_sla_auxiliaries = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::toggle_model_objects_visibility(bool visible, const ModelObject* mo)
|
void GLCanvas3D::toggle_model_objects_visibility(bool visible, const ModelObject* mo, int instance_idx)
|
||||||
{
|
{
|
||||||
for (GLVolume* vol : m_volumes.volumes) {
|
for (GLVolume* vol : m_volumes.volumes) {
|
||||||
if (mo == nullptr || m_model->objects[vol->composite_id.object_id] == mo)
|
if (mo == nullptr
|
||||||
|
| (m_model->objects[vol->composite_id.object_id] == mo && vol->composite_id.instance_id == instance_idx))
|
||||||
vol->is_active = visible;
|
vol->is_active = visible;
|
||||||
}
|
}
|
||||||
if (visible && !mo)
|
if (visible && !mo)
|
||||||
|
|
|
@ -952,7 +952,7 @@ public:
|
||||||
int check_volumes_outside_state() const;
|
int check_volumes_outside_state() const;
|
||||||
|
|
||||||
void toggle_sla_auxiliaries_visibility(bool visible);
|
void toggle_sla_auxiliaries_visibility(bool visible);
|
||||||
void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr);
|
void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
||||||
|
|
||||||
void set_config(const DynamicPrintConfig* config);
|
void set_config(const DynamicPrintConfig* config);
|
||||||
void set_process(BackgroundSlicingProcess* process);
|
void set_process(BackgroundSlicingProcess* process);
|
||||||
|
|
|
@ -1782,28 +1782,30 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const G
|
||||||
if (selection.is_empty())
|
if (selection.is_empty())
|
||||||
m_old_instance_id = -1;
|
m_old_instance_id = -1;
|
||||||
|
|
||||||
|
m_active_instance = selection.get_instance_idx();
|
||||||
|
|
||||||
if ((model_object != nullptr) && selection.is_from_single_instance())
|
if ((model_object != nullptr) && selection.is_from_single_instance())
|
||||||
{
|
{
|
||||||
if (is_mesh_update_necessary())
|
if (is_mesh_update_necessary())
|
||||||
update_mesh();
|
update_mesh();
|
||||||
|
|
||||||
// If there are no points, let's ask the backend if it calculated some.
|
// If there are no points, let's ask the backend if it calculated some.
|
||||||
if (model_object->sla_support_points.empty() && m_parent.sla_print()->is_step_done(slaposSupportPoints)) {
|
if (m_editing_mode_cache.empty() && m_parent.sla_print()->is_step_done(slaposSupportPoints)) {
|
||||||
for (const SLAPrintObject* po : m_parent.sla_print()->objects()) {
|
for (const SLAPrintObject* po : m_parent.sla_print()->objects()) {
|
||||||
if (po->model_object()->id() == model_object->id()) {
|
if (po->model_object()->id() == model_object->id()) {
|
||||||
const Eigen::MatrixXd& points = po->get_support_points();
|
const Eigen::MatrixXd& points = po->get_support_points();
|
||||||
for (unsigned int i=0; i<points.rows();++i)
|
for (unsigned int i=0; i<points.rows();++i)
|
||||||
model_object->sla_support_points.emplace_back(po->trafo().inverse().cast<float>() * Vec3f(points(i,0), points(i,1), points(i,2)),
|
m_editing_mode_cache.emplace_back(po->trafo().inverse().cast<float>() * Vec3f(points(i,0), points(i,1), points(i,2)),
|
||||||
points(i, 3), points(i, 4));
|
points(i, 3), points(i, 4));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_old_model_object != m_model_object)
|
if (m_model_object != m_old_model_object)
|
||||||
m_editing_mode_cache = m_model_object->sla_support_points; // make a copy of ModelObject's support points
|
m_editing_mode = false;
|
||||||
if (m_state == On) {
|
if (m_state == On) {
|
||||||
m_parent.toggle_model_objects_visibility(false);
|
m_parent.toggle_model_objects_visibility(false);
|
||||||
m_parent.toggle_model_objects_visibility(true, m_model_object);
|
m_parent.toggle_model_objects_visibility(true, m_model_object, m_active_instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2221,7 +2223,7 @@ void GLGizmoSlaSupports::on_set_state()
|
||||||
|
|
||||||
m_parent.toggle_model_objects_visibility(false);
|
m_parent.toggle_model_objects_visibility(false);
|
||||||
if (m_model_object)
|
if (m_model_object)
|
||||||
m_parent.toggle_model_objects_visibility(true, m_model_object);
|
m_parent.toggle_model_objects_visibility(true, m_model_object, m_active_instance);
|
||||||
}
|
}
|
||||||
if (m_state == Off)
|
if (m_state == Off)
|
||||||
m_parent.toggle_model_objects_visibility(true);
|
m_parent.toggle_model_objects_visibility(true);
|
||||||
|
|
|
@ -442,6 +442,7 @@ class GLGizmoSlaSupports : public GLGizmoBase
|
||||||
private:
|
private:
|
||||||
ModelObject* m_model_object = nullptr;
|
ModelObject* m_model_object = nullptr;
|
||||||
ModelObject* m_old_model_object = nullptr;
|
ModelObject* m_old_model_object = nullptr;
|
||||||
|
int m_active_instance = -1;
|
||||||
int m_old_instance_id = -1;
|
int m_old_instance_id = -1;
|
||||||
Vec3f unproject_on_mesh(const Vec2d& mouse_pos);
|
Vec3f unproject_on_mesh(const Vec2d& mouse_pos);
|
||||||
|
|
||||||
|
|
|
@ -170,17 +170,17 @@ void ImGuiWrapper::text(const wxString &label)
|
||||||
|
|
||||||
void ImGuiWrapper::combo(const wxString& label, const std::vector<wxString>& options, wxString& selection)
|
void ImGuiWrapper::combo(const wxString& label, const std::vector<wxString>& options, wxString& selection)
|
||||||
{
|
{
|
||||||
const char* selection_u8 = into_u8(selection).c_str();
|
std::string selection_u8 = into_u8(selection);
|
||||||
|
|
||||||
// this is to force the label to the left of the widget:
|
// this is to force the label to the left of the widget:
|
||||||
text(label);
|
text(label);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (ImGui::BeginCombo("", selection_u8)) {
|
if (ImGui::BeginCombo("", selection_u8.c_str())) {
|
||||||
for (const wxString& option : options) {
|
for (const wxString& option : options) {
|
||||||
const char* option_u8 = into_u8(option).c_str();
|
std::string option_u8 = into_u8(option);
|
||||||
bool is_selected = (selection_u8 == nullptr) ? false : strcmp(option_u8, selection_u8) == 0;
|
bool is_selected = (selection_u8.empty()) ? false : (option_u8 == selection_u8);
|
||||||
if (ImGui::Selectable(option_u8, is_selected))
|
if (ImGui::Selectable(option_u8.c_str(), is_selected))
|
||||||
selection = option_u8;
|
selection = option_u8;
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
|
|
|
@ -2231,6 +2231,7 @@ void Plater::priv::on_slicing_update(SlicingStatusEvent &evt)
|
||||||
}
|
}
|
||||||
if (evt.status.flags & PrintBase::SlicingStatus::RELOAD_SLA_SUPPORT_POINTS) {
|
if (evt.status.flags & PrintBase::SlicingStatus::RELOAD_SLA_SUPPORT_POINTS) {
|
||||||
// Update SLA gizmo
|
// Update SLA gizmo
|
||||||
|
q->canvas3D()->reload_scene(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue