ShiftSelect() with a rectangle: how is supposed to work?

In the description of the method AIS_InteractiveContext::ShiftSelect() it's said: "Rectangle of selection; adds new detected entities into the picked list, removes the detected entities that were already stored."

In my application this method is called from mouse movement event handler. However, because of such behavior, at every new event processing all previously contained subjects get removed from the selection and new ones are included. The next call makes inverse, and so on. I am judging of this by the look of the selection highlight: when the selection rectangle moves, selection starts flashing, and finishing the movement selects random objects, which were under the rectangle.

The question is: is it supposed to be like that? I have compared my code with the examples (MFC), no differences have been noticed. Wouldn't it have been wiser to choose whether to include or exclude new/old objects during a single rectangle shift-selection?

 

No source code is attached, since it's just a single call to ShiftSelect().

Kirill Gavrilov's picture

The described behavior matches documentation:

  //! Stores and hilights the previous detected; Unhilights the previous picked.
  //! @sa MoveTo().
  Standard_EXPORT AIS_StatusOfPick Select (const Standard_Boolean theToUpdateViewer);

  //! Adds the last detected to the list of previous picked.
  //! If the last detected was already declared as picked, removes it from the Picked List.
  //! @sa MoveTo().
  Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Boolean theToUpdateViewer);

so that:

  • Method AIS_InteractiveContext::Select() implements REPLACE logic (clears previous selection + adds newly detected);
  • AIS_InteractiveContext::ShiftSelect() implements XOR logic (adds not previously selected and removes previously selected).

Application might also look for two other options, not covered by existing Select()/ShiftSelect() methods:

  • REMOVE logic, removing detected entities from previous selection list (and ignoring unselected);
  • ADD logic, adding detected entities to precious selection list (and ignoring already selected).

All these options can be implemented at application level using existing API, by processing picking results and managing selection list independently.
It might be also reasonable extending AIS_InteractiveContext to support the whole set - contributions are welcome:
https://dev.opencascade.org/index.php?q=home/get_involved