Visualization - Expose SelectMgr pixel tolerance via IVtk picker#1204
Open
soilSpoon wants to merge 1 commit intoOpen-Cascade-SAS:masterfrom
Open
Visualization - Expose SelectMgr pixel tolerance via IVtk picker#1204soilSpoon wants to merge 1 commit intoOpen-Cascade-SAS:masterfrom
soilSpoon wants to merge 1 commit intoOpen-Cascade-SAS:masterfrom
Conversation
IVtkTools_ShapePicker::SetTolerance(float) was effectively a dead setter: it stored the value in myTolerance but nothing read it. The actual pick radius was taken from IVtkOCC_ViewerSelector::myPixTol, hardcoded to 2 in its constructor, guarded by a one-shot myToUpdateTol flag that was flipped to false on the first Pick and never reset, and exposed through no public accessor. The result: no code path — public API, Draw command, or subclass — could change the pick radius after the first Pick. This matters most on high-DPI displays where 2 physical pixels are a small fraction of a CSS pixel, making edge and vertex selection practically unusable. Align IVtk with the AIS tolerance flow already established in SelectMgr_ViewerSelector::Pick (line 1239): * Remove myPixTol and myToUpdateTol from IVtkOCC_ViewerSelector. * Replace the caching branch in all three Pick overloads with mySelectingVolumeMgr.SetPixelTolerance(myTolerances.Tolerance()), read on every Pick, matching the base SelectMgr path. * Add SetPixelTolerance(int) / PixelTolerance() on both IVtkOCC_ShapePickerAlgo and IVtkTools_ShapePicker, forwarding to SelectMgr_ViewerSelector's public API. * Remove the dead SetTolerance(float) / GetTolerance() pair and the unused myTolerance field from IVtkTools_ShapePicker. Targeting the 8.0 major release window permits this API break; retaining them as deprecated would only preserve misleading no-ops. * Update ivtkinit in TKIVtkDraw to use the new SetPixelTolerance(2) call, matching the historical hardcoded default. After this change, IVtkTools_ShapePicker::SetPixelTolerance(n) behaves exactly like AIS_InteractiveContext::SetPixelTolerance(n): the value is written to myTolerances via the base setter and read on every subsequent Pick. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8ba5886 to
c5cf754
Compare
Member
|
Dear @soilSpoon Thank you for your patch. To proceed with integration, please complete signing CLA process: In case if you already have signed CLA, please share ID that OCCT team shared with your by email after accepting of CLA. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IVtkTools_ShapePicker::SetTolerance(float)has been effectively a dead setter: it stored the value inmyTolerancebut nothing read it. The actual pick radius was taken fromIVtkOCC_ViewerSelector::myPixTol, hardcoded to2in its constructor, guarded by a one-shotmyToUpdateTolflag that was flipped tofalseon the first Pick and never reset, and exposed through no public accessor.As a result, no code path — public API, Draw command, or subclass — could change the pick radius after the first Pick. This matters most on high-DPI displays where 2 physical pixels are a small fraction of a CSS pixel, making edge and vertex selection practically unusable.
Root cause
IVtkOCC_ViewerSelectorwas introduced in 2011 modeled onStdSelect_ViewerSelector3d. It kept its ownmyPixTol/myToUpdateTolfields and aPick()override that consulted them, instead of reading the baseSelectMgr_ViewerSelector::myTolerances. MeanwhileStdSelect_ViewerSelector3dwas simplified to a typedef overSelectMgr_ViewerSelectorand AIS now uses the canonical flow atSelectMgr_ViewerSelector.cxx:1239:IVtkOCC_ViewerSelector::Picknever migrated to this pattern, leaving the IVtk picker with a dead external API.Change
Align IVtk with the existing AIS tolerance flow:
myPixTolandmyToUpdateTolfromIVtkOCC_ViewerSelector.Pickoverloads withmySelectingVolumeMgr.SetPixelTolerance(myTolerances.Tolerance()), read on every Pick, matching the baseSelectMgrpath.SetPixelTolerance(int)/PixelTolerance() conston bothIVtkOCC_ShapePickerAlgoandIVtkTools_ShapePicker, forwarding toSelectMgr_ViewerSelector's public API. Signatures matchSelectMgr_ViewerSelector's exactly (sameconst int theToleranceparam name).SetTolerance(float)/GetTolerance()pair and the unusedmyTolerancefield fromIVtkTools_ShapePicker. Targeting the 8.0 major release window permits this API break; retaining them as deprecated would only preserve misleading no-ops and produce compile-silent bugs.ivtkinitinTKIVtkDrawto use the newSetPixelTolerance(2)call, matching the historical hardcoded default.After this change,
IVtkTools_ShapePicker::SetPixelTolerance(n)behaves exactly likeAIS_InteractiveContext::SetPixelTolerance(n).Verification
Built vanilla OCCT master (commit
0ebbbedb23) on macOS and wrote a minimal C++ reproducer that drivesIVtkTools_ShapePicker::Pickat increasing pixel offsets from a projected box edge. Results (same test, same renderer, onlylibTKIVtkswapped):SetPixelTolerance(20)Observations:
myTolerances.Tolerance()defaults produce essentially the same small pick radius as the oldmyPixTol = 2. No regression for existing users.SetPixelTolerance(20)works — hits at 3, 5, 10 px that previously missed, andPixelTolerance()returns23(= 20 custom + edge sensitivity contribution from the basemyTolerancessum), exactly like AIS.SetTolerance(float)fails withdyld: Symbol not found: __ZN21IVtkTools_ShapePicker12SetToleranceEf, i.e. the deletion reached ABI.Scope
IVtkOCC_ShapePickerAlgo.{hxx,cxx},IVtkOCC_ViewerSelector.{hxx,cxx},IVtkTools_ShapePicker.{hxx,cxx},IVtkDraw.cxx.API break notice
The removal of
IVtkTools_ShapePicker::SetTolerance(float)/GetTolerance()is a source-level break for downstream consumers that were calling them. Since these methods never affected picking behaviour, the migration is a one-line replacement:For downstream code that was relying on
GetTolerance()to echo back the last value it set, the newPixelTolerance()returns the effective pixel tolerance (possibly adjusted by the basemyTolerancessum).Notes
ivtksetpixtol <n>) and atests/vtk/ivtk/regression script as a follow-up. It was omitted here becauseTKIVtkDrawdoes not build on macOS (X11-only interactor path inIVtkDraw_Interactor.cxx). Happy to add it if preferred — Linux CI would cover it.CR<issue_id>convention since there is no Mantis ticket; can rename if required.