• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

mainwindow.cpp

Go to the documentation of this file.
00001 
00002 
00003 #include "mainwindow.h"
00004 #include "ui_mainwindow.h"
00005 
00006 #include "FlowData.h"
00007 #include "renderingview.h"
00008 #include "gradientview.h"
00009 
00010 MainWindow::MainWindow(QWidget *parent) :
00011     QMainWindow(parent),
00012     ui(new Ui::MainWindow)
00013 {
00014     ui->setupUi(this);
00015 
00016     setWindowTitle(tr("LU Visualisierung 2010, Beispiel 2"));
00017 
00018     renderingView = new RenderingView(ui, ui->rendererGroupBox);
00019     ui->renderingLayout->addWidget(renderingView);
00020 
00021     gradientView = new GradientView(renderingView, ui->gradientGroupBox);
00022     ui->gradientLayout->addWidget(gradientView);
00023 
00024     connect(ui->colorCodingActive, SIGNAL(toggled(bool)),
00025             renderingView, SLOT(updateColorCoding()));
00026     connect(ui->colorCodingChannel, SIGNAL(valueChanged(int)),
00027             renderingView, SLOT(updateColorCoding()));
00028     connect(ui->colorCodingGradient, SIGNAL(currentIndexChanged(int)),
00029             renderingView, SLOT(updateColorCoding()));
00030 
00031     connect(ui->colorCodingGradient, SIGNAL(currentIndexChanged(int)),
00032             gradientView, SLOT(update()));
00033 
00034     connect(ui->arrowPlotActive, SIGNAL(toggled(bool)),
00035             renderingView, SLOT(updateArrowPlot()));
00036     connect(ui->arrowPlotChannelX, SIGNAL(valueChanged(int)),
00037             renderingView, SLOT(updateDerivedChannels()));
00038     connect(ui->arrowPlotChannelY, SIGNAL(valueChanged(int)),
00039             renderingView, SLOT(updateDerivedChannels()));
00040     connect(ui->arrowPlotDistance, SIGNAL(valueChanged(int)),
00041             renderingView, SLOT(updateArrowPlot()));
00042     connect(ui->arrowPlotScale, SIGNAL(toggled(bool)),
00043             renderingView, SLOT(updateArrowPlot()));
00044     connect(ui->arrowPlotSize, SIGNAL(valueChanged(int)),
00045             renderingView, SLOT(updateArrowPlot()));
00046 
00047     connect(ui->streamlinesActive, SIGNAL(toggled(bool)),
00048             renderingView, SLOT(updateStreamlines()));
00049     connect(ui->streamlinesDistance, SIGNAL(valueChanged(int)),
00050             renderingView, SLOT(updateStreamlines()));
00051     connect(ui->streamlinesDSep, SIGNAL(valueChanged(double)),
00052             renderingView, SLOT(updateStreamlines()));
00053     connect(ui->streamlinesDTest, SIGNAL(valueChanged(double)),
00054             renderingView, SLOT(updateStreamlines()));
00055     connect(ui->streamlinesIntegration, SIGNAL(currentIndexChanged(int)),
00056             renderingView, SLOT(updateStreamlines()));
00057     connect(ui->streamlinesSpacing, SIGNAL(currentIndexChanged(int)),
00058             renderingView, SLOT(updateStreamlines()));
00059     connect(ui->streamlinesTimeStep, SIGNAL(valueChanged(double)),
00060             renderingView, SLOT(updateStreamlines()));
00061     connect(ui->streamlinesSteps, SIGNAL(valueChanged(int)),
00062             renderingView, SLOT(updateStreamlines()));
00063     connect(ui->streamlinesTapering, SIGNAL(toggled(bool)),
00064             renderingView, SLOT(updateStreamlines()));
00065     connect(ui->streamlinesMaximumWidth, SIGNAL(valueChanged(int)),
00066             renderingView, SLOT(updateStreamlines()));
00067     connect(ui->streamlinesGlyphMapping, SIGNAL(toggled(bool)),
00068             renderingView, SLOT(updateStreamlines()));
00069     connect(ui->streamlinesGlyphDistance, SIGNAL(valueChanged(int)),
00070             renderingView, SLOT(updateStreamlines()));
00071     connect(ui->streamlinesGlyphSize, SIGNAL(valueChanged(int)),
00072             renderingView, SLOT(updateStreamlines()));
00073 }
00074 
00075 MainWindow::~MainWindow()
00076 {
00077     delete ui;
00078 }
00079 
00080 
00081 void MainWindow::on_actionDatensatz_laden_triggered()
00082 {
00083     QString fileName = QFileDialog::getOpenFileName(this, tr("Datensatz laden"), ".", tr("Grid files (*.gri)"));
00084 
00085     // user may abort the file dialog, in which case the file name will be empty
00086     if (!fileName.isEmpty())
00087     {
00088         // clear all channels first
00089         for (int i = 0; i < max_channels; ++i)
00090             if (flowData.getChannel(i))
00091                 flowData.deleteChannel(i);
00092 
00093         bool success = flowData.loadDataset(fileName.toStdString().c_str(), false);
00094         std::cout << "File load " << (success ? "successful" : "unsucessful") << std::endl;
00095 
00096         if (success)
00097         {
00098             renderingView->setDataset(&flowData);
00099         }
00100         else
00101             QMessageBox::warning(this, "Datensatz laden", "Laden des Datensatzes fehlgeschlagen.");
00102     }
00103 }
00104 
00105 void MainWindow::on_actionBeenden_triggered()
00106 {
00107     QApplication::quit();
00108 }
00109 
00110 
00111 void MainWindow::on_actionBild_speichern_triggered()
00112 {
00113     QString filename = QFileDialog::getSaveFileName(this, "Save image", QString(), "PNG Image (*.png)");
00114 
00115     if (filename.isEmpty())
00116         return;
00117 
00118     if (!filename.endsWith(".png")) {
00119         filename.append(".png");
00120     }
00121     //QPixmap image = m_volume_renderer->renderPixmap(1024, 768);
00122     QPixmap image = QPixmap::grabWidget(renderingView);
00123     //QImage image = renderingView->grabFrameBuffer();
00124     if (!image.save(filename, "PNG")) {
00125         QMessageBox::warning(this, "Save Image", "Error saving image.");
00126     }
00127 }

Generated on Wed Jan 19 2011 13:25:19 for LU Visualisierung WS2010 - Beispiel 1 by  doxygen 1.7.2