Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_selection_undoredo

This commit is contained in:
Enrico Turri 2019-07-26 11:34:05 +02:00
commit eefd950e16
7 changed files with 23 additions and 42 deletions

View File

@ -1566,9 +1566,9 @@ void ObjectList::create_freq_settings_popupmenu(wxMenu *menu)
#endif
}
void ObjectList::update_opt_keys(t_config_option_keys& opt_keys)
void ObjectList::update_opt_keys(t_config_option_keys& opt_keys, const bool is_object)
{
auto full_current_opts = get_options(false);
auto full_current_opts = get_options(!is_object);
for (int i = opt_keys.size()-1; i >= 0; --i)
if (find(full_current_opts.begin(), full_current_opts.end(), opt_keys[i]) == full_current_opts.end())
opt_keys.erase(opt_keys.begin() + i);
@ -2161,16 +2161,15 @@ void ObjectList::part_selection_changed()
panel.Thaw();
}
SettingsBundle ObjectList::get_item_settings_bundle(const DynamicPrintConfig* config, const bool is_layers_range_settings)
SettingsBundle ObjectList::get_item_settings_bundle(const DynamicPrintConfig* config, const bool is_object_settings)
{
auto opt_keys = config->keys();
if (opt_keys.empty())
return SettingsBundle();
update_opt_keys(opt_keys); // update options list according to print technology
update_opt_keys(opt_keys, is_object_settings); // update options list according to print technology
if (opt_keys.size() == 1 && opt_keys[0] == "extruder" ||
is_layers_range_settings && opt_keys.size() == 2)
if (opt_keys.empty())
return SettingsBundle();
const int extruders_cnt = wxGetApp().extruders_edited_cnt();
@ -2201,24 +2200,15 @@ wxDataViewItem ObjectList::add_settings_item(wxDataViewItem parent_item, const D
if (!parent_item)
return ret;
const bool is_layers_range_settings = m_objects_model->GetItemType(parent_item) == itLayer;
SettingsBundle cat_options = get_item_settings_bundle(config, is_layers_range_settings);
const bool is_object_settings = m_objects_model->GetItemType(parent_item) == itObject;
SettingsBundle cat_options = get_item_settings_bundle(config, is_object_settings);
if (cat_options.empty())
return ret;
std::vector<std::string> categories;
categories.reserve(cat_options.size());
for (auto& cat : cat_options)
{
if (cat.second.size() == 1 &&
(cat.second[0] == "extruder" || is_layers_range_settings && cat.second[0] == "layer_height"))
continue;
categories.push_back(cat.first);
}
if (categories.empty())
return ret;
if (m_objects_model->GetItemType(parent_item) & itInstance)
parent_item = m_objects_model->GetTopParent(parent_item);

View File

@ -238,7 +238,7 @@ public:
wxMenu* create_settings_popupmenu(wxMenu *parent_menu);
void create_freq_settings_popupmenu(wxMenu *parent_menu);
void update_opt_keys(t_config_option_keys& t_optopt_keys);
void update_opt_keys(t_config_option_keys& t_optopt_keys, const bool is_object);
void load_subobject(ModelVolumeType type);
void load_part(ModelObject* model_object, std::vector<std::pair<wxString, bool>> &volumes_info, ModelVolumeType type);
@ -266,7 +266,7 @@ public:
wxBoxSizer* get_sizer() {return m_sizer;}
int get_selected_obj_idx() const;
DynamicPrintConfig& get_item_config(const wxDataViewItem& item) const;
SettingsBundle get_item_settings_bundle(const DynamicPrintConfig* config, const bool is_layers_range_settings);
SettingsBundle get_item_settings_bundle(const DynamicPrintConfig* config, const bool is_object_settings);
void changed_object(const int obj_idx = -1) const;
void part_selection_changed();

View File

@ -77,8 +77,8 @@ bool ObjectSettings::update_settings_list()
if (!item || !objects_model->IsSettingsItem(item) || !config || objects_ctrl->multiple_selection())
return false;
const bool is_layers_range_settings = objects_model->GetItemType(objects_model->GetParent(item)) == itLayer;
SettingsBundle cat_options = objects_ctrl->get_item_settings_bundle(config, is_layers_range_settings);
const bool is_object_settings = objects_model->GetItemType(objects_model->GetParent(item)) == itObject;
SettingsBundle cat_options = objects_ctrl->get_item_settings_bundle(config, is_object_settings);
if (!cat_options.empty())
{
@ -107,10 +107,6 @@ bool ObjectSettings::update_settings_list()
for (auto& cat : cat_options)
{
if (cat.second.size() == 1 &&
(cat.second[0] == "extruder" || is_layers_range_settings && cat.second[0] == "layer_height"))
continue;
categories.push_back(cat.first);
auto optgroup = std::make_shared<ConfigOptionsGroup>(m_og->ctrl_parent(), _(cat.first), config, false, extra_column);
@ -131,8 +127,6 @@ bool ObjectSettings::update_settings_list()
const bool is_extruders_cat = cat.first == "Extruders";
for (auto& opt : cat.second)
{
if (opt == "extruder" || is_layers_range_settings && opt == "layer_height")
continue;
Option option = optgroup->get_option(opt);
option.opt.width = 12;
if (is_extruders_cat)

View File

@ -718,7 +718,7 @@ Sidebar::Sidebar(Plater *parent)
p->scrolled->SetSizer(scrolled_sizer);
// Sizer with buttons for mode changing
p->mode_sizer = new ModeSizer(p->scrolled, 2 * wxGetApp().em_unit());
p->mode_sizer = new ModeSizer(p->scrolled);
// The preset chooser
p->sizer_presets = new wxFlexGridSizer(10, 1, 1, 2);
@ -3799,6 +3799,7 @@ void Plater::priv::undo_redo_to(std::vector<UndoRedo::Snapshot>::const_iterator
model.wipe_tower.position = Vec2d(config.opt_float("wipe_tower_x"), config.opt_float("wipe_tower_y"));
model.wipe_tower.rotation = config.opt_float("wipe_tower_rotation_angle");
}
const int layer_range_idx = it_snapshot->snapshot_data.layer_range_idx;
// Flags made of Snapshot::Flags enum values.
unsigned int new_flags = it_snapshot->snapshot_data.flags;
UndoRedo::SnapshotData top_snapshot_data;
@ -3858,7 +3859,7 @@ void Plater::priv::undo_redo_to(std::vector<UndoRedo::Snapshot>::const_iterator
new_selected_layerroot_on_sidebar ? ObjectList::SELECTION_MODE::smLayerRoot :
ObjectList::SELECTION_MODE::smUndef);
if (new_selected_settings_on_sidebar || new_selected_layer_on_sidebar)
this->sidebar->obj_list()->set_selected_layers_range_idx(it_snapshot->snapshot_data.layer_range_idx);
this->sidebar->obj_list()->set_selected_layers_range_idx(layer_range_idx);
this->update_after_undo_redo(temp_snapshot_was_taken);
// Enable layer editing after the Undo / Redo jump.

View File

@ -198,7 +198,7 @@ void Tab::create_preset_tab()
// There is used just additional sizer for m_mode_sizer with right alignment
auto mode_sizer = new wxBoxSizer(wxVERTICAL);
mode_sizer->Add(m_mode_sizer, 1, wxALIGN_RIGHT);
m_hsizer->Add(mode_sizer, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, wxOSX ? 15 : 5);
m_hsizer->Add(mode_sizer, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, wxOSX ? 15 : 10);
//Horizontal sizer to hold the tree and the selected page.
m_hsizer = new wxBoxSizer(wxHORIZONTAL);

View File

@ -2808,11 +2808,13 @@ ModeButton::ModeButton( wxWindow * parent,
const wxString& mode /* = wxEmptyString*/,
const wxSize& size /* = wxDefaultSize*/,
const wxPoint& pos /* = wxDefaultPosition*/) :
ScalableButton(parent, id, icon_name, mode, size, pos)
ScalableButton(parent, id, icon_name, mode, size, pos, wxBU_EXACTFIT)
{
m_tt_focused = wxString::Format(_(L("Switch to the %s mode")), mode);
m_tt_selected = wxString::Format(_(L("Current mode is %s")), mode);
SetBitmapMargins(3, 0);
//button events
Bind(wxEVT_BUTTON, &ModeButton::OnButton, this);
Bind(wxEVT_ENTER_WINDOW, &ModeButton::OnEnterBtn, this);
@ -2841,6 +2843,7 @@ void ModeButton::focus_button(const bool focus)
Slic3r::GUI::wxGetApp().normal_font();
SetFont(new_font);
SetForegroundColour(wxSystemSettings::GetColour(focus ? wxSYS_COLOUR_BTNTEXT : wxSYS_COLOUR_BTNSHADOW));
Refresh();
Update();
@ -2851,7 +2854,7 @@ void ModeButton::focus_button(const bool focus)
// ModeSizer
// ----------------------------------------------------------------------------
ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 0*/) :
wxFlexGridSizer(3, 0, hgap)
{
SetFlexibleDirection(wxHORIZONTAL);
@ -2869,14 +2872,7 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
m_mode_btns.reserve(3);
for (const auto& button : buttons) {
#ifdef __WXOSX__
wxSize sz = parent->GetTextExtent(button.first);
// set default width for ModeButtons to correct rendering on OnFocus under OSX
sz.x += 2 * em_unit(parent);
m_mode_btns.push_back(new ModeButton(parent, wxID_ANY, button.second, button.first, sz));
#else
m_mode_btns.push_back(new ModeButton(parent, wxID_ANY, button.second, button.first));;
#endif // __WXOSX__
m_mode_btns.push_back(new ModeButton(parent, wxID_ANY, button.second, button.first));
m_mode_btns.back()->Bind(wxEVT_BUTTON, std::bind(modebtnfn, std::placeholders::_1, int(m_mode_btns.size() - 1)));
Add(m_mode_btns.back());

View File

@ -946,7 +946,7 @@ private:
class ModeSizer : public wxFlexGridSizer
{
public:
ModeSizer( wxWindow *parent, int hgap = 10);
ModeSizer( wxWindow *parent, int hgap = 0);
~ModeSizer() {}
void SetMode(const /*ConfigOptionMode*/int mode);