Types.hh 7.81 KB
Newer Older
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
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
 *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.openflipper.org                             *
 *                                                                           *
 *---------------------------------------------------------------------------*
 *  This file is part of OpenFlipper.                                        *
 *                                                                           *
 *  OpenFlipper 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 with the              *
 *  following exceptions:                                                    *
 *                                                                           *
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
 *                                                                           *
 *  OpenFlipper 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 LesserGeneral Public          *
 *  License along with OpenFlipper. If not,                                  *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
 *   $Revision$                                                         *
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60




//=============================================================================
//
//  Types
//
//=============================================================================

/**
 * \file Types.hh
 * This File contains the basic available datatypes in the Framework.
 */


#ifndef TYPES_HH
#define TYPES_HH

Jan Möbius's avatar
Jan Möbius committed
61
#include <OpenFlipper/common/GlobalDefines.hh>
62
#include <limits.h>
63
#include <QIcon>
64 65 66 67


//== Global Typedefs  =================================================================

68
/** \brief Predefined datatypes
69
 *
70
 * Here are several datatypes which have predefined ids. This might be changed to runtime added
71
 * datatypes in the future.
72
 */
73 74

/// None of the other Objects
75
#define DATA_UNKNOWN 0
76 77

/// Items used for Grouping
78
#define DATA_GROUP 1
79 80

/// Triangle Mesh objects
81
#define DATA_TRIANGLE_MESH typeId("TriangleMesh")
82
#define DATA_TRIANGLE_MESH_CONST_ID 2
83 84

/// Poly Mesh Objects
85
#define DATA_POLY_MESH typeId("PolyMesh")
86
#define DATA_POLY_MESH_CONST_ID 4
87

88 89 90 91
/// Identifier for all available objects
const unsigned int DATA_ALL           = UINT_MAX;

typedef unsigned int DataType;
Jan Möbius's avatar
Jan Möbius committed
92 93

// TODO: Make types runtime addable
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

//== INCLUDES =================================================================

#include "BaseObject.hh"
#include "GroupObject.hh"
#include "BaseObjectData.hh"

//== TYPEDEFS =================================================================

/// Standard Type for 3d Vector used for scripting
typedef ACG::Vec3d Vector;
/// Standard Type for id Lists used for scripting
typedef std::vector< int > idList;
/// Standard Type for a 4x4 Matrix used for scripting
typedef ACG::Matrix4x4d Matrix4x4;

Q_DECLARE_METATYPE(idList);
Q_DECLARE_METATYPE(QVector< int >);
Q_DECLARE_METATYPE(Vector);
Q_DECLARE_METATYPE(Matrix4x4);

/// Vector Type containing the Data Objects
typedef std::vector<BaseObjectData*> DataContainer;

118 119 120 121
//================================================================================================
/** @name Functions for adding dataTypes
* @{ */
//================================================================================================
122

123
/** Adds a datatype and returns the id for the new type
124
*
125 126 127
* @param _name Internal name for the new DataType
* @param _readableName Human readable Name for this type ( Use tr to make it translatable )
*/
128
DLLEXPORT
129
DataType addDataType(QString _name, QString _readableName);
130 131

/// Given a dataType Identifier string this function will return the id of the datatype
132
DLLEXPORT
133
DataType typeId(QString _name);
134

135 136 137 138 139
/** \brief Get the name of a type with given id
*
* The ids are organized in a bitfield. So use either the macro for getting the type id or
* use the id directly (they have to be power of 2! ... Bitfield)
*/
140
DLLEXPORT
141 142
QString typeName(DataType _id);

143 144 145 146 147 148 149 150 151 152
/** \brief Get the number of registered types
*
* This function will return the number of types registered to the core. You can use it to
* iterate over all types. 
*
* \Note Remember that the types are organized in a bitfield!
*/
DLLEXPORT 
uint typeCount();

153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
/** @} */

//================================================================================================
/** @name Datatype Name handling
* @{ */
//================================================================================================

/// Get DataType Human readable name ( this name might change. Use the typeName insted! )
DLLEXPORT
QString dataTypeName( DataType _id );

/// Get DataType Human readable name ( this name might change. Use the typeName insted! )
DLLEXPORT
QString dataTypeName( QString _typeName);

/// Set DataType Human readable name
DLLEXPORT
void setDataTypeName( DataType _id, QString _name );

/// Set DataType Human readable name
DLLEXPORT
void setDataTypeName( QString _typeName, QString _name );


/** @} */

179 180 181 182 183
//================================================================================================
/** @name Datatype Icons
* @{ */
//================================================================================================

184
/// Get a string with the filename of the icon for the DataType name
185
DLLEXPORT
186
QString typeIconName(QString  _name);
187

188
/// Get a string with the filename of the icon for the DataType
189
DLLEXPORT
190 191 192 193 194 195 196 197 198
QString typeIconName(DataType _id);

/** \brief Get an QIcon associated with the given datatype
* 
* The icons are loaded once when set and then the reference is returned here.
* This reduces the time when frequently requesting the icons (e.g. DataControl)
*/
DLLEXPORT
QIcon& typeIcon(DataType _id);
199 200

/// Set an Icon for a given DataType
201
DLLEXPORT
202
void setTypeIcon( DataType _id   , QString _icon);
203

204
/// Set an Icon for a given DataType
205
DLLEXPORT
206 207 208 209 210
void setTypeIcon( QString  _name , QString _icon );

/** @} */


211 212 213
//=============================================================================
#endif // TYPES_HH defined
//=============================================================================