#include <sprk_ops.h>

Classes | |
class | MeasurementEvent |
Public Types | |
enum | DistanceMeasurementReference { DistanceMeasurementReference::Entity, DistanceMeasurementReference::Body } |
enum | LineMeasurementPosition { LineMeasurementPosition::LastPoint, LineMeasurementPosition::FirstPoint, LineMeasurementPosition::MidPoint } |
enum | MeasurementType { MeasurementType::PointToPoint, MeasurementType::Line, MeasurementType::Angle, MeasurementType::Area, MeasurementType::Distance } |
enum | SelectionHint { SelectionHint::Snapped, SelectionHint::Valid, SelectionHint::Invalid } |
![]() | |
enum | Priority { Low, Default, High } |
Public Member Functions | |
void | DeleteAllMeasurements () |
DistanceMeasurementReference | GetDistanceMeasurementReference () const |
SegmentKey | GetHintSegment (SelectionHint in_hint) |
LineMeasurementPosition | GetLineMeasurementPosition () const |
MeasurementType | GetMeasurementType () const |
virtual HPS::UTF8 | GetName () const override |
size_t | GetPrecision () const |
bool | GetSelectionHinting () |
void | GetVertexSnapping (bool &out_state, float &out_proximity) const |
MeasurementOperator (MouseButtons in_mouse_trigger=MouseButtons::ButtonLeft(), ModifierKeys in_modifier_trigger=ModifierKeys()) | |
virtual bool | OnKeyDown (KeyboardState const &in_state) override |
virtual void | OnModelAttached () override |
virtual void | OnModelDetached () override |
virtual bool | OnMouseDown (MouseState const &in_state) override |
virtual bool | OnMouseMove (MouseState const &in_state) override |
virtual bool | OnMouseUp (MouseState const &in_state) override |
virtual bool | OnTouchDown (TouchState const &in_state) override |
virtual bool | OnTouchMove (TouchState const &in_state) override |
virtual bool | OnTouchUp (TouchState const &in_state) override |
virtual void | OnViewAttached (HPS::View const &in_attached_view) override |
virtual void | OnViewDetached (HPS::View const &in_detached_view) override |
void | SetDistanceMeasurementReference (DistanceMeasurementReference in_reference) |
void | SetLineMeasurementPosition (LineMeasurementPosition in_position) |
void | SetMeasurementType (MeasurementType in_measurement_type) |
void | SetPrecision (size_t in_precision) |
void | SetSelectionHinting (bool in_state) |
void | SetVertexSnapping (bool in_state, float in_proximity=0.0f) |
![]() | |
virtual void | Assign (Operator const &in_that) |
void | DetachView () |
virtual bool | Equals (Operator const &in_that) const |
View | GetAttachedView () const |
ModifierKeys | GetModifierTrigger () const |
MouseButtons | GetMouseTrigger () const |
virtual bool | IsMouseTriggered (MouseState const &in_state) |
HPS::Type | ObjectType () const |
virtual bool | OnKeyUp (KeyboardState const &in_state) |
virtual bool | OnMouseEnter (MouseState const &in_state) |
virtual bool | OnMouseLeave (MouseState const &in_state) |
virtual bool | OnMouseWheel (MouseState const &in_state) |
virtual bool | OnTextInput (HPS::UTF8 const &in_text) |
virtual bool | OnTimerTick (HPS::TimerTickEvent const &in_event) |
Operator (MouseButtons in_mouse_trigger=MouseButtons::ButtonLeft(), ModifierKeys in_modifier_trigger=ModifierKeys()) | |
Operator (Operator const &in_that) | |
virtual bool | operator!= (Operator const &in_that) const |
virtual Operator & | operator= (Operator const &in_that) |
virtual bool | operator== (Operator const &in_that) const |
void | SetModifierTrigger (ModifierKeys in_modifiers) |
void | SetMouseTrigger (MouseButtons in_buttons) |
![]() | |
Sprocket (Sprocket &&in_that) | |
![]() | |
virtual bool | Empty () const |
intptr_t | GetClassID () const |
intptr_t | GetInstanceID () const |
bool | HasType (HPS::Type in_mask) const |
Object (Object const &that) | |
Object (Object &&in_that) | |
Object & | operator= (Object const &other_object) |
Object & | operator= (Object &&in_that) |
virtual void | Reset () |
virtual HPS::Type | Type () const |
Additional Inherited Members | |
![]() | |
template<typename T > | |
static intptr_t | ClassID () |
![]() | |
static const HPS::Type | staticType = HPS::Type::Operator |
![]() | |
static const HPS::Type | staticType = HPS::Type::None |
![]() | |
HPS::ModifierKeys | modifier_trigger |
HPS::MouseButtons | mouse_trigger |
Detailed Description
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:
- 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.
- 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.
- 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.
Member Enumeration Documentation
◆ DistanceMeasurementReference
◆ LineMeasurementPosition
◆ MeasurementType
|
strong |
◆ SelectionHint
|
strong |
Member Function Documentation
◆ DeleteAllMeasurements()
void HPS::MeasurementOperator::DeleteAllMeasurements | ( | ) |
Deletes all inserted measurements.
◆ GetDistanceMeasurementReference()
|
inline |
Returns the reference used for distance measurements.
◆ GetHintSegment()
SegmentKey HPS::MeasurementOperator::GetHintSegment | ( | 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.
- Parameters
-
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.
◆ GetLineMeasurementPosition()
|
inline |
Returns where the line measurement text will be positioned.
◆ GetMeasurementType()
|
inline |
Returns the type of measurement the operator will insert the next time a measurement operation is started
◆ GetName()
|
inlineoverridevirtual |
Returns the name of the operator.
Reimplemented from HPS::Operator.
◆ GetPrecision()
size_t HPS::MeasurementOperator::GetPrecision | ( | ) | const |
Returns the precision used in the measurement (number of digits after the decimal point)
◆ GetSelectionHinting()
bool HPS::MeasurementOperator::GetSelectionHinting | ( | ) |
Whether hint geometry is shown during point selection.
◆ GetVertexSnapping()
void HPS::MeasurementOperator::GetVertexSnapping | ( | bool & | out_state, |
float & | out_proximity | ||
) | const |
Whether to snap to vertices during selection.
◆ OnKeyDown()
|
overridevirtual |
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
- Parameters
-
in_state A KeyboardState object describing the current keyboard state.
- Returns
- true if the input event was handled, false otherwise.
Reimplemented from HPS::Operator.
◆ OnModelAttached()
|
overridevirtual |
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.
Reimplemented from HPS::Operator.
◆ OnModelDetached()
|
overridevirtual |
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.
Reimplemented from HPS::Operator.
◆ OnMouseDown()
|
overridevirtual |
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
- Parameters
-
in_state A MouseState object describing the current mouse state.
- Returns
- true if the input event was handled, false otherwise.
Reimplemented from HPS::Operator.
◆ OnMouseMove()
|
overridevirtual |
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
- Parameters
-
in_state A MouseState object describing the current mouse state.
- Returns
- true if the input event was handled, false otherwise.
Reimplemented from HPS::Operator.
◆ OnMouseUp()
|
overridevirtual |
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.
- Parameters
-
in_state A MouseState object describing the current mouse state.
- Returns
- true if the input event was handled, false otherwise.
Reimplemented from HPS::Operator.
◆ OnTouchDown()
|
overridevirtual |
This function is called whenever HPS receives a TouchEvent that signals that the device was touched. This is the touch equivalent of OnMouseDown
- Parameters
-
in_state A TouchState object describing the current touch state.
- Returns
- true if the input event was handled, false otherwise.
Reimplemented from HPS::Operator.
◆ OnTouchMove()
|
overridevirtual |
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
- Parameters
-
in_state A TouchState object describing the current touch state.
- Returns
- true if the input event was handled, false otherwise.
Reimplemented from HPS::Operator.
◆ OnTouchUp()
|
overridevirtual |
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
- Parameters
-
in_state A TouchState object describing the current touch state.
- Returns
- true if the input event was handled, false otherwise.
Reimplemented from HPS::Operator.
◆ OnViewAttached()
|
overridevirtual |
This function is called whenever a view is attached to this operator.
Reimplemented from HPS::Operator.
◆ OnViewDetached()
|
overridevirtual |
This function is called whenever a view is detached from this operator.
Reimplemented from HPS::Operator.
◆ SetLineMeasurementPosition()
|
inline |
Sets where to position line measurement text relative to the line.
◆ SetMeasurementType()
void HPS::MeasurementOperator::SetMeasurementType | ( | 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.
◆ SetPrecision()
void HPS::MeasurementOperator::SetPrecision | ( | size_t | 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.
◆ SetSelectionHinting()
void HPS::MeasurementOperator::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.
- Parameters
-
in_state Indicates whether to enable or disable visual selection hints.
◆ SetVertexSnapping()
void HPS::MeasurementOperator::SetVertexSnapping | ( | bool | in_state, |
float | in_proximity = 0.0f |
||
) |
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.
- Parameters
-
in_state Indicates whether to enable or disable vertex snapping. in_proximity The distance to which a vertex will snap. The value is specified in centimeters.
The documentation for this class was generated from the following file:
- include/sprk_ops.h