This commit is contained in:
bubnikv 2019-01-21 10:07:27 +01:00
commit ba1abf3f1f
4 changed files with 34 additions and 2 deletions

View file

@ -2466,11 +2466,13 @@ void GLGizmoCut::on_render_input_window(float x, float y, const GLCanvas3D::Sele
m_imgui->checkbox(_(L("Keep lower part")), m_keep_lower);
m_imgui->checkbox(_(L("Rotate lower part upwards")), m_rotate_lower);
m_imgui->disabled_begin(!m_keep_upper && !m_keep_lower);
const bool cut_clicked = m_imgui->button(_(L("Perform cut")));
m_imgui->disabled_end();
m_imgui->end();
if (cut_clicked) {
if (cut_clicked && (m_keep_upper || m_keep_lower)) {
perform_cut(selection);
}
}

View file

@ -12,6 +12,8 @@
#include <GL/glew.h>
#include <imgui/imgui_internal.h>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Utils.hpp"
#include "GUI.hpp"
@ -23,6 +25,7 @@ namespace GUI {
ImGuiWrapper::ImGuiWrapper()
: m_font_texture(0)
, m_mouse_buttons(0)
, m_disabled(false)
{
}
@ -154,6 +157,26 @@ void ImGuiWrapper::text(const wxString &label)
ImGui::Text(label_utf8.c_str(), NULL);
}
void ImGuiWrapper::disabled_begin(bool disabled)
{
wxCHECK_RET(!m_disabled, "ImGUI: Unbalanced disabled_begin() call");
if (disabled) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
m_disabled = true;
}
}
void ImGuiWrapper::disabled_end()
{
if (m_disabled) {
ImGui::PopItemFlag();
ImGui::PopStyleVar();
m_disabled = false;
}
}
bool ImGuiWrapper::want_mouse() const
{
return ImGui::GetIO().WantCaptureMouse;

View file

@ -21,8 +21,8 @@ class ImGuiWrapper
FontsMap m_fonts;
unsigned m_font_texture;
unsigned m_mouse_buttons;
bool m_disabled;
public:
ImGuiWrapper();
@ -50,6 +50,9 @@ public:
bool checkbox(const wxString &label, bool &value);
void text(const wxString &label);
void disabled_begin(bool disabled);
void disabled_end();
bool want_mouse() const;
bool want_keyboard() const;
bool want_text_input() const;

View file

@ -2769,6 +2769,10 @@ void Plater::cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_uppe
wxCHECK_RET(instance_idx < object->instances.size(), "instance_idx out of bounds");
if (!keep_upper && !keep_lower) {
return;
}
const auto new_objects = object->cut(instance_idx, z, keep_upper, keep_lower, rotate_lower);
remove(obj_idx);