mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-08 18:40:55 +03:00
0029724: Visualization - add AIS_InteractiveContext::ClearDetected() undoing MoveTo() dynamic highlighting
Introduced new method AIS_InteractiveContext::ClearDetected() allowing to reset the list of detected objects and clear dynamically highlighted entity under mouse cursor after previous AIS_InteractiveContext::MoveTo(). vmoveto command has been extended with new argument -reset.
This commit is contained in:
parent
be480fe752
commit
8a5905801c
src
AIS
SelectMgr
ViewerTest
tests/v3d/materials
@ -2491,6 +2491,33 @@ void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ClearDetected
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean AIS_InteractiveContext::ClearDetected (Standard_Boolean theToRedrawImmediate)
|
||||||
|
{
|
||||||
|
myCurDetected = 0;
|
||||||
|
myCurHighlighted = 0;
|
||||||
|
myDetectedSeq.Clear();
|
||||||
|
myLastPicked = myLastinMain;
|
||||||
|
myWasLastMain = Standard_True;
|
||||||
|
Standard_Boolean toUpdate = Standard_False;
|
||||||
|
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
|
||||||
|
{
|
||||||
|
toUpdate = Standard_True;
|
||||||
|
clearDynamicHighlight();
|
||||||
|
}
|
||||||
|
myLastinMain.Nullify();
|
||||||
|
myLastPicked.Nullify();
|
||||||
|
myMainSel->ClearPicked();
|
||||||
|
if (toUpdate && theToRedrawImmediate)
|
||||||
|
{
|
||||||
|
myMainVwr->RedrawImmediate();
|
||||||
|
}
|
||||||
|
return toUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : DrawHiddenLine
|
//function : DrawHiddenLine
|
||||||
//purpose :
|
//purpose :
|
||||||
|
@ -347,6 +347,11 @@ public: //! @name mouse picking logic (detection and dynamic highlighting of ent
|
|||||||
const Handle(V3d_View)& theView,
|
const Handle(V3d_View)& theView,
|
||||||
const Standard_Boolean theToRedrawOnUpdate);
|
const Standard_Boolean theToRedrawOnUpdate);
|
||||||
|
|
||||||
|
//! Clears the list of entities detected by MoveTo() and resets dynamic highlighting.
|
||||||
|
//! @param theToRedrawImmediate if TRUE, the main Viewer will be redrawn on update
|
||||||
|
//! @return TRUE if viewer needs to be updated (e.g. there were actually dynamically highlighted entities)
|
||||||
|
Standard_EXPORT Standard_Boolean ClearDetected (Standard_Boolean theToRedrawImmediate = Standard_False);
|
||||||
|
|
||||||
//! Returns true if there is a mouse-detected entity in context.
|
//! Returns true if there is a mouse-detected entity in context.
|
||||||
//! @sa DetectedOwner()/HasNextDetected()/HilightPreviousDetected()/HilightNextDetected().
|
//! @sa DetectedOwner()/HasNextDetected()/HilightPreviousDetected()/HilightNextDetected().
|
||||||
Standard_EXPORT Standard_Boolean HasDetected() const;
|
Standard_EXPORT Standard_Boolean HasDetected() const;
|
||||||
|
@ -623,6 +623,15 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
|||||||
SortResult();
|
SortResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==================================================
|
||||||
|
// Function: ClearPicked
|
||||||
|
// Purpose :
|
||||||
|
//==================================================
|
||||||
|
void SelectMgr_ViewerSelector::ClearPicked()
|
||||||
|
{
|
||||||
|
mystored.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
//==================================================
|
//==================================================
|
||||||
// Function: Picked
|
// Function: Picked
|
||||||
// Purpose :
|
// Purpose :
|
||||||
|
@ -112,6 +112,9 @@ public:
|
|||||||
//! Returns the number of detected owners.
|
//! Returns the number of detected owners.
|
||||||
Standard_Integer NbPicked() const { return mystored.Extent(); }
|
Standard_Integer NbPicked() const { return mystored.Extent(); }
|
||||||
|
|
||||||
|
//! Clears picking results.
|
||||||
|
Standard_EXPORT void ClearPicked();
|
||||||
|
|
||||||
//! Returns the entity Owner for the object picked at specified position.
|
//! Returns the entity Owner for the object picked at specified position.
|
||||||
//! @param theRank rank of detected object within range 1...NbPicked()
|
//! @param theRank rank of detected object within range 1...NbPicked()
|
||||||
Standard_EXPORT Handle(SelectMgr_EntityOwner) Picked (const Standard_Integer theRank) const;
|
Standard_EXPORT Handle(SelectMgr_EntityOwner) Picked (const Standard_Integer theRank) const;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <AIS_InteractiveObject.hxx>
|
#include <AIS_InteractiveObject.hxx>
|
||||||
#include <AIS_ListOfInteractive.hxx>
|
#include <AIS_ListOfInteractive.hxx>
|
||||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||||
|
#include <Aspect_Grid.hxx>
|
||||||
#include <DBRep.hxx>
|
#include <DBRep.hxx>
|
||||||
#include <Draw_ProgressIndicator.hxx>
|
#include <Draw_ProgressIndicator.hxx>
|
||||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||||
@ -6667,23 +6668,69 @@ static Standard_Integer VSelect (Draw_Interpretor& di,
|
|||||||
//function : VMoveTo
|
//function : VMoveTo
|
||||||
//purpose : Emulates cursor movement to defined pixel position
|
//purpose : Emulates cursor movement to defined pixel position
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
static Standard_Integer VMoveTo (Draw_Interpretor& di,
|
static Standard_Integer VMoveTo (Draw_Interpretor& ,
|
||||||
Standard_Integer argc,
|
Standard_Integer theNbArgs,
|
||||||
const char ** argv)
|
const char** theArgVec)
|
||||||
{
|
{
|
||||||
if(argc != 3)
|
const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
|
||||||
|
const Handle(V3d_View)& aView = ViewerTest::CurrentView();
|
||||||
|
if (aContext.IsNull())
|
||||||
{
|
{
|
||||||
di << "Usage : " << argv[0] << " x y\n";
|
std::cout << "Error: no active View\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
|
Graphic3d_Vec2i aMousePos (IntegerLast(), IntegerLast());
|
||||||
if(aContext.IsNull())
|
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
|
||||||
{
|
{
|
||||||
di << "use 'vinit' command before " << argv[0] << "\n";
|
TCollection_AsciiString anArgStr (theArgVec[anArgIter]);
|
||||||
|
anArgStr.LowerCase();
|
||||||
|
if (anArgStr == "-reset"
|
||||||
|
|| anArgStr == "-clear")
|
||||||
|
{
|
||||||
|
if (anArgIter + 1 < theNbArgs)
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error at '" << theArgVec[anArgIter + 1] << "'\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Standard_Boolean toEchoGrid = aContext->CurrentViewer()->Grid()->IsActive()
|
||||||
|
&& aContext->CurrentViewer()->GridEcho();
|
||||||
|
if (toEchoGrid)
|
||||||
|
{
|
||||||
|
aContext->CurrentViewer()->HideGridEcho (aView);
|
||||||
|
}
|
||||||
|
if (aContext->ClearDetected() || toEchoGrid)
|
||||||
|
{
|
||||||
|
aContext->CurrentViewer()->RedrawImmediate();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (aMousePos.x() == IntegerLast()
|
||||||
|
&& anArgStr.IsIntegerValue())
|
||||||
|
{
|
||||||
|
aMousePos.x() = anArgStr.IntegerValue();
|
||||||
|
}
|
||||||
|
else if (aMousePos.y() == IntegerLast()
|
||||||
|
&& anArgStr.IsIntegerValue())
|
||||||
|
{
|
||||||
|
aMousePos.y() = anArgStr.IntegerValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aMousePos.x() == IntegerLast()
|
||||||
|
|| aMousePos.y() == IntegerLast())
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: wrong number of arguments\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
|
|
||||||
|
ViewerTest::CurrentEventManager()->MoveTo (aMousePos.x(), aMousePos.y());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12161,8 +12208,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
|||||||
"- 5) any of these selections with shift button pressed",
|
"- 5) any of these selections with shift button pressed",
|
||||||
__FILE__, VSelect, group);
|
__FILE__, VSelect, group);
|
||||||
theCommands.Add ("vmoveto",
|
theCommands.Add ("vmoveto",
|
||||||
"vmoveto x y"
|
"vmoveto [x y] [-reset]"
|
||||||
"- emulates cursor movement to pixel postion (x,y)",
|
"\n\t\t: Emulates cursor movement to pixel position (x,y)."
|
||||||
|
"\n\t\t: -reset resets current highlighting",
|
||||||
__FILE__, VMoveTo, group);
|
__FILE__, VMoveTo, group);
|
||||||
theCommands.Add ("vviewparams",
|
theCommands.Add ("vviewparams",
|
||||||
"vviewparams [-args] [-scale [s]]"
|
"vviewparams [-args] [-scale [s]]"
|
||||||
|
@ -1,44 +1,30 @@
|
|||||||
puts "============"
|
puts "============"
|
||||||
puts "OCC27818_1"
|
puts "0027818: Visualization - provide an interface to define highlight presentation properties"
|
||||||
|
puts "Test change of highlight properties for whole interactive context"
|
||||||
puts "============"
|
puts "============"
|
||||||
puts ""
|
puts ""
|
||||||
####################################################################################
|
|
||||||
# Visualization - provide an interface to define highlight presentation properties:
|
|
||||||
# test change of highlight properties for whole interactive context
|
|
||||||
####################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
pload VISUALIZATION MODELING
|
pload VISUALIZATION MODELING
|
||||||
|
|
||||||
box b 10 20 30
|
box b 10 20 30
|
||||||
pcone p 15 0 40
|
pcone p 15 0 40
|
||||||
|
|
||||||
vinit
|
|
||||||
vclear
|
vclear
|
||||||
|
vinit View1
|
||||||
vdisplay b -dispMode 1
|
vdisplay b -dispMode 1 b p
|
||||||
vdisplay p -dispMode 1
|
|
||||||
vsetcolor b RED
|
vsetcolor b RED
|
||||||
vsetcolor p GREEN
|
vsetcolor p GRAY
|
||||||
|
|
||||||
vviewparams -scale 17.8 -proj 0.9 -0.3 0.3
|
vviewparams -scale 17.8 -proj 0.892687 -0.331602 0.305206 -up -0.162521 0.394789 0.904284 -at 1.99 2.4 20.9
|
||||||
vviewparams -up -0.2 0.4 0.9 -at 1.99 2.4 20.9
|
vselprops dynHighlight -transp 0.3 -color PALEGREEN2 -dispMode 1
|
||||||
vviewparams -eye 56.1 -17.7 39.4
|
|
||||||
|
|
||||||
vselprops dynHighlight -transp 0.1 -color PALEGREEN2 -dispMode 1
|
|
||||||
|
|
||||||
vmoveto 167 263
|
|
||||||
set aPixelColor [vreadpixel 167 263 name rgba]
|
|
||||||
set aTransp [lindex [split $aPixelColor { }] 1]
|
|
||||||
if { $aTransp == 1 } {
|
|
||||||
puts "Error: highlighting of a cone is not transparent!"
|
|
||||||
}
|
|
||||||
|
|
||||||
vmoveto 285 212
|
vmoveto 285 212
|
||||||
set aPixelColor [vreadpixel 285 212 name rgba]
|
if { [vreadpixel 285 212 name rgb] != "DARKKHAKI" } { puts "Error: highlighting of a box is not transparent!" }
|
||||||
set aTransp [lindex [split $aPixelColor { }] 1]
|
|
||||||
if { $aTransp == 1 } {
|
vmoveto -reset
|
||||||
puts "Error: highlighting of a box is not transparent!"
|
if { [vreadpixel 285 212 name rgb] != "RED" } { puts "Error: highlighting of a box is not reset!" }
|
||||||
}
|
|
||||||
|
vmoveto 167 263
|
||||||
|
if { [vreadpixel 167 263 name rgb] != "DARKSEAGREEN2" } { puts "Error: highlighting of a cone is not transparent!" }
|
||||||
|
|
||||||
vdump $imagedir/${casename}.png
|
vdump $imagedir/${casename}.png
|
||||||
|
Loading…
x
Reference in New Issue
Block a user