43 #include "UpdateType.hh" 44 #include <QCoreApplication> 50 static std::map< UpdateType, QString > updateTypeToString;
54 static std::map< QString , size_t > stringToUpdateTypeInfo;
58 static std::map< UpdateType , size_t > updateTypeToTypeInfo;
66 UpdateType::UpdateType()
72 UpdateType::UpdateType(
const UpdateTypeSet& _set)
79 return ( (type_ & _type.type_) != 0);
83 UpdateType::operator|(
const UpdateType& _type)
const 90 UpdateType::operator|=(
const UpdateType& _type)
110 return ( (type_ & _type.type_) != 0 );
115 UpdateTypeSet check = type_;
117 for (count = 0; check; count++)
123 std::cerr <<
"Operator ++ for UpdateType which is not atomic!!" << std::endl;
131 bool UpdateType::operator<(
const UpdateType& _i )
const {
132 return (type_ < _i.type_);
142 resetNeeded(_needsScenegraphReset)
156 static std::vector< UpdateTypeInfo > updateTypes;
162 void initializeUpdateTypes() {
164 stringToUpdateTypeInfo[
"All"] = updateTypes.size();
165 updateTypeToTypeInfo[
UPDATE_ALL] = updateTypes.size();
168 stringToUpdateTypeInfo[
"Visibility"] = updateTypes.size();
172 stringToUpdateTypeInfo[
"Geometry"] = updateTypes.size();
176 stringToUpdateTypeInfo[
"Topology"] = updateTypes.size();
180 stringToUpdateTypeInfo[
"Selection"] = updateTypes.size();
184 stringToUpdateTypeInfo[
"VertexSelection"] = updateTypes.size();
188 stringToUpdateTypeInfo[
"EdgeSelection"] = updateTypes.size();
192 stringToUpdateTypeInfo[
"HalfedgeSelection"] = updateTypes.size();
196 stringToUpdateTypeInfo[
"FaceSelection"] = updateTypes.size();
200 stringToUpdateTypeInfo[
"KnotSelection"] = updateTypes.size();
204 stringToUpdateTypeInfo[
"Color"] = updateTypes.size();
205 updateTypeToTypeInfo[
UPDATE_COLOR] = updateTypes.size();
208 stringToUpdateTypeInfo[
"Texture"] = updateTypes.size();
212 stringToUpdateTypeInfo[
"State"] = updateTypes.size();
213 updateTypeToTypeInfo[
UPDATE_STATE] = updateTypes.size();
235 std::map<QString, size_t>::iterator index = stringToUpdateTypeInfo.find( _name );
237 if ( index != stringToUpdateTypeInfo.end() )
238 return updateTypes[ index->second ].type;
243 stringToUpdateTypeInfo[ _name ] = updateTypes.size();
244 updateTypeToTypeInfo[ type ] = updateTypes.size();
245 updateTypes.push_back(
UpdateTypeInfo(type, _name, _resetNeeded ) );
247 updateTypeToString[type] = _name;
257 std::map<QString, size_t>::iterator index = stringToUpdateTypeInfo.find( _name );
259 if ( index != stringToUpdateTypeInfo.end() )
260 return updateTypes[ index->second ].type;
263 std::cerr <<
"Unknown UpdateType with name " << _name.toStdString() << std::endl;
272 std::map<UpdateType, QString>::iterator name = updateTypeToString.find(_id);
274 if ( name != updateTypeToString.end() )
278 std::cerr <<
"Unable to retrieve updateTypeName" << std::endl;
285 std::map<UpdateType, QString>::iterator partName = updateTypeToString.find(
UpdateType(UpdateTypeSet(1) << i));
286 if ( partName != updateTypeToString.end() ) {
287 type += partName->second +
";";
295 type = type.left(type.length()-1);
303 return updateTypes.size();
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(8))
Topology updated.
UpdateType addUpdateType(QString _name, bool _resetNeeded)
Adds a updateType and returns the id for the new type.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
QString updateTypeName(UpdateType _id)
Get the name of a type with given id.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(16))
Selection updated.
QString name
The name of the UpdateType.
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(2048))
Textures have changed.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(4))
Geometry updated.
const UpdateType UPDATE_SELECTION_HALFEDGES(UpdateTypeSet(128))
Halfedge selection has changed.
const UpdateType UPDATE_UNUSED(UpdateTypeSet(8192))
marks the last used ID
const UpdateType UPDATE_STATE(UpdateTypeSet(4096))
State 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_SELECTION_KNOTS(UpdateTypeSet(512))
Knot selection has changed.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1024))
Colors have changed.
const UpdateType UPDATE_SELECTION_EDGES(UpdateTypeSet(64))
Edge selection has changed.
const UpdateType UPDATE_VISIBILITY(UpdateTypeSet(2))
This is the update identifier for global Object visibility ( show/hide )
const UpdateType UPDATE_SELECTION_FACES(UpdateTypeSet(256))
Face selection has changed.
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.
UpdateType updateType(QString _name)
Get the id of a type with given name.
const UpdateType UPDATE_SELECTION_VERTICES(UpdateTypeSet(32))
Vertex selection has changed.