I want that when I click on a point on the screen, the item containing that point will be highlighted. Then, I would like to maintain the highlight state while still being able to perform panOrbit actions.
My idea is to customize the class MyCustomOperator_s1 : public HPS::PanOrbitZoomOperator.
Then, when touchDown → get point → get item with the selected point → set highlight item.
Please let me know if I’m on the right track. Currently, I am pursuing this direction but have not found the function to convert the point into an item. @simon
bool OnTouchDown(HPS::TouchState const& in_state)
{
doubleTap_test_count++;
HPS::TouchArray touches = in_state.GetTouches();
if (doubleTap_test_count == 1)
{
// get location in window space for first touch object
HPS::Touch touch = touches.at(0);
HPS::WindowPoint windowPoint = touch.Location;
//Setup a start a timer
firstPoint = windowPoint;
// Get touch object
HPS::SelectionResults new_selection;
HPS::SelectionOptionsKit selection_options;
selection_options.SetRelatedLimit(0).SetLevel(HPS::Selection::Level::Entity);
}
// Please also check for the time difference between the first and second touch event
if (doubleTap_test_count == 2 ) // and the
{
// check timer - If timer is less then 0.5 seconds, then doubleTap event is trigger
// Check position - Check the position of the first touch event and compare it to lastest position
// They should be close
// if ()
//Double tap event
printf("");
// Select and highlight option
}
// Test to see if OnTouchDown is triggered.
// canvas.GetFrontView().GetAttachedModel().GetSegmentKey().GetVisibilityControl().SetEdges(true);
// canvas.UpdateWithNotifier().Wait();
// PanOrbitZoomOperator need to record the first touch position for reference.
HPS::PanOrbitZoomOperator::OnTouchDown(in_state);
return true;
}
Your customize operator should derived from HPS::HighlightOperator. In both OnTouchDown and OnTouchUp method, you need to call “return false” which tell HOOSP to not consume the event and pass it to the next operator (PanOrbitZoom).
Hi @simon
Thank you for your suggestion. I have successfully implemented highlight, pan, and zoom functionality.
However, I would now like to add a zoom fit feature triggered by a double click (double tap). The issue I am encountering is that the ZoomFitTouchOperator does not receive the touch events because the HighlightOperator handles (consumes) them first.
Is there any recommended approach or solution to resolve this issue?
You should create a custom operator that derived from HPS::ZoomFitTouchOperator. This way you can control if you want to consume the event or pass it on to the next operator.
It should look something like this:
I believe you want the ZoomFitTouchOperator on top of the stack. Your first touch could be under a geometry, so you will need to call “return true” to pass the event to the HighlightOperator. If your first touch did not select anything, then you still have to pass the event on a potential PanZoomOrbit( swipe/move) event.