UpdateType.hh 7.91 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1 2 3
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen       *
Jan Möbius's avatar
Jan Möbius committed
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
*                           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$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
\*===========================================================================*/

Dirk Wilden's avatar
Dirk Wilden committed
43 44 45 46

#ifndef UPDATETYPE_HH
#define UPDATETYPE_HH

Jan Möbius's avatar
Jan Möbius committed
47
#include <OpenFlipper/common/GlobalDefines.hh>
Jan Möbius's avatar
Jan Möbius committed
48
#include <bitset>
Dirk Wilden's avatar
Dirk Wilden committed
49

Jan Möbius's avatar
Jan Möbius committed
50
typedef std::bitset<64> UpdateTypeSet;
Dirk Wilden's avatar
Dirk Wilden committed
51

52 53 54 55 56 57 58 59 60 61
/** \brief Update type class
 *
 *
 *  This class is used to specify the scope of updates. There are update types for
 *  selection,geometry,topology,colors,... specified here: \ref DefaultUpdateTypes
 *
 *  You can also find functions to add custom update types at runtime at
 *  \ref UpdateTypeFunctions
 *
 */
Jan Möbius's avatar
Jan Möbius committed
62
class DLLEXPORT UpdateType {
Jan Möbius's avatar
Jan Möbius committed
63 64 65 66 67 68 69
  public:
    UpdateType(const UpdateType& _type);
    
    UpdateType(UpdateTypeSet _set);
    
    /// Exact compare operator
    bool operator==(const UpdateType& _type) const;
70 71 72 73

    UpdateType operator|(const UpdateType& _type) const;

    UpdateType& operator|=(const UpdateType& _type);
Jan Möbius's avatar
Jan Möbius committed
74 75 76 77 78 79
    
    UpdateType& operator++();
    
    bool operator<( const UpdateType& _i ) const;
    
    /// Check if this update contains the given UpdateType
80
    bool contains( const UpdateType& _type ) const;
Jan Möbius's avatar
Jan Möbius committed
81 82 83 84
    
  protected:
    UpdateTypeSet type_;
};
Dirk Wilden's avatar
Dirk Wilden committed
85

86 87 88 89 90 91
/** \defgroup DefaultUpdateTypes Default update types
 * The following update types are predefined for the general use cases
 * @{
 *
 */

Dirk Wilden's avatar
Dirk Wilden committed
92
/// Identifier for all updates
Jan Möbius's avatar
Jan Möbius committed
93 94
const UpdateType UPDATE_ALL(              UpdateTypeSet(1)       );

95
/// This is the update identifier for global Object visibility ( show/hide )
Jan Möbius's avatar
Jan Möbius committed
96
const UpdateType UPDATE_VISIBILITY(       UpdateTypeSet(1) << 1  );
Jan Möbius's avatar
Jan Möbius committed
97 98 99 100 101 102 103


/** \brief Geometry updated
*
* Updated Geometry ( This update type has to be used if you only modify vertex positions of 
* an object. Everything else has to stay as before the update.
*/
Jan Möbius's avatar
Jan Möbius committed
104
const UpdateType UPDATE_GEOMETRY( UpdateTypeSet(1) << 2 );
Jan Möbius's avatar
Jan Möbius committed
105 106 107 108 109 110

/** \brief Topology updated
*
* Updated Topology ( This update type has to be used if you modify the topology
* of an object. This includes adding vertices or removing them! )
*/
Jan Möbius's avatar
Jan Möbius committed
111
const UpdateType UPDATE_TOPOLOGY( UpdateTypeSet(1) << 3 );
Jan Möbius's avatar
Jan Möbius committed
112 113 114 115 116 117 118


/** \brief Selection updated
*
* Updated Selection ( This update type has to be used if you modify the internal
* selection of an object. Like selecting a single vertex or a set of faces. ). 
*/
Jan Möbius's avatar
Jan Möbius committed
119
const UpdateType UPDATE_SELECTION( UpdateTypeSet(1) << 4 );
Jan Möbius's avatar
Jan Möbius committed
120 121 122 123 124

/** \brief Vertex selection has changed
*
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/
Jan Möbius's avatar
Jan Möbius committed
125
const UpdateType UPDATE_SELECTION_VERTICES( UpdateTypeSet(1) << 5 );
Jan Möbius's avatar
Jan Möbius committed
126 127 128 129 130 131


/** \brief Edge selection has changed
*
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/
Jan Möbius's avatar
Jan Möbius committed
132
const UpdateType UPDATE_SELECTION_EDGES( UpdateTypeSet(1) << 6 );
Jan Möbius's avatar
Jan Möbius committed
133

134

135
/** \brief Halfedge selection has changed
136 137 138 139 140
*
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/
const UpdateType UPDATE_SELECTION_HALFEDGES( UpdateTypeSet(1) << 7 );

Jan Möbius's avatar
Jan Möbius committed
141 142 143 144
/** \brief Face selection has changed
*
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/
145
const UpdateType UPDATE_SELECTION_FACES( UpdateTypeSet(1) << 8 );
Dirk Wilden's avatar
Dirk Wilden committed
146

147 148 149 150
/** \brief Knot selection has changed
*
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/
151
const UpdateType UPDATE_SELECTION_KNOTS( UpdateTypeSet(1) << 9 );
152

153 154 155 156
/** \brief Colors have changed
*
* Update the colors. This does not have to be called when topology is also updated
*/
157
const UpdateType UPDATE_COLOR( UpdateTypeSet(1) << 10 );
158

159 160 161 162 163 164
/** \brief Textures have changed
*
* Update the Textures.
*/
const UpdateType UPDATE_TEXTURE( UpdateTypeSet(1) << 11 );

165 166 167 168 169 170
/** \brief State has changed
*
* The object's state (target, source) has changed
*/
const UpdateType UPDATE_STATE( UpdateTypeSet(1) << 12 );

Jan Möbius's avatar
Jan Möbius committed
171
/// marks the last used ID
172
const UpdateType UPDATE_UNUSED ( UpdateTypeSet(1) << 13 );
Dirk Wilden's avatar
Dirk Wilden committed
173

174 175
/**@}*/

Jan Möbius's avatar
Jan Möbius committed
176
//=====================================================================================
Dirk Wilden's avatar
Dirk Wilden committed
177
// FUNCTIONS
Jan Möbius's avatar
Jan Möbius committed
178
//=====================================================================================
Dirk Wilden's avatar
Dirk Wilden committed
179

180 181 182 183 184 185 186

/** \defgroup UpdateTypeFunctions Runtime Update Types
 * Use these functions to add custom update types at runtime.
 * @{
 *
 */

187
/** Adds a UpdateType and returns the id for the new type
Dirk Wilden's avatar
Dirk Wilden committed
188
*
189 190
* @param _name Internal name for the new UpdateType
* @param _resetNeeded If a sceneGraph reset is needed for this update
Dirk Wilden's avatar
Dirk Wilden committed
191 192
*/
DLLEXPORT
193
UpdateType addUpdateType(QString _name, bool _resetNeeded = true);
Dirk Wilden's avatar
Dirk Wilden committed
194

195
/// Given an UpdateType Identifier string this function will return the id of the UpdateType
Dirk Wilden's avatar
Dirk Wilden committed
196 197 198 199 200
DLLEXPORT
UpdateType updateType(QString _name);

/** \brief Get the name of a type with given id
*
201 202
* The ids are organized in a bit field. So use either the macro for getting the type id or
* use the id directly (they have to be power of 2! ... Bit field)
Dirk Wilden's avatar
Dirk Wilden committed
203 204 205 206 207 208 209 210 211 212
*/
DLLEXPORT
QString updateTypeName(UpdateType _id);

/** \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. 
*/
DLLEXPORT 
213
size_t updateTypeCount();
Dirk Wilden's avatar
Dirk Wilden committed
214

215
/**@}*/
Dirk Wilden's avatar
Dirk Wilden committed
216 217

#endif // UPDATETYPE_HH