2018-11-09 17:39:07 +00:00
|
|
|
#include "GUI_ObjectSettings.hpp"
|
|
|
|
#include "GUI_ObjectList.hpp"
|
|
|
|
|
|
|
|
#include "OptionsGroup.hpp"
|
|
|
|
#include "wxExtensions.hpp"
|
|
|
|
#include "PresetBundle.hpp"
|
2018-11-26 13:41:58 +00:00
|
|
|
#include "libslic3r/Model.hpp"
|
2018-11-09 17:39:07 +00:00
|
|
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
|
2018-11-26 13:41:58 +00:00
|
|
|
#include "I18N.hpp"
|
|
|
|
|
2019-03-23 07:23:22 +00:00
|
|
|
#include <wx/wupdlock.h>
|
|
|
|
|
2018-11-09 17:39:07 +00:00
|
|
|
namespace Slic3r
|
|
|
|
{
|
|
|
|
namespace GUI
|
|
|
|
{
|
|
|
|
|
|
|
|
OG_Settings::OG_Settings(wxWindow* parent, const bool staticbox) :
|
|
|
|
m_parent(parent)
|
|
|
|
{
|
|
|
|
wxString title = staticbox ? " " : ""; // temporary workaround - #ys_FIXME
|
|
|
|
m_og = std::make_shared<ConfigOptionsGroup>(parent, title);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OG_Settings::IsShown()
|
|
|
|
{
|
|
|
|
return m_og->sizer->IsEmpty() ? false : m_og->sizer->IsShown(size_t(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OG_Settings::Show(const bool show)
|
|
|
|
{
|
|
|
|
m_og->Show(show);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OG_Settings::Hide()
|
|
|
|
{
|
|
|
|
Show(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OG_Settings::UpdateAndShow(const bool show)
|
|
|
|
{
|
|
|
|
Show(show);
|
2019-03-22 22:00:23 +00:00
|
|
|
// m_parent->Layout();
|
2018-11-09 17:39:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxSizer* OG_Settings::get_sizer()
|
|
|
|
{
|
|
|
|
return m_og->sizer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectSettings::ObjectSettings(wxWindow* parent) :
|
|
|
|
OG_Settings(parent, true)
|
|
|
|
{
|
|
|
|
m_og->set_name(_(L("Additional Settings")));
|
|
|
|
|
|
|
|
m_settings_list_sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
m_og->sizer->Add(m_settings_list_sizer, 1, wxEXPAND | wxLEFT, 5);
|
2019-04-13 21:46:52 +00:00
|
|
|
|
2019-04-24 23:45:00 +00:00
|
|
|
m_bmp_delete = ScalableBitmap(parent, "cross");
|
2018-11-09 17:39:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectSettings::update_settings_list()
|
|
|
|
{
|
|
|
|
m_settings_list_sizer->Clear(true);
|
|
|
|
|
|
|
|
auto objects_ctrl = wxGetApp().obj_list();
|
2019-05-28 14:38:04 +00:00
|
|
|
auto objects_model = wxGetApp().obj_list()->GetModel();
|
|
|
|
auto config = wxGetApp().obj_list()->config();
|
2018-11-09 17:39:07 +00:00
|
|
|
|
|
|
|
const auto item = objects_ctrl->GetSelection();
|
|
|
|
if (item && !objects_ctrl->multiple_selection() &&
|
|
|
|
config && objects_model->IsSettingsItem(item))
|
|
|
|
{
|
|
|
|
auto extra_column = [config, this](wxWindow* parent, const Line& line)
|
|
|
|
{
|
|
|
|
auto opt_key = (line.get_options())[0].opt_id; //we assume that we have one option per line
|
|
|
|
|
2019-04-24 23:45:00 +00:00
|
|
|
auto btn = new ScalableButton(parent, wxID_ANY, m_bmp_delete);
|
2019-05-10 15:10:12 +00:00
|
|
|
btn->SetToolTip(_(L("Remove parameter")));
|
2019-04-24 23:45:00 +00:00
|
|
|
|
2018-11-09 17:39:07 +00:00
|
|
|
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
|
|
|
|
config->erase(opt_key);
|
2019-04-21 23:51:10 +00:00
|
|
|
wxGetApp().obj_list()->changed_object();
|
2019-04-03 10:45:06 +00:00
|
|
|
wxTheApp->CallAfter([this]() {
|
2019-03-23 07:23:22 +00:00
|
|
|
wxWindowUpdateLocker noUpdates(m_parent);
|
2018-11-09 17:39:07 +00:00
|
|
|
update_settings_list();
|
|
|
|
m_parent->Layout();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return btn;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::map<std::string, std::vector<std::string>> cat_options;
|
|
|
|
auto opt_keys = config->keys();
|
2018-11-29 14:00:23 +00:00
|
|
|
objects_ctrl->update_opt_keys(opt_keys); // update options list according to print technology
|
|
|
|
|
2018-11-09 17:39:07 +00:00
|
|
|
m_og_settings.resize(0);
|
|
|
|
std::vector<std::string> categories;
|
|
|
|
if (!(opt_keys.size() == 1 && opt_keys[0] == "extruder"))// return;
|
|
|
|
{
|
2019-02-06 08:49:32 +00:00
|
|
|
const int extruders_cnt = wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA ? 1 :
|
2018-11-09 17:39:07 +00:00
|
|
|
wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
|
|
|
|
|
|
|
|
for (auto& opt_key : opt_keys) {
|
|
|
|
auto category = config->def()->get(opt_key)->category;
|
|
|
|
if (category.empty() ||
|
|
|
|
(category == "Extruders" && extruders_cnt == 1)) continue;
|
|
|
|
|
|
|
|
std::vector< std::string > new_category;
|
|
|
|
|
|
|
|
auto& cat_opt = cat_options.find(category) == cat_options.end() ? new_category : cat_options.at(category);
|
|
|
|
cat_opt.push_back(opt_key);
|
|
|
|
if (cat_opt.size() == 1)
|
|
|
|
cat_options[category] = cat_opt;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto& cat : cat_options) {
|
|
|
|
if (cat.second.size() == 1 && cat.second[0] == "extruder")
|
|
|
|
continue;
|
|
|
|
|
2019-05-04 00:07:07 +00:00
|
|
|
auto optgroup = std::make_shared<ConfigOptionsGroup>(m_og->ctrl_parent(), _(cat.first), config, false, extra_column);
|
2019-04-13 21:46:52 +00:00
|
|
|
optgroup->label_width = 15;
|
2019-04-16 08:05:45 +00:00
|
|
|
optgroup->sidetext_width = 5.5;
|
2018-11-09 17:39:07 +00:00
|
|
|
|
|
|
|
optgroup->m_on_change = [](const t_config_option_key& opt_id, const boost::any& value) {
|
2019-04-21 23:51:10 +00:00
|
|
|
wxGetApp().obj_list()->changed_object(); };
|
2018-11-09 17:39:07 +00:00
|
|
|
|
2019-05-14 10:15:48 +00:00
|
|
|
const bool is_extriders_cat = cat.first == "Extruders";
|
2018-11-09 17:39:07 +00:00
|
|
|
for (auto& opt : cat.second)
|
|
|
|
{
|
|
|
|
if (opt == "extruder")
|
|
|
|
continue;
|
|
|
|
Option option = optgroup->get_option(opt);
|
2019-04-16 08:05:45 +00:00
|
|
|
option.opt.width = 12;
|
2019-05-14 10:15:48 +00:00
|
|
|
if (is_extriders_cat)
|
|
|
|
option.opt.max = wxGetApp().extruders_cnt();
|
2018-11-09 17:39:07 +00:00
|
|
|
optgroup->append_single_option_line(option);
|
|
|
|
}
|
|
|
|
optgroup->reload_config();
|
|
|
|
m_settings_list_sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 0);
|
2019-04-13 21:46:52 +00:00
|
|
|
|
|
|
|
// call back for rescaling of the extracolumn control
|
2019-04-16 08:05:45 +00:00
|
|
|
optgroup->rescale_extra_column_item = [this](wxWindow* win) {
|
2019-04-24 23:45:00 +00:00
|
|
|
auto *ctrl = dynamic_cast<ScalableButton*>(win);
|
2019-04-13 21:46:52 +00:00
|
|
|
if (ctrl == nullptr)
|
|
|
|
return;
|
|
|
|
ctrl->SetBitmap_(m_bmp_delete);
|
|
|
|
};
|
|
|
|
|
2018-11-09 17:39:07 +00:00
|
|
|
m_og_settings.push_back(optgroup);
|
|
|
|
|
|
|
|
categories.push_back(cat.first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_og_settings.empty()) {
|
|
|
|
objects_ctrl->select_item(objects_model->Delete(item));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!categories.empty())
|
|
|
|
objects_model->UpdateSettingsDigest(item, categories);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectSettings::UpdateAndShow(const bool show)
|
|
|
|
{
|
|
|
|
if (show)
|
|
|
|
update_settings_list();
|
|
|
|
|
|
|
|
OG_Settings::UpdateAndShow(show);
|
|
|
|
}
|
|
|
|
|
2019-04-24 23:45:00 +00:00
|
|
|
void ObjectSettings::msw_rescale()
|
2019-04-13 21:46:52 +00:00
|
|
|
{
|
2019-04-24 23:45:00 +00:00
|
|
|
m_bmp_delete.msw_rescale();
|
2019-04-13 21:46:52 +00:00
|
|
|
|
|
|
|
for (auto group : m_og_settings)
|
2019-04-24 23:45:00 +00:00
|
|
|
group->msw_rescale();
|
2019-04-13 21:46:52 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 17:39:07 +00:00
|
|
|
} //namespace GUI
|
|
|
|
} //namespace Slic3r
|