46 #include <OpenMesh/Core/Utils/BaseProperty.hh> 48 #include <QAbstractListModel> 64 static const char *entity2str(ENTITY_FILTER entity);
68 TypeInfoWrapper(
const std::type_info & ti,
const char *friendlyName) : ti(&ti), friendlyName(friendlyName) {}
69 TypeInfoWrapper(
const std::type_info & ti) : ti(&ti),friendlyName(
"") {}
71 operator const std::type_info *()
const {
return ti; }
72 operator const std::type_info &()
const {
return *ti; }
73 operator const char *()
const {
return friendlyName; }
75 const std::type_info *operator->()
const {
return ti; }
76 const std::type_info &
get()
const {
return *ti; }
77 const char *getName()
const {
return friendlyName; }
84 return strcmp(ti->name(), other.ti->name()) == 0;
88 return strcmp(ti->name(), other.ti->name()) < 0;
92 const std::type_info *ti;
93 const char *friendlyName;
99 propName_(propName), typeinfo_(typeinfo), entity(entity) {}
101 QString toString()
const {
102 return tr(
"%3 %1 : %2").arg(propName_.c_str()).arg(friendlyTypeName()).arg(QString::fromUtf8(entity2str(entity)));
105 bool operator==(
const PROP_INFO &rhs)
const {
106 return propName_ == rhs.propName_ && typeinfo_ == rhs.typeinfo_ && entity == rhs.entity;
109 bool operator<(
const PROP_INFO &rhs)
const {
110 if (entity != rhs.entity)
return entity < rhs.entity;
112 int result = propName_.compare(rhs.propName_);
113 if (result)
return result < 0;
115 return typeinfo_ < rhs.typeinfo_;
118 inline bool isFaceProp()
const {
return entity == EF_FACE; }
119 inline bool isEdgeProp()
const {
return entity == EF_EDGE; }
120 inline bool isHalfedgeProp()
const {
return entity == EF_HALFEDGE; }
121 inline bool isVertexProp()
const {
return entity == EF_VERTEX; }
123 inline const std::string &propName()
const {
return propName_; }
124 inline const char *friendlyTypeName()
const {
return typeinfo_.getName(); }
126 inline ENTITY_FILTER entityType()
const {
return entity; }
129 std::string propName_;
131 ENTITY_FILTER entity;
138 virtual int rowCount(
const QModelIndex & parent = QModelIndex())
const;
139 virtual QVariant data(
const QModelIndex & index,
int role = Qt::DisplayRole)
const;
140 virtual QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const;
147 template<
typename MeshT>
148 void refresh(MeshT *mesh, ENTITY_FILTER entityFilterMask, std::type_info *typeIdFilter) {
149 std::vector<PROP_INFO> propList;
152 if (entityFilterMask & EF_FACE)
153 gatherProperties(mesh, mesh->fprops_begin(), mesh->fprops_end(), typeIdFilter, std::back_inserter(propList), EF_FACE);
155 if (entityFilterMask & EF_EDGE)
156 gatherProperties(mesh, mesh->eprops_begin(), mesh->eprops_end(), typeIdFilter, std::back_inserter(propList), EF_EDGE);
158 if (entityFilterMask & EF_HALFEDGE)
159 gatherProperties(mesh, mesh->hprops_begin(), mesh->hprops_end(), typeIdFilter, std::back_inserter(propList), EF_HALFEDGE);
161 if (entityFilterMask & EF_VERTEX)
162 gatherProperties(mesh, mesh->vprops_begin(), mesh->vprops_end(), typeIdFilter, std::back_inserter(propList), EF_VERTEX);
165 std::sort(propList.begin(), propList.end());
167 if (propList != propList_) {
170 propList_.swap(propList);
183 template<
typename MeshT,
typename OUTPUT_ITERATOR>
184 void gatherProperties(MeshT *mesh,
185 typename MeshT::prop_iterator props_first,
186 typename MeshT::prop_iterator props_last,
187 std::type_info *typeIdFilter, OUTPUT_ITERATOR oit,
188 ENTITY_FILTER entity) {
190 for (
typename MeshT::prop_iterator pit = props_first; pit != props_last; ++pit) {
192 if (!baseProp)
continue;
195 TYPE_INFO_SET::const_iterator sane_prop_it = sane_prop_types.find(bp_type);
196 if ((typeIdFilter == 0 ||
TypeInfoWrapper(*typeIdFilter) == bp_type) && sane_prop_it != sane_prop_types.end()) {
202 const PROP_INFO &operator[] (
size_t index) {
203 return propList_[index];
207 std::vector<PROP_INFO> propList_;
221 typedef std::set<TypeInfoWrapper> TYPE_INFO_SET;
223 static const TYPE_INFO_SET sane_prop_types;
bool tryInsertionsDeletions(std::vector< PROP_INFO > &propList)
const std::string & name() const
Return the name of the property.
void refresh(MeshT *mesh, ENTITY_FILTER entityFilterMask, std::type_info *typeIdFilter)