The latest release of paraview 12 has a new feature called legend grid annotation that exist in screen space and is tethered to the -z view direction in parallel projection. This is a feature I was wanting to implement in VTK directly. Can this or an equivalent be created with VTK filters, if so can an example be provided to show how.
What you are looking for is the vtkLegendScaleActor
class. You can find example (https://examples.vtk.org/site/Cxx/Visualization/LegendScaleActor/) and tests.
@nicolas.vuaille you mentioned here that new Legend Grid Annotation option checkbox to align which axes in model space correspond to screen space - Feature Requests - ParaView that the vtklegendscaleactor axes can sync when the camera normal matches one of the main scene axis. With vtkLegenScaleActor when I set camera ViewUp to [1,0,0] and the Label Mode to XYCoordinate for vtkLegendScaleActor the horizontal & vertical screen space axes are flipped relative to the camera. How do I rectify this so that they are in sync? Thanks for all of your assistance with this.
I hope this illustration coveys how I would like to utilize the Legend Annotation actor both in alignment with the main scene axis but also with respect to a custom normal and origin. I am not sure how to accomplish this or if is possible without transforming a copy of all of the actors to a separate scene such that they are rotated and shifted in a way that I can pan the viewport relative to the custom origin as depicted in the top right.
In Coordinates mode, not only the view up matters but also the focal direction. I.e. the screen should be defined by 2 of the main axes, the focal direction being the 3rd.
Otherwise you cannot define coordinates along the legend axes, only some distance (that is the other mode of the Legend Scale).
Just to clarify in the current 9.3 nightly documentation it seems that the 2 main axes are hard coded to be X & Y and the focal direction can be toggled +Z or -Z, at lease within the LegendScaleActor API, perhaps I am unaware of way to customize the 2 main axes for the scene such that I can make a LegendScaleActor for a scene where all of the data is in a cartesian XYZ space but the with respect to the viewport/scene the 2 main axes are rotated and translated relative the 0,0,0 origin and the XYZ directions. I do see the LegendScaleActor has a method SetOrigin that would allow for translation of the view relative to 0,0,0 but nothing in the API suggest a way to use alternative main axes other than X & Y
Previously, we had the XY_COORDINATES
. It used to assume a X-Y plane for the screen. Then it was turned into COORDINATES
because it now had the ability to auto detect the screen plane, assuming it is made of the main axes. So to control axes, one have to change the camera.
Note that this was changed really recently (one month ago: https://gitlab.kitware.com/vtk/vtk/-/commit/ed2af29f5643720fe42976bcff43346e09b2e0dd)
Thanks again for the insight, perhaps I will try to download and build nightly-master in order to test the functionality, it is fortunate that the use case I imagined for my workflow is already being implemented.
I have been using the master branch (from 3/18/24) and it seems to orient based on some logic to set legend grid screen space axis to a corresponding world coordinate main axis. The legend coordinate values seem to be incomprehensible if the camera position is not perfectly along one and only one axis and the focal point is the world origin.
The way I would like to use this involves (perhaps a new mode, I propose) SetModeToFocalPlane? where the screen space Legend Grid Annocation horizontal and vertical axis correspond to distances along the focal plane and this could still use SetOrigin to shift (0,0) in focal plane space.
Well, Coordinates
mode display scene coordinates, which are badly defined in screen space if you are not aligned with axis scene.
To display distances from an origin, you should use Distance
mode instead.
I am going to make a proposal in feature request that tries to codify exactly how the axis can be clearly defined with respect to camera position, the normal for the focal plane the view up and an origin that is the (x,y,z) origin projected (along FP normal) onto the Focal plane with the view up as the legend grid vertical access, the FP normal as the Z axis, and the horizontal axis being (view up) x (FP normal), and from the perspective of the camera the scene would dynamically always be looking in the -Z direction. And because the legend grid is essentially linked to the focal plane, there may need to a corresponding toggle to reverse the horizontal axis by flipping the grid axis Z to be the negative FP normal. This is the equivalent of moving the camera to the opposite side (+Z/-Z view direction) relative to a fixed world space x,y,z axis, but because here there would be a dynamic on-the-fly x’,y’,z’ axis tethered to the camera, there would need to be a toggle, reversing the verticle direction could just be done with the rotating view up the same as with SetModeToCoordinates. This modes behavior would match that of SetModeToCoordinates when the camera exists along a main world axis (in the positive direction) and is positioned in a plane orthagonal to the same axis and pointing along said axis towards the origin (except it is always pointing in the -Z direction)
I will also include I use case of how I’d like to use this feature (this will also cover why “Distance” mode isn’t desired for my use case), and even if feature request is declined maybe the community will have suggestions about how to engineer my workflow another way.