Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVojtech Bubnik <bubnikv@gmail.com>2022-01-27 19:02:07 +0300
committerVojtech Bubnik <bubnikv@gmail.com>2022-01-27 19:02:16 +0300
commit7da4bebe7a3653136eebb0dbd7557a8b5ddcbe91 (patch)
tree9d2983b44176158f69b5c0494a293af6e71d01a1 /src
parent12cebddce6441afced9d3b060a3fcf977023b4c5 (diff)
WIP GCode substitutions: Changed the format of gcode_substitutions by
adding an empty comment as a fourth parameter to each substitution. In the future, we will provide a UI to show / edit the comment.
Diffstat (limited to 'src')
-rw-r--r--src/libslic3r/GCode/FindReplace.cpp6
-rw-r--r--src/slic3r/GUI/Tab.cpp16
-rw-r--r--src/slic3r/GUI/Tab.hpp4
3 files changed, 13 insertions, 13 deletions
diff --git a/src/libslic3r/GCode/FindReplace.cpp b/src/libslic3r/GCode/FindReplace.cpp
index 9f9852f04..85b027b79 100644
--- a/src/libslic3r/GCode/FindReplace.cpp
+++ b/src/libslic3r/GCode/FindReplace.cpp
@@ -24,11 +24,11 @@ const void unescape_extended_search_mode(std::string &s)
GCodeFindReplace::GCodeFindReplace(const std::vector<std::string> &gcode_substitutions)
{
- if ((gcode_substitutions.size() % 3) != 0)
+ if ((gcode_substitutions.size() % 4) != 0)
throw RuntimeError("Invalid length of gcode_substitutions parameter");
- m_substitutions.reserve(gcode_substitutions.size() / 3);
- for (size_t i = 0; i < gcode_substitutions.size(); i += 3) {
+ m_substitutions.reserve(gcode_substitutions.size() / 4);
+ for (size_t i = 0; i < gcode_substitutions.size(); i += 4) {
Substitution out;
try {
out.plain_pattern = gcode_substitutions[i];
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index 0dd51809a..41db5e27e 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -3899,17 +3899,17 @@ void SubstitutionManager::init(DynamicPrintConfig* config, wxWindow* parent, wxF
void SubstitutionManager::validate_lenth()
{
std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
- if ((substitutions.size() % 3) != 0) {
+ if ((substitutions.size() % 4) != 0) {
WarningDialog(m_parent, "Value of gcode_substitutions parameter will be cut to valid length",
"Invalid length of gcode_substitutions parameter").ShowModal();
- substitutions.resize(substitutions.size() - (substitutions.size() % 3));
+ substitutions.resize(substitutions.size() - (substitutions.size() % 4));
}
}
bool SubstitutionManager::is_compatibile_with_ui()
{
const std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
- if (int(substitutions.size() / 3) != m_grid_sizer->GetEffectiveRowsCount() - 1) {
+ if (int(substitutions.size() / 4) != m_grid_sizer->GetEffectiveRowsCount() - 1) {
ErrorDialog(m_parent, "Invalid compatibility between UI and BE", false).ShowModal();
return false;
}
@@ -3919,7 +3919,7 @@ bool SubstitutionManager::is_compatibile_with_ui()
bool SubstitutionManager::is_valid_id(int substitution_id, const wxString& message)
{
const std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
- if (int(substitutions.size() / 3) < substitution_id) {
+ if (int(substitutions.size() / 4) < substitution_id) {
ErrorDialog(m_parent, message, false).ShowModal();
return false;
}
@@ -3948,7 +3948,7 @@ void SubstitutionManager::delete_substitution(int substitution_id)
// delete substitution
std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
- substitutions.erase(std::next(substitutions.begin(), substitution_id * 3), std::next(substitutions.begin(), substitution_id * 3 + 3));
+ substitutions.erase(std::next(substitutions.begin(), substitution_id * 4), std::next(substitutions.begin(), substitution_id * 4 + 4));
call_ui_update();
// update grid_sizer
@@ -3970,7 +3970,7 @@ void SubstitutionManager::add_substitution(int substitution_id, const std::strin
// create new substitution
// it have to be added to config too
std::vector<std::string>& substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
- for (size_t i = 0; i < 3; i ++)
+ for (size_t i = 0; i < 4; i ++)
substitutions.push_back(std::string());
call_after_layout = true;
@@ -4073,7 +4073,7 @@ void SubstitutionManager::update_from_config()
validate_lenth();
int subst_id = 0;
- for (size_t i = 0; i < subst.size(); i += 3)
+ for (size_t i = 0; i < subst.size(); i += 4)
add_substitution(subst_id++, subst[i], subst[i + 1], subst[i + 2]);
m_parent->GetParent()->Layout();
@@ -4098,7 +4098,7 @@ void SubstitutionManager::edit_substitution(int substitution_id, int opt_pos, co
if(!is_compatibile_with_ui() || !is_valid_id(substitution_id, "Invalid substitution_id to edit"))
return;
- substitutions[substitution_id * 3 + opt_pos] = value;
+ substitutions[substitution_id * 4 + opt_pos] = value;
call_ui_update();
}
diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp
index 1a1ffb908..d953b662a 100644
--- a/src/slic3r/GUI/Tab.hpp
+++ b/src/slic3r/GUI/Tab.hpp
@@ -60,8 +60,8 @@ class SubstitutionManager
bool is_valid_id(int substitution_id, const wxString& message);
public:
- SubstitutionManager() {};
- ~SubstitutionManager() {};
+ SubstitutionManager() = default;
+ ~SubstitutionManager() = default;
void init(DynamicPrintConfig* config, wxWindow* parent, wxFlexGridSizer* grid_sizer);
void create_legend();