mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-21 04:23:15 +08:00
ENH: seperate wipe tower weight from model
jira:STUDIO-4353 Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Ia8a030314ab995c57a0990d08a966382f6f0eecc
This commit is contained in:
parent
394a602e8f
commit
81bab138b5
@ -1002,6 +1002,21 @@ namespace DoExport {
|
|||||||
total_cost += weight * extruder->filament_cost() * 0.001;
|
total_cost += weight * extruder->filament_cost() * 0.001;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto volume : result.print_statistics.wipe_tower_volumes_per_extruder) {
|
||||||
|
total_extruded_volume += volume.second;
|
||||||
|
|
||||||
|
size_t extruder_id = volume.first;
|
||||||
|
auto extruder = std::find_if(extruders.begin(), extruders.end(), [extruder_id](const Extruder& extr) {return extr.id() == extruder_id; });
|
||||||
|
if (extruder == extruders.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
double s = PI * sqr(0.5* extruder->filament_diameter());
|
||||||
|
double weight = volume.second * extruder->filament_density() * 0.001;
|
||||||
|
total_used_filament += volume.second/s;
|
||||||
|
total_weight += weight;
|
||||||
|
total_cost += weight * extruder->filament_cost() * 0.001;
|
||||||
|
}
|
||||||
|
|
||||||
print_statistics.total_extruded_volume = total_extruded_volume;
|
print_statistics.total_extruded_volume = total_extruded_volume;
|
||||||
print_statistics.total_used_filament = total_used_filament;
|
print_statistics.total_used_filament = total_used_filament;
|
||||||
print_statistics.total_weight = total_weight;
|
print_statistics.total_weight = total_weight;
|
||||||
|
@ -58,7 +58,8 @@ const std::vector<std::string> GCodeProcessor::Reserved_Tags = {
|
|||||||
"_GP_LAST_LINE_M73_PLACEHOLDER",
|
"_GP_LAST_LINE_M73_PLACEHOLDER",
|
||||||
"_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER",
|
"_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER",
|
||||||
"_GP_TOTAL_LAYER_NUMBER_PLACEHOLDER",
|
"_GP_TOTAL_LAYER_NUMBER_PLACEHOLDER",
|
||||||
"_DURING_PRINT_EXHAUST_FAN"
|
" WIPE_TOWER_START",
|
||||||
|
" WIPE_TOWER_END"
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string GCodeProcessor::Flush_Start_Tag = " FLUSH_START";
|
const std::string GCodeProcessor::Flush_Start_Tag = " FLUSH_START";
|
||||||
@ -698,22 +699,30 @@ void GCodeProcessor::UsedFilaments::reset()
|
|||||||
color_change_cache = 0.0f;
|
color_change_cache = 0.0f;
|
||||||
volumes_per_color_change = std::vector<double>();
|
volumes_per_color_change = std::vector<double>();
|
||||||
|
|
||||||
tool_change_cache = 0.0f;
|
model_extrude_cache = 0.0f;
|
||||||
volumes_per_extruder.clear();
|
volumes_per_extruder.clear();
|
||||||
|
|
||||||
flush_per_filament.clear();
|
flush_per_filament.clear();
|
||||||
|
|
||||||
role_cache = 0.0f;
|
role_cache = 0.0f;
|
||||||
filaments_per_role.clear();
|
filaments_per_role.clear();
|
||||||
|
|
||||||
|
wipe_tower_cache = 0.0f;
|
||||||
|
wipe_tower_volume_per_extruder.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeProcessor::UsedFilaments::increase_caches(double extruded_volume)
|
void GCodeProcessor::UsedFilaments::increase_model_caches(double extruded_volume)
|
||||||
{
|
{
|
||||||
color_change_cache += extruded_volume;
|
color_change_cache += extruded_volume;
|
||||||
tool_change_cache += extruded_volume;
|
model_extrude_cache += extruded_volume;
|
||||||
role_cache += extruded_volume;
|
role_cache += extruded_volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::UsedFilaments::increase_wipe_tower_caches(double extruded_volume)
|
||||||
|
{
|
||||||
|
wipe_tower_cache += extruded_volume;
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeProcessor::UsedFilaments::process_color_change_cache()
|
void GCodeProcessor::UsedFilaments::process_color_change_cache()
|
||||||
{
|
{
|
||||||
if (color_change_cache != 0.0f) {
|
if (color_change_cache != 0.0f) {
|
||||||
@ -722,15 +731,27 @@ void GCodeProcessor::UsedFilaments::process_color_change_cache()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeProcessor::UsedFilaments::process_extruder_cache(GCodeProcessor* processor)
|
void GCodeProcessor::UsedFilaments::process_model_cache(GCodeProcessor* processor)
|
||||||
{
|
{
|
||||||
size_t active_extruder_id = processor->m_extruder_id;
|
size_t active_extruder_id = processor->m_extruder_id;
|
||||||
if (tool_change_cache != 0.0f) {
|
if (model_extrude_cache != 0.0f) {
|
||||||
if (volumes_per_extruder.find(active_extruder_id) != volumes_per_extruder.end())
|
if (volumes_per_extruder.find(active_extruder_id) != volumes_per_extruder.end())
|
||||||
volumes_per_extruder[active_extruder_id] += tool_change_cache;
|
volumes_per_extruder[active_extruder_id] += model_extrude_cache;
|
||||||
else
|
else
|
||||||
volumes_per_extruder[active_extruder_id] = tool_change_cache;
|
volumes_per_extruder[active_extruder_id] = model_extrude_cache;
|
||||||
tool_change_cache = 0.0f;
|
model_extrude_cache = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::UsedFilaments::process_wipe_tower_cache(GCodeProcessor* processor)
|
||||||
|
{
|
||||||
|
size_t active_extruder_id = processor->m_extruder_id;
|
||||||
|
if (wipe_tower_cache != 0.0f) {
|
||||||
|
if (wipe_tower_volume_per_extruder.find(active_extruder_id) != wipe_tower_volume_per_extruder.end())
|
||||||
|
wipe_tower_volume_per_extruder[active_extruder_id] += wipe_tower_cache;
|
||||||
|
else
|
||||||
|
wipe_tower_volume_per_extruder[active_extruder_id] = wipe_tower_cache;
|
||||||
|
wipe_tower_cache = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,8 +786,9 @@ void GCodeProcessor::UsedFilaments::process_role_cache(GCodeProcessor* processor
|
|||||||
void GCodeProcessor::UsedFilaments::process_caches(GCodeProcessor* processor)
|
void GCodeProcessor::UsedFilaments::process_caches(GCodeProcessor* processor)
|
||||||
{
|
{
|
||||||
process_color_change_cache();
|
process_color_change_cache();
|
||||||
process_extruder_cache(processor);
|
process_model_cache(processor);
|
||||||
process_role_cache(processor);
|
process_role_cache(processor);
|
||||||
|
process_wipe_tower_cache(processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
@ -1266,6 +1288,7 @@ void GCodeProcessor::reset()
|
|||||||
m_cached_position.reset();
|
m_cached_position.reset();
|
||||||
m_wiping = false;
|
m_wiping = false;
|
||||||
m_flushing = false;
|
m_flushing = false;
|
||||||
|
m_wipe_tower = false;
|
||||||
m_remaining_volume = 0.f;
|
m_remaining_volume = 0.f;
|
||||||
// BBS: arc move related data
|
// BBS: arc move related data
|
||||||
m_move_path_type = EMovePathType::Noop_move;
|
m_move_path_type = EMovePathType::Noop_move;
|
||||||
@ -2042,6 +2065,17 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (boost::starts_with(comment, reserved_tag(ETags::Wipe_Tower_Start))) {
|
||||||
|
m_wipe_tower = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (boost::starts_with(comment, reserved_tag(ETags::Wipe_Tower_End))) {
|
||||||
|
m_wipe_tower = false;
|
||||||
|
m_used_filaments.process_wipe_tower_cache(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//BBS: flush start tag
|
//BBS: flush start tag
|
||||||
if (boost::starts_with(comment, GCodeProcessor::Flush_Start_Tag)) {
|
if (boost::starts_with(comment, GCodeProcessor::Flush_Start_Tag)) {
|
||||||
m_flushing = true;
|
m_flushing = true;
|
||||||
@ -2731,10 +2765,13 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
|||||||
float delta_xyz = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
|
float delta_xyz = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
|
||||||
float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
|
float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
|
||||||
float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
|
float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
|
||||||
|
if (m_wipe_tower) {
|
||||||
|
m_used_filaments.increase_wipe_tower_caches(volume_extruded_filament);
|
||||||
|
}
|
||||||
|
else {
|
||||||
// save extruded volume to the cache
|
// save extruded volume to the cache
|
||||||
m_used_filaments.increase_caches(volume_extruded_filament);
|
m_used_filaments.increase_model_caches(volume_extruded_filament);
|
||||||
|
}
|
||||||
// volume extruded filament / tool displacement = area toolpath cross section
|
// volume extruded filament / tool displacement = area toolpath cross section
|
||||||
m_mm3_per_mm = area_toolpath_cross_section;
|
m_mm3_per_mm = area_toolpath_cross_section;
|
||||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
@ -3188,10 +3225,14 @@ void GCodeProcessor::process_G2_G3(const GCodeReader::GCodeLine& line)
|
|||||||
if (type == EMoveType::Extrude) {
|
if (type == EMoveType::Extrude) {
|
||||||
float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
|
float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
|
||||||
float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
|
float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
|
||||||
|
if (m_wipe_tower) {
|
||||||
|
//BBS: save wipe tower volume to the cache
|
||||||
|
m_used_filaments.increase_wipe_tower_caches(volume_extruded_filament);
|
||||||
|
}
|
||||||
|
else {
|
||||||
//BBS: save extruded volume to the cache
|
//BBS: save extruded volume to the cache
|
||||||
m_used_filaments.increase_caches(volume_extruded_filament);
|
m_used_filaments.increase_model_caches(volume_extruded_filament);
|
||||||
|
}
|
||||||
//BBS: volume extruded filament / tool displacement = area toolpath cross section
|
//BBS: volume extruded filament / tool displacement = area toolpath cross section
|
||||||
m_mm3_per_mm = area_toolpath_cross_section;
|
m_mm3_per_mm = area_toolpath_cross_section;
|
||||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
@ -4236,7 +4277,7 @@ void GCodeProcessor::process_filaments(CustomGCode::Type code)
|
|||||||
m_used_filaments.process_color_change_cache();
|
m_used_filaments.process_color_change_cache();
|
||||||
|
|
||||||
if (code == CustomGCode::ToolChange) {
|
if (code == CustomGCode::ToolChange) {
|
||||||
m_used_filaments.process_extruder_cache(this);
|
m_used_filaments.process_model_cache(this);
|
||||||
//BBS: reset remaining filament
|
//BBS: reset remaining filament
|
||||||
m_remaining_volume = m_nozzle_volume;
|
m_remaining_volume = m_nozzle_volume;
|
||||||
}
|
}
|
||||||
@ -4269,6 +4310,7 @@ void GCodeProcessor::update_estimated_times_stats()
|
|||||||
|
|
||||||
m_result.print_statistics.volumes_per_color_change = m_used_filaments.volumes_per_color_change;
|
m_result.print_statistics.volumes_per_color_change = m_used_filaments.volumes_per_color_change;
|
||||||
m_result.print_statistics.volumes_per_extruder = m_used_filaments.volumes_per_extruder;
|
m_result.print_statistics.volumes_per_extruder = m_used_filaments.volumes_per_extruder;
|
||||||
|
m_result.print_statistics.wipe_tower_volumes_per_extruder = m_used_filaments.wipe_tower_volume_per_extruder;
|
||||||
m_result.print_statistics.flush_per_filament = m_used_filaments.flush_per_filament;
|
m_result.print_statistics.flush_per_filament = m_used_filaments.flush_per_filament;
|
||||||
m_result.print_statistics.used_filaments_per_role = m_used_filaments.filaments_per_role;
|
m_result.print_statistics.used_filaments_per_role = m_used_filaments.filaments_per_role;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@ namespace Slic3r {
|
|||||||
|
|
||||||
std::vector<double> volumes_per_color_change;
|
std::vector<double> volumes_per_color_change;
|
||||||
std::map<size_t, double> volumes_per_extruder;
|
std::map<size_t, double> volumes_per_extruder;
|
||||||
|
std::map<size_t, double> wipe_tower_volumes_per_extruder;
|
||||||
//BBS: the flush amount of every filament
|
//BBS: the flush amount of every filament
|
||||||
std::map<size_t, double> flush_per_filament;
|
std::map<size_t, double> flush_per_filament;
|
||||||
std::map<ExtrusionRole, std::pair<double, double>> used_filaments_per_role;
|
std::map<ExtrusionRole, std::pair<double, double>> used_filaments_per_role;
|
||||||
@ -87,6 +88,7 @@ namespace Slic3r {
|
|||||||
}
|
}
|
||||||
volumes_per_color_change.clear();
|
volumes_per_color_change.clear();
|
||||||
volumes_per_color_change.shrink_to_fit();
|
volumes_per_color_change.shrink_to_fit();
|
||||||
|
wipe_tower_volumes_per_extruder.clear();
|
||||||
volumes_per_extruder.clear();
|
volumes_per_extruder.clear();
|
||||||
flush_per_filament.clear();
|
flush_per_filament.clear();
|
||||||
used_filaments_per_role.clear();
|
used_filaments_per_role.clear();
|
||||||
@ -256,7 +258,8 @@ namespace Slic3r {
|
|||||||
Last_Line_M73_Placeholder,
|
Last_Line_M73_Placeholder,
|
||||||
Estimated_Printing_Time_Placeholder,
|
Estimated_Printing_Time_Placeholder,
|
||||||
Total_Layer_Number_Placeholder,
|
Total_Layer_Number_Placeholder,
|
||||||
During_Print_Exhaust_Fan
|
Wipe_Tower_Start,
|
||||||
|
Wipe_Tower_End,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::string& reserved_tag(ETags tag) { return Reserved_Tags[static_cast<unsigned char>(tag)]; }
|
static const std::string& reserved_tag(ETags tag) { return Reserved_Tags[static_cast<unsigned char>(tag)]; }
|
||||||
@ -467,9 +470,12 @@ namespace Slic3r {
|
|||||||
double color_change_cache;
|
double color_change_cache;
|
||||||
std::vector<double> volumes_per_color_change;
|
std::vector<double> volumes_per_color_change;
|
||||||
|
|
||||||
double tool_change_cache;
|
double model_extrude_cache;
|
||||||
std::map<size_t, double> volumes_per_extruder;
|
std::map<size_t, double> volumes_per_extruder;
|
||||||
|
|
||||||
|
double wipe_tower_cache;
|
||||||
|
std::map<size_t, double>wipe_tower_volume_per_extruder;
|
||||||
|
|
||||||
//BBS: the flush amount of every filament
|
//BBS: the flush amount of every filament
|
||||||
std::map<size_t, double> flush_per_filament;
|
std::map<size_t, double> flush_per_filament;
|
||||||
|
|
||||||
@ -478,10 +484,12 @@ namespace Slic3r {
|
|||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void increase_caches(double extruded_volume);
|
void increase_model_caches(double extruded_volume);
|
||||||
|
void increase_wipe_tower_caches(double extruded_volume);
|
||||||
|
|
||||||
void process_color_change_cache();
|
void process_color_change_cache();
|
||||||
void process_extruder_cache(GCodeProcessor* processor);
|
void process_model_cache(GCodeProcessor* processor);
|
||||||
|
void process_wipe_tower_cache(GCodeProcessor* processor);
|
||||||
void update_flush_per_filament(size_t extrude_id, float flush_length);
|
void update_flush_per_filament(size_t extrude_id, float flush_length);
|
||||||
void process_role_cache(GCodeProcessor* processor);
|
void process_role_cache(GCodeProcessor* processor);
|
||||||
void process_caches(GCodeProcessor* processor);
|
void process_caches(GCodeProcessor* processor);
|
||||||
@ -630,6 +638,7 @@ namespace Slic3r {
|
|||||||
CachedPosition m_cached_position;
|
CachedPosition m_cached_position;
|
||||||
bool m_wiping;
|
bool m_wiping;
|
||||||
bool m_flushing;
|
bool m_flushing;
|
||||||
|
bool m_wipe_tower;
|
||||||
float m_remaining_volume;
|
float m_remaining_volume;
|
||||||
|
|
||||||
//BBS: x, y offset for gcode generated
|
//BBS: x, y offset for gcode generated
|
||||||
|
@ -770,6 +770,7 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool, bool extrude_per
|
|||||||
"; CP TOOLCHANGE START\n")
|
"; CP TOOLCHANGE START\n")
|
||||||
.comment_with_value(" toolchange #", m_num_tool_changes + 1); // the number is zero-based
|
.comment_with_value(" toolchange #", m_num_tool_changes + 1); // the number is zero-based
|
||||||
|
|
||||||
|
|
||||||
if (tool != (unsigned)(-1))
|
if (tool != (unsigned)(-1))
|
||||||
writer.append(std::string("; material : " + (m_current_tool < m_filpar.size() ? m_filpar[m_current_tool].material : "(NONE)") + " -> " + m_filpar[tool].material + "\n").c_str())
|
writer.append(std::string("; material : " + (m_current_tool < m_filpar.size() ? m_filpar[m_current_tool].material : "(NONE)") + " -> " + m_filpar[tool].material + "\n").c_str())
|
||||||
.append(";--------------------\n");
|
.append(";--------------------\n");
|
||||||
@ -787,6 +788,7 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool, bool extrude_per
|
|||||||
|
|
||||||
// Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
|
// Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
|
||||||
if (tool != (unsigned int)-1){ // This is not the last change.
|
if (tool != (unsigned int)-1){ // This is not the last change.
|
||||||
|
writer.append(";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_Tower_Start) + "\n");
|
||||||
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material,
|
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material,
|
||||||
is_first_layer() ? m_filpar[tool].nozzle_temperature_initial_layer : m_filpar[tool].nozzle_temperature);
|
is_first_layer() ? m_filpar[tool].nozzle_temperature_initial_layer : m_filpar[tool].nozzle_temperature);
|
||||||
toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials.
|
toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials.
|
||||||
@ -806,8 +808,8 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool, bool extrude_per
|
|||||||
writer.travel(Vec2f(0, 0));
|
writer.travel(Vec2f(0, 0));
|
||||||
writer.travel(initial_position);
|
writer.travel(initial_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolchange_Wipe(writer, cleaning_box, wipe_length); // Wipe the newly loaded filament until the end of the assigned wipe area.
|
toolchange_Wipe(writer, cleaning_box, wipe_length); // Wipe the newly loaded filament until the end of the assigned wipe area.
|
||||||
|
writer.append(";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_Tower_End) + "\n");
|
||||||
++ m_num_tool_changes;
|
++ m_num_tool_changes;
|
||||||
} else
|
} else
|
||||||
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].nozzle_temperature);
|
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].nozzle_temperature);
|
||||||
|
@ -936,9 +936,9 @@ void GCodeViewer::update_by_mode(ConfigOptionMode mode)
|
|||||||
view_type_items.push_back(EViewType::LayerTime);
|
view_type_items.push_back(EViewType::LayerTime);
|
||||||
view_type_items.push_back(EViewType::FanSpeed);
|
view_type_items.push_back(EViewType::FanSpeed);
|
||||||
view_type_items.push_back(EViewType::Temperature);
|
view_type_items.push_back(EViewType::Temperature);
|
||||||
if (mode == ConfigOptionMode::comDevelop) {
|
//if (mode == ConfigOptionMode::comDevelop) {
|
||||||
view_type_items.push_back(EViewType::Tool);
|
// view_type_items.push_back(EViewType::Tool);
|
||||||
}
|
//}
|
||||||
|
|
||||||
for (int i = 0; i < view_type_items.size(); i++) {
|
for (int i = 0; i < view_type_items.size(); i++) {
|
||||||
view_type_items_str.push_back(get_view_type_string(view_type_items[i]));
|
view_type_items_str.push_back(get_view_type_string(view_type_items[i]));
|
||||||
@ -951,9 +951,9 @@ void GCodeViewer::update_by_mode(ConfigOptionMode mode)
|
|||||||
options_items.push_back(EMoveType::Retract);
|
options_items.push_back(EMoveType::Retract);
|
||||||
options_items.push_back(EMoveType::Unretract);
|
options_items.push_back(EMoveType::Unretract);
|
||||||
options_items.push_back(EMoveType::Wipe);
|
options_items.push_back(EMoveType::Wipe);
|
||||||
if (mode == ConfigOptionMode::comDevelop) {
|
//if (mode == ConfigOptionMode::comDevelop) {
|
||||||
options_items.push_back(EMoveType::Tool_change);
|
// options_items.push_back(EMoveType::Tool_change);
|
||||||
}
|
//}
|
||||||
//BBS: seam is not real move and extrusion, put at last line
|
//BBS: seam is not real move and extrusion, put at last line
|
||||||
options_items.push_back(EMoveType::Seam);
|
options_items.push_back(EMoveType::Seam);
|
||||||
}
|
}
|
||||||
@ -4692,8 +4692,17 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||||||
std::vector<double> flushed_filaments_m;
|
std::vector<double> flushed_filaments_m;
|
||||||
std::vector<double> flushed_filaments_g;
|
std::vector<double> flushed_filaments_g;
|
||||||
double total_flushed_filament_m = 0, total_flushed_filament_g = 0;
|
double total_flushed_filament_m = 0, total_flushed_filament_g = 0;
|
||||||
bool show_model_used_filaments = true;
|
std::vector<double> wipe_tower_used_filaments_m;
|
||||||
bool show_flushed_filaments = true;
|
std::vector<double> wipe_tower_used_filaments_g;
|
||||||
|
double total_wipe_tower_used_filament_m = 0, total_wipe_tower_used_filament_g = 0;
|
||||||
|
struct ColumnData {
|
||||||
|
enum {
|
||||||
|
Model = 1,
|
||||||
|
Flushed = 2,
|
||||||
|
WipeTower = 4,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
int displayed_columns = ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower;
|
||||||
const PrintStatistics& ps = wxGetApp().plater()->get_partplate_list().get_current_fff_print().print_statistics();
|
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 koef = imperial_units ? GizmoObjectManipulation::in_to_mm : 1000.0;
|
||||||
double unit_conver = imperial_units ? GizmoObjectManipulation::oz_to_g : 1;
|
double unit_conver = imperial_units ? GizmoObjectManipulation::oz_to_g : 1;
|
||||||
@ -4782,7 +4791,19 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||||||
total_model_used_filament_g += model_used_filament_g;
|
total_model_used_filament_g += model_used_filament_g;
|
||||||
}
|
}
|
||||||
if (model_used_filaments_m.size() == 0 || model_used_filaments_g.size() == 0)
|
if (model_used_filaments_m.size() == 0 || model_used_filaments_g.size() == 0)
|
||||||
show_model_used_filaments = false;
|
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()) continue;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
if (wipe_tower_used_filaments_m.size() == 0 || wipe_tower_used_filaments_g.size() == 0)
|
||||||
|
displayed_columns &= ~ColumnData::WipeTower;
|
||||||
|
|
||||||
for (size_t extruder_id : m_extruder_ids) {
|
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()) continue;
|
if (m_print_statistics.flush_per_filament.find(extruder_id) == m_print_statistics.flush_per_filament.end()) continue;
|
||||||
@ -4794,18 +4815,27 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||||||
total_flushed_filament_g += flushed_filament_g;
|
total_flushed_filament_g += flushed_filament_g;
|
||||||
}
|
}
|
||||||
if (flushed_filaments_m.size() == 0 || flushed_filaments_g.size() == 0)
|
if (flushed_filaments_m.size() == 0 || flushed_filaments_g.size() == 0)
|
||||||
show_flushed_filaments = false;
|
displayed_columns &= ~ColumnData::Flushed;
|
||||||
|
|
||||||
std::vector<std::string> total_filaments;
|
std::vector<std::string> total_filaments;
|
||||||
char buffer[64];
|
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);
|
::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);
|
total_filaments.push_back(buffer);
|
||||||
|
|
||||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), total_filaments}, {_u8L("Flushed"), total_filaments}, /*{_u8L("Tower"), total_filaments},*/ {_u8L("Total"), total_filaments} }, icon_size);
|
|
||||||
if (m_extruder_ids.size() <= 1 || !show_flushed_filaments)
|
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]}});
|
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[2]}});
|
||||||
else
|
}
|
||||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[1]}, {_u8L("Flushed"), offsets[2]}, /*{_u8L("Tower"), offsets[3]},*/ {_u8L("Total"), offsets[3]}});// to add Tower
|
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::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]} });
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: { break; }
|
default: { break; }
|
||||||
@ -4976,7 +5006,12 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||||||
columns_offsets.push_back({ std::to_string(extruder_idx + 1), offsets[0] });
|
columns_offsets.push_back({ std::to_string(extruder_idx + 1), offsets[0] });
|
||||||
|
|
||||||
char buf[64];
|
char buf[64];
|
||||||
if (show_flushed_filaments) {
|
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] });
|
||||||
|
}
|
||||||
|
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);
|
::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] });
|
columns_offsets.push_back({ buf, offsets[1] });
|
||||||
|
|
||||||
@ -4987,12 +5022,22 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||||||
(model_used_filaments_g[i] + flushed_filaments_g[i]) / unit_conver);
|
(model_used_filaments_g[i] + flushed_filaments_g[i]) / unit_conver);
|
||||||
columns_offsets.push_back({ buf, offsets[3] });
|
columns_offsets.push_back({ buf, offsets[3] });
|
||||||
}
|
}
|
||||||
else {
|
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower)) {
|
||||||
char buf[64];
|
::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);
|
||||||
::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[1] });
|
||||||
columns_offsets.push_back({buf, offsets[2]});
|
|
||||||
|
::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", 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] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
append_item(EItemType::Rect, m_tools.m_tool_colors[extruder_idx], columns_offsets, false, filament_visible, [this, extruder_idx]() {
|
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];
|
m_tools.m_tool_visibles[extruder_idx] = !m_tools.m_tool_visibles[extruder_idx];
|
||||||
// update buffers' render paths
|
// update buffers' render paths
|
||||||
@ -5038,13 +5083,13 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||||||
|
|
||||||
std::vector<std::pair<std::string, float>> columns_offsets;
|
std::vector<std::pair<std::string, float>> columns_offsets;
|
||||||
columns_offsets.push_back({ _u8L("Total"), offsets[0] });
|
columns_offsets.push_back({ _u8L("Total"), offsets[0] });
|
||||||
if (!show_flushed_filaments) {
|
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);
|
::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] });
|
columns_offsets.push_back({ buf, offsets[2] });
|
||||||
|
|
||||||
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
::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] });
|
columns_offsets.push_back({ buf, offsets[1] });
|
||||||
|
|
||||||
@ -5052,9 +5097,25 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||||||
columns_offsets.push_back({ buf, offsets[2] });
|
columns_offsets.push_back({ buf, offsets[2] });
|
||||||
|
|
||||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
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);
|
::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] });
|
columns_offsets.push_back({ buf, offsets[3] });
|
||||||
|
|
||||||
|
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||||
|
}
|
||||||
|
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] });
|
||||||
|
|
||||||
|
::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] });
|
||||||
|
|
||||||
|
::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);
|
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user