diff --git a/src/Mod/Fem/App/FemPostFilter.cpp b/src/Mod/Fem/App/FemPostFilter.cpp index 2096a2c2a3..76116180c2 100644 --- a/src/Mod/Fem/App/FemPostFilter.cpp +++ b/src/Mod/Fem/App/FemPostFilter.cpp @@ -477,7 +477,8 @@ FemPostContoursFilter::FemPostContoursFilter() ADD_PROPERTY_TYPE(Field, (long(0)), "Clip", App::Prop_None, "The field used to clip"); ADD_PROPERTY_TYPE( VectorMode, ((long)0), "Contours", App::Prop_None, "Select what vector field"); - ADD_PROPERTY_TYPE(NoColor, (false), "Contours", App::Prop_None, "Don't color the contours"); + ADD_PROPERTY_TYPE(NoColor, (false), "Contours", + PropertyType(Prop_Hidden), "Don't color the contours"); m_contourConstraints.LowerBound = 1; m_contourConstraints.UpperBound = 1000; diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index 0b9ac4d2c3..fe24296f87 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -1369,26 +1369,19 @@ TaskPostContours::~TaskPostContours() void TaskPostContours::applyPythonCode() {} -void TaskPostContours::updateFields(int idx) +void TaskPostContours::updateFields() { - std::vector fieldArray; - std::vector vec = - getTypedObject()->Field.getEnumVector(); - for (std::vector::iterator it = vec.begin(); it != vec.end(); ++it) { - fieldArray.emplace_back(*it); + // update the ViewProvider Field + // since the ViewProvider can have another field sorting, we cannot use the same index + if (!static_cast(getObject())->NoColor.getValue()) { + std::string objectField = + getTypedObject()->Field.getValueAsString(); + getTypedView()->Field.setValue(objectField.c_str()); } - // update the ViewProvider Field enums - App::Enumeration anEnum; - getTypedView()->Field.setValue(anEnum); - anEnum.setEnums(fieldArray); - getTypedView()->Field.setValue(anEnum); - // set new Field index to ViewProvider Field - // the ViewProvider field starts with an additional entry "None", - // therefore the desired new setting is idx + 1 - if (!static_cast(getObject())->NoColor.getValue()) - getTypedView()->Field.setValue(idx + 1); - else - getTypedView()->Field.setValue(long(0)); + else { + getTypedView()->Field.setValue("None"); + } + } void TaskPostContours::onFieldsChanged(int idx) @@ -1402,7 +1395,7 @@ void TaskPostContours::onFieldsChanged(int idx) // In > 99 % of the cases the coloring should be equal to the field, // thus change the coloring field too. Users can override this be resetting only the coloring // field afterwards in the properties if really necessary. - updateFields(idx); + updateFields(); // since a new field can be e.g. no vector while the previous one was, // we must also update the VectorMode @@ -1421,8 +1414,7 @@ void TaskPostContours::onVectorModeChanged(int idx) // since it is a 2D field, Z is eompty thus no field is available to color // when the user noch goes back to e.g. "Y" we must set the Field // first to get the possible VectorModes of that field - auto currentField = getTypedObject()->Field.getValue(); - updateFields(currentField); + updateFields(); // now we can set the VectorMode if (!static_cast(getObject())->NoColor.getValue()) getTypedView()->VectorMode.setValue(idx); diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.h b/src/Mod/Fem/Gui/TaskPostBoxes.h index 0a6e5e7803..4f1fa1a23c 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.h +++ b/src/Mod/Fem/Gui/TaskPostBoxes.h @@ -385,7 +385,7 @@ private: QWidget* proxy; std::unique_ptr ui; bool blockVectorUpdate = false; - void updateFields(int idx); + void updateFields(); };