mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 12:42:02 +08:00
Propagate information about colliding objects into the UI
This commit is contained in:
parent
cfcfeb8cab
commit
736033e02a
@ -337,18 +337,7 @@ void SeqArrange::apply_seq_arrange(Model& model) const
|
||||
|
||||
|
||||
|
||||
|
||||
bool check_seq_printability(const Model& model, const ConfigBase& config)
|
||||
{
|
||||
if (auto conflict = check_seq_conflict(model, config))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::optional<std::pair<int, int> > check_seq_conflict(const Model& model, const ConfigBase& config)
|
||||
std::optional<std::pair<std::string, std::string> > check_seq_conflict(const Model& model, const ConfigBase& config)
|
||||
{
|
||||
Sequential::PrinterGeometry printer_geometry = get_printer_geometry(config);
|
||||
Sequential::SolverConfiguration solver_config = get_solver_config(printer_geometry);
|
||||
@ -380,8 +369,19 @@ std::optional<std::pair<int, int> > check_seq_conflict(const Model& model, const
|
||||
}
|
||||
}
|
||||
|
||||
//return Sequential::check_ScheduledObjectsForSequentialPrintability(solver_config, printer_geometry, objects, std::vector<Sequential::ScheduledPlate>(1, plate));
|
||||
return Sequential::check_ScheduledObjectsForSequentialConflict(solver_config, printer_geometry, objects, std::vector<Sequential::ScheduledPlate>(1, plate));
|
||||
std::optional<std::pair<int,int>> conflict = Sequential::check_ScheduledObjectsForSequentialConflict(solver_config, printer_geometry, objects, std::vector<Sequential::ScheduledPlate>(1, plate));
|
||||
if (conflict) {
|
||||
std::pair<std::string, std::string> names;
|
||||
for (const ModelObject* mo : model.objects)
|
||||
for (const ModelInstance* mi : mo->instances) {
|
||||
if (mi->id().id == conflict->first)
|
||||
names.first = mo->name;
|
||||
if (mi->id().id == conflict->second)
|
||||
names.second = mo->name;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,8 +15,7 @@ namespace Slic3r {
|
||||
|
||||
void arrange_model_sequential(Model& model, const ConfigBase& config);
|
||||
|
||||
bool check_seq_printability(const Model& model, const ConfigBase& config);
|
||||
std::optional<std::pair<int, int> > check_seq_conflict(const Model& model, const ConfigBase& config);
|
||||
std::optional<std::pair<std::string, std::string>> check_seq_conflict(const Model& model, const ConfigBase& config);
|
||||
|
||||
// This is just a helper class to collect data for seq. arrangement, running the arrangement
|
||||
// and applying the results to model. It is here so the processing itself can be offloaded
|
||||
|
@ -538,7 +538,7 @@ void GCodeProcessorResult::reset() {
|
||||
custom_gcode_per_print_z = std::vector<CustomGCode::Item>();
|
||||
spiral_vase_mode = false;
|
||||
conflict_result = std::nullopt;
|
||||
sequential_collision_detected = false;
|
||||
sequential_collision_detected = std::nullopt;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<GCodeProcessor::EProducer, std::string>> GCodeProcessor::Producers = {
|
||||
|
@ -163,7 +163,7 @@ namespace Slic3r {
|
||||
bool spiral_vase_mode;
|
||||
|
||||
ConflictResultOpt conflict_result;
|
||||
bool sequential_collision_detected;
|
||||
std::optional<std::pair<std::string, std::string>> sequential_collision_detected;
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
@ -970,7 +970,7 @@ void Print::process()
|
||||
if (conflictRes.has_value())
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("gcode path conflicts found between %1% and %2%") % conflictRes->_objName1 % conflictRes->_objName2;
|
||||
|
||||
m_sequential_collision_detected = config().complete_objects && ! check_seq_printability(model(), config());
|
||||
m_sequential_collision_detected = config().complete_objects ? check_seq_conflict(model(), config()) : std::nullopt;
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "Slicing process finished." << log_memory_info();
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ private:
|
||||
friend class PrintObject;
|
||||
|
||||
ConflictResultOpt m_conflict_result;
|
||||
bool m_sequential_collision_detected;
|
||||
std::optional<std::pair<std::string, std::string>> m_sequential_collision_detected; // names of objects (hit first when printing second)
|
||||
};
|
||||
|
||||
} /* slic3r_Print_hpp_ */
|
||||
|
@ -261,7 +261,7 @@ private:
|
||||
bool m_contained_in_bed{ true };
|
||||
|
||||
ConflictResultOpt m_conflict_result;
|
||||
bool m_sequential_collision_detected{ false };
|
||||
std::optional<std::pair<std::string, std::string>> m_sequential_collision_detected;
|
||||
|
||||
libvgcode::Viewer m_viewer;
|
||||
bool m_loaded_as_preview{ false };
|
||||
@ -358,7 +358,7 @@ public:
|
||||
void invalidate_legend() { m_legend_resizer.reset(); }
|
||||
|
||||
const ConflictResultOpt& get_conflict_result() const { return m_conflict_result; }
|
||||
bool get_sequential_collision_detected() const { return m_sequential_collision_detected; }
|
||||
std::optional<std::pair<std::string, std::string>> get_sequential_collision_detected() const { return m_sequential_collision_detected; }
|
||||
|
||||
void load_shells(const Print& print);
|
||||
|
||||
|
@ -7372,7 +7372,7 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
|
||||
else if (warning == EWarning::GCodeConflict)
|
||||
show = m_gcode_viewer.has_data() && m_gcode_viewer.is_contained_in_bed() && m_gcode_viewer.get_conflict_result().has_value();
|
||||
else if (warning == EWarning::SequentialCollision)
|
||||
show = m_gcode_viewer.has_data() && m_gcode_viewer.get_sequential_collision_detected();
|
||||
show = m_gcode_viewer.has_data() && m_gcode_viewer.get_sequential_collision_detected().has_value();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7413,7 +7413,12 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
|
||||
break;
|
||||
}
|
||||
case EWarning::SequentialCollision: {
|
||||
text = _u8L("Collision between an object and extruder gantry detected.");
|
||||
auto conflict = m_gcode_viewer.get_sequential_collision_detected();
|
||||
if (! conflict.has_value())
|
||||
break;
|
||||
// TRN: Placeholders contain names of the colliding objects.
|
||||
text = format(_u8L("Extruder will crash into %1% while printing %2%."),
|
||||
conflict->first, conflict->second);
|
||||
error = ErrorType::SLICING_ERROR;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user