Merge remote-tracking branch 'origin/ys_dev_native' into dev_native

This commit is contained in:
YuSanka 2018-10-09 12:44:32 +02:00
commit 1b93b952a2
8 changed files with 93 additions and 58 deletions

View file

@ -132,7 +132,8 @@ void MainFrame::init_tabpanel()
m_tabpanel->AddPage(m_plater, _(L("Plater"))); m_tabpanel->AddPage(m_plater, _(L("Plater")));
} }
// The following event is emited by the C++ Tab implementation on config value change. // The following event is emited by Tab implementation on config value change.
Bind(EVT_TAB_VALUE_CHANGED, &MainFrame::on_value_changed, this);
// EVT_COMMAND($self, -1, $VALUE_CHANGE_EVENT, sub { // EVT_COMMAND($self, -1, $VALUE_CHANGE_EVENT, sub {
// my($self, $event) = @_; // my($self, $event) = @_;
// auto str = event->GetString; // auto str = event->GetString;
@ -145,10 +146,6 @@ void MainFrame::init_tabpanel()
// auto value = event->GetInt(); // auto value = event->GetInt();
// m_plater->on_extruders_change(value); // m_plater->on_extruders_change(value);
// } // }
// if (opt_key == "printer_technology"){
// auto value = event->GetInt(); // 0 ~"ptFFF"; 1 ~"ptSLA"
// m_plater->show_preset_comboboxes(value);
// }
// } // }
// // don't save while loading for the first time // // don't save while loading for the first time
// if (Slic3r::GUI::autosave && m_loaded) // if (Slic3r::GUI::autosave && m_loaded)
@ -759,21 +756,14 @@ void MainFrame::on_presets_changed(SimpleEvent &event)
auto reload_dependent_tabs = tab->get_dependent_tabs(); auto reload_dependent_tabs = tab->get_dependent_tabs();
// FIXME: The preset type really should be a property of Tab instead // FIXME: The preset type really should be a property of Tab instead
Slic3r::Preset::Type preset_type; Slic3r::Preset::Type preset_type = tab->type();
if (tab == m_options_tabs["print"]) { preset_type = Slic3r::Preset::TYPE_PRINT; } if (preset_type == Slic3r::Preset::TYPE_INVALID){
else if (tab == m_options_tabs["filament"]) { preset_type = Slic3r::Preset::TYPE_FILAMENT; }
else if (tab == m_options_tabs["sla_material"]) { preset_type = Slic3r::Preset::TYPE_SLA_MATERIAL; }
else if (tab == m_options_tabs["printer"]) { preset_type = Slic3r::Preset::TYPE_PRINTER; }
else {
wxASSERT(false); wxASSERT(false);
return; return;
} }
m_plater->sidebar().update_presets(preset_type); m_plater->sidebar().update_presets(preset_type);
// XXX: ???
// m_plater->{"selected_item_$tab_name"} = tab->get_selected_preset_item();
if (preset_type == Slic3r::Preset::TYPE_PRINTER) { if (preset_type == Slic3r::Preset::TYPE_PRINTER) {
// Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors. // Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors.
// XXX: Do this in a more C++ way // XXX: Do this in a more C++ way
@ -789,12 +779,18 @@ void MainFrame::on_presets_changed(SimpleEvent &event)
else else
cur_tab->load_current_preset(); cur_tab->load_current_preset();
} }
m_plater->sidebar().show_preset_comboboxes(static_cast<TabPrinter*>(tab)->m_printer_technology == ptSLA);
} }
// XXX: ? // XXX: ?
// m_plater->on_config_change(tab->get_config()); // m_plater->on_config_change(tab->get_config());
} }
} }
void MainFrame::on_value_changed(wxCommandEvent&)
{
;
}
// Called after the Preferences dialog is closed and the program settings are saved. // Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences. // Update the UI based on the current preferences.
void MainFrame::update_ui_from_settings() void MainFrame::update_ui_from_settings()

View file

@ -73,6 +73,7 @@ class MainFrame : public wxFrame
std::string get_dir_name(const wxString full_name) const ; std::string get_dir_name(const wxString full_name) const ;
void on_presets_changed(SimpleEvent&); void on_presets_changed(SimpleEvent&);
void on_value_changed(wxCommandEvent&);
Tab* get_tab(const std::string& name); Tab* get_tab(const std::string& name);
public: public:

View file

@ -169,21 +169,6 @@ SlicedInfo::SlicedInfo(wxWindow *parent) :
Add(grid_sizer, 0, wxEXPAND); Add(grid_sizer, 0, wxEXPAND);
} }
class PresetComboBox : public wxBitmapComboBox
{
public:
PresetComboBox(wxWindow *parent, Preset::Type preset_type);
~PresetComboBox();
private:
typedef std::size_t Marker;
enum { LABEL_ITEM_MARKER = 0x4d };
Preset::Type preset_type;
int last_selected;
};
PresetComboBox::PresetComboBox(wxWindow *parent, Preset::Type preset_type) : PresetComboBox::PresetComboBox(wxWindow *parent, Preset::Type preset_type) :
wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY), wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY),
preset_type(preset_type), preset_type(preset_type),
@ -199,6 +184,7 @@ PresetComboBox::PresetComboBox(wxWindow *parent, Preset::Type preset_type) :
} else if (this->last_selected != selected_item) { } else if (this->last_selected != selected_item) {
this->last_selected = selected_item; this->last_selected = selected_item;
evt.SetInt(this->preset_type); evt.SetInt(this->preset_type);
evt.Skip();
} else { } else {
evt.StopPropagation(); evt.StopPropagation();
} }
@ -208,6 +194,11 @@ PresetComboBox::PresetComboBox(wxWindow *parent, Preset::Type preset_type) :
PresetComboBox::~PresetComboBox() {} PresetComboBox::~PresetComboBox() {}
void PresetComboBox::set_label_marker(int item)
{
this->SetClientData(item, (void*)LABEL_ITEM_MARKER);
}
// Frequently changed parameters // Frequently changed parameters
class FreqChangedParams : public OG_Settings class FreqChangedParams : public OG_Settings
@ -521,6 +512,22 @@ void Sidebar::update_presets(Preset::Type preset_type)
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
} }
void Sidebar::show_preset_comboboxes(bool showSLA)
{
// wxWindowUpdateLocker noUpdates(wxGetApp().mainframe);
for (size_t i = 0; i < 4; ++i)
p->sizer_presets->Show(i, !showSLA);
p->sizer_presets->Show(4, showSLA);
p->sizer_presets->Show(5, showSLA);
p->frequently_changed_parameters->get_sizer()->Show(!showSLA);
wxGetApp().plater()->Layout();
wxGetApp().mainframe->Layout();
}
ObjectManipulation* Sidebar::obj_manipul() ObjectManipulation* Sidebar::obj_manipul()
{ {
return p->object_manipulation; return p->object_manipulation;
@ -579,6 +586,11 @@ void Sidebar::enable_buttons(bool enable)
p->btn_send_gcode->Enable(enable); p->btn_send_gcode->Enable(enable);
} }
bool Sidebar::is_multifilament()
{
return p->combos_filament.size() > 0;
}
// Plater::Object // Plater::Object
struct PlaterObject struct PlaterObject
@ -1444,26 +1456,29 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
auto preset_type = static_cast<Preset::Type>(evt.GetInt()); auto preset_type = static_cast<Preset::Type>(evt.GetInt());
auto *combo = static_cast<wxBitmapComboBox*>(evt.GetEventObject()); auto *combo = static_cast<wxBitmapComboBox*>(evt.GetEventObject());
auto idx = 0;// evt.GetId();
if (preset_type == Preset::TYPE_FILAMENT) { if (preset_type == Preset::TYPE_FILAMENT) {
// FIXME: wxGetApp().preset_bundle->set_filament_preset(idx, combo->GetStringSelection().ToStdString());
// wxTheApp->{preset_bundle}->set_filament_preset($idx, $choice->GetStringSelection);
} }
// TODO: ? // TODO: ?
if (false) { if (preset_type == Preset::TYPE_FILAMENT && sidebar->is_multifilament()) {
// if ($group eq 'filament' && @{$self->{preset_choosers}{filament}} > 1) { // Only update the platter UI for the 2nd and other filaments.
// # Only update the platter UI for the 2nd and other filaments. wxGetApp().preset_bundle->update_platter_filament_ui(idx, combo);
// wxTheApp->{preset_bundle}->update_platter_filament_ui($idx, $choice);
// } // }
} else { } else {
auto selected_item = combo->GetSelection(); for (Tab* tab : wxGetApp().tabs_list) {
if (tab->type() == preset_type) {
// TODO: Handle by an event handler in MainFrame, if needed tab->select_preset(combo->GetStringSelection().ToStdString());
break;
}
}
} }
// Synchronize config.ini with the current selections.
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
// TODO: // TODO:
// # Synchronize config.ini with the current selections.
// wxTheApp->{preset_bundle}->export_selections(wxTheApp->{app_config});
// # get new config and generate on_config_change() event for updating plater and other things // # get new config and generate on_config_change() event for updating plater and other things
// $self->on_config_change(wxTheApp->{preset_bundle}->full_config); // $self->on_config_change(wxTheApp->{preset_bundle}->full_config);
} }

View file

@ -6,6 +6,7 @@
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/bmpcbox.h>
#include "Preset.hpp" #include "Preset.hpp"
@ -27,6 +28,22 @@ using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>;
class Plater; class Plater;
class PresetComboBox : public wxBitmapComboBox
{
public:
PresetComboBox(wxWindow *parent, Preset::Type preset_type);
~PresetComboBox();
void set_label_marker(int item);
private:
typedef std::size_t Marker;
enum { LABEL_ITEM_MARKER = 0x4d };
Preset::Type preset_type;
int last_selected;
};
class Sidebar : public wxPanel class Sidebar : public wxPanel
{ {
public: public:
@ -38,8 +55,9 @@ public:
~Sidebar(); ~Sidebar();
void update_presets(Slic3r::Preset::Type preset_type); void update_presets(Slic3r::Preset::Type preset_type);
void show_preset_comboboxes(bool showSLA);
ObjectManipulation* obj_manipul(); ObjectManipulation* obj_manipul();
ObjectList* obj_list(); ObjectList* obj_list();
ConfigOptionsGroup* og_freq_chng_params(); ConfigOptionsGroup* og_freq_chng_params();
@ -49,6 +67,7 @@ public:
void show_info_sizers(const bool show); void show_info_sizers(const bool show);
void show_buttons(const bool show); void show_buttons(const bool show);
void enable_buttons(bool enable); void enable_buttons(bool enable);
bool is_multifilament();
private: private:
struct priv; struct priv;

View file

@ -28,6 +28,7 @@
#include "../../libslic3r/libslic3r.h" #include "../../libslic3r/libslic3r.h"
#include "../../libslic3r/Utils.hpp" #include "../../libslic3r/Utils.hpp"
#include "../../libslic3r/PlaceholderParser.hpp" #include "../../libslic3r/PlaceholderParser.hpp"
#include "Plater.hpp"
using boost::property_tree::ptree; using boost::property_tree::ptree;
@ -734,7 +735,7 @@ size_t PresetCollection::update_compatible_with_printer_internal(const Preset &a
// Update the wxChoice UI component from this list of presets. // Update the wxChoice UI component from this list of presets.
// Hide the // Hide the
void PresetCollection::update_platter_ui(wxBitmapComboBox *ui) void PresetCollection::update_platter_ui(GUI::PresetComboBox *ui)
{ {
if (ui == nullptr) if (ui == nullptr)
return; return;
@ -751,7 +752,7 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui)
std::map<wxString, wxBitmap*> nonsys_presets; std::map<wxString, wxBitmap*> nonsys_presets;
wxString selected = ""; wxString selected = "";
if (!this->m_presets.front().is_visible) if (!this->m_presets.front().is_visible)
ui->Append("------- " +_(L("System presets")) + " -------", wxNullBitmap); ui->set_label_marker(ui->Append("------- " + _(L("System presets")) + " -------", wxNullBitmap));
for (size_t i = this->m_presets.front().is_visible ? 0 : m_num_default_presets; i < this->m_presets.size(); ++i) { for (size_t i = this->m_presets.front().is_visible ? 0 : m_num_default_presets; i < this->m_presets.size(); ++i) {
const Preset &preset = this->m_presets[i]; const Preset &preset = this->m_presets[i];
if (! preset.is_visible || (! preset.is_compatible && i != m_idx_selected)) if (! preset.is_visible || (! preset.is_compatible && i != m_idx_selected))
@ -791,11 +792,11 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui)
selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()); selected = wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str());
} }
if (i + 1 == m_num_default_presets) if (i + 1 == m_num_default_presets)
ui->Append("------- " + _(L("System presets")) + " -------", wxNullBitmap); ui->set_label_marker(ui->Append("------- " + _(L("System presets")) + " -------", wxNullBitmap));
} }
if (!nonsys_presets.empty()) if (!nonsys_presets.empty())
{ {
ui->Append("------- " + _(L("User presets")) + " -------", wxNullBitmap); ui->set_label_marker(ui->Append("------- " + _(L("User presets")) + " -------", wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
ui->Append(it->first, *it->second); ui->Append(it->first, *it->second);
if (it->first == selected) if (it->first == selected)

View file

@ -22,6 +22,7 @@ class PresetBundle;
namespace GUI { namespace GUI {
class BitmapCache; class BitmapCache;
class PresetComboBox;
} }
enum ConfigFileType enum ConfigFileType
@ -355,7 +356,7 @@ public:
// Update the choice UI from the list of presets. // Update the choice UI from the list of presets.
// Only the compatible presets are shown. // Only the compatible presets are shown.
// If an incompatible preset is selected, it is shown as well. // If an incompatible preset is selected, it is shown as well.
void update_platter_ui(wxBitmapComboBox *ui); void update_platter_ui(GUI::PresetComboBox *ui);
// Update a dirty floag of the current preset, update the labels of the UI component accordingly. // Update a dirty floag of the current preset, update the labels of the UI component accordingly.
// Return true if the dirty flag changed. // Return true if the dirty flag changed.

View file

@ -38,6 +38,15 @@ wxDEFINE_EVENT(EVT_TAB_VALUE_CHANGED, wxCommandEvent);
wxDEFINE_EVENT(EVT_TAB_PRESETS_CHANGED, SimpleEvent); wxDEFINE_EVENT(EVT_TAB_PRESETS_CHANGED, SimpleEvent);
void Tab::set_type()
{
if (m_name == "print") { m_type = Slic3r::Preset::TYPE_PRINT; }
else if (m_name == "filament") { m_type = Slic3r::Preset::TYPE_FILAMENT; }
else if (m_name == "sla_material") { m_type = Slic3r::Preset::TYPE_SLA_MATERIAL; }
else if (m_name == "printer") { m_type = Slic3r::Preset::TYPE_PRINTER; }
else { m_type = Slic3r::Preset::TYPE_INVALID; }
}
// sub new // sub new
void Tab::create_preset_tab() void Tab::create_preset_tab()
{ {
@ -672,14 +681,6 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
event.SetInt(val); event.SetInt(val);
} }
if (opt_key == "printer_technology")
{
int val = boost::any_cast<PrinterTechnology>(value);
event.SetInt(val);
wxPostEvent(this, event);
return;
}
wxPostEvent(this, event); wxPostEvent(this, event);
@ -1461,8 +1462,6 @@ void TabPrinter::build()
m_printer_technology = m_presets->get_selected_preset().printer_technology(); m_printer_technology = m_presets->get_selected_preset().printer_technology();
m_presets->get_selected_preset().printer_technology() == ptSLA ? build_sla() : build_fff(); m_presets->get_selected_preset().printer_technology() == ptSLA ? build_sla() : build_fff();
// on_value_change("printer_technology", m_printer_technology); // to update show/hide preset ComboBoxes
} }
void TabPrinter::build_fff() void TabPrinter::build_fff()
@ -2044,8 +2043,6 @@ void TabPrinter::update_pages()
m_pages_sla.empty() ? build_sla() : m_pages.swap(m_pages_sla); m_pages_sla.empty() ? build_sla() : m_pages.swap(m_pages_sla);
rebuild_page_tree(true); rebuild_page_tree(true);
on_value_change("printer_technology", m_presets->get_edited_preset().printer_technology()); // to update show/hide preset ComboBoxes
} }
void TabPrinter::update() void TabPrinter::update()

View file

@ -108,6 +108,7 @@ class Tab: public wxPanel
int m_size_move = -1; int m_size_move = -1;
#endif // __WXOSX__ #endif // __WXOSX__
protected: protected:
Preset::Type m_type;
std::string m_name; std::string m_name;
const wxString m_title; const wxString m_title;
wxBitmapComboBox* m_presets_choice; wxBitmapComboBox* m_presets_choice;
@ -183,6 +184,8 @@ protected:
size_t m_selected_preset_item{ 0 }; size_t m_selected_preset_item{ 0 };
void set_type();
public: public:
PresetBundle* m_preset_bundle; PresetBundle* m_preset_bundle;
bool m_show_btn_incompatible_presets = false; bool m_show_btn_incompatible_presets = false;
@ -196,6 +199,7 @@ public:
Tab(wxNotebook* parent, const wxString& title, const char* name) : Tab(wxNotebook* parent, const wxString& title, const char* name) :
m_parent(parent), m_title(title), m_name(name) { m_parent(parent), m_title(title), m_name(name) {
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL, name); Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL, name);
set_type();
wxGetApp().tabs_list.push_back(this); wxGetApp().tabs_list.push_back(this);
} }
~Tab(){ ~Tab(){
@ -205,6 +209,7 @@ public:
wxWindow* parent() const { return m_parent; } wxWindow* parent() const { return m_parent; }
wxString title() const { return m_title; } wxString title() const { return m_title; }
std::string name() const { return m_name; } std::string name() const { return m_name; }
Preset::Type type() const { return m_type; }
void create_preset_tab(); void create_preset_tab();
void load_current_preset(); void load_current_preset();