void MapWindow::on_actionOpen_triggered() { QString filename; filename = QFileDialog::getOpenFileName(0, "Open File", QDir::home().absolutePath(), "ProjMapper Files (*.pmap)"); if (!filename.isEmpty()) { QFile fd(filename); fd.open(QIODevice::ReadWrite); QDataStream ds(&fd); Quad *q; int size; ds >> size; quadList->clear(); for (int i = ui->listWidget->count()-1; i >= 0; i--) { ui->listWidget->takeItem(i); } for (int i = 0; i<size; i++) { q = new Quad(); ds >> *q; quadList->append(q); new QListWidgetItem(q->getName(), ui->listWidget); qDebug() << q->getName(); } fd.close(); emit updateAllDisplays(); }
void MapWindow::outputTemplates(QDir outDir) { if (!outDir.exists()) { outDir.mkdir(outDir.absolutePath()); } QPainter p; p.setRenderHint(QPainter::HighQualityAntialiasing); for (int i = 0; i<quadList->size(); i++) { Quad *q = quadList->at(i); QPixmap *temp = new QPixmap(q->getQuad().boundingRect().size()); temp->fill(Qt::transparent); qDebug() << "Quad: " << q->getName() << " poly: " << q->getQuad(); p.begin(temp); p.setPen(QColor(Qt::black)); p.setBrush(QColor(Qt::black)); p.translate(-q->getQuad().at(0)); p.drawPolygon(q->getQuad()); p.end(); temp->save(outDir.absolutePath().append("/").append(q->getName()).append(".png")); } }