本文整理汇总了C++中ImageItem类的典型用法代码示例。如果您正苦于以下问题:C++ ImageItem类的具体用法?C++ ImageItem怎么用?C++ ImageItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImageItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImageItem
//! [3]
void View::addItems()
{
int officeCount = officeTable->rowCount();
int imageOffset = 150;
int leftMargin = 70;
int topMargin = 40;
for (int i = 0; i < officeCount; i++) {
ImageItem *image;
QGraphicsTextItem *label;
QSqlRecord record = officeTable->record(i);
int id = record.value("id").toInt();
QString file = record.value("file").toString();
QString location = record.value("location").toString();
int columnOffset = ((i / 3) * 37);
int x = ((i / 3) * imageOffset) + leftMargin + columnOffset;
int y = ((i % 3) * imageOffset) + topMargin;
image = new ImageItem(id, QPixmap(":/" + file));
image->setData(0, i);
image->setPos(x, y);
scene->addItem(image);
label = scene->addText(location);
QPointF labelOffset((150 - label->boundingRect().width()) / 2, 120.0);
label->setPos(QPointF(x, y) + labelOffset);
}
}
示例2: sp_image_read
bool StitcherView::loadImage(QString s){
Image * a = sp_image_read(s.toAscii(),0);
ImageItem * item = new ImageItem(a,s,this,NULL);
addImage(item);
item->update();
return true;
}
示例3: fileInfo
void ImageModel::AddImage(const cv::Mat image, const QString fileName)
{
QFileInfo fileInfo(fileName);
QString name = fileInfo.fileName();
// find image if already in list and remove before append new one;
ImageItem* child = this->findImage(fileName);
if(child)
{
child->remove();
}
int channelsCount = image.channels();
if(channelsCount>1)
{
ImageItem* multichannelImage = new ImageItem(name, fileName);
vector<cv::Mat> imageChannels;
cv::split(image, imageChannels);
QHash<int, QString> ChannelsStrings;
ChannelsStrings[0] = QString("Red");
ChannelsStrings[1] = QString("Green");
ChannelsStrings[2] = QString("Blue");
ChannelsStrings[3] = QString("Alpha");
for(int i = 0; i<channelsCount; i++)
{
ImageItem* child = new ImageItem(imageChannels[i], name+QString(" ")+ChannelsStrings[i], fileName, i);
multichannelImage->appendChild(child);
}
this->AddItem(multichannelImage);
}
else
{
ImageItem* item = new ImageItem(image, name, fileName, 0);
this->AddItem(item);
}
}
示例4: selectedIndexes
void ImageItemView::slotDelete() {
QModelIndexList selected = selectedIndexes();
if (selected.isEmpty()) {
return;
}
QStringList names;
for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); it++) {
ImageItem* itm = (ImageItem*) ((ImageItemModel*) model())->itemFromIndex(*it);
if (itm) {
names << tr("Name: %1, ID: %2")
.arg(itm->getImage()->getName())
.arg(itm->getImage()->getId());
}
}
if (QMessageBox::Yes == QMessageBox::warning(this,
tr("Really Delete?"),
tr("Really delete this Images?\n%1")
.arg(names.join(", ")),
QMessageBox::Yes | QMessageBox::No)) {
emit deleteRequest(selected);
}
}
示例5: mouseDoubleClickEvent
void ImageStripScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{
ImageItem* item = static_cast<ImageItem*>(itemAt(event->scenePos()));
if(item)
emit sigImageActivated(item->path());
}
示例6: scene
void BlurPicker::setupScene()
{
QSize size = BlurPicker::size();
// scene()->setSceneRect(-size.width()/2,-size.height()/2,size.width(),size.height());
scene()->setSceneRect(-500, -309, 1000, 618);
QStringList names;
names << ":/images/LEDLabel.png"; //id=0 led
names << ":/images/timerLabel.png";//id=1 定时器
names << ":/images/ThermometerLabel.png"; //id=2 温度
names << ":/images/temAndHumLabel.png";//id=3 温湿度
names << ":/images/shockLabel.png";//id=4 震动
names << ":/images/rfidLabel.png";//id=5 RFID
names << ":/images/portLabel.png";//id=6 串口通信
names << ":/images/motorLabel.png";//id=7 步进电机
names << ":/images/lightLabel.png";//id=8 光线
names << ":/images/LCDLabel.png";//id=9 LCD
names << ":/images/interruptLabel.png";//id=10 中断
names << ":/images/infarredLabel.png";//id=11 红外线
names << ":/images/enterLabel.png";//id=12 按键
names << ":/images/audioLabel.png";//id=13 蜂鸣器
names << ":/images/compLabel.png";//id=14 综合
for (int i = 0; i < names.count(); i++) {
QPixmap pixmap(names[i]);
//QGraphicsPixmapItem *icon = scene()->addPixmap(pixmap);
ImageItem *icon = new ImageItem(i,QPixmap(names[i]),this);
scene()->addItem(icon);
// ZValue,层叠次序
icon->setZValue(1);
icon->setGraphicsEffect(new BlurEffect(icon));
m_icons << icon;
}
}
示例7: path
QString ImageItem::path() const
{
QStringList names;
ImageItem *parent = m_parentItem;
while (parent && parent->type() != Root) {
names.prepend(parent->name());
parent = parent->parent();
}
return names.join("/") + "/";
}
示例8: currentImageChanged
void ImageItemView::slotIndexActivated(const QModelIndex& idx) {
if (!idx.isValid()) {
emit currentImageChanged(0);
return;
}
ImageItem* itm = (ImageItem*) (((ImageItemModel*) model())->itemFromIndex(idx));
if (!itm) {
emit currentImageChanged(0);
} else {
emit currentImageChanged(itm->getImage());
}
}
示例9: where
void View::addItems()
{
int imageOffset = 140;
int leftMargin = 40;
int topMargin = 40;
if(comportamiento == 0)
{
query.prepare("select imagen_pk from e_imagen where (url = '"+carpeta+"' and reporte_operatorio_pk IS NULL)");
qDebug()<<"Entro a NULL"<<endl;
}
else
{
query.prepare("select imagen_pk from e_imagen where (url = '"+carpeta+"' and reporte_operatorio_pk = '"+documento+"')");
qDebug()<<"Entro a "<<documento<<endl;
//qDebug("select imagen_pk from e_imagen where (url = '"+carpeta.toStdString()+"' and reporte_operatorio_pk = '"+documento.toStdString()+"')");
}
int i = 0;
query.exec();
while(query.next())
{
QGraphicsTextItem *label = new QGraphicsTextItem;
int id = query.value(0).toInt();
QString file = query.value(0).toString()+".JPG";
qDebug()<<"Agregando al visor"<<file<<endl;
QFileInfo fileInfo(file);
//fecha de creacion de archivo
QString location = fileInfo.created().toString();
int columnOffset = ((i / 3) * 37);
int x = ((i / 3) * imageOffset) + leftMargin + columnOffset;
int y = ((i % 3) * imageOffset) + topMargin;
ImageItem *image = new ImageItem(id, QPixmap(file));
image->setData(0, i);
image->setPos(x, y);
scene->addItem(image);
label = scene->addText(location);
QPointF labelOffset((150 - label->boundingRect().width()) / 2, 120.0);
label->setPos(QPointF(x, y) + labelOffset);
i++;
//Guardando los punteros para luego eliminarlos;
QPair<QGraphicsTextItem*, ImageItem*> par_punteros;
par_punteros.first = label;
par_punteros.second = image;
punteros.push_back(par_punteros);
}
}
示例10: QStandardItem
void StitcherWorkspace::onAddConstraintDialogClosed() {
QStandardItemModel * model = qobject_cast<QStandardItemModel *>(constraintsTree->model());
AddConstraintDialog * d = qobject_cast<AddConstraintDialog *>(sender());
QList<QPair<int,ImageItem *> > points = d->selectedPoints();
if(points.isEmpty()) {
delete d;
return;
}
QStandardItem *parentItem = model->invisibleRootItem();
QStandardItem * itemName = new QStandardItem("Type");
// This seems a bit too much
QList<QVariant> point_details;
QList<QVariant> item_details;
for(int i = 0; i<points.size(); i++) {
ImageItem * item = points[i].second;
QPointF pos = item->getControlPoints()[points[i].first];
item_details.append(QVariant::fromValue(item));
point_details.append(QVariant::fromValue(pos));
}
// itemName->setData(QVariant::fromValue(d));
itemName->setData(QVariant::fromValue(item_details),Qt::UserRole + 1);
itemName->setData(QVariant::fromValue(point_details),Qt::UserRole + 2);
itemName->setData(QVariant::fromValue((int)d->constraintType()),Qt::UserRole + 3);
QStandardItem * itemValue;
if(d->constraintType() == RadialLineConstraint) {
itemValue = new QStandardItem("Radial Line");
} else {
itemValue = new QStandardItem("Centered Circle");
}
parentItem->appendRow(QList<QStandardItem *>() << itemName << itemValue);
parentItem = itemName;
for(int i = 0; i<points.size(); i++) {
itemName = new QStandardItem(points[i].second->identifier() + "." + QString::number(points[i].first+1));
itemValue = new QStandardItem("");
parentItem->appendRow(QList<QStandardItem *>() << itemName << itemValue);
}
if(d->constraintType() == RadialLineConstraint) {
itemName = new QStandardItem("Angle");
} else {
itemName = new QStandardItem("Radius");
}
itemValue = new QStandardItem("");
parentItem->appendRow(QList<QStandardItem *>() << itemName << itemValue);
constraintsTree->expandAll();
constraintsTree->resizeColumnToContents(0);
constraintsTree->resizeColumnToContents(1);
}
示例11: getQImage
void ImageViewer::init(const imagein::Image* img, int x, int y)
{
/* Get info about the image */
QImage qimg = getQImage(img);
QSize size = (qimg).size();
int height = size.height();
int width = size.width();
int sup = max(height, width);
/* Compute the numeric attributs of our object */
_scale = sup > WIDGET_S ? (double) WIDGET_S / (double) sup : 1.0;
_dx = (WIDGET_S - width * _scale) / 2;
_dy = (WIDGET_S - height * _scale) / 2;
_supx = width * _scale;
_supy = height * _scale;
/* Creats the scene */
QPixmap i;
i.convertFromImage(qimg);
i = i.scaled(width * _scale, height * _scale);
//QGraphicsPixmapItem* im = new QGraphicsPixmapItem(i);
ImageItem* im = new ImageItem(i);
im->setOffset(_dx, _dy);
QObject::connect(im, SIGNAL(clickListenned(int, int)), this, SLOT(slotPositionReception(int, int)));
addItem(im);
_rect = new QGraphicsRectItem(0, 0, _scale * RECT_W, _scale * RECT_H);
QPen b;
b.setColor(Qt::red);
_rect->setPen(b);
addItem(_rect);
_rect->setX(_dx);
_rect->setY(_dy);
updatePos(x * _scale, y * _scale);
}
示例12: dir
void MainWindow::setDirectory(const QString &path)
{
QDir dir(path);
QStringList files = dir.entryList(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot);
foreach(const QString &file, files) {
QImageReader img(path + QLatin1String("/")+file);
QImage image = img.read();
if (!image.isNull()) {
{
ImageItem *item = new ImageItem(image);
item->setPos(0, 0);
item->setFlags(QGraphicsItem::ItemIsMovable);
standardGestures->scene->addItem(item);
}
{
ImageItem *item = new ImageItem(image);
item->setPos(0, 0);
item->setFlags(QGraphicsItem::ItemIsMovable);
globalViewGestures->scene->addItem(item);
}
{
GestureImageItem *item = new GestureImageItem(image);
item->setPos(0, 0);
item->setFlags(QGraphicsItem::ItemIsMovable);
graphicsItemGestures->scene->addItem(item);
}
}
}
示例13: switch
void QCustomTreeWidget::launchItem(QTreeWidgetItem *qItem)
{
Item *item = dynamic_cast<QCustomTreeWidgetItem*>(qItem)->branch()->item();
switch (item->type())
{
case Item::tSound: {
SoundItem *soundItem = dynamic_cast<SoundItem*>(item);
// we send a signal to play the music (and do some other things)
emit fileToPlay(soundItem->fileName(),soundItem->duration());
break;
}
case Item::tImage: {
ImageItem *imageItem = dynamic_cast<ImageItem*>(item);
new ImageWindow(imageItem->fileName(),this);
break;
}
default: break;
}
}
示例14: QString
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();
}
示例15: loadGeometry
void StitcherWorkspace::onItemChanged(QStandardItem * item) {
if(item->isEnabled() == false) {
return;
}
if(item->flags() & Qt::ItemIsUserCheckable) {
bool value = (item->checkState() == Qt::Checked);
QString property = item->data(Qt::UserRole + 2).toString();
ImageItem * imageItem = item->data(Qt::UserRole + 3).value<ImageItem *>();
imageItem->setProperty(property.toAscii().constData(),value);
loadGeometry();
} else if(item->flags() & Qt::ItemIsEditable) {
qDebug("item changed");
if(!item->data().isValid()) {
item = item->parent();
}
if(!item->data().isValid()) {
qFatal("Can't reach here");
}
QVariant var = item->data();
if(var.type() == QVariant::Double) {
double value = item->text().toDouble();
QString property = item->data(Qt::UserRole + 2).toString();
if(property.endsWith("_theta") || property.endsWith("_alpha")) {
/* convert from degrees */
value /= 180/M_PI;
}
if(property.endsWith("_dy")) {
/* swap axis */
value = -value;
}
ImageItem * imageItem = item->data(Qt::UserRole + 3).value<ImageItem *>();
// item->setText(QString("%0").arg(value));
imageItem->setProperty(property.toAscii().constData(),value);
qDebug("New value for %s = %f",property.toAscii().data(),value);
loadGeometry();
}
}
}