44 #include "UpdateType.hh" 45 #include <QCoreApplication> 51 static std::map< UpdateType, QString > updateTypeToString;
55 static std::map< QString , size_t > stringToUpdateTypeInfo;
59 static std::map< UpdateType , size_t > updateTypeToTypeInfo;
65 UpdateType::UpdateType()
71 UpdateType::UpdateType(
const UpdateType& _type)
77 UpdateType::UpdateType(
const UpdateTypeSet& _set)
84 return ((type_ & _type.type_).any());
88 UpdateType::operator|(
const UpdateType& _type)
const 90 return (type_ | _type.type_);
95 UpdateType::operator|=(
const UpdateType& _type)
115 return ((type_ & _type.type_).any());
119 if ( type_.count() != 1 ) {
120 std::cerr <<
"Operator ++ for UpdateType which is not atomic!!" << std::endl;
128 bool UpdateType::operator<(
const UpdateType& _i )
const {
129 return (type_.to_ulong() < _i.type_.to_ulong());
139 resetNeeded(_needsScenegraphReset)
153 static std::vector< UpdateTypeInfo > updateTypes;
159 void initializeUpdateTypes() {
161 stringToUpdateTypeInfo[
"All"] = updateTypes.size();
162 updateTypeToTypeInfo[
UPDATE_ALL] = updateTypes.size();
165 stringToUpdateTypeInfo[
"Visibility"] = updateTypes.size();
169 stringToUpdateTypeInfo[
"Geometry"] = updateTypes.size();
173 stringToUpdateTypeInfo[
"Topology"] = updateTypes.size();
177 stringToUpdateTypeInfo[
"Selection"] = updateTypes.size();
181 stringToUpdateTypeInfo[
"VertexSelection"] = updateTypes.size();
185 stringToUpdateTypeInfo[
"EdgeSelection"] = updateTypes.size();
189 stringToUpdateTypeInfo[
"HalfedgeSelection"] = updateTypes.size();
193 stringToUpdateTypeInfo[
"FaceSelection"] = updateTypes.size();
197 stringToUpdateTypeInfo[
"KnotSelection"] = updateTypes.size();
201 stringToUpdateTypeInfo[
"Color"] = updateTypes.size();
202 updateTypeToTypeInfo[
UPDATE_COLOR] = updateTypes.size();
205 stringToUpdateTypeInfo[
"Texture"] = updateTypes.size();
209 stringToUpdateTypeInfo[
"State"] = updateTypes.size();
210 updateTypeToTypeInfo[
UPDATE_STATE] = updateTypes.size();
232 std::map<QString, size_t>::iterator index = stringToUpdateTypeInfo.find( _name );
234 if ( index != stringToUpdateTypeInfo.end() )
235 return updateTypes[ index->second ].type;
240 stringToUpdateTypeInfo[ _name ] = updateTypes.size();
241 updateTypeToTypeInfo[ type ] = updateTypes.size();
242 updateTypes.push_back(
UpdateTypeInfo(type, _name, _resetNeeded ) );
244 updateTypeToString[type] = _name;
254 std::map<QString, size_t>::iterator index = stringToUpdateTypeInfo.find( _name );
256 if ( index != stringToUpdateTypeInfo.end() )
257 return updateTypes[ index->second ].type;
260 std::cerr <<
"Unknown UpdateType with name " << _name.toStdString() << std::endl;
269 std::map<UpdateType, QString>::iterator name = updateTypeToString.find(_id);
271 if ( name != updateTypeToString.end() )
275 std::cerr <<
"Unable to retrieve updateTypeName" << std::endl;
282 std::map<UpdateType, QString>::iterator partName = updateTypeToString.find(
UpdateType(UpdateTypeSet(1) << i));
283 if ( partName != updateTypeToString.end() ) {
284 type += partName->second +
";";
292 type.left(type.length()-1);
300 return updateTypes.size();
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
const UpdateType UPDATE_SELECTION_KNOTS(UpdateTypeSet(1)<< 9)
Knot selection has changed.
UpdateType addUpdateType(QString _name, bool _resetNeeded)
Adds a updateType and returns the id for the new type.
const UpdateType UPDATE_STATE(UpdateTypeSet(1)<< 12)
State has changed.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
const UpdateType UPDATE_SELECTION_VERTICES(UpdateTypeSet(1)<< 5)
Vertex selection has changed.
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_UNUSED(UpdateTypeSet(1)<< 13)
marks the last used ID
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
QString name
The name of the UpdateType.
const UpdateType UPDATE_VISIBILITY(UpdateTypeSet(1)<< 1)
This is the update identifier for global Object visibility ( show/hide )
const UpdateType UPDATE_SELECTION_FACES(UpdateTypeSet(1)<< 8)
Face selection has changed.
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
const UpdateType UPDATE_SELECTION_EDGES(UpdateTypeSet(1)<< 6)
Edge selection has changed.
bool resetNeeded
is a sceneGraph reset needed for this update
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
bool operator==(const UpdateType &_type) const
Exact compare operator.
size_t updateTypeCount()
Return the number of registered types.
UpdateType type
The id of the UpdateType.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
UpdateType updateType(QString _name)
Get the id of a type with given name.