[Paraview] Python: How to change the location and size of orientation axes?

Liang Wang frank0734 at gmail.com
Sat Apr 8 22:05:08 EDT 2017


It turned out using the vtkPVAxesWidget might be more appropriate because
it is attached to a fixed renderer thus does not rotate when you rotate
your main renderer. However, I still do not know how to set the location
and size of the resulting orientation axes more accurately. Maybe it is
because the resulting renderer always zoom to match the dimension of the
resulting orientation axes?


from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

renderView1 = GetActiveViewOrCreate('RenderView')

sphere1 = Sphere()
sphere1.Radius = 1.0
sphere1Display = Show(sphere1, renderView1)
sphere1Display.SetRepresentationType('Outline')

renderer = renderView1.GetRenderer()

renderView1.OrientationAxesVisibility = 0

import vtk
a = vtk.vtkPVAxesWidget()
a.SetParentRenderer(renderer)
a.SetViewport(0, 0, 0.4, 0.4) # default is (0, 0, 0.25, 0.25)

r = a.GetRenderer()

aa = a.GetAxesActor() # vtkPVAxesActor

#aa.SetOrigin(-5.0, -5.0, -5.0) # not working
#aa.SetPosition(-5.0, -5.0, -5.0) # not working
#aa.SetScale(2.0, 2.0, 2.0) # not working
#aa.SetShaftTypeToCylinder()
#aa.SetCylinderRadius(aa.GetCylinderRadius()*2.0)
#aa.SetConeRadius(aa.GetConeRadius()*2.0)

Interact()


On Sat, Apr 8, 2017 at 7:46 PM, Liang Wang <frank0734 at gmail.com> wrote:

> I figured out a way by using the vtkAxesActor class directly.
>
> An example script:
>
> from paraview.simple import *
> paraview.simple._DisableFirstRenderCameraReset()
>
> renderView1 = GetActiveViewOrCreate('RenderView')
>
> sphere1 = Sphere()
> sphere1.Radius = 1.0
> sphere1Display = Show(sphere1, renderView1)
> sphere1Display.SetRepresentationType('Outline')
>
> import vtk
> renderer = renderView1.GetRenderer()
> axes = vtk.vtkAxesActor()
>
> #axes.SetAxisLabels(0) # 0/1 to turn off/on axis labels
>
> transform = vtk.vtkTransform()
> transform.Translate(-1.0, -1.0, -1.0)
> transform.Scale(0.75, 0.75, 0.75)
> axes.SetUserTransform(transform)
>
> tprop = vtk.vtkTextProperty()
> #tprop.SetFontSize(6) # seems to be overriden by vtkCaptionActor2D
> tprop.SetBold(1)
> tprop.SetItalic(0)
> tprop.SetColor(1.0, 1.0, 1.0)
> tprop.SetOpacity(1.0)
> tprop.SetFontFamilyToTimes()
>
> for label in [
>         axes.GetXAxisCaptionActor2D(),
>         axes.GetYAxisCaptionActor2D(),
>         axes.GetZAxisCaptionActor2D(),
>         ]:
>     # set Positoin2
>     label.SetWidth(label.GetWidth() * 0.5)
>     label.SetHeight(label.GetHeight() * 0.5)
>     label.SetCaptionTextProperty(tprop)
>
> renderer.AddActor(axes)
>
> Interact()
>
>
> On Sat, Apr 8, 2017 at 4:08 PM, Liang Wang <frank0734 at gmail.com> wrote:
>
>> From http://public.kitware.com/pipermail/paraview/2010-July/018081.html
>> it was not possible back then to change the size of orientation axes.
>>
>> Is it possible now, hopefully through Python, too?
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170408/6de77386/attachment.html>


More information about the ParaView mailing list