Commit 38cc606f authored by Jan Möbius's avatar Jan Möbius

Changed the updateType

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8699 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 29925c78
......@@ -5,10 +5,6 @@
#include <OpenFlipper/common/GlobalOptions.hh>
/** This field defines the start id for custom updatetypes.
*/
static unsigned int nextUpdateTypeId_ = 16;
/** This map maps an updateType id to an typeName
*/
static std::map< UpdateType, QString > updateTypeToString;
......@@ -21,6 +17,51 @@ static std::map< QString , unsigned int > stringToUpdateTypeInfo;
*/
static std::map< UpdateType , unsigned int > updateTypeToTypeInfo;
/** This field defines the start id for custom updatetypes.
*/
static UpdateType firstFreeID_(UPDATE_UNUSED);
UpdateType::UpdateType(const UpdateType& _type)
:type_(_type.type_)
{
}
UpdateType::UpdateType(UpdateTypeSet _set)
: type_(_set)
{
}
bool UpdateType::operator==(const UpdateType& _type) const {
return ((type_ & _type.type_).any());
};
/// Check if this update contains the given UpdateType
bool UpdateType::contains( const UpdateType& _type ) {
// Catch the specialization of updates
if ( _type == UPDATE_SELECTION ) {
if ( type_ == UPDATE_SELECTION_VERTICES.type_ || type_ == UPDATE_SELECTION_EDGES.type_ || type_ == UPDATE_SELECTION_FACES.type_ )
return true;
}
return ((type_ & _type.type_).any());
}
UpdateType& UpdateType::operator++() {
if ( type_.count() != 1 ) {
std::cerr << "Operator ++ for UpdateType which is not atomic!!" << std::endl;
}
type_ << 1;
return (*this);
}
bool UpdateType::operator<( const UpdateType& _i ) const {
return (type_.to_ulong() < _i.type_.to_ulong());
}
class UpdateTypeInfo {
public:
......@@ -73,14 +114,29 @@ void initializeUpdateTypes() {
stringToUpdateTypeInfo["Selection"] = updateTypes.size();
updateTypeToTypeInfo[UPDATE_SELECTION] = updateTypes.size();
updateTypes.push_back( UpdateTypeInfo(UPDATE_SELECTION, "Selection", true) );
stringToUpdateTypeInfo["VertexSelection"] = updateTypes.size();
updateTypeToTypeInfo[UPDATE_SELECTION_VERTICES] = updateTypes.size();
updateTypes.push_back( UpdateTypeInfo(UPDATE_SELECTION_VERTICES, "VertexSelection", true) );
stringToUpdateTypeInfo["EdgeSelection"] = updateTypes.size();
updateTypeToTypeInfo[UPDATE_SELECTION_EDGES] = updateTypes.size();
updateTypes.push_back( UpdateTypeInfo(UPDATE_SELECTION_EDGES, "EdgeSelection", true) );
stringToUpdateTypeInfo["FaceSelection"] = updateTypes.size();
updateTypeToTypeInfo[UPDATE_SELECTION_FACES] = updateTypes.size();
updateTypes.push_back( UpdateTypeInfo(UPDATE_SELECTION_FACES, "FaceSelection", true) );
updateTypeToString[UPDATE_ALL] = "All";
updateTypeToString[UPDATE_OBJECT_SELECTION] = "ObjectSelection";
updateTypeToString[UPDATE_VISIBILITY] = "Visibility";
updateTypeToString[UPDATE_GEOMETRY] = "Geometry";
updateTypeToString[UPDATE_TOPOLOGY] = "Topology";
updateTypeToString[UPDATE_SELECTION] = "Selection";
updateTypeToString[UPDATE_ALL] = "All";
updateTypeToString[UPDATE_OBJECT_SELECTION] = "ObjectSelection";
updateTypeToString[UPDATE_VISIBILITY] = "Visibility";
updateTypeToString[UPDATE_GEOMETRY] = "Geometry";
updateTypeToString[UPDATE_TOPOLOGY] = "Topology";
updateTypeToString[UPDATE_SELECTION] = "Selection";
updateTypeToString[UPDATE_SELECTION_VERTICES] = "VertexSelection";
updateTypeToString[UPDATE_SELECTION_EDGES] = "EdgeSelection";
updateTypeToString[UPDATE_SELECTION_FACES] = "FaceSelection";
}
/// Adds a updateType and returns the id for the new type
......@@ -93,7 +149,7 @@ UpdateType addUpdateType(QString _name, bool _resetNeeded) {
return updateTypes[ index->second ].type;
else {
unsigned int type = nextUpdateTypeId_;
UpdateType type = firstFreeID_;
stringToUpdateTypeInfo[ _name ] = updateTypes.size();
updateTypeToTypeInfo[ type ] = updateTypes.size();
......@@ -101,7 +157,7 @@ UpdateType addUpdateType(QString _name, bool _resetNeeded) {
updateTypeToString[type] = _name;
nextUpdateTypeId_ *= 2;
++firstFreeID_;
return( type );
}
}
......@@ -130,7 +186,7 @@ QString updateTypeName(UpdateType _id) {
return name->second;
else {
#ifdef DEBUG
std::cerr << "Unable to retrieve updateTypeName for id " << _id << std::endl;
std::cerr << "Unable to retrieve updateTypeName" << std::endl;
#endif
return "Unknown";
}
......
......@@ -2,21 +2,90 @@
#ifndef UPDATETYPE_HH
#define UPDATETYPE_HH
// TYPE
#include <bitset>
typedef uint UpdateType;
typedef std::bitset<64> UpdateTypeSet;
// TYPE
class UpdateType {
public:
UpdateType(const UpdateType& _type);
UpdateType(UpdateTypeSet _set);
/// Exact compare operator
bool operator==(const UpdateType& _type) const;
UpdateType& operator++();
bool operator<( const UpdateType& _i ) const;
/// Check if this update contains the given UpdateType
bool contains( const UpdateType& _type );
protected:
UpdateTypeSet type_;
};
/// Identifier for all updates
const UpdateType UPDATE_ALL(UINT_MAX);
const UpdateType UPDATE_ALL( UpdateTypeSet(1) );
/// This is the update identifier for global Object selections(source/target)
const UpdateType UPDATE_OBJECT_SELECTION( UpdateTypeSet(1) << 1 );
/// This is the update identifier for global Object visibiölity ( show/hide )
const UpdateType UPDATE_VISIBILITY( UpdateTypeSet(1) << 2 );
/// 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.
*/
const UpdateType UPDATE_GEOMETRY( UpdateTypeSet(1) << 3 );
/** \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! )
*/
const UpdateType UPDATE_TOPOLOGY( UpdateTypeSet(1) << 4 );
/** \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. ).
*/
const UpdateType UPDATE_SELECTION( UpdateTypeSet(1) << 5 );
/** \brief Vertex selection has changed
*
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/
const UpdateType UPDATE_SELECTION_VERTICES( UpdateTypeSet(1) << 6 );
/** \brief Edge selection has changed
*
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/
const UpdateType UPDATE_SELECTION_EDGES( UpdateTypeSet(1) << 7 );
/** \brief Face selection has changed
*
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/
const UpdateType UPDATE_SELECTION_FACES( UpdateTypeSet(1) << 8 );
const UpdateType UPDATE_OBJECT_SELECTION(0);
const UpdateType UPDATE_VISIBILITY(1);
const UpdateType UPDATE_GEOMETRY(2);
const UpdateType UPDATE_TOPOLOGY(4);
const UpdateType UPDATE_SELECTION(8);
/// marks the last used ID
const UpdateType UPDATE_UNUSED ( UpdateTypeSet(1) << 9 );
//=====================================================================================
// FUNCTIONS
//=====================================================================================
/** Adds a datatype and returns the id for the new type
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment