ENH: add support for gcodeviewer statistics
jira: new Change-Id: Ied6d61e8c48ac82daf16579d9caed9723cf8e29d
This commit is contained in:
parent
39e7ad2c6b
commit
7ec14b3f63
|
@ -4186,16 +4186,19 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
float window_padding = 4.0f * m_scale;
|
||||
const float icon_size = ImGui::GetTextLineHeight() * 0.7;
|
||||
std::vector<float> offsets;
|
||||
std::map<std::string, float> offsets;
|
||||
std::map<int, double> model_volume_of_extruders_all_plates; // map<extruder_idx, volume>
|
||||
std::map<int, double> flushed_volume_of_extruders_all_plates; // map<extruder_idx, flushed volume>
|
||||
std::map<int, double> wipe_tower_volume_of_extruders_all_plates; // map<extruder_idx, flushed volume>
|
||||
std::map<int, double> support_volume_of_extruders_all_plates; // map<extruder_idx, flushed volume>
|
||||
std::vector<double> model_used_filaments_m_all_plates;
|
||||
std::vector<double> model_used_filaments_g_all_plates;
|
||||
std::vector<double> flushed_filaments_m_all_plates;
|
||||
std::vector<double> flushed_filaments_g_all_plates;
|
||||
std::vector<double> wipe_tower_used_filaments_m_all_plates;
|
||||
std::vector<double> wipe_tower_used_filaments_g_all_plates;
|
||||
std::vector<double> support_used_filaments_m_all_plates;
|
||||
std::vector<double> support_used_filaments_g_all_plates;
|
||||
float total_time_all_plates = 0.0f;
|
||||
float total_cost_all_plates = 0.0f;
|
||||
struct ColumnData {
|
||||
|
@ -4203,6 +4206,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
Model = 1,
|
||||
Flushed = 2,
|
||||
WipeTower = 4,
|
||||
Support = 1 << 3,
|
||||
};
|
||||
};
|
||||
int displayed_columns = 0;
|
||||
|
@ -4303,6 +4307,12 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
double wipe_tower_volume = plate_print_statistics.wipe_tower_volumes_per_extruder.at(extruder_id);
|
||||
wipe_tower_volume_of_extruders_all_plates[extruder_id] += wipe_tower_volume;
|
||||
}
|
||||
if (plate_print_statistics.support_volumes_per_extruder.find(extruder_id) == plate_print_statistics.support_volumes_per_extruder.end())
|
||||
support_volume_of_extruders_all_plates[extruder_id] += 0;
|
||||
else {
|
||||
double support_volume = plate_print_statistics.support_volumes_per_extruder.at(extruder_id);
|
||||
support_volume_of_extruders_all_plates[extruder_id] += support_volume;
|
||||
}
|
||||
}
|
||||
const PrintEstimatedStatistics::Mode& plate_time_mode = plate_print_statistics.modes[static_cast<size_t>(m_time_estimate_mode)];
|
||||
total_time_all_plates += plate_time_mode.time;
|
||||
|
@ -4333,6 +4343,13 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
wipe_tower_used_filaments_m_all_plates.push_back(wipe_tower_filament_m);
|
||||
wipe_tower_used_filaments_g_all_plates.push_back(wipe_tower_filament_g);
|
||||
}
|
||||
for (auto it = support_volume_of_extruders_all_plates.begin(); it != support_volume_of_extruders_all_plates.end(); it++) {
|
||||
auto [support_filament_m, support_filament_g] = get_used_filament_from_volume(it->second, it->first);
|
||||
if (support_filament_m != 0.0 || support_filament_g != 0.0)
|
||||
displayed_columns |= ColumnData::Support;
|
||||
support_used_filaments_m_all_plates.push_back(support_filament_m);
|
||||
support_used_filaments_g_all_plates.push_back(support_filament_g);
|
||||
}
|
||||
|
||||
char buff[64];
|
||||
double longest_str = 0.0;
|
||||
|
@ -4342,21 +4359,30 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
}
|
||||
::sprintf(buff, "%.2f", longest_str);
|
||||
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), {buff}}, {_u8L("Flushed"), {buff}}, {_u8L("Total"), {buff}} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[2]} });
|
||||
std::vector<std::pair<std::string, std::vector<::string>>> title_columns;
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
title_columns.push_back({ _u8L("Filament"), {""} });
|
||||
title_columns.push_back({ _u8L("Model"), {buff} });
|
||||
}
|
||||
else if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), {buff}}, {_u8L("Flushed"), {buff}}, {_u8L("Total"), {buff}} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[1]}, {_u8L("Flushed"), offsets[2]}, {_u8L("Total"), offsets[3]} });
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
title_columns.push_back({ _u8L("Support"), {buff} });
|
||||
}
|
||||
else {
|
||||
if (displayed_columns != (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower))
|
||||
displayed_columns = (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower);
|
||||
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), {buff}}, {_u8L("Flushed"), {buff}}, {_u8L("Tower"), {buff}}, {_u8L("Total"), {buff}} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[1]}, {_u8L("Flushed"), offsets[2]}, {_u8L("Tower"), offsets[3]}, {_u8L("Total"), offsets[4]} });
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
title_columns.push_back({ _u8L("Flushed"), {buff} });
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
title_columns.push_back({ _u8L("Tower"), {buff} });
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
title_columns.push_back({ _u8L("Total"), {buff} });
|
||||
}
|
||||
auto offsets_ = calculate_offsets(title_columns, icon_size);
|
||||
std::vector<std::pair<std::string, float>> title_offsets;
|
||||
for (int i = 0; i < offsets_.size(); i++) {
|
||||
title_offsets.push_back({ title_columns[i].first, offsets_[i] });
|
||||
offsets[title_columns[i].first] = offsets_[i];
|
||||
}
|
||||
append_headers(title_offsets);
|
||||
}
|
||||
|
||||
// item
|
||||
|
@ -4365,39 +4391,43 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
for (auto it = model_volume_of_extruders_all_plates.begin(); it != model_volume_of_extruders_all_plates.end(); it++) {
|
||||
if (i < model_used_filaments_m_all_plates.size() && i < model_used_filaments_g_all_plates.size()) {
|
||||
std::vector<std::pair<std::string, float>> columns_offsets;
|
||||
columns_offsets.push_back({ std::to_string(it->first + 1), offsets[0] });
|
||||
columns_offsets.push_back({ std::to_string(it->first + 1), offsets[_u8L("Filament")]});
|
||||
|
||||
char buf[64];
|
||||
double unit_conver = imperial_units ? GizmoObjectManipulation::oz_to_g : 1.0;
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
char buf[64];
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
float column_sum_m = 0.0f;
|
||||
float column_sum_g = 0.0f;
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0)
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
else
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Model")] });
|
||||
column_sum_m += model_used_filaments_m_all_plates[i];
|
||||
column_sum_g += model_used_filaments_g_all_plates[i];
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", flushed_filaments_m_all_plates[i], flushed_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", (model_used_filaments_m_all_plates[i] + flushed_filaments_m_all_plates[i]),
|
||||
(model_used_filaments_g_all_plates[i] + flushed_filaments_g_all_plates[i]) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", support_used_filaments_m_all_plates[i], support_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Support")] });
|
||||
column_sum_m += support_used_filaments_m_all_plates[i];
|
||||
column_sum_g += support_used_filaments_g_all_plates[i];
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", flushed_filaments_m_all_plates[i], flushed_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Flushed")] });
|
||||
column_sum_m += flushed_filaments_m_all_plates[i];
|
||||
column_sum_g += flushed_filaments_g_all_plates[i];
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", wipe_tower_used_filaments_m_all_plates[i], wipe_tower_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", (model_used_filaments_m_all_plates[i] + flushed_filaments_m_all_plates[i] + wipe_tower_used_filaments_m_all_plates[i]),
|
||||
(model_used_filaments_g_all_plates[i] + flushed_filaments_g_all_plates[i] + wipe_tower_used_filaments_g_all_plates[i]) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[4] });
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Tower")] });
|
||||
column_sum_m += wipe_tower_used_filaments_m_all_plates[i];
|
||||
column_sum_g += wipe_tower_used_filaments_g_all_plates[i];
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", column_sum_m, column_sum_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Total")] });
|
||||
}
|
||||
|
||||
append_item(filament_colors[it->first], columns_offsets);
|
||||
|
@ -4800,19 +4830,90 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
std::vector<double> wipe_tower_used_filaments_m;
|
||||
std::vector<double> wipe_tower_used_filaments_g;
|
||||
double total_wipe_tower_used_filament_m = 0, total_wipe_tower_used_filament_g = 0;
|
||||
std::vector<double> support_used_filaments_m;
|
||||
std::vector<double> support_used_filaments_g;
|
||||
double total_support_used_filament_m = 0, total_support_used_filament_g = 0;
|
||||
struct ColumnData {
|
||||
enum {
|
||||
Model = 1,
|
||||
Flushed = 2,
|
||||
WipeTower = 4,
|
||||
Support = 1 << 3,
|
||||
};
|
||||
};
|
||||
int displayed_columns = 0;
|
||||
std::map<std::string, float> color_print_offsets;
|
||||
const PrintStatistics& ps = wxGetApp().plater()->get_partplate_list().get_current_fff_print().print_statistics();
|
||||
double koef = imperial_units ? GizmoObjectManipulation::in_to_mm : 1000.0;
|
||||
double unit_conver = imperial_units ? GizmoObjectManipulation::oz_to_g : 1;
|
||||
|
||||
|
||||
// used filament statistics
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.volumes_per_extruder.find(extruder_id) == m_print_statistics.volumes_per_extruder.end()) {
|
||||
model_used_filaments_m.push_back(0.0);
|
||||
model_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.volumes_per_extruder.at(extruder_id);
|
||||
auto [model_used_filament_m, model_used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
model_used_filaments_m.push_back(model_used_filament_m);
|
||||
model_used_filaments_g.push_back(model_used_filament_g);
|
||||
total_model_used_filament_m += model_used_filament_m;
|
||||
total_model_used_filament_g += model_used_filament_g;
|
||||
displayed_columns |= ColumnData::Model;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.wipe_tower_volumes_per_extruder.find(extruder_id) == m_print_statistics.wipe_tower_volumes_per_extruder.end()) {
|
||||
wipe_tower_used_filaments_m.push_back(0.0);
|
||||
wipe_tower_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.wipe_tower_volumes_per_extruder.at(extruder_id);
|
||||
auto [wipe_tower_used_filament_m, wipe_tower_used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
wipe_tower_used_filaments_m.push_back(wipe_tower_used_filament_m);
|
||||
wipe_tower_used_filaments_g.push_back(wipe_tower_used_filament_g);
|
||||
total_wipe_tower_used_filament_m += wipe_tower_used_filament_m;
|
||||
total_wipe_tower_used_filament_g += wipe_tower_used_filament_g;
|
||||
displayed_columns |= ColumnData::WipeTower;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.flush_per_filament.find(extruder_id) == m_print_statistics.flush_per_filament.end()) {
|
||||
flushed_filaments_m.push_back(0.0);
|
||||
flushed_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.flush_per_filament.at(extruder_id);
|
||||
auto [flushed_filament_m, flushed_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
flushed_filaments_m.push_back(flushed_filament_m);
|
||||
flushed_filaments_g.push_back(flushed_filament_g);
|
||||
total_flushed_filament_m += flushed_filament_m;
|
||||
total_flushed_filament_g += flushed_filament_g;
|
||||
displayed_columns |= ColumnData::Flushed;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.support_volumes_per_extruder.find(extruder_id) == m_print_statistics.support_volumes_per_extruder.end()) {
|
||||
support_used_filaments_m.push_back(0.0);
|
||||
support_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.support_volumes_per_extruder.at(extruder_id);
|
||||
auto [used_filament_m, used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
support_used_filaments_m.push_back(used_filament_m);
|
||||
support_used_filaments_g.push_back(used_filament_g);
|
||||
total_support_used_filament_m += used_filament_m;
|
||||
total_support_used_filament_g += used_filament_g;
|
||||
displayed_columns |= ColumnData::Support;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// extrusion paths section -> title
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
|
@ -4893,76 +4994,36 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
}
|
||||
case EViewType::ColorPrint:
|
||||
{
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.volumes_per_extruder.find(extruder_id) == m_print_statistics.volumes_per_extruder.end()) {
|
||||
model_used_filaments_m.push_back(0.0);
|
||||
model_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.volumes_per_extruder.at(extruder_id);
|
||||
auto [model_used_filament_m, model_used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
model_used_filaments_m.push_back(model_used_filament_m);
|
||||
model_used_filaments_g.push_back(model_used_filament_g);
|
||||
total_model_used_filament_m += model_used_filament_m;
|
||||
total_model_used_filament_g += model_used_filament_g;
|
||||
displayed_columns |= ColumnData::Model;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.wipe_tower_volumes_per_extruder.find(extruder_id) == m_print_statistics.wipe_tower_volumes_per_extruder.end()) {
|
||||
wipe_tower_used_filaments_m.push_back(0.0);
|
||||
wipe_tower_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.wipe_tower_volumes_per_extruder.at(extruder_id);
|
||||
auto [wipe_tower_used_filament_m, wipe_tower_used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
wipe_tower_used_filaments_m.push_back(wipe_tower_used_filament_m);
|
||||
wipe_tower_used_filaments_g.push_back(wipe_tower_used_filament_g);
|
||||
total_wipe_tower_used_filament_m += wipe_tower_used_filament_m;
|
||||
total_wipe_tower_used_filament_g += wipe_tower_used_filament_g;
|
||||
displayed_columns |= ColumnData::WipeTower;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.flush_per_filament.find(extruder_id) == m_print_statistics.flush_per_filament.end()) {
|
||||
flushed_filaments_m.push_back(0.0);
|
||||
flushed_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.flush_per_filament.at(extruder_id);
|
||||
auto [flushed_filament_m, flushed_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
flushed_filaments_m.push_back(flushed_filament_m);
|
||||
flushed_filaments_g.push_back(flushed_filament_g);
|
||||
total_flushed_filament_m += flushed_filament_m;
|
||||
total_flushed_filament_g += flushed_filament_g;
|
||||
displayed_columns |= ColumnData::Flushed;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> total_filaments;
|
||||
char buffer[64];
|
||||
::sprintf(buffer, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", ps.total_used_filament / /*1000*/koef, ps.total_weight / unit_conver);
|
||||
total_filaments.push_back(buffer);
|
||||
|
||||
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), total_filaments}, {_u8L("Flushed"), total_filaments}, {_u8L("Total"), total_filaments} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[2]}});
|
||||
std::vector<std::pair<std::string, std::vector<::string>>> title_columns;
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
title_columns.push_back({ _u8L("Filament"), {""} });
|
||||
title_columns.push_back({ _u8L("Model"), total_filaments });
|
||||
}
|
||||
else if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), total_filaments}, {_u8L("Flushed"), total_filaments}, {_u8L("Total"), total_filaments} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[1]}, {_u8L("Flushed"), offsets[2]}, {_u8L("Total"), offsets[3]} });
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
title_columns.push_back({ _u8L("Support"), total_filaments });
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "displayed_columns: " << displayed_columns;
|
||||
if (displayed_columns != (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower))
|
||||
displayed_columns = (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower);
|
||||
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), total_filaments}, {_u8L("Flushed"), total_filaments}, {_u8L("Tower"), total_filaments}, {_u8L("Total"), total_filaments} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[1]}, {_u8L("Flushed"), offsets[2]}, {_u8L("Tower"), offsets[3]}, {_u8L("Total"), offsets[4]} });
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
title_columns.push_back({ _u8L("Flushed"), total_filaments });
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
title_columns.push_back({ _u8L("Tower"), total_filaments });
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
title_columns.push_back({ _u8L("Total"), total_filaments });
|
||||
}
|
||||
auto offsets_ = calculate_offsets(title_columns, icon_size);
|
||||
std::vector<std::pair<std::string, float>> title_offsets;
|
||||
for (int i = 0; i < offsets_.size(); i++) {
|
||||
title_offsets.push_back({ title_columns[i].first, offsets_[i] });
|
||||
color_print_offsets[title_columns[i].first] = offsets_[i];
|
||||
}
|
||||
append_headers(title_offsets);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -5102,40 +5163,42 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
const bool filament_visible = m_tools.m_tool_visibles[extruder_idx];
|
||||
if (i < model_used_filaments_m.size() && i < model_used_filaments_g.size()) {
|
||||
std::vector<std::pair<std::string, float>> columns_offsets;
|
||||
columns_offsets.push_back({ std::to_string(extruder_idx + 1), offsets[0] });
|
||||
columns_offsets.push_back({ std::to_string(extruder_idx + 1), color_print_offsets[_u8L("Filament")]});
|
||||
|
||||
char buf[64];
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
char buf[64];
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
float column_sum_m = 0.0f;
|
||||
float column_sum_g = 0.0f;
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0)
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
else
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Model")] });
|
||||
column_sum_m += model_used_filaments_m[i];
|
||||
column_sum_g += model_used_filaments_g[i];
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", flushed_filaments_m[i], flushed_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", (model_used_filaments_m[i] + flushed_filaments_m[i]),
|
||||
(model_used_filaments_g[i] + flushed_filaments_g[i]) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", support_used_filaments_m[i], support_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Support")] });
|
||||
column_sum_m += support_used_filaments_m[i];
|
||||
column_sum_g += support_used_filaments_g[i];
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", flushed_filaments_m[i], flushed_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Flushed")]});
|
||||
column_sum_m += flushed_filaments_m[i];
|
||||
column_sum_g += flushed_filaments_g[i];
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", wipe_tower_used_filaments_m[i], wipe_tower_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", (model_used_filaments_m[i] + flushed_filaments_m[i] + wipe_tower_used_filaments_m[i]),
|
||||
(model_used_filaments_g[i] + flushed_filaments_g[i] + wipe_tower_used_filaments_g[i]) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[4] });
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Tower")] });
|
||||
column_sum_m += wipe_tower_used_filaments_m[i];
|
||||
column_sum_g += wipe_tower_used_filaments_g[i];
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", column_sum_m, column_sum_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Total")] });
|
||||
}
|
||||
|
||||
|
||||
append_item(EItemType::Rect, m_tools.m_tool_colors[extruder_idx], columns_offsets, false, filament_visible, [this, extruder_idx]() {
|
||||
m_tools.m_tool_visibles[extruder_idx] = !m_tools.m_tool_visibles[extruder_idx];
|
||||
|
@ -5151,6 +5214,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
if (need_scrollable)
|
||||
ImGui::EndChild();
|
||||
|
||||
// Sum of all rows
|
||||
char buf[64];
|
||||
if (m_extruder_ids.size() > 1) {
|
||||
// Separator
|
||||
|
@ -5161,42 +5225,32 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
window->DrawList->AddLine(separator.Min, ImVec2(separator.Max.x, separator.Min.y), ImGui::GetColorU32(ImGuiCol_Separator));
|
||||
|
||||
std::vector<std::pair<std::string, float>> columns_offsets;
|
||||
columns_offsets.push_back({ _u8L("Total"), offsets[0] });
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||
columns_offsets.push_back({ _u8L("Total"), color_print_offsets[_u8L("Filament")]});
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0)
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
else
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Model")] });
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_flushed_filament_m, total_flushed_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m + total_flushed_filament_m , (total_model_used_filament_g + total_flushed_filament_g) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
|
||||
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_support_used_filament_m, total_support_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Support")] });
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_flushed_filament_m, total_flushed_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Flushed")] });
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_wipe_tower_used_filament_m, total_wipe_tower_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m + total_flushed_filament_m + total_wipe_tower_used_filament_m, (total_model_used_filament_g + total_flushed_filament_g + total_wipe_tower_used_filament_g) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[4] });
|
||||
|
||||
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Tower")] });
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m + total_support_used_filament_m + total_flushed_filament_m + total_wipe_tower_used_filament_m,
|
||||
(total_model_used_filament_g + total_support_used_filament_g + total_flushed_filament_g + total_wipe_tower_used_filament_g) / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Total")] });
|
||||
}
|
||||
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||
}
|
||||
|
||||
//BBS display filament change times
|
||||
|
@ -5567,7 +5621,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.title(time_title);
|
||||
std::string filament_str = _u8L("Filament");
|
||||
std::string total_filament_str = _u8L("Total Filament");
|
||||
std::string model_filament_str = _u8L("Model Filament");
|
||||
std::string cost_str = _u8L("Cost");
|
||||
std::string prepare_str = _u8L("Prepare time");
|
||||
std::string print_str = _u8L("Model printing time");
|
||||
|
@ -5581,7 +5636,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
max_len += std::max(ImGui::CalcTextSize(cost_str.c_str()).x,
|
||||
std::max(ImGui::CalcTextSize(print_str.c_str()).x,
|
||||
std::max(std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x),
|
||||
ImGui::CalcTextSize(filament_str.c_str()).x)));
|
||||
std::max(ImGui::CalcTextSize(total_filament_str.c_str()).x, ImGui::CalcTextSize(model_filament_str.c_str()).x))));
|
||||
else
|
||||
max_len += std::max(ImGui::CalcTextSize(print_str.c_str()).x,
|
||||
(std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x)));
|
||||
|
@ -5591,24 +5646,34 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
//BBS display filament cost
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(filament_str + ":");
|
||||
imgui.text(total_filament_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
|
||||
//BBS: use current plater's print statistics
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
char buf[64];
|
||||
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", ps.total_used_filament / /*1000*/koef);
|
||||
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", ps.total_used_filament / koef);
|
||||
imgui.text(buf);
|
||||
ImGui::SameLine();
|
||||
::sprintf(buf, imperial_units ? " %.2f oz" : " %.2f g", ps.total_weight / unit_conver);
|
||||
imgui.text(buf);
|
||||
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(model_filament_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
auto exlude_m = total_support_used_filament_m + total_flushed_filament_m + total_wipe_tower_used_filament_m;
|
||||
auto exlude_g = total_support_used_filament_g + total_flushed_filament_g + total_wipe_tower_used_filament_g;
|
||||
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", ps.total_used_filament / koef - exlude_m);
|
||||
imgui.text(buf);
|
||||
ImGui::SameLine();
|
||||
::sprintf(buf, imperial_units ? " %.2f oz" : " %.2f g", (ps.total_weight - exlude_g) / unit_conver);
|
||||
imgui.text(buf);
|
||||
|
||||
//BBS: display cost of filaments
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(cost_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
|
||||
::sprintf(buf, "%.2f", ps.total_cost);
|
||||
imgui.text(buf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue