ganeswidgets/inc/hgquad.h
changeset 0 89c329efa980
child 5 4fa04caf0f43
equal deleted inserted replaced
-1:000000000000 0:89c329efa980
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef HGQUAD_H
       
    19 #define HGQUAD_H
       
    20 
       
    21 #include <qvector3d>
       
    22 #include <qvector2d>
       
    23 #include <qquaternion>
       
    24 #include <qvariant>
       
    25 
       
    26 class HgImage;
       
    27 
       
    28 /**
       
    29  * Quad class to be used by HgQuadRenderer.
       
    30  */
       
    31 class HgQuad
       
    32 {
       
    33 public:
       
    34     /**
       
    35      * Constructor.
       
    36      */
       
    37     HgQuad();
       
    38     /**
       
    39      * Destructor.
       
    40      */
       
    41     virtual ~HgQuad();
       
    42     /**
       
    43      * Sets the position of the quad.
       
    44      * @param position in 3D space.
       
    45      */
       
    46     void setPosition(const QVector3D& position);
       
    47     /**
       
    48      * Sets the rotation of the quad.
       
    49      * @param rotation as quaternion.
       
    50      */
       
    51     void setRotation(const QQuaternion& rotation);
       
    52     /**
       
    53      * Sets the image to use in this quad.
       
    54      * @param image to use in this quad.
       
    55      */
       
    56     void setImage(const HgImage* image);
       
    57     /**
       
    58      * Toggles quads visible/hidden.
       
    59      * @param visible true to make quad visible.
       
    60      */
       
    61     void setVisible(bool visible);
       
    62     /**
       
    63      * Sets the pivot point of the quad.
       
    64      * @pivot to set for this quad. Quads are considered unit quads so to set pivot for example,
       
    65      * to bottom left corner you would use QVector2D(-0.5f, -0.5f).
       
    66      */
       
    67     void setPivot(const QVector2D& pivot);
       
    68     /**
       
    69      * Sets the scale of the quad.
       
    70      * @param scale scaling 2d vector (appliend before rotation but after pivot is transformed)
       
    71      */
       
    72     void setScale(const QVector2D& scale);
       
    73     /**
       
    74      * Sets user data to this quad.
       
    75      * @param userdata to be carried in this quad. This can be for example to identify object that is represented by this specific quad instance.
       
    76      */
       
    77     void setUserData(const QVariant& data);
       
    78     /**
       
    79      * Gets the image in this quad.
       
    80      * @return pointer HgImage-object carried by this quad.
       
    81      */
       
    82     const HgImage* image() const;
       
    83     /**
       
    84      * Gets the position of this quad.
       
    85      * @return position vector.
       
    86      */
       
    87     const QVector3D& position() const;
       
    88     /**
       
    89      * Gets the roation of this quad.
       
    90      * @return rotation quaternion.
       
    91      */
       
    92     const QQuaternion& rotation() const;
       
    93     /**
       
    94      * Tells whether or not this quad is visible and should be rendered.
       
    95      * @return true if this quad is visible and should be rendered.
       
    96      */
       
    97     bool visible() const;
       
    98     /**
       
    99      * Gets the pivot point of this quad.
       
   100      * @return pivot point applied to this quads trasformation.
       
   101      */
       
   102     const QVector2D& pivot() const;
       
   103     /**
       
   104      * Gets the scale of this quad.
       
   105      * @return scaling applied to this quads transformation.
       
   106      */
       
   107     const QVector2D& scale() const;
       
   108     /**
       
   109      * Gets the user data associated in to this quad.
       
   110      * @return user data carriend by this quad.
       
   111      */
       
   112     const QVariant& userData() const;
       
   113     /**
       
   114      * 
       
   115      */
       
   116     HgQuad* copy() const;
       
   117     /**
       
   118      * 
       
   119      */
       
   120     void copyFrom(const HgQuad& quad);
       
   121     /*
       
   122      * 
       
   123      */
       
   124     void setOuterRotation(const QQuaternion& rot);
       
   125     /*
       
   126      * 
       
   127      */
       
   128     const QQuaternion outerRotation() const;
       
   129     /**
       
   130      * 
       
   131      */
       
   132     void enableMirrorImage(bool enabled);
       
   133     /**
       
   134      * 
       
   135      */
       
   136     bool mirrorImageEnabled() const;
       
   137     /**
       
   138      * 
       
   139      */
       
   140     void setAlpha(qreal alpha);
       
   141     /**
       
   142      * 
       
   143      */
       
   144     qreal alpha() const;
       
   145 private:    
       
   146     QVector3D mPosition;
       
   147     QQuaternion mRotation;
       
   148     const HgImage* mImage;
       
   149     bool mVisible;
       
   150     QVector2D mPivot;
       
   151     QVector2D mScale;
       
   152     QVariant mUserData;
       
   153     QQuaternion mOuterRotation;
       
   154     bool mDrawMirror;
       
   155     qreal mAlpha;
       
   156 private:
       
   157     Q_DISABLE_COPY(HgQuad)
       
   158 };
       
   159 
       
   160 
       
   161 #endif