Added AIS_ViewController::MouseSelectionSchemes() property defining map of selection schemes for mouse+modifier combinations.
IsXOR flag has been replaced by AIS_SelectionScheme in interfaces.
Rubber-band selection with Shift key pressed now applies XOR selection scheme in in Draw Harness.
Command vselect has been extended to specify selection scheme by name.
#ifndef _AIS_MouseGesture_HeaderFile
#define _AIS_MouseGesture_HeaderFile
+#include <AIS_SelectionScheme.hxx>
#include <NCollection_DataMap.hxx>
//! Mouse gesture - only one can be active at one moment.
//! Map defining mouse gestures.
typedef NCollection_DataMap<unsigned int, AIS_MouseGesture> AIS_MouseGestureMap;
+typedef NCollection_DataMap<unsigned int, AIS_SelectionScheme> AIS_MouseSelectionSchemeMap;
#endif // _AIS_MouseGesture_HeaderFile
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton | Aspect_VKeyFlags_CTRL, AIS_MouseGesture_Zoom);
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton | Aspect_VKeyFlags_SHIFT, AIS_MouseGesture_Pan);
myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton | Aspect_VKeyFlags_ALT, AIS_MouseGesture_SelectRectangle);
+ myMouseGestureMap.Bind (Aspect_VKeyMouse_LeftButton | Aspect_VKeyFlags_ALT | Aspect_VKeyFlags_SHIFT, AIS_MouseGesture_SelectRectangle);
+
+ myMouseSelectionSchemes.Bind (Aspect_VKeyMouse_LeftButton, AIS_SelectionScheme_Replace);
+ myMouseSelectionSchemes.Bind (Aspect_VKeyMouse_LeftButton | Aspect_VKeyFlags_ALT, AIS_SelectionScheme_Replace);
+ myMouseSelectionSchemes.Bind (Aspect_VKeyMouse_LeftButton | Aspect_VKeyFlags_SHIFT, AIS_SelectionScheme_XOR);
+ myMouseSelectionSchemes.Bind (Aspect_VKeyMouse_LeftButton | Aspect_VKeyFlags_ALT | Aspect_VKeyFlags_SHIFT, AIS_SelectionScheme_XOR);
myMouseGestureMap.Bind (Aspect_VKeyMouse_RightButton, AIS_MouseGesture_Zoom);
myMouseGestureMap.Bind (Aspect_VKeyMouse_RightButton | Aspect_VKeyFlags_CTRL, AIS_MouseGesture_RotateOrbit);
{
myGL.Selection.Tool = myUI.Selection.Tool;
- myGL.Selection.IsXOR = myUI.Selection.IsXOR;
+ myGL.Selection.Scheme = myUI.Selection.Scheme;
myGL.Selection.Points = myUI.Selection.Points;
- myUI.Selection.IsXOR = false;
+ //myGL.Selection.Scheme = AIS_SelectionScheme_UNKNOWN; // no need
if (myUI.Selection.Tool == AIS_ViewSelectionTool_Picking)
{
myUI.Selection.Points.Clear();
// purpose :
// =======================================================================
void AIS_ViewController::SelectInViewer (const Graphic3d_Vec2i& thePnt,
- const bool theIsXOR)
+ const AIS_SelectionScheme theScheme)
{
if (myUI.Selection.Tool != AIS_ViewSelectionTool_Picking)
{
myUI.Selection.Points.Clear();
}
- myUI.Selection.IsXOR = theIsXOR;
+ myUI.Selection.Scheme = theScheme;
myUI.Selection.Points.Append (thePnt);
}
// purpose :
// =======================================================================
void AIS_ViewController::SelectInViewer (const NCollection_Sequence<Graphic3d_Vec2i>& thePnts,
- const bool theIsXOR)
+ const AIS_SelectionScheme theScheme)
{
- myUI.Selection.IsXOR = theIsXOR;
+ myUI.Selection.Scheme = theScheme;
myUI.Selection.Points = thePnts;
myUI.Selection.ToApplyTool = true;
if (thePnts.Length() == 1)
// purpose :
// =======================================================================
void AIS_ViewController::UpdateRubberBand (const Graphic3d_Vec2i& thePntFrom,
- const Graphic3d_Vec2i& thePntTo,
- const bool theIsXOR)
+ const Graphic3d_Vec2i& thePntTo)
{
myUI.Selection.Tool = AIS_ViewSelectionTool_RubberBand;
- myUI.Selection.IsXOR = theIsXOR;
myUI.Selection.Points.Clear();
myUI.Selection.Points.Append (thePntFrom);
myUI.Selection.Points.Append (thePntTo);
bool theIsDoubleClick)
{
(void )theIsDoubleClick;
- if (theButton == Aspect_VKeyMouse_LeftButton)
+ AIS_SelectionScheme aScheme = AIS_SelectionScheme_UNKNOWN;
+ if (myMouseSelectionSchemes.Find (theButton | theModifiers, aScheme))
{
- SelectInViewer (thePoint, (theModifiers & Aspect_VKeyFlags_SHIFT) != 0);
+ SelectInViewer (thePoint, aScheme);
return true;
}
return false;
}
const AIS_MouseGesture aPrevGesture = myMouseActiveGesture;
+ const Aspect_VKeyMouse aPrevButtons = myMousePressed;
+ const Aspect_VKeyFlags aPrevModifiers = myMouseModifiers;
myMouseModifiers = theModifiers;
myMousePressed = theButtons;
if (theIsEmulated
|| aPrevGesture == AIS_MouseGesture_ZoomWindow)
{
myUI.Selection.ToApplyTool = true;
+ myUI.Selection.Scheme = AIS_SelectionScheme_Replace;
+ myMouseSelectionSchemes.Find (aPrevButtons | aPrevModifiers, myUI.Selection.Scheme);
}
myUI.IsNewGesture = true;
toUpdateView = true;
}
+
return toUpdateView;
}
ResetPreviousMoveTo();
}
- theCtx->SelectDetected (myGL.Selection.IsXOR ? AIS_SelectionScheme_XOR : AIS_SelectionScheme_Replace);
+ theCtx->SelectDetected (myGL.Selection.Scheme);
// selection affects all Views
theView->Viewer()->Invalidate();
theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y()));
theCtx->SelectRectangle (Graphic3d_Vec2i (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y())),
Graphic3d_Vec2i (Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y())),
- theView,
- myGL.Selection.IsXOR ? AIS_SelectionScheme_XOR : AIS_SelectionScheme_Replace);
+ theView,
+ myGL.Selection.Scheme);
theCtx->MainSelector()->AllowOverlapDetection (false);
}
}
aPolyIter.ChangeValue() = gp_Pnt2d (aNewPnt.x(), -aNewPnt.y());
}
- theCtx->SelectPolygon (aPolyline, theView,
- myGL.Selection.IsXOR ? AIS_SelectionScheme_XOR : AIS_SelectionScheme_Replace);
+ theCtx->SelectPolygon (aPolyline, theView, myGL.Selection.Scheme);
theCtx->MainSelector()->AllowOverlapDetection (false);
}
}
//! Return map defining mouse gestures.
AIS_MouseGestureMap& ChangeMouseGestureMap() { return myMouseGestureMap; }
+ //! Return map defining mouse selection schemes.
+ const AIS_MouseSelectionSchemeMap& MouseSelectionSchemes() const { return myMouseSelectionSchemes; }
+
+ //! Return map defining mouse gestures.
+ AIS_MouseSelectionSchemeMap& ChangeMouseSelectionSchemes() { return myMouseSelectionSchemes; }
+
//! Return double click interval in seconds; 0.4 by default.
double MouseDoubleClickInterval() const { return myMouseDoubleClickInt; }
//! Perform selection in 3D viewer.
//! This method is expected to be called from UI thread.
//! @param thePnt picking point
- //! @param theIsXOR XOR selection flag
+ //! @param theScheme selection scheme
Standard_EXPORT virtual void SelectInViewer (const Graphic3d_Vec2i& thePnt,
- const bool theIsXOR = false);
+ const AIS_SelectionScheme theScheme = AIS_SelectionScheme_Replace);
//! Perform selection in 3D viewer.
//! This method is expected to be called from UI thread.
//! @param thePnts picking point
- //! @param theIsXOR XOR selection flag
+ //! @param theScheme selection scheme
Standard_EXPORT virtual void SelectInViewer (const NCollection_Sequence<Graphic3d_Vec2i>& thePnts,
- const bool theIsXOR = false);
+ const AIS_SelectionScheme theScheme = AIS_SelectionScheme_Replace);
//! Update rectangle selection tool.
//! This method is expected to be called from UI thread.
//! @param thePntFrom rectangle first corner
//! @param thePntTo rectangle another corner
- //! @param theIsXOR XOR selection flag
Standard_EXPORT virtual void UpdateRubberBand (const Graphic3d_Vec2i& thePntFrom,
- const Graphic3d_Vec2i& thePntTo,
- const bool theIsXOR = false);
+ const Graphic3d_Vec2i& thePntTo);
//! Update polygonal selection tool.
//! This method is expected to be called from UI thread.
AIS_MouseGestureMap myMouseGestureMap; //!< map defining mouse gestures
AIS_MouseGesture myMouseActiveGesture; //!< initiated mouse gesture (by pressing mouse button)
+ AIS_MouseSelectionSchemeMap
+ myMouseSelectionSchemes; //!< map defining selection schemes bound to mouse + modifiers
Standard_Boolean myMouseActiveIdleRotation; //!< flag indicating view idle rotation state
Graphic3d_Vec2i myMousePositionLast; //!< last mouse position
Graphic3d_Vec2i myMousePressPoint; //!< mouse position where active gesture was been initiated
#include <Aspect_ScrollDelta.hxx>
+#include <AIS_SelectionScheme.hxx>
#include <Graphic3d_Vec2.hxx>
#include <NCollection_Sequence.hxx>
#include <V3d_TypeOfOrientation.hxx>
struct _selection
{
AIS_ViewSelectionTool Tool; //!< perform selection
- bool IsXOR; //!< perform shift selection
+ AIS_SelectionScheme Scheme; //!< selection scheme
NCollection_Sequence<Graphic3d_Vec2i>
Points; //!< the points for selection
bool ToApplyTool; //!< apply rubber-band selection tool
- _selection() : Tool (AIS_ViewSelectionTool_Picking), IsXOR (false), ToApplyTool (false) {}
+ _selection() : Tool (AIS_ViewSelectionTool_Picking), Scheme (AIS_SelectionScheme_UNKNOWN), ToApplyTool (false) {}
} Selection;
struct _panningParams
++anArgIter;
}
}
+ else if (anArg == "-replace")
+ {
+ aSelScheme = AIS_SelectionScheme_Replace;
+ }
+ else if (anArg == "-xor"
+ || anArg == "-shift")
+ {
+ aSelScheme = AIS_SelectionScheme_XOR;
+ }
+ else if (anArg == "-add")
+ {
+ aSelScheme = AIS_SelectionScheme_Add;
+ }
+ else if (anArg == "-remove")
+ {
+ aSelScheme = AIS_SelectionScheme_Remove;
+ }
else if (anArgIter + 1 < theNbArgs
&& anArg.IsIntegerValue()
&& TCollection_AsciiString (theArgVec[anArgIter + 1]).IsIntegerValue())
{
std::swap (aPnts.ChangeFirst(), aPnts.ChangeLast());
}
- aCurrentEventManager->SelectInViewer (aPnts, aSelScheme == AIS_SelectionScheme_XOR);
+
+ aCurrentEventManager->SelectInViewer (aPnts, aSelScheme);
}
else
{
- aCurrentEventManager->SelectInViewer (aPnts, aSelScheme == AIS_SelectionScheme_XOR);
+ aCurrentEventManager->SelectInViewer (aPnts, aSelScheme);
}
aCurrentEventManager->FlushViewEvents (aCtx, ViewerTest::CurrentView(), true);
return 0;
"\n\t\t: When -closeOnEscape is specified, view will be closed on pressing Escape.",
__FILE__, VDiffImage, group);
theCommands.Add ("vselect",
- "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [shift_selection = 0|1]\n"
+ "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [-replace|-xor|-add|-remove]\n"
"- emulates different types of selection:\n"
"- 1) single click selection\n"
"- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n"
" If the flag is set to 1, both sensitives that were included completely and overlapped partially by defined \n"
" rectangle or polygon will be detected, otherwise algorithm will chose only fully included sensitives.\n"
" Default behavior is to detect only full inclusion. (partial inclusion - overlap - is not allowed by default)\n"
- "- 5) any of these selections with shift button pressed",
+ "- 5) selection scheme replace, xor, add or remove (replace by default)",
__FILE__, VSelect, group);
theCommands.Add ("vmoveto",
"vmoveto [x y] [-reset]"
vselmode m 8 1
puts "\nSelection of elements is activated"
-vselect $x_coord $y_coord 1
-###vselect $x_coord $y_coord 1
+vselect $x_coord $y_coord -xor
meshhidesel m
puts "\nSelected element is hidden"
vdisplay -dispMode 1 b1 b2
vfit
vselprops selHighlight -dispMode -1
-vselect 0 0 400 400 1
+vselect 0 0 400 400 -xor
if { [vreadpixel 50 300 rgb name] != "GRAY73" } { puts "Error: b1 should be selected."}
if { [vreadpixel 300 200 rgb name] != "GRAY73" } { puts "Error: b2 should be selected."}
vselect 200 200
vselmode 2 1
vselect 0 0
vselect 58 300
-vselect 300 200 300 60 400 60 407 150 1
+vselect 300 200 300 60 400 60 407 150 -xor
set NbSelected1 [vnbselected]
if { ${NbSelected1} != 13 } {
puts "Error : Polygonal shift selection doesn't work properly"
}
-vselect 350 120 1
+vselect 350 120 -xor
set NbSelected1 [vnbselected]
if { ${NbSelected1} != 12 } {
#select the first edge
vselect 232 368
#select the second edge
-vselect 165 278 1
+vselect 165 278 -xor
vmoveto 0 0
vdump ${anImage1}
#select the first edge
vselect 232 368
#select the second edge
-vselect 165 278 1
+vselect 165 278 -xor
vmoveto 0 0
#enable 'highlight selected' mode
#select the first shape
vselect 70 230
#select the second shape
-vselect 200 358 1
+vselect 200 358 -xor
vmoveto 0 0
vdump ${anImage1}
#select the first shape
vselect 70 230
#select the second shape
-vselect 200 358 1
+vselect 200 358 -xor
vmoveto 0 0
#enable 'highlight selected' mode
vselmode b3 4 1
-vselect 75 230 235 320 -allowoverlap 0 1
-vselect 350 150 380 170 1
+vselect 75 230 235 320 -allowoverlap 0 -xor
+vselect 350 150 380 170 -xor
vnbselected
set aNbSelected3 [vnbselected]
if {$aNbSelected3 != 4} {
vselect 0 0
-vselect 75 230 235 320 -allowoverlap 1 1
-vselect 350 150 380 170 -allowOverlap 1 1
+vselect 75 230 235 320 -allowoverlap 1 -xor
+vselect 350 150 380 170 -allowOverlap 1 -xor
vnbselected
set aNbSelected4 [vnbselected]
if {$aNbSelected4 != 13} {
vfit
vselect 29 104
-vselect 204 2 1
+vselect 204 2 -xor
vfit -selected
checkcolor 29 104 0 0 0
checkcolor 2 317 0.8 0.8 0.8
vselmode 2 1
# try to select b1 and b2
-vselect 305 322 1
-vselect 103 322 1
+vselect 305 322 -xor
+vselect 103 322 -xor
# check that both boxes were not selected with default tolerance value
set aNbSelected [vnbselected]
if {$aNbSelected != "0"} {
puts "ERROR: b1 was not selected"
}
# try to select b2
-vselect 103 322 1
+vselect 103 322 -xor
# check that increase of tolerance for b1 doesn't influence
# on b2
set aNbSelected [vnbselected]
vdisplay b2
vfit
-vselect 350 120 1
+vselect 350 120 -xor
set anInfo [split [vstate *] "\n"]
set aItem1 [string trim [lindex $anInfo 1] ]
set aItem2 [string trim [lindex $anInfo 2] ]
vselect 0 0
vselect ${x1} ${y1}
-vselect ${x2} ${y2} 1
+vselect ${x2} ${y2} -xor
set NbSelected1 [vnbselected]
if { ${NbSelected1} != 2 } {
puts "Error : (case 1)"
}
-vselect ${x2} ${y2} 1
+vselect ${x2} ${y2} -xor
set NbSelected1 [vnbselected]
if { ${NbSelected1} != 1 } {
vdump $imagedir/${casename}_dyn.png
-vselect 50 200 1
-vselect 200 200 1
-vselect 350 200 1
+vselect 50 200 -xor
+vselect 200 200 -xor
+vselect 350 200 -xor
if {[vreadpixel 350 200 name rgba] != "RED2 1" || [vreadpixel 350 200 name rgba] == [vreadpixel 200 200 name rgba]} {
puts "ERROR: selection highlight of 3rd box is displayed with wrong color!"
vclear
meshfromstl m [locate_data_file b.stl]
vselmode m 8 1
-vselect 150 100 1
-vselect 200 200 1
-vselect 250 250 1
-vselect 200 100 1
-vselect 250 100 1
+vselect 150 100 -xor
+vselect 200 200 -xor
+vselect 250 250 -xor
+vselect 200 100 -xor
+vselect 250 100 -xor
meshhidesel m
vrotate -0.9 0 0
vdump $::imagedir/${::casename}.png
vclear
meshfromstl m [locate_data_file b.stl]
vselmode m 8 1
-vselect 150 100 1
-vselect 200 200 1
-vselect 250 250 1
-vselect 200 100 1
-vselect 250 100 1
+vselect 150 100 -xor
+vselect 200 200 -xor
+vselect 250 250 -xor
+vselect 200 100 -xor
+vselect 250 100 -xor
meshshowsel m
vdump $::imagedir/${::casename}.png
vrotate 1.5 0 0
vrotate 0 0.5 0
vselmode m 16 1
-vselect 200 200 1
-vselect 200 300 1
+vselect 200 200 -xor
+vselect 200 300 -xor
meshhidesel m
vdump $::imagedir/${::casename}.png
vrotate 1.5 0 0
vrotate 0 0.5 0
vselmode m 16 1
-vselect 200 200 1
-vselect 200 300 1
+vselect 200 200 -xor
+vselect 200 300 -xor
meshshowsel m
vdump $::imagedir/${::casename}.png