44 #include "PropertyNameListModel.hh" 46 #include <OpenMesh/Core/Utils/Property.hh> 47 #include <ACG/Math/VectorT.hh> 68 #ifdef ENABLE_SKELETON_SUPPORT 69 #include <ObjectTypes/Skeleton/BaseSkin.hh> 87 #ifdef ENABLE_SKELETON_SUPPORT 92 #ifdef ENABLE_SKELETON_SUPPORT 93 const PropertyNameListModel::TYPE_INFO_SET PropertyNameListModel::sane_prop_types(prop_types, prop_types + 9);
95 const PropertyNameListModel::TYPE_INFO_SET PropertyNameListModel::sane_prop_types(prop_types, prop_types + 8);
98 const char *PropertyNameListModel::entity2str(ENTITY_FILTER entity) {
114 PropertyNameListModel::PropertyNameListModel(QObject *parent) :
115 QAbstractListModel(parent) {
118 PropertyNameListModel::~PropertyNameListModel() {
121 int PropertyNameListModel::rowCount(
const QModelIndex & parent)
const {
122 return propList_.size();
125 QVariant PropertyNameListModel::data(
const QModelIndex & index,
int role)
const {
127 case Qt::DisplayRole:
128 return propList_[index.row()].toString();
130 return QVariant::Invalid;
134 QVariant PropertyNameListModel::headerData(
int section, Qt::Orientation orientation,
int role)
const {
136 case Qt::DisplayRole:
137 return tr(
"Some header. %1 %2").arg(section).arg(orientation);
140 return QAbstractListModel::headerData(section, orientation, role);
147 enum OP { INS, DEL };
148 InsDel(OP op,
int first,
int count,
int before) : op(op), first(first), count(count), before(before) {}
150 int first, count, before;
156 std::vector<InsDel> result;
157 typedef std::vector<PROP_INFO>::iterator IT;
160 for (oldIt = propList_.begin(), newIt = propList.begin(); oldIt < propList_.end() && newIt < propList.end(); ++oldIt, ++newIt) {
161 if (*oldIt == *newIt)
continue;
162 const IT nextNew = std::find(newIt+1, propList.end(), *oldIt);
163 if (nextNew != propList.end()) {
164 const int count = std::distance(newIt, nextNew);
165 result.push_back(InsDel(InsDel::INS, std::distance(propList.begin(), newIt), count, std::distance(propList_.begin(), oldIt) + correction));
170 const IT nextOld = std::find(oldIt+1, propList_.end(), *newIt);
171 if (nextOld != propList_.end()) {
172 const int count = std::distance(oldIt, nextOld);
173 result.push_back(InsDel(InsDel::DEL, std::distance(propList_.begin(), oldIt) + correction, count, 0));
180 if (oldIt < propList_.end() && newIt < propList.end()) {
184 if (oldIt < propList_.end())
185 result.push_back(InsDel(InsDel::DEL, std::distance(propList_.begin(), oldIt) + correction, std::distance(oldIt, propList_.end()), 0));
186 if (newIt < propList.end())
187 result.push_back(InsDel(InsDel::INS, std::distance(propList.begin(), newIt), std::distance(newIt, propList.end()), propList_.size() + correction));
189 for (std::vector<InsDel>::iterator it = result.begin(); it != result.end(); ++it) {
190 if (it->op == InsDel::INS) {
191 beginInsertRows(QModelIndex(), it->before, it->before + it->count - 1);
192 propList_.insert(propList_.begin() + it->before, propList.begin() + it->first, propList.begin() + it->first + it->count);
195 beginRemoveRows(QModelIndex(), it->first, it->first + it->count - 1);
196 propList_.erase(propList_.begin() + it->first, propList_.begin() + it->first + it->count);
201 if (propList_ != propList) {
202 std::cerr <<
"Apparently, the function PropertyNameListModel::tryInsertionsDeletions() has an implementation error." << std::endl;
203 throw std::logic_error(
"Apparently, the function PropertyNameListModel::tryInsertionsDeletions() has an implementation error.");
bool tryInsertionsDeletions(std::vector< PROP_INFO > &propList)
Default property class for any type T.