Debian Codegraph @

vcg/wrap/qt/trackball.h

raw symbols SCIP
1 /****************************************************************************
2 * VCGLib o o *
3 * Visual and Computer Graphics Library o o *
4 * _ O _ *
5 * Copyright(C) 2007 \/)\/ *
6 * Visual Computing Lab /\/| *
7 * ISTI - Italian National Research Council | *
8 * \ *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
20 * for more details. *
21 * *
22 ****************************************************************************/
23 /****************************************************************************
24 History
25
26 $Log: trackball.h,v $
27
28 ****************************************************************************/
29
30 #ifndef QT_TRACKBALL_H
31 #define QT_TRACKBALL_H
32
33 /// Takes a QT MouseButton, some QT KeyboardModifiers and returns the equivalent Trackball::Button
34 static vcg::Trackball::Button QT2VCG (Qt::MouseButton qtbt, Qt::KeyboardModifiers modifiers)
35 {
36 int vcgbt = vcg::Trackball::BUTTON_NONE;
37
38 if (qtbt & Qt::LeftButton) vcgbt |= vcg::Trackball::BUTTON_LEFT;
39 if (qtbt & Qt::RightButton) vcgbt |= vcg::Trackball::BUTTON_RIGHT;
40 if (qtbt & Qt::MidButton) vcgbt |= vcg::Trackball::BUTTON_MIDDLE;
41
42 if (modifiers & Qt::ShiftModifier) vcgbt |= vcg::Trackball::KEY_SHIFT;
43 if (modifiers & Qt::ControlModifier) vcgbt |= vcg::Trackball::KEY_CTRL;
44 if (modifiers & Qt::AltModifier) vcgbt |= vcg::Trackball::KEY_ALT;
45
46 return vcg::Trackball::Button (vcgbt);
47 }
48
49 /// Takes some QT KeyboardModifiers and returns the mouse wheel related Trackball::Button
50 static vcg::Trackball::Button QTWheel2VCG (Qt::KeyboardModifiers modifiers)
51 {
52 int vcgbt = vcg::Trackball::WHEEL;
53
54 if (modifiers & Qt::ShiftModifier) vcgbt |= vcg::Trackball::KEY_SHIFT;
55 if (modifiers & Qt::ControlModifier) vcgbt |= vcg::Trackball::KEY_CTRL;
56 if (modifiers & Qt::AltModifier) vcgbt |= vcg::Trackball::KEY_ALT;
57
58 return vcg::Trackball::Button (vcgbt);
59 }
60
61 #endif // QT_TRACKBALL_H