C:/Projekte/C++/FlowVIS_107/src/MainWindow.cpp

Go to the documentation of this file.
00001 #include "MainWindow.h"
00002 #include <QFileDialog>
00003 
00004 MainWindow::MainWindow(QWidget* parent /*= 0*/, Qt::WFlags flags /*= 0*/) : 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   // load/save/reset tf
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   // nk - connect reset data view
00030   connect(m_resetView, SIGNAL(triggered()), glWidget, SLOT(resetDataView()));
00031   
00032   // nk - enable/disable UI elements dependent on file status
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     // load dataset
00064     isFileOpened = flowData->loadDataset( strFileName.c_str(), false );
00065 
00066     if(isFileOpened)
00067     {
00068       // gv Do NOT manipulate data here!! Do this in the corresponding methods loadDataset and readFromFile !!!
00069 
00071       navigation->resetGuiElements(isFileOpened);
00072 
00074       navigation->createColorBar(isFileOpened);
00075 
00077       navigation->setBackgroundChooser( flowData->getScalarChannelCount() );
00078 
00079       glWidget->setFlowData(flowData);
00080       //glWidget->setPointSpriteTexture();
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 }

Generated on Mon Jan 21 14:50:12 2008 for VisLU by  doxygen 1.5.4