This commit is contained in:
Vojtech Bubnik 2021-03-29 14:15:27 +02:00
commit e94a4da954
6 changed files with 31 additions and 105 deletions

View File

@ -1,2 +1,2 @@
min_slic3r_version = 2.3.0
min_slic3r_version = 2.4.0-alpha0
0.0.1 Initial Artillery bundle

View File

@ -1,2 +1,2 @@
min_slic3r_version = 2.3.0
min_slic3r_version = 2.4.0-alpha0
0.0.1 Initial version

View File

@ -329,7 +329,7 @@ double Control::get_double_value(const SelectedSlider& selection)
int Control::get_tick_from_value(double value)
{
std::vector<double>::iterator it;
if (m_is_smart_wipe_tower)
if (m_is_wipe_tower)
it = std::find_if(m_values.begin(), m_values.end(),
[value](const double & val) { return fabs(value - val) <= epsilon(); });
else
@ -400,8 +400,7 @@ void Control::SetLayersTimes(const std::vector<float>& layers_times, float total
// Erase duplicates values from m_values and save it to the m_layers_values
// They will be used for show the correct estimated time for MM print, when "No sparce layer" is enabled
// See https://github.com/prusa3d/PrusaSlicer/issues/6232
m_is_smart_wipe_tower = m_values.size() != m_layers_times.size();
if (m_is_smart_wipe_tower) {
if (m_is_wipe_tower && m_values.size() != m_layers_times.size()) {
m_layers_values = m_values;
sort(m_layers_values.begin(), m_layers_values.end());
m_layers_values.erase(unique(m_layers_values.begin(), m_layers_values.end()), m_layers_values.end());
@ -411,12 +410,14 @@ void Control::SetLayersTimes(const std::vector<float>& layers_times, float total
if (m_layers_values.size() != m_layers_times.size())
for (size_t i = m_layers_times.size(); i < m_layers_values.size(); i++)
m_layers_times.push_back(total_time);
Refresh();
Update();
}
}
void Control::SetLayersTimes(const std::vector<double>& layers_times)
{
m_is_smart_wipe_tower = false;
m_is_wipe_tower = false;
m_layers_times = layers_times;
for (size_t i = 1; i < m_layers_times.size(); i++)
m_layers_times[i] += m_layers_times[i - 1];
@ -439,6 +440,8 @@ void Control::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, c
m_only_extruder = only_extruder;
UseDefaultColors(m_mode == SingleExtruder);
m_is_wipe_tower = m_mode != SingleExtruder;
}
void Control::SetExtruderColors( const std::vector<std::string>& extruder_colors)
@ -535,7 +538,7 @@ void Control::render()
bool Control::is_wipe_tower_layer(int tick) const
{
if (!m_is_smart_wipe_tower || tick >= (int)m_values.size())
if (!m_is_wipe_tower || tick >= (int)m_values.size())
return false;
if (tick == 0 || (tick == (int)m_values.size() - 1 && m_values[tick] > m_values[tick - 1]))
return false;
@ -723,9 +726,9 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer
it = std::lower_bound(m_values.begin(), m_values.end(), layer_print_z - epsilon());
if (it == m_values.end())
return size_t(-1);
return m_layers_values.size();
return size_t(value + 1);
}
return size_t(it - m_layers_values.begin());
return size_t(it - m_layers_values.begin()+1);
};
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
@ -740,7 +743,7 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
else {
if (label_type == ltEstimatedTime) {
if (m_is_smart_wipe_tower) {
if (m_is_wipe_tower) {
size_t layer_number = get_layer_number(value);
return layer_number == size_t(-1) ? "" : short_and_splitted_time(get_time_dhms(m_layers_times[layer_number]));
}
@ -752,7 +755,7 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer
if (label_type == ltHeight)
return str;
if (label_type == ltHeightWithLayer) {
size_t layer_number = m_is_smart_wipe_tower ? get_layer_number(value) : (m_values.empty() ? value : value + 1);
size_t layer_number = m_is_wipe_tower ? get_layer_number(value) : (m_values.empty() ? value : value + 1);
return format_wxstr("%1%\n(%2%)", str, layer_number);
}
}
@ -1498,7 +1501,7 @@ void Control::OnMotion(wxMouseEvent& event)
m_focus = fiHigherThumb;
else {
tick = get_tick_near_point(pos);
if (tick < 0 && m_is_smart_wipe_tower) {
if (tick < 0 && m_is_wipe_tower) {
tick = get_value_from_position(pos);
m_focus = tick > 0 && is_wipe_tower_layer(tick) && (tick == m_lower_value || tick == m_higher_value) ?
fiSmartWipeTower : fiTick;

View File

@ -370,7 +370,7 @@ private:
bool m_is_focused = false;
bool m_force_mode_apply = true;
bool m_enable_action_icon = true;
bool m_is_smart_wipe_tower = false; //This flag indicates that for current print is used "smart" wipe tower (Print Settings->Multiple Extruders->No sparse layer is enabled)
bool m_is_wipe_tower = false; //This flag indicates that there is multiple extruder print with wipe tower
DrawMode m_draw_mode = dmRegular;

View File

@ -1112,28 +1112,17 @@ void Choice::set_value(const boost::any& value, bool change_event)
int val = boost::any_cast<int>(value);
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "fill_pattern")
{
if (!m_opt.enum_values.empty()) {
std::string key;
t_config_enum_values map_names = ConfigOptionEnum<InfillPattern>::get_enum_values();
for (auto it : map_names) {
if (val == it.second) {
key = it.first;
break;
}
std::string key;
const t_config_enum_values& map_names = ConfigOptionEnum<InfillPattern>::get_enum_values();
for (auto it : map_names)
if (val == it.second) {
key = it.first;
break;
}
size_t idx = 0;
for (auto el : m_opt.enum_values)
{
if (el == key)
break;
++idx;
}
val = idx == m_opt.enum_values.size() ? 0 : idx;
}
else
val = 0;
const std::vector<std::string>& values = m_opt.enum_values;
auto it = std::find(values.begin(), values.end(), key);
val = it == values.end() ? 0 : it - values.begin();
}
field->SetSelection(val);
break;
@ -1199,45 +1188,12 @@ boost::any& Choice::get_value()
if (m_opt.type == coEnum)
{
int ret_enum = field->GetSelection();
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "fill_pattern")
{
if (!m_opt.enum_values.empty()) {
std::string key = m_opt.enum_values[ret_enum];
t_config_enum_values map_names = ConfigOptionEnum<InfillPattern>::get_enum_values();
int value = map_names.at(key);
m_value = static_cast<InfillPattern>(value);
}
else
m_value = static_cast<InfillPattern>(0);
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "fill_pattern") {
const std::string& key = m_opt.enum_values[field->GetSelection()];
m_value = int(ConfigOptionEnum<InfillPattern>::get_enum_values().at(key));
}
else if (m_opt_id.compare("ironing_type") == 0)
m_value = static_cast<IroningType>(ret_enum);
else if (m_opt_id.compare("fuzzy_skin") == 0)
m_value = static_cast<FuzzySkinType>(ret_enum);
else if (m_opt_id.compare("gcode_flavor") == 0)
m_value = static_cast<GCodeFlavor>(ret_enum);
else if (m_opt_id.compare("machine_limits_usage") == 0)
m_value = static_cast<MachineLimitsUsage>(ret_enum);
else if (m_opt_id.compare("support_material_pattern") == 0)
m_value = static_cast<SupportMaterialPattern>(ret_enum);
else if (m_opt_id.compare("support_material_interface_pattern") == 0)
m_value = static_cast<SupportMaterialInterfacePattern>(ret_enum);
else if (m_opt_id.compare("support_material_style") == 0)
m_value = static_cast<SupportMaterialStyle>(ret_enum);
else if (m_opt_id.compare("seam_position") == 0)
m_value = static_cast<SeamPosition>(ret_enum);
else if (m_opt_id.compare("host_type") == 0)
m_value = static_cast<PrintHostType>(ret_enum);
else if (m_opt_id.compare("display_orientation") == 0)
m_value = static_cast<SLADisplayOrientation>(ret_enum);
else if (m_opt_id.compare("support_pillar_connection_mode") == 0)
m_value = static_cast<SLAPillarConnectionMode>(ret_enum);
else if (m_opt_id == "printhost_authorization_type")
m_value = static_cast<AuthorizationType>(ret_enum);
else if (m_opt_id == "brim_type")
m_value = static_cast<BrimType>(ret_enum);
else
m_value = field->GetSelection();
}
else if (m_opt.gui_type == ConfigOptionDef::GUIType::f_enum_open || m_opt.gui_type == ConfigOptionDef::GUIType::i_enum_open) {
const int ret_enum = field->GetSelection();

View File

@ -177,43 +177,10 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
}
break;
case coEnum:{
#if 0
auto *opt = opt_def->default_value.get()->clone();
opt->setInt(0);
opt->setInt(boost::any_cast<int>(value));
config.set_key_value(opt_key, opt);
#else
if (opt_key == "top_fill_pattern" ||
opt_key == "bottom_fill_pattern" ||
opt_key == "fill_pattern")
config.set_key_value(opt_key, new ConfigOptionEnum<InfillPattern>(boost::any_cast<InfillPattern>(value)));
else if (opt_key.compare("ironing_type") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<IroningType>(boost::any_cast<IroningType>(value)));
else if (opt_key.compare("fuzzy_skin") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<FuzzySkinType>(boost::any_cast<FuzzySkinType>(value)));
else if (opt_key.compare("gcode_flavor") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<GCodeFlavor>(boost::any_cast<GCodeFlavor>(value)));
else if (opt_key.compare("machine_limits_usage") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<MachineLimitsUsage>(boost::any_cast<MachineLimitsUsage>(value)));
else if (opt_key.compare("support_material_pattern") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<SupportMaterialPattern>(boost::any_cast<SupportMaterialPattern>(value)));
else if (opt_key.compare("support_material_interface_pattern") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<SupportMaterialInterfacePattern>(boost::any_cast<SupportMaterialInterfacePattern>(value)));
else if (opt_key.compare("support_material_style") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<SupportMaterialStyle>(boost::any_cast<SupportMaterialStyle>(value)));
else if (opt_key.compare("seam_position") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<SeamPosition>(boost::any_cast<SeamPosition>(value)));
else if (opt_key.compare("host_type") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<PrintHostType>(boost::any_cast<PrintHostType>(value)));
else if (opt_key.compare("display_orientation") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<SLADisplayOrientation>(boost::any_cast<SLADisplayOrientation>(value)));
else if(opt_key.compare("support_pillar_connection_mode") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<SLAPillarConnectionMode>(boost::any_cast<SLAPillarConnectionMode>(value)));
else if(opt_key == "printhost_authorization_type")
config.set_key_value(opt_key, new ConfigOptionEnum<AuthorizationType>(boost::any_cast<AuthorizationType>(value)));
else if(opt_key == "brim_type")
config.set_key_value(opt_key, new ConfigOptionEnum<BrimType>(boost::any_cast<BrimType>(value)));
}
#endif
break;
case coPoints:{
if (opt_key == "bed_shape" || opt_key == "thumbnails") {