Added SETTINGS_SELECTED_ON_SIDEBAR flag to undo/redo
This commit is contained in:
parent
b34252bf0f
commit
4245b61afc
@ -2638,7 +2638,8 @@ void ObjectList::update_selections()
|
||||
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
wxDataViewItemArray sels;
|
||||
|
||||
m_selection_mode = smInstance;
|
||||
if (m_selection_mode & smSettings == 0)
|
||||
m_selection_mode = smInstance;
|
||||
|
||||
// We doesn't update selection if SettingsItem for the current object/part is selected
|
||||
// if (GetSelectedItemsCount() == 1 && m_objects_model->GetItemType(GetSelection()) == itSettings )
|
||||
@ -2664,6 +2665,12 @@ void ObjectList::update_selections()
|
||||
else if (selection.is_single_full_object() || selection.is_multiple_full_object())
|
||||
{
|
||||
const Selection::ObjectIdxsToInstanceIdxsMap& objects_content = selection.get_content();
|
||||
if (m_selection_mode & smSettings)
|
||||
{
|
||||
wxDataViewItem obj_item = m_objects_model->GetItemById(objects_content.begin()->first);
|
||||
sels.Add(m_objects_model->GetSettingsItem(obj_item));
|
||||
}
|
||||
else {
|
||||
for (const auto& object : objects_content) {
|
||||
if (object.second.size() == 1) // object with 1 instance
|
||||
sels.Add(m_objects_model->GetItemById(object.first));
|
||||
@ -2688,10 +2695,23 @@ void ObjectList::update_selections()
|
||||
for (const auto& inst : instances)
|
||||
sels.Add(m_objects_model->GetItemByInstanceId(object.first, inst));
|
||||
}
|
||||
}
|
||||
} }
|
||||
}
|
||||
else if (selection.is_any_volume() || selection.is_any_modifier())
|
||||
{
|
||||
if (m_selection_mode & smSettings)
|
||||
{
|
||||
const auto idx = *selection.get_volume_idxs().begin();
|
||||
const auto gl_vol = selection.get_volume(idx);
|
||||
if (gl_vol->volume_idx() >= 0) {
|
||||
// Only add GLVolumes with non-negative volume_ids. GLVolumes with negative volume ids
|
||||
// are not associated with ModelVolumes, but they are temporarily generated by the backend
|
||||
// (for example, SLA supports or SLA pad).
|
||||
wxDataViewItem vol_item = m_objects_model->GetItemByVolumeId(gl_vol->object_idx(), gl_vol->volume_idx());
|
||||
sels.Add(m_objects_model->GetSettingsItem(vol_item));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (auto idx : selection.get_volume_idxs()) {
|
||||
const auto gl_vol = selection.get_volume(idx);
|
||||
if (gl_vol->volume_idx() >= 0)
|
||||
@ -2700,7 +2720,7 @@ void ObjectList::update_selections()
|
||||
// (for example, SLA supports or SLA pad).
|
||||
sels.Add(m_objects_model->GetItemByVolumeId(gl_vol->object_idx(), gl_vol->volume_idx()));
|
||||
}
|
||||
m_selection_mode = smVolume;
|
||||
m_selection_mode = smVolume; }
|
||||
}
|
||||
else if (selection.is_single_full_instance() || selection.is_multiple_full_instance())
|
||||
{
|
||||
@ -2744,7 +2764,7 @@ void ObjectList::update_selections()
|
||||
}
|
||||
}
|
||||
|
||||
if (sels.size() == 0)
|
||||
if (sels.size() == 0 || m_selection_mode & smSettings)
|
||||
m_selection_mode = smUndef;
|
||||
|
||||
select_items(sels);
|
||||
@ -3522,15 +3542,16 @@ void ObjectList::set_extruder_for_selected_items(const int extruder) const
|
||||
|
||||
void ObjectList::update_after_undo_redo()
|
||||
{
|
||||
m_prevent_list_events = true;
|
||||
m_prevent_canvas_selection_update = true;
|
||||
|
||||
Plater::SuppressSnapshots suppress(wxGetApp().plater());
|
||||
|
||||
// Unselect all objects before deleting them, so that no change of selection is emitted during deletion.
|
||||
this->UnselectAll();
|
||||
unselect_objects();//this->UnselectAll();
|
||||
m_objects_model->DeleteAll();
|
||||
|
||||
// m_prevent_list_events = true;
|
||||
|
||||
size_t obj_idx = 0;
|
||||
while (obj_idx < m_objects->size()) {
|
||||
add_object_to_list(obj_idx, false);
|
||||
@ -3544,7 +3565,7 @@ void ObjectList::update_after_undo_redo()
|
||||
update_selections();
|
||||
|
||||
m_prevent_canvas_selection_update = false;
|
||||
m_prevent_list_events = false;
|
||||
// m_prevent_list_events = false;
|
||||
}
|
||||
|
||||
ModelObject* ObjectList::object(const int obj_idx) const
|
||||
|
@ -66,14 +66,17 @@ struct ItemForDelete
|
||||
|
||||
class ObjectList : public wxDataViewCtrl
|
||||
{
|
||||
public:
|
||||
enum SELECTION_MODE
|
||||
{
|
||||
smUndef = 0,
|
||||
smVolume = 1,
|
||||
smInstance = 2,
|
||||
smLayer = 4
|
||||
smLayer = 4,
|
||||
smSettings = 8, // used for undo/redo
|
||||
} m_selection_mode {smUndef};
|
||||
|
||||
private:
|
||||
struct dragged_item_data
|
||||
{
|
||||
void init(const int obj_idx, const int subobj_idx, const ItemType type) {
|
||||
@ -302,6 +305,7 @@ public:
|
||||
void init_objects();
|
||||
bool multiple_selection() const ;
|
||||
bool is_selected(const ItemType type) const;
|
||||
void set_selection_mode(SELECTION_MODE mode) { m_selection_mode = mode; }
|
||||
void update_selections();
|
||||
void update_selections_on_canvas();
|
||||
void select_item(const wxDataViewItem& item);
|
||||
|
@ -3729,6 +3729,8 @@ void Plater::priv::take_snapshot(const std::string& snapshot_name)
|
||||
snapshot_data.printer_technology = this->printer_technology;
|
||||
if (this->view3D->is_layers_editing_enabled())
|
||||
snapshot_data.flags |= UndoRedo::SnapshotData::VARIABLE_LAYER_EDITING_ACTIVE;
|
||||
if (this->sidebar->obj_list()->is_selected(itSettings))
|
||||
snapshot_data.flags |= UndoRedo::SnapshotData::SETTINGS_SELECTED_ON_SIDEBAR;
|
||||
//FIXME updating the Wipe tower config values at the ModelWipeTower from the Print config.
|
||||
// This is a workaround until we refactor the Wipe Tower position / orientation to live solely inside the Model, not in the Print config.
|
||||
if (this->printer_technology == ptFFF) {
|
||||
@ -3795,7 +3797,10 @@ void Plater::priv::undo_redo_to(std::vector<UndoRedo::Snapshot>::const_iterator
|
||||
top_snapshot_data.printer_technology = this->printer_technology;
|
||||
if (this->view3D->is_layers_editing_enabled())
|
||||
top_snapshot_data.flags |= UndoRedo::SnapshotData::VARIABLE_LAYER_EDITING_ACTIVE;
|
||||
if (this->sidebar->obj_list()->is_selected(itSettings))
|
||||
top_snapshot_data.flags |= UndoRedo::SnapshotData::SETTINGS_SELECTED_ON_SIDEBAR;
|
||||
bool new_variable_layer_editing_active = (new_flags & UndoRedo::SnapshotData::VARIABLE_LAYER_EDITING_ACTIVE) != 0;
|
||||
bool new_settings_selected_on_sidebar = (new_flags & UndoRedo::SnapshotData::SETTINGS_SELECTED_ON_SIDEBAR) != 0;
|
||||
// Disable layer editing before the Undo / Redo jump.
|
||||
if (!new_variable_layer_editing_active && view3D->is_layers_editing_enabled())
|
||||
view3D->get_canvas3d()->force_main_toolbar_left_action(view3D->get_canvas3d()->get_main_toolbar_item_id("layersediting"));
|
||||
@ -3828,6 +3833,9 @@ void Plater::priv::undo_redo_to(std::vector<UndoRedo::Snapshot>::const_iterator
|
||||
tab_print->update_dirty();
|
||||
}
|
||||
}
|
||||
// set settings mode for ObjectList on sidebar
|
||||
if (new_settings_selected_on_sidebar)
|
||||
this->sidebar->obj_list()->set_selection_mode(ObjectList::SELECTION_MODE::smSettings);
|
||||
this->update_after_undo_redo(temp_snapshot_was_taken);
|
||||
// Enable layer editing after the Undo / Redo jump.
|
||||
if (! view3D->is_layers_editing_enabled() && this->layers_height_allowed() && new_variable_layer_editing_active)
|
||||
|
@ -38,6 +38,7 @@ struct SnapshotData
|
||||
// Bitmask of various binary flags to be stored with the snapshot.
|
||||
enum Flags {
|
||||
VARIABLE_LAYER_EDITING_ACTIVE = 1,
|
||||
SETTINGS_SELECTED_ON_SIDEBAR = 2,
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user