Implementing a Zoom To previous/Zoom Next functionality

Any question about the main GUI application (frontend)
vinayan
Posts: 27
Joined: Thu Nov 03, 2016 4:11 pm

Implementing a Zoom To previous/Zoom Next functionality

Postby vinayan » Thu Nov 09, 2017 5:24 am

hi Daniel,

I was thinking of implementing a functionality that lets users undo the zoom and pan operations. Sometimes we hit the zoom to whole cloud extent or do several pan/zoom it would be good if we could just go back to the extent where it was. My idea was to store the camera parameter for the last 10 views and move back and forth between them using "View Previous/View Next" buttons in some toolbar.

Browsing the source, I found the zoom is handled here..

Code: Select all

void ccGLWindow::setZoom(float value)

and pan is handled here..

Code: Select all

void ccGLWindow::setCameraPos(const CCVector3d& P)


So an array inside ccGLWindow could possible store these camera parameters.

The issue that i noticed was that when mousewheel is scrolled, the zoom is activated for each movement of the wheel. For example the user does a huge scroll fast, this method could get called about 10 times in a second like shown below.
Zoomprevious.png
Zoomprevious.png (8.35 KiB) Viewed 53 times


So something that lets us know that user has not finished his scrolling/panning would be helpful in storing these intermediate values.

Please share your views.
thanks
Vinayan

daniel
Site Admin
Posts: 3327
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Implementing a Zoom To previous/Zoom Next functionality

Postby daniel » Fri Nov 10, 2017 8:40 am

Interesting feature. Another more generic way to implement this would be to save the whole 'viewport' (see the 'm_viewportParams' parameter of ccGLWindow). It stores all the parameters (zoom, pan, rotation, etc.). You just have to call 'setViewportParameters' to reset them back to a previous state (properly ;) ).

For the wheel events... I guess you'll need a (single shot) timer (see http://doc.qt.io/qt-5/qtimer.html)? Each time the setZoom method is called, you (re)start the timer with a timeout like 5 seconds so that it's not triggered if the wheel or the +/- keys are operated many times in a row.

This timer should be a member of the ccGLWindow class that is connected to a 'pushViewport' or equivalent slot of this class. The 'pushViewport' function will handle the circular buffer to store the 10 last viewports. I guess it can be called in various places in the code (the 'setCameraPos' function as you said, but maybe elsewhere?).
Daniel, CloudCompare admin

vinayan
Posts: 27
Joined: Thu Nov 03, 2016 4:11 pm

Re: Implementing a Zoom To previous/Zoom Next functionality

Postby vinayan » Fri Nov 10, 2017 9:40 am

hi Daniel,

thanks for the suggestions. I would try to get this done possibly with a pull request in the near future.


Return to “CloudCompare”

Who is online

Users browsing this forum: No registered users and 1 guest