00001 #include "MainWindow.h"
00002 #include <QFileDialog>
00003
00004 MainWindow::MainWindow(QWidget* parent , Qt::WFlags flags ) : QMainWindow(parent, flags)
00005 {
00006 setupUi(this);
00007
00008 flowData = NULL;
00009 isFileOpened = false;
00010
00011 glWidget = new OpenGLWidget(this);
00012 navigation = new Navigation(glWidget, this);
00013
00015 gridLayout = new QGridLayout();
00016 gridLayout->addWidget(navigation, 0, 0);
00017 gridLayout->addWidget(glWidget, 0, 1, 0, 3);
00018
00019 m_centralwidget->setLayout(gridLayout);
00020
00021 connect(actionLoad, SIGNAL(triggered()), this, SLOT(openFile()) );
00022 connect(actionClose, SIGNAL(triggered()), this, SLOT(closeFile()) );
00023
00024
00025 connect(m_saveTF, SIGNAL(triggered()), navigation, SLOT(saveTF()));
00026 connect(m_loadTF, SIGNAL(triggered()), navigation, SLOT(loadTF()));
00027 connect(m_resetTF, SIGNAL(triggered()), navigation, SLOT(resetTF()));
00028
00029
00030 connect(m_resetView, SIGNAL(triggered()), glWidget, SLOT(resetDataView()));
00031
00032
00033 navigation->resetGuiElements(isFileOpened);
00034 }
00035
00036 MainWindow::~MainWindow()
00037 {
00038 delete flowData;
00039 delete navigation;
00040 delete glWidget;
00041 }
00042
00043 void MainWindow::openFile()
00044 {
00045 cout << "open file..." << endl;
00046 if(isFileOpened)
00047 closeFile();
00048
00049 QString fileName = QFileDialog::getOpenFileName( this, tr("Load Flow Grid"), ".", tr("Data Sets (*.gri)") );
00050
00051 if( !fileName.isNull() )
00052 {
00053 std::string strFileName = std::string( fileName.toLatin1() );
00054 strFileName.erase(strFileName.find(".gri"), 4);
00055
00056 cout << "File: " << strFileName.c_str() << endl;;
00057
00058 if(flowData == NULL)
00059 {
00060 flowData = new FlowData();
00061 }
00062
00063
00064 isFileOpened = flowData->loadDataset( strFileName.c_str(), false );
00065
00066 if(isFileOpened)
00067 {
00068
00069
00071 navigation->resetGuiElements(isFileOpened);
00072
00074 navigation->createColorBar(isFileOpened);
00075
00077 navigation->setBackgroundChooser( flowData->getScalarChannelCount() );
00078
00079 glWidget->setFlowData(flowData);
00080
00081 glWidget->update();
00082 }
00083 }
00084 }
00085
00086 void MainWindow::closeFile()
00087 {
00088 cout << "close file..." << endl;
00089
00090 isFileOpened = false;
00091
00093 navigation->setBackgroundChooser(isFileOpened);
00094
00096 navigation->createColorBar(isFileOpened);
00097
00099 navigation->resetGuiElements(isFileOpened);
00100
00101 delete flowData;
00102 flowData = NULL;
00103 glWidget->setFlowData(flowData);
00104 glWidget->update();
00105 }