[PartDesign] Dynamic hole cut-types
‣ Make countersink and counterbore on metric holes freely definable by user. ‣ Fixed the Naming of M1.6, M2, M2.5 and M3.5 ‣ Added constructor for custom enums from Enums to PropertyEnumeration ‣ Put definitions of cut-types (counterbore/countersink) for screwtypes into json-files for easy modification. ‣ Allow users to put its own definitions in json-files in [UserDir]/Mod/PartDesign/Resources/Hole ‣ Contains several examples of cut-type definition json-files that are propably not production-ready. This uses a local copy of nlohmann::json¹ to read json-files. __________ ¹ This is a very nice,header-only C++ library under the MIT License (https://github.com/nlohmann/json). I copied the single-file-version and the forward-declaration-header into …/PartDesign/App/ so no new dependencies arise.
This commit is contained in:
@@ -329,6 +329,17 @@ void PropertyEnumeration::setEnums(const char **plEnums)
|
||||
_enum._index = std::min<int>(index, max);
|
||||
}
|
||||
|
||||
void PropertyEnumeration::setEnums(const std::vector<std::string> &Enums)
|
||||
{
|
||||
if (_enum.isValid()) {
|
||||
const std::string &index = getValueAsString();
|
||||
_enum.setEnums(Enums);
|
||||
setValue(index.c_str());
|
||||
} else {
|
||||
_enum.setEnums(Enums);
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyEnumeration::setValue(const char *value)
|
||||
{
|
||||
aboutToSetValue();
|
||||
|
||||
@@ -153,10 +153,17 @@ public:
|
||||
* \endcode
|
||||
*/
|
||||
void setEnums(const char** plEnums);
|
||||
|
||||
/** setting the enumaration string as vector of strings
|
||||
* This makes the enumeration custom.
|
||||
*/
|
||||
void setEnums(const std::vector<std::string> &Enums);
|
||||
|
||||
/** set the enum by a string
|
||||
* is slower than setValue(long). Use long if possible
|
||||
*/
|
||||
void setValue(const char* value);
|
||||
|
||||
/** set directly the enum value
|
||||
* In DEBUG checks for boundaries.
|
||||
* Is faster than using setValue(const char*).
|
||||
|
||||
Reference in New Issue
Block a user