Tech ENABLE_SCROLLABLE_LEGEND -> 1st installment of scrollable legend
This commit is contained in:
parent
96447de1d4
commit
ddf59a4a8c
4 changed files with 196 additions and 137 deletions
src
|
@ -59,6 +59,8 @@
|
|||
#define ENABLE_EXTENDED_M73_LINES (1 && ENABLE_VALIDATE_CUSTOM_GCODE)
|
||||
// Enable a modified version of automatic downscale on load of objects too big
|
||||
#define ENABLE_MODIFIED_DOWNSCALE_ON_LOAD_OBJECTS_TOO_BIG (1 && ENABLE_2_4_0_ALPHA0)
|
||||
// Enable scrollable legend in preview
|
||||
#define ENABLE_SCROLLABLE_LEGEND (1 && ENABLE_2_4_0_ALPHA0)
|
||||
// Enable visualization of start gcode as regular toolpaths
|
||||
#define ENABLE_START_GCODE_VISUALIZATION (1 && ENABLE_2_4_0_ALPHA0)
|
||||
// Enable visualization of seams in preview
|
||||
|
|
|
@ -4051,14 +4051,23 @@ void GCodeViewer::render_legend() const
|
|||
if (!m_legend_enabled)
|
||||
return;
|
||||
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
|
||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
|
||||
imgui.set_next_window_pos(0.0f, 0.0f, ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::SetNextWindowBgAlpha(0.6f);
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
float child_height = 0.2222f * static_cast<float>(cnv_size.get_height());
|
||||
imgui.begin(std::string("Legend"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove);
|
||||
#else
|
||||
imgui.begin(std::string("Legend"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove);
|
||||
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
|
||||
enum class EItemType : unsigned char
|
||||
{
|
||||
|
@ -4069,15 +4078,27 @@ void GCodeViewer::render_legend() const
|
|||
};
|
||||
|
||||
const PrintEstimatedTimeStatistics::Mode& time_mode = m_time_statistics.modes[static_cast<size_t>(m_time_estimate_mode)];
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
bool show_estimated_time = time_mode.time > 0.0f && (m_view_type == EViewType::FeatureType ||
|
||||
(m_view_type == EViewType::ColorPrint && !time_mode.custom_gcode_times.empty()));
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
|
||||
float icon_size = ImGui::GetTextLineHeight();
|
||||
float percent_bar_size = 2.0f * ImGui::GetTextLineHeight();
|
||||
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
auto append_item = [this, icon_size, percent_bar_size, &imgui](EItemType type, const Color& color, const std::string& label,
|
||||
#else
|
||||
auto append_item = [this, draw_list, icon_size, percent_bar_size, &imgui](EItemType type, const Color& color, const std::string& label,
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
bool visible = true, const std::string& time = "", float percent = 0.0f, float max_percent = 0.0f, const std::array<float, 2>& offsets = { 0.0f, 0.0f },
|
||||
std::function<void()> callback = nullptr) {
|
||||
if (!visible)
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.3333f);
|
||||
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
ImVec2 pos = ImGui::GetCursorScreenPos();
|
||||
switch (type) {
|
||||
default:
|
||||
|
@ -4341,6 +4362,10 @@ void GCodeViewer::render_legend() const
|
|||
}
|
||||
case EViewType::ColorPrint:
|
||||
{
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
// add scrollable region
|
||||
if (ImGui::BeginChild("color_prints", { -1.0f, child_height }, false)) {
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
const std::vector<CustomGCode::Item>& custom_gcode_per_print_z = wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes;
|
||||
if (m_extruders_count == 1) { // single extruder use case
|
||||
std::vector<std::pair<Color, std::pair<double, double>>> cp_values = color_print_ranges(0, custom_gcode_per_print_z);
|
||||
|
@ -4392,6 +4417,10 @@ void GCodeViewer::render_legend() const
|
|||
}
|
||||
}
|
||||
}
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
}
|
||||
ImGui::EndChild();
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -4518,6 +4547,10 @@ void GCodeViewer::render_legend() const
|
|||
|
||||
ImGui::Spacing();
|
||||
append_headers({ _u8L("Event"), _u8L("Remaining time"), _u8L("Duration") }, offsets);
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
// add scrollable region
|
||||
if (ImGui::BeginChild("events", { -1.0f, child_height }, false)) {
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
for (const PartialTime& item : partial_times) {
|
||||
switch (item.type)
|
||||
{
|
||||
|
@ -4537,6 +4570,11 @@ void GCodeViewer::render_legend() const
|
|||
}
|
||||
}
|
||||
}
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
}
|
||||
ImGui::EndChild();
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4680,10 +4718,14 @@ void GCodeViewer::render_legend() const
|
|||
}
|
||||
|
||||
// total estimated printing time section
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
if (show_estimated_time) {
|
||||
#else
|
||||
if (time_mode.time > 0.0f && (m_view_type == EViewType::FeatureType ||
|
||||
(m_view_type == EViewType::ColorPrint && !time_mode.custom_gcode_times.empty()))) {
|
||||
|
||||
ImGui::Spacing();
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
ImGui::Spacing();
|
||||
ImGui::PushStyleColor(ImGuiCol_Separator, { 1.0f, 1.0f, 1.0f, 1.0f });
|
||||
ImGui::Separator();
|
||||
|
|
|
@ -4780,8 +4780,16 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
|||
if (m_canvas == nullptr && m_context == nullptr)
|
||||
return;
|
||||
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
const std::array<unsigned int, 2> new_size = { w, h };
|
||||
if (m_old_size == new_size)
|
||||
return;
|
||||
|
||||
m_old_size = new_size;
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
|
||||
auto *imgui = wxGetApp().imgui();
|
||||
imgui->set_display_size((float)w, (float)h);
|
||||
imgui->set_display_size(static_cast<float>(w), static_cast<float>(h));
|
||||
const float font_size = 1.5f * wxGetApp().em_unit();
|
||||
#if ENABLE_RETINA_GL
|
||||
imgui->set_scaling(font_size, 1.0f, m_retina_helper->get_scale_factor());
|
||||
|
@ -4789,6 +4797,10 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
|||
imgui->set_scaling(font_size, m_canvas->GetContentScaleFactor(), 1.0f);
|
||||
#endif
|
||||
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
this->request_extra_frame();
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
|
||||
// ensures that this canvas is current
|
||||
_set_current();
|
||||
}
|
||||
|
@ -4829,8 +4841,7 @@ void GLCanvas3D::_update_camera_zoom(double zoom)
|
|||
|
||||
void GLCanvas3D::_refresh_if_shown_on_screen()
|
||||
{
|
||||
if (_is_shown_on_screen())
|
||||
{
|
||||
if (_is_shown_on_screen()) {
|
||||
const Size& cnv_size = get_canvas_size();
|
||||
_resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
|
||||
|
||||
|
|
|
@ -474,6 +474,10 @@ private:
|
|||
Model* m_model;
|
||||
BackgroundSlicingProcess *m_process;
|
||||
|
||||
#if ENABLE_SCROLLABLE_LEGEND
|
||||
std::array<unsigned int, 2> m_old_size{ 0, 0 };
|
||||
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||
|
||||
// Screen is only refreshed from the OnIdle handler if it is dirty.
|
||||
bool m_dirty;
|
||||
bool m_initialized;
|
||||
|
|
Loading…
Add table
Reference in a new issue