UpdateType.hh 3.88 KB
Newer Older
Dirk Wilden's avatar
Dirk Wilden committed
1 2 3 4

#ifndef UPDATETYPE_HH
#define UPDATETYPE_HH

Jan Möbius's avatar
Jan Möbius committed
5
#include <OpenFlipper/common/GlobalDefines.hh>
Jan Möbius's avatar
Jan Möbius committed
6
#include <bitset>
Dirk Wilden's avatar
Dirk Wilden committed
7

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

Jan Möbius's avatar
Jan Möbius committed
10
// TYPE
Jan Möbius's avatar
Jan Möbius committed
11
class DLLEXPORT UpdateType {
Jan Möbius's avatar
Jan Möbius committed
12 13 14 15 16 17 18
  public:
    UpdateType(const UpdateType& _type);
    
    UpdateType(UpdateTypeSet _set);
    
    /// Exact compare operator
    bool operator==(const UpdateType& _type) const;
19 20 21 22

    UpdateType operator|(const UpdateType& _type) const;

    UpdateType& operator|=(const UpdateType& _type);
Jan Möbius's avatar
Jan Möbius committed
23 24 25 26 27 28
    
    UpdateType& operator++();
    
    bool operator<( const UpdateType& _i ) const;
    
    /// Check if this update contains the given UpdateType
29
    bool contains( const UpdateType& _type ) const;
Jan Möbius's avatar
Jan Möbius committed
30 31 32 33
    
  protected:
    UpdateTypeSet type_;
};
Dirk Wilden's avatar
Dirk Wilden committed
34 35

/// Identifier for all updates
Jan Möbius's avatar
Jan Möbius committed
36 37
const UpdateType UPDATE_ALL(              UpdateTypeSet(1)       );

38
/// This is the update identifier for global Object visibility ( show/hide )
Jan Möbius's avatar
Jan Möbius committed
39
const UpdateType UPDATE_VISIBILITY(       UpdateTypeSet(1) << 1  );
Jan Möbius's avatar
Jan Möbius committed
40 41 42 43 44 45 46 47 48


/// The following update types are predefined for the general use cases

/** \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
49
const UpdateType UPDATE_GEOMETRY( UpdateTypeSet(1) << 2 );
Jan Möbius's avatar
Jan Möbius committed
50 51 52 53 54 55

/** \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
56
const UpdateType UPDATE_TOPOLOGY( UpdateTypeSet(1) << 3 );
Jan Möbius's avatar
Jan Möbius committed
57 58 59 60 61 62 63


/** \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
64
const UpdateType UPDATE_SELECTION( UpdateTypeSet(1) << 4 );
Jan Möbius's avatar
Jan Möbius committed
65 66 67 68 69

/** \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
70
const UpdateType UPDATE_SELECTION_VERTICES( UpdateTypeSet(1) << 5 );
Jan Möbius's avatar
Jan Möbius committed
71 72 73 74 75 76


/** \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
77
const UpdateType UPDATE_SELECTION_EDGES( UpdateTypeSet(1) << 6 );
Jan Möbius's avatar
Jan Möbius committed
78 79 80 81 82

/** \brief Face 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
83
const UpdateType UPDATE_SELECTION_FACES( UpdateTypeSet(1) << 7 );
Dirk Wilden's avatar
Dirk Wilden committed
84

85 86 87 88 89 90
/** \brief Knot selection has changed
*
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/
const UpdateType UPDATE_SELECTION_KNOTS( UpdateTypeSet(1) << 8 );

91 92 93 94
/** \brief Colors have changed
*
* Update the colors. This does not have to be called when topology is also updated
*/
95
const UpdateType UPDATE_COLOR( UpdateTypeSet(1) << 9 );
96

Jan Möbius's avatar
Jan Möbius committed
97
/// marks the last used ID
98
const UpdateType UPDATE_UNUSED ( UpdateTypeSet(1) << 10 );
Dirk Wilden's avatar
Dirk Wilden committed
99

Jan Möbius's avatar
Jan Möbius committed
100
//=====================================================================================
Dirk Wilden's avatar
Dirk Wilden committed
101
// FUNCTIONS
Jan Möbius's avatar
Jan Möbius committed
102
//=====================================================================================
Dirk Wilden's avatar
Dirk Wilden committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133

/** Adds a datatype and returns the id for the new type
*
* @param _name Internal name for the new DataType
* @param _readableName Human readable Name for this type ( Use tr to make it translatable )
*/
DLLEXPORT
UpdateType addUpdateType(QString _name);

/// Given a dataType Identifier string this function will return the id of the datatype
DLLEXPORT
UpdateType updateType(QString _name);

/** \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)
*/
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 
uint updateTypeCount();


#endif // UPDATETYPE_HH