本文整理汇总了C++中ImageItem::identifier方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageItem::identifier方法的具体用法?C++ ImageItem::identifier怎么用?C++ ImageItem::identifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageItem
的用法示例。
在下文中一共展示了ImageItem::identifier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onLoadGeometryClicked
void StitcherWorkspace::onLoadGeometryClicked() {
QString file = QFileDialog::getOpenFileName(0,tr("Load Geometry from File"), QString(), tr("Image Geometry (*.hig)"));
if(file.isEmpty()) {
return;
}
QFile fp(file);
if(!fp.open(QIODevice::ReadOnly)) {
return;
}
QList<QGraphicsItem *> graphicsItems = _stitcherView->items();
QTextStream in(&fp);
QString dumb;
int nImages;
in >> dumb >> dumb >> nImages;
for(int i = 0; i<nImages; i++) {
QString id;
double dx,dy,dz,theta;
in >> dumb >> id;
ImageItem * item = NULL;
for(int j = 0; j < graphicsItems.size(); j++) {
item = qgraphicsitem_cast<ImageItem *>(graphicsItems[j]);
if(item && item->identifier() == id) {
break;
} else {
item = NULL;
}
}
in >> dumb >> dx;
in >> dumb >> dy;
in >> dumb >> dz;
in >> dumb >> theta;
if(item) {
item->setDx(dx);
item->setDy(dy);
item->setDz(dz);
item->setTheta(theta);
}
}
fp.close();
loadGeometry();
}
示例2: onLoadControlPointsClicked
void StitcherWorkspace::onLoadControlPointsClicked() {
QString file = QFileDialog::getOpenFileName(0,tr("Load Control Points from File"), QString(), tr("Image Control Points (*.hicp)"));
if(file.isEmpty()) {
return;
}
QFile fp(file);
if(!fp.open(QIODevice::ReadOnly)) {
return;
}
QList<QGraphicsItem *> graphicsItems = _stitcherView->items();
QTextStream in(&fp);
QString dumb;
int nImages;
in >> dumb >> dumb >> nImages;
for(int i = 0; i<nImages; i++) {
QString id;
double dx,dy;
in >> dumb >> id;
ImageItem * item = NULL;
for(int j = 0; j < graphicsItems.size(); j++) {
item = qgraphicsitem_cast<ImageItem *>(graphicsItems[j]);
if(item && item->identifier() == id) {
break;
} else {
item = NULL;
}
}
int nPoints;
in >> dumb >> dumb >> nPoints;
for(int j = 0; j<nPoints; j++) {
in >> dumb >> dx;
in >> dumb >> dy;
if(item) {
item->addControlPoint(QPointF(dx,dy));
}
}
}
fp.close();
}
示例3: loadGeometry
void StitcherWorkspace::loadGeometry() {
/*
This is a prefix to distinguish Hawk Geometry properties from the
normal widget properties
*/
const QString tag("HawkGeometry_");
QList<QGraphicsItem *> ii = _stitcherView->items();
QMap<QString,ImageItem *> sortMap;
for(int i = 0; i<ii.size(); i++) {
if(ImageItem * imageItem = qgraphicsitem_cast<ImageItem *>(ii[i])) {
if(imageItem->isVisible()) {
sortMap.insert(imageItem->identifier(),imageItem);
}
}
}
QList<ImageItem *>sortedItems = sortMap.values();
QStandardItemModel * model = qobject_cast<QStandardItemModel *>(geometryTree->model());
model->clear();
model->setHorizontalHeaderLabels(QStringList() << "Parameter" << "Value" << "Locked");
for(int i = 0; i<sortedItems.size(); i++) {
ImageItem * imageItem = sortedItems[i];
const QMetaObject *metaobject = imageItem->metaObject();
int count = metaobject->propertyCount();
QStandardItem * itemName = new QStandardItem(imageItem->identifier());
QStandardItem * itemValue = new QStandardItem();
QStandardItem * itemLocked = new QStandardItem();
itemLocked->setFlags(itemLocked->flags() & ~Qt::ItemIsEditable);
QStandardItem *parentItem = model->invisibleRootItem();
itemName->setFlags(itemName->flags() & ~Qt::ItemIsEditable);
itemValue->setFlags(itemValue->flags() & ~Qt::ItemIsEditable);
if(model->findItems(itemName->text()).empty()) {
parentItem->appendRow(QList<QStandardItem *>() << itemName << itemValue << itemLocked);
parentItem = itemName;
} else {
parentItem = model->findItems(itemName->text()).first();
}
for (int j=0; j<count; ++j) {
QMetaProperty metaproperty = metaobject->property(j);
const char *name = metaproperty.name();
if(!QString(name).startsWith(tag)) {
continue;
}
QVariant var = imageItem->property(name);
Qt::ItemFlags itemValueFlags = Qt::ItemIsSelectable|Qt::ItemIsEnabled;
if(metaproperty.isWritable()) {
itemValueFlags |= Qt::ItemIsEditable;
}
if(var.type() == QVariant::Double) {
double value = var.toDouble();
if(QString(name).endsWith("_theta") || QString(name).endsWith("_alpha")) {
/* convert to degrees */
value *= 180/M_PI;
}
if(QString(name).endsWith("_dy")) {
/* swap axis */
value = -value;
}
QStandardItem * itemName = new QStandardItem(_stitcherView->propertyNameToDisplayName(name,tag));
QStandardItem * itemValue = new QStandardItem(QString("%0").arg(value));
itemValue->setData(value,Qt::UserRole + 1);
itemValue->setData(QString(name),Qt::UserRole + 2);
itemValue->setData(QVariant::fromValue(imageItem),Qt::UserRole + 3);
itemName->setFlags(itemName->flags() & ~Qt::ItemIsEditable);
itemValue->setFlags(itemValueFlags);
QStandardItem * itemLocked = new QStandardItem();
itemLocked->setFlags(itemLocked->flags() & ~Qt::ItemIsEditable);
/* check for lock property */
QString lockedPropertyName = name + QString("_locked");
if(imageItem->property(lockedPropertyName.toAscii().data()).isValid()) {
bool locked = imageItem->property(lockedPropertyName.toAscii().data()).toBool();
itemLocked->setCheckable(true);
itemLocked->setData(locked,Qt::UserRole + 1);
itemLocked->setData(QString(lockedPropertyName),Qt::UserRole + 2);
itemLocked->setData(QVariant::fromValue(imageItem),Qt::UserRole + 3);
if(locked) {
itemLocked->setCheckState(Qt::Checked);
itemValue->setEnabled(false);
}
}
/* Temporarily disable Dz and Alpha */
if(itemName->text() == "Dz" ||
itemName->text() == "Alpha") {
itemLocked->setCheckState(Qt::Checked);
itemName->setEnabled(false);
itemValue->setEnabled(false);
itemLocked->setEnabled(false);
itemName->setToolTip("Currently disabled");
itemValue->setToolTip("Currently disabled");
itemLocked->setToolTip("Currently disabled");
}
parentItem->appendRow(QList<QStandardItem *>() << itemName << itemValue << itemLocked);
}
}
}
geometryTree->expandAll();
geometryTree->resizeColumnToContents(0);
geometryTree->sortByColumn(0,Qt::AscendingOrder);
}