Tech ENABLE_PREVIEW_LAYOUT - A few fixes in the new legend layout

This commit is contained in:
enricoturri1966 2021-09-14 10:32:17 +02:00
parent 7f89a42be6
commit cddfc8b690
5 changed files with 45 additions and 18 deletions

View file

@ -3346,21 +3346,26 @@ void GCodeViewer::render_legend(float& legend_height)
#if ENABLE_PREVIEW_LAYOUT
// selection section
bool selection_changed = false;
int view_type = static_cast<int>(get_view_type());
int old_view_type = view_type;
if (imgui.combo("", { _u8L("Feature type"),
_u8L("Height (mm)"),
_u8L("Width (mm)"),
_u8L("Speed (mm/s)"),
_u8L("Fan speed (%)"),
_u8L("Temperature (°C)"),
_u8L("Volumetric flow rate (mm³/s)"),
_u8L("Tool"),
_u8L("Color Print") }, view_type)) {
bool view_type_changed = false;
int old_view_type = static_cast<int>(get_view_type());
int view_type = old_view_type;
ImGuiStyle& style = ImGui::GetStyle();
ImGui::PushItemWidth(ImGui::GetWindowWidth() - style.ItemSpacing.x - 2.0f * style.FramePadding.x);
imgui.combo("", { _u8L("Feature type"),
_u8L("Height (mm)"),
_u8L("Width (mm)"),
_u8L("Speed (mm/s)"),
_u8L("Fan speed (%)"),
_u8L("Temperature (°C)"),
_u8L("Volumetric flow rate (mm³/s)"),
_u8L("Tool"),
_u8L("Color Print") }, view_type);
if (old_view_type != view_type) {
set_view_type(static_cast<EViewType>(view_type));
wxGetApp().plater()->set_keep_current_preview_type(true);
wxGetApp().plater()->refresh_print();
selection_changed = old_view_type != view_type;
view_type_changed = true;
}
// extrusion paths section -> title
@ -3394,7 +3399,7 @@ void GCodeViewer::render_legend(float& legend_height)
#endif // ENABLE_PREVIEW_LAYOUT
#if ENABLE_PREVIEW_LAYOUT
if (!selection_changed) {
if (!view_type_changed) {
#endif // ENABLE_PREVIEW_LAYOUT
// extrusion paths section -> items
switch (m_view_type)

View file

@ -993,13 +993,21 @@ void Preview::load_print_as_fff(bool keep_z_range)
std::vector<Item> gcodes = wxGetApp().is_editor() ?
wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes :
m_canvas->get_custom_gcode_per_print_z();
#if ENABLE_PREVIEW_LAYOUT
const GCodeViewer::EViewType choice = !gcodes.empty() ?
GCodeViewer::EViewType::ColorPrint :
(number_extruders > 1) ? GCodeViewer::EViewType::Tool : GCodeViewer::EViewType::FeatureType;
if (choice != gcode_view_type) {
m_canvas->set_gcode_view_preview_type(choice);
if (wxGetApp().is_gcode_viewer()) {
m_keep_current_preview_type = true;
refresh_print();
}
}
#else
const wxString choice = !gcodes.empty() ?
_L("Color Print") :
(number_extruders > 1) ? _L("Tool") : _L("Feature type");
#if ENABLE_PREVIEW_LAYOUT
GCodeViewer::EViewType view_type = m_canvas->get_gcode_view_type();
#else
int type = m_choice_view_type->FindString(choice);
if (m_choice_view_type->GetSelection() != type) {
if (0 <= type && type < static_cast<int>(GCodeViewer::EViewType::Count)) {

View file

@ -164,6 +164,10 @@ public:
void move_moves_slider(wxKeyEvent& evt);
void hide_layers_slider();
#if ENABLE_PREVIEW_LAYOUT
void set_keep_current_preview_type(bool value) { m_keep_current_preview_type = value; }
#endif // ENABLE_PREVIEW_LAYOUT
private:
bool init(wxWindow* parent, Model* model);

View file

@ -6606,6 +6606,12 @@ bool Plater::is_render_statistic_dialog_visible() const
return p->show_render_statistic_dialog;
}
#if ENABLE_PREVIEW_LAYOUT
void Plater::set_keep_current_preview_type(bool value)
{
p->preview->set_keep_current_preview_type(value);
}
#endif // ENABLE_PREVIEW_LAYOUT
Plater::TakeSnapshot::TakeSnapshot(Plater *plater, const std::string &snapshot_name)
: TakeSnapshot(plater, from_u8(snapshot_name)) {}

View file

@ -403,6 +403,10 @@ public:
void toggle_render_statistic_dialog();
bool is_render_statistic_dialog_visible() const;
#if ENABLE_PREVIEW_LAYOUT
void set_keep_current_preview_type(bool value);
#endif // ENABLE_PREVIEW_LAYOUT
// Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition);
bool PopupMenu(wxMenu *menu, int x, int y) { return this->PopupMenu(menu, wxPoint(x, y)); }