Hi Guys,
I am trying to show the logo in the background of the render view in Paraview 5.9
The script below is used for this purpose:
from paraview.simple import *
import vtk
image = vtk.vtkPNGReader()
rep = vtk.vtkLogoRepresentation()
logoProp = rep.GetImageProperty()
widget = vtk.vtkLogoWidget()
repPosition = [0.5, 0.5]
image.SetFileName('../share/icons/hicolor/96x96/apps/paraview.png')
image.Update()
logoProp.SetDisplayLocationToBackground()
rep.SetPosition(repPosition)
rep.SetImage(image.GetOutput())
rep.SetImageProperty(logoProp)
widget.SetRepresentation(rep)
widget.SetInteractor(GetRenderView().GetInteractor())
widget.On()
widget.Render()
Unfortunately it doesn’t work in Paraview 5.9
But it is ok in Paraview 5.6
What am I doing wrong?
Best regards, Petr
mwestphal
(Mathieu Westphal (Kitware))
January 28, 2021, 11:04am
2
Do not use vtk directly.
# a texture
a = CreateTexture('/home/glow/a.png')
# create a new 'Logo'
logo1 = Logo(registrationName='Logo1')
logo1.Texture = a
# show data from logo1
logo1Display = Show(logo1, renderView1, 'LogoSourceRepresentation')
Render(renderView1)
Thank you!
But I want to put logo into background, not foreground
mwestphal
(Mathieu Westphal (Kitware))
January 28, 2021, 12:49pm
4
Not supported, but that should be simple to.
In fact, it is not difficult.
The following changes are required:
+++ b/Remoting/Views/vtkLogoSourceRepresentation.h
@@ -61,6 +61,14 @@ public:
vtkGetMacro(Opacity, double);
//@}
+ //@{
+ /**
+ * Set the display location of the logo
+ */
+ vtkSetMacro(Background, bool);
+ vtkGetMacro(Background, bool);
+ //@}
+
/**
* vtkAlgorithm::ProcessRequest() equivalent for rendering passes. This is
* typically called by the vtkView to request meta-data from the
@@ -101,6 +109,7 @@ protected:
vtkNew<vtkImageData> ImageCache;
vtk3DWidgetRepresentation* LogoWidgetRepresentation = nullptr;
double Opacity = 1.0;
+ bool Background = false;
private:
vtkLogoSourceRepresentation(const vtkLogoSourceRepresentation&) = delete;
+++ b/Remoting/Views/vtkLogoSourceRepresentation.cxx
@@ -140,6 +140,8 @@ int vtkLogoSourceRepresentation::ProcessViewRequest(
image->GetDimensions(dims);
repr->SetImage(image);
repr->GetImageProperty()->SetOpacity(this->Opacity);
+ repr->GetImageProperty()->SetDisplayLocation(
+ this->Background ? VTK_BACKGROUND_LOCATION : VTK_FOREGROUND_LOCATION);
repr->SetVisibility(true);
float height = repr->GetPosition2()[1];
repr->SetPosition2(height * dims[0] / dims[1], height);
+++ b/Remoting/Views/Resources/views_and_representations.xml
@@ -9645,6 +9645,13 @@
min="0"
name="range" />
</DoubleVectorProperty>
+ <IntVectorProperty command="SetBackground"
+ default_values="0"
+ label="Send to background"
+ name="Background"
+ number_of_elements="1">
+ <BooleanDomain name="bool" />
+ </IntVectorProperty>
<SubProxy command="SetLogoWidgetRepresentation">
<Proxy name="LogoWidgetRepresentation"
proxygroup="representations"
Two versions 5.8.1 and 5.9.0 were built.
In version 5.8.1, it works wonderfully:
But there is an issue with 5.9.0 version:
The method vtkProperty2D:: SetDisplayLocation(int) doesn’t work correctly, it makes the logo disappear. I think it’s all about the VTK::RenderingOpenGL2 module.
I don’t know it’s a bug or a feature.
mwestphal
(Mathieu Westphal (Kitware))
February 1, 2021, 9:49am
6
Could you contribute your branch in a MR so I can take a look easily ?
Done.
https://gitlab.kitware.com/paraview/paraview/-/merge_requests/4702
It’s my first MR, correct me, please, if I did something wrong
After rebasing on master branch, my changes began to work correctly!
Paraview 5.9.0-382-g75e8e49108
VTK 9.0.0-2821-gc0b80b8f5e
Thanks
mwestphal
(Mathieu Westphal (Kitware))
February 2, 2021, 1:47pm
10
Lets keep the discussion on the MR.