mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-29 01:52:03 +08:00
Merge branch 'master' into fs_svg_SPE-1517
This commit is contained in:
commit
a57e3c14b6
@ -4328,62 +4328,22 @@ void GCodeProcessor::post_process()
|
|||||||
out.close();
|
out.close();
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
|
const std::string result_filename = m_result.filename;
|
||||||
if (m_binarizer.is_enabled()) {
|
if (m_binarizer.is_enabled()) {
|
||||||
// updates m_result.lines_ends from binarized gcode file
|
// The list of lines in the binary gcode is different from the original one.
|
||||||
m_result.lines_ends.clear();
|
// This requires to re-process the binarized file to be able to synchronize with it all the data needed by the preview,
|
||||||
|
// as gcode window, tool position and moves slider which relies on indexing the gcode lines.
|
||||||
FilePtr file(boost::nowide::fopen(out_path.c_str(), "rb"));
|
reset();
|
||||||
if (file.f != nullptr) {
|
// the following call modifies m_result.filename
|
||||||
fseek(file.f, 0, SEEK_END);
|
process_binary_file(out_path);
|
||||||
const long file_size = ftell(file.f);
|
// restore the proper filename
|
||||||
rewind(file.f);
|
m_result.filename = result_filename;
|
||||||
|
|
||||||
// read file header
|
|
||||||
using namespace bgcode::core;
|
|
||||||
using namespace bgcode::binarize;
|
|
||||||
FileHeader file_header;
|
|
||||||
EResult res = read_header(*file.f, file_header, nullptr);
|
|
||||||
if (res == EResult::Success) {
|
|
||||||
// search first GCode block
|
|
||||||
BlockHeader block_header;
|
|
||||||
res = read_next_block_header(*file.f, file_header, block_header, EBlockType::GCode, nullptr, 0);
|
|
||||||
while (res == EResult::Success) {
|
|
||||||
GCodeBlock block;
|
|
||||||
res = block.read_data(*file.f, file_header, block_header);
|
|
||||||
if (res != EResult::Success)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// extract lines ends from block
|
|
||||||
std::vector<size_t>& lines_ends = m_result.lines_ends.emplace_back(std::vector<size_t>());
|
|
||||||
for (size_t i = 0; i < block.raw_data.size(); ++i) {
|
|
||||||
if (block.raw_data[i] == '\n')
|
|
||||||
lines_ends.emplace_back(i + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ftell(file.f) == file_size)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// read next block header
|
|
||||||
res = read_next_block_header(*file.f, file_header, block_header, nullptr, 0);
|
|
||||||
if (res != EResult::Success)
|
|
||||||
break;
|
|
||||||
if (block_header.type != (uint16_t)EBlockType::GCode) {
|
|
||||||
res = EResult::InvalidBlockType;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res != EResult::Success && !m_result.lines_ends.empty() && !m_result.lines_ends.front().empty())
|
|
||||||
// some error occourred, clear lines ends
|
|
||||||
m_result.lines_ends = { std::vector<size_t>() };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
export_lines.synchronize_moves(m_result);
|
||||||
|
|
||||||
export_lines.synchronize_moves(m_result);
|
if (rename_file(out_path, result_filename))
|
||||||
|
throw Slic3r::RuntimeError(std::string("Failed to rename the output G-code file from ") + out_path + " to " + result_filename + '\n' +
|
||||||
if (rename_file(out_path, m_result.filename))
|
|
||||||
throw Slic3r::RuntimeError(std::string("Failed to rename the output G-code file from ") + out_path + " to " + m_result.filename + '\n' +
|
|
||||||
"Is " + out_path + " locked?" + '\n');
|
"Is " + out_path + " locked?" + '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +109,23 @@
|
|||||||
<key>LSHandlerRank</key>
|
<key>LSHandlerRank</key>
|
||||||
<string>Alternate</string>
|
<string>Alternate</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>bgcode</string>
|
||||||
|
<string>BGCODE</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>bgcode.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>BGCODE</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
<key>LISsAppleDefaultForType</key>
|
||||||
|
<true/>
|
||||||
|
<key>LSHandlerRank</key>
|
||||||
|
<string>Alternate</string>
|
||||||
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleURLTypes</key>
|
<key>CFBundleURLTypes</key>
|
||||||
<array>
|
<array>
|
||||||
|
@ -2258,20 +2258,22 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||||||
if (move.type == EMoveType::Seam)
|
if (move.type == EMoveType::Seam)
|
||||||
++seams_count;
|
++seams_count;
|
||||||
|
|
||||||
size_t move_id = i - seams_count;
|
const size_t move_id = i - seams_count;
|
||||||
|
|
||||||
if (move.type == EMoveType::Extrude) {
|
if (move.type == EMoveType::Extrude) {
|
||||||
if (!move.internal_only) {
|
// layers zs/ranges
|
||||||
// layers zs
|
const double* const last_z = m_layers.empty() ? nullptr : &m_layers.get_zs().back();
|
||||||
const double* const last_z = m_layers.empty() ? nullptr : &m_layers.get_zs().back();
|
const double z = static_cast<double>(move.position.z());
|
||||||
const double z = static_cast<double>(move.position.z());
|
if (last_z == nullptr || z < *last_z - EPSILON || *last_z + EPSILON < z) {
|
||||||
if (last_z == nullptr || z < *last_z - EPSILON || *last_z + EPSILON < z) {
|
// start a new layer
|
||||||
const size_t start_it = (m_layers.empty() && first_travel_s_id != 0) ? first_travel_s_id : last_travel_s_id;
|
const size_t start_it = (m_layers.empty() && first_travel_s_id != 0) ? first_travel_s_id : last_travel_s_id;
|
||||||
m_layers.append(z, { start_it, move_id });
|
m_layers.append(z, { start_it, move_id });
|
||||||
}
|
|
||||||
else
|
|
||||||
m_layers.get_ranges().back().last = move_id;
|
|
||||||
}
|
}
|
||||||
|
else if (!move.internal_only) {
|
||||||
|
// update last layer
|
||||||
|
m_layers.get_ranges().back().last = move_id;
|
||||||
|
}
|
||||||
|
|
||||||
// extruder ids
|
// extruder ids
|
||||||
m_extruder_ids.emplace_back(move.extruder_id);
|
m_extruder_ids.emplace_back(move.extruder_id);
|
||||||
// roles
|
// roles
|
||||||
|
@ -1528,6 +1528,8 @@ bool GLCanvas3D::check_volumes_outside_state(GLVolumeCollection& volumes, ModelI
|
|||||||
contained_min_one |= !volume->is_outside;
|
contained_min_one |= !volume->is_outside;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (volume->is_modifier)
|
||||||
|
volume->is_outside = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int vol_idx = 0; vol_idx < volumes.volumes.size(); ++vol_idx) {
|
for (unsigned int vol_idx = 0; vol_idx < volumes.volumes.size(); ++vol_idx) {
|
||||||
@ -2371,6 +2373,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||||||
volume->extruder_id = extruder_id;
|
volume->extruder_id = extruder_id;
|
||||||
|
|
||||||
volume->is_modifier = !mvs->model_volume->is_model_part();
|
volume->is_modifier = !mvs->model_volume->is_model_part();
|
||||||
|
volume->shader_outside_printer_detection_enabled = mvs->model_volume->is_model_part();
|
||||||
volume->set_color(color_from_model_volume(*mvs->model_volume));
|
volume->set_color(color_from_model_volume(*mvs->model_volume));
|
||||||
// force update of render_color alpha channel
|
// force update of render_color alpha channel
|
||||||
volume->set_render_color(volume->color.is_transparent());
|
volume->set_render_color(volume->color.is_transparent());
|
||||||
|
@ -4547,6 +4547,7 @@ void SubstitutionManager::init(DynamicPrintConfig* config, wxWindow* parent, wxF
|
|||||||
m_em = em_unit(parent);
|
m_em = em_unit(parent);
|
||||||
|
|
||||||
m_substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
|
m_substitutions = m_config->option<ConfigOptionStrings>("gcode_substitutions")->values;
|
||||||
|
m_chb_match_single_lines.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubstitutionManager::validate_length()
|
void SubstitutionManager::validate_length()
|
||||||
|
@ -57,11 +57,10 @@ TEMPLATE_LIST_TEST_CASE("State should not be idle while running a job", "[Jobs]"
|
|||||||
}).wait();
|
}).wait();
|
||||||
});
|
});
|
||||||
|
|
||||||
worker.wait_for_idle();
|
// make sure that the job starts BEFORE the worker.wait_for_idle() is called
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
|
||||||
// To avoid stalling the job, in case the wait_for_idle is called before
|
worker.wait_for_idle();
|
||||||
// the job goes into blocking wait
|
|
||||||
worker.process_events();
|
|
||||||
|
|
||||||
REQUIRE(worker.is_idle());
|
REQUIRE(worker.is_idle());
|
||||||
}
|
}
|
||||||
@ -79,13 +78,12 @@ TEMPLATE_LIST_TEST_CASE("Status messages should be received by the main thread d
|
|||||||
});
|
});
|
||||||
|
|
||||||
worker.wait_for_idle();
|
worker.wait_for_idle();
|
||||||
worker.process_events();
|
|
||||||
|
|
||||||
REQUIRE(pri->pr == 100);
|
REQUIRE(pri->pr == 100);
|
||||||
REQUIRE(pri->statustxt == "Running");
|
REQUIRE(pri->statustxt == "Running");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMPLATE_LIST_TEST_CASE("Cancellation should be recognized by the worker", "[Jobs]", TestClasses) {
|
TEMPLATE_LIST_TEST_CASE("Cancellation should be recognized be the worker", "[Jobs]", TestClasses) {
|
||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
using namespace Slic3r::GUI;
|
using namespace Slic3r::GUI;
|
||||||
|
|
||||||
@ -110,7 +108,6 @@ TEMPLATE_LIST_TEST_CASE("Cancellation should be recognized by the worker", "[Job
|
|||||||
worker.cancel();
|
worker.cancel();
|
||||||
|
|
||||||
worker.wait_for_current_job();
|
worker.wait_for_current_job();
|
||||||
worker.process_events();
|
|
||||||
|
|
||||||
REQUIRE(pri->pr != 100);
|
REQUIRE(pri->pr != 100);
|
||||||
}
|
}
|
||||||
@ -148,7 +145,6 @@ TEMPLATE_LIST_TEST_CASE("cancel_all should remove all pending jobs", "[Jobs]", T
|
|||||||
// during the first job's execution.
|
// during the first job's execution.
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
worker.cancel_all();
|
worker.cancel_all();
|
||||||
worker.process_events();
|
|
||||||
|
|
||||||
REQUIRE(jobres[0] == true);
|
REQUIRE(jobres[0] == true);
|
||||||
REQUIRE(jobres[1] == false);
|
REQUIRE(jobres[1] == false);
|
||||||
@ -177,7 +173,5 @@ TEMPLATE_LIST_TEST_CASE("Exception should be properly forwarded to finalize()",
|
|||||||
});
|
});
|
||||||
|
|
||||||
worker.wait_for_idle();
|
worker.wait_for_idle();
|
||||||
worker.process_events();
|
|
||||||
|
|
||||||
REQUIRE(worker.is_idle());
|
REQUIRE(worker.is_idle());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user