Refactoring and cleanup of painting gizmos.
This commit is contained in:
parent
8a77fa38f0
commit
15a1b51339
@ -104,9 +104,9 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
||||
const float minimal_slider_width = m_imgui->scaled(4.f);
|
||||
|
||||
float caption_max = 0.f;
|
||||
float total_text_max = 0.;
|
||||
for (const std::string& t : {"enforce", "block", "remove"}) {
|
||||
caption_max = std::max(caption_max, m_imgui->calc_text_size(m_desc.at(t+"_caption")).x);
|
||||
float total_text_max = 0.f;
|
||||
for (const auto &t : std::array<std::string, 3>{"enforce", "block", "remove"}) {
|
||||
caption_max = std::max(caption_max, m_imgui->calc_text_size(m_desc.at(t + "_caption")).x);
|
||||
total_text_max = std::max(total_text_max, caption_max + m_imgui->calc_text_size(m_desc.at(t)).x);
|
||||
}
|
||||
caption_max += m_imgui->scaled(1.f);
|
||||
@ -124,7 +124,7 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
||||
m_imgui->text(text);
|
||||
};
|
||||
|
||||
for (const std::string& t : {"enforce", "block", "remove"})
|
||||
for (const auto &t : std::array<std::string, 3>{"enforce", "block", "remove"})
|
||||
draw_text_with_caption(m_desc.at(t + "_caption"), m_desc.at(t));
|
||||
|
||||
m_imgui->text("");
|
||||
|
@ -33,15 +33,15 @@ bool GLGizmoMmuSegmentation::on_is_selectable() const
|
||||
&& wxGetApp().get_mode() != comSimple && wxGetApp().extruders_edited_cnt() > 1);
|
||||
}
|
||||
|
||||
static std::vector<std::array<uint8_t, 3>> get_extruders_colors()
|
||||
static std::vector<std::array<float, 4>> get_extruders_colors()
|
||||
{
|
||||
unsigned char rgb_color[3] = {};
|
||||
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||
std::vector<std::array<uint8_t, 3>> colors_out(colors.size());
|
||||
std::vector<std::array<float, 4>> colors_out(colors.size());
|
||||
for (const std::string &color : colors) {
|
||||
Slic3r::GUI::BitmapCache::parse_color(color, rgb_color);
|
||||
size_t color_idx = &color - &colors.front();
|
||||
colors_out[color_idx] = {rgb_color[0], rgb_color[1], rgb_color[2]};
|
||||
colors_out[color_idx] = {float(rgb_color[0]) / 255.f, float(rgb_color[1]) / 255.f, float(rgb_color[2]) / 255.f, 1.f};
|
||||
}
|
||||
|
||||
return colors_out;
|
||||
@ -142,14 +142,17 @@ void GLGizmoMmuSegmentation::set_painter_gizmo_data(const Selection &selection)
|
||||
|
||||
static void render_extruders_combo(const std::string &label,
|
||||
const std::vector<std::string> &extruders,
|
||||
const std::vector<std::array<uint8_t, 3>> &extruders_colors,
|
||||
const std::vector<std::array<float, 4>> &extruders_colors,
|
||||
size_t &selection_idx)
|
||||
{
|
||||
assert(!extruders_colors.empty());
|
||||
assert(extruders_colors.size() == extruders_colors.size());
|
||||
|
||||
size_t selection_out = selection_idx;
|
||||
auto convert_to_imu32 = [](const std::array<float, 4> &color) -> ImU32 {
|
||||
return IM_COL32(uint8_t(color[0] * 255.f), uint8_t(color[1] * 255.f), uint8_t(color[2] * 255.f), uint8_t(color[3] * 255.f));
|
||||
};
|
||||
|
||||
size_t selection_out = selection_idx;
|
||||
// It is necessary to use BeginGroup(). Otherwise, when using SameLine() is called, then other items will be drawn inside the combobox.
|
||||
ImGui::BeginGroup();
|
||||
ImVec2 combo_pos = ImGui::GetCursorScreenPos();
|
||||
@ -164,8 +167,7 @@ static void render_extruders_combo(const std::string &la
|
||||
ImGui::SameLine();
|
||||
ImGuiStyle &style = ImGui::GetStyle();
|
||||
float height = ImGui::GetTextLineHeight();
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(start_position, ImVec2(start_position.x + height + height / 2, start_position.y + height),
|
||||
IM_COL32(extruders_colors[extruder_idx][0], extruders_colors[extruder_idx][1], extruders_colors[extruder_idx][2], 255));
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(start_position, ImVec2(start_position.x + height + height / 2, start_position.y + height), convert_to_imu32(extruders_colors[extruder_idx]));
|
||||
ImGui::GetWindowDrawList()->AddRect(start_position, ImVec2(start_position.x + height + height / 2, start_position.y + height), IM_COL32_BLACK);
|
||||
|
||||
ImGui::SetCursorScreenPos(ImVec2(start_position.x + height + height / 2 + style.FramePadding.x, start_position.y));
|
||||
@ -183,9 +185,7 @@ static void render_extruders_combo(const std::string &la
|
||||
ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
float height = ImGui::GetTextLineHeight();
|
||||
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + height + height / 2, p.y + height),
|
||||
IM_COL32(extruders_colors[selection_idx][0], extruders_colors[selection_idx][1],
|
||||
extruders_colors[selection_idx][2], 255));
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + height + height / 2, p.y + height), convert_to_imu32(extruders_colors[selection_idx]));
|
||||
ImGui::GetWindowDrawList()->AddRect(p, ImVec2(p.x + height + height / 2, p.y + height), IM_COL32_BLACK);
|
||||
|
||||
ImGui::SetCursorScreenPos(ImVec2(p.x + height + height / 2 + style.FramePadding.x, p.y));
|
||||
@ -224,7 +224,7 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
||||
|
||||
float caption_max = 0.f;
|
||||
float total_text_max = 0.;
|
||||
for (const std::string &t : {"first_color", "second_color", "remove"}) {
|
||||
for (const auto &t : std::array<std::string, 3>{"first_color", "second_color", "remove"}) {
|
||||
caption_max = std::max(caption_max, m_imgui->calc_text_size(m_desc.at(t + "_caption")).x);
|
||||
total_text_max = std::max(total_text_max, caption_max + m_imgui->calc_text_size(m_desc.at(t)).x);
|
||||
}
|
||||
@ -243,33 +243,33 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
||||
m_imgui->text(text);
|
||||
};
|
||||
|
||||
for (const std::string &t : {"first_color", "second_color", "remove"})
|
||||
for (const auto &t : std::array<std::string, 3>{"first_color", "second_color", "remove"})
|
||||
draw_text_with_caption(m_desc.at(t + "_caption"), m_desc.at(t));
|
||||
|
||||
m_imgui->text("");
|
||||
ImGui::Separator();
|
||||
|
||||
const std::array<uint8_t, 3> &select_first_color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
const std::array<uint8_t, 3> &select_second_color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
|
||||
m_imgui->text(m_desc.at("first_color"));
|
||||
ImGui::SameLine(combo_label_width);
|
||||
ImGui::PushItemWidth(window_width - combo_label_width - color_button_width);
|
||||
render_extruders_combo("##first_color_combo", m_original_extruders_names, m_original_extruders_colors, m_first_selected_extruder_idx);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImVec4 first_color = ImVec4(float(select_first_color[0]) / 255.0f, float(select_first_color[1]) / 255.0f, float(select_first_color[2]) / 255.0f, 1.0f);
|
||||
ImVec4 second_color = ImVec4(float(select_second_color[0]) / 255.0f, float(select_second_color[1]) / 255.0f, float(select_second_color[2]) / 255.0f, 1.0f);
|
||||
const std::array<float, 4> &select_first_color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
ImVec4 first_color = ImVec4(select_first_color[0], select_first_color[1], select_first_color[2], select_first_color[3]);
|
||||
if(ImGui::ColorEdit4("First color##color_picker", (float*)&first_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_first_selected_extruder_idx] = {uint8_t(first_color.x * 255.0f), uint8_t(first_color.y * 255.0f), uint8_t(first_color.z * 255.0f)};
|
||||
m_modified_extruders_colors[m_first_selected_extruder_idx] = {first_color.x, first_color.y, first_color.z, first_color.w};
|
||||
|
||||
m_imgui->text(m_desc.at("second_color"));
|
||||
ImGui::SameLine(combo_label_width);
|
||||
ImGui::PushItemWidth(window_width - combo_label_width - color_button_width);
|
||||
render_extruders_combo("##second_color_combo", m_original_extruders_names, m_original_extruders_colors, m_second_selected_extruder_idx);
|
||||
ImGui::SameLine();
|
||||
|
||||
const std::array<float, 4> &select_second_color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
ImVec4 second_color = ImVec4(select_second_color[0], select_second_color[1], select_second_color[2], select_second_color[3]);
|
||||
if(ImGui::ColorEdit4("Second color##color_picker", (float*)&second_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
|
||||
m_modified_extruders_colors[m_second_selected_extruder_idx] = {uint8_t(second_color.x * 255.0f), uint8_t(second_color.y * 255.0f), uint8_t(second_color.z * 255.0f)};
|
||||
m_modified_extruders_colors[m_second_selected_extruder_idx] = {second_color.x, second_color.y, second_color.z, second_color.w};
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
@ -431,74 +431,66 @@ PainterGizmoType GLGizmoMmuSegmentation::get_painter_type() const
|
||||
|
||||
std::array<float, 4> GLGizmoMmuSegmentation::get_cursor_sphere_left_button_color() const
|
||||
{
|
||||
const std::array<uint8_t, 3> &color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
return {float(color[0]) / 255.0f, float(color[1]) / 255.0f, float(color[2]) / 255.0f, 0.25f};
|
||||
const std::array<float, 4> &color = m_modified_extruders_colors[m_first_selected_extruder_idx];
|
||||
return {color[0], color[1], color[2], 0.25f};
|
||||
}
|
||||
|
||||
std::array<float, 4> GLGizmoMmuSegmentation::get_cursor_sphere_right_button_color() const
|
||||
{
|
||||
const std::array<uint8_t, 3> &color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
return {float(color[0]) / 255.0f, float(color[1]) / 255.0f, float(color[2]) / 255.0f, 0.25f};
|
||||
const std::array<float, 4> &color = m_modified_extruders_colors[m_second_selected_extruder_idx];
|
||||
return {color[0], color[1], color[2], 0.25f};
|
||||
}
|
||||
|
||||
void TriangleSelectorMmuGui::render(ImGuiWrapper *imgui)
|
||||
{
|
||||
static constexpr std::array<float, 4> seed_fill_color{0.f, 1.f, 0.44f, 1.f};
|
||||
|
||||
std::vector<int> color_cnt(m_iva_colors.size());
|
||||
int seed_fill_cnt = 0;
|
||||
for (auto &iva_color : m_iva_colors)
|
||||
iva_color.release_geometry();
|
||||
m_iva_seed_fill.release_geometry();
|
||||
|
||||
auto append_triangle = [this](GLIndexedVertexArray &iva, int &cnt, const Triangle &tr) -> void {
|
||||
for (int i = 0; i < 3; ++i)
|
||||
iva.push_geometry(m_vertices[tr.verts_idxs[i]].v, m_mesh->stl.facet_start[tr.source_triangle].normal);
|
||||
iva.push_triangle(cnt, cnt + 1, cnt + 2);
|
||||
cnt += 3;
|
||||
};
|
||||
|
||||
for (size_t color_idx = 0; color_idx < m_iva_colors.size(); ++color_idx) {
|
||||
for (const Triangle &tr : m_triangles) {
|
||||
if (!tr.valid() || tr.is_split() || tr.is_selected_by_seed_fill() || tr.get_state() != EnforcerBlockerType(color_idx))
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
m_iva_colors[color_idx].push_geometry(m_vertices[tr.verts_idxs[i]].v, m_mesh->stl.facet_start[tr.source_triangle].normal);
|
||||
m_iva_colors[color_idx].push_triangle(color_cnt[color_idx], color_cnt[color_idx] + 1, color_cnt[color_idx] + 2);
|
||||
color_cnt[color_idx] += 3;
|
||||
append_triangle(m_iva_colors[color_idx], color_cnt[color_idx], tr);
|
||||
}
|
||||
}
|
||||
|
||||
for (const Triangle &tr : m_triangles) {
|
||||
if (!tr.valid() || tr.is_split() || !tr.is_selected_by_seed_fill()) continue;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
m_iva_seed_fill.push_geometry(m_vertices[tr.verts_idxs[i]].v, m_mesh->stl.facet_start[tr.source_triangle].normal);
|
||||
m_iva_seed_fill.push_triangle(seed_fill_cnt, seed_fill_cnt + 1, seed_fill_cnt + 2);
|
||||
seed_fill_cnt += 3;
|
||||
if (!tr.valid() || tr.is_split() || !tr.is_selected_by_seed_fill())
|
||||
continue;
|
||||
append_triangle(m_iva_seed_fill, seed_fill_cnt, tr);
|
||||
}
|
||||
|
||||
for (auto &iva_color : m_iva_colors)
|
||||
iva_color.finalize_geometry(true);
|
||||
m_iva_seed_fill.finalize_geometry(true);
|
||||
|
||||
std::vector<bool> render_colors(m_iva_colors.size());
|
||||
for (size_t color_idx = 0; color_idx < m_iva_colors.size(); ++color_idx)
|
||||
render_colors[color_idx] = m_iva_colors[color_idx].has_VBOs();
|
||||
bool render_seed_fill = m_iva_seed_fill.has_VBOs();
|
||||
|
||||
auto* shader = wxGetApp().get_current_shader();
|
||||
if (! shader)
|
||||
auto *shader = wxGetApp().get_current_shader();
|
||||
if (!shader)
|
||||
return;
|
||||
assert(shader->get_name() == "gouraud");
|
||||
|
||||
for (size_t color_idx = 0; color_idx < m_iva_colors.size(); ++color_idx) {
|
||||
const std::array<uint8_t, 3> &color_source = (color_idx == 0) ? m_default_volume_color : m_colors[color_idx - 1];
|
||||
if (render_colors[color_idx]) {
|
||||
std::array<float, 4> color = {float(color_source[0]) / 255.0f, float(color_source[1]) / 255.0f,
|
||||
float(color_source[2]) / 255.0f, 1.f};
|
||||
auto render = [&shader](const GLIndexedVertexArray &iva, const std::array<float, 4> &color) -> void {
|
||||
if (iva.has_VBOs()) {
|
||||
shader->set_uniform("uniform_color", color);
|
||||
m_iva_colors[color_idx].render();
|
||||
}
|
||||
iva.render();
|
||||
}
|
||||
};
|
||||
|
||||
if (render_seed_fill) {
|
||||
std::array<float, 4> color = {0.f, 1.f, 0.44f, 1.f};
|
||||
shader->set_uniform("uniform_color", color);
|
||||
m_iva_seed_fill.render();
|
||||
}
|
||||
for (size_t color_idx = 0; color_idx < m_iva_colors.size(); ++color_idx)
|
||||
render(m_iva_colors[color_idx], (color_idx == 0) ? m_default_volume_color : m_colors[color_idx - 1]);
|
||||
render(m_iva_seed_fill, seed_fill_color);
|
||||
}
|
||||
|
||||
wxString GLGizmoMmuSegmentation::handle_snapshot_action_name(bool shift_down, GLGizmoPainterBase::Button button_down) const
|
||||
|
@ -7,7 +7,7 @@ namespace Slic3r::GUI {
|
||||
|
||||
class TriangleSelectorMmuGui : public TriangleSelectorGUI {
|
||||
public:
|
||||
explicit TriangleSelectorMmuGui(const TriangleMesh& mesh, const std::vector<std::array<uint8_t, 3>> &colors, const std::array<uint8_t, 3> &default_volume_color)
|
||||
explicit TriangleSelectorMmuGui(const TriangleMesh& mesh, const std::vector<std::array<float, 4>> &colors, const std::array<float, 4> &default_volume_color)
|
||||
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color) {
|
||||
// Plus 1 is because the first position is allocated for non-painted triangles.
|
||||
m_iva_colors = std::vector<GLIndexedVertexArray>(colors.size() + 1);
|
||||
@ -19,9 +19,10 @@ public:
|
||||
void render(ImGuiWrapper* imgui) override;
|
||||
|
||||
private:
|
||||
const std::vector<std::array<uint8_t, 3>> &m_colors;
|
||||
const std::vector<std::array<float, 4>> &m_colors;
|
||||
std::vector<GLIndexedVertexArray> m_iva_colors;
|
||||
const std::array<uint8_t, 3> m_default_volume_color;
|
||||
const std::array<float, 4> m_default_volume_color;
|
||||
GLIndexedVertexArray m_iva_seed_fill;
|
||||
};
|
||||
|
||||
class GLGizmoMmuSegmentation : public GLGizmoPainterBase
|
||||
@ -52,8 +53,8 @@ protected:
|
||||
size_t m_first_selected_extruder_idx = 0;
|
||||
size_t m_second_selected_extruder_idx = 1;
|
||||
std::vector<std::string> m_original_extruders_names;
|
||||
std::vector<std::array<uint8_t, 3>> m_original_extruders_colors;
|
||||
std::vector<std::array<uint8_t, 3>> m_modified_extruders_colors;
|
||||
std::vector<std::array<float, 4>> m_original_extruders_colors;
|
||||
std::vector<std::array<float, 4>> m_modified_extruders_colors;
|
||||
std::vector<int> m_original_volumes_extruder_idxs;
|
||||
|
||||
private:
|
||||
|
@ -126,8 +126,8 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection, const bool
|
||||
if (clipping_plane_active) {
|
||||
const ClippingPlane* clp = m_c->object_clipper()->get_clipping_plane();
|
||||
for (size_t i=0; i<3; ++i)
|
||||
clp_dataf[i] = -1. * clp->get_data()[i];
|
||||
clp_dataf[3] = clp->get_data()[3];
|
||||
clp_dataf[i] = -1.f * float(clp->get_data()[i]);
|
||||
clp_dataf[3] = float(clp->get_data()[3]);
|
||||
}
|
||||
|
||||
auto *shader = wxGetApp().get_shader("gouraud");
|
||||
@ -203,13 +203,13 @@ void GLGizmoPainterBase::render_cursor() const
|
||||
|
||||
void GLGizmoPainterBase::render_cursor_circle() const
|
||||
{
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
float zoom = (float)camera.get_zoom();
|
||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||
auto zoom = (float) camera.get_zoom();
|
||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
|
||||
Size cnv_size = m_parent.get_canvas_size();
|
||||
float cnv_half_width = 0.5f * (float)cnv_size.get_width();
|
||||
float cnv_half_height = 0.5f * (float)cnv_size.get_height();
|
||||
float cnv_half_width = 0.5f * (float) cnv_size.get_width();
|
||||
float cnv_half_height = 0.5f * (float) cnv_size.get_height();
|
||||
if ((cnv_half_width == 0.0f) || (cnv_half_height == 0.0f))
|
||||
return;
|
||||
Vec2d mouse_pos(m_parent.get_local_mouse_position()(0), m_parent.get_local_mouse_position()(1));
|
||||
@ -217,11 +217,8 @@ void GLGizmoPainterBase::render_cursor_circle() const
|
||||
center = center * inv_zoom;
|
||||
|
||||
glsafe(::glLineWidth(1.5f));
|
||||
float color[3];
|
||||
color[0] = 0.f;
|
||||
color[1] = 1.f;
|
||||
color[2] = 0.3f;
|
||||
glsafe(::glColor3fv(color));
|
||||
static const std::array<float, 3> color = {0.f, 1.f, 0.3f};
|
||||
glsafe(::glColor3fv(color.data()));
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
glsafe(::glPushMatrix());
|
||||
@ -515,11 +512,7 @@ bool GLGizmoPainterBase::on_is_activable() const
|
||||
|
||||
// Check that none of the selected volumes is outside. Only SLA auxiliaries (supports) are allowed outside.
|
||||
const Selection::IndicesList& list = selection.get_volume_idxs();
|
||||
for (const auto& idx : list)
|
||||
if (selection.get_volume(idx)->is_outside)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return std::all_of(list.cbegin(), list.cend(), [&selection](unsigned int idx) { return !selection.get_volume(idx)->is_outside; });
|
||||
}
|
||||
|
||||
bool GLGizmoPainterBase::on_is_selectable() const
|
||||
@ -579,66 +572,42 @@ void GLGizmoPainterBase::on_load(cereal::BinaryInputArchive&)
|
||||
|
||||
void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
||||
{
|
||||
static constexpr std::array<float, 4> enforcers_color{0.47f, 0.47f, 1.f, 1.f};
|
||||
static constexpr std::array<float, 4> blockers_color{1.f, 0.44f, 0.44f, 1.f};
|
||||
|
||||
int enf_cnt = 0;
|
||||
int blc_cnt = 0;
|
||||
int seed_fill_cnt = 0;
|
||||
|
||||
m_iva_enforcers.release_geometry();
|
||||
m_iva_blockers.release_geometry();
|
||||
m_iva_seed_fill.release_geometry();
|
||||
for (auto *iva : {&m_iva_enforcers, &m_iva_blockers})
|
||||
iva->release_geometry();
|
||||
|
||||
for (const Triangle& tr : m_triangles) {
|
||||
if (!tr.valid() || tr.is_split() || tr.get_state() == EnforcerBlockerType::NONE || tr.is_selected_by_seed_fill())
|
||||
if (!tr.valid() || tr.is_split() || tr.get_state() == EnforcerBlockerType::NONE)
|
||||
continue;
|
||||
|
||||
GLIndexedVertexArray &va = tr.get_state() == EnforcerBlockerType::ENFORCER ? m_iva_enforcers : m_iva_blockers;
|
||||
int &cnt = tr.get_state() == EnforcerBlockerType::ENFORCER ? enf_cnt : blc_cnt;
|
||||
GLIndexedVertexArray &iva = tr.get_state() == EnforcerBlockerType::ENFORCER ? m_iva_enforcers : m_iva_blockers;
|
||||
int & cnt = tr.get_state() == EnforcerBlockerType::ENFORCER ? enf_cnt : blc_cnt;
|
||||
|
||||
for (int i=0; i<3; ++i)
|
||||
va.push_geometry(m_vertices[tr.verts_idxs[i]].v, m_mesh->stl.facet_start[tr.source_triangle].normal);
|
||||
va.push_triangle(cnt, cnt + 1, cnt + 2);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
iva.push_geometry(m_vertices[tr.verts_idxs[i]].v, m_mesh->stl.facet_start[tr.source_triangle].normal);
|
||||
iva.push_triangle(cnt, cnt + 1, cnt + 2);
|
||||
cnt += 3;
|
||||
}
|
||||
|
||||
for (const Triangle &tr : m_triangles) {
|
||||
if (!tr.valid() || tr.is_split() || !tr.is_selected_by_seed_fill())
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
m_iva_seed_fill.push_geometry(m_vertices[tr.verts_idxs[i]].v, m_mesh->stl.facet_start[tr.source_triangle].normal);
|
||||
m_iva_seed_fill.push_triangle(seed_fill_cnt, seed_fill_cnt + 1, seed_fill_cnt + 2);
|
||||
seed_fill_cnt += 3;
|
||||
}
|
||||
|
||||
m_iva_enforcers.finalize_geometry(true);
|
||||
m_iva_blockers.finalize_geometry(true);
|
||||
m_iva_seed_fill.finalize_geometry(true);
|
||||
|
||||
bool render_enf = m_iva_enforcers.has_VBOs();
|
||||
bool render_blc = m_iva_blockers.has_VBOs();
|
||||
bool render_seed_fill = m_iva_seed_fill.has_VBOs();
|
||||
for (auto *iva : {&m_iva_enforcers, &m_iva_blockers})
|
||||
iva->finalize_geometry(true);
|
||||
|
||||
auto* shader = wxGetApp().get_current_shader();
|
||||
if (! shader)
|
||||
return;
|
||||
assert(shader->get_name() == "gouraud");
|
||||
|
||||
if (render_enf) {
|
||||
std::array<float, 4> color = {0.47f, 0.47f, 1.f, 1.f};
|
||||
shader->set_uniform("uniform_color", color);
|
||||
m_iva_enforcers.render();
|
||||
for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color),
|
||||
std::make_pair(&m_iva_blockers, blockers_color)}) {
|
||||
if (iva.first->has_VBOs()) {
|
||||
shader->set_uniform("uniform_color", iva.second);
|
||||
iva.first->render();
|
||||
}
|
||||
|
||||
if (render_blc) {
|
||||
std::array<float, 4> color = {1.f, 0.44f, 0.44f, 1.f};
|
||||
shader->set_uniform("uniform_color", color);
|
||||
m_iva_blockers.render();
|
||||
}
|
||||
|
||||
if (render_seed_fill) {
|
||||
std::array<float, 4> color = {0.f, 1.00f, 0.44f, 1.f};
|
||||
shader->set_uniform("uniform_color", color);
|
||||
m_iva_seed_fill.render();
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,8 @@ public:
|
||||
|
||||
// Render current selection. Transformation matrices are supposed
|
||||
// to be already set.
|
||||
virtual void render(ImGuiWrapper* imgui = nullptr);
|
||||
virtual void render(ImGuiWrapper *imgui);
|
||||
void render() { this->render(nullptr); }
|
||||
|
||||
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
||||
void render_debug(ImGuiWrapper* imgui);
|
||||
@ -47,8 +48,6 @@ private:
|
||||
GLIndexedVertexArray m_iva_enforcers;
|
||||
GLIndexedVertexArray m_iva_blockers;
|
||||
std::array<GLIndexedVertexArray, 3> m_varrays;
|
||||
protected:
|
||||
GLIndexedVertexArray m_iva_seed_fill;
|
||||
};
|
||||
|
||||
|
||||
@ -60,8 +59,8 @@ class GLGizmoPainterBase : public GLGizmoBase
|
||||
private:
|
||||
ObjectID m_old_mo_id;
|
||||
size_t m_old_volumes_size = 0;
|
||||
virtual void on_render() const override {}
|
||||
virtual void on_render_for_picking() const override {}
|
||||
void on_render() const override {}
|
||||
void on_render_for_picking() const override {}
|
||||
|
||||
public:
|
||||
GLGizmoPainterBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
@ -83,7 +82,6 @@ protected:
|
||||
virtual void update_model_object() const = 0;
|
||||
virtual void update_from_model_object() = 0;
|
||||
void activate_internal_undo_redo_stack(bool activate);
|
||||
void set_cursor_type(TriangleSelector::CursorType);
|
||||
|
||||
virtual std::array<float, 4> get_cursor_sphere_left_button_color() const { return {0.f, 0.f, 1.f, 0.25f}; }
|
||||
virtual std::array<float, 4> get_cursor_sphere_right_button_color() const { return {1.f, 0.f, 0.f, 0.25f}; }
|
||||
|
@ -87,9 +87,9 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
|
||||
const float minimal_slider_width = m_imgui->scaled(4.f);
|
||||
|
||||
float caption_max = 0.f;
|
||||
float total_text_max = 0.;
|
||||
for (const std::string& t : {"enforce", "block", "remove"}) {
|
||||
caption_max = std::max(caption_max, m_imgui->calc_text_size(m_desc.at(t+"_caption")).x);
|
||||
float total_text_max = 0.f;
|
||||
for (const auto &t : std::array<std::string, 3>{"enforce", "block", "remove"}) {
|
||||
caption_max = std::max(caption_max, m_imgui->calc_text_size(m_desc.at(t + "_caption")).x);
|
||||
total_text_max = std::max(total_text_max, caption_max + m_imgui->calc_text_size(m_desc.at(t)).x);
|
||||
}
|
||||
caption_max += m_imgui->scaled(1.f);
|
||||
@ -107,7 +107,7 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
|
||||
m_imgui->text(text);
|
||||
};
|
||||
|
||||
for (const std::string& t : {"enforce", "block", "remove"})
|
||||
for (const auto &t : std::array<std::string, 3>{"enforce", "block", "remove"})
|
||||
draw_text_with_caption(m_desc.at(t + "_caption"), m_desc.at(t));
|
||||
|
||||
m_imgui->text("");
|
||||
|
Loading…
Reference in New Issue
Block a user