Skip to content

Commit

Permalink
Attempt at adding a currency field
Browse files Browse the repository at this point in the history
  • Loading branch information
cochcoder committed Mar 12, 2024
1 parent 68217a3 commit 46b2922
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ static std::vector<std::string> s_Preset_printer_options {
"default_print_profile", "inherits",
"silent_mode",
// BBS
"scan_first_layer", "machine_load_filament_time", "machine_unload_filament_time","electric_consumption","kWh_cost","other_costs","machine_pause_gcode", "template_custom_gcode",
"scan_first_layer", "machine_load_filament_time", "machine_unload_filament_time","electric_consumption","kWh_cost","other_costs","currency","machine_pause_gcode", "template_custom_gcode",
"nozzle_type", "nozzle_hrc","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types", "retract_lift_enforce","support_chamber_temp_control","support_air_filtration","printer_structure",
"best_object_pos","head_wrap_detect_zone",
//SoftFever
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ struct PrintStatistics
PrintStatistics() { clear(); }
std::string estimated_normal_print_time;
std::string estimated_silent_print_time;
std::string currency;
double total_used_filament;
double total_extruded_volume;
double total_filament_cost;
Expand Down
9 changes: 9 additions & 0 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2521,6 +2521,15 @@ def = this->add("filament_loading_speed", coFloats);
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0));

def = this->add("currency", coString);
def->label = "Currency";
def->tooltip = "Enter the symbol of your currency";
def->full_width = true;
def->height = 5;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionString());
// def->cli = ConfigOptionDef::nocli;

// Orca: may remove this option later
def =this->add("support_chamber_temp_control",coBool);
def->label=L("Support control chamber temperature");
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloat, electric_consumption))
((ConfigOptionFloat, kWh_cost))
((ConfigOptionFloat, other_costs))
((ConfigOptionString, currency))
((ConfigOptionString, layer_change_gcode))
((ConfigOptionString, time_lapse_gcode))

Expand Down
19 changes: 10 additions & 9 deletions src/slic3r/GUI/GCodeViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4322,7 +4322,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
imgui.text(_u8L("Filament cost") + ":");
ImGui::SameLine();
char buf[64];
::sprintf(buf, "%.2f", filament_cost_all_plates);
::sprintf(buf, "%.2f", currency.c_str(), filament_cost_all_plates);
imgui.text(buf);
}

Expand All @@ -4332,7 +4332,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
imgui.text(_u8L("Electric cost") + ":");
ImGui::SameLine();
char buf[64];
::sprintf(buf, "%.2f", electric_cost_all_plates);
::sprintf(buf, "%.2f", currency.c_str(), electric_cost_all_plates);
imgui.text(buf);
}

Expand All @@ -4342,7 +4342,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
imgui.text(_u8L("Other costs") + ":");
ImGui::SameLine();
char buf[64];
::sprintf(buf, "%.2f", other_costs_all_plates);
::sprintf(buf, "%.2f", currency.c_str(), other_costs_all_plates);
imgui.text(buf);
}

Expand All @@ -4352,7 +4352,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
imgui.text(_u8L("Total cost") + ":");
ImGui::SameLine();
char buf[64];
::sprintf(buf, "%.2f", total_cost_all_plates);
::sprintf(buf, "%.2f", currency.c_str(), total_cost_all_plates);
imgui.text(buf);
}
}
Expand Down Expand Up @@ -5135,7 +5135,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGui::SameLine();
imgui.text(_u8L("Filament cost")+":");
ImGui::SameLine();
::sprintf(buf, "%.2f", ps.total_filament_cost);
::sprintf(buf, "%.2f", currency.c_str(), ps.total_filament_cost);
imgui.text(buf);
}

Expand Down Expand Up @@ -5566,6 +5566,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
std::string cost_energy = _u8L("Electric cost");
std::string other_costs = _u8L("Other costs");
std::string total_cost = _u8L("Total cost");
std::string currency = ps.currency;
std::string prepare_str = _u8L("Prepare time");
std::string print_str = _u8L("Model printing time");
std::string total_str = _u8L("Total time");
Expand Down Expand Up @@ -5607,7 +5608,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
imgui.text(cost_filament+":");
ImGui::SameLine(max_len);
char buf[64];
::sprintf(buf, "%.2f", ps.total_filament_cost);
::sprintf(buf, "%.2f", currency.c_str(), ps.total_filament_cost);
imgui.text(buf);
}

Expand All @@ -5618,7 +5619,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
imgui.text(cost_energy+":");
ImGui::SameLine(max_len);
char buf[64];
::sprintf(buf, "%.2f", ps.electric_cost);
::sprintf(buf, "%.2f", currency.c_str(), ps.electric_cost);
imgui.text(buf);
}

Expand All @@ -5629,7 +5630,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
imgui.text(other_costs+":");
ImGui::SameLine(max_len);
char buf[64];
::sprintf(buf, "%.2f", ps.other_costs);
::sprintf(buf, "%.2f", currency.c_str(), ps.other_costs);
imgui.text(buf);
}

Expand All @@ -5640,7 +5641,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
imgui.text(total_cost+":");
ImGui::SameLine(max_len);
char buf[64];
::sprintf(buf, "%.2f", ps.total_cost);
::sprintf(buf, "%.2f", currency.c_str(), ps.total_cost);
imgui.text(buf);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3559,6 +3559,7 @@ void TabPrinter::build_fff()
optgroup->append_single_option_line("electric_consumption");
optgroup->append_single_option_line("kWh_cost");
optgroup->append_single_option_line("other_costs");
optgroup->append_single_option_line("currency");

optgroup = page->new_optgroup(L("Cooling Fan"));
Line line = Line{ L("Fan speed-up time"), optgroup->get_option("fan_speedup_time").opt.tooltip };
Expand Down

0 comments on commit 46b2922

Please sign in to comment.