From 910f95f01a66635045f3e781d90fcea39249a5fe Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Tue, 15 May 2018 22:26:39 -0500 Subject: [PATCH] added info box --- src/GUI/Plater.cpp | 63 ++++++++++++++++++++++++++++++++++++++++----- src/GUI/Plater.hpp | 29 +++++++++++++++++++++ src/GUI/misc_ui.hpp | 4 +++ 3 files changed, 90 insertions(+), 6 deletions(-) diff --git a/src/GUI/Plater.cpp b/src/GUI/Plater.cpp index ce68fdfde..bb0898532 100644 --- a/src/GUI/Plater.cpp +++ b/src/GUI/Plater.cpp @@ -144,8 +144,63 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptrSetMinSize(wxSize(350, -1)); + { + auto* sizer {new wxBoxSizer(wxHORIZONTAL)}; + object_info_sizer->Add(sizer, 0, wxEXPAND | wxBOTTOM, 5); + auto* text {new wxStaticText(this, wxID_ANY, _("Object:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)}; + text->SetFont(small_font); + sizer->Add(text, 0, wxALIGN_CENTER_VERTICAL); + /* We supply a bogus width to wxChoice (sizer will override it and stretch + * the control anyway), because if we leave the default (-1) it will stretch + * too much according to the contents, and this is bad with long file names. + */ + this->object_info.choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(100, -1)); + this->object_info.choice->SetFont(small_font); + sizer->Add(this->object_info.choice, 1, wxALIGN_CENTER_VERTICAL); + // Select object on change. + this->Bind(wxEVT_CHOICE, [this](wxCommandEvent& e) { this->select_object(this->object_info.choice->GetSelection()); this->refresh_canvases();}); + + } + + auto* grid_sizer { new wxFlexGridSizer(3, 4, 5, 5)}; + grid_sizer->SetFlexibleDirection(wxHORIZONTAL); + grid_sizer->AddGrowableCol(1, 1); + grid_sizer->AddGrowableCol(3, 1); + + add_info_field(this, this->object_info.copies, _("Copies"), grid_sizer); + add_info_field(this, this->object_info.size, _("Size"), grid_sizer); + add_info_field(this, this->object_info.volume, _("Volume"), grid_sizer); + add_info_field(this, this->object_info.facets, _("Facets"), grid_sizer); + add_info_field(this, this->object_info.materials, _("Materials"), grid_sizer); + { + wxString name {"Manifold:"}; + auto* text {new wxStaticText(parent, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)}; + text->SetFont(small_font); + grid_sizer->Add(text, 0); + + this->object_info.manifold = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + this->object_info.manifold->SetFont(small_font); + + this->object_info.manifold_warning_icon = new wxStaticBitmap(this, wxID_ANY, wxBitmap(var("error.png"), wxBITMAP_TYPE_PNG)); + this->object_info.manifold_warning_icon->Hide(); + + auto* h_sizer {new wxBoxSizer(wxHORIZONTAL)}; + h_sizer->Add(this->object_info.manifold_warning_icon, 0); + h_sizer->Add(this->object_info.manifold, 0); + + grid_sizer->Add(h_sizer, 0, wxEXPAND); + } + + object_info_sizer->Add(grid_sizer, 0, wxEXPAND); + } + this->selection_changed(); this->canvas2D->update_bed_size(); // Toolbar @@ -156,10 +211,11 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptrright_sizer; + auto* right_sizer {this->right_sizer}; // $right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; // $right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5); // $right_sizer->Add($self->{settings_override_panel}, 1, wxEXPAND, 5); + right_sizer->Add(object_info_sizer, 0, wxEXPAND, 0); // $right_sizer->Add($object_info_sizer, 0, wxEXPAND, 0); // $right_sizer->Add($print_info_sizer, 0, wxEXPAND, 0); // $right_sizer->Hide($print_info_sizer); @@ -524,11 +580,6 @@ void Plater::selection_changed() { $self->{"btn_$_"}->$method for grep $self->{"btn_$_"}, qw(remove increase decrease rotate45cw rotate45ccw changescale split cut layers settings); - if ($self->{htoolbar}) { - $self->{htoolbar}->EnableTool($_, $have_sel) - for (TB_REMOVE, TB_MORE, TB_FEWER, TB_45CW, TB_45CCW, TB_SCALE, TB_SPLIT, TB_CUT, TB_LAYERS, TB_SETTINGS); - } - if ($self->{object_info_size}) { # have we already loaded the info pane? if ($have_sel) { diff --git a/src/GUI/Plater.hpp b/src/GUI/Plater.hpp index aafad916e..288764702 100644 --- a/src/GUI/Plater.hpp +++ b/src/GUI/Plater.hpp @@ -15,6 +15,7 @@ #include "Model.hpp" #include "Print.hpp" #include "Config.hpp" +#include "misc_ui.hpp" #include "Plater/PlaterObject.hpp" #include "Plater/Plate2D.hpp" @@ -46,6 +47,18 @@ class PlaterObject; class Plate2D; class MainFrame; +/// Struct to group object info text fields together +struct info_fields { + wxChoice* choice {nullptr}; + wxStaticText* copies {nullptr}; + wxStaticText* size {nullptr}; + wxStaticText* volume {nullptr}; + wxStaticText* facets {nullptr}; + wxStaticText* materials {nullptr}; + wxStaticText* manifold {nullptr}; + wxStaticBitmap* manifold_warning_icon {nullptr}; +}; + /// Extension of wxPanel class to handle the main plater. /// 2D, 3D, preview, etc tabs. class Plater : public wxPanel @@ -125,6 +138,8 @@ private: PreviewDLP* previewDLP {nullptr}; //< DLP/SLA Preview canvas + wxStaticBoxSizer* object_info_size {nullptr}; + /// Handles the actual load of the file from the dialog handoff. std::vector load_file(const std::string file, const int obj_idx_to_load = -1); @@ -223,9 +238,23 @@ private: void center_selected_object_on_bed(); void set_number_of_copies(); + + /// Struct containing various object info fields. + info_fields object_info; }; +template +static void add_info_field(wxWindow* parent, T*& field, wxString name, wxGridSizer* sizer) { + name << ":"; + auto* text {new wxStaticText(parent, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT)}; + text->SetFont(small_font); + sizer->Add(text, 0); + + field = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + field->SetFont(small_font); + sizer->Add(field, 0); +} } } // Namespace Slic3r::GUI diff --git a/src/GUI/misc_ui.hpp b/src/GUI/misc_ui.hpp index dedfa8e4f..40b3b4b81 100644 --- a/src/GUI/misc_ui.hpp +++ b/src/GUI/misc_ui.hpp @@ -6,6 +6,7 @@ #include #endif +#include #include #include #include @@ -50,6 +51,9 @@ constexpr bool isDev = false; constexpr bool threaded = false; +const wxFont small_font { wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; + + // hopefully the compiler is smart enough to figure this out const std::map FILE_WILDCARDS { std::make_pair("known", "Known files (*.stl, *.obj, *.amf, *.xml, *.3mf)|*.3mf;*.3MF;*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML"),