mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-27 02:31:10 -06:00
Implemented possibility to set a resin cost
This commit is contained in:
parent
6f8a9bc1ff
commit
82bc243281
8 changed files with 107 additions and 11 deletions
|
|
@ -221,7 +221,7 @@ SlicedInfo::SlicedInfo(wxWindow *parent) :
|
|||
init_info_label(_(L("Used Filament (mm³)")));
|
||||
init_info_label(_(L("Used Filament (g)")));
|
||||
init_info_label(_(L("Used Material (unit)")));
|
||||
init_info_label(_(L("Cost")));
|
||||
init_info_label(_(L("Cost (money)")));
|
||||
init_info_label(_(L("Estimated printing time")));
|
||||
init_info_label(_(L("Number of tool changes")));
|
||||
|
||||
|
|
@ -1117,12 +1117,10 @@ void Sidebar::show_info_sizer()
|
|||
}
|
||||
}
|
||||
|
||||
void Sidebar::show_sliced_info_sizer(const bool show)
|
||||
void Sidebar::update_sliced_info_sizer()
|
||||
{
|
||||
wxWindowUpdateLocker freeze_guard(this);
|
||||
|
||||
p->sliced_info->Show(show);
|
||||
if (show) {
|
||||
if (p->sliced_info->IsShown(size_t(0)))
|
||||
{
|
||||
if (p->plater->printer_technology() == ptSLA)
|
||||
{
|
||||
const SLAPrintStatistics& ps = p->plater->sla_print().print_statistics();
|
||||
|
|
@ -1138,7 +1136,18 @@ void Sidebar::show_sliced_info_sizer(const bool show)
|
|||
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)*/);
|
||||
wxString str_total_cost = "N/A";
|
||||
|
||||
DynamicPrintConfig* cfg = wxGetApp().get_tab(Preset::TYPE_SLA_MATERIAL)->get_config();
|
||||
if (cfg->option("bottle_cost")->getFloat() > 0.0 &&
|
||||
cfg->option("bottle_volume")->getFloat() > 0.0)
|
||||
{
|
||||
double material_cost = cfg->option("bottle_cost")->getFloat() /
|
||||
cfg->option("bottle_volume")->getFloat();
|
||||
str_total_cost = wxString::Format("%.2f", material_cost*(ps.objects_used_material + ps.support_used_material) / 1000);
|
||||
}
|
||||
p->sliced_info->SetTextAndShow(siCost, str_total_cost);
|
||||
|
||||
wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : get_time_dhms(float(ps.estimated_print_time));
|
||||
p->sliced_info->SetTextAndShow(siEstimatedTime, t_est, _(L("Estimated printing time")) + " :");
|
||||
|
||||
|
|
@ -1212,6 +1221,15 @@ void Sidebar::show_sliced_info_sizer(const bool show)
|
|||
p->sliced_info->SetTextAndShow(siMateril_unit, "N/A");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sidebar::show_sliced_info_sizer(const bool show)
|
||||
{
|
||||
wxWindowUpdateLocker freeze_guard(this);
|
||||
|
||||
p->sliced_info->Show(show);
|
||||
if (show)
|
||||
update_sliced_info_sizer();
|
||||
|
||||
Layout();
|
||||
p->scrolled->Refresh();
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ public:
|
|||
void update_objects_list_extruder_column(size_t extruders_count);
|
||||
void show_info_sizer();
|
||||
void show_sliced_info_sizer(const bool show);
|
||||
void update_sliced_info_sizer();
|
||||
void enable_buttons(bool enable);
|
||||
void set_btn_label(const ActionButtonType btn_type, const wxString& label) const;
|
||||
bool show_reslice(bool show) const;
|
||||
|
|
|
|||
|
|
@ -500,6 +500,10 @@ const std::vector<std::string>& Preset::sla_material_options()
|
|||
if (s_opts.empty()) {
|
||||
s_opts = {
|
||||
"initial_layer_height",
|
||||
"bottle_cost",
|
||||
"bottle_volume",
|
||||
"bottle_weight",
|
||||
"material_density",
|
||||
"exposure_time",
|
||||
"initial_exposure_time",
|
||||
"material_correction",
|
||||
|
|
|
|||
|
|
@ -3398,8 +3398,41 @@ void TabSLAMaterial::build()
|
|||
|
||||
auto page = add_options_page(_(L("Material")), "resin");
|
||||
|
||||
auto optgroup = page->new_optgroup(_(L("Layers")));
|
||||
// optgroup->append_single_option_line("layer_height");
|
||||
auto optgroup = page->new_optgroup(_(L("Material")));
|
||||
optgroup->append_single_option_line("bottle_cost");
|
||||
optgroup->append_single_option_line("bottle_volume");
|
||||
optgroup->append_single_option_line("bottle_weight");
|
||||
optgroup->append_single_option_line("material_density");
|
||||
|
||||
optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value)
|
||||
{
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
|
||||
if (opt_key == "bottle_volume") {
|
||||
double new_bottle_weight = boost::any_cast<double>(value)/(new_conf.option("material_density")->getFloat() * 1000);
|
||||
new_conf.set_key_value("bottle_weight", new ConfigOptionFloat(new_bottle_weight));
|
||||
}
|
||||
if (opt_key == "bottle_weight") {
|
||||
double new_bottle_volume = boost::any_cast<double>(value)*(new_conf.option("material_density")->getFloat() * 1000);
|
||||
new_conf.set_key_value("bottle_volume", new ConfigOptionFloat(new_bottle_volume));
|
||||
}
|
||||
if (opt_key == "material_density") {
|
||||
double new_bottle_weight = new_conf.option("bottle_volume")->getFloat() * boost::any_cast<double>(value) / 1000;
|
||||
new_conf.set_key_value("bottle_weight", new ConfigOptionFloat(new_bottle_weight));
|
||||
}
|
||||
|
||||
load_config(new_conf);
|
||||
|
||||
update_dirty();
|
||||
on_value_change(opt_key, value);
|
||||
|
||||
if (opt_key == "bottle_volume" || opt_key == "bottle_cost") {
|
||||
wxGetApp().sidebar().update_sliced_info_sizer();
|
||||
wxGetApp().sidebar().Layout();
|
||||
}
|
||||
};
|
||||
|
||||
optgroup = page->new_optgroup(_(L("Layers")));
|
||||
optgroup->append_single_option_line("initial_layer_height");
|
||||
|
||||
optgroup = page->new_optgroup(_(L("Exposure")));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue