mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 16:21:24 -06:00
Merge branch 'add_kinematics' of https://github.com/prusa3d/Slic3r into time_estimate
This commit is contained in:
commit
3da21a4ce8
5 changed files with 77 additions and 50 deletions
|
|
@ -35,6 +35,22 @@ namespace Slic3r { namespace GUI {
|
|||
set_undo_bitmap(&bmp);
|
||||
set_undo_to_sys_bitmap(&bmp);
|
||||
|
||||
switch (m_opt.type)
|
||||
{
|
||||
case coPercents:
|
||||
case coFloats:
|
||||
case coStrings:
|
||||
case coBools:
|
||||
case coInts: {
|
||||
auto tag_pos = m_opt_id.find("#");
|
||||
if (tag_pos != std::string::npos)
|
||||
m_opt_idx = stoi(m_opt_id.substr(tag_pos + 1, m_opt_id.size()));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
BUILD();
|
||||
}
|
||||
|
||||
|
|
@ -151,10 +167,10 @@ namespace Slic3r { namespace GUI {
|
|||
case coFloat:
|
||||
{
|
||||
double val = m_opt.type == coFloats ?
|
||||
static_cast<const ConfigOptionFloats*>(m_opt.default_value)->get_at(0) :
|
||||
static_cast<const ConfigOptionFloats*>(m_opt.default_value)->get_at(m_opt_idx) :
|
||||
m_opt.type == coFloat ?
|
||||
m_opt.default_value->getFloat() :
|
||||
static_cast<const ConfigOptionPercents*>(m_opt.default_value)->get_at(0);
|
||||
static_cast<const ConfigOptionPercents*>(m_opt.default_value)->get_at(m_opt_idx);
|
||||
text_value = double_to_string(val);
|
||||
break;
|
||||
}
|
||||
|
|
@ -164,10 +180,8 @@ namespace Slic3r { namespace GUI {
|
|||
case coStrings:
|
||||
{
|
||||
const ConfigOptionStrings *vec = static_cast<const ConfigOptionStrings*>(m_opt.default_value);
|
||||
if (vec == nullptr || vec->empty()) break;
|
||||
if (vec->size() > 1)
|
||||
break;
|
||||
text_value = vec->values.at(0);
|
||||
if (vec == nullptr || vec->empty()) break; //for the case of empty default value
|
||||
text_value = vec->get_at(m_opt_idx);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -249,7 +263,7 @@ void CheckBox::BUILD() {
|
|||
|
||||
bool check_value = m_opt.type == coBool ?
|
||||
m_opt.default_value->getBool() : m_opt.type == coBools ?
|
||||
static_cast<ConfigOptionBools*>(m_opt.default_value)->values.at(0) :
|
||||
static_cast<ConfigOptionBools*>(m_opt.default_value)->get_at(m_opt_idx) :
|
||||
false;
|
||||
|
||||
auto temp = new wxCheckBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
|
||||
|
|
@ -408,7 +422,7 @@ void Choice::set_selection()
|
|||
break;
|
||||
}
|
||||
case coStrings:{
|
||||
text_value = static_cast<const ConfigOptionStrings*>(m_opt.default_value)->values.at(0);
|
||||
text_value = static_cast<const ConfigOptionStrings*>(m_opt.default_value)->get_at(m_opt_idx);
|
||||
|
||||
size_t idx = 0;
|
||||
for (auto el : m_opt.enum_values)
|
||||
|
|
@ -572,7 +586,7 @@ void ColourPicker::BUILD()
|
|||
if (m_opt.height >= 0) size.SetHeight(m_opt.height);
|
||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width);
|
||||
|
||||
wxString clr(static_cast<ConfigOptionStrings*>(m_opt.default_value)->values.at(0));
|
||||
wxString clr(static_cast<ConfigOptionStrings*>(m_opt.default_value)->get_at(m_opt_idx));
|
||||
auto temp = new wxColourPickerCtrl(m_parent, wxID_ANY, clr, wxDefaultPosition, size);
|
||||
|
||||
// // recast as a wxWindow to fit the calling convention
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ public:
|
|||
/// Copy of ConfigOption for deduction purposes
|
||||
const ConfigOptionDef m_opt {ConfigOptionDef()};
|
||||
const t_config_option_key m_opt_id;//! {""};
|
||||
int m_opt_idx = 0;
|
||||
|
||||
/// Sets a value for this control.
|
||||
/// subclasses should overload with a specific version
|
||||
|
|
|
|||
|
|
@ -1631,8 +1631,14 @@ void TabPrinter::build()
|
|||
|
||||
optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value){
|
||||
wxTheApp->CallAfter([this, opt_key, value](){
|
||||
if (opt_key.compare("gcode_flavor") == 0)
|
||||
build_extruder_pages();
|
||||
if (opt_key.compare("silent_mode") == 0) {
|
||||
bool val = boost::any_cast<bool>(value);
|
||||
if (m_use_silent_mode != val) {
|
||||
m_rebuil_kinematics_page = true;
|
||||
m_use_silent_mode = val;
|
||||
}
|
||||
}
|
||||
build_extruder_pages();
|
||||
update_dirty();
|
||||
on_value_change(opt_key, value);
|
||||
});
|
||||
|
|
@ -1718,44 +1724,47 @@ void TabPrinter::extruders_count_changed(size_t extruders_count){
|
|||
on_value_change("extruders_count", extruders_count);
|
||||
}
|
||||
|
||||
void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key)
|
||||
void TabPrinter::append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key)
|
||||
{
|
||||
auto option = optgroup->get_option(opt_key, 0);
|
||||
auto line = Line{ option.opt.full_label, "" };
|
||||
line.append_option(option);
|
||||
line.append_option(optgroup->get_option(opt_key, 1));
|
||||
if (m_use_silent_mode)
|
||||
line.append_option(optgroup->get_option(opt_key, 1));
|
||||
optgroup->append_line(line);
|
||||
}
|
||||
|
||||
PageShp TabPrinter::create_kinematics_page()
|
||||
PageShp TabPrinter::build_kinematics_page()
|
||||
{
|
||||
auto page = add_options_page(_(L("Machine limits")), "cog.png", true);
|
||||
|
||||
// Legend for OptionsGroups
|
||||
auto optgroup = page->new_optgroup(_(L("")));
|
||||
optgroup->set_show_modified_btns_val(false);
|
||||
optgroup->label_width = 230;
|
||||
auto line = Line{ "", "" };
|
||||
if (m_use_silent_mode) {
|
||||
// Legend for OptionsGroups
|
||||
auto optgroup = page->new_optgroup(_(L("")));
|
||||
optgroup->set_show_modified_btns_val(false);
|
||||
optgroup->label_width = 230;
|
||||
auto line = Line{ "", "" };
|
||||
|
||||
ConfigOptionDef def;
|
||||
def.type = coString;
|
||||
def.width = 150;
|
||||
def.gui_type = "legend";
|
||||
def.tooltip = L("Values in this column are for Full Power mode");
|
||||
def.default_value = new ConfigOptionString{ L("Full Power")};
|
||||
ConfigOptionDef def;
|
||||
def.type = coString;
|
||||
def.width = 150;
|
||||
def.gui_type = "legend";
|
||||
def.tooltip = L("Values in this column are for Full Power mode");
|
||||
def.default_value = new ConfigOptionString{ L("Full Power") };
|
||||
|
||||
auto option = Option(def, "full_power_legend");
|
||||
line.append_option(option);
|
||||
auto option = Option(def, "full_power_legend");
|
||||
line.append_option(option);
|
||||
|
||||
def.tooltip = L("Values in this column are for Silent mode");
|
||||
def.default_value = new ConfigOptionString{ L("Silent") };
|
||||
option = Option(def, "silent_legend");
|
||||
line.append_option(option);
|
||||
def.tooltip = L("Values in this column are for Silent mode");
|
||||
def.default_value = new ConfigOptionString{ L("Silent") };
|
||||
option = Option(def, "silent_legend");
|
||||
line.append_option(option);
|
||||
|
||||
optgroup->append_line(line);
|
||||
optgroup->append_line(line);
|
||||
}
|
||||
|
||||
std::vector<std::string> axes{ "x", "y", "z", "e" };
|
||||
optgroup = page->new_optgroup(_(L("Maximum accelerations")));
|
||||
auto optgroup = page->new_optgroup(_(L("Maximum accelerations")));
|
||||
for (const std::string &axis : axes) {
|
||||
append_option_line(optgroup, "machine_max_acceleration_" + axis);
|
||||
}
|
||||
|
|
@ -1789,7 +1798,7 @@ void TabPrinter::build_extruder_pages()
|
|||
size_t existed_page = 0;
|
||||
for (int i = n_before_extruders; i < m_pages.size(); ++i) // first make sure it's not there already
|
||||
if (m_pages[i]->title().find(_(L("Machine limits"))) != std::string::npos) {
|
||||
if (!is_marlin_flavor)
|
||||
if (!is_marlin_flavor || m_rebuil_kinematics_page)
|
||||
m_pages.erase(m_pages.begin() + i);
|
||||
else
|
||||
existed_page = i;
|
||||
|
|
@ -1797,7 +1806,7 @@ void TabPrinter::build_extruder_pages()
|
|||
}
|
||||
|
||||
if (existed_page < n_before_extruders && is_marlin_flavor){
|
||||
auto page = create_kinematics_page();
|
||||
auto page = build_kinematics_page();
|
||||
m_pages.insert(m_pages.begin() + n_before_extruders, page);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -313,6 +313,9 @@ public:
|
|||
class TabPrinter : public Tab
|
||||
{
|
||||
bool m_has_single_extruder_MM_page = false;
|
||||
bool m_use_silent_mode = false;
|
||||
void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key);
|
||||
bool m_rebuil_kinematics_page = false;
|
||||
public:
|
||||
wxButton* m_serial_test_btn;
|
||||
wxButton* m_octoprint_host_test_btn;
|
||||
|
|
@ -330,7 +333,7 @@ public:
|
|||
void update() override;
|
||||
void update_serial_ports();
|
||||
void extruders_count_changed(size_t extruders_count);
|
||||
PageShp create_kinematics_page();
|
||||
PageShp build_kinematics_page();
|
||||
void build_extruder_pages();
|
||||
void on_preset_loaded() override;
|
||||
void init_options_list() override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue