File: scene3d.cpp

package info (click to toggle)
sight 25.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 42,180 kB
  • sloc: cpp: 289,476; xml: 17,257; ansic: 9,878; python: 1,379; sh: 144; makefile: 33
file content (60 lines) | stat: -rw-r--r-- 2,288 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/************************************************************************
 *
 * Copyright (C) 2023 IRCAD France
 *
 * This file is part of Sight.
 *
 * Sight is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Sight is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
 *
 ***********************************************************************/

#include "scene3d.hpp"

namespace sight::ui::test::helper
{

//------------------------------------------------------------------------------

void scene3d::rotate(tester& _tester, const selector& _scene, QPointF _rotation)
{
    auto bt = _tester.add_in_backtrace(
        "rotating \"" + _scene.get_description(_tester) + "\" scene by (" + std::to_string(_rotation.x())
        + ", " + std::to_string(_rotation.y()) + ')'
    );
    _scene.select(_tester);
    const QWidget* s = _tester.get<QWidget*>();
    int rotation_x   = _rotation.x() == 0 ? 0 : static_cast<int>(s->width() * _rotation.x());
    int rotation_y   = _rotation.y() == 0 ? 0 : static_cast<int>(s->height() * _rotation.y());
    _tester.interact(
        std::make_unique<mouse_drag>(
            tester::left_of(s),
            tester::left_of(s) + QPoint(rotation_x, rotation_y)
        )
    );
}

//------------------------------------------------------------------------------

void scene3d::zoom(tester& _tester, const selector& _scene, int _mouse_steps)
{
    auto bt = _tester.add_in_backtrace(
        "zooming \"" + _scene.get_description(_tester) + "\" scene by " + std::to_string(_mouse_steps) + " mouse steps"
    );
    _scene.select(_tester);
    _tester.interact(
        std::make_unique<mouse_wheel>(QPoint(0, static_cast<int>(_mouse_steps * 120 / qApp->devicePixelRatio())))
    );
}

} // namespace sight::ui::test::helper