MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0030523Community[OCCT] OCCT:Visualizationpublic2019-02-26 13:152019-03-11 14:02
ReporterBenjaminBihler 
Assigned Toapn 
PrioritynormalSeverityminor 
StatusverifiedResolutionfixed 
PlatformMingw-w64OSWindowsOS Version7
Product Version[OCCT] 7.4.0* 
Target Version[OCCT] 7.4.0*Fixed in Version 
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
Attached Files

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

-  Notes
(0082370)
kgv (developer)
2019-02-26 14:04

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.
(0082382)
BenjaminBihler (developer)
2019-02-26 17:11

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.
(0082506)
kgv (developer)
2019-03-01 14:40

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.
(0082577)
BenjaminBihler (developer)
2019-03-04 12:46

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!
(0082582)
kgv (developer)
2019-03-04 14:22

> 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.
(0082589)
git (administrator)
2019-03-04 15:22

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.
(0082590)
BenjaminBihler (developer)
2019-03-04 15:23

Done.
(0082727)
git (administrator)
2019-03-06 13:45

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.
(0082734)
git (administrator)
2019-03-06 14:41

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.
(0082739)
git (administrator)
2019-03-06 15:08

Branch CR30523_2 has been updated forcibly by kgv.

SHA-1: 3258ab72385dbfe4c4622204862a453dd9add660
(0082745)
git (administrator)
2019-03-06 16:23

Branch CR30523_2 has been updated forcibly by kgv.

SHA-1: 302ea67280048df9e89ca1b824d03c92c193cc4e
(0082746)
kgv (developer)
2019-03-06 16:24

Please raise the patch.
(0082756)
apn (administrator)
2019-03-07 11:27

Tested with IR-WEEK10:
http://jenkins-test-12.nnov.opencascade.com/view/IR-WEEK10/view/COMPARE/ [^]
(0082820)
git (administrator)
2019-03-11 14:01

Branch CR30523_2 has been deleted by inv.

SHA-1: 302ea67280048df9e89ca1b824d03c92c193cc4e
(0082822)
git (administrator)
2019-03-11 14:02

Branch CR30523_1 has been deleted by inv.

SHA-1: b9e52590edbe0b7710e50237979d11271565a28a
(0082826)
git (administrator)
2019-03-11 14:02

Branch CR30523 has been deleted by inv.

SHA-1: 1d35fefcbd03f6dbb6bb9bbe26f72f3d28e85599

- Related Changesets
occt: master 55c8f0f7
Timestamp: 2019-03-06 12:02:29
Author: 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.
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 View Revisions
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


Copyright © 2000 - 2019 MantisBT Team
Powered by Mantis Bugtracker