Merge branch 'master' into fs_QuadricEdgeCollapse

This commit is contained in:
Filip Sykala 2021-08-18 10:37:21 +02:00
commit cc88b1e86b
18 changed files with 269 additions and 137 deletions

View file

@ -55,8 +55,15 @@ std::string GLGizmoCut::on_get_name() const
void GLGizmoCut::on_set_state()
{
// Reset m_cut_z on gizmo activation
#if ENABLE_SINKING_CONTOURS
if (get_state() == On) {
m_cut_z = bounding_box().center().z();
m_cut_contours.reset();
}
#else
if (get_state() == On)
m_cut_z = bounding_box().center().z();
#endif // ENABLE_SINKING_CONTOURS
}
bool GLGizmoCut::on_is_activable() const
@ -209,8 +216,12 @@ void GLGizmoCut::on_render_input_window(float x, float y, float bottom_limit)
m_imgui->end();
if (cut_clicked && (m_keep_upper || m_keep_lower))
if (cut_clicked && (m_keep_upper || m_keep_lower)) {
perform_cut(m_parent.get_selection());
#if ENABLE_SINKING_CONTOURS
m_cut_contours.reset();
#endif // ENABLE_SINKING_CONTOURS
}
}
void GLGizmoCut::set_cut_z(double cut_z)
@ -308,9 +319,8 @@ void GLGizmoCut::update_contours()
m_cut_contours.contours.set_color(-1, { 1.0f, 1.0f, 1.0f, 1.0f });
}
}
else if (box.center() != m_cut_contours.position) {
else if (box.center() != m_cut_contours.position)
m_cut_contours.shift = box.center() - m_cut_contours.position;
}
}
else
m_cut_contours.contours.reset();

View file

@ -35,6 +35,16 @@ class GLGizmoCut : public GLGizmoBase
Vec3d shift{ Vec3d::Zero() };
int object_idx{ -1 };
int instance_idx{ -1 };
void reset() {
mesh.clear();
contours.reset();
cut_z = 0.0;
position = Vec3d::Zero();
shift = Vec3d::Zero();
object_idx = -1;
instance_idx = -1;
}
};
CutContours m_cut_contours;

View file

@ -497,9 +497,6 @@ void GLGizmoRotate3D::on_render()
m_gizmos[Z].render();
}
const char * GLGizmoRotate3D::RotoptimzeWindow::options[RotoptimizeJob::get_methods_count()];
bool GLGizmoRotate3D::RotoptimzeWindow::options_valid = false;
GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
State & state,
const Alignment &alignment)
@ -515,21 +512,26 @@ GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
y = std::min(y, alignment.bottom_limit - win_h);
ImGui::SetWindowPos(ImVec2(x, y), ImGuiCond_Always);
ImGui::PushItemWidth(200.f);
ImGui::PushItemWidth(300.f);
size_t methods_cnt = RotoptimizeJob::get_methods_count();
if (!options_valid) {
for (size_t i = 0; i < methods_cnt; ++i)
options[i] = RotoptimizeJob::get_method_names()[i].c_str();
if (ImGui::BeginCombo(_L("Choose goal").c_str(), RotoptimizeJob::get_method_name(state.method_id).c_str())) {
for (size_t i = 0; i < RotoptimizeJob::get_methods_count(); ++i) {
if (ImGui::Selectable(RotoptimizeJob::get_method_name(i).c_str())) {
state.method_id = i;
wxGetApp().app_config->set("sla_auto_rotate",
"method_id",
std::to_string(state.method_id));
}
options_valid = true;
if (ImGui::IsItemHovered())
ImGui::SetTooltip("%s", RotoptimizeJob::get_method_description(i).c_str());
}
ImGui::EndCombo();
}
int citem = state.method_id;
if (ImGui::Combo(_L("Choose goal").c_str(), &citem, options, methods_cnt) ) {
state.method_id = citem;
wxGetApp().app_config->set("sla_auto_rotate", "method_id", std::to_string(state.method_id));
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("%s", RotoptimizeJob::get_method_description(state.method_id).c_str());
ImGui::Separator();

View file

@ -138,10 +138,6 @@ private:
class RotoptimzeWindow {
ImGuiWrapper *m_imgui = nullptr;
static const char * options [];
static bool options_valid;
public:
struct State {

View file

@ -447,7 +447,8 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
}
if (action == SLAGizmoEventType::DiscardChanges) {
editing_mode_discard_changes();
ask_about_changes_call_after([this](){ editing_mode_apply_changes(); },
[this](){ editing_mode_discard_changes(); });
return true;
}
@ -879,6 +880,22 @@ CommonGizmosDataID GLGizmoSlaSupports::on_get_requirements() const
void GLGizmoSlaSupports::ask_about_changes_call_after(std::function<void()> on_yes, std::function<void()> on_no)
{
wxGetApp().CallAfter([this, on_yes, on_no]() {
// Following is called through CallAfter, because otherwise there was a problem
// on OSX with the wxMessageDialog being shown several times when clicked into.
MessageDialog dlg(GUI::wxGetApp().mainframe, _L("Do you want to save your manually "
"edited support points?") + "\n",_L("Save support points?"), wxICON_QUESTION | wxYES | wxNO | wxCANCEL );
int ret = dlg.ShowModal();
if (ret == wxID_YES)
on_yes();
else if (ret == wxID_NO)
on_no();
});
}
void GLGizmoSlaSupports::on_set_state()
{
if (m_state == m_old_state)
@ -901,18 +918,8 @@ void GLGizmoSlaSupports::on_set_state()
if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off
bool will_ask = m_editing_mode && unsaved_changes() && on_is_activable();
if (will_ask) {
wxGetApp().CallAfter([this]() {
// Following is called through CallAfter, because otherwise there was a problem
// on OSX with the wxMessageDialog being shown several times when clicked into.
//wxMessageDialog dlg(GUI::wxGetApp().mainframe, _L("Do you want to save your manually "
MessageDialog dlg(GUI::wxGetApp().mainframe, _L("Do you want to save your manually "
"edited support points?") + "\n",_L("Save support points?"), wxICON_QUESTION | wxYES | wxNO | wxCANCEL );
int ret = dlg.ShowModal();
if (ret == wxID_YES)
editing_mode_apply_changes();
else if (ret == wxID_NO)
editing_mode_discard_changes();
});
ask_about_changes_call_after([this](){ editing_mode_apply_changes(); },
[this](){ editing_mode_discard_changes(); });
// refuse to be turned off so the gizmo is active when the CallAfter is executed
m_state = m_old_state;
}

View file

@ -117,6 +117,7 @@ private:
void auto_generate();
void switch_to_editing_mode();
void disable_editing_mode();
void ask_about_changes_call_after(std::function<void()> on_yes, std::function<void()> on_no);
protected:
void on_set_state() override;