Copy and paste -> prototype of copy and paste for objects
This commit is contained in:
parent
1b6bf30e76
commit
8b9568797a
@ -469,8 +469,25 @@ void ObjectList::paste_volumes_into_list(int obj_idx, const ModelVolumePtrs& vol
|
||||
#endif //no __WXOSX__ //__WXMSW__
|
||||
}
|
||||
|
||||
void ObjectList::paste_object_into_list(const ModelObject& object)
|
||||
void ObjectList::paste_objects_into_list(const std::vector<size_t>& object_idxs)
|
||||
{
|
||||
if (object_idxs.empty())
|
||||
return;
|
||||
|
||||
wxDataViewItemArray items;
|
||||
for (const size_t object : object_idxs)
|
||||
{
|
||||
add_object_to_list(object);
|
||||
m_parts_changed = true;
|
||||
parts_changed(object);
|
||||
|
||||
items.Add(m_objects_model->GetItemById(object));
|
||||
}
|
||||
|
||||
select_items(items);
|
||||
#ifndef __WXOSX__ //#ifdef __WXMSW__ // #ys_FIXME
|
||||
selection_changed();
|
||||
#endif //no __WXOSX__ //__WXMSW__
|
||||
}
|
||||
|
||||
void ObjectList::OnChar(wxKeyEvent& event)
|
||||
|
@ -289,7 +289,7 @@ public:
|
||||
void update_item_error_icon(const int obj_idx, int vol_idx) const ;
|
||||
|
||||
void paste_volumes_into_list(int obj_idx, const ModelVolumePtrs& volumes);
|
||||
void paste_object_into_list(const ModelObject& object);
|
||||
void paste_objects_into_list(const std::vector<size_t>& object_idxs);
|
||||
|
||||
private:
|
||||
void OnChar(wxKeyEvent& event);
|
||||
|
@ -1033,6 +1033,9 @@ void Selection::copy_to_clipboard()
|
||||
{
|
||||
ModelObject* src_object = m_model->objects[object.first];
|
||||
ModelObject* dst_object = m_clipboard.add_object();
|
||||
dst_object->name = src_object->name;
|
||||
dst_object->input_file = src_object->input_file;
|
||||
dst_object->config = src_object->config;
|
||||
|
||||
for (int i : object.second)
|
||||
{
|
||||
@ -1044,13 +1047,16 @@ void Selection::copy_to_clipboard()
|
||||
const GLVolume* volume = (*m_volumes)[i];
|
||||
if (volume->object_idx() == object.first)
|
||||
{
|
||||
ModelVolume* src_volume = src_object->volumes[i];
|
||||
ModelVolume* dst_volume = dst_object->add_volume(*src_volume);
|
||||
dst_volume->set_new_unique_id();
|
||||
dst_volume->config = src_volume->config;
|
||||
int volume_idx = volume->volume_idx();
|
||||
if ((0 <= volume_idx) && (volume_idx < (int)src_object->volumes.size()))
|
||||
{
|
||||
ModelVolume* src_volume = src_object->volumes[volume->volume_idx()];
|
||||
ModelVolume* dst_volume = dst_object->add_volume(*src_volume);
|
||||
dst_volume->set_new_unique_id();
|
||||
dst_volume->config = src_volume->config;
|
||||
}
|
||||
}
|
||||
}
|
||||
dst_object->config = src_object->config;
|
||||
}
|
||||
|
||||
m_clipboard.set_mode(m_mode);
|
||||
@ -1064,7 +1070,7 @@ void Selection::paste_from_clipboard()
|
||||
if ((m_clipboard.get_mode() == Volume) && is_from_single_instance())
|
||||
paste_volumes_from_clipboard();
|
||||
else
|
||||
paste_object_from_clipboard();
|
||||
paste_objects_from_clipboard();
|
||||
}
|
||||
|
||||
bool Selection::is_clipboard_empty()
|
||||
@ -1770,8 +1776,16 @@ void Selection::paste_volumes_from_clipboard()
|
||||
}
|
||||
}
|
||||
|
||||
void Selection::paste_object_from_clipboard()
|
||||
void Selection::paste_objects_from_clipboard()
|
||||
{
|
||||
std::vector<size_t> object_idxs;
|
||||
const ModelObjectPtrs& src_objects = m_clipboard.get_objects();
|
||||
for (const ModelObject* src_object : src_objects)
|
||||
{
|
||||
ModelObject* dst_object = m_model->add_object(*src_object);
|
||||
object_idxs.push_back(m_model->objects.size() - 1);
|
||||
}
|
||||
wxGetApp().obj_list()->paste_objects_into_list(object_idxs);
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
|
@ -162,6 +162,7 @@ private:
|
||||
|
||||
ModelObject* add_object() { return m_model.add_object(); }
|
||||
ModelObject* get_object(unsigned int id) { return (id < (unsigned int)m_model.objects.size()) ? m_model.objects[id] : nullptr; }
|
||||
const ModelObjectPtrs& get_objects() const { return m_model.objects; }
|
||||
|
||||
Selection::EMode get_mode() const { return m_mode; }
|
||||
void set_mode(Selection::EMode mode) { m_mode = mode; }
|
||||
@ -322,8 +323,9 @@ private:
|
||||
void synchronize_unselected_volumes();
|
||||
void ensure_on_bed();
|
||||
bool is_from_fully_selected_instance(unsigned int volume_idx) const;
|
||||
|
||||
void paste_volumes_from_clipboard();
|
||||
void paste_object_from_clipboard();
|
||||
void paste_objects_from_clipboard();
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
Loading…
Reference in New Issue
Block a user