This commit is contained in:
YuSanka 2019-07-23 16:18:14 +02:00
commit a121253520
14 changed files with 98 additions and 37 deletions

View file

@ -166,7 +166,7 @@ void GLGizmoBase::set_highlight_color(const float* color)
void GLGizmoBase::enable_grabber(unsigned int id)
{
if ((0 <= id) && (id < (unsigned int)m_grabbers.size()))
if (id < m_grabbers.size())
m_grabbers[id].enabled = true;
on_enable_grabber(id);
@ -174,7 +174,7 @@ void GLGizmoBase::enable_grabber(unsigned int id)
void GLGizmoBase::disable_grabber(unsigned int id)
{
if ((0 <= id) && (id < (unsigned int)m_grabbers.size()))
if (id < m_grabbers.size())
m_grabbers[id].enabled = false;
on_disable_grabber(id);

View file

@ -93,19 +93,19 @@ protected:
}
virtual void on_set_hover_id()
{
for (unsigned int i = 0; i < 3; ++i)
for (int i = 0; i < 3; ++i)
{
m_gizmos[i].set_hover_id((m_hover_id == i) ? 0 : -1);
}
}
virtual void on_enable_grabber(unsigned int id)
{
if ((0 <= id) && (id < 3))
if (id < 3)
m_gizmos[id].enable_grabber(0);
}
virtual void on_disable_grabber(unsigned int id)
{
if ((0 <= id) && (id < 3))
if (id < 3)
m_gizmos[id].disable_grabber(0);
}
virtual void on_start_dragging();

View file

@ -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);
}

View file

@ -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;

View file

@ -223,7 +223,7 @@ void GLGizmosManager::update_data()
enable_grabber(Rotate, 1, !is_wipe_tower);
bool enable_scale_xyz = selection.is_single_full_instance() || selection.is_single_volume() || selection.is_single_modifier();
for (int i = 0; i < 6; ++i)
for (unsigned int i = 0; i < 6; ++i)
{
enable_grabber(Scale, i, enable_scale_xyz);
}

View file

@ -3912,8 +3912,6 @@ void Plater::load_project()
// Ask user for a project file name.
wxString input_file;
wxGetApp().load_project(this, input_file);
// Take the Undo / Redo snapshot.
Plater::TakeSnapshot snapshot(this, _(L("Load Project")) + ": " + wxString::FromUTF8(into_path(input_file).stem().string().c_str()));
// And finally load the new project.
load_project(input_file);
}
@ -3923,6 +3921,9 @@ void Plater::load_project(const wxString& filename)
if (filename.empty())
return;
// Take the Undo / Redo snapshot.
Plater::TakeSnapshot snapshot(this, _(L("Load Project")) + ": " + wxString::FromUTF8(into_path(filename).stem().string().c_str()));
p->reset();
p->set_project_filename(filename);

View file

@ -1892,8 +1892,35 @@ void TabPrinter::build_fff()
extruders_count_changed(extruders_count);
init_options_list(); // m_options_list should be updated before UI updating
update_dirty();
if (opt_key == "single_extruder_multi_material") // the single_extruder_multimaterial was added to force pages
if (opt_key == "single_extruder_multi_material") { // the single_extruder_multimaterial was added to force pages
on_value_change(opt_key, value); // rebuild - let's make sure the on_value_change is not skipped
if (boost::any_cast<bool>(value) && m_extruders_count > 1) {
SuppressBackgroundProcessingUpdate sbpu;
std::vector<double> nozzle_diameters = static_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter"))->values;
const double frst_diam = nozzle_diameters[0];
for (auto cur_diam : nozzle_diameters) {
// if value is differs from first nozzle diameter value
if (fabs(cur_diam - frst_diam) > EPSILON) {
const wxString msg_text = _(L("Single Extruder Multi Material is selected, \n"
"and all extruders must have the same diameter.\n"
"Do you want to change the diameter for all extruders to first extruder nozzle diameter value?"));
auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Nozzle diameter")), wxICON_WARNING | wxYES_NO);
if (dialog->ShowModal() == wxID_YES) {
DynamicPrintConfig new_conf = *m_config;
for (size_t i = 1; i < nozzle_diameters.size(); i++)
nozzle_diameters[i] = frst_diam;
new_conf.set_key_value("nozzle_diameter", new ConfigOptionFloats(nozzle_diameters));
load_config(new_conf);
}
break;
}
}
}
}
}
else {
update_dirty();
@ -2318,7 +2345,7 @@ void TabPrinter::build_unregular_pages()
optgroup->m_on_change = [this, extruder_idx](const t_config_option_key& opt_key, boost::any value)
{
if (m_extruders_count > 1 && opt_key.find_first_of("nozzle_diameter") != std::string::npos)
if (m_config->opt_bool("single_extruder_multi_material") && m_extruders_count > 1 && opt_key.find_first_of("nozzle_diameter") != std::string::npos)
{
SuppressBackgroundProcessingUpdate sbpu;
const double new_nd = boost::any_cast<double>(value);

View file

@ -323,9 +323,9 @@ public:
}
bool SwapChildrens(int frst_id, int scnd_id) {
if (GetChildCount() < 2 ||
frst_id < 0 || frst_id >= GetChildCount() ||
scnd_id < 0 || scnd_id >= GetChildCount())
if (GetChildCount() < 2 ||
frst_id < 0 || (size_t)frst_id >= GetChildCount() ||
scnd_id < 0 || (size_t)scnd_id >= GetChildCount())
return false;
ObjectDataViewModelNode new_scnd = *GetNthChild(frst_id);

View file

@ -17,6 +17,7 @@
#define CEREAL_FUTURE_EXPERIMENTAL
#include <cereal/archives/adapters.hpp>
#include <libslic3r/Config.hpp>
#include <libslic3r/ObjectID.hpp>
#include <libslic3r/Utils.hpp>