Active Topics

 


Reply
Thread Tools
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#11
Originally Posted by marxian View Post
The zoom values are not meant to be absolute, but relative to the previous value.
That would be consistent with the OP's experience. I would approach it as a matrix, rows for the previous and columns for the new zoom level:

Code:
void MainWindow::zoomSlider(int newLevel)
{
    static const qreal zoomMatrix[5][5] =
    {
        // Matrix initialized to zoom in and out by a factor of 1.5.
        // To use a different factor, change the numbers.
        // You can even use a variable factor, to allow e.g.
        // logarithmic or exponential zoom.
        { 0.0000, 1.5000, 2.2500, 3.3750, 5.0625 },
        { 0.6667, 0.0000, 1.5000, 2.2500, 3.3750 },
        { 0.4444, 0.6667, 0.0000, 1.5000, 2.2500 },
        { 0.2963, 0.4444, 0.6667, 0.0000, 1.5000 },
        { 0.1975, 0.2963, 0.4444, 0.6667, 0.0000 }
    };
    qreal zoom = zoomMatrix[oldLevel][newLevel];

    getCurrentImageArea()->zoomImage(zoom);
    getCurrentImageArea()->setZoomFactor(zoom);

    oldLevel = newLevel;
}
Disclaimer: The above code is not tested, and could be completely wrong.
 

The Following User Says Thank You to pichlo For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 09:38.