mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 13:56:01 +08:00
Nicer bed selector dialog
This commit is contained in:
parent
e1be0f041c
commit
324763a90e
@ -208,6 +208,8 @@ namespace ImGui
|
|||||||
const wchar_t RemoveTick = 0x280F;
|
const wchar_t RemoveTick = 0x280F;
|
||||||
const wchar_t RemoveTickHovered = 0x2810;
|
const wchar_t RemoveTickHovered = 0x2810;
|
||||||
|
|
||||||
|
// icon for multiple beds
|
||||||
|
const wchar_t SliceAllBtnIcon = 0x2811;
|
||||||
// void MyFunction(const char* name, const MyMatrix44& v);
|
// void MyFunction(const char* name, const MyMatrix44& v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
resources/icons/slice_all.svg
Normal file
3
resources/icons/slice_all.svg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="1 0 16 16">
|
||||||
|
<path d="M 2 2 L 4 4 L 6 1 M 2 7 L 4 9 L 6 6 M 2 12 L 4 14 L 6 11 M 7 12 L 9 14 L 11 11 M 12 12 L 14 14 L 16 11 M 7 7 L 9 9 L 11 6 M 12 7 L 14 9 L 16 6" stroke="#ED6B21" stroke-width="0.95" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 319 B |
@ -79,6 +79,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
#endif
|
#endif
|
||||||
@ -1982,44 +1984,10 @@ void GLCanvas3D::render()
|
|||||||
wxGetApp().plater()->schedule_background_process();
|
wxGetApp().plater()->schedule_background_process();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// draw overlays
|
|
||||||
_render_overlays();
|
|
||||||
|
|
||||||
{
|
_render_overlays();
|
||||||
if (s_multiple_beds.get_number_of_beds() != 1 && wxGetApp().plater()->is_preview_shown()) {
|
|
||||||
ImGui::Begin("Bed selector", 0, ImGuiWindowFlags_NoResize);
|
|
||||||
for (int i = 0; i < s_multiple_beds.get_number_of_beds(); ++i) {
|
|
||||||
bool inactive = i != s_multiple_beds.get_active_bed() || s_multiple_beds.is_autoslicing();
|
|
||||||
if (inactive)
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0., 0., 0., .5));
|
|
||||||
if (bool clicked = (i >= int(s_th_tex_id.size()))
|
|
||||||
? ImGui::Button(std::to_string(i).c_str(), ImVec2(100,100))
|
|
||||||
: ImGui::ImageButton((void*)(int64_t)s_th_tex_id[i], ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
|
|
||||||
clicked)
|
|
||||||
select_bed(i, true);
|
|
||||||
if (inactive)
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
|
|
||||||
std::string status_text;
|
|
||||||
if (wxGetApp().plater()->get_fff_prints()[i]->finished())
|
|
||||||
status_text = "finished";
|
|
||||||
else if (m_process->fff_print() == wxGetApp().plater()->get_fff_prints()[i].get() && m_process->running())
|
|
||||||
status_text = "running";
|
|
||||||
else
|
|
||||||
status_text = "idle";
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Text("%s", status_text.c_str());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
if (ImGui::Button("ALL", ImVec2(105, 105))) {
|
|
||||||
if (! s_multiple_beds.is_autoslicing())
|
|
||||||
s_multiple_beds.start_autoslice([this](int i, bool user) { this->select_bed(i, user); });
|
|
||||||
}
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
_render_bed_selector();
|
||||||
|
|
||||||
if (wxGetApp().plater()->is_render_statistic_dialog_visible()) {
|
if (wxGetApp().plater()->is_render_statistic_dialog_visible()) {
|
||||||
ImGuiPureWrap::begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
ImGuiPureWrap::begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||||
@ -4882,7 +4850,8 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||||||
const bool is_enabled_painted_thumbnail = !model_objects.empty() && !extruders_colors.empty();
|
const bool is_enabled_painted_thumbnail = !model_objects.empty() && !extruders_colors.empty();
|
||||||
|
|
||||||
if (thumbnail_params.transparent_background)
|
if (thumbnail_params.transparent_background)
|
||||||
glsafe(::glClearColor(0.0f, 0.0f, 0.0f, 0.0f));
|
// glsafe(::glClearColor(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
|
glsafe(::glClearColor(0.4f, 0.4f, 0.4f, 0.0f));
|
||||||
|
|
||||||
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
@ -6322,6 +6291,131 @@ void GLCanvas3D::_render_overlays()
|
|||||||
m_labels.render(sorted_instances);
|
m_labels.render(sorted_instances);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define use_scrolling 1
|
||||||
|
|
||||||
|
void Slic3r::GUI::GLCanvas3D::_render_bed_selector()
|
||||||
|
{
|
||||||
|
static float btn_side = 80.f;
|
||||||
|
static float btn_border = 4.f;
|
||||||
|
static bool hide_title = true;
|
||||||
|
|
||||||
|
ImVec2 btn_size = ImVec2(btn_side, btn_side);
|
||||||
|
|
||||||
|
if (s_multiple_beds.get_number_of_beds() != 1 && wxGetApp().plater()->is_preview_shown()) {
|
||||||
|
auto render_bed_button = [btn_size, this](int i)
|
||||||
|
{
|
||||||
|
//ImGui::Text("%d", i);
|
||||||
|
//ImGui::SameLine();
|
||||||
|
|
||||||
|
bool inactive = i != s_multiple_beds.get_active_bed() || s_multiple_beds.is_autoslicing();
|
||||||
|
if (inactive)
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0., 0., 0., .5));
|
||||||
|
if (bool clicked = (i >= int(s_th_tex_id.size()))
|
||||||
|
? ImGui::Button(std::to_string(i).c_str(), btn_size)
|
||||||
|
: ImGui::ImageButton((void*)(int64_t)s_th_tex_id[i], btn_size, ImVec2(0, 1), ImVec2(1, 0));
|
||||||
|
clicked)
|
||||||
|
select_bed(i, true);
|
||||||
|
|
||||||
|
if (inactive)
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
|
std::string status_text;
|
||||||
|
if (wxGetApp().plater()->get_fff_prints()[i]->finished())
|
||||||
|
status_text = "Finished";
|
||||||
|
else if (m_process->fff_print() == wxGetApp().plater()->get_fff_prints()[i].get() && m_process->running())
|
||||||
|
status_text = "Running";
|
||||||
|
else
|
||||||
|
status_text = "Idle";
|
||||||
|
if (ImGui::IsItemHovered())
|
||||||
|
ImGui::SetTooltip(status_text.c_str());
|
||||||
|
};
|
||||||
|
|
||||||
|
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||||
|
float win_x_pos = get_canvas_size().get_width();
|
||||||
|
if (const Preview* preview = dynamic_cast<Preview*>(m_canvas->GetParent()))
|
||||||
|
win_x_pos -= preview->get_layers_slider_width(true);
|
||||||
|
|
||||||
|
#if use_scrolling
|
||||||
|
static float width { 0.f };
|
||||||
|
static float height { 0.f };
|
||||||
|
static float v_pos { 1.f };
|
||||||
|
|
||||||
|
ImGui::SetNextWindowPos({ win_x_pos - imgui.get_style_scaling() * 5.f, v_pos }, ImGuiCond_Always, { 1.f, 0.f });
|
||||||
|
ImGui::SetNextWindowSize({ width, height });
|
||||||
|
#else
|
||||||
|
ImGuiPureWrap::set_next_window_pos(win_x_pos - imgui.get_style_scaling() * 5.f, 1.f, ImGuiCond_Always, 1.f);
|
||||||
|
#endif
|
||||||
|
ImGui::Begin("Bed selector", 0, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar);
|
||||||
|
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.f);
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2());
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(btn_border, btn_border));
|
||||||
|
|
||||||
|
// Disable for now.
|
||||||
|
//if (imgui.image_button(ImGui::SliceAllBtnIcon, "Slice All")) {
|
||||||
|
// if (!s_multiple_beds.is_autoslicing())
|
||||||
|
// s_multiple_beds.start_autoslice([this](int i, bool user) { this->select_bed(i, user); });
|
||||||
|
//}
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, btn_border);
|
||||||
|
|
||||||
|
int beds_num = s_multiple_beds.get_number_of_beds();
|
||||||
|
|
||||||
|
for (int i = 0; i < beds_num; ++i) {
|
||||||
|
render_bed_button(i);
|
||||||
|
if (i < beds_num - 1)
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PopStyleVar(4);
|
||||||
|
|
||||||
|
#if use_scrolling
|
||||||
|
bool extra_frame{ false };
|
||||||
|
|
||||||
|
ImVec2 win_size = ImGui::GetCurrentWindow()->ContentSizeIdeal +
|
||||||
|
ImGui::GetCurrentWindow()->WindowPadding * 2.f +
|
||||||
|
ImGui::GetCurrentWindow()->ScrollbarSizes +
|
||||||
|
ImVec2(0.f, ImGui::GetCurrentWindow()->TitleBarHeight());
|
||||||
|
|
||||||
|
if (!is_approx(height, win_size.y)) {
|
||||||
|
height = win_size.y;
|
||||||
|
wxGetApp().imgui()->set_requires_extra_frame();
|
||||||
|
}
|
||||||
|
|
||||||
|
float max_width = win_x_pos;
|
||||||
|
if (is_legend_shown())
|
||||||
|
max_width -= 400.f; // 400.f is used instead of legend width
|
||||||
|
|
||||||
|
if (max_width < height) {
|
||||||
|
width = win_x_pos - 5.f;
|
||||||
|
|
||||||
|
v_pos = ImGui::GetCurrentWindow()->CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f + 5.f;
|
||||||
|
extra_frame = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (v_pos > 1.f) {
|
||||||
|
v_pos = 1.f;
|
||||||
|
extra_frame = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (win_size.x > max_width) {
|
||||||
|
width = max_width;
|
||||||
|
extra_frame = true;
|
||||||
|
}
|
||||||
|
else if (!is_approx(width, win_size.x)) {
|
||||||
|
width = win_size.x;
|
||||||
|
extra_frame = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extra_frame)
|
||||||
|
wxGetApp().imgui()->set_requires_extra_frame();
|
||||||
|
#endif
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_volumes_for_picking(const Camera& camera) const
|
void GLCanvas3D::_render_volumes_for_picking(const Camera& camera) const
|
||||||
{
|
{
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_clip");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat_clip");
|
||||||
|
@ -1074,6 +1074,7 @@ private:
|
|||||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||||
void _check_and_update_toolbar_icon_scale();
|
void _check_and_update_toolbar_icon_scale();
|
||||||
void _render_overlays();
|
void _render_overlays();
|
||||||
|
void _render_bed_selector();
|
||||||
void _render_volumes_for_picking(const Camera& camera) const;
|
void _render_volumes_for_picking(const Camera& camera) const;
|
||||||
void _render_current_gizmo() const { m_gizmos.render_current_gizmo(); }
|
void _render_current_gizmo() const { m_gizmos.render_current_gizmo(); }
|
||||||
void _render_gizmos_overlay();
|
void _render_gizmos_overlay();
|
||||||
|
@ -348,9 +348,9 @@ float Preview::get_moves_slider_height() const
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Preview::get_layers_slider_width() const
|
float Preview::get_layers_slider_width(bool disregard_visibility) const
|
||||||
{
|
{
|
||||||
if (m_layers_slider && m_layers_slider->IsShown())
|
if (m_layers_slider && (m_layers_slider->IsShown() || disregard_visibility))
|
||||||
return m_layers_slider->GetWidth();
|
return m_layers_slider->GetWidth();
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ public:
|
|||||||
void msw_rescale();
|
void msw_rescale();
|
||||||
|
|
||||||
void render_sliders(GLCanvas3D& canvas);
|
void render_sliders(GLCanvas3D& canvas);
|
||||||
float get_layers_slider_width() const;
|
float get_layers_slider_width(bool disregard_visibility = false) const;
|
||||||
float get_moves_slider_height() const;
|
float get_moves_slider_height() const;
|
||||||
|
|
||||||
bool is_loaded() const { return m_loaded; }
|
bool is_loaded() const { return m_loaded; }
|
||||||
|
@ -112,6 +112,7 @@ static const std::map<const wchar_t, std::string> font_icons = {
|
|||||||
{ImGui::SnapMarker , "snap" },
|
{ImGui::SnapMarker , "snap" },
|
||||||
{ImGui::HorizontalHide , "horizontal_hide" },
|
{ImGui::HorizontalHide , "horizontal_hide" },
|
||||||
{ImGui::HorizontalShow , "horizontal_show" },
|
{ImGui::HorizontalShow , "horizontal_show" },
|
||||||
|
{ImGui::SliceAllBtnIcon , "slice_all" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::map<const wchar_t, std::string> font_icons_large = {
|
static const std::map<const wchar_t, std::string> font_icons_large = {
|
||||||
|
@ -2202,7 +2202,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
|||||||
params.parts_only = true;
|
params.parts_only = true;
|
||||||
params.printable_only = true;
|
params.printable_only = true;
|
||||||
params.show_bed = true;
|
params.show_bed = true;
|
||||||
params.transparent_background = false;
|
params.transparent_background = true;
|
||||||
int w = 100, h = 100;
|
int w = 100, h = 100;
|
||||||
|
|
||||||
int curr_bound_texture = 0;
|
int curr_bound_texture = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user