mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0027530: Visualization - AIS_InteractiveContext::HilightNextDetected() doesn't work in Neutral Point
- added implementation of mentioned methods for neutral point; - sequence of detected objects was replaced by sequence of detected owner's indexes in AIS_InteractiveContext; - commands vselnext and vselprev were corrected to update viewer properly; - test case for issue #27530.
This commit is contained in:
parent
c9c7286e56
commit
f0cddd16eb
@ -92,7 +92,8 @@ myPreselectionColor(Quantity_NOC_GREEN),
|
||||
mySubintStyle(new Graphic3d_HighlightStyle (Aspect_TOHM_COLOR, Quantity_NOC_GRAY40)),
|
||||
myDisplayMode(0),
|
||||
myCurLocalIndex(0),
|
||||
myAISCurDetected(0),
|
||||
myCurDetected(0),
|
||||
myCurHighlighted(0),
|
||||
myZDetectionFlag(0),
|
||||
myIsAutoActivateSelMode(Standard_True)
|
||||
{
|
||||
@ -2354,13 +2355,13 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
|
||||
myMainPM->Erase (theIObj, -1);
|
||||
|
||||
// Object removes from Detected sequence
|
||||
for(Standard_Integer aDetIter = 1; aDetIter < myAISDetectedSeq.Length(); ++aDetIter)
|
||||
for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper(); ++aDetIter)
|
||||
{
|
||||
Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
|
||||
if (!anObj.IsNull()
|
||||
&& anObj != theIObj)
|
||||
{
|
||||
myAISDetectedSeq.Remove (aDetIter);
|
||||
myDetectedSeq.Remove (aDetIter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <Quantity_NameOfColor.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <AIS_DataMapOfILC.hxx>
|
||||
#include <AIS_SequenceOfInteractive.hxx>
|
||||
#include <AIS_DisplayStatus.hxx>
|
||||
#include <AIS_KindOfInteractive.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
@ -1716,8 +1715,9 @@ protected:
|
||||
AIS_DataMapOfILC myLocalContexts;
|
||||
Standard_Integer myCurLocalIndex;
|
||||
Handle(V3d_View) mylastmoveview;
|
||||
AIS_SequenceOfInteractive myAISDetectedSeq;
|
||||
Standard_Integer myAISCurDetected;
|
||||
TColStd_SequenceOfInteger myDetectedSeq;
|
||||
Standard_Integer myCurDetected;
|
||||
Standard_Integer myCurHighlighted;
|
||||
Standard_Boolean myZDetectionFlag;
|
||||
Standard_Boolean myIsAutoActivateSelMode;
|
||||
|
||||
|
@ -307,8 +307,9 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
|
||||
return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate);
|
||||
}
|
||||
|
||||
myAISCurDetected = 0;
|
||||
myAISDetectedSeq.Clear();
|
||||
myCurDetected = 0;
|
||||
myCurHighlighted = 0;
|
||||
myDetectedSeq.Clear();
|
||||
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
@ -341,15 +342,14 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
|
||||
{
|
||||
aNewDetected = aDetIter;
|
||||
}
|
||||
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
||||
if (!anObj.IsNull())
|
||||
{
|
||||
myAISDetectedSeq.Append (anObj);
|
||||
}
|
||||
|
||||
myDetectedSeq.Append (aDetIter);
|
||||
}
|
||||
|
||||
if (aNewDetected >= 1)
|
||||
{
|
||||
myCurHighlighted = myDetectedSeq.Lower();
|
||||
|
||||
// Does nothing if previously detected object is equal to the current one.
|
||||
// However in advanced selection modes the owners comparison
|
||||
// is not effective because in that case only one owner manage the
|
||||
@ -1518,14 +1518,18 @@ Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() cons
|
||||
return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : HasNextDetected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
|
||||
{
|
||||
if(!HasOpenedContext())
|
||||
return Standard_False; // temporaire
|
||||
else
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->HasNextDetected();
|
||||
|
||||
}
|
||||
|
||||
return !myDetectedSeq.IsEmpty() && myCurHighlighted <= myDetectedSeq.Upper();
|
||||
}
|
||||
|
||||
|
||||
@ -1548,23 +1552,79 @@ Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
|
||||
Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean theToRedrawImmediate)
|
||||
{
|
||||
return HasOpenedContext()
|
||||
? myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate)
|
||||
: 0;
|
||||
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate);
|
||||
}
|
||||
|
||||
myMainPM->ClearImmediateDraw();
|
||||
if (myDetectedSeq.IsEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (++myCurHighlighted > myDetectedSeq.Upper())
|
||||
{
|
||||
myCurHighlighted = myDetectedSeq.Lower();
|
||||
}
|
||||
const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
|
||||
if (anOwner.IsNull())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
highlightWithColor (anOwner, theView->Viewer());
|
||||
myLastPicked = anOwner;
|
||||
myLastinMain = myLastPicked;
|
||||
|
||||
if (theToRedrawImmediate)
|
||||
{
|
||||
myMainPM->RedrawImmediate (theView->Viewer());
|
||||
myMainVwr->RedrawImmediate();
|
||||
}
|
||||
|
||||
return myCurHighlighted;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightNextDetected
|
||||
//function : HilightPreviousDetected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean theToRedrawImmediate)
|
||||
{
|
||||
return HasOpenedContext()
|
||||
? myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate)
|
||||
: 0;
|
||||
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate);
|
||||
}
|
||||
|
||||
myMainPM->ClearImmediateDraw();
|
||||
if (myDetectedSeq.IsEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (--myCurHighlighted < myDetectedSeq.Lower())
|
||||
{
|
||||
myCurHighlighted = myDetectedSeq.Upper();
|
||||
}
|
||||
const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
|
||||
if (anOwner.IsNull())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
highlightWithColor (anOwner, theView->Viewer());
|
||||
myLastPicked = anOwner;
|
||||
myLastinMain = myLastPicked;
|
||||
|
||||
if (theToRedrawImmediate)
|
||||
{
|
||||
myMainPM->RedrawImmediate (theView->Viewer());
|
||||
myMainVwr->RedrawImmediate();
|
||||
}
|
||||
|
||||
return myCurHighlighted;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -1575,13 +1635,13 @@ void AIS_InteractiveContext::InitDetected()
|
||||
{
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
myLocalContexts(myCurLocalIndex)->InitDetected();
|
||||
myLocalContexts (myCurLocalIndex)->InitDetected();
|
||||
return;
|
||||
}
|
||||
|
||||
if(myAISDetectedSeq.Length() != 0)
|
||||
if (!myDetectedSeq.IsEmpty())
|
||||
{
|
||||
myAISCurDetected = 1;
|
||||
myCurDetected = myDetectedSeq.Lower();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1593,11 +1653,10 @@ Standard_Boolean AIS_InteractiveContext::MoreDetected() const
|
||||
{
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->MoreDetected();
|
||||
return myLocalContexts (myCurLocalIndex)->MoreDetected();
|
||||
}
|
||||
|
||||
return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length()) ?
|
||||
Standard_True : Standard_False;
|
||||
return myCurDetected >= myDetectedSeq.Lower() && myCurDetected <= myDetectedSeq.Upper();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -1606,13 +1665,13 @@ Standard_Boolean AIS_InteractiveContext::MoreDetected() const
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::NextDetected()
|
||||
{
|
||||
if(HasOpenedContext())
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
myLocalContexts(myCurLocalIndex)->NextDetected();
|
||||
myLocalContexts (myCurLocalIndex)->NextDetected();
|
||||
return;
|
||||
}
|
||||
|
||||
myAISCurDetected++;
|
||||
myCurDetected++;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -1647,7 +1706,9 @@ Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() co
|
||||
return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
|
||||
}
|
||||
|
||||
return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
|
||||
return MoreDetected()
|
||||
? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
|
||||
: NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -4688,7 +4688,7 @@ static Standard_Integer VSelectionNext(Draw_Interpretor& /*theDI*/,
|
||||
return 1;
|
||||
}
|
||||
|
||||
anAISContext->HilightNextDetected(aView);
|
||||
anAISContext->HilightNextDetected (aView);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4710,7 +4710,7 @@ static Standard_Integer VSelectionPrevious(Draw_Interpretor& /*theDI*/,
|
||||
return 1;
|
||||
}
|
||||
|
||||
anAISContext->HilightPreviousDetected(aView);
|
||||
anAISContext->HilightPreviousDetected (aView);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
79
tests/bugs/vis/bug27530
Normal file
79
tests/bugs/vis/bug27530
Normal file
@ -0,0 +1,79 @@
|
||||
puts "==========="
|
||||
puts "OCC27530"
|
||||
puts "==========="
|
||||
puts ""
|
||||
##########################################################################
|
||||
# Visualization - AIS_InteractiveContext::HilightNextDetected() doesn't work in Neutral Point
|
||||
##########################################################################
|
||||
|
||||
proc check_highlighting { theHiBoxIdx theCoords } {
|
||||
set aNext [expr ($theHiBoxIdx + 1) % 3]
|
||||
set aNextNext [expr ($theHiBoxIdx + 2) % 3]
|
||||
set hiColor [vreadpixel [lindex $theCoords [expr $theHiBoxIdx * 2] ] [lindex $theCoords [expr $theHiBoxIdx * 2 + 1] ] name]
|
||||
set nextColor [vreadpixel [lindex $theCoords [expr $aNext * 2] ] [lindex $theCoords [expr $aNext * 2 + 1] ] name]
|
||||
set nextNextColor [vreadpixel [lindex $theCoords [expr $aNextNext * 2] ] [lindex $theCoords [expr $aNextNext * 2 + 1] ] name]
|
||||
|
||||
if {$hiColor == "CYAN1 1" && $nextColor == "YELLOW 1" && $nextNextColor == "YELLOW 1"} {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
pload VISUALIZATION MODELING
|
||||
|
||||
box b0 3 3 3
|
||||
box b1 1 1 1 3 2 1
|
||||
box b2 1.5 1.5 1.5 4 4 4
|
||||
|
||||
set coords { }
|
||||
# b0_x, b0_y
|
||||
lappend coords 355
|
||||
lappend coords 186
|
||||
# b1_x, b1_y
|
||||
lappend coords 266
|
||||
lappend coords 333
|
||||
# b2_x, b2_y
|
||||
lappend coords 177
|
||||
lappend coords 2
|
||||
|
||||
vinit
|
||||
vclear
|
||||
vdisplay b0 b1 b2
|
||||
vleft
|
||||
vfit
|
||||
|
||||
# MoveTo in area that is common for all boxes
|
||||
vmoveto 210 280
|
||||
|
||||
if { ![check_highlighting 0 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of box b0"
|
||||
}
|
||||
|
||||
# check vselnext
|
||||
vselnext
|
||||
if { ![check_highlighting 1 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of box b1 after vselnext call"
|
||||
}
|
||||
vselnext
|
||||
if { ![check_highlighting 2 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of box b2 after vselnext call"
|
||||
}
|
||||
vselnext
|
||||
if { ![check_highlighting 0 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of box b0 after vselnext call"
|
||||
}
|
||||
|
||||
# check vselprev
|
||||
vselprev
|
||||
if { ![check_highlighting 2 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of box b2 after vselprev call"
|
||||
}
|
||||
vselprev
|
||||
if { ![check_highlighting 1 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of box b1 after vselprev call"
|
||||
}
|
||||
vselprev
|
||||
if { ![check_highlighting 0 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of box b0 after vselprev call"
|
||||
}
|
@ -4,16 +4,63 @@ puts "Test case check work of the new commands vselnext and vselprev"
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
proc check_highlighting { theEdgeIdx theCoords } {
|
||||
set aNext [expr ($theEdgeIdx + 1) % 3]
|
||||
set aNextNext [expr ($theEdgeIdx + 2) % 3]
|
||||
set hiColor [vreadpixel [lindex $theCoords [expr $theEdgeIdx * 2] ] [lindex $theCoords [expr $theEdgeIdx * 2 + 1] ] name]
|
||||
set nextColor [vreadpixel [lindex $theCoords [expr $aNext * 2] ] [lindex $theCoords [expr $aNext * 2 + 1] ] name]
|
||||
set nextNextColor [vreadpixel [lindex $theCoords [expr $aNextNext * 2] ] [lindex $theCoords [expr $aNextNext * 2 + 1] ] name]
|
||||
|
||||
if {$hiColor == "CYAN1 1" && $nextColor == "YELLOW 1" && $nextNextColor == "YELLOW 1"} {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
set coords { }
|
||||
# e10_x, e10_y
|
||||
lappend coords 94
|
||||
lappend coords 140
|
||||
# e2_x, e2_y
|
||||
lappend coords 103
|
||||
lappend coords 60
|
||||
# e1_x, e1_y
|
||||
lappend coords 29
|
||||
lappend coords 208
|
||||
|
||||
box b 10 10 10
|
||||
vdisplay b
|
||||
vfit
|
||||
vselmode 2 1
|
||||
vmoveto 30 101
|
||||
|
||||
if { ![check_highlighting 0 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of edge 10"
|
||||
}
|
||||
|
||||
vselnext
|
||||
if { ![check_highlighting 1 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of edge 2 after vselnext call"
|
||||
}
|
||||
vselnext
|
||||
if { ![check_highlighting 2 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of edge 1 after vselnext call"
|
||||
}
|
||||
vselnext
|
||||
if { ![check_highlighting 0 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of edge 10 after vselnext call"
|
||||
}
|
||||
|
||||
vselprev
|
||||
if { ![check_highlighting 2 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of edge 1 after vselprev call"
|
||||
}
|
||||
vselprev
|
||||
if { ![check_highlighting 1 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of edge 2 after vselprev call"
|
||||
}
|
||||
vselprev
|
||||
if { ![check_highlighting 0 $coords] } {
|
||||
puts "ERROR: incorrect highlighting of edge 10 after vselprev call"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user