Skip to content

Commit

Permalink
FIX: old gcode files don't show timelapse when send print
Browse files Browse the repository at this point in the history
Change-Id: If1829c8848ab9874a55367cdf77f881be0645c10
(cherry picked from commit 95d456f4cc16840167b3e2beaee597208bc885b4)
  • Loading branch information
zhimin-zeng-bambulab authored and lanewei120 committed Dec 15, 2022
1 parent 11fa28a commit 035c38b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/slic3r/GUI/SelectMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,8 @@ void SelectMachineDialog::update_select_layout(MachineObject *obj)
}

if (obj && obj->is_function_supported(PrinterFunction::FUNC_TIMELAPSE)
&& obj->is_support_print_with_timelapse()) {
&& obj->is_support_print_with_timelapse()
&& is_show_timelapse()) {
select_timelapse->Show();
} else {
select_timelapse->Hide();
Expand Down Expand Up @@ -2538,6 +2539,49 @@ void SelectMachineDialog::update_show_status()
}
}

bool SelectMachineDialog::is_show_timelapse()
{
auto compare_version = [](const std::string &version1, const std::string &version2) -> bool {
int i = 0, j = 0;
int max_size = std::max(version1.size(), version2.size());
while (i < max_size || j < max_size) {
int v1 = 0, v2 = 0;
while (i < version1.size() && version1[i] != '.') v1 = 10 * v1 + (version1[i++] - '0');
while (j < version2.size() && version2[j] != '.') v2 = 10 * v2 + (version2[j++] - '0');
if (v1 > v2) return true;
if (v1 < v2) return false;
++i;
++j;
}
return false;
};

std::string standard_version = "01.04.00.00";
PartPlate *plate = m_plater->get_partplate_list().get_curr_plate();
fs::path gcode_path = plate->get_tmp_gcode_path();

std::string line;
std::ifstream gcode_file;
gcode_file.open(gcode_path.string());
if (gcode_file.fail()) {
} else {
bool is_version = false;
while (gcode_file >> line) {
if (is_version) {
if (compare_version(standard_version, line)) {
gcode_file.close();
return false;
}
break;
}
if (line == "BambuStudio")
is_version = true;
}
}
gcode_file.close();
return true;
}

void SelectMachineDialog::reset_ams_material()
{
MaterialHash::iterator iter = m_materialList.begin();
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/SelectMachine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ class SelectMachineDialog : public DPIDialog
void reset_ams_material();
void update_show_status();
void update_ams_check(MachineObject* obj);
bool is_show_timelapse();

wxTimer *m_refresh_timer { nullptr };

Expand Down

0 comments on commit 035c38b

Please sign in to comment.