Handles
Handles are a feature of a PythonPart, which improves the user's experience by allowing him to edit the geometry (or in some cases also non-geometrical properties) directly in the model view. The user can be provided a possibility to perform various operations e.g.:
- changing a dimension with dimension handle
- define a coordinate with coordinate handle
- execute action with button handle
- hiding or displaying a component with checkbox handle
- increment a dimension with increment handle
- input an angle with rotation handle
A handle can be assigned to a PythonPart parameter. If that is the case, it is possible to show an input field directly inside the model view.
Create a handle
Handle is created by instantiating the class HandleProperties. Object of this class represents a handle. Handle processing differs depending on whether the PythonPart is an interactor or not. Please refer to the relevant subsection to learn more.
The composition of the HandleProperties class is shown below.
classDiagram
direction BT
class Point3D {
float X
float Y
float Z
}
class ElementHandleType{
<<Enumeration>>
HANDLE_ARROW
HANDLE_CIRCLE
HANDLE_SQUARE_BLUE
HANDLE_SQUARE_EMPTY
HANDLE_SQUARE_RED
HANDLE_SQUARE_RIGHT
}
class HandleDirection{
<<Enumeration>>
X_DIR
Y_DIR
Z_DIR
XY_DIR
XZ_DIR
YZ_DIR
XYZ_DIR
POINT_DIR
ANGLE
Z_COORD
PLANE_DIR
VECTOR_DIR
CLICK
}
class HandleParameterType{
<<Enumeration>>
X_DISTANCE
Y_DISTANCE
Z_DISTANCE
POINT
POINT_DISTANCE
ANGLE
Z_COORD
VECTOR_DISTANCE
CHECK_BOX
INCREMENT_BUTTON
DECREMENT_BUTTON
}
class HandleParameterData{
<<Dataclass>>
+str param_prop_name
+HandleParameterType param_type
}
class HandleProperties{
+str handle_id
+Point3D handle_point
+Point3D ref_point
+List[HandleParameterData] parameter_data
+HandleDirection handle_move_dir
+ElementHandleType handle_type
}
Point3D "2" ..> HandleProperties
ElementHandleType ..> HandleProperties
HandleDirection ..> HandleProperties
HandleParameterData ..> HandleProperties
HandleParameterType ..> HandleParameterData
Handle type
The enumeration class ElementHandleType defines the layout of the handle. The default value when instantiating the class HandleProperties is HANDLE_CIRCLE and can be changed to one of the following:
Layout | Type |
---|---|
HANDLE_ARROW | |
HANDLE_CIRCLE | |
HANDLE_SQUARE_BLUE | |
HANDLE_SQUARE_EMPTY | |
HANDLE_SQUARE_RED | |
HANDLE_SQUARE_RIGHT |
Handle parameter data
The data class HandleParameterData connects the handle to a specific PythonPart parameter defined in the .pyp file. Thanks to this, a parameter value is recalculated every time a connected handle is modified. The recalculation is performed depending on the defined HandleParameterType.
Handle parameter type
The enumeration class HandleParameterType defines how the value of the parameter property assigned to the handle should be recalculated, when the handle is modified. Please refer to the API reference to see, what recalculation methods are available.
Handle direction
The enumeration class HandleDirection defines the allowed direction, in which the handle can be moved when being modified. Please refer to the API reference to see the available options.