PD: Fix helix property visibility/writability (#5254)
[PD]: Fix helix property visibility/writeability * Hide irrelevant and internal helix properties - The `HasBeenEdited` property is only used internally to check whether to fill certain other parameters with initial values. So there is no need show it in the property grid at all. - The `Outside` property is only used in the subtractive helix and thus hidden for the additive helix. * Make derived helix properties read-only Depending on the input mode, some properties are primary input, others are derived. Prior to this change, also the derived properties have been writable but their values are ignored and overwritten on the next recompute. Now, when changing the input mode, only the primary input props are writable. * Reorder some helix properties This change puts the reference axis and input mode at the top to become more prominent. Only "Base" and "Axis" are higher in the list for consistency with the other axis-based features.
This commit is contained in:
@@ -76,12 +76,19 @@ const App::PropertyAngle::Constraints Helix::floatAngle = { -89.0, 89.0, 1.0 };
|
||||
Helix::Helix()
|
||||
{
|
||||
addSubType = FeatureAddSub::Additive;
|
||||
auto initialMode = HelixMode::pitch_height_angle;
|
||||
|
||||
const char* group = "Helix";
|
||||
ADD_PROPERTY_TYPE(Base, (Base::Vector3d(0.0, 0.0, 0.0)), group, App::Prop_ReadOnly,
|
||||
"The center point of the helix' start.");
|
||||
"The center point of the helix' start; derived from the reference axis.");
|
||||
ADD_PROPERTY_TYPE(Axis, (Base::Vector3d(0.0, 1.0, 0.0)), group, App::Prop_ReadOnly,
|
||||
"The helix' direction.");
|
||||
"The helix' direction; derived from the reference axis.");
|
||||
ADD_PROPERTY_TYPE(ReferenceAxis, (0), group, App::Prop_None,
|
||||
"The reference axis of the helix.");
|
||||
ADD_PROPERTY_TYPE(Mode, (long(initialMode)), group, App::Prop_None,
|
||||
"The helix input mode specifies which properties are set by the user.\n"
|
||||
"Dependent properties are then calculated.");
|
||||
Mode.setEnums(ModeEnums);
|
||||
ADD_PROPERTY_TYPE(Pitch, (10.), group, App::Prop_None,
|
||||
"The axial distance between two turns.");
|
||||
ADD_PROPERTY_TYPE(Height, (30.0), group, App::Prop_None,
|
||||
@@ -89,11 +96,6 @@ Helix::Helix()
|
||||
ADD_PROPERTY_TYPE(Turns, (3.0), group, App::Prop_None,
|
||||
"The number of turns in the helix.");
|
||||
Turns.setConstraints(&floatTurns);
|
||||
ADD_PROPERTY_TYPE(LeftHanded, (long(0)), group, App::Prop_None,
|
||||
"Sets the turning direction to left handed,\n"
|
||||
"i.e. counter-clockwise when moving along its axis.");
|
||||
ADD_PROPERTY_TYPE(Reversed, (long(0)), group, App::Prop_None,
|
||||
"Determines whether the helix points in the opposite direction of the axis.");
|
||||
ADD_PROPERTY_TYPE(Angle, (0.0), group, App::Prop_None,
|
||||
"The angle of the cone that forms a hull around the helix.\n"
|
||||
"Non-zero values turn the helix into a conical spiral.\n"
|
||||
@@ -102,17 +104,18 @@ Helix::Helix()
|
||||
ADD_PROPERTY_TYPE(Growth, (0.0), group, App::Prop_None,
|
||||
"The growth of the helix' radius per turn.\n"
|
||||
"Non-zero values turn the helix into a conical spiral.");
|
||||
ADD_PROPERTY_TYPE(ReferenceAxis, (0), group, App::Prop_None,
|
||||
"The reference axis of the helix.");
|
||||
ADD_PROPERTY_TYPE(Mode, (long(0)), group, App::Prop_None,
|
||||
"The helix input mode specifies which properties are set by the user.\n"
|
||||
"Dependent properties are then calculated.");
|
||||
Mode.setEnums(ModeEnums);
|
||||
ADD_PROPERTY_TYPE(LeftHanded, (long(0)), group, App::Prop_None,
|
||||
"Sets the turning direction to left handed,\n"
|
||||
"i.e. counter-clockwise when moving along its axis.");
|
||||
ADD_PROPERTY_TYPE(Reversed, (long(0)), group, App::Prop_None,
|
||||
"Determines whether the helix points in the opposite direction of the axis.");
|
||||
ADD_PROPERTY_TYPE(Outside, (long(0)), group, App::Prop_None,
|
||||
"If set, the result will be the intersection of the profile and the preexisting body.");
|
||||
ADD_PROPERTY_TYPE(HasBeenEdited, (long(0)), group, App::Prop_None,
|
||||
ADD_PROPERTY_TYPE(HasBeenEdited, (long(0)), group, App::Prop_Hidden,
|
||||
"If false, the tool will propose an initial value for the pitch based on the profile bounding box,\n"
|
||||
"so that self intersection is avoided.");
|
||||
|
||||
setReadWriteStatusForMode(initialMode);
|
||||
}
|
||||
|
||||
short Helix::mustExecute() const
|
||||
@@ -619,12 +622,79 @@ void Helix::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeN
|
||||
}
|
||||
}
|
||||
|
||||
void Helix::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &Mode) {
|
||||
// Depending on the mode, the derived properties are set read-only
|
||||
auto inputMode = static_cast<HelixMode>(Mode.getValue());
|
||||
setReadWriteStatusForMode(inputMode);
|
||||
}
|
||||
|
||||
ProfileBased::onChanged(prop);
|
||||
}
|
||||
|
||||
void Helix::setReadWriteStatusForMode(HelixMode inputMode)
|
||||
{
|
||||
switch (inputMode)
|
||||
{
|
||||
case HelixMode::pitch_height_angle:
|
||||
// primary input:
|
||||
Pitch.setStatus(App::Property::ReadOnly, false);
|
||||
Height.setStatus(App::Property::ReadOnly, false);
|
||||
Angle.setStatus(App::Property::ReadOnly, false);
|
||||
// derived props:
|
||||
Turns.setStatus(App::Property::ReadOnly, true);
|
||||
Growth.setStatus(App::Property::ReadOnly, true);
|
||||
break;
|
||||
|
||||
case HelixMode::pitch_turns_angle:
|
||||
// primary input:
|
||||
Pitch.setStatus(App::Property::ReadOnly, false);
|
||||
Turns.setStatus(App::Property::ReadOnly, false);
|
||||
Angle.setStatus(App::Property::ReadOnly, false);
|
||||
// derived props:
|
||||
Height.setStatus(App::Property::ReadOnly, true);
|
||||
Growth.setStatus(App::Property::ReadOnly, true);
|
||||
break;
|
||||
|
||||
case HelixMode::height_turns_angle:
|
||||
// primary input:
|
||||
Height.setStatus(App::Property::ReadOnly, false);
|
||||
Turns.setStatus(App::Property::ReadOnly, false);
|
||||
Angle.setStatus(App::Property::ReadOnly, false);
|
||||
// derived props:
|
||||
Pitch.setStatus(App::Property::ReadOnly, true);
|
||||
Growth.setStatus(App::Property::ReadOnly, true);
|
||||
break;
|
||||
|
||||
case HelixMode::height_turns_growth:
|
||||
// primary input:
|
||||
Height.setStatus(App::Property::ReadOnly, false);
|
||||
Turns.setStatus(App::Property::ReadOnly, false);
|
||||
Growth.setStatus(App::Property::ReadOnly, false);
|
||||
// derived props:
|
||||
Pitch.setStatus(App::Property::ReadOnly, true);
|
||||
Angle.setStatus(App::Property::ReadOnly, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
Pitch.setStatus(App::Property::ReadOnly, false);
|
||||
Height.setStatus(App::Property::ReadOnly, false);
|
||||
Turns.setStatus(App::Property::ReadOnly, false);
|
||||
Angle.setStatus(App::Property::ReadOnly, false);
|
||||
Growth.setStatus(App::Property::ReadOnly, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::AdditiveHelix, PartDesign::Helix)
|
||||
AdditiveHelix::AdditiveHelix() {
|
||||
addSubType = Additive;
|
||||
Outside.setStatus(App::Property::Hidden, true);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::SubtractiveHelix, PartDesign::Helix)
|
||||
SubtractiveHelix::SubtractiveHelix() {
|
||||
addSubType = Subtractive;
|
||||
Outside.setStatus(App::Property::Hidden, false);
|
||||
}
|
||||
|
||||
@@ -88,13 +88,19 @@ protected:
|
||||
// center of profile bounding box
|
||||
Base::Vector3d getProfileCenterPoint();
|
||||
|
||||
// handle changed property
|
||||
// handle changed property types for backward compatibility
|
||||
virtual void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, App::Property* prop);
|
||||
|
||||
void onChanged(const App::Property* prop);
|
||||
|
||||
static const App::PropertyFloatConstraint::Constraints floatTurns;
|
||||
static const App::PropertyAngle::Constraints floatAngle;
|
||||
|
||||
private:
|
||||
static const char* ModeEnums[];
|
||||
|
||||
// Sets the read-only status bit for properties depending on the input mode.
|
||||
void setReadWriteStatusForMode(HelixMode inputMode);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user