# Zoom Close To Data

**URL:** https://discourse.paraview.org/t/zoom-close-to-data/5752
**Category:** Development
**Tags:** proposal
**Created:** [November 9, 2020, 3:38pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752 "2020-11-09T15:38:04Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![LfxPaul](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lfxpaul/32/3703_2.png) [@LfxPaul](https://discourse.paraview.org/u/LfxPaul)
#### Post date: [November 9, 2020, 3:38pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/1 "2020-11-09T15:38:04Z")

</div>

This post is here to talk about a new button to zoom close to the active data.

The already existing “Zoom To Data” button computes the camera distance as a constant that depends on the radius of the bounding box. The problem with this behavior is when the user wants to view a data described by an elongated bounding box : when the view is oriented along the direction of the bounding box, the button do not really “zoom” to data as the distance of the camera is very large due to the size of the bounding box.

The image below explains this behavior. Each column represent 3 angles of view of a fixed length cylinder (length = 1 to length = 100 from left to right). You can notice that in the bottom image of the longest cylinder, the view could zoom in a lot more to fit the data).

 ![zoomFactor](https://discourse.paraview.org/uploads/default/original/2X/a/ae36a453b5c7abcbdfc1db33d575347b03159760.png)

We propose here a new button “Zoom Close To Data” that fits the data in the screen in the direction of the view. The image below compare the button “Zoom To Data” (top row) and “Zoom Close To Data” (bottom row) for a cylinder with a length = 100

 ![zoomCloseToData](https://discourse.paraview.org/uploads/default/original/2X/b/b30deb5c169a5bac639e060a10c5494c69a7d3aa.png)

Feel free to discuss / share your ideas about this !

@cory.quammen @mwestphal

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [November 9, 2020, 3:49pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/2 "2020-11-09T15:49:57Z")

</div>

I think this is a good idea. One question: in the “Zoom Close To Data” example on the bottom right, why is the right side of the cylinder in the center of the image instead of the upper right, as one might expect?

Another thought - instead of introducing this as a new Zoom mode, why not replace the current zoom with the closer zoom? It would avoid having to explain to people “well, Zoom To Data doesn’t zoom real close enough, so you can use the other Zoom Close To Data button that does”. I think this is more of a fix for Zoom To Data than it is a new feature.

---

<div class="post-metadata">

### Author: ![LfxPaul](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lfxpaul/32/3703_2.png) [@LfxPaul](https://discourse.paraview.org/u/LfxPaul)
#### Post date: [November 9, 2020, 3:58pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/3 "2020-11-09T15:58:22Z")

</div>

The right side of the cylinder is in the center because the focal point stays at the center of the bounding box. We just compute the distance to make the closest side of the bounding box visible

I don’t know if we can replace the current zoom, because actually if the user move around the object after “Zoom To Data”, he can be sure that the data will be **always** visible. In case of a “Zoom Close To Data”, the object can go out of the scene when moving the camera

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [November 9, 2020, 4:16pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/4 "2020-11-09T16:16:07Z")

</div>

> [@LfxPaul](#):
>
> The right side of the cylinder is in the center because the focal point stays at the center of the bounding box. We just compute the distance to make the closest side of the bounding box visible

I think the result is as surprising as what Zoom To Data does currently, just in a different way, but indeed the zoom is closer.

Have you considered using a screen-space bounding box to determine the zoom and pan? Seems like that would work better and be more intuitive than fitting the closest face of the bounding box.

> [@LfxPaul](#):
>
> I don’t know if we can replace the current zoom, because actually if the user move around the object after “Zoom To Data”, he can be sure that the data will be **always** visible. In case of a “Zoom Close To Data”, the object can go out of the scene when moving the camera

Do we make the claim somewhere that “Zoom To Data” guarantees that the data is always regardless of rotation? I don’t think so. I think people just want to fill the screen with data when “Zoom To Data” is clicked, and your new approach gets closer to that goal.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 9, 2020, 4:22pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/5 "2020-11-09T16:22:49Z")

</div>

> Do we make the claim somewhere that “Zoom To Data” guarantees that the data is always regardless of rotation? I don’t think so. I think people just want to fill the screen with data when “Zoom To Data” is clicked, and your new approach gets closer to that goal.

No, but a user could rely on this behavior.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [November 9, 2020, 4:27pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/6 "2020-11-09T16:27:23Z")

</div>

Fair enough. I just want to make sure yet another zoom button is required.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [November 10, 2020, 2:59am UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/7 "2020-11-10T02:59:09Z")

</div>

Thanks to Cory for helping me understand the issue.

Question: What is the difference between “Reset” and “Zoom to Data”? It appears to me that they do the same thing. I NEVER use Zoom to Data, again, because I don’t know what it does.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [November 10, 2020, 2:59am UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/8 "2020-11-10T02:59:20Z")

</div>

@Kenneth_Moreland

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [November 10, 2020, 4:48am UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/9 "2020-11-10T04:48:06Z")

</div>

“Reset” resets the camera so the bounding box of ALL objects in the view fill the screen. “Zoom to Data” resets the camera so that the bounding box of the ACTIVE source in the pipeline fills the screen.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [November 10, 2020, 6:55am UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/10 "2020-11-10T06:55:18Z")

</div>

OK, now that makes sense. In my mind, the “Zoom to Data” resets the camera to the bounding box of the ACTIVE Filter/Source/Reader (I know, Source is overloaded in the discussion above).

After rewriting this three times, I want to ponder further.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 10, 2020, 2:25pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/11 "2020-11-10T14:25:18Z")

</div>

So we will go forward with adding a new button, ideally with the implementation suggested by @cory.quammen.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [November 10, 2020, 6:35pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/12 "2020-11-10T18:35:29Z")

</div>

I am undecided with regards to this new button. The reason is that I believe this functionality is missing in ParaView, but it is very rarely needed. Furthermore, the solution is trivial - you click Reset, and zoom out. Do we really want Yet Another Icon for something that is not (frequently) needed?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 12, 2020, 9:37am UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/13 "2020-11-12T09:37:31Z")

</div>

We have users asking for it.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [November 12, 2020, 10:13am UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/14 "2020-11-12T10:13:33Z")

</div>

Is it acceptable to have a single button and control the behavior in the settings ?  
Or maybe change the behavior when a modifier (ctrl / alt /shift / …) is pressed ?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 12, 2020, 12:18pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/15 "2020-11-12T12:18:24Z")

</div>

A modifier for a tool button is unheard of in ParaView.

A setting would be ok, even if it hides the feature to potential users.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [November 12, 2020, 3:28pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/16 "2020-11-12T15:28:43Z")

</div>

> [@mwestphal](#):
>
> A modifier for a tool button is unheard of in ParaView.

The “Capture Screenshot to the clipboard” toolbutton saves to a file if Ctrl is pressed instead of copying to the clipboard, so there is precedent.

> [@nicolas.vuaille](#):
>
> Is it acceptable to have a single button and control the behavior in the settings ?

I really don’t like this idea. It hides the zoom mode, and makes Python tracing of a zoom that much harder.

I’d vote to just add new tool buttons. However you implement the new mode, you may want to do it for both the whole scene bounding box and have another button to do it for the active source.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 12, 2020, 4:15pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/17 "2020-11-12T16:15:42Z")

</div>

> > [@mwestphal](#):
> >
> > A modifier for a tool button is unheard of in ParaView.
> 
> The “Capture Screenshot to the clipboard” toolbutton saves to a file if Ctrl is pressed instead of copying to the clipboard, so there is precedent.

Right ! Forgot this one.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [November 12, 2020, 5:08pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/18 "2020-11-12T17:08:02Z")

</div>

OK, if users are asking for it, I agree we should implement it. I also would rather we have a second (or in this case third) button rather than overloading one button. Overloading buttons is confusing.

---

<div class="post-metadata">

### Author: ![LfxPaul](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lfxpaul/32/3703_2.png) [@LfxPaul](https://discourse.paraview.org/u/LfxPaul)
#### Post date: [November 13, 2020, 9:49am UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/19 "2020-11-13T09:49:25Z")

</div>

OK so if you are all agree with this idea, we go for **two new buttons** (one to zoom on active data and one to zoom on all bounds), as this is a new functionality and can be asked by some users.

Considering the implementation, I thought to do, from Cory’s idea :

- Still set the focal point as the center of the bounding box (not quite sure here, we could maybe use as focal point the center of the screen space bounding bounding box, with a Z equals to maxZ - minZ / 2.0)
- Project all the bounding box points in screen space, get the two min/max points
- Reproject these 2 points in world space, using for the Z coordinate the minimum z of the bbox in world space
- Adjust camera distance so that these 2 points lie in the camera field of view

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [November 13, 2020, 9:03pm UTC](https://discourse.paraview.org/t/zoom-close-to-data/5752/20 "2020-11-13T21:03:40Z")

</div>

That sounds reasonable at first reading.

[Next page](https://discourse.paraview.org/t/zoom-close-to-data/5752.md?page=2)
