Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_selection_undoredo
This commit is contained in:
commit
1f24e82690
3 changed files with 31 additions and 13 deletions
|
@ -163,7 +163,7 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
|
|||
endif()
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
add_compile_options(-Wall)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder" )
|
||||
|
||||
# On GCC and Clang, no return from a non-void function is a warning only. Here, we make it an error.
|
||||
|
|
|
@ -82,7 +82,9 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const S
|
|||
editing_mode_reload_cache();
|
||||
}
|
||||
|
||||
if (m_editing_mode_cache.empty() && m_model_object->sla_points_status != sla::PointsStatus::UserModified)
|
||||
if (m_editing_mode_cache.empty()
|
||||
&& m_model_object->sla_points_status != sla::PointsStatus::UserModified
|
||||
&& m_model_object->sla_points_status != sla::PointsStatus::None)
|
||||
get_data_from_backend();
|
||||
|
||||
if (m_state == On) {
|
||||
|
@ -1122,9 +1124,13 @@ void GLGizmoSlaSupports::on_start_dragging()
|
|||
|
||||
void GLGizmoSlaSupports::on_load(cereal::BinaryInputArchive& ar)
|
||||
{
|
||||
if (m_editing_mode)
|
||||
editing_mode_discard_changes();
|
||||
|
||||
ar(m_clipping_plane_distance,
|
||||
m_clipping_plane_normal,
|
||||
m_current_mesh_object_id
|
||||
m_current_mesh_object_id,
|
||||
m_editing_mode_cache
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1140,8 @@ void GLGizmoSlaSupports::on_save(cereal::BinaryOutputArchive& ar) const
|
|||
{
|
||||
ar(m_clipping_plane_distance,
|
||||
m_clipping_plane_normal,
|
||||
m_current_mesh_object_id
|
||||
m_current_mesh_object_id,
|
||||
m_editing_mode_cache
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1177,16 +1184,16 @@ void GLGizmoSlaSupports::editing_mode_discard_changes()
|
|||
// If the points were autogenerated, they may not be on the ModelObject yet.
|
||||
// Because the user probably messed with the cache, we will get the data
|
||||
// from the backend again.
|
||||
|
||||
if (m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated)
|
||||
/*if (m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated) {
|
||||
get_data_from_backend();
|
||||
else {
|
||||
m_editing_mode_cache.clear();
|
||||
for (const sla::SupportPoint& point : m_model_object->sla_support_points)
|
||||
m_editing_mode_cache.emplace_back(point, false);
|
||||
}
|
||||
m_editing_mode = false;
|
||||
m_unsaved_changes = false;
|
||||
}
|
||||
else
|
||||
editing_mode_reload_cache();*/
|
||||
|
||||
m_editing_mode_cache = m_old_cache;
|
||||
|
||||
m_editing_mode = false;
|
||||
m_unsaved_changes = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1196,7 +1203,13 @@ void GLGizmoSlaSupports::editing_mode_apply_changes()
|
|||
// If there are no changes, don't touch the front-end. The data in the cache could have been
|
||||
// taken from the backend and copying them to ModelObject would needlessly invalidate them.
|
||||
if (m_unsaved_changes) {
|
||||
// In order to make the undo/redo snapshot, we must first temporarily restore
|
||||
// the editing cache to the state before the edits were made.
|
||||
std::vector<CacheEntry> backup = m_editing_mode_cache;
|
||||
m_editing_mode_cache = m_old_cache;
|
||||
wxGetApp().plater()->take_snapshot(_(L("Support points edit")));
|
||||
m_editing_mode_cache = std::move(backup);
|
||||
|
||||
m_model_object->sla_points_status = sla::PointsStatus::UserModified;
|
||||
m_model_object->sla_support_points.clear();
|
||||
for (const CacheEntry& cache_entry : m_editing_mode_cache)
|
||||
|
@ -1216,6 +1229,7 @@ void GLGizmoSlaSupports::editing_mode_apply_changes()
|
|||
void GLGizmoSlaSupports::editing_mode_reload_cache()
|
||||
{
|
||||
m_editing_mode_cache.clear();
|
||||
|
||||
for (const sla::SupportPoint& point : m_model_object->sla_support_points)
|
||||
m_editing_mode_cache.emplace_back(point, false);
|
||||
|
||||
|
@ -1271,6 +1285,8 @@ void GLGizmoSlaSupports::switch_to_editing_mode()
|
|||
editing_mode_reload_cache();
|
||||
m_unsaved_changes = false;
|
||||
m_editing_mode = true;
|
||||
m_old_cache = m_editing_mode_cache;
|
||||
select_point(NoPoints);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ private:
|
|||
float m_new_point_head_diameter; // Size of a new point.
|
||||
float m_minimal_point_distance = 20.f;
|
||||
mutable std::vector<CacheEntry> m_editing_mode_cache; // a support point and whether it is currently selected
|
||||
std::vector<CacheEntry> m_old_cache; // to restore after discarding changes or undo/redo
|
||||
|
||||
float m_clipping_plane_distance = 0.f;
|
||||
mutable float m_old_clipping_plane_distance = 0.f;
|
||||
mutable Vec3d m_old_clipping_plane_normal;
|
||||
|
|
Loading…
Reference in a new issue