HPS::Exchange::MeasurementOperator

class HPS::Exchange::MeasurementOperator : public HPS::Exchange::CommonMeasurementOperator

The MeasurementOperator class defines an operator which allows the user to insert measurements into the scene This operator requires the model be loaded using the Exchange bridge, and the model must contain B-rep.

The behavior of the operator, and its usage, vary based on the type of measurement the user wishes to insert.

  • Point to Point measurement: The Point to Point measurement mode allows the user to measure the distance between two arbitrary points. Usage:

  • Click or tap where you want to insert the first measurement point.

  • Click or tap where you want to insert the second measurement point

  • Move the mouse or drag your finger to move the measurement geometry around.

  • Click or lift your finger to position the measurement.

  • Edge and Radius measurement: The Edge and Radius measurement mode allows the user to measure the length of an edge, or the radius of a circle, based on whether the edge clicked on is a line or a circle. Usage:

  • Click or tap on the edge you want to measure

  • Move the mouse or drag your finger to move the measurement geometry around.

  • Click again or lift your finger to position the measurement.

  • If the edge you selected is part of a circle, the circle radius will be measured, otherwise the edge length will be measured.

  • Feature to Feature measurement: The Feature to Feature measurement mode allows the user to measure the shortest distance between two features. Usage:

  • Click or tap on a face

  • Click or tap on a different face

  • Move the mouse or drag your finger to move the measurement geometry around.

  • Click again or lift your finger to position the measurement.

  • If both faces are planar, the shortest distance between them is measured

  • If one face is planar and the other is id conical or cylindrical, the shortest distance between the center line and the face is measured

  • If both faces are conical or cylindrical, the shortest distance between the two center lines is measured

  • Face Angle measurement: The Face Angle measurement mode allows the user to measure the angle between two planar, non-parallel faces. Usage:

  • Click or tap on a face

  • Click or tap on a different face, which is not parallel to the first face

  • Move the mouse or drag your finger to move the measurement geometry around.

  • Click again or lift your finger to position the measurement.

Once a measurement has been inserted, its position can be modified by clicking on it, moving the mouse, and clicking once more once it is in the desired position. On touch-enabled devices measurements can be repositioned by dragging them into a new position. Pressing Escape will delete the measurement currently being inserted.

The operator will inject an Event of type MeasurementInsertedEvent every time a new measurement is inserted. The user can handle this event to obtain the segment key associated with every inserted measurement.

A valid CADModel needs to be passed to the constructor of this class.

Public Types

enum MeasurementType

Values:

enumerator PointToPoint
enumerator EdgeAndRadius
enumerator FeatureToFeature
enumerator FaceAngle

Public Functions

void ComputeExchangeScale(HPS::Exchange::Component const &in_edge_component, double &out_product_occurrence_scale, double &out_ri_scale, double &out_context_scale)

Compute the accumulated scales applied on the product occurrences, on the representation items, and on the context, until the given edge. The scales are set to 1 by default.

Parameters
  • in_edge_component – The edge on which the scales are retrieved.

  • out_product_occurrence_scale – The accumulated scale on the product occurrences.

  • out_ri_scale – The scale on the representation item.

  • out_context_scale – The context scale.

void DeleteLastMeasurement()

Delete the current measurement and brings the operator back to a state to start a new measurement

HighlightOptionsKit GetHighlightOptions()

Returns the highlight option kit currently used for mouse over highlighting.

Returns

the highlight option kit currently used for mouse over highlighting.

MeasurementType GetMeasurementType()

Returns the type of measurement the operator is currently set up to insert.

Returns

The type of measurement the operator is currently set up to insert.

bool GetMouseOverHighlighting()

Whether measurable geometry is highlighted when mousing over it

Returns

true if measurable geometry is highlighted on mouse over, false otherwise.

inline virtual HPS::UTF8 GetName() const override

Returns the name of the operator.

bool IsMeasurementActive()

Whether a measurement is currently being inserted or edited.

Returns

true if a measurement is being inserted or manipulated, false otherwise.

MeasurementOperator()
MeasurementOperator(Exchange::CADModel const &in_cad_model, MouseButtons in_mouse_trigger = MouseButtons::ButtonLeft(), ModifierKeys in_modifier_trigger = ModifierKeys())
virtual bool OnKeyDown(KeyboardState const &in_state) override

This function is called whenever HPS receives a KeyDownEvent that signals a key was pressed. Pressing Escape while in the process of inserting a measurement deletes that measurement.

Returns

true if the input event was handled, false otherwise.

virtual bool OnMouseDown(MouseState const &in_state) override

This function is called whenever HPS receives a MouseEvent that signals a mouse button was pressed. This function inserts the measuring points.

Parameters

in_state – A MouseState object describing the current mouse state.

Returns

true if the input event was handled, false otherwise.

virtual bool OnMouseMove(MouseState const &in_state) override

This function is called whenever HPS receives a MouseEvent that signals the mouse moved When the user has just inserted the second measurement point, this function allows the user to move the measurement If the user has selected an already existing measurement, this function allows the user to reposition the measurement

Parameters

in_state – A MouseState object describing the current mouse state.

Returns

true if the input event was handled, false otherwise.

virtual bool OnMouseUp(MouseState const &in_state) override

This function is called whenever HPS receives a MouseEvent that signals a mouse button was released.

Parameters

in_state – A MouseState object describing the current mouse state.

Returns

true if the input event was handled, false otherwise.

virtual bool OnTouchDown(TouchState const &in_state) override

This function is called whenever HPS receives a TouchEvent that signals the device was touched. This function inserts the measuring points.

Parameters

in_state – A TouchState object describing the current touch state.

Returns

true if the input event was handled, false otherwise.

virtual bool OnTouchMove(TouchState const &in_state) override

This function is called whenever HPS receives a TouchEvent that signals a point of contact has moved. When the user has just inserted the second measurement point, this function allows the user to move the measurement If the user has selected an already existing measurement, this function allows the user to reposition the measurement

Parameters

in_state – A TouchState object describing the current touch state.

Returns

true if the input event was handled, false otherwise.

virtual bool OnTouchUp(TouchState const &in_state) override

This function is called whenever HPS receives a TouchEvent that signals a point of contact has been released.

Parameters

in_state – A TouchState object describing the current touch state.

Returns

true if the input event was handled, false otherwise.

virtual void OnViewAttached(HPS::View const &in_attached_view) override

This function is called whenever a view is attached to this operator.

Parameters

in_attached_view – The view attached to this operator.

virtual void OnViewDetached(HPS::View const &in_detached_view) override

This function is called whenever a view is detached from this operator.

Parameters

in_detached_view – The view detached from this operator.

void SetMeasurementType(MeasurementType in_measurement_type)

Sets the type of measurement to insert.

Parameters

in_measurement_type – The type of measurement to insert.

void SetMouseOverHighlighting(bool in_highlighting)

Whether measurable geometry should be highlighted when mousing over it

Parameters

in_highlighting – Whether measurable geometry should be highlighted when mousing over it.

void SetMouseOverHighlighting(bool in_highlighting, HighlightOptionsKit const &in_highlight_options_kit)

Whether measurable geometry should be highlighted when mousing over it

Parameters
  • in_highlighting – Whether measurable geometry should be highlighted when mousing over it.

  • in_highlight_options_kit – The highlight kit used for mouse over highlights