mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 23:54:00 -06:00
New class ModelConfig wrapping DynamicPrintConfig and a timestamp
to help with detecting "not changed" event when taking Undo/Redo snapshot or synchronizing with the back-end. Converted layer height profile and supports / seam painted areas to the same timestamp controlled structure.
This commit is contained in:
parent
0d6eb842b0
commit
54976e29bb
28 changed files with 366 additions and 215 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "ConfigManipulation.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
#include <wx/msgdlg.h>
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "Field.hpp"
|
||||
//#include <boost-1_70/boost/any.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class ModelConfig;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class ConfigManipulation
|
||||
|
@ -24,13 +26,13 @@ class ConfigManipulation
|
|||
std::function<Field* (const std::string&, int opt_index)> get_field = nullptr;
|
||||
// callback to propagation of changed value, if needed
|
||||
std::function<void(const std::string&, const boost::any&)> cb_value_change = nullptr;
|
||||
DynamicPrintConfig* local_config = nullptr;
|
||||
ModelConfig* local_config = nullptr;
|
||||
|
||||
public:
|
||||
ConfigManipulation(std::function<void()> load_config,
|
||||
std::function<Field* (const std::string&, int opt_index)> get_field,
|
||||
std::function<void(const std::string&, const boost::any&)> cb_value_change,
|
||||
DynamicPrintConfig* local_config = nullptr) :
|
||||
ModelConfig* local_config = nullptr) :
|
||||
load_config(load_config),
|
||||
get_field(get_field),
|
||||
cb_value_change(cb_value_change),
|
||||
|
|
|
@ -511,7 +511,7 @@ void GLCanvas3D::LayersEditing::adaptive_layer_height_profile(GLCanvas3D& canvas
|
|||
{
|
||||
this->update_slicing_parameters();
|
||||
m_layer_height_profile = layer_height_profile_adaptive(*m_slicing_parameters, *m_model_object, quality_factor);
|
||||
const_cast<ModelObject*>(m_model_object)->layer_height_profile = m_layer_height_profile;
|
||||
const_cast<ModelObject*>(m_model_object)->layer_height_profile.set(m_layer_height_profile);
|
||||
m_layers_texture.valid = false;
|
||||
canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ void GLCanvas3D::LayersEditing::smooth_layer_height_profile(GLCanvas3D& canvas,
|
|||
{
|
||||
this->update_slicing_parameters();
|
||||
m_layer_height_profile = smooth_height_profile(m_layer_height_profile, *m_slicing_parameters, smoothing_params);
|
||||
const_cast<ModelObject*>(m_model_object)->layer_height_profile = m_layer_height_profile;
|
||||
const_cast<ModelObject*>(m_model_object)->layer_height_profile.set(m_layer_height_profile);
|
||||
m_layers_texture.valid = false;
|
||||
canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ void GLCanvas3D::LayersEditing::accept_changes(GLCanvas3D& canvas)
|
|||
if (last_object_id >= 0) {
|
||||
if (m_layer_height_profile_modified) {
|
||||
wxGetApp().plater()->take_snapshot(_(L("Variable layer height - Manual edit")));
|
||||
const_cast<ModelObject*>(m_model_object)->layer_height_profile = m_layer_height_profile;
|
||||
const_cast<ModelObject*>(m_model_object)->layer_height_profile.set(m_layer_height_profile);
|
||||
canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ wxSizer* ObjectLayers::create_layer(const t_layer_height_range& range, PlusMinus
|
|||
|
||||
void ObjectLayers::create_layers_list()
|
||||
{
|
||||
for (const auto layer : m_object->layer_config_ranges)
|
||||
for (const auto &layer : m_object->layer_config_ranges)
|
||||
{
|
||||
const t_layer_height_range& range = layer.first;
|
||||
auto del_btn = new PlusMinusButton(m_parent, m_bmp_delete, range);
|
||||
|
|
|
@ -468,7 +468,7 @@ int ObjectList::get_selected_obj_idx() const
|
|||
return -1;
|
||||
}
|
||||
|
||||
DynamicPrintConfig& ObjectList::get_item_config(const wxDataViewItem& item) const
|
||||
ModelConfig& ObjectList::get_item_config(const wxDataViewItem& item) const
|
||||
{
|
||||
assert(item);
|
||||
const ItemType type = m_objects_model->GetItemType(item);
|
||||
|
@ -492,10 +492,10 @@ void ObjectList::update_extruder_values_for_items(const size_t max_extruder)
|
|||
auto object = (*m_objects)[i];
|
||||
wxString extruder;
|
||||
if (!object->config.has("extruder") ||
|
||||
size_t(object->config.option<ConfigOptionInt>("extruder")->value) > max_extruder)
|
||||
size_t(object->config.extruder()) > max_extruder)
|
||||
extruder = _(L("default"));
|
||||
else
|
||||
extruder = wxString::Format("%d", object->config.option<ConfigOptionInt>("extruder")->value);
|
||||
extruder = wxString::Format("%d", object->config.extruder());
|
||||
|
||||
m_objects_model->SetExtruder(extruder, item);
|
||||
|
||||
|
@ -504,10 +504,10 @@ void ObjectList::update_extruder_values_for_items(const size_t max_extruder)
|
|||
item = m_objects_model->GetItemByVolumeId(i, id);
|
||||
if (!item) continue;
|
||||
if (!object->volumes[id]->config.has("extruder") ||
|
||||
size_t(object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value) > max_extruder)
|
||||
size_t(object->volumes[id]->config.extruder()) > max_extruder)
|
||||
extruder = _(L("default"));
|
||||
else
|
||||
extruder = wxString::Format("%d", object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value);
|
||||
extruder = wxString::Format("%d", object->volumes[id]->config.extruder());
|
||||
|
||||
m_objects_model->SetExtruder(extruder, item);
|
||||
}
|
||||
|
@ -767,8 +767,7 @@ void ObjectList::copy_settings_to_clipboard()
|
|||
if (m_objects_model->GetItemType(item) & itSettings)
|
||||
item = m_objects_model->GetParent(item);
|
||||
|
||||
DynamicPrintConfig& config_cache = m_clipboard.get_config_cache();
|
||||
config_cache = get_item_config(item);
|
||||
m_clipboard.get_config_cache() = get_item_config(item).get();
|
||||
}
|
||||
|
||||
void ObjectList::paste_settings_into_list()
|
||||
|
@ -799,7 +798,7 @@ void ObjectList::paste_settings_into_list()
|
|||
}
|
||||
|
||||
// Add settings item for object/sub-object and show them
|
||||
show_settings(add_settings_item(item, m_config));
|
||||
show_settings(add_settings_item(item, &m_config->get()));
|
||||
}
|
||||
|
||||
void ObjectList::paste_volumes_into_list(int obj_idx, const ModelVolumePtrs& volumes)
|
||||
|
@ -818,8 +817,8 @@ void ObjectList::paste_volumes_into_list(int obj_idx, const ModelVolumePtrs& vol
|
|||
{
|
||||
const wxDataViewItem& vol_item = m_objects_model->AddVolumeChild(object_item, wxString::FromUTF8(volume->name.c_str()), volume->type(),
|
||||
volume->get_mesh_errors_count()>0 ,
|
||||
volume->config.has("extruder") ? volume->config.option<ConfigOptionInt>("extruder")->value : 0);
|
||||
add_settings_item(vol_item, &volume->config);
|
||||
volume->config.has("extruder") ? volume->config.extruder() : 0);
|
||||
add_settings_item(vol_item, &volume->config.get());
|
||||
items.Add(vol_item);
|
||||
}
|
||||
|
||||
|
@ -1480,7 +1479,7 @@ void ObjectList::get_settings_choice(const wxString& category_name)
|
|||
// Add settings item for object/sub-object and show them
|
||||
if (!(item_type & (itObject | itVolume | itLayer)))
|
||||
item = m_objects_model->GetTopParent(item);
|
||||
show_settings(add_settings_item(item, m_config));
|
||||
show_settings(add_settings_item(item, &m_config->get()));
|
||||
}
|
||||
|
||||
void ObjectList::get_freq_settings_choice(const wxString& bundle_name)
|
||||
|
@ -1537,7 +1536,7 @@ void ObjectList::get_freq_settings_choice(const wxString& bundle_name)
|
|||
// Add settings item for object/sub-object and show them
|
||||
if (!(item_type & (itObject | itVolume | itLayer)))
|
||||
item = m_objects_model->GetTopParent(item);
|
||||
show_settings(add_settings_item(item, m_config));
|
||||
show_settings(add_settings_item(item, &m_config->get()));
|
||||
}
|
||||
|
||||
void ObjectList::show_settings(const wxDataViewItem settings_item)
|
||||
|
@ -1821,9 +1820,8 @@ void ObjectList::append_menu_item_change_extruder(wxMenu* menu)
|
|||
|
||||
int initial_extruder = -1; // negative value for multiple object/part selection
|
||||
if (sels.Count()==1) {
|
||||
DynamicPrintConfig& config = get_item_config(sels[0]);
|
||||
initial_extruder = !config.has("extruder") ? 0 :
|
||||
config.option<ConfigOptionInt>("extruder")->value;
|
||||
const ModelConfig &config = get_item_config(sels[0]);
|
||||
initial_extruder = config.has("extruder") ? config.extruder() : 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= extruders_cnt; i++)
|
||||
|
@ -2320,9 +2318,7 @@ void ObjectList::del_settings_from_config(const wxDataViewItem& parent_item)
|
|||
|
||||
take_snapshot(_(L("Delete Settings")));
|
||||
|
||||
int extruder = -1;
|
||||
if (m_config->has("extruder"))
|
||||
extruder = m_config->option<ConfigOptionInt>("extruder")->value;
|
||||
int extruder = m_config->has("extruder") ? m_config->extruder() : -1;
|
||||
|
||||
coordf_t layer_height = 0.0;
|
||||
if (is_layer_settings)
|
||||
|
@ -2459,11 +2455,10 @@ void ObjectList::split()
|
|||
const wxDataViewItem& vol_item = m_objects_model->AddVolumeChild(parent, from_u8(volume->name),
|
||||
volume->is_modifier() ? ModelVolumeType::PARAMETER_MODIFIER : ModelVolumeType::MODEL_PART,
|
||||
volume->get_mesh_errors_count()>0,
|
||||
volume->config.has("extruder") ?
|
||||
volume->config.option<ConfigOptionInt>("extruder")->value : 0,
|
||||
volume->config.has("extruder") ? volume->config.extruder() : 0,
|
||||
false);
|
||||
// add settings to the part, if it has those
|
||||
add_settings_item(vol_item, &volume->config);
|
||||
add_settings_item(vol_item, &volume->config.get());
|
||||
}
|
||||
|
||||
model_object->input_file.clear();
|
||||
|
@ -2579,7 +2574,7 @@ void ObjectList::merge(bool to_multipart_object)
|
|||
Model* model = (*m_objects)[0]->get_model();
|
||||
ModelObject* new_object = model->add_object();
|
||||
new_object->name = _u8L("Merged");
|
||||
DynamicPrintConfig* config = &new_object->config;
|
||||
ModelConfig &config = new_object->config;
|
||||
|
||||
for (int obj_idx : obj_idxs)
|
||||
{
|
||||
|
@ -2616,8 +2611,8 @@ void ObjectList::merge(bool to_multipart_object)
|
|||
}
|
||||
|
||||
// merge settings
|
||||
auto new_opt_keys = config->keys();
|
||||
const DynamicPrintConfig& from_config = object->config;
|
||||
auto new_opt_keys = config.keys();
|
||||
const ModelConfig& from_config = object->config;
|
||||
auto opt_keys = from_config.keys();
|
||||
|
||||
for (auto& opt_key : opt_keys) {
|
||||
|
@ -2628,7 +2623,7 @@ void ObjectList::merge(bool to_multipart_object)
|
|||
// get it from default config values
|
||||
option = DynamicPrintConfig::new_from_defaults_keys({ opt_key })->option(opt_key);
|
||||
}
|
||||
config->set_key_value(opt_key, option->clone());
|
||||
config.set_key_value(opt_key, option->clone());
|
||||
}
|
||||
}
|
||||
// save extruder value if it was set
|
||||
|
@ -2695,7 +2690,7 @@ void ObjectList::layers_editing()
|
|||
// set some default value
|
||||
if (ranges.empty()) {
|
||||
take_snapshot(_(L("Add Layers")));
|
||||
ranges[{ 0.0f, 2.0f }] = get_default_layer_config(obj_idx);
|
||||
ranges[{ 0.0f, 2.0f }].assign_config(get_default_layer_config(obj_idx));
|
||||
}
|
||||
|
||||
// create layer root item
|
||||
|
@ -3011,8 +3006,7 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed)
|
|||
auto model_object = (*m_objects)[obj_idx];
|
||||
const wxString& item_name = from_u8(model_object->name);
|
||||
const auto item = m_objects_model->Add(item_name,
|
||||
!model_object->config.has("extruder") ? 0 :
|
||||
model_object->config.option<ConfigOptionInt>("extruder")->value,
|
||||
model_object->config.has("extruder") ? model_object->config.extruder() : 0,
|
||||
get_mesh_errors_count(obj_idx) > 0);
|
||||
|
||||
// add volumes to the object
|
||||
|
@ -3022,10 +3016,9 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed)
|
|||
from_u8(volume->name),
|
||||
volume->type(),
|
||||
volume->get_mesh_errors_count()>0,
|
||||
!volume->config.has("extruder") ? 0 :
|
||||
volume->config.option<ConfigOptionInt>("extruder")->value,
|
||||
volume->config.has("extruder") ? volume->config.extruder() : 0,
|
||||
false);
|
||||
add_settings_item(vol_item, &volume->config);
|
||||
add_settings_item(vol_item, &volume->config.get());
|
||||
}
|
||||
Expand(item);
|
||||
}
|
||||
|
@ -3045,7 +3038,7 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed)
|
|||
m_objects_model->SetPrintableState(model_object->instances[0]->printable ? piPrintable : piUnprintable, obj_idx);
|
||||
|
||||
// add settings to the object, if it has those
|
||||
add_settings_item(item, &model_object->config);
|
||||
add_settings_item(item, &model_object->config.get());
|
||||
|
||||
// Add layers if it has
|
||||
add_layer_root_item(item);
|
||||
|
@ -3123,7 +3116,7 @@ void ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& it
|
|||
if ((*m_objects)[item->obj_idx]->volumes.size() == 1 &&
|
||||
(*m_objects)[item->obj_idx]->config.has("extruder"))
|
||||
{
|
||||
const wxString extruder = wxString::Format("%d", (*m_objects)[item->obj_idx]->config.option<ConfigOptionInt>("extruder")->value);
|
||||
const wxString extruder = wxString::Format("%d", (*m_objects)[item->obj_idx]->config.extruder());
|
||||
m_objects_model->SetExtruder(extruder, m_objects_model->GetItemById(item->obj_idx));
|
||||
}
|
||||
wxGetApp().plater()->canvas3D()->ensure_on_bed(item->obj_idx);
|
||||
|
@ -3289,7 +3282,7 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range curren
|
|||
|
||||
const wxDataViewItem layers_item = GetSelection();
|
||||
|
||||
t_layer_config_ranges& ranges = object(obj_idx)->layer_config_ranges;
|
||||
auto& ranges = object(obj_idx)->layer_config_ranges;
|
||||
auto it_range = ranges.find(current_range);
|
||||
assert(it_range != ranges.end());
|
||||
if (it_range == ranges.end())
|
||||
|
@ -3305,7 +3298,7 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range curren
|
|||
changed = true;
|
||||
|
||||
const t_layer_height_range new_range = { current_range.second, current_range.second + 2. };
|
||||
ranges[new_range] = get_default_layer_config(obj_idx);
|
||||
ranges[new_range].assign_config(get_default_layer_config(obj_idx));
|
||||
add_layer_item(new_range, layers_item);
|
||||
}
|
||||
else if (const std::pair<coordf_t, coordf_t> &next_range = it_next_range->first; current_range.second <= next_range.first)
|
||||
|
@ -3342,7 +3335,7 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range curren
|
|||
add_layer_item(new_range, layers_item, layer_idx);
|
||||
|
||||
new_range = { current_range.second, middle_layer_z };
|
||||
ranges[new_range] = get_default_layer_config(obj_idx);
|
||||
ranges[new_range].assign_config(get_default_layer_config(obj_idx));
|
||||
add_layer_item(new_range, layers_item, layer_idx);
|
||||
}
|
||||
}
|
||||
|
@ -3353,7 +3346,7 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range curren
|
|||
changed = true;
|
||||
|
||||
const t_layer_height_range new_range = { current_range.second, next_range.first };
|
||||
ranges[new_range] = get_default_layer_config(obj_idx);
|
||||
ranges[new_range].assign_config(get_default_layer_config(obj_idx));
|
||||
add_layer_item(new_range, layers_item, layer_idx);
|
||||
}
|
||||
}
|
||||
|
@ -3379,7 +3372,7 @@ wxString ObjectList::can_add_new_range_after_current(const t_layer_height_range
|
|||
// This should not happen.
|
||||
return "ObjectList assert";
|
||||
|
||||
t_layer_config_ranges& ranges = object(obj_idx)->layer_config_ranges;
|
||||
auto& ranges = object(obj_idx)->layer_config_ranges;
|
||||
auto it_range = ranges.find(current_range);
|
||||
assert(it_range != ranges.end());
|
||||
if (it_range == ranges.end())
|
||||
|
@ -3418,7 +3411,7 @@ void ObjectList::add_layer_item(const t_layer_height_range& range,
|
|||
const int obj_idx = m_objects_model->GetObjectIdByItem(layers_item);
|
||||
if (obj_idx < 0) return;
|
||||
|
||||
const DynamicPrintConfig& config = object(obj_idx)->layer_config_ranges[range];
|
||||
const DynamicPrintConfig& config = object(obj_idx)->layer_config_ranges[range].get();
|
||||
if (!config.has("extruder"))
|
||||
return;
|
||||
|
||||
|
@ -3438,7 +3431,7 @@ bool ObjectList::edit_layer_range(const t_layer_height_range& range, coordf_t la
|
|||
if (obj_idx < 0)
|
||||
return false;
|
||||
|
||||
DynamicPrintConfig* config = &object(obj_idx)->layer_config_ranges[range];
|
||||
ModelConfig* config = &object(obj_idx)->layer_config_ranges[range];
|
||||
if (fabs(layer_height - config->opt_float("layer_height")) < EPSILON)
|
||||
return false;
|
||||
|
||||
|
@ -3467,12 +3460,14 @@ bool ObjectList::edit_layer_range(const t_layer_height_range& range, const t_lay
|
|||
|
||||
const ItemType sel_type = m_objects_model->GetItemType(GetSelection());
|
||||
|
||||
t_layer_config_ranges& ranges = object(obj_idx)->layer_config_ranges;
|
||||
auto& ranges = object(obj_idx)->layer_config_ranges;
|
||||
|
||||
const DynamicPrintConfig config = ranges[range];
|
||||
{
|
||||
ModelConfig config = std::move(ranges[range]);
|
||||
ranges.erase(range);
|
||||
ranges[new_range] = std::move(config);
|
||||
}
|
||||
|
||||
ranges.erase(range);
|
||||
ranges[new_range] = config;
|
||||
changed_object(obj_idx);
|
||||
|
||||
wxDataViewItem root_item = m_objects_model->GetLayerRootItem(m_objects_model->GetItemById(obj_idx));
|
||||
|
@ -4040,7 +4035,7 @@ void ObjectList::change_part_type()
|
|||
}
|
||||
else if (!settings_item &&
|
||||
(new_type == ModelVolumeType::MODEL_PART || new_type == ModelVolumeType::PARAMETER_MODIFIER)) {
|
||||
add_settings_item(item, &volume->config);
|
||||
add_settings_item(item, &volume->config.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4065,14 +4060,14 @@ void ObjectList::update_and_show_object_settings_item()
|
|||
if (!item) return;
|
||||
|
||||
const wxDataViewItem& obj_item = m_objects_model->IsSettingsItem(item) ? m_objects_model->GetParent(item) : item;
|
||||
select_item(add_settings_item(obj_item, &get_item_config(obj_item)));
|
||||
select_item(add_settings_item(obj_item, &get_item_config(obj_item).get()));
|
||||
}
|
||||
|
||||
// Update settings item for item had it
|
||||
void ObjectList::update_settings_item_and_selection(wxDataViewItem item, wxDataViewItemArray& selections)
|
||||
{
|
||||
const wxDataViewItem old_settings_item = m_objects_model->GetSettingsItem(item);
|
||||
const wxDataViewItem new_settings_item = add_settings_item(item, &get_item_config(item));
|
||||
const wxDataViewItem new_settings_item = add_settings_item(item, &get_item_config(item).get());
|
||||
|
||||
if (!new_settings_item && old_settings_item)
|
||||
m_objects_model->Delete(old_settings_item);
|
||||
|
@ -4489,19 +4484,19 @@ void ObjectList::set_extruder_for_selected_items(const int extruder) const
|
|||
|
||||
for (const wxDataViewItem& item : sels)
|
||||
{
|
||||
DynamicPrintConfig& config = get_item_config(item);
|
||||
ModelConfig& config = get_item_config(item);
|
||||
|
||||
if (config.has("extruder")) {
|
||||
if (extruder == 0)
|
||||
config.erase("extruder");
|
||||
else
|
||||
config.option<ConfigOptionInt>("extruder")->value = extruder;
|
||||
config.set("extruder", extruder);
|
||||
}
|
||||
else if (extruder > 0)
|
||||
config.set_key_value("extruder", new ConfigOptionInt(extruder));
|
||||
|
||||
const wxString extruder_str = extruder == 0 ? wxString (_(L("default"))) :
|
||||
wxString::Format("%d", config.option<ConfigOptionInt>("extruder")->value);
|
||||
wxString::Format("%d", config.extruder());
|
||||
|
||||
auto const type = m_objects_model->GetItemType(item);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class MenuWithSeparators;
|
|||
namespace Slic3r {
|
||||
class ConfigOptionsGroup;
|
||||
class DynamicPrintConfig;
|
||||
class ModelConfig;
|
||||
class ModelObject;
|
||||
class ModelVolume;
|
||||
class TriangleMesh;
|
||||
|
@ -39,9 +40,9 @@ typedef std::map< std::string, std::vector< std::pair<std::string, std::string>
|
|||
|
||||
typedef std::vector<ModelVolume*> ModelVolumePtrs;
|
||||
|
||||
typedef double coordf_t;
|
||||
typedef std::pair<coordf_t, coordf_t> t_layer_height_range;
|
||||
typedef std::map<t_layer_height_range, DynamicPrintConfig> t_layer_config_ranges;
|
||||
typedef double coordf_t;
|
||||
typedef std::pair<coordf_t, coordf_t> t_layer_height_range;
|
||||
typedef std::map<t_layer_height_range, ModelConfig> t_layer_config_ranges;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -165,7 +166,7 @@ private:
|
|||
wxMenuItem* m_menu_item_split_instances { nullptr };
|
||||
|
||||
ObjectDataViewModel *m_objects_model{ nullptr };
|
||||
DynamicPrintConfig *m_config {nullptr};
|
||||
ModelConfig *m_config {nullptr};
|
||||
std::vector<ModelObject*> *m_objects{ nullptr };
|
||||
|
||||
wxBitmapComboBox *m_extruder_editor { nullptr };
|
||||
|
@ -210,7 +211,7 @@ public:
|
|||
std::map<std::string, wxBitmap> CATEGORY_ICON;
|
||||
|
||||
ObjectDataViewModel* GetModel() const { return m_objects_model; }
|
||||
DynamicPrintConfig* config() const { return m_config; }
|
||||
ModelConfig* config() const { return m_config; }
|
||||
std::vector<ModelObject*>* objects() const { return m_objects; }
|
||||
|
||||
ModelObject* object(const int obj_idx) const ;
|
||||
|
@ -320,7 +321,7 @@ public:
|
|||
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
|
||||
wxBoxSizer* get_sizer() {return m_sizer;}
|
||||
int get_selected_obj_idx() const;
|
||||
DynamicPrintConfig& get_item_config(const wxDataViewItem& item) const;
|
||||
ModelConfig& get_item_config(const wxDataViewItem& item) const;
|
||||
SettingsBundle get_item_settings_bundle(const DynamicPrintConfig* config, const bool is_object_settings);
|
||||
|
||||
void changed_object(const int obj_idx = -1) const;
|
||||
|
|
|
@ -82,7 +82,7 @@ bool ObjectSettings::update_settings_list()
|
|||
return false;
|
||||
|
||||
const bool is_object_settings = objects_model->GetItemType(objects_model->GetParent(item)) == itObject;
|
||||
SettingsBundle cat_options = objects_ctrl->get_item_settings_bundle(config, is_object_settings);
|
||||
SettingsBundle cat_options = objects_ctrl->get_item_settings_bundle(&config->get(), is_object_settings);
|
||||
|
||||
if (!cat_options.empty())
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ bool ObjectSettings::update_settings_list()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ObjectSettings::add_missed_options(DynamicPrintConfig* config_to, const DynamicPrintConfig& config_from)
|
||||
bool ObjectSettings::add_missed_options(ModelConfig* config_to, const DynamicPrintConfig& config_from)
|
||||
{
|
||||
bool is_added = false;
|
||||
if (wxGetApp().plater()->printer_technology() == ptFFF)
|
||||
|
@ -193,7 +193,7 @@ bool ObjectSettings::add_missed_options(DynamicPrintConfig* config_to, const Dyn
|
|||
return is_added;
|
||||
}
|
||||
|
||||
void ObjectSettings::update_config_values(DynamicPrintConfig* config)
|
||||
void ObjectSettings::update_config_values(ModelConfig* config)
|
||||
{
|
||||
const auto objects_model = wxGetApp().obj_list()->GetModel();
|
||||
const auto item = wxGetApp().obj_list()->GetSelection();
|
||||
|
@ -250,14 +250,12 @@ void ObjectSettings::update_config_values(DynamicPrintConfig* config)
|
|||
{
|
||||
const int obj_idx = objects_model->GetObjectIdByItem(item);
|
||||
assert(obj_idx >= 0);
|
||||
DynamicPrintConfig* obj_config = &wxGetApp().model().objects[obj_idx]->config;
|
||||
|
||||
main_config.apply(*obj_config, true);
|
||||
main_config.apply(wxGetApp().model().objects[obj_idx]->config.get(), true);
|
||||
printer_technology == ptFFF ? config_manipulation.update_print_fff_config(&main_config) :
|
||||
config_manipulation.update_print_sla_config(&main_config) ;
|
||||
}
|
||||
|
||||
main_config.apply(*config, true);
|
||||
main_config.apply(config->get(), true);
|
||||
printer_technology == ptFFF ? config_manipulation.update_print_fff_config(&main_config) :
|
||||
config_manipulation.update_print_sla_config(&main_config) ;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ class wxBoxSizer;
|
|||
|
||||
namespace Slic3r {
|
||||
class DynamicPrintConfig;
|
||||
class ModelConfig;
|
||||
namespace GUI {
|
||||
class ConfigOptionsGroup;
|
||||
|
||||
|
@ -52,8 +53,8 @@ public:
|
|||
* Example: if Infill is set to 100%, and Fill Pattern is missed in config_to,
|
||||
* we should add fill_pattern to avoid endless loop in update
|
||||
*/
|
||||
bool add_missed_options(DynamicPrintConfig *config_to, const DynamicPrintConfig &config_from);
|
||||
void update_config_values(DynamicPrintConfig*config);
|
||||
bool add_missed_options(ModelConfig *config_to, const DynamicPrintConfig &config_from);
|
||||
void update_config_values(ModelConfig *config);
|
||||
void UpdateAndShow(const bool show) override;
|
||||
void msw_rescale();
|
||||
};
|
||||
|
|
|
@ -466,7 +466,7 @@ GLGizmoHollow::get_config_options(const std::vector<std::string>& keys) const
|
|||
if (! mo)
|
||||
return out;
|
||||
|
||||
const DynamicPrintConfig& object_cfg = mo->config;
|
||||
const DynamicPrintConfig& object_cfg = mo->config.get();
|
||||
const DynamicPrintConfig& print_cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
|
||||
std::unique_ptr<DynamicPrintConfig> default_cfg = nullptr;
|
||||
|
||||
|
@ -556,7 +556,7 @@ RENDER_AGAIN:
|
|||
auto opts = get_config_options({"hollowing_enable"});
|
||||
m_enable_hollowing = static_cast<const ConfigOptionBool*>(opts[0].first)->value;
|
||||
if (m_imgui->checkbox(m_desc["enable"], m_enable_hollowing)) {
|
||||
mo->config.opt<ConfigOptionBool>("hollowing_enable", true)->value = m_enable_hollowing;
|
||||
mo->config.set("hollowing_enable", m_enable_hollowing);
|
||||
wxGetApp().obj_list()->update_and_show_object_settings_item();
|
||||
config_changed = true;
|
||||
}
|
||||
|
@ -618,14 +618,14 @@ RENDER_AGAIN:
|
|||
}
|
||||
if (slider_edited || slider_released) {
|
||||
if (slider_released) {
|
||||
mo->config.opt<ConfigOptionFloat>("hollowing_min_thickness", true)->value = m_offset_stash;
|
||||
mo->config.opt<ConfigOptionFloat>("hollowing_quality", true)->value = m_quality_stash;
|
||||
mo->config.opt<ConfigOptionFloat>("hollowing_closing_distance", true)->value = m_closing_d_stash;
|
||||
mo->config.set("hollowing_min_thickness", m_offset_stash);
|
||||
mo->config.set("hollowing_quality", m_quality_stash);
|
||||
mo->config.set("hollowing_closing_distance", m_closing_d_stash);
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Hollowing parameter change")));
|
||||
}
|
||||
mo->config.opt<ConfigOptionFloat>("hollowing_min_thickness", true)->value = offset;
|
||||
mo->config.opt<ConfigOptionFloat>("hollowing_quality", true)->value = quality;
|
||||
mo->config.opt<ConfigOptionFloat>("hollowing_closing_distance", true)->value = closing_d;
|
||||
mo->config.set("hollowing_min_thickness", offset);
|
||||
mo->config.set("hollowing_quality", quality);
|
||||
mo->config.set("hollowing_closing_distance", closing_d);
|
||||
if (slider_released) {
|
||||
wxGetApp().obj_list()->update_and_show_object_settings_item();
|
||||
config_changed = true;
|
||||
|
|
|
@ -546,7 +546,7 @@ std::vector<const ConfigOption*> GLGizmoSlaSupports::get_config_options(const st
|
|||
if (! mo)
|
||||
return out;
|
||||
|
||||
const DynamicPrintConfig& object_cfg = mo->config;
|
||||
const DynamicPrintConfig& object_cfg = mo->config.get();
|
||||
const DynamicPrintConfig& print_cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
|
||||
std::unique_ptr<DynamicPrintConfig> default_cfg = nullptr;
|
||||
|
||||
|
@ -753,15 +753,15 @@ RENDER_AGAIN:
|
|||
m_density_stash = density;
|
||||
}
|
||||
if (slider_edited) {
|
||||
mo->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
|
||||
mo->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density;
|
||||
mo->config.set("support_points_minimal_distance", minimal_point_distance);
|
||||
mo->config.set("support_points_density_relative", (int)density);
|
||||
}
|
||||
if (slider_released) {
|
||||
mo->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = m_minimal_point_distance_stash;
|
||||
mo->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)m_density_stash;
|
||||
mo->config.set("support_points_minimal_distance", m_minimal_point_distance_stash);
|
||||
mo->config.set("support_points_density_relative", (int)m_density_stash);
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Support parameter change")));
|
||||
mo->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
|
||||
mo->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density;
|
||||
mo->config.set("support_points_minimal_distance", minimal_point_distance);
|
||||
mo->config.set("support_points_density_relative", (int)density);
|
||||
wxGetApp().obj_list()->update_and_show_object_settings_item();
|
||||
}
|
||||
|
||||
|
|
|
@ -414,7 +414,7 @@ Option ConfigOptionsGroup::get_option(const std::string& opt_key, int opt_index
|
|||
m_opt_map.emplace(opt_id, pair);
|
||||
|
||||
if (m_show_modified_btns) // fill group and category values just fro options from Settings Tab
|
||||
wxGetApp().sidebar().get_searcher().add_key(opt_id, title, config_category);
|
||||
wxGetApp().sidebar().get_searcher().add_key(opt_id, title, this->config_category());
|
||||
|
||||
return Option(*m_config->def()->get(opt_key), opt_id);
|
||||
}
|
||||
|
@ -430,13 +430,11 @@ void ConfigOptionsGroup::on_change_OG(const t_config_option_key& opt_id, const b
|
|||
return;
|
||||
}
|
||||
|
||||
auto itOption = it->second;
|
||||
std::string opt_key = itOption.first;
|
||||
int opt_index = itOption.second;
|
||||
auto itOption = it->second;
|
||||
const std::string &opt_key = itOption.first;
|
||||
int opt_index = itOption.second;
|
||||
|
||||
auto option = m_options.at(opt_id).opt;
|
||||
|
||||
change_opt_value(*m_config, opt_key, value, opt_index == -1 ? 0 : opt_index);
|
||||
this->change_opt_value(opt_key, value, opt_index == -1 ? 0 : opt_index);
|
||||
}
|
||||
|
||||
OptionsGroup::on_change_OG(opt_id, value);
|
||||
|
@ -470,7 +468,7 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config,
|
|||
opt_key == "bed_shape" || opt_key == "filament_ramming_parameters" ||
|
||||
opt_key == "compatible_printers" || opt_key == "compatible_prints" ) {
|
||||
value = get_config_value(config, opt_key);
|
||||
change_opt_value(*m_config, opt_key, value);
|
||||
this->change_opt_value(opt_key, value);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -789,6 +787,15 @@ Field* ConfigOptionsGroup::get_fieldc(const t_config_option_key& opt_key, int op
|
|||
return opt_id.empty() ? nullptr : get_field(opt_id);
|
||||
}
|
||||
|
||||
// Change an option on m_config, possibly call ModelConfig::touch().
|
||||
void ConfigOptionsGroup::change_opt_value(const t_config_option_key& opt_key, const boost::any& value, int opt_index /*= 0*/)
|
||||
|
||||
{
|
||||
Slic3r::GUI::change_opt_value(const_cast<DynamicPrintConfig&>(*m_config), opt_key, value, opt_index);
|
||||
if (m_modelconfig)
|
||||
m_modelconfig->touch();
|
||||
}
|
||||
|
||||
void ogStaticText::SetText(const wxString& value, bool wrap/* = true*/)
|
||||
{
|
||||
SetLabel(value);
|
||||
|
|
|
@ -221,18 +221,18 @@ protected:
|
|||
|
||||
class ConfigOptionsGroup: public OptionsGroup {
|
||||
public:
|
||||
ConfigOptionsGroup( wxWindow* parent, const wxString& title, DynamicPrintConfig* _config = nullptr,
|
||||
ConfigOptionsGroup( wxWindow* parent, const wxString& title, DynamicPrintConfig* config = nullptr,
|
||||
bool is_tab_opt = false, column_t extra_clmn = nullptr) :
|
||||
OptionsGroup(parent, title, is_tab_opt, extra_clmn), m_config(_config) {}
|
||||
OptionsGroup(parent, title, is_tab_opt, extra_clmn), m_config(config) {}
|
||||
ConfigOptionsGroup( wxWindow* parent, const wxString& title, ModelConfig* config,
|
||||
bool is_tab_opt = false, column_t extra_clmn = nullptr) :
|
||||
OptionsGroup(parent, title, is_tab_opt, extra_clmn), m_config(&config->get()), m_modelconfig(config) {}
|
||||
|
||||
/// reference to libslic3r config, non-owning pointer (?).
|
||||
DynamicPrintConfig* m_config {nullptr};
|
||||
bool m_full_labels {0};
|
||||
t_opt_map m_opt_map;
|
||||
const std::string& config_category() const throw() { return m_config_category; }
|
||||
const t_opt_map& opt_map() const throw() { return m_opt_map; }
|
||||
|
||||
std::string config_category;
|
||||
|
||||
void set_config(DynamicPrintConfig* config) { m_config = config; }
|
||||
void set_config_category(const std::string &category) { this->m_config_category = category; }
|
||||
void set_config(DynamicPrintConfig* config) { m_config = config; m_modelconfig = nullptr; }
|
||||
Option get_option(const std::string& opt_key, int opt_index = -1);
|
||||
Line create_single_option_line(const std::string& title, int idx = -1) /*const*/{
|
||||
Option option = get_option(title, idx);
|
||||
|
@ -266,6 +266,20 @@ public:
|
|||
// return option value from config
|
||||
boost::any get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index = -1);
|
||||
Field* get_fieldc(const t_config_option_key& opt_key, int opt_index);
|
||||
|
||||
private:
|
||||
// Reference to libslic3r config or ModelConfig::get(), non-owning pointer.
|
||||
// The reference is const, so that the spots which modify m_config are clearly
|
||||
// demarcated by const_cast and m_config_changed_callback is called afterwards.
|
||||
const DynamicPrintConfig* m_config {nullptr};
|
||||
// If the config is modelconfig, then ModelConfig::touch() has to be called after value change.
|
||||
ModelConfig* m_modelconfig { nullptr };
|
||||
bool m_full_labels{ 0 };
|
||||
t_opt_map m_opt_map;
|
||||
std::string m_config_category;
|
||||
|
||||
// Change an option on m_config, possibly call ModelConfig::touch().
|
||||
void change_opt_value(const t_config_option_key& opt_key, const boost::any& value, int opt_index = 0);
|
||||
};
|
||||
|
||||
// Static text shown among the options.
|
||||
|
|
|
@ -1364,7 +1364,7 @@ void Selection::copy_to_clipboard()
|
|||
ModelObject* dst_object = m_clipboard.add_object();
|
||||
dst_object->name = src_object->name;
|
||||
dst_object->input_file = src_object->input_file;
|
||||
static_cast<DynamicPrintConfig&>(dst_object->config) = static_cast<const DynamicPrintConfig&>(src_object->config);
|
||||
dst_object->config.assign_config(src_object->config);
|
||||
dst_object->sla_support_points = src_object->sla_support_points;
|
||||
dst_object->sla_points_status = src_object->sla_points_status;
|
||||
dst_object->sla_drain_holes = src_object->sla_drain_holes;
|
||||
|
|
|
@ -675,8 +675,8 @@ void Tab::update_changed_tree_ui()
|
|||
{
|
||||
if (!sys_page && modified_page)
|
||||
break;
|
||||
for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) {
|
||||
const std::string& opt_key = it->first;
|
||||
for (const auto &kvp : group->opt_map()) {
|
||||
const std::string& opt_key = kvp.first;
|
||||
get_sys_and_mod_flags(opt_key, sys_page, modified_page);
|
||||
}
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/)
|
|||
is_empty ? m_compatible_prints.btn->Disable() : m_compatible_prints.btn->Enable();
|
||||
}
|
||||
}
|
||||
for (auto kvp : group->m_opt_map) {
|
||||
for (const auto &kvp : group->opt_map()) {
|
||||
const std::string& opt_key = kvp.first;
|
||||
if ((m_options_list[opt_key] & os) == 0)
|
||||
to_sys ? group->back_to_sys_value(opt_key) : group->back_to_initial_value(opt_key);
|
||||
|
@ -3791,7 +3791,7 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la
|
|||
|
||||
//! config_ have to be "right"
|
||||
ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(this, title, m_config, true, extra_column);
|
||||
optgroup->config_category = m_title.ToStdString();
|
||||
optgroup->set_config_category(m_title.ToStdString());
|
||||
if (noncommon_label_width >= 0)
|
||||
optgroup->label_width = noncommon_label_width;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue