# Orientation Widget "Padding"

**URL:** https://discourse.vtk.org/t/orientation-widget-padding/2546
**Category:** Support
**Created:** [February 5, 2020, 5:13am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546 "2020-02-05T05:13:33Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![ChristopherWaters](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@ChristopherWaters](https://discourse.vtk.org/u/ChristopherWaters)
#### Post date: [February 5, 2020, 5:13am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/1 "2020-02-05T05:13:33Z")

</div>

**Currently:**

- I have implemented an orientation widget into my application using:

```cpp
orientationWidget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
axes = vtkSmartPointer<vtkAxesActor>::New();
orientationWidget->SetOrientationMarker(axes);
orientationWidget->SetInteractor(myInteractor);
orientationWidget->SetViewport(0.833, 0.744, 1, 1);
orientationWidget->SetEnabled(1);
orientationWidget->SetInteractive(0);

```

- Which produces this:

![capture](https://discourse.vtk.org/uploads/default/original/2X/e/e32736b3a02d9fb2fb09a5c5fdd549d09764140b.png)

**Problem:**

- I **want to squeeze the actor closer to the corner of the window** (up+right) but cannot manage to do so by messing with the view port.
- When I enable interactivity and see an outline of the widget, some sort of padding is in place which leaves substantial negative space around the actor within the widget
- **What is the source of the padding?** (I cannot find any indication in `vtkOrientationWidget.cxx`)

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 5, 2020, 5:30am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/2 "2020-02-05T05:30:56Z")

</div>

We have come across this problem in 3D Slicer, too, and fixed it here:

> <https://github.com/Slicer/Slicer/blob/master/Libs/MRML/DisplayableManager/vtkMRMLOrientationMarkerDisplayableManager.cxx#L62-L87>

When we implemented this fix we didn’t have time to contribute this back to VTK. It would be nice if you could do it.

---

<div class="post-metadata">

### Author: ![ChristopherWaters](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@ChristopherWaters](https://discourse.vtk.org/u/ChristopherWaters)
#### Post date: [February 5, 2020, 7:49am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/3 "2020-02-05T07:49:49Z")

</div>

Worked perfectly, thank you VTK Wizard.

In terms of contributing back, do you mean replacing the current `vtkAxesActor::GetBounds()` with this?

---

<div class="post-metadata">

### Author: ![ChristopherWaters](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@ChristopherWaters](https://discourse.vtk.org/u/ChristopherWaters)
#### Post date: [February 5, 2020, 8:00am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/4 "2020-02-05T08:00:43Z")

</div>

Also, now I notice that the vtkAxesActor is not accurate when compared to the 3D environment.

 ![capture](https://discourse.vtk.org/uploads/default/original/2X/3/3d7bae8f25d77715ef2c114d716775d2169f6724.png)

I even turned off all of my camera overrides and this still occurs. Do you know what could be causing this problem?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 5, 2020, 12:32pm UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/5 "2020-02-05T12:32:25Z")

</div>

Maybe you need to enable parallel projection.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [February 5, 2020, 2:32pm UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/6 "2020-02-05T14:32:13Z")

</div>

> [@ChristopherWaters](#):
>
> Also, now I notice that the vtkAxesActor is not accurate when compared to the 3D environment.
> 
> ![capture](https://discourse.vtk.org/uploads/default/original/2X/3/3d7bae8f25d77715ef2c114d716775d2169f6724.png)
> 
> I even turned off all of my camera overrides and this still occurs. Do you know what could be causing this problem?

You can either use orthographic projection like @lassoan suggested, which is easier to do. Or, if you want to stick to perspective projection, you can narrow down the FOV angle to reduce the visual discrepancy between the main scene and the orientation axes. Decreasing the FOV angle will do a zoom-in, then you have to dolly (translate) the camera backwards to compensate.

---

<div class="post-metadata">

### Author: ![ChristopherWaters](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@ChristopherWaters](https://discourse.vtk.org/u/ChristopherWaters)
#### Post date: [February 6, 2020, 1:03am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/8 "2020-02-06T01:03:19Z")

</div>

Would there be any other way to remedy the issue?

I need the camera to use perspective projection (parallel doesn’t seem to even fix the issue), and lowering the camera viewing angle all the way down to 5 doesn’t really hide the dependencies that well…

(I can think of many 3D modeling applications and video game engines that use perspective projection and still have accurate axes)

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 6, 2020, 1:07am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/9 "2020-02-06T01:07:46Z")

</div>

You can keep using perspective projection for your main 3D content and keep using parallel projection for rendering the orientation widget. You can give this a try in 3D Slicer.

---

<div class="post-metadata">

### Author: ![ChristopherWaters](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@ChristopherWaters](https://discourse.vtk.org/u/ChristopherWaters)
#### Post date: [February 6, 2020, 1:31am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/10 "2020-02-06T01:31:47Z")

</div>

What would be the best way to exclusively set the projection mode of the orientation widget.

When I try give it a new **separate** camera it either crashes my application if done so before I set the interactor, or freeze my main camera if done afterwards…

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 6, 2020, 2:38am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/11 "2020-02-06T02:38:12Z")

</div>

You can find the full implementation at the link I posted above.

---

<div class="post-metadata">

### Author: ![ChristopherWaters](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@ChristopherWaters](https://discourse.vtk.org/u/ChristopherWaters)
#### Post date: [February 7, 2020, 4:40am UTC](https://discourse.vtk.org/t/orientation-widget-padding/2546/12 "2020-02-07T04:40:14Z")

</div>

Thanks to SetupWindowInteraction()

```cpp
  vtkCamera* pcam = this->CurrentRenderer->GetActiveCamera();
  vtkCamera* cam = this->Renderer->GetActiveCamera();
  if (pcam && cam)
  {
    cam->SetParallelProjection(pcam->GetParallelProjection());
  }

```

It is very simple to exclusively make the orientation widget use parallel projection, just set your main camera to parallel mode, create the widget, and then set the main camera back to perspective mode.
