51 #include "UpdateType.hh" 52 #include <QCoreApplication> 58 static std::map< UpdateType, QString > updateTypeToString;
62 static std::map< QString , size_t > stringToUpdateTypeInfo;
66 static std::map< UpdateType , size_t > updateTypeToTypeInfo;
72 UpdateType::UpdateType()
78 UpdateType::UpdateType(
const UpdateType& _type)
84 UpdateType::UpdateType(UpdateTypeSet _set)
91 return ((type_ & _type.type_).any());
95 UpdateType::operator|(
const UpdateType& _type)
const 97 return (type_ | _type.type_);
102 UpdateType::operator|=(
const UpdateType& _type)
104 type_ |= _type.type_;
122 return ((type_ & _type.type_).any());
126 if ( type_.count() != 1 ) {
127 std::cerr <<
"Operator ++ for UpdateType which is not atomic!!" << std::endl;
135 bool UpdateType::operator<(
const UpdateType& _i )
const {
136 return (type_.to_ulong() < _i.type_.to_ulong());
146 resetNeeded(_needsScenegraphReset)
160 static std::vector< UpdateTypeInfo > updateTypes;
166 void initializeUpdateTypes() {
168 stringToUpdateTypeInfo[
"All"] = updateTypes.size();
169 updateTypeToTypeInfo[
UPDATE_ALL] = updateTypes.size();
172 stringToUpdateTypeInfo[
"Visibility"] = updateTypes.size();
176 stringToUpdateTypeInfo[
"Geometry"] = updateTypes.size();
180 stringToUpdateTypeInfo[
"Topology"] = updateTypes.size();
184 stringToUpdateTypeInfo[
"Selection"] = updateTypes.size();
188 stringToUpdateTypeInfo[
"VertexSelection"] = updateTypes.size();
192 stringToUpdateTypeInfo[
"EdgeSelection"] = updateTypes.size();
196 stringToUpdateTypeInfo[
"HalfedgeSelection"] = updateTypes.size();
200 stringToUpdateTypeInfo[
"FaceSelection"] = updateTypes.size();
204 stringToUpdateTypeInfo[
"KnotSelection"] = updateTypes.size();
208 stringToUpdateTypeInfo[
"Color"] = updateTypes.size();
209 updateTypeToTypeInfo[
UPDATE_COLOR] = updateTypes.size();
212 stringToUpdateTypeInfo[
"Texture"] = updateTypes.size();
216 stringToUpdateTypeInfo[
"State"] = updateTypes.size();
217 updateTypeToTypeInfo[
UPDATE_STATE] = updateTypes.size();
239 std::map<QString, size_t>::iterator index = stringToUpdateTypeInfo.find( _name );
241 if ( index != stringToUpdateTypeInfo.end() )
242 return updateTypes[ index->second ].type;
247 stringToUpdateTypeInfo[ _name ] = updateTypes.size();
248 updateTypeToTypeInfo[ type ] = updateTypes.size();
249 updateTypes.push_back(
UpdateTypeInfo(type, _name, _resetNeeded ) );
251 updateTypeToString[type] = _name;
261 std::map<QString, size_t>::iterator index = stringToUpdateTypeInfo.find( _name );
263 if ( index != stringToUpdateTypeInfo.end() )
264 return updateTypes[ index->second ].type;
267 std::cerr <<
"Unknown UpdateType with name " << _name.toStdString() << std::endl;
276 std::map<UpdateType, QString>::iterator name = updateTypeToString.find(_id);
278 if ( name != updateTypeToString.end() )
282 std::cerr <<
"Unable to retrieve updateTypeName" << std::endl;
290 return updateTypes.size();
UpdateType type
The id of the UpdateType.
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
UpdateType updateType(QString _name)
Get the id of a type with given name.
const UpdateType UPDATE_SELECTION_HALFEDGES(UpdateTypeSet(1)<< 7)
Halfedge selection has changed.
QString updateTypeName(UpdateType _id)
Get the name of a type with given id.
const UpdateType UPDATE_SELECTION_FACES(UpdateTypeSet(1)<< 8)
Face selection has changed.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
size_t updateTypeCount()
Return the number of registered types.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
const UpdateType UPDATE_VISIBILITY(UpdateTypeSet(1)<< 1)
This is the update identifier for global Object visibility ( show/hide )
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
const UpdateType UPDATE_SELECTION_VERTICES(UpdateTypeSet(1)<< 5)
Vertex selection has changed.
UpdateType addUpdateType(QString _name, bool _resetNeeded)
Adds a updateType and returns the id for the new type.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
bool resetNeeded
is a sceneGraph reset needed for this update
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
const UpdateType UPDATE_STATE(UpdateTypeSet(1)<< 12)
State has changed.
const UpdateType UPDATE_UNUSED(UpdateTypeSet(1)<< 13)
marks the last used ID
const UpdateType UPDATE_SELECTION_EDGES(UpdateTypeSet(1)<< 6)
Edge selection has changed.
bool operator==(const UpdateType &_type) const
Exact compare operator.
QString name
The name of the UpdateType.
const UpdateType UPDATE_SELECTION_KNOTS(UpdateTypeSet(1)<< 9)
Knot selection has changed.