View Issue Details

IDProjectCategoryView StatusLast Update
0030523CommunityOCCT:Visualizationpublic2019-03-11 14:02
ReporterBenjaminBihler Assigned Toapn  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
PlatformMingw-w64OSWindows 
Product Version7.4.0 
Target Version7.4.0Fixed in Version7.4.0 
Summary0030523: Visualization - Highlighting does not work anymore
DescriptionThe commit c29c0ad0a2052257e0bd42f3b9491e0a34328acd disturbs highlighting in our software.

Background: Our software contains a viewer that is very similar to the one from the Qt tutorial sample. Highlighting is done by a method that is very similar to the one from the sample. Here is the code with some debug output:

void View::MoveEvent(const int x, const int y)
{
interactiveContext->MoveTo(x, y, myView, Standard_True);

Handle(AIS_InteractiveObject) newHighlightedObject;

if (interactiveContext->HasDetected())
{
newHighlightedObject = interactiveContext->DetectedInteractive();

std::cout << "Has detected. Object is " << newHighlightedObject->DynamicType()->Name() << std::endl;
}
}

From the given commit on, the shape over which the user hovers with the mouse is not highlighted anymore. Still the debugging output "Has detected. Object is AIS_Shape" shows that a shape has been detected. As soon as I go back one commit (to cf152970e2a79e7d60ffffffe4389f3e4d2b1ef5) everything works as expected.

I have a serious problem: the Qt tutorial sample works as expected also with the new commit, both on Windows and on Linux. Therefore the issue is not easily reproducible. Is there still a chance to trace it and to fix it?
Steps To Reproduce
pload MODELING VISUALIZATION 
box b 1 2 3
vclear
vinit View1
vdisplay -dispMode 1 b
vfit
vselprops dynHighlight -layer -2 -dispMode -1
vmoveto 200 200
#if { [vreadpixel 200 200 rgb name] != "DARKTURQUOISE" } { puts "Error" }
# OK

vmoveto 0 0
vselprops dynHighlight -layer 0 -dispMode -1
vmoveto 200 200
#if { [vreadpixel 200 200 rgb name] != "DARKTURQUOISE" } { puts "Error" }
# KO on the screen (but vreadpixel will NOT return issue here)
TagsNo tags attached.
Test case numberNot needed

Relationships

child of 0030450 closedbugmaster Open CASCADE Visualization - AIS_InteractiveContext::MoveTo() never uses V3d_View::ImmediateRedraw() 

Activities

kgv

2019-02-26 14:04

developer   ~0082370

The referred patch only replaces V3d_View::Update() with V3d_View::RedrawImmediate() in context, when dynamic highlighting is performed and it is expected to be done within one of Immediate Layers (Graphic3d_ZLayerId_Top/Graphic3d_ZLayerId_Topmost/Graphic3d_ZLayerId_TopOSD).

So that easiest way to keep updates is just calling V3d_View::Update() manually and pass FALSE to ::MoveTo().

Why issue might happen within application?
In case if you are using some sub-classes of SelectMgr_EntityOwner/StdSelect_BRepOwner/AIS_InteractiveObject or override highlight styles in one or another way, some dynamic highlighting might be erroneously (or unexpectedly) put into non-immediate layer.
Actually, there might be reasons for application doing this, but in this case application should manually call V3d_View::Update()/Redraw() after ::MoveTo().

Other possible reasons - no immediate layer properly initialized within OpenGL window or specifics in integrating of OCCT 3D Viewer into Qt application.

BenjaminBihler

2019-02-26 17:11

developer   ~0082382

Kirill, your hints have been valueable as always.

Indeed there seems to be a problem with immediate layer initialization. If during redraw I query the number of immediate layers, then there is one such layer in the sample while an object is highlighted, but always zero such layers in my application. It is hard for me to understand the reason, because my code is very close to the sample code except that I use an OCAF TPrsStd_AISViewer and have restructured the code. Does anything come to your mind what the reason could be?

Still your proposal with manual updates works for me. Therefore you may want to close the issue.

kgv

2019-03-01 14:40

developer   ~0082506

I don't know what can be wrong, as long as application does not modify ZLayers / highlight styles, it should work by default.

I suggest closing the issue - fill free to reopen it when you will be able providing a reproducer.

BenjaminBihler

2019-03-04 12:46

developer   ~0082577

You had mentioned it before, but just now I have realized that I do change highlight styles. And yes, this is the source of the error. If I omit highlight style changes, then highlighting works as expected.

My highlight style changing code is similar to this:

const Handle(Prs3d_Drawer) highlightStyle = new Prs3d_Drawer();
highlightStyle->SetColor(Quantity_NOC_CYAN1);
interactiveContext->SetHighlightStyle(highlightStyle);

I have found two ways to solve the problem.

1. Do not create a new Prs3d_Drawer, but modify the existing one instead:

interactiveContext->HighlightStyle()->SetColor(Quantity_NOC_CYAN1);

The idea to call the setter SetHighlightStyle() came from previous OCCT versions where SetHilightColor() was the suitable setter to modify highlight colors.

2. Set the ZLayer ID of the Prs3d_Drawer:

const Handle(Prs3d_Drawer) highlightStyle = new Prs3d_Drawer();
highlightStyle->SetColor(Quantity_NOC_CYAN1);
highlightStyle->SetZLayer(interactiveContext->HighlightStyle()->ZLayer());
interactiveContext->SetHighlightStyle(highlightStyle);

Could you answer three more questions?
- Is there a preferred way to set the highlight color?
- Would it be an option to change the default value of myZLayer in Graphic3d_PresentationAttributes to get working highlight styles by default even if the user doesn't know what he is doing?
- Would a hint in the documentation of the setter SetHighlightStyle help to prevent other users from doing the same mistake?

Thank you again for your help!

kgv

2019-03-04 14:22

developer   ~0082582

> 1. Do not create a new Prs3d_Drawer, but modify the existing one instead:
> - Is there a preferred way to set the highlight color?
Yes, there is no use in creating a new Prs3d_Drawer instance here, so that modifying existing instance is more preferable and straightforward.

> - Would it be an option to change the default value of myZLayer
> in Graphic3d_PresentationAttributes to get working highlight styles by default
I don't think there is a safe way modifying default value within Graphic3d_PresentationAttributes.
Although AIS_IneractiveContext::MoveTo() might check if default highlight style has non-immediate Z-layer and perform full Redraw() instead of RedrawImmediate().

> - Would a hint in the documentation of the setter SetHighlightStyle
> help to prevent other users from doing the same mistake?
Yes, I think that a hint in documentation might be helpfuil.

git

2019-03-04 15:22

administrator   ~0082589

Branch CR30523 has been created by BenjaminBihler.

SHA-1: 1d35fefcbd03f6dbb6bb9bbe26f72f3d28e85599


Detailed log of new commits:

Author: Benjamin Bihler
Date: Mon Mar 4 13:16:10 2019 +0100

    0030523: Visualization - Highlighting does not work anymore
    
    Added hints about ZLayer consideration and changing highlight colors to
    the setter documentation.

BenjaminBihler

2019-03-04 15:23

developer   ~0082590

Done.

git

2019-03-06 13:45

administrator   ~0082727

Branch CR30523_1 has been created by kgv.

SHA-1: b9e52590edbe0b7710e50237979d11271565a28a


Detailed log of new commits:

Author: Benjamin Bihler
Date: Mon Mar 4 13:16:10 2019 +0100

    0030523: Visualization - Highlighting does not work anymore
    
    Added hints about ZLayer consideration and changing highlight colors to documentation
    of AIS_InteractiveContext::SetHighlightStyle() method.

git

2019-03-06 14:41

administrator   ~0082734

Branch CR30523_2 has been created by kgv.

SHA-1: db5f0198777c7601902934391932d42329df3c8a


Detailed log of new commits:

Author: Benjamin Bihler
Date: Mon Mar 4 13:16:10 2019 +0100

    0030523: Visualization - Highlighting does not work anymore
    
    Added hints about ZLayer consideration and changing highlight colors to documentation
    of AIS_InteractiveContext::SetHighlightStyle() method.
    
    AIS_InteractiveContext::MoveTo() now checks if highlighting style does not use immediate layer
    and performs full Redraw() instead of RedrawImmediate().
    
    Improved parsing of ZLayer names within vdisplay, vzlayer and vselprops commands.
    vreadpixel now reports syntax errors on wrong input.

git

2019-03-06 15:08

administrator   ~0082739

Branch CR30523_2 has been updated forcibly by kgv.

SHA-1: 3258ab72385dbfe4c4622204862a453dd9add660

git

2019-03-06 16:23

administrator   ~0082745

Branch CR30523_2 has been updated forcibly by kgv.

SHA-1: 302ea67280048df9e89ca1b824d03c92c193cc4e

kgv

2019-03-06 16:24

developer   ~0082746

Please raise the patch.

apn

2019-03-07 11:27

administrator   ~0082756

Tested with IR-WEEK10:
http://jenkins-test-12.nnov.opencascade.com/view/IR-WEEK10/view/COMPARE/

git

2019-03-11 14:01

administrator   ~0082820

Branch CR30523_2 has been deleted by inv.

SHA-1: 302ea67280048df9e89ca1b824d03c92c193cc4e

git

2019-03-11 14:02

administrator   ~0082822

Branch CR30523_1 has been deleted by inv.

SHA-1: b9e52590edbe0b7710e50237979d11271565a28a

git

2019-03-11 14:02

administrator   ~0082826

Branch CR30523 has been deleted by inv.

SHA-1: 1d35fefcbd03f6dbb6bb9bbe26f72f3d28e85599

Related Changesets

occt: master 55c8f0f7

2019-03-06 12:02:29

BenjaminBihler


Committer: apn Details Diff
0030523: Visualization - Highlighting does not work anymore

Added hints about ZLayer consideration and changing highlight colors to documentation
of AIS_InteractiveContext::SetHighlightStyle() method.

AIS_InteractiveContext::MoveTo() now checks if highlighting style does not use immediate layer
and performs full Redraw() instead of RedrawImmediate().

Improved parsing of ZLayer names within vdisplay, vzlayer and vselprops commands.
vreadpixel now reports syntax errors on wrong input.
Affected Issues
0030523
mod - src/AIS/AIS_InteractiveContext.hxx Diff File
mod - src/AIS/AIS_InteractiveContext_1.cxx Diff File
mod - src/ViewerTest/ViewerTest.cxx Diff File
mod - src/ViewerTest/ViewerTest.hxx Diff File
mod - src/ViewerTest/ViewerTest_ViewerCommands.cxx Diff File
mod - tests/v3d/materials/bug27818_2 Diff File

Issue History

Date Modified Username Field Change
2019-02-26 13:15 BenjaminBihler New Issue
2019-02-26 13:15 BenjaminBihler Assigned To => kgv
2019-02-26 13:57 kgv Relationship added related to 0030450
2019-02-26 14:04 kgv Note Added: 0082370
2019-02-26 17:11 BenjaminBihler Note Added: 0082382
2019-03-01 14:40 kgv Note Added: 0082506
2019-03-01 14:40 kgv Assigned To kgv => bugmaster
2019-03-01 14:40 kgv Status new => feedback
2019-03-01 14:40 kgv Resolution open => unable to reproduce
2019-03-04 12:46 BenjaminBihler Note Added: 0082577
2019-03-04 12:47 BenjaminBihler Assigned To bugmaster => kgv
2019-03-04 14:22 kgv Note Added: 0082582
2019-03-04 14:23 kgv Assigned To kgv => BenjaminBihler
2019-03-04 15:22 git Note Added: 0082589
2019-03-04 15:23 BenjaminBihler Note Added: 0082590
2019-03-04 15:23 BenjaminBihler Assigned To BenjaminBihler =>
2019-03-04 15:23 BenjaminBihler Assigned To => kgv
2019-03-06 13:45 git Note Added: 0082727
2019-03-06 13:59 kgv Steps to Reproduce Updated
2019-03-06 14:41 git Note Added: 0082734
2019-03-06 14:51 kgv Status feedback => resolved
2019-03-06 14:51 kgv Resolution unable to reproduce => open
2019-03-06 14:51 kgv Product Version => 7.4.0
2019-03-06 15:08 git Note Added: 0082739
2019-03-06 16:23 git Note Added: 0082745
2019-03-06 16:24 kgv Note Added: 0082746
2019-03-06 16:24 kgv Assigned To kgv => bugmaster
2019-03-06 16:24 kgv Status resolved => reviewed
2019-03-07 11:27 apn Test case number => Not needed
2019-03-07 11:27 apn Note Added: 0082756
2019-03-07 11:27 apn Status reviewed => tested
2019-03-07 12:14 kgv Relationship replaced child of 0030450
2019-03-10 18:17 apn Changeset attached => occt master 55c8f0f7
2019-03-10 18:17 apn Assigned To bugmaster => apn
2019-03-10 18:17 apn Status tested => verified
2019-03-10 18:17 apn Resolution open => fixed
2019-03-11 14:01 git Note Added: 0082820
2019-03-11 14:02 git Note Added: 0082822
2019-03-11 14:02 git Note Added: 0082826