Skip to content

Commit

Permalink
Implementation for #6216 - Make number keys select extruder when obje…
Browse files Browse the repository at this point in the history
…ct treeview has focus

+ deleted unused extruder_selection()
+ Fixed notification after splitting of the solid object
  • Loading branch information
YuSanka committed May 4, 2021
1 parent 4fe6f72 commit fb7b24d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 34 deletions.
49 changes: 18 additions & 31 deletions src/slic3r/GUI/GUI_ObjectList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,20 @@ void ObjectList::key_event(wxKeyEvent& event)
increase_instances();
else if (event.GetUnicodeKey() == '-')
decrease_instances();
else if (event.GetUnicodeKey() == 'p')
toggle_printable_state();
else if (extruders_count() > 1) {
std::vector<wxChar> numbers = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
wxChar key_char = event.GetUnicodeKey();
if (std::find(numbers.begin(), numbers.end(), key_char) != numbers.end()) {
long extruder_number;
if (wxNumberFormatter::FromString(wxString(key_char), &extruder_number) &&
extruders_count() >= extruder_number)
set_extruder_for_selected_items(int(extruder_number));
}
else
event.Skip();
}
else
event.Skip();
}
Expand Down Expand Up @@ -3787,33 +3801,6 @@ void ObjectList::OnEditingDone(wxDataViewEvent &event)
plater->set_current_canvas_as_dirty();
}

void ObjectList::extruder_selection()
{
wxArrayString choices;
choices.Add(_(L("default")));
for (int i = 1; i <= extruders_count(); ++i)
choices.Add(wxString::Format("%d", i));

const wxString& selected_extruder = wxGetSingleChoice(_(L("Select extruder number:")),
_(L("This extruder will be set for selected items")),
choices, 0, this);
if (selected_extruder.IsEmpty())
return;

const int extruder_num = selected_extruder == _(L("default")) ? 0 : atoi(selected_extruder.c_str());

// /* Another variant for an extruder selection */
// extruder_num = wxGetNumberFromUser(_(L("Attention!!! \n"
// "It's a possibile to set an extruder number \n"
// "for whole Object(s) and/or object Part(s), \n"
// "not for an Instance. ")),
// _(L("Enter extruder number:")),
// _(L("This extruder will be set for selected items")),
// 1, 1, 5, this);

set_extruder_for_selected_items(extruder_num);
}

void ObjectList::set_extruder_for_selected_items(const int extruder) const
{
wxDataViewItemArray sels;
Expand Down Expand Up @@ -3918,10 +3905,10 @@ void ObjectList::toggle_printable_state()
int inst_idx = type == itObject ? 0 : m_objects_model->GetInstanceIdByItem(frst_item);
bool printable = !object(obj_idx)->instances[inst_idx]->printable;

const wxString snapshot_text = sels.Count() > 1 ? (printable ? _L("Set Printable group") : _L("Set Unprintable group")) :
object(obj_idx)->instances.size() == 1 ? from_u8((boost::format("%1% %2%")
% (printable ? _L("Set Printable") : _L("Set Unprintable"))
% object(obj_idx)->name).str()) :
const wxString snapshot_text = sels.Count() > 1 ?
(printable ? _L("Set Printable group") : _L("Set Unprintable group")) :
object(obj_idx)->instances.size() == 1 ?
format_wxstr("%1% %2%", (printable ? _L("Set Printable") : _L("Set Unprintable")), from_u8(object(obj_idx)->name)) :
(printable ? _L("Set Printable Instance") : _L("Set Unprintable Instance"));
take_snapshot(snapshot_text);

Expand Down
1 change: 0 additions & 1 deletion src/slic3r/GUI/GUI_ObjectList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ class ObjectList : public wxDataViewCtrl
void OnEditingStarted(wxDataViewEvent &event);
#endif /* __WXMSW__ */
void OnEditingDone(wxDataViewEvent &event);
void extruder_selection();
};


Expand Down
5 changes: 3 additions & 2 deletions src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2743,10 +2743,11 @@ void Plater::priv::split_object()
Slic3r::GUI::warning_catcher(q, _L("The selected object couldn't be split because it contains only one solid part."));
else
{
if (current_model_object->volumes.size() != new_objects.size())
// If we splited object which is contain some parts/modifiers then all non-solid parts (modifiers) were deleted
if (current_model_object->volumes.size() > 1 && current_model_object->volumes.size() != new_objects.size())
notification_manager->push_notification(NotificationType::CustomNotification,
NotificationManager::NotificationLevel::RegularNotification,
_u8L("All non-solid parts (modifiers) was deleted"));
_u8L("All non-solid parts (modifiers) were deleted"));

Plater::TakeSnapshot snapshot(q, _L("Split to Objects"));

Expand Down

0 comments on commit fb7b24d

Please sign in to comment.