Changed data types
This commit is contained in:
parent
e09207e27e
commit
51b18fddeb
6 changed files with 54 additions and 35 deletions
|
@ -179,6 +179,8 @@ public:
|
|||
DynamicPrintConfig config;
|
||||
// Variation of a layer thickness for spans of Z coordinates.
|
||||
t_layer_height_ranges layer_height_ranges;
|
||||
// Variation of a layer thickness for spans of Z coordinates.
|
||||
t_layer_config_ranges layer_config_ranges;
|
||||
// Profile of increasing z to a layer height, to be linearly interpolated when calculating the layers.
|
||||
// The pairs of <z, layer_height> are packed into a 1D array.
|
||||
std::vector<coordf_t> layer_height_profile;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "libslic3r.h"
|
||||
#include "Utils.hpp"
|
||||
#include "PrintConfig.hpp"
|
||||
|
||||
namespace Slic3r
|
||||
{
|
||||
|
||||
|
@ -129,6 +131,7 @@ inline bool equal_layering(const SlicingParameters &sp1, const SlicingParameters
|
|||
|
||||
typedef std::pair<coordf_t,coordf_t> t_layer_height_range;
|
||||
typedef std::map<t_layer_height_range,coordf_t> t_layer_height_ranges;
|
||||
typedef std::map<t_layer_height_range, DynamicPrintConfig> t_layer_config_ranges;
|
||||
|
||||
extern std::vector<coordf_t> layer_height_profile_from_ranges(
|
||||
const SlicingParameters &slicing_params,
|
||||
|
|
|
@ -23,6 +23,8 @@ ObjectLayers::ObjectLayers(wxWindow* parent) :
|
|||
{
|
||||
m_og->label_width = 1;
|
||||
m_og->set_grid_vgap(5);
|
||||
|
||||
m_og->m_on_change = std::bind(&ObjectLayers::on_change, this, std::placeholders::_1, std::placeholders::_2);
|
||||
|
||||
// Legend for object layers
|
||||
Line line = Line{ "", "" };
|
||||
|
@ -33,9 +35,9 @@ ObjectLayers::ObjectLayers(wxWindow* parent) :
|
|||
def.type = coString;
|
||||
def.width = field_width;
|
||||
|
||||
for (const std::string axis : { "Min Z", "Max Z", "Layer height" }) {
|
||||
def.set_default_value(new ConfigOptionString{ axis });
|
||||
std::string label = boost::algorithm::replace_all_copy(axis, " ", "_");
|
||||
for (const std::string col : { "Min Z", "Max Z", "Layer height" }) {
|
||||
def.set_default_value(new ConfigOptionString{ col });
|
||||
std::string label = boost::algorithm::replace_all_copy(col, " ", "_");
|
||||
boost::algorithm::to_lower(label);
|
||||
line.append_option(Option(def, label + "_legend"));
|
||||
|
||||
|
@ -48,7 +50,7 @@ ObjectLayers::ObjectLayers(wxWindow* parent) :
|
|||
m_bmp_add = ScalableBitmap(parent, "add_copies");
|
||||
}
|
||||
|
||||
static Line create_new_layer(const t_layer_height_ranges::value_type& layer)
|
||||
static Line create_new_layer(const t_layer_config_ranges::value_type& layer, const int idx)
|
||||
{
|
||||
Line line = Line{ "", "" };
|
||||
ConfigOptionDef def;
|
||||
|
@ -57,16 +59,16 @@ static Line create_new_layer(const t_layer_height_ranges::value_type& layer)
|
|||
def.type = coFloat;
|
||||
def.width = field_width;
|
||||
|
||||
std::string label = (boost::format("min_z_%.2f") % layer.first.first).str();
|
||||
std::string label = (boost::format("min_z_%d") % idx).str();
|
||||
def.set_default_value(new ConfigOptionFloat(layer.first.first));
|
||||
line.append_option(Option(def, label));
|
||||
|
||||
label = (boost::format("max_z_%.2f") % layer.first.second).str();
|
||||
label = (boost::format("max_z_%d") % idx).str();
|
||||
def.set_default_value(new ConfigOptionFloat(layer.first.second));
|
||||
line.append_option(Option(def, label));
|
||||
|
||||
label = (boost::format("layer_height_%.2f_%.2f") % layer.first.first % layer.first.second).str();
|
||||
def.set_default_value(new ConfigOptionFloat(layer.second));
|
||||
label = (boost::format("layer_height_%d") % idx).str();
|
||||
def.set_default_value(new ConfigOptionFloat(layer.second.option("layer_height")->getFloat()));
|
||||
line.append_option(Option(def, label));
|
||||
|
||||
return line;
|
||||
|
@ -74,7 +76,7 @@ static Line create_new_layer(const t_layer_height_ranges::value_type& layer)
|
|||
|
||||
void ObjectLayers::create_layers_list()
|
||||
{
|
||||
for (const auto layer : m_object->layer_height_ranges)
|
||||
for (const auto layer : m_object->layer_config_ranges)
|
||||
{
|
||||
auto create_btns = [this, layer](wxWindow* parent) {
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -100,7 +102,7 @@ void ObjectLayers::create_layers_list()
|
|||
return sizer;
|
||||
};
|
||||
|
||||
Line line = create_new_layer(layer);
|
||||
Line line = create_new_layer(layer, m_og->get_grid_sizer()->GetEffectiveRowsCount()-1);
|
||||
line.append_widget(create_btns);
|
||||
m_og->append_line(line);
|
||||
}
|
||||
|
@ -108,15 +110,15 @@ void ObjectLayers::create_layers_list()
|
|||
|
||||
void ObjectLayers::create_layer(int id)
|
||||
{
|
||||
t_layer_height_ranges::iterator layer_range = m_object->layer_height_ranges.begin();
|
||||
t_layer_config_ranges::iterator layer_range = m_object->layer_config_ranges.begin();
|
||||
|
||||
// May be not a best solution #ys_FIXME
|
||||
while (id > 0 && layer_range != m_object->layer_height_ranges.end()) {
|
||||
layer_range++;
|
||||
while (id > 0 && layer_range != m_object->layer_config_ranges.end()) {
|
||||
++layer_range;
|
||||
id--;
|
||||
}
|
||||
|
||||
m_og->append_line(create_new_layer(*layer_range));
|
||||
m_og->append_line(create_new_layer(*layer_range, m_og->get_grid_sizer()->GetEffectiveRowsCount()-1));
|
||||
}
|
||||
|
||||
void ObjectLayers::update_layers_list()
|
||||
|
@ -134,7 +136,7 @@ void ObjectLayers::update_layers_list()
|
|||
if (!(type & (itLayerRoot | itLayer))) return;
|
||||
|
||||
m_object = objects_ctrl->object(obj_idx);
|
||||
if (!m_object || m_object->layer_height_ranges.empty()) return;
|
||||
if (!m_object || m_object->layer_config_ranges.empty()) return;
|
||||
|
||||
// Delete all controls from options group except of the legends
|
||||
|
||||
|
@ -175,5 +177,10 @@ void ObjectLayers::msw_rescale()
|
|||
m_bmp_add.msw_rescale();
|
||||
}
|
||||
|
||||
void ObjectLayers::on_change(t_config_option_key opt_key, const boost::any& value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} //namespace GUI
|
||||
} //namespace Slic3r
|
|
@ -30,6 +30,7 @@ public:
|
|||
|
||||
void UpdateAndShow(const bool show) override;
|
||||
void msw_rescale();
|
||||
void on_change(t_config_option_key opt_key, const boost::any& value);
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -700,10 +700,11 @@ void ObjectList::show_context_menu()
|
|||
if (item)
|
||||
{
|
||||
const ItemType type = m_objects_model->GetItemType(item);
|
||||
if (!(type & (itObject | itVolume | itInstance)))
|
||||
if (!(type & (itObject | itVolume | itLayer | itInstance)))
|
||||
return;
|
||||
|
||||
wxMenu* menu = type & itInstance ? &m_menu_instance :
|
||||
type & itLayer ? &m_menu_layer :
|
||||
m_objects_model->GetParent(item) != wxDataViewItem(0) ? &m_menu_part :
|
||||
printer_technology() == ptFFF ? &m_menu_object : &m_menu_sla_object;
|
||||
|
||||
|
@ -1694,7 +1695,7 @@ void ObjectList::del_instances_from_object(const int obj_idx)
|
|||
|
||||
void ObjectList::del_layers_from_object(const int obj_idx)
|
||||
{
|
||||
object(obj_idx)->layer_height_ranges.clear(); // ? #ys_FIXME
|
||||
object(obj_idx)->layer_config_ranges.clear();
|
||||
|
||||
changed_object(obj_idx);
|
||||
}
|
||||
|
@ -1739,13 +1740,13 @@ bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, con
|
|||
object->delete_instance(idx);
|
||||
}
|
||||
else if (type == itLayer) {
|
||||
t_layer_height_ranges::iterator layer_range = object->layer_height_ranges.begin();
|
||||
t_layer_config_ranges::iterator layer_range = object->layer_config_ranges.begin();
|
||||
int id = idx;
|
||||
while (id > 0 && layer_range != object->layer_height_ranges.end()) {
|
||||
while (id > 0 && layer_range != object->layer_config_ranges.end()) {
|
||||
layer_range++;
|
||||
id--;
|
||||
}
|
||||
object->layer_height_ranges.erase(layer_range);
|
||||
object->layer_config_ranges.erase(layer_range);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
@ -1816,14 +1817,16 @@ void ObjectList::layers_editing()
|
|||
// if it doesn't exist now
|
||||
if (!layers_item.IsOk())
|
||||
{
|
||||
// create LayerRoor item
|
||||
// create LayerRoot item
|
||||
layers_item = m_objects_model->AddLayersRoot(obj_item);
|
||||
|
||||
if (object(obj_idx)->layer_height_ranges.empty())
|
||||
object(obj_idx)->layer_height_ranges[{ 0.0f, 0.2f }] = 0.1f;// some default value
|
||||
|
||||
// and create Layer item(s) according to the layer_height_ranges
|
||||
for (const auto range : object(obj_idx)->layer_height_ranges)
|
||||
t_layer_config_ranges& ranges = object(obj_idx)->layer_config_ranges;
|
||||
|
||||
if (ranges.empty())
|
||||
ranges[{ 0.0f, 0.2f }] = *DynamicPrintConfig::new_from_defaults_keys({"layer_height"});// some default value
|
||||
|
||||
// and create Layer item(s) according to the layer_config_ranges
|
||||
for (const auto range : ranges)
|
||||
add_layer_item(range.first, layers_item);
|
||||
}
|
||||
|
||||
|
@ -2239,10 +2242,10 @@ void ObjectList::add_layer_range(const t_layer_height_range& range)
|
|||
|
||||
wxDataViewItem layers_item = GetSelection();
|
||||
|
||||
t_layer_height_ranges& ranges = object(obj_idx)->layer_height_ranges;
|
||||
t_layer_config_ranges& ranges = object(obj_idx)->layer_config_ranges;
|
||||
|
||||
const t_layer_height_ranges::iterator selected_range = ranges.find(range);
|
||||
const t_layer_height_ranges::iterator last_range = --ranges.end();
|
||||
const t_layer_config_ranges::iterator selected_range = ranges.find(range);
|
||||
const t_layer_config_ranges::iterator last_range = --ranges.end();
|
||||
|
||||
if (selected_range->first == last_range->first)
|
||||
{
|
||||
|
@ -2253,13 +2256,13 @@ void ObjectList::add_layer_range(const t_layer_height_range& range)
|
|||
else
|
||||
{
|
||||
int layer_idx = 0;
|
||||
t_layer_height_ranges::iterator next_range = ++ranges.find(range);
|
||||
t_layer_config_ranges::iterator next_range = ++ranges.find(range);
|
||||
|
||||
// May be not a best solution #ys_FIXME
|
||||
t_layer_height_ranges::iterator it = ranges.begin();
|
||||
t_layer_config_ranges::iterator it = ranges.begin();
|
||||
while (it != next_range && it != ranges.end()) {
|
||||
layer_idx++;
|
||||
it++;
|
||||
++it;
|
||||
}
|
||||
|
||||
if (selected_range->first.second == next_range->first.first)
|
||||
|
@ -2269,7 +2272,8 @@ void ObjectList::add_layer_range(const t_layer_height_range& range)
|
|||
return;
|
||||
|
||||
const coordf_t midl_layer = next_range->first.first + 0.5f * delta;
|
||||
const coordf_t old_height = next_range->second;
|
||||
// #ys_FIXME May be it should be copied just a "layer_height" option
|
||||
const /*coordf_t*/auto old_config = next_range->second;
|
||||
t_layer_height_range new_range = { midl_layer, next_range->first.second };
|
||||
|
||||
// delete old layer
|
||||
|
@ -2279,7 +2283,7 @@ void ObjectList::add_layer_range(const t_layer_height_range& range)
|
|||
|
||||
// create new 2 layers instead of deleted one
|
||||
|
||||
ranges[new_range] = old_height;
|
||||
ranges[new_range] = old_config;
|
||||
add_layer_item(new_range, layers_item, layer_idx);
|
||||
|
||||
new_range = { selected_range->first.second, midl_layer };
|
||||
|
@ -2996,7 +3000,8 @@ void ObjectList::msw_rescale()
|
|||
for (MenuWithSeparators* menu : { &m_menu_object,
|
||||
&m_menu_part,
|
||||
&m_menu_sla_object,
|
||||
&m_menu_instance })
|
||||
&m_menu_instance,
|
||||
&m_menu_layer })
|
||||
msw_rescale_menu(menu);
|
||||
|
||||
Layout();
|
||||
|
|
|
@ -119,6 +119,7 @@ class ObjectList : public wxDataViewCtrl
|
|||
MenuWithSeparators m_menu_part;
|
||||
MenuWithSeparators m_menu_sla_object;
|
||||
MenuWithSeparators m_menu_instance;
|
||||
MenuWithSeparators m_menu_layer;
|
||||
wxMenuItem* m_menu_item_settings { nullptr };
|
||||
wxMenuItem* m_menu_item_split_instances { nullptr };
|
||||
|
||||
|
|
Loading…
Reference in a new issue