mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
Port EditGCodeDialog from PrusaSlicer (#3417)
This is a port of the EditGCodeDialog from PrusaSlicer 2.7.x. There were a few changes made to make it a bit more functional. Also, it isn't quite fully complete, but it should be in a very usable state. General Changes: - Implement UndoValueUIManager and EditValueUI in Field - Implement EditGCodeDialog and add buttons to the tabs - Other minor changes to accommodate the new classes Differences from PrusaSlicer's Implementation: - backported to wxWidgets 3.1.5 (reverse commit8770c4b7
after updating to 3.2.x) - icons have been updated to use Orca colors - improve the report that tells you if certain placeholders have not been defined properly for the dialog. It now shows all issues at once rather than having to fix then recompile to see the next issue. - allow the use of the cmake option `ORCA_CHECK_GCODE_PLACEHOLDERS` to toggle the above report since our workflow rarely uses debug mode. - if a custom gcode value is not set when checking gcode placeholders, a testing value is set. Custom gcode is not parsed if it is empty, and the only way to check if the placeholders are all defined is by running the placeholder operation on the custom gcode. - some calls to `print.config()` in Gcode.cpp were changed to `m_config` to support the above testing values feature (only m_config is modified with the placeholders and `print.config()` would return an empty string) - a macro has been added to quickly add a definition to SlicingStatesConfigDefs with less boiler plate (it could technically be used for any ConfigOptionDef, but that would hurt interoperability with PS. I tried to not use the macro for too many PS defined definitions.) - the presets are now also categorized by the page they are on in their tab <table> <tr> <td>Prusa <td>Orca <tr> <td> <img src="27cb4f48
-d225-4563-9aeb-b2b461f8bff5" /> <td> <img src="4fcd8cde
-2427-4d1a-a0ed-1738b570b919" /> </table> TODO: - [x] Make sure all linux fixes have been applied - [x] Finish adding "universal" gcode options - [x] add search function to dataview (maybe?) - [x] determine if any options are being left out of the preset categories by getting options from Tab rather than Presets. If so, consider adding outside of the groupings
This commit is contained in:
commit
5ff00fb48c
33 changed files with 2155 additions and 122 deletions
|
@ -38,6 +38,7 @@
|
|||
#include "format.hpp"
|
||||
#include "UnsavedChangesDialog.hpp"
|
||||
#include "SavePresetDialog.hpp"
|
||||
#include "EditGCodeDialog.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "Notebook.hpp"
|
||||
|
||||
|
@ -255,6 +256,8 @@ void Tab::create_preset_tab()
|
|||
// Bitmaps to be shown on the "Undo user changes" button next to each input field.
|
||||
add_scaled_bitmap(this, m_bmp_value_revert, "undo");
|
||||
add_scaled_bitmap(this, m_bmp_white_bullet, "dot");
|
||||
// Bitmap to be shown on the "edit" button before to each editable input field.
|
||||
add_scaled_bitmap(this, m_bmp_edit_value, "edit");
|
||||
|
||||
set_tooltips_text();
|
||||
|
||||
|
@ -708,8 +711,8 @@ void Tab::update_label_colours()
|
|||
}
|
||||
if (opt.first == "printable_area" ||
|
||||
opt.first == "compatible_prints" || opt.first == "compatible_printers" ) {
|
||||
if (m_colored_Label_colors.find(opt.first) != m_colored_Label_colors.end())
|
||||
m_colored_Label_colors.at(opt.first) = *color;
|
||||
if (Line* line = get_line(opt.first))
|
||||
line->set_label_colour(color);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -748,13 +751,13 @@ void Tab::decorate()
|
|||
for (const auto& opt : m_options_list)
|
||||
{
|
||||
Field* field = nullptr;
|
||||
wxColour* colored_label_clr = nullptr;
|
||||
bool option_without_field = false;
|
||||
|
||||
if (opt.first == "printable_area" ||
|
||||
opt.first == "compatible_prints" || opt.first == "compatible_printers")
|
||||
colored_label_clr = (m_colored_Label_colors.find(opt.first) == m_colored_Label_colors.end()) ? nullptr : &m_colored_Label_colors.at(opt.first);
|
||||
option_without_field = true;
|
||||
|
||||
if (!colored_label_clr) {
|
||||
if (!option_without_field) {
|
||||
field = get_field(opt.first);
|
||||
if (!field)
|
||||
continue;
|
||||
|
@ -789,8 +792,14 @@ void Tab::decorate()
|
|||
tt = &m_tt_white_bullet;
|
||||
}
|
||||
|
||||
if (colored_label_clr) {
|
||||
*colored_label_clr = *color;
|
||||
if (option_without_field) {
|
||||
if (Line* line = get_line(opt.first)) {
|
||||
line->set_undo_bitmap(icon);
|
||||
line->set_undo_to_sys_bitmap(sys_icon);
|
||||
line->set_undo_tooltip(tt);
|
||||
line->set_undo_to_sys_tooltip(sys_tt);
|
||||
line->set_label_colour(color);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -802,6 +811,10 @@ void Tab::decorate()
|
|||
field->set_undo_tooltip(tt);
|
||||
field->set_undo_to_sys_tooltip(sys_tt);
|
||||
field->set_label_colour(color);
|
||||
|
||||
if (field->has_edit_ui())
|
||||
field->set_edit_bitmap(&m_bmp_edit_value);
|
||||
|
||||
}
|
||||
|
||||
if (m_active_page)
|
||||
|
@ -1082,7 +1095,7 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/)
|
|||
|
||||
m_postpone_update_ui = false;
|
||||
|
||||
// When all values are rolled, then we hane to update whole tab in respect to the reverted values
|
||||
// When all values are rolled, then we have to update whole tab in respect to the reverted values
|
||||
update();
|
||||
|
||||
// BBS: restore all pages in preset, update_dirty also update combobox
|
||||
|
@ -1265,6 +1278,11 @@ Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/
|
|||
return m_active_page ? m_active_page->get_field(opt_key, opt_index) : nullptr;
|
||||
}
|
||||
|
||||
Line* Tab::get_line(const t_config_option_key& opt_key)
|
||||
{
|
||||
return m_active_page ? m_active_page->get_line(opt_key) : nullptr;
|
||||
}
|
||||
|
||||
std::pair<OG_CustomCtrl*, bool*> Tab::get_custom_ctrl_with_blinking_ptr(const t_config_option_key& opt_key, int opt_index/* = -1*/)
|
||||
{
|
||||
if (!m_active_page)
|
||||
|
@ -2880,6 +2898,43 @@ static void validate_custom_gcode_cb(Tab* tab, ConfigOptionsGroupShp opt_group,
|
|||
tab->on_value_change(opt_key, value);
|
||||
}
|
||||
|
||||
void Tab::edit_custom_gcode(const t_config_option_key& opt_key)
|
||||
{
|
||||
EditGCodeDialog dlg = EditGCodeDialog(this, opt_key, get_custom_gcode(opt_key));
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
set_custom_gcode(opt_key, dlg.get_edited_gcode());
|
||||
update_dirty();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& Tab::get_custom_gcode(const t_config_option_key& opt_key)
|
||||
{
|
||||
return m_config->opt_string(opt_key);
|
||||
}
|
||||
|
||||
void Tab::set_custom_gcode(const t_config_option_key& opt_key, const std::string& value)
|
||||
{
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
new_conf.set_key_value(opt_key, new ConfigOptionString(value));
|
||||
load_config(new_conf);
|
||||
}
|
||||
|
||||
const std::string& TabFilament::get_custom_gcode(const t_config_option_key& opt_key)
|
||||
{
|
||||
return m_config->opt_string(opt_key, unsigned(0));
|
||||
}
|
||||
|
||||
void TabFilament::set_custom_gcode(const t_config_option_key& opt_key, const std::string& value)
|
||||
{
|
||||
std::vector<std::string> gcodes = static_cast<const ConfigOptionStrings*>(m_config->option(opt_key))->values;
|
||||
gcodes[0] = value;
|
||||
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
new_conf.set_key_value(opt_key, new ConfigOptionStrings(gcodes));
|
||||
load_config(new_conf);
|
||||
}
|
||||
|
||||
void TabFilament::add_filament_overrides_page()
|
||||
{
|
||||
//BBS
|
||||
|
@ -3155,11 +3210,14 @@ void TabFilament::build()
|
|||
const int gcode_field_height = 15; // 150
|
||||
const int notes_field_height = 25; // 250
|
||||
|
||||
auto edit_custom_gcode_fn = [this](const t_config_option_key& opt_key) { edit_custom_gcode(opt_key); };
|
||||
|
||||
page = add_options_page(L("Advanced"), "advanced");
|
||||
optgroup = page->new_optgroup(L("Filament start G-code"), L"param_gcode", 0);
|
||||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("filament_start_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3170,6 +3228,7 @@ void TabFilament::build()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("filament_end_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3471,6 +3530,8 @@ void TabPrinter::build_fff()
|
|||
optgroup->append_single_option_line("support_chamber_temp_control", "chamber-temperature");
|
||||
optgroup->append_single_option_line("support_air_filtration", "air-filtration");
|
||||
|
||||
auto edit_custom_gcode_fn = [this](const t_config_option_key& opt_key) { edit_custom_gcode(opt_key); };
|
||||
|
||||
const int gcode_field_height = 15; // 150
|
||||
const int notes_field_height = 25; // 250
|
||||
page = add_options_page(L("Machine gcode"), "cog");
|
||||
|
@ -3478,6 +3539,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("machine_start_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3488,6 +3550,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("machine_end_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3498,6 +3561,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, optgroup](const t_config_option_key &opt_key, const boost::any &value) {
|
||||
validate_custom_gcode_cb(this, optgroup, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("printing_by_object_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3509,6 +3573,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("before_layer_change_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3519,6 +3584,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("layer_change_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3529,6 +3595,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("time_lapse_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3539,6 +3606,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("change_filament_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3549,7 +3617,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key &opt_key, const boost::any &value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("change_extrusion_role_gcode");
|
||||
option.opt.full_width = true;
|
||||
option.opt.is_code = true;
|
||||
|
@ -3560,6 +3628,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("machine_pause_gcode");
|
||||
option.opt.is_code = true;
|
||||
option.opt.height = gcode_field_height;//150;
|
||||
|
@ -3569,6 +3638,7 @@ void TabPrinter::build_fff()
|
|||
optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) {
|
||||
validate_custom_gcode_cb(this, optgroup_title, opt_key, value);
|
||||
};
|
||||
optgroup->edit_custom_gcode = edit_custom_gcode_fn;
|
||||
option = optgroup->get_option("template_custom_gcode");
|
||||
option.opt.is_code = true;
|
||||
option.opt.height = gcode_field_height;//150;
|
||||
|
@ -5312,8 +5382,12 @@ void Tab::create_line_with_widget(ConfigOptionsGroup* optgroup, const std::strin
|
|||
line.widget = widget;
|
||||
line.label_path = path;
|
||||
|
||||
m_colored_Label_colors[opt_key] = m_default_text_clr;
|
||||
line.full_Label_color = &m_colored_Label_colors[opt_key];
|
||||
// set default undo ui
|
||||
line.set_undo_bitmap(&m_bmp_white_bullet);
|
||||
line.set_undo_to_sys_bitmap(&m_bmp_white_bullet);
|
||||
line.set_undo_tooltip(&m_tt_white_bullet);
|
||||
line.set_undo_to_sys_tooltip(&m_tt_white_bullet);
|
||||
line.set_label_colour(&m_default_text_clr);
|
||||
|
||||
optgroup->append_line(line);
|
||||
}
|
||||
|
@ -5671,12 +5745,10 @@ Field *Page::get_field(const t_config_option_key &opt_key, int opt_index /*= -1*
|
|||
|
||||
Line *Page::get_line(const t_config_option_key &opt_key)
|
||||
{
|
||||
Line *line = nullptr;
|
||||
for (auto opt : m_optgroups) {
|
||||
line = opt->get_line(opt_key);
|
||||
if (line != nullptr) return line;
|
||||
}
|
||||
return line;
|
||||
for (auto opt : m_optgroups)
|
||||
if (Line* line = opt->get_line(opt_key))
|
||||
return line;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Page::set_value(const t_config_option_key &opt_key, const boost::any &value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue