# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlQt4/Qt4Widget.cpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.org                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
    00007 /*  All rights reserved.                                                              */
    00008 /*                                                                                    */
    00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
    00010 /*  are permitted provided that the following conditions are met:                     */
    00011 /*                                                                                    */
    00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
    00013 /*  list of conditions and the following disclaimer.                                  */
    00014 /*                                                                                    */
    00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
    00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
    00017 /*  other materials provided with the distribution.                                   */
    00018 /*                                                                                    */
    00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
    00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
    00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
    00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
    00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
    00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
    00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
    00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
    00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
    00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
    00029 /*                                                                                    */
    00030 /**************************************************************************************/
    00031
    00032 #include <vlQt4/Qt4Widget.hpp>
    00033 #include <vlCore/Log.hpp>
    00034
    00035 using namespace vl;
    00036 using namespace vlQt4;
    00037
    00038 void Qt4Widget::translateKeyEvent(QKeyEvent* ev, unsigned short& unicode_out, EKey& key_out)
    00039 {
    00040   // translate non unicode characters
    00041   key_out     = Key_None;
    00042   unicode_out = 0;
    00043
    00044   switch(ev->key())
    00045   {
    00046     case Qt::Key_Clear:    key_out = Key_Clear; break;
    00047     case Qt::Key_Control:  key_out = Key_Ctrl; break;
    00048     // case Qt::Key_LCONTROL: key_out = Key_LeftCtrl; break;
    00049     // case Qt::Key_RCONTROL: key_out = Key_RightCtrl; break;
    00050     case Qt::Key_Alt:     key_out = Key_Alt; break;
    00051     // case Qt::Key_LMENU:    key_out = Key_LeftAlt; break;
    00052     // case Qt::Key_RMENU:    key_out = Key_RightAlt; break;
    00053     case Qt::Key_Shift:    key_out = Key_Shift; break;
    00054     // case Qt::Key_LSHIFT:   key_out = Key_LeftShift; break;
    00055     // case Qt::Key_RSHIFT:   key_out = Key_RightShift; break;
    00056     case Qt::Key_Insert:   key_out = Key_Insert; break;
    00057     case Qt::Key_Delete:   key_out = Key_Delete; break;
    00058     case Qt::Key_Home:     key_out = Key_Home; break;
    00059     case Qt::Key_End:      key_out = Key_End; break;
    00060     case Qt::Key_Print:    key_out = Key_Print; break;
    00061     case Qt::Key_Pause:    key_out = Key_Pause; break;
    00062     case Qt::Key_PageUp:   key_out = Key_PageUp; break;
    00063     case Qt::Key_PageDown: key_out = Key_PageDown; break;
    00064     case Qt::Key_Left:     key_out = Key_Left; break;
    00065     case Qt::Key_Right:    key_out = Key_Right; break;
    00066     case Qt::Key_Up:       key_out = Key_Up; break;
    00067     case Qt::Key_Down:     key_out = Key_Down; break;
    00068     case Qt::Key_F1:       key_out = Key_F1; break;
    00069     case Qt::Key_F2:       key_out = Key_F2; break;
    00070     case Qt::Key_F3:       key_out = Key_F3; break;
    00071     case Qt::Key_F4:       key_out = Key_F4; break;
    00072     case Qt::Key_F5:       key_out = Key_F5; break;
    00073     case Qt::Key_F6:       key_out = Key_F6; break;
    00074     case Qt::Key_F7:       key_out = Key_F7; break;
    00075     case Qt::Key_F8:       key_out = Key_F8; break;
    00076     case Qt::Key_F9:       key_out = Key_F9; break;
    00077     case Qt::Key_F10:      key_out = Key_F10; break;
    00078     case Qt::Key_F11:      key_out = Key_F11; break;
    00079     case Qt::Key_F12:      key_out = Key_F12; break;
    00080
    00081     case Qt::Key_0: key_out = Key_0; break;
    00082     case Qt::Key_1: key_out = Key_1; break;
    00083     case Qt::Key_2: key_out = Key_2; break;
    00084     case Qt::Key_3: key_out = Key_3; break;
    00085     case Qt::Key_4: key_out = Key_4; break;
    00086     case Qt::Key_5: key_out = Key_5; break;
    00087     case Qt::Key_6: key_out = Key_6; break;
    00088     case Qt::Key_7: key_out = Key_7; break;
    00089     case Qt::Key_8: key_out = Key_8; break;
    00090     case Qt::Key_9: key_out = Key_9; break;
    00091
    00092     case Qt::Key_A: key_out = Key_A; break;
    00093     case Qt::Key_B: key_out = Key_B; break;
    00094     case Qt::Key_C: key_out = Key_C; break;
    00095     case Qt::Key_D: key_out = Key_D; break;
    00096     case Qt::Key_E: key_out = Key_E; break;
    00097     case Qt::Key_F: key_out = Key_F; break;
    00098     case Qt::Key_G: key_out = Key_G; break;
    00099     case Qt::Key_H: key_out = Key_H; break;
    00100     case Qt::Key_I: key_out = Key_I; break;
    00101     case Qt::Key_J: key_out = Key_J; break;
    00102     case Qt::Key_K: key_out = Key_K; break;
    00103     case Qt::Key_L: key_out = Key_L; break;
    00104     case Qt::Key_M: key_out = Key_M; break;
    00105     case Qt::Key_N: key_out = Key_N; break;
    00106     case Qt::Key_O: key_out = Key_O; break;
    00107     case Qt::Key_P: key_out = Key_P; break;
    00108     case Qt::Key_Q: key_out = Key_Q; break;
    00109     case Qt::Key_R: key_out = Key_R; break;
    00110     case Qt::Key_S: key_out = Key_S; break;
    00111     case Qt::Key_T: key_out = Key_T; break;
    00112     case Qt::Key_U: key_out = Key_U; break;
    00113     case Qt::Key_V: key_out = Key_V; break;
    00114     case Qt::Key_W: key_out = Key_W; break;
    00115     case Qt::Key_X: key_out = Key_X; break;
    00116     case Qt::Key_Y: key_out = Key_Y; break;
    00117     case Qt::Key_Z: key_out = Key_Z; break;
    00118   }
    00119
    00120   // fill unicode
    00121   QString ustring = ev->text();
    00122   if ( ustring.length() == 1 )
    00123   {
    00124     unicode_out = ustring[0].unicode();
    00125
    00126     // fill key
    00127     switch(unicode_out)
    00128     {
    00129       case L'0': key_out = Key_0; break;
    00130       case L'1': key_out = Key_1; break;
    00131       case L'2': key_out = Key_2; break;
    00132       case L'3': key_out = Key_3; break;
    00133       case L'4': key_out = Key_4; break;
    00134       case L'5': key_out = Key_5; break;
    00135       case L'6': key_out = Key_6; break;
    00136       case L'7': key_out = Key_7; break;
    00137       case L'8': key_out = Key_8; break;
    00138       case L'9': key_out = Key_9; break;
    00139
    00140       case L'A': key_out = Key_A; break;
    00141       case L'B': key_out = Key_B; break;
    00142       case L'C': key_out = Key_C; break;
    00143       case L'D': key_out = Key_D; break;
    00144       case L'E': key_out = Key_E; break;
    00145       case L'F': key_out = Key_F; break;
    00146       case L'G': key_out = Key_G; break;
    00147       case L'H': key_out = Key_H; break;
    00148       case L'I': key_out = Key_I; break;
    00149       case L'J': key_out = Key_J; break;
    00150       case L'K': key_out = Key_K; break;
    00151       case L'L': key_out = Key_L; break;
    00152       case L'M': key_out = Key_M; break;
    00153       case L'N': key_out = Key_N; break;
    00154       case L'O': key_out = Key_O; break;
    00155       case L'P': key_out = Key_P; break;
    00156       case L'Q': key_out = Key_Q; break;
    00157       case L'R': key_out = Key_R; break;
    00158       case L'S': key_out = Key_S; break;
    00159       case L'T': key_out = Key_T; break;
    00160       case L'U': key_out = Key_U; break;
    00161       case L'V': key_out = Key_V; break;
    00162       case L'W': key_out = Key_W; break;
    00163       case L'X': key_out = Key_X; break;
    00164       case L'Y': key_out = Key_Y; break;
    00165       case L'Z': key_out = Key_Z; break;
    00166
    00167       case L'a': key_out = Key_A; break;
    00168       case L'b': key_out = Key_B; break;
    00169       case L'c': key_out = Key_C; break;
    00170       case L'd': key_out = Key_D; break;
    00171       case L'e': key_out = Key_E; break;
    00172       case L'f': key_out = Key_F; break;
    00173       case L'g': key_out = Key_G; break;
    00174       case L'h': key_out = Key_H; break;
    00175       case L'i': key_out = Key_I; break;
    00176       case L'j': key_out = Key_J; break;
    00177       case L'k': key_out = Key_K; break;
    00178       case L'l': key_out = Key_L; break;
    00179       case L'm': key_out = Key_M; break;
    00180       case L'n': key_out = Key_N; break;
    00181       case L'o': key_out = Key_O; break;
    00182       case L'p': key_out = Key_P; break;
    00183       case L'q': key_out = Key_Q; break;
    00184       case L'r': key_out = Key_R; break;
    00185       case L's': key_out = Key_S; break;
    00186       case L't': key_out = Key_T; break;
    00187       case L'u': key_out = Key_U; break;
    00188       case L'v': key_out = Key_V; break;
    00189       case L'w': key_out = Key_W; break;
    00190       case L'x': key_out = Key_X; break;
    00191       case L'y': key_out = Key_Y; break;
    00192       case L'z': key_out = Key_Z; break;
    00193
    00194       case 13: key_out = Key_Return; break;
    00195       case 8: key_out = Key_BackSpace; break;
    00196       case 9: key_out = Key_Tab; break;
    00197       case L' ': key_out = Key_Space; break;
    00198
    00199       case 27: key_out = Key_Escape; break;
    00200       case L'!': key_out = Key_Exclam; break;
    00201       case L'"': key_out = Key_QuoteDbl; break;
    00202       case L'#': key_out = Key_Hash; break;
    00203       case L'$': key_out = Key_Dollar; break;
    00204       case L'&': key_out = Key_Ampersand; break;
    00205       case L'\'': key_out = Key_Quote; break;
    00206       case L'(': key_out = Key_LeftParen; break;
    00207       case L')': key_out = Key_RightParen; break;
    00208       case L'*': key_out = Key_Asterisk; break;
    00209       case L'+': key_out = Key_Plus; break;
    00210       case L',': key_out = Key_Comma; break;
    00211       case L'-': key_out = Key_Minus; break;
    00212       case L'.': key_out = Key_Period; break;
    00213       case L'\\': key_out = Key_Slash; break;
    00214       case L':': key_out = Key_Colon; break;
    00215       case L';': key_out = Key_Semicolon; break;
    00216       case L'<': key_out = Key_Less; break;
    00217       case L'=': key_out = Key_Equal; break;
    00218       case L'>': key_out = Key_Greater; break;
    00219       case L'?': key_out = Key_Question; break;
    00220       case L'@': key_out = Key_At; break;
    00221       case L'[': key_out = Key_LeftBracket; break;
    00222       case L'/': key_out = Key_BackSlash; break;
    00223       case L']': key_out = Key_RightBracket; break;
    00224       case L'|': key_out = Key_Caret; break;
    00225       case L'_': key_out = Key_Underscore; break;
    00226       case L'`': key_out = Key_QuoteLeft; break;
    00227     }
    00228   }
    00229 }
    00230 //-----------------------------------------------------------------------------

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:43:45.
Permission is granted to use this page to write and publish articles regarding Visualization Library.