MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //connect signals of GUI elements with slots of this class
    connectSignalSlots();

    //hide advanced settings and connect signals/slots to show them
    hideAdvancedSettings();

    //initialize graphicsview
    GraphicsScene *scene = new GraphicsScene();
    ui->graphicsView->setScene(scene);
    scene->setBackgroundBrush(QBrush(Qt::darkGray));
    ui->graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
    scene->addText("Start by dragging images here.");
    ui->graphicsView->setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform);
    ui->graphicsView->setAcceptDrops(true);

    //initialize QImage objects to store the calculated maps
    input = QImage();
    channelIntensity = QImage();
    normalmap = QImage();
    specmap = QImage();
    displacementmap = QImage();
    ssaomap = QImage();

    //initialize calctimes
    lastCalctime_normal = 0;
    lastCalctime_specular = 0;
    lastCalctime_displace = 0;
    lastCalctime_ssao = 0;

    //initialize stopQueue flag
    stopQueue = false;

    //show default status message
    ui->statusBar->showMessage("Drag images into the empty preview window to load them.");

    //hide queue progressbar
    ui->progressBar_Queue->hide();

    //if the program was opened via "open with" by the OS, extract the image paths from the arguments
    //(args[0] is the name of the application)
    QStringList args = QCoreApplication::arguments();
    if(args.size() > 1) {
        QList<QUrl> imageUrls;

        for(int i = 1; i < args.size(); i++) {
            imageUrls.append(QUrl::fromLocalFile(args[i]));
        }

        loadMultipleDropped(imageUrls);
    }
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    lastCalctime_normal(0),
    lastCalctime_specular(0),
    lastCalctime_displace(0),
    lastCalctime_ssao(0),
    stopQueue(false)
{
    ui->setupUi(this);

    supportedImageformats << "*.png" << "*.jpg" << "*.jpeg" << "*.tiff"
                          << "*.tif" << "*.ppm" << "*.bmp"  << "*.xpm"
                          << "*.tga" << "*.gif";

    //connect signals of GUI elements with slots of this class
    connectSignalSlots();

    //hide advanced settings and connect signals/slots to show them
    hideAdvancedSettings();

    //initialize graphicsview
    GraphicsScene *scene = new GraphicsScene();
    ui->graphicsView->setScene(scene);
    ui->graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
    scene->addText("Start by dragging images here.");
    ui->graphicsView->setRenderHints(QPainter::HighQualityAntialiasing
                                     | QPainter::SmoothPixmapTransform);
    ui->graphicsView->setAcceptDrops(true);

    //show default status message
    ui->statusBar->showMessage("Drag images into the empty preview window to load them.");

    //hide queue progressbar
    ui->progressBar_Queue->hide();
    
    // SSAO map generator is not ready yet, remove it from the UI
    ui->tabWidget->removeTab(4);

    //default UI colors
    useCustomUiColors = false;
    uiColorMainDefault = QColor("#444");
    uiColorTextDefault = QColor("#eee");
    uiColorGraphicsViewDefault = QColor(Qt::darkGray);
    uiColorMain = uiColorMainDefault;
    uiColorText = uiColorTextDefault;
    uiColorGraphicsView = uiColorGraphicsViewDefault;

    //read last window position and color settings from registry
    readSettings();

    //set UI colors
    setUiColors();

    //if the program was opened via "open with" by the OS,
    //extract the image paths from the arguments
    QStringList args = QCoreApplication::arguments();
    if(args.size() > 1) {
        QList<QUrl> imageUrls;

        for(int i = 1; i < args.size(); i++) {
            imageUrls.append(QUrl::fromLocalFile(args[i]));
        }

        loadMultipleDropped(imageUrls);
    }
}