How to highlight object by point using custom operator (HPS::PanOrbitZoomOperator)

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;

    }

This behavior is available through typical selection and highlighting.

Is there some reason this doesn’t meet your needs?

@phu_bn

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).

Here is sample code:

class MyCustomOperator :  public HPS::HighlightOperator
{
public:
    MyCustomOperator(HPS::Canvas c) : canvas(c) {
        

    }
    bool OnTouchDown(HPS::TouchState const& in_state)
    {

        HPS::HighlightOperator::OnTouchDown(in_state);
        canvas.UpdateWithNotifier().Wait();
        return false;
    }

    bool OnTouchMove(HPS::TouchState const& in_state)
    {

        return false;
    }

    bool OnTouchUp(HPS::TouchState const& in_state) {

        HPS::HighlightOperator::OnTouchUp(in_state);
        return false;
    }



private:
    HPS::Canvas canvas;
    
};

Your operator’s call stack should look like this:

// TODO: Add your command handler code here
dprintf("user code 3\n");


auto *cus = new MyCustomOperator(GetCanvas());
auto view = GetCanvas().GetFrontView();
view.GetOperatorControl().Pop();
view.GetOperatorControl().Pop();

view.GetOperatorControl().Push(new HPS::PanOrbitZoomOperator());
view.GetOperatorControl().Push(cus, HPS::Operator::Priority::Default);