2 ways box selection with feedack

Using AIS_InteractiveContext & V3d_View, i would like to be able to do 2 types of box selection (right/left): one includes all elements touching the selection square, and the other selects whats completely insde the selection square. On top of it, i would love to have feedback (highligt/detection) over this box movement to help the user understand what is he selecting.

Is there an already implemented way of doing so? Else i will very much appreciate some pointers on how to be able to develop this.

gkv311 n's picture

There is a property SelectMgr_ViewerSelector::AllowOverlapDetection() that switched between these two modes. AIS_ViewController setup this flag based on the rubberband rectangle direction - from left to right or from right to left. There is no visual feedback indicating within mode is active, though.

Dario Dura Armadans's picture

Great info thanks!

I tried this (based on the CSharp_D3D project and your reccommendation):

	void OCCTProxyD3D::MoveTo(int theX1, int theY1, int theX2, int theY2)
	{
		if (theX1 < theX2)
			myAISContext()->SelectionManager()->Selector()->AllowOverlapDetection(Standard_True);
		else
			myAISContext()->SelectionManager()->Selector()->AllowOverlapDetection(Standard_False);

		myAISContext()->SelectionManager()->Selector()->Pick(theX1, theY1, theX2, theY2, myView());
		myAISContext()->UpdateCurrentViewer();
	}

To kindof simulate a box MoveTo behaviour to hilight items while im dragging the selection box, but it does not hilight or select anything... i guess i am missing something plus i am unsure if pick will work as hilight or select (apparently none).

How could i achieve the effect i am describing?

gkv311 n's picture

Highlighting is handled by AIS_InteractiveContext, not SelectMgr_ViewerSelector. You need to call something like AIS_InteractiveContext::SelectRectangle() instead of SelectMgr_ViewerSelector::Pick() (AIS_InteractiveContext will call Pick() internally).

Dario Dura Armadans's picture

Oh, i see now! Thanks!

As a clarification, i want to do Highlight of the detected elements, not drawing the box (that i do with a 2d canvas rectangle), attach a vid example of this behaviour done in SpaceClaim.

Checking the code of AIS_InteractiveContext for MoveTo i came with this:

AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer  theXPMin,
                                                     const Standard_Integer  theYPMin,
                                                     const Standard_Integer  theXPMax,
                                                     const Standard_Integer  theYPMax,
                                                     const Handle(V3d_View)& theView,
                                                     const Standard_Boolean  theToRedrawOnUpdate)
{
  if (theView->Viewer() != myMainVwr)
  {
    throw Standard_ProgramError("AIS_InteractiveContext::MoveTo() - invalid argument");
  }
  MainSelector()->Pick(theXPMin, theYPMin, theXPMax, theYPMax, theView);
  return moveTo(theView, theToRedrawOnUpdate);
}

But seeing how moveTo works, i see that AIS_InteractiveContext is only prepared to have one picked element at a time and not several, right?

I will try to extend it to be able to handle several picked elements (and probably secondary selection).

As well, how to display c++ code in this forum? [CODE] dont show c++

And one more question, is there a way to display hidden lines (surface edges without depth test) in picking(highlight) and selection?