MeasurementOperator
-
class
HPS.MeasurementOperator: HPS.Operator The MeasurementOperator class defines an operator which allows the user to measure geometry. This operator responds to both mouse and touch events. Five different measuring types are available: Point to Point, Line, Angle, Area and Distance. Whenever a measurement is inserted, an Event of type MeasurementEvent is injected. This event can be handled in order to to get details about the measurement (its type and value), which View it was inserted under, and what Segment it was placed on. This information, and specifically the segment in which the measurement is placed, can be used to customize the appearance of the measurement, to delete it, hide it, etc…
When vertex snapping is enabled, the measurement operator will try to snap to vertices close to the location that was clicked / touched. The value of the proximity snapping is expressed in centimeter. Snapping is not taken into consideration when placing Distance measurements.
If hinting is turned on, which it is by default, the operator will give the user feedback on what would be measured if a click were to happen at the current position. This feedback is given in the form of markers of various shapes. By default, an X means that the clicking the current point will not yield a measurement point. This can happen if the click happens off the geometry or if the current point would otherwise be invalid (for example, if the point would not be on the same plane as the other points which describe an area measurement). When vertex snapping is enabled, a square denotes the position the measurement point would snap to. Finally, a circle indicates that the current selection is valid but would not be snapped to a vertex. The look of these hinting geometry can be changed at anytime by editing the attributes found in their owning segments. The segments can be obtained through a call to GetHintSegment Hinting geometry is not enabled for Distance measurement, since the individual points picked are not relevant in this mode.
The number of decimal place shown in measurement labels can be changed through the SetPrecision function, and defaults to 2.
When working with a CADModel, the CADModel can be passed to this operator through the SetCADModel function. Setting a CADModel allows the operator to detect the unit of measurements used in the loaded file, which will be displayed when inserting measurement labels. When a CADModel is not set, measurements are considered unit-less.
While inserting a measurement, the last point inserted can be undone by pressing CTRL+Z. Note that in order to delete a single measurement that was already inserted, you should delete its associate segment, which can be obtained by intercepting MeasurementEvent events. Deleting all measurements at once can be easily done through the DeleteAllMeasurements function.
Notes about specific measurement types:<itemizedlist><listitem>
Line Measurements Lines are measured as points are picked. An arbitrary number of points describing a line can be picked. To signal that you are done describing a line, either select the last point inserted, or double click/tap anywhere in the scene The position of the label for Line Measurement can be chosen through the SetLineMeasurementPosition.
</listitem><listitem>
Area Measurements Placing at least three points is required when measuring an area. All points placed should be co-planar. After the third point has been inserted, attempting to insert a point that does not lie on the same plane will result in a warning, and the operator will discard this point. To signal that you are done inserting points for the area measurement, either select the first point inserted, or double click/tap anywhere in the scene.
</listitem><listitem>
Distance Measurements The distance measurement finds the shortest distance between two objects. The two objects in question can be either individual faceted Entities (shells, polygons, meshes, etc…) or Bodies. This setting can be controlled through the SetDistanceMeasurementReference function. When Bodies are selected as the reference, is a CADModel is not associated with this operator, Segments will be used instead. Note that when comparing whole bodies it might take a noticeable amount of time for the operator to complete the calculation.
</listitem></itemizedlist>
Public Types
-
enum
DistanceMeasurementReference Values:
-
Entity When measuring distance, only the specific entity selected will be considered.
-
Body When measuring distance, all faceted entities belonging to the selected body will be considered.
-
-
enum
LineMeasurementPosition Values:
-
LastPoint Measurement text should be at the last selected point.
-
FirstPoint Measurement text should be at the first selected point.
-
MidPoint Measurement text should be at the mid-point of the line.
-
-
enum
MeasurementType Values:
-
PointToPoint Measure the distance between two points.
-
Line Measure the length of a series of lines.
-
Angle Measure the angle between two lines.
-
Area Measure the area of a polygon on a plane.
-
Distance Measure the shortest distance between two objects.
-
-
enum
SelectionHint Values:
-
Snapped If vertex snapping is enabled, hint goemetry is rendered over the closest vertex within the snapping proximity supplied to SetVertexSnapping.
-
Valid Hint goemetry is rendered under the mouse cursor indicating that a valid measurement point could be inserted at the underlying position.
-
Invalid Hint goemetry is rendered under the mouse cursor indicating that no valid measurement point could be inserted at the underlying position.
-
Public Functions
-
void
DeleteAllMeasurements() Deletes all inserted measurements.
-
override void
Dispose()
-
HPS.MeasurementOperator.DistanceMeasurementReference
GetDistanceMeasurementReference() Returns the reference used for distance measurements.
-
HPS.SegmentKey
GetHintSegment(HPS.MeasurementOperator.SelectionHint in_hint) Retrieves the segment key which contains the marker used for a given snapping hint. The appearance of the marker used for each hint type can be altered by modifying the attributes of the returned segment key.
Param in_hint: Indicates the hint type to retrieve the parent segment for. which contains the marker used to indicate the snapping state given the mouse position.
-
HPS.MeasurementOperator.LineMeasurementPosition
GetLineMeasurementPosition() Returns where the line measurement text will be positioned.
-
HPS.MeasurementOperator.MeasurementType
GetMeasurementType() Returns the type of measurement the operator will insert the next time a measurement operation is started
-
override string
GetName() Returns the name of the operator.
-
ulong
GetPrecision() Returns the precision used in the measurement (number of digits after the decimal point)
-
bool
GetSelectionHinting() Whether hint geometry is shown during point selection.
-
void
GetVertexSnapping(out bool out_state, out float out_proximity) Whether to snap to vertices during selection.
-
MeasurementOperator()
-
MeasurementOperator(HPS.MeasurementOperator in_that)
-
MeasurementOperator(HPS.MouseButtons in_mouse_trigger)
-
MeasurementOperator(HPS.MouseButtons in_mouse_trigger, HPS.ModifierKeys in_modifier_trigger)
-
override bool
OnKeyDown(HPS.KeyboardState in_state) This function is called whenever HPS receives a KeyboardState event that signals a button was pressed. This function is used to undo a measurement point when CTRL+Z is pressed
Param in_state: A KeyboardState object describing the current keyboard state. Return: true if the input event was handled, false otherwise.
-
override void
OnModelAttached() This function is called whenever a model is attached to the view that is attached to this operator. If no view is attached to this operator, this function will not be called.
-
override void
OnModelDetached() This function is called whenever a model is detached from the view that is attached to this operator. If no view is attached to this operator, this function will not be called.
-
override bool
OnMouseDown(HPS.MouseState in_state) This function is called whenever HPS receives a MouseEvent that signals a mouse button was pressed. This function starts the operator and records the position of the mouse click
Param in_state: A MouseState object describing the current mouse state. Return: true if the input event was handled, false otherwise.
-
override bool
OnMouseMove(HPS.MouseState in_state) This function is called whenever HPS receives a MouseEvent that signals the mouse moved This function shows a preview of what would be selected, taking into account vertex snapping
Param in_state: A MouseState object describing the current mouse state. Return: true if the input event was handled, false otherwise.
-
override bool
OnMouseUp(HPS.MouseState in_state) This function is called whenever HPS receives a MouseEvent that signals a mouse button was released. If the mouse position was the same as it was when the mouse button was pressed, a measurement point is inserted.
Param in_state: A MouseState object describing the current mouse state. Return: true if the input event was handled, false otherwise.
-
override bool
OnTouchDown(HPS.TouchState in_state) This function is called whenever HPS receives a TouchEvent that signals that the device was touched. This is the touch equivalent of OnMouseDown
Param in_state: A TouchState object describing the current touch state. Return: true if the input event was handled, false otherwise.
-
override bool
OnTouchMove(HPS.TouchState in_state) This function is called whenever HPS receives a TouchEvent that signals that a touch on the device has moved This is the touch equivalent of OnMouseMove
Param in_state: A TouchState object describing the current touch state. Return: true if the input event was handled, false otherwise.
-
override bool
OnTouchUp(HPS.TouchState in_state) This function is called whenever HPS receives a TouchEvent that signals that a touch on the device was released This is the touch equivalent of OnMouseUp
Param in_state: A TouchState object describing the current touch state. Return: true if the input event was handled, false otherwise.
-
override void
OnViewAttached(HPS.View in_attached_view) This function is called whenever a view is attached to this operator.
-
override void
OnViewDetached(HPS.View in_detached_view) This function is called whenever a view is detached from this operator.
-
void
SetDistanceMeasurementReference(HPS.MeasurementOperator.DistanceMeasurementReference in_reference)
-
void
SetLineMeasurementPosition(HPS.MeasurementOperator.LineMeasurementPosition in_position) Sets where to position line measurement text relative to the line.
-
void
SetMeasurementType(HPS.MeasurementOperator.MeasurementType in_measurement_type) Sets the type of measurement to insert. If a measurement of a different type is currently being inserted, that measurement will be deleted.
-
void
SetPrecision(ulong in_precision) Changes the precision used in the measurement (number of digits after the decimal point) The operator might override this setting if increasing the precision is necessary in order not to display the measurement value as all zeros. Example: When precision is set to 2, and a distance measurement of 0.0012 is performed, the operator will display 3 digits after the decimal point (0.001) in order not to display a value of 0. Only affects future measurements.
-
void
SetSelectionHinting(bool in_state) Whether to show hint geometry while moving the mouse over the model during point selection. This function is not available on mobile platforms as it requires hovering over geometry.
Param in_state: Indicates whether to enable or disable visual selection hints.
-
void
SetVertexSnapping(bool in_state) Whether selections should snap to the closest vertex. This behavior is only relevant when selecting shells, meshes, lines, NURBS curves and polygons. If the selection cannot be snapped to a vertex, the measurement will be taken based on the actual selection point.
Param in_state: Indicates whether to enable or disable vertex snapping.
-
void
SetVertexSnapping(bool in_state, float in_proximity) Whether selections should snap to the closest vertex. This behavior is only relevant when selecting shells, meshes, lines, NURBS curves and polygons. If the selection cannot be snapped to a vertex, the measurement will be taken based on the actual selection point.
Param in_state: Indicates whether to enable or disable vertex snapping. Param in_proximity: The distance to which a vertex will snap. The value is specified in centimeters.
-
class
MeasurementEvent: public HPS.Event Public Functions
-
override string
ClassName()
-
override HPS.Event
Clone() Allocates and returns a copy of this MeasurementEvent.
Return: A copy of this MeasurementEvent.
-
override void
Dispose()
-
MeasurementEvent() The default constructor creates an empty MeasurementEvent object.
-
MeasurementEvent(HPS.Event in_event) This constructor converts an Event Object to a MeasurementEvent object.
Param in_event: The Event Object to be converted.
-
MeasurementEvent(HPS.MeasurementOperator.MeasurementEvent in_that)
-
MeasurementEvent(HPS.View in_view, HPS.SegmentKey in_segment_key, HPS.MeasurementOperator.MeasurementType in_measurement_type, float in_measurement_value)
Properties
-
HPS.MeasurementOperator.MeasurementType
measurement_type{ get; set; }
-
float
measurement_value{ get; set; }
-
HPS.SegmentKey
segment_key{ get; set; }
-
override string
-
enum