//! press button to start, move mouse to define rectangle, release to finish
AIS_MouseGesture_SelectLasso, //!< polygonal selection;
//! press button to start, move mouse to define polygonal path, release to finish
+ AIS_MouseGesture_SelectPolygonal, //!< polygonal selection;
+ //! press buttons to define the vertices of the polygon, click on the first vertex or Esc to finish
//
AIS_MouseGesture_Zoom, //!< view zoom gesture;
//! move mouse left to zoom-out, and to the right to zoom-in
const Handle(AIS_InteractiveContext)& theCtx)
: myCtx (theCtx),
myView (theView),
- myToPickPnt (Standard_False)
+ myToPickPnt (Standard_False),
+ myToSelectPolygon (Standard_False)
{
myViewAnimation = GlobalViewAnimation();
}
}
}
+//=======================================================================
+//function : PolygonalSelection
+//purpose :
+//=======================================================================
+void ViewerTest_EventManager::SelectPolygon()
+{
+ ActivatePolygonalSelection();
+ myToSelectPolygon = Standard_True;
+}
+
+
//=======================================================================
//function : UpdateMouseButtons
//purpose :
//=======================================================================
-bool ViewerTest_EventManager::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
- Aspect_VKeyMouse theButtons,
- Aspect_VKeyFlags theModifiers,
- bool theIsEmulated)
+bool ViewerTest_EventManager::UpdateMouseButtons(const Graphic3d_Vec2i& thePoint,
+ Aspect_VKeyMouse theButtons,
+ Aspect_VKeyFlags theModifiers,
+ bool theIsEmulated)
{
- SetAllowRotation (!ViewerTest_V3dView::IsCurrentViewIn2DMode());
+ SetAllowRotation(!ViewerTest_V3dView::IsCurrentViewIn2DMode());
if (theButtons == Aspect_VKeyMouse_LeftButton)
{
if (myToPickPnt && (theModifiers & Aspect_VKeyFlags_CTRL) != 0)
{
Graphic3d_Vec3d anXYZ;
- myView->Convert (thePoint.x(), thePoint.y(), anXYZ.x(), anXYZ.y(), anXYZ.z());
- Draw::Set (myPickPntArgVec[0].ToCString(), anXYZ.x());
- Draw::Set (myPickPntArgVec[1].ToCString(), anXYZ.y());
- Draw::Set (myPickPntArgVec[2].ToCString(), anXYZ.z());
+ myView->Convert(thePoint.x(), thePoint.y(), anXYZ.x(), anXYZ.y(), anXYZ.z());
+ Draw::Set(myPickPntArgVec[0].ToCString(), anXYZ.x());
+ Draw::Set(myPickPntArgVec[1].ToCString(), anXYZ.y());
+ Draw::Set(myPickPntArgVec[2].ToCString(), anXYZ.z());
myToPickPnt = false;
}
}
+ if (myToSelectPolygon)
+ {
+ if ((theButtons & Aspect_VKeyMouse_LeftButton) == Aspect_VKeyMouse_LeftButton)
+ {
+ if (!myUI.Selection.Points.IsEmpty())
+ {
+ if (myUI.Selection.Points.First() == thePoint)
+ {
+ myUI.Selection.ToApplyTool = true;
+ myToSelectPolygon = Standard_False;
+ }
+ }
+ UpdatePolySelection(thePoint, true);
+ FlushViewEvents(myCtx, myView, true);
+ return true;
+ }
+ else if (((theButtons & Aspect_VKeyMouse_RightButton) == Aspect_VKeyMouse_RightButton)
+ && (!myUI.Selection.Points.IsEmpty()))
+ {
+ myUI.Selection.Points.Remove(myUI.Selection.Points.Size());
+ }
+ }
return AIS_ViewController::UpdateMouseButtons (thePoint, theButtons, theModifiers, theIsEmulated);
}
{
Draw_Interprete (ViewerTest_EventManager::ToExitOnCloseView() ? "exit" : "vclose");
}
+ if (myToSelectPolygon)
+ {
+ myToSelectPolygon = false;
+ myUI.Selection.Points.Clear();
+ myView->Redraw();
+ myView->Invalidate();
+ }
}
}
}
NCollection_Sequence<Graphic3d_Vec2i> aPnts;
- bool isShiftSelection = false, toAllowOverlap = false;
+ bool isShiftSelection = false, toAllowOverlap = false, toSelectPolygon = false;
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
{
TCollection_AsciiString anArg (theArgVec[anArgIter]);
++anArgIter;
}
}
+ else if (anArg == "-polygonal")
+ {
+ std::cout << "Polygonal Selection is activated" << std::endl;
+ toSelectPolygon = true;
+ }
else if (anArgIter + 1 < theNbArgs
&& anArg.IsIntegerValue()
&& TCollection_AsciiString (theArgVec[anArgIter + 1]).IsIntegerValue())
}
Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
+ if (toSelectPolygon)
+ {
+ aCurrentEventManager->SelectPolygon();
+ }
if (aPnts.IsEmpty())
{
if (isShiftSelection)