44 #include "PropertyNameListModel.hh" 46 #include <OpenMesh/Core/Utils/Property.hh> 47 #include <ACG/Math/VectorT.hh> 48 #include <ACG/Math/Matrix3x3T.hh> 71 #ifdef ENABLE_SKELETON_SUPPORT 72 #include <ObjectTypes/Skeleton/BaseSkin.hh> 90 #ifdef ENABLE_SKELETON_SUPPORT 95 #ifdef ENABLE_SKELETON_SUPPORT 96 const PropertyNameListModel::TYPE_INFO_SET PropertyNameListModel::sane_prop_types(prop_types, prop_types + 9);
98 const PropertyNameListModel::TYPE_INFO_SET PropertyNameListModel::sane_prop_types(prop_types, prop_types + 8);
101 const char *PropertyNameListModel::entity2str(ENTITY_FILTER entity) {
117 PropertyNameListModel::PropertyNameListModel(QObject *parent) :
118 QAbstractListModel(parent) {
121 PropertyNameListModel::~PropertyNameListModel() {
124 int PropertyNameListModel::rowCount(
const QModelIndex & parent)
const {
125 return propList_.size();
128 QVariant PropertyNameListModel::data(
const QModelIndex & index,
int role)
const {
130 case Qt::DisplayRole:
131 return propList_[index.row()].toString();
133 return QVariant::Invalid;
137 QVariant PropertyNameListModel::headerData(
int section, Qt::Orientation orientation,
int role)
const {
139 case Qt::DisplayRole:
140 return tr(
"Some header. %1 %2").arg(section).arg(orientation);
143 return QAbstractListModel::headerData(section, orientation, role);
150 enum OP { INS, DEL };
151 InsDel(OP op,
int first,
int count,
int before) : op(op), first(first), count(count), before(before) {}
153 int first, count, before;
159 std::vector<InsDel> result;
160 typedef std::vector<PROP_INFO>::iterator IT;
163 for (oldIt = propList_.begin(), newIt = propList.begin(); oldIt < propList_.end() && newIt < propList.end(); ++oldIt, ++newIt) {
164 if (*oldIt == *newIt)
continue;
165 const IT nextNew = std::find(newIt+1, propList.end(), *oldIt);
166 if (nextNew != propList.end()) {
167 const int count = std::distance(newIt, nextNew);
168 result.push_back(InsDel(InsDel::INS, std::distance(propList.begin(), newIt), count, std::distance(propList_.begin(), oldIt) + correction));
173 const IT nextOld = std::find(oldIt+1, propList_.end(), *newIt);
174 if (nextOld != propList_.end()) {
175 const int count = std::distance(oldIt, nextOld);
176 result.push_back(InsDel(InsDel::DEL, std::distance(propList_.begin(), oldIt) + correction, count, 0));
183 if (oldIt < propList_.end() && newIt < propList.end()) {
187 if (oldIt < propList_.end())
188 result.push_back(InsDel(InsDel::DEL, std::distance(propList_.begin(), oldIt) + correction, std::distance(oldIt, propList_.end()), 0));
189 if (newIt < propList.end())
190 result.push_back(InsDel(InsDel::INS, std::distance(propList.begin(), newIt), std::distance(newIt, propList.end()), propList_.size() + correction));
192 for (std::vector<InsDel>::iterator it = result.begin(); it != result.end(); ++it) {
193 if (it->op == InsDel::INS) {
194 beginInsertRows(QModelIndex(), it->before, it->before + it->count - 1);
195 propList_.insert(propList_.begin() + it->before, propList.begin() + it->first, propList.begin() + it->first + it->count);
198 beginRemoveRows(QModelIndex(), it->first, it->first + it->count - 1);
199 propList_.erase(propList_.begin() + it->first, propList_.begin() + it->first + it->count);
204 if (propList_ != propList) {
205 std::cerr <<
"Apparently, the function PropertyNameListModel::tryInsertionsDeletions() has an implementation error." << std::endl;
206 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.