#ifndef DISTORTIONDIALOG_H #define DISTORTIONDIALOG_H #include #include #include #include #include #include #include #include "ui_distortiondialog.h" #include "globals.h" extern QGraphicsScene* distortionScene; extern QGraphicsView* distortionWindow; extern QGraphicsPixmapItem* pixmapItem; class qtDistortionDialog : public QDialog { Q_OBJECT public: qtDistortionDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~qtDistortionDialog(); bool updating; private: Ui::DistortionDialogClass ui; public slots: void on_btnComputeDistortionMap_clicked() { //get the filename QString filename = QFileDialog::getSaveFileName(NULL, "Distortion File"); int steps = ui.spinSteps->value(); //delete the pixmap if one previously existed if(pixmapItem != NULL) delete(pixmapItem); //create an image QImage image(steps, steps, QImage::Format_RGB888); QColor color(255, 255, 0); double minIn, maxIn, minOut, maxOut; minIn = ui.spinInStart->value(); maxIn = ui.spinInEnd->value(); minOut = ui.spinOutStart->value(); maxOut = ui.spinOutEnd->value(); //compute the distortion map (2D steps x steps image) float* distortionMap = (float*)malloc(sizeof(float) * steps * steps); DistortionMap(distortionMap, minIn, maxIn, minOut, maxOut, steps, filename.toUtf8().constData()); //compute the extrema float minDistortion = 99999; float maxDistortion = distortionMap[0]; for(int i=1; i 0) minDistortion = distortionMap[i]; if(distortionMap[i] > maxDistortion) maxDistortion = distortionMap[i]; } cout<addItem(pixmapItem); distortionWindow->show(); } }; #endif