Tech ENABLE_PREVIEW_LAYOUT - Added menu item View/Show legend

This commit is contained in:
enricoturri1966 2021-10-14 11:30:27 +02:00
parent fe1c5f34a0
commit 0d922b04af
6 changed files with 39 additions and 6 deletions

View File

@ -2425,11 +2425,13 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
case 'L':
case 'l': {
if (!m_main_toolbar.is_enabled()) {
#if ENABLE_PREVIEW_LAYOUT
show_legend(!is_legend_shown());
#else
m_gcode_viewer.enable_legend(!m_gcode_viewer.is_legend_enabled());
m_dirty = true;
#if !ENABLE_PREVIEW_LAYOUT
wxGetApp().plater()->update_preview_bottom_toolbar();
#endif // !ENABLE_PREVIEW_LAYOUT
#endif // ENABLE_PREVIEW_LAYOUT
}
break;
}

View File

@ -820,6 +820,11 @@ public:
bool are_labels_shown() const { return m_labels.is_shown(); }
void show_labels(bool show) { m_labels.show(show); }
#if ENABLE_PREVIEW_LAYOUT
bool is_legend_shown() const { return m_gcode_viewer.is_legend_enabled(); }
void show_legend(bool show) { m_gcode_viewer.enable_legend(show); m_dirty = true; }
#endif // ENABLE_PREVIEW_LAYOUT
bool is_using_slope() const { return m_slope.is_used(); }
void use_slope(bool use) { m_slope.use(use); }
void set_slope_normal_angle(float angle_in_deg) { m_slope.set_normal_angle(angle_in_deg); }

View File

@ -223,7 +223,7 @@ void KBShortcutsDialog::fill_shortcuts()
{ "A", L("Horizontal slider - Move active thumb Left") },
{ "D", L("Horizontal slider - Move active thumb Right") },
{ "X", L("On/Off one layer mode of the vertical slider") },
{ "L", L("Show/Hide Legend and Estimated printing time") },
{ "L", L("Show/Hide legend") },
{ "C", L("Show/Hide G-code window") },
};

View File

@ -1433,6 +1433,11 @@ void MainFrame::init_menubar_as_editor()
append_menu_check_item(viewMenu, wxID_ANY, _L("Show &labels") + sep + "E", _L("Show object/instance labels in 3D scene"),
[this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); }, this,
[this]() { return m_plater->is_view3D_shown(); }, [this]() { return m_plater->are_view3D_labels_shown(); }, this);
#if ENABLE_PREVIEW_LAYOUT
append_menu_check_item(viewMenu, wxID_ANY, _L("Show legen&d") + sep + "L", _L("Show legend in preview"),
[this](wxCommandEvent&) { m_plater->show_legend(!m_plater->is_legend_shown()); }, this,
[this]() { return m_plater->is_preview_shown(); }, [this]() { return m_plater->is_legend_shown(); }, this);
#endif // ENABLE_PREVIEW_LAYOUT
append_menu_check_item(viewMenu, wxID_ANY, _L("&Collapse sidebar") + sep + "Shift+" + sep_space + "Tab", _L("Collapse sidebar"),
[this](wxCommandEvent&) { m_plater->collapse_sidebar(!m_plater->is_sidebar_collapsed()); }, this,
[]() { return true; }, [this]() { return m_plater->is_sidebar_collapsed(); }, this);
@ -1550,6 +1555,12 @@ void MainFrame::init_menubar_as_gcodeviewer()
if (m_plater != nullptr) {
viewMenu = new wxMenu();
add_common_view_menu_items(viewMenu, this, std::bind(&MainFrame::can_change_view, this));
#if ENABLE_PREVIEW_LAYOUT
viewMenu->AppendSeparator();
append_menu_check_item(viewMenu, wxID_ANY, _L("Show legen&d") + sep + "L", _L("Show legend"),
[this](wxCommandEvent&) { m_plater->show_legend(!m_plater->is_legend_shown()); }, this,
[this]() { return m_plater->is_preview_shown(); }, [this]() { return m_plater->is_legend_shown(); }, this);
#endif // ENABLE_PREVIEW_LAYOUT
}
// helpmenu

View File

@ -1667,6 +1667,11 @@ struct Plater::priv
bool are_view3D_labels_shown() const { return (current_panel == view3D) && view3D->get_canvas3d()->are_labels_shown(); }
void show_view3D_labels(bool show) { if (current_panel == view3D) view3D->get_canvas3d()->show_labels(show); }
#if ENABLE_PREVIEW_LAYOUT
bool is_legend_shown() const { return (current_panel == preview) && preview->get_canvas3d()->is_legend_shown(); }
void show_legend(bool show) { if (current_panel == preview) preview->get_canvas3d()->show_legend(show); }
#endif // ENABLE_PREVIEW_LAYOUT
bool is_sidebar_collapsed() const { return sidebar->is_collapsed(); }
void collapse_sidebar(bool collapse);
@ -5410,6 +5415,11 @@ bool Plater::is_view3D_shown() const { return p->is_view3D_shown(); }
bool Plater::are_view3D_labels_shown() const { return p->are_view3D_labels_shown(); }
void Plater::show_view3D_labels(bool show) { p->show_view3D_labels(show); }
#if ENABLE_PREVIEW_LAYOUT
bool Plater::is_legend_shown() const { return p->is_legend_shown(); }
void Plater::show_legend(bool show) { p->show_legend(show); }
#endif // ENABLE_PREVIEW_LAYOUT
bool Plater::is_sidebar_collapsed() const { return p->is_sidebar_collapsed(); }
void Plater::collapse_sidebar(bool show) { p->collapse_sidebar(show); }

View File

@ -187,6 +187,11 @@ public:
bool are_view3D_labels_shown() const;
void show_view3D_labels(bool show);
#if ENABLE_PREVIEW_LAYOUT
bool is_legend_shown() const;
void show_legend(bool show);
#endif // ENABLE_PREVIEW_LAYOUT
bool is_sidebar_collapsed() const;
void collapse_sidebar(bool show);