int main(int argc, char **argv) { /********************* ** Qt **********************/ QApplication app(argc, argv); qRegisterMetaType<sensor_msgs::CompressedImageConstPtr>("sensor_msgs::CompressedImageConstPtr"); qRegisterMetaType<tld_msgs::Target>("tld_msgs::Target"); MainWindow w; w.show(); ros::init(argc, argv, "listener"); ros::NodeHandle node; Test test(node); test.start(); QObject::connect(&test, SIGNAL(ImageReceived(sensor_msgs::CompressedImageConstPtr)), &w, SLOT(ImageShow(sensor_msgs::CompressedImageConstPtr))); QObject::connect(w.ui->widget, SIGNAL(signalSelectRect(tld_msgs::Target)), &test, SLOT(selectRectReceived(tld_msgs::Target))); int result = app.exec(); return result; }
void HWMapContainer::askForGeneratedPreview() { pMap = new HWMap(this); connect(pMap, SIGNAL(ImageReceived(QPixmap)), this, SLOT(setImage(QPixmap))); connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); connect(pMap, SIGNAL(destroyed(QObject *)), this, SLOT(onPreviewMapDestroyed(QObject *))); pMap->getImage(m_seed, getTemplateFilter(), get_mapgen(), getMazeSize(), getDrawnMapData(), m_script ); setHHLimit(0); const QPixmap waitIcon(":/res/iconTime.png"); QPixmap waitImage(m_previewSize); QPainter p(&waitImage); p.fillRect(waitImage.rect(), linearGrad); int x = (waitImage.width() - waitIcon.width()) / 2; int y = (waitImage.height() - waitIcon.height()) / 2; p.drawPixmap(QPoint(x, y), waitIcon); addInfoToPreview(waitImage); cType->setEnabled(false); }
void HWMap::onClientDisconnect() { QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); linearGrad.setColorAt(1, QColor(0, 0, 192)); linearGrad.setColorAt(0, QColor(66, 115, 225)); if (readbuffer.size() == 128 * 32 + 1) { quint8 *buf = (quint8*) readbuffer.constData(); QImage im(buf, 256, 128, QImage::Format_Mono); im.setNumColors(2); QPixmap px(QSize(256, 128)); QPixmap pxres(px.size()); QPainter p(&pxres); px.fill(Qt::yellow); QBitmap bm = QBitmap::fromImage(im); px.setMask(bm); p.fillRect(pxres.rect(), linearGrad); p.drawPixmap(0, 0, px); emit HHLimitReceived(buf[128 * 32]); emit ImageReceived(px); } else if (readbuffer.size() == 128 * 256 + 1) { QVector<QRgb> colorTable; colorTable.resize(256); for(int i = 0; i < 256; ++i) colorTable[i] = qRgba(255, 255, 0, i); const quint8 *buf = (const quint8*) readbuffer.constData(); QImage im(buf, 256, 128, QImage::Format_Indexed8); im.setColorTable(colorTable); QPixmap px = QPixmap::fromImage(im, Qt::ColorOnly); QPixmap pxres(px.size()); QPainter p(&pxres); p.fillRect(pxres.rect(), linearGrad); p.drawPixmap(0, 0, px); emit HHLimitReceived(buf[128 * 256]); emit ImageReceived(px); } }