diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 0e358d8c73..08ab56db32 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -1033,16 +1033,52 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vectorget_support_slices()) + for (const ExPolygon& polygon : polygons) + supports_volume += polygon.area() *layer_height; + + // Calculate full volume of the object + for (const ExPolygons& polygons : po->get_model_slices()) + for (const ExPolygon& polygon : polygons) + models_volume += polygon.area() *layer_height; + + const SLAPrintObject::SliceIndex& slice_index = po->get_slice_index(); + + // If init_layer_height isn't equivalent to the layer_height, + // let correct volume of the first(initial) layer + if (init_layer_height != layer_height) + { + const auto index = slice_index.begin(); + if (index->second.support_slices_idx != SLAPrintObject::SliceRecord::NONE) + for (const ExPolygon& polygon : po->get_support_slices().front()) + supports_volume += polygon.area() *(init_layer_height - layer_height); + if (index->second.model_slices_idx != SLAPrintObject::SliceRecord::NONE) + for (const ExPolygon& polygon : po->get_model_slices().front()) + models_volume += polygon.area() *(init_layer_height - layer_height); + } + + if (max_layers_cnt < slice_index.size()) + max_layers_cnt = slice_index.size(); + } + + m_print_statistics.support_used_material = supports_volume * SCALING_FACTOR * SCALING_FACTOR; + m_print_statistics.objects_used_material = models_volume * SCALING_FACTOR * SCALING_FACTOR; + // Estimated printing time // A layers count o the highest object - int max_layers_cnt = 0; - for (SLAPrintObject * po : m_objects) { - if (max_layers_cnt < po->get_slice_index().size()) - max_layers_cnt = po->get_slice_index().size(); - } if (max_layers_cnt == 0) - return; - + m_print_statistics.estimated_print_time = "N/A"; float init_exp_time = m_material_config.initial_exposure_time.getFloat();//35; float exp_time = m_material_config.exposure_time.getFloat();//8; @@ -1308,7 +1344,8 @@ DynamicConfig SLAPrintStatistics::config() const DynamicConfig config; const std::string print_time = Slic3r::short_time(this->estimated_print_time); config.set_key_value("print_time", new ConfigOptionString(print_time)); - config.set_key_value("used_material", new ConfigOptionFloat(this->total_used_material/* / 1000.*/)); + config.set_key_value("objects_used_material", new ConfigOptionFloat(this->objects_used_material)); + config.set_key_value("support_used_material", new ConfigOptionFloat(this->support_used_material)); config.set_key_value("total_cost", new ConfigOptionFloat(this->total_cost)); config.set_key_value("total_weight", new ConfigOptionFloat(this->total_weight)); return config; @@ -1318,7 +1355,8 @@ DynamicConfig SLAPrintStatistics::placeholders() { DynamicConfig config; for (const std::string &key : { - "print_time", "used_material", "total_cost", "total_weight" }) + "print_time", "total_cost", "total_weight", + "objects_used_material", "support_used_material" }) config.set_key_value(key, new ConfigOptionString(std::string("{") + key + "}")); return config; } diff --git a/src/libslic3r/SLAPrint.hpp b/src/libslic3r/SLAPrint.hpp index 0e12fff638..f054921c87 100644 --- a/src/libslic3r/SLAPrint.hpp +++ b/src/libslic3r/SLAPrint.hpp @@ -175,7 +175,8 @@ struct SLAPrintStatistics { SLAPrintStatistics() { clear(); } std::string estimated_print_time; - double total_used_material; + double objects_used_material; + double support_used_material; double total_cost; double total_weight; @@ -188,7 +189,8 @@ struct SLAPrintStatistics void clear() { estimated_print_time.clear(); - total_used_material = 0.; + objects_used_material = 0.; + support_used_material = 0.; total_cost = 0.; total_weight = 0.; } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 18a923d453..f4a3c0b48f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -822,8 +822,19 @@ void Sidebar::show_sliced_info_sizer(const bool show) if (p->plater->printer_technology() == ptSLA) { const SLAPrintStatistics& ps = p->plater->sla_print().print_statistics(); - p->sliced_info->SetTextAndShow(siMateril_unit, wxString::Format("%.2f", ps.total_used_material)); - p->sliced_info->SetTextAndShow(siCost, wxString::Format("%.2f", ps.total_cost)); + wxString new_label = _(L("Used Material (mm³)")) + " :"; + const bool is_supports = ps.support_used_material > 0.0; + if (is_supports) + new_label += wxString::Format("\n - %s\n - %s", _(L("object(s)")), _(L("supports and pad"))); + + wxString info_text = is_supports ? + wxString::Format("%.2f \n%.2f \n%.2f", ps.objects_used_material + ps.support_used_material/* / 1000*/, + ps.objects_used_material/* / 1000*/, + ps.support_used_material/* / 1000*/) : + wxString::Format("%.2f", ps.objects_used_material + ps.support_used_material/* / 1000*/); + p->sliced_info->SetTextAndShow(siMateril_unit, info_text, new_label); + + p->sliced_info->SetTextAndShow(siCost, "N/A"/*wxString::Format("%.2f", ps.total_cost)*/); p->sliced_info->SetTextAndShow(siEstimatedTime, ps.estimated_print_time, _(L("Estimated printing time")) + " :"); // Hide non-SLA sliced info parameters