mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-12 03:27:55 +00:00
Fix per-obj multi-variant options handling (#14700)
* ENH: config: add logic to apply params to object/region config with multi-extruder JIRA: no-jira Change-Id: Ieab98cd8d031e5ca82a3aad2d0b89d8ae4a794f1 (cherry picked from commit 3179fd416e68ca8bc2d746f859508d07db18fe5b) * FIX: X1C switch to H2D lose Highflow parameter Jira: STUDIO-15272 Change-Id: Id8cf5d93a49d5542ac82f9554974b458e15c1193 (cherry picked from commit 15d9f072ff658a3beb4f916d978dfea12c2d9f16) * Fix mishandling of `stride` param and add unit test for it * Fix modified multi-variant per-obj option highlight * Fix issue that per-obj FloatsOrPercents options are marked as dirty incorrectly when lost focus --------- Co-authored-by: lane.wei <lane.wei@bambulab.com> Co-authored-by: weiting.ji <weiting.ji@bambulab.com>
This commit is contained in:
@@ -363,6 +363,7 @@ public:
|
||||
virtual void set_with_restore(const ConfigOptionVectorBase* rhs, std::vector<int>& restore_index, int stride) = 0;
|
||||
virtual void set_with_restore_2(const ConfigOptionVectorBase* rhs, std::vector<int>& restore_index, int start, int len, bool skip_error = false) = 0;
|
||||
virtual void set_only_diff(const ConfigOptionVectorBase* rhs, std::vector<int>& diff_index, int stride) = 0;
|
||||
virtual void set_to_index(const ConfigOptionVectorBase* rhs, std::vector<int>& dest_index, int stride) = 0;
|
||||
virtual void set_with_nil(const ConfigOptionVectorBase* rhs, const ConfigOptionVectorBase* inherits, int stride) = 0;
|
||||
// Resize the vector of values, copy the newly added values from opt_default if provided.
|
||||
virtual void resize(size_t n, const ConfigOption *opt_default = nullptr) = 0;
|
||||
@@ -586,6 +587,32 @@ public:
|
||||
throw ConfigurationError("ConfigOptionVector::set_only_diff(): Assigning an incompatible type");
|
||||
}
|
||||
|
||||
//set a item related with extruder variants when apply static config with dynamic config
|
||||
//rhs: item from dynamic config
|
||||
//dest_index: which index in this vector need to be used
|
||||
virtual void set_to_index(const ConfigOptionVectorBase* rhs, std::vector<int>& dest_index, int stride) override
|
||||
{
|
||||
if (rhs->type() == this->type()) {
|
||||
// Assign the first value of the rhs vector.
|
||||
auto other = static_cast<const ConfigOptionVector<T>*>(rhs);
|
||||
T v = other->values.front();
|
||||
this->values.resize(dest_index.size() * stride, v);
|
||||
|
||||
for (size_t i = 0; i < dest_index.size(); i++) {
|
||||
if (dest_index[i] < 0)
|
||||
continue;
|
||||
for (size_t j = 0; j < size_t(stride); j++)
|
||||
{
|
||||
const size_t src_idx = size_t(dest_index[i]) * size_t(stride) + j;
|
||||
if (src_idx < other->values.size() && !other->is_nil(size_t(dest_index[i]) * size_t(stride)))
|
||||
this->values[i * size_t(stride) + j] = other->values[src_idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
throw ConfigurationError("ConfigOptionVector::set_to_index(): Assigning an incompatible type");
|
||||
}
|
||||
|
||||
//set a item related with extruder variants when saving user config, set the non-diff value of some extruder to nill
|
||||
//this item has different value with inherit config
|
||||
//rhs: item from userconfig
|
||||
|
||||
Reference in New Issue
Block a user