mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-19 14:51:11 -06:00
FIX: Disable print button when gcode has conflict
Also fix a crash bug due to setStarted and setDone. Change-Id: Ib9b069fe4b7e5d1fc359f48e44b4032dd8249428 (cherry picked from commit 9ef190ed3ecd66d12617ad96e927ff34251395a2)
This commit is contained in:
parent
e002885efc
commit
d72b4c1bfe
9 changed files with 78 additions and 8 deletions
|
@ -201,6 +201,7 @@ ConflictRet ConflictChecker::find_inter_of_lines(const LineWithIDs &lines)
|
|||
|
||||
ConflictRet ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectPtrs objs) // find the first intersection point of lines in different objects
|
||||
{
|
||||
if (objs.size() <= 1) { return {}; }
|
||||
LinesBucketQueue conflictQueue;
|
||||
for (PrintObject *obj : objs) {
|
||||
auto layers = getAllLayersExtrusionPathsFromObject(obj);
|
||||
|
|
|
@ -90,6 +90,29 @@ namespace Slic3r {
|
|||
|
||||
struct GCodeProcessorResult
|
||||
{
|
||||
//BBS
|
||||
struct ConflictResult
|
||||
{
|
||||
bool conflicted;
|
||||
std::string obj1Name;
|
||||
std::string obj2Name;
|
||||
|
||||
void set(const std::string &o1, const std::string &o2)
|
||||
{
|
||||
conflicted = true;
|
||||
obj1Name = o1;
|
||||
obj2Name = o2;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
conflicted = false;
|
||||
obj1Name.clear();
|
||||
obj2Name.clear();
|
||||
}
|
||||
|
||||
ConflictResult() = default;
|
||||
ConflictResult(const ConflictResult &) = default;
|
||||
}conflict_result;
|
||||
|
||||
struct SettingsIds
|
||||
{
|
||||
|
|
|
@ -1669,20 +1669,20 @@ void Print::process(bool use_cache)
|
|||
// BBS
|
||||
if(!m_no_check)
|
||||
{
|
||||
this->set_started(psConflictCheck);
|
||||
this->set_status(70, L("Checking gcode path conflicts."));
|
||||
using Clock = std::chrono::high_resolution_clock;
|
||||
auto startTime = Clock::now();
|
||||
auto conflictRes = ConflictChecker::find_inter_of_lines_in_diff_objs(m_objects);
|
||||
auto endTime = Clock::now();
|
||||
volatile double seconds = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count() / (double) 1000;
|
||||
BOOST_LOG_TRIVIAL(info) << "gcode path conflicts check takes " << seconds << " secs.";
|
||||
|
||||
if (conflictRes.has_value()) {
|
||||
m_conflict_result.set(conflictRes.value()._obj1, conflictRes.value()._obj2);
|
||||
auto objName1 = conflictRes.value()._obj1->m_model_object->name;
|
||||
auto objName2 = conflictRes.value()._obj2->m_model_object->name;
|
||||
//throw Slic3r::SlicingError((boost::format(L("Conflicts of gcode paths have been found. Please separate the conflicted objects (%s + %s) farther.")) % objName1% objName2).str());
|
||||
this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, (boost::format(L("Conflicts of gcode paths have been found. Please separate the conflicted objects (%s <-> %s) farther.")) % objName1 % objName2).str());
|
||||
} else {
|
||||
m_conflict_result.reset();
|
||||
}
|
||||
this->set_done(psConflictCheck);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "Slicing process finished." << log_memory_info();
|
||||
|
@ -1713,6 +1713,12 @@ std::string Print::export_gcode(const std::string& path_template, GCodeProcessor
|
|||
const Vec3d origin = this->get_plate_origin();
|
||||
gcode.set_gcode_offset(origin(0), origin(1));
|
||||
gcode.do_export(this, path.c_str(), result, thumbnail_cb);
|
||||
//BBS
|
||||
if (m_conflict_result.conflicted) {
|
||||
result->conflict_result.set(m_conflict_result.obj1->m_model_object->name, m_conflict_result.obj2->m_model_object->name);
|
||||
} else {
|
||||
result->conflict_result.reset();
|
||||
}
|
||||
return path.c_str();
|
||||
}
|
||||
|
||||
|
|
|
@ -774,6 +774,28 @@ private:
|
|||
Vec3d m_origin;
|
||||
//BBS: modified_count
|
||||
int m_modified_count {0};
|
||||
//BBS
|
||||
struct ConflictResult
|
||||
{
|
||||
bool conflicted;
|
||||
PrintObject *obj1;
|
||||
PrintObject *obj2;
|
||||
//TODO
|
||||
//the actual loaction
|
||||
|
||||
void set(PrintObject *o1, PrintObject *o2)
|
||||
{
|
||||
conflicted = true;
|
||||
obj1 = o1;
|
||||
obj2 = o2;
|
||||
}
|
||||
void reset()
|
||||
{
|
||||
conflicted = false;
|
||||
obj1 = nullptr;
|
||||
obj2 = nullptr;
|
||||
}
|
||||
}m_conflict_result;
|
||||
|
||||
// To allow GCode to set the Print's GCodeExport step status.
|
||||
friend class GCode;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue