Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer

This commit is contained in:
enricoturri1966 2020-07-21 16:01:27 +02:00
commit 6bbc7c048f
6 changed files with 13 additions and 11 deletions

View File

@ -42,6 +42,8 @@ private:
// Base for Model, ModelObject, ModelVolume, ModelInstance or ModelMaterial to provide a unique ID
// to synchronize the front end (UI) with the back end (BackgroundSlicingProcess / Print / PrintObject).
// Also base for Print, PrintObject, SLAPrint, SLAPrintObject to provide a unique ID for matching Model / ModelObject
// with their corresponding Print / PrintObject objects by the notification center at the UI when processing back-end warnings.
// Achtung! The s_last_id counter is not thread safe, so it is expected, that the ObjectBase derived instances
// are only instantiated from the main thread.
class ObjectBase

View File

@ -450,7 +450,7 @@ public:
// in the notification center.
const PrintObject* get_object(ObjectID object_id) const {
auto it = std::find_if(m_objects.begin(), m_objects.end(),
[object_id](const PrintObject *obj) { return *static_cast<const ObjectID*>(obj) == object_id; });
[object_id](const PrintObject *obj) { return obj->id() == object_id; });
return (it == m_objects.end()) ? nullptr : *it;
}
const PrintRegionPtrs& regions() const { return m_regions; }

View File

@ -93,7 +93,7 @@ void PrintBase::status_update_warnings(ObjectID object_id, int step, PrintStateB
if (this->m_status_callback)
m_status_callback(SlicingStatus(*this, step));
else if (! message.empty())
printf("%s warning: %s\n", (object_id == ObjectID(*this)) ? "print" : "print object", message.c_str());
printf("%s warning: %s\n", (object_id == this->id()) ? "print" : "print object", message.c_str());
}
tbb::mutex& PrintObjectBase::state_mutex(PrintBase *print)
@ -108,7 +108,7 @@ std::function<void()> PrintObjectBase::cancel_callback(PrintBase *print)
void PrintObjectBase::status_update_warnings(PrintBase *print, int step, PrintStateBase::WarningLevel warning_level, const std::string &message)
{
print->status_update_warnings(*this, step, warning_level, message);
print->status_update_warnings(this->id(), step, warning_level, message);
}
} // namespace Slic3r

View File

@ -304,7 +304,7 @@ private:
class PrintBase;
class PrintObjectBase : public ObjectID
class PrintObjectBase : public ObjectBase
{
public:
const ModelObject* model_object() const { return m_model_object; }
@ -335,7 +335,7 @@ protected:
* The PrintBase class will abstract this flow for different technologies.
*
*/
class PrintBase : public ObjectID
class PrintBase : public ObjectBase
{
public:
PrintBase() : m_placeholder_parser(&m_full_print_config) { this->restart(); }
@ -386,9 +386,9 @@ public:
struct SlicingStatus {
SlicingStatus(int percent, const std::string &text, unsigned int flags = 0) : percent(percent), text(text), flags(flags) {}
SlicingStatus(const PrintBase &print, int warning_step) :
flags(UPDATE_PRINT_STEP_WARNINGS), warning_object_id(print), warning_step(warning_step) {}
flags(UPDATE_PRINT_STEP_WARNINGS), warning_object_id(print.id()), warning_step(warning_step) {}
SlicingStatus(const PrintObjectBase &print_object, int warning_step) :
flags(UPDATE_PRINT_OBJECT_STEP_WARNINGS), warning_object_id(print_object), warning_step(warning_step) {}
flags(UPDATE_PRINT_OBJECT_STEP_WARNINGS), warning_object_id(print_object.id()), warning_step(warning_step) {}
int percent { -1 };
std::string text;
// Bitmap of flags.
@ -508,7 +508,7 @@ protected:
PrintStateBase::TimeStamp set_done(PrintStepEnum step) {
std::pair<PrintStateBase::TimeStamp, bool> status = m_state.set_done(step, this->state_mutex(), [this](){ this->throw_if_canceled(); });
if (status.second)
this->status_update_warnings(*this, static_cast<int>(step), PrintStateBase::WarningLevel::NON_CRITICAL, std::string());
this->status_update_warnings(this->id(), static_cast<int>(step), PrintStateBase::WarningLevel::NON_CRITICAL, std::string());
return status.first;
}
bool invalidate_step(PrintStepEnum step)
@ -530,7 +530,7 @@ protected:
std::pair<PrintStepEnum, bool> active_step = m_state.active_step_add_warning(warning_level, message, message_id, this->state_mutex());
if (active_step.second)
// Update UI.
this->status_update_warnings(*this, static_cast<int>(active_step.first), warning_level, message);
this->status_update_warnings(this->id(), static_cast<int>(active_step.first), warning_level, message);
}
private:

View File

@ -433,7 +433,7 @@ public:
// in the notification center.
const SLAPrintObject* get_object(ObjectID object_id) const {
auto it = std::find_if(m_objects.begin(), m_objects.end(),
[object_id](const SLAPrintObject *obj) { return *static_cast<const ObjectID*>(obj) == object_id; });
[object_id](const SLAPrintObject *obj) { return obj->id() == object_id; });
return (it == m_objects.end()) ? nullptr : *it;
}

View File

@ -350,7 +350,7 @@ void ObjectList::get_selection_indexes(std::vector<int>& obj_idxs, std::vector<i
else {
for (wxDataViewItem item : sels) {
const ItemType type = m_objects_model->GetItemType(item);
assert(type & itObject | itInstance | itInstanceRoot);
assert(type & (itObject | itInstance | itInstanceRoot));
obj_idxs.emplace_back(type & itObject ? m_objects_model->GetIdByItem(item) :
m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item)));