# Dynamically change position of Axes

**URL:** https://discourse.vtk.org/t/dynamically-change-position-of-axes/691
**Category:** Support
**Created:** [April 5, 2019, 12:43pm UTC](https://discourse.vtk.org/t/dynamically-change-position-of-axes/691 "2019-04-05T12:43:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![fern17](https://discourse.vtk.org/user_avatar/discourse.vtk.org/fern17/32/44_2.png) [@fern17](https://discourse.vtk.org/u/fern17)
#### Post date: [April 5, 2019, 12:43pm UTC](https://discourse.vtk.org/t/dynamically-change-position-of-axes/691/1 "2019-04-05T12:43:17Z")

</div>

Hello.  
I’m trying to control the position of the Axes (vtkOrientationMarkerWidget).  
In our interface, there should be an option to change the position with 4 possible values: Bottom left, bottom right, top left, top right).  
I know that I can set the position of the vtkOrientationMarkerWidget with the call to setViewport, but that seems to only work the first time.

I’m using VTK 7.1.1 with Visual Studio 2010.  
Here a snippet of my code:

> ```
> // initialization, in constructor of the class that handle the vtkRenderer. All with m_ are properties of the class.
> // Axes actor
> m_axesActor = vtkSmartPointer<vtkAxesActor>::New();
> m_axesActor->SetPickable(0);
> // Orientation marker that synchronizes its orientation with the camera position.
> m_widget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
> m_widget->SetInteractor(m_renderWindowInteractor); // vtkSmartPointer<vtkRenderWindowInteractor>, interactor of the render window.
> m_widget->SetOrientationMarker( m_axesActor );
> m_widget->SetViewport(0, 0, 0.4, 0.4); // bottom left, works OK.
> m_widget->SetEnabled(1);
> m_widget->InteractiveOff(); // i don't want to be interactable...
> // After, in method to change the position:
> void changePosition(int position)
> {
> // This has no effect
> if (position == AXES_POSITION_BOTTOM_LEFT)
> m_widget->SetViewport(0, 0, 0.4, 0.4);
> else if (position == AXES_POSITION_BOTTOM_RIGHT)
> m_widget->SetViewport(0.6, 0.6, 1.0, 1.0);
> else if (position == AXES_POSITION_TOP_LEFT)
> m_widget->SetViewport(0, 0.6, 0.4, 1.0);
> else if (position == AXES_POSITION_TOP_RIGHT)
> m_widget->SetViewport(0.6, 0.6, 1.0, 1.0);
> // more code follows, with calls to redraw and sort...
> }
> 
> ```

Thank you.

---

<div class="post-metadata">

### Author: ![fern17](https://discourse.vtk.org/user_avatar/discourse.vtk.org/fern17/32/44_2.png) [@fern17](https://discourse.vtk.org/u/fern17)
#### Post date: [April 12, 2019, 10:51am UTC](https://discourse.vtk.org/t/dynamically-change-position-of-axes/691/2 "2019-04-12T10:51:04Z")

</div>

Finally I solved it by myself.  
The secret was to call SetEnabled(0) before changing the position with SetViewport. Then you should call SetEnabled(1).  
Thanks.
