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

src/DGVMainVTK.cpp

Go to the documentation of this file.
00001 
00022 #include "DGVMainVTK.h"
00023 
00024 #include <QFileDialog>
00025 
00026 #include "vtkWindowToImageFilter.h"
00027 #include "vtkPNGWriter.h"
00028 #include "vtkJPEGWriter.h"
00029 #include "vtkTIFFWriter.h"
00030 #include "vtkPNMWriter.h"
00031 #include "vtkBMPWriter.h"
00032 #include "vtkPostScriptWriter.h"
00033 #include "vtkXMLImageDataWriter.h"
00034 
00035 //Forms
00036 #include "ui/OperateForm.h"
00037 #include "ui/AboutForm.h"
00038 
00039 DGVMainVTK::DGVMainVTK(QWidget *parent) : QMainWindow(parent)
00040 {
00041     QString tmp;
00042 
00043     workingOn = false;
00044     conductingFFT = false;
00045     conductingFFT_1D = false;
00046     conductingInverseFFT = false;
00047     conductingInverseFFT_1D = false;
00048 
00050     workspaces = new QTabWidget(this);
00051     workspaces->setTabsClosable(true);
00052     newTab();
00053     QMainWindow::setCentralWidget(workspaces);
00054     windowMapper = new QSignalMapper(this);
00055 
00057     console = new DGVConsole(this);
00058     addDockWidget(Qt::RightDockWidgetArea,console);
00059     console->setWindowTitle("Console");
00060     console->show();
00061     console->printWarning("Discrete Geometry Viewer (DGV) Version: " + tmp.setNum(version));
00062     console->printWarning("Copyright Shekhar S. Chandra, 2008-2010.");
00063     console->printWarning("Ready for display and analysis.");
00064 
00066     Transforms = new DGVTransform(this);
00067     Transforms->alwaysWaitTillComplete(false); 
00068     Transforms->setConsole(console);
00069 
00071     createMenu();
00072 
00074     createConnections();
00075 
00076     setAcceptDrops(true);
00077 
00078     setToolTip("<p style='white-space:pre'>Welcome to DGV. Use the <b>context menu</b> (right click) for all operations.\n Load data from the <b>File Menu</b>.</p>");
00079 
00080     readSettings();
00081 }
00082 
00083 DGVMainVTK::~DGVMainVTK()
00084 {
00085     contextMenusToPass.clear();
00086 
00087     //delete Transforms;
00088 }
00089 
00090 void DGVMainVTK::addImage(DGVImageVTK *img)
00091 {
00092     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(img);
00093     img->addToContextMenu(contextMenusToPass);
00094     img->setConsole(console);
00095     commonChildProperties(img);
00096     connect(img, SIGNAL(tableAvailable(DGVTableVTK *)), this, SLOT(displayTable(DGVTableVTK *)));
00097     connect(img, SIGNAL(surfacePlotAvailable(DGVSurfacePlotVTK *)), this, SLOT(displaySurfacePlot(DGVSurfacePlotVTK *)));
00098     connect(img, SIGNAL(plotAvailable(DGVPlot *)), this, SLOT(displayPlot(DGVPlot *)));
00099     connect(img, SIGNAL(plotAvailable(DGVPlotVTK *)), this, SLOT(displayPlot(DGVPlotVTK *)));
00100     connect(img, SIGNAL(recentFileAvailable(const QString &)), this, SLOT(setCurrentFile(const QString &)));
00101     //connect(img, SIGNAL(volumePlotAvailable(DGVVolumePlotVTK *)), this, SLOT(displayVolumePlot(DGVVolumePlotVTK *)));
00102 }
00103 
00104 void DGVMainVTK::addImage(DGVImage *img)
00105 {
00106     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(img);
00107     commonChildProperties(img);
00108     connect(img, SIGNAL(tableAvailable(DGVTable *)), this, SLOT(displayTable(DGVTable *)));
00109 }
00110 
00111 void DGVMainVTK::addTable(DGVTable *tbl)
00112 {
00113     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(tbl);
00114     commonChildProperties(tbl);
00115     connect(tbl, SIGNAL(plotAvailable(DGVPlot *)), this, SLOT(displayPlot(DGVPlot *)));
00116 }
00117 
00118 void DGVMainVTK::addTable(DGVTableVTK *tbl)
00119 {
00120     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(tbl);
00121     tbl->addToContextMenu(contextMenusToPass);
00122     tbl->setConsole(console);
00123     commonChildProperties(tbl);
00124     if(!tbl->isLinkedToImage())
00125         connect(tbl, SIGNAL(cellChanged(int,int)), tbl, SLOT(updateData(int,int)));
00126     connect(tbl, SIGNAL(plotAvailable(DGVPlot *)), this, SLOT(displayPlot(DGVPlot *)));
00127     connect(tbl, SIGNAL(animationAvailable(DGVAnimatedScan *)), this, SLOT(displayScan(DGVAnimatedScan *)));
00128     connect(tbl, SIGNAL(surfacePlotAvailable(DGVSurfacePlotVTK *)), this, SLOT(displaySurfacePlot(DGVSurfacePlotVTK *)));
00129     connect(tbl, SIGNAL(fftSelectionAvailable(Array<Array<complex<tableType>,1>,1> )), this, SLOT(FFT_1D(Array<Array<complex<tableType>,1>,1> )));
00130     connect(tbl, SIGNAL(ifftSelectionAvailable(Array<Array<complex<tableType>,1>,1> )), this, SLOT(iFFT_1D(Array<Array<complex<tableType>,1>,1> )));
00131     connect(tbl, SIGNAL(fftRealSelectionAvailable(Array<Array<tableType,1>,1> )), this, SLOT(FFT_Real_1D(Array<Array<tableType,1>,1> )));
00132     connect(tbl, SIGNAL(ifftRealSelectionAvailable(Array<Array<complex<tableType>,1>,1> )), this, SLOT(iFFT_Real_1D(Array<Array<complex<tableType>,1>,1> )));
00133     connect(tbl, SIGNAL(recentFileAvailable(const QString &)), this, SLOT(setCurrentFile(const QString &)));
00134 }
00135 
00136 void DGVMainVTK::addPlot(DGVPlot *plot)
00137 {
00138     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(plot);
00139     commonChildProperties(plot);
00140     //connect(img, tableAvailable(DGVTable *), this, displayTable(DGVTable *));
00141 }
00142 
00143 void DGVMainVTK::addPlot(DGVPlotVTK *plot)
00144 {
00145     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(plot);
00146     commonChildProperties(plot);
00147     //connect(img, tableAvailable(DGVTable *), this, displayTable(DGVTable *));
00148 }
00149 
00150 void DGVMainVTK::addScan(DGVAnimatedScan *scan)
00151 {
00152     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(scan);
00153     commonChildProperties(scan);
00154 }
00155 
00156 void DGVMainVTK::addSurfacePlot(DGVSurfacePlotVTK *plot)
00157 {
00158     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(plot);
00159     plot->setConsole(console);
00160     commonChildProperties(plot);
00161 }
00162 
00163 void DGVMainVTK::addVolumePlot(DGVVolumePlotVTK *plot)
00164 {
00165     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(plot);
00166     commonChildProperties(plot);
00167     connect(plot, SIGNAL(surfacePlotAvailable(DGVSurfacePlotVTK *)), this, SLOT(displaySurfacePlot(DGVSurfacePlotVTK *)));
00168 }
00169 
00170 void DGVMainVTK::addLattice(DGVLatticeVTK *lattice)
00171 {
00172     qobject_cast<QWorkspace *>(workspaces->currentWidget())->addWindow(lattice);
00173     commonChildProperties(lattice);
00174 }
00175 
00176 bool DGVMainVTK::loadFile(const QString &filename)
00177 {
00178     bool success = false;
00179 
00180     if (!filename.isEmpty())
00181     {
00182         working();
00183         if(filename.contains(".png", Qt::CaseInsensitive)
00184             || filename.contains(".pnm", Qt::CaseInsensitive) || filename.contains(".ppm", Qt::CaseInsensitive) || filename.contains(".pgm", Qt::CaseInsensitive) || filename.contains(".pbm", Qt::CaseInsensitive)
00185             || filename.contains(".jpeg", Qt::CaseInsensitive) || filename.contains(".jpg", Qt::CaseInsensitive)
00186             || filename.contains(".bmp", Qt::CaseInsensitive)
00187             || filename.contains(".tiff", Qt::CaseInsensitive) || filename.contains(".tif", Qt::CaseInsensitive)
00188             || filename.contains(".dicom", Qt::CaseInsensitive) || filename.contains(".dcm", Qt::CaseInsensitive)
00189             || filename.contains(".vti", Qt::CaseInsensitive) || filename.contains(".vtk", Qt::CaseInsensitive)
00190             || filename.contains(".tga", Qt::CaseInsensitive) )
00191         {
00192             DGVImageVTK *image = new DGVImageVTK(this);
00193 
00194             console->printInfo("Opening Image: " + filename);
00195             connect(image, SIGNAL(volumePlotAvailable(DGVVolumePlotVTK *)), this, SLOT(displayVolumePlot(DGVVolumePlotVTK *))); 
00196             image->setConsole(console);
00197             if(image->openImage(filename))
00198             {
00199                 displayImage(image);
00200                 success = true;
00201             }
00202             else
00203                 console->printError("An error was enountered while loading the image " + filename);
00204         }
00205         else if(filename.contains(".csv", Qt::CaseInsensitive))
00206         {
00207             DGVTableVTK *table = new DGVTableVTK(this);
00208 
00209             console->printInfo("Opening Table: " + filename);
00210             table->setConsole(console);
00211             if(table->loadCSV(filename))
00212             {
00213                 table->setName(filename);
00214                 displayTable(table);
00215                 success = true;
00216             }
00217             else
00218                 console->printError("Unable to load data file " + filename + ". Check the data Delimiters and Try opening the file again.");
00219         }
00220         else if(filename.contains(".dat", Qt::CaseInsensitive) || filename.contains(".gnu", Qt::CaseInsensitive) || filename.contains(".gnuplot", Qt::CaseInsensitive))
00221         {
00222             DGVPlot *gnuPlot = new DGVPlot(this);
00223 
00224             gnuPlot->loadGNU(filename);
00225             displayPlot(gnuPlot);
00226             success = true;
00227         }
00228         else if(filename.contains(".dio", Qt::CaseInsensitive))
00229         {
00230             DGVDiophantineVTK dioFile;
00231             DGVLatticeVTK *lattice;
00232 
00233             console->printInfo("Opening Diophantine File: " + filename);
00234             lattice = dioFile.loadFile(filename); 
00235             lattice->setName(filename);
00236             displayLattice(lattice);
00237             success = true;
00238         }
00239         else if(filename.contains(".blz", Qt::CaseInsensitive) || filename.contains(".blitz", Qt::CaseInsensitive))
00240         {
00241             ifstream inFile(filename.toStdString().c_str(),ios::in);
00242             string tmpStr1, tmpStr2;
00243             DGVImageVTK *blitzImage = new DGVImageVTK(this);
00244 
00245             inFile >> tmpStr1 >> tmpStr2;
00246 
00247             if(tmpStr2 == "Yes")
00248             {
00249                 blitzImage->complexValuedMode(true);
00250                 inFile >> blitzImage->dataComplex();
00251             }
00252             else
00253             {
00254                 blitzImage->complexValuedMode(false);
00255                 inFile >> blitzImage->data();
00256             }
00257             blitzImage->setName(filename);
00258             blitzImage->generateImage();
00259             displayImage(blitzImage);
00260 
00261             inFile.close();
00262             success = true;
00263         }
00264         else
00265         {
00266             console->printError("File Type in: " + filename + " not supported! Check extension.");
00267             success = false;
00268         }
00269         if(success)
00270             setCurrentFile(filename);
00271         done();
00272     }
00273     return success;
00274 }
00275 
00276 void DGVMainVTK::loadFiles(const QStringList &filenames)
00277 {
00278     for(int j = 0; j < filenames.size(); j ++)
00279         loadFile(filenames[j]); //Errors handled internally
00280 }
00281 
00282 bool DGVMainVTK::loadStack(const QString &filename)
00283 {
00284     bool success = false;
00285 
00286     if (!filename.isEmpty())
00287     {
00288         working();
00289         if(filename.contains(".png", Qt::CaseInsensitive)
00290             || filename.contains(".pnm", Qt::CaseInsensitive) || filename.contains(".ppm", Qt::CaseInsensitive) || filename.contains(".pgm", Qt::CaseInsensitive) || filename.contains(".pbm", Qt::CaseInsensitive)
00291             || filename.contains(".jpeg", Qt::CaseInsensitive) || filename.contains(".jpg", Qt::CaseInsensitive)
00292             || filename.contains(".bmp", Qt::CaseInsensitive)
00293             || filename.contains(".tiff", Qt::CaseInsensitive) || filename.contains(".tif", Qt::CaseInsensitive))
00294         {
00295             DGVImageVTK *image = new DGVImageVTK(this);
00296 
00297             console->printInfo("Opening Image: " + filename);
00298             connect(image, SIGNAL(volumePlotAvailable(DGVVolumePlotVTK *)), this, SLOT(displayVolumePlot(DGVVolumePlotVTK *))); 
00299             image->setConsole(console);
00300             if(image->openStack(filename))
00301             {
00302                 displayImage(image);
00303                 success = true;
00304             }
00305             else
00306                 console->printError("An error was enountered while loading the image " + filename);
00307         }
00308         done();
00309     }
00310     if(success)
00311         setCurrentFile(filename);
00312 
00313     return success;
00314 }
00315 
00316 Array<imageType,2>* DGVMainVTK::activeData()
00317 {
00318     if(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow() == 0)
00319     {
00321         return 0;
00322     }
00323     else
00324     {
00325         if(isActiveImage())
00326         {
00327             DGVImageVTK *childImg = qobject_cast<DGVImageVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00328             return &childImg->data();
00329         }
00330         else if(isActiveTable())
00331         {
00332             DGVTableVTK *childTbl = qobject_cast<DGVTableVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00333             return &childTbl->data();
00334         }
00335         else if(isActiveSPlot())
00336         {
00337             DGVSurfacePlotVTK *childSPlt = qobject_cast<DGVSurfacePlotVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00338             return &childSPlt->data();
00339         }
00340         else
00341             return NULL;
00342     }
00343 }
00344 
00345 Array<imageType,2>* DGVMainVTK::activeViewedData()
00346 {
00347     if(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow() == 0)
00348     {
00350         return 0;
00351     }
00352     else
00353     {
00354         if(isActiveImage())
00355         {
00356             DGVImageVTK *childImg = qobject_cast<DGVImageVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00357             return &childImg->dataViewing();
00358         }
00359         else if(isActiveTable())
00360         {
00361             DGVTableVTK *childTbl = qobject_cast<DGVTableVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00362             return &childTbl->dataViewing();
00363         }
00364         else if(isActiveSPlot())
00365         {
00366             DGVSurfacePlotVTK *childSPlt = qobject_cast<DGVSurfacePlotVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00367             return &childSPlt->data();
00368         }
00369         else
00370             return NULL;
00371     }
00372 }
00373 
00374 Array<complex<imageType>,2>* DGVMainVTK::activeDataComplex()
00375 {
00376     if(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow() == 0)
00377     {
00379         return 0;
00380     }
00381     else
00382     {
00383         if(isActiveImage())
00384         {
00385             DGVImageVTK *childImg = qobject_cast<DGVImageVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00386             return &childImg->dataComplex();
00387         }
00388         else if(isActiveTable())
00389         {
00390             DGVTableVTK *childTbl = qobject_cast<DGVTableVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00391             return &childTbl->dataComplex();
00392         }
00393         else
00394             return NULL;
00395     }
00396 }
00397 
00398 bool DGVMainVTK::isActiveDataComplex()
00399 {
00400     if(isActiveImage())
00401     {
00402         DGVImageVTK *childImg = qobject_cast<DGVImageVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00403         return childImg->isComplexValued();
00404     }
00405     else if(isActiveTable())
00406     {
00407         DGVTableVTK *childTbl = qobject_cast<DGVTableVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00408         return childTbl->isComplexValued();
00409     }
00410     else
00411         return false;
00412 }
00413 
00414 QString DGVMainVTK::activeName()
00415 {
00416     if(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow() == 0)
00417     {
00419         return 0;
00420     }
00421     else
00422     {
00423         if(isActiveImage())
00424         {
00425             DGVImageVTK *childImg = qobject_cast<DGVImageVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00426             return childImg->strippedName();
00427         }
00428         else if(isActiveTable())
00429         {
00430             DGVTableVTK *childTbl = qobject_cast<DGVTableVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00431             return childTbl->strippedName();
00432         }
00433         else if(isActiveSPlot())
00434         {
00435             DGVSurfacePlotVTK *childSPlt = qobject_cast<DGVSurfacePlotVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00436             return childSPlt->strippedName();
00437         }
00438         else if(isActiveVPlot())
00439         {
00440             DGVVolumePlotVTK *childVPlt = qobject_cast<DGVVolumePlotVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00441             return childVPlt->strippedName();
00442         }
00443         else
00444             return "Unrecognised Display";
00445     }
00446 }
00447 
00448 QString DGVMainVTK::activeNamePrefix()
00449 {
00450     if(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow() == 0)
00451     {
00453         return 0;
00454     }
00455     else
00456     {
00457         if(isActiveImage())
00458         {
00459             DGVImageVTK *childImg = qobject_cast<DGVImageVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00460             return childImg->strippedNamePrefix();
00461         }
00462         else if(isActiveTable())
00463         {
00464             DGVTableVTK *childTbl = qobject_cast<DGVTableVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00465             return childTbl->strippedNamePrefix();
00466         }
00467         else if(isActiveSPlot())
00468         {
00469             DGVSurfacePlotVTK *childSPlt = qobject_cast<DGVSurfacePlotVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00470             return childSPlt->strippedNamePrefix();
00471         }
00472         else if(isActiveVPlot())
00473         {
00474             DGVVolumePlotVTK *childVPlt = qobject_cast<DGVVolumePlotVTK *>(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow());
00475             return childVPlt->strippedNamePrefix();
00476         }
00477         else
00478             return "Unrecognised Display";
00479     }
00480 }
00481 
00482 //Slots
00483 void DGVMainVTK::displayImage(DGVImageVTK *newImage)
00484 {
00485     working();
00487     addImage(newImage);
00488     console->printMessage("Displaying " + newImage->strippedNamePrefix());
00489     newImage->setToolTip("<p style='white-space:pre'>VTK Image Viewer 2 Keys - <b>f:</b> Move to, <b>r:</b> Reset, <b>Shift+r:</b> Reset Camera,\n<b>Shift+Mouse1:</b> Translate, <b>Shift+Ctrl+Mouse1:</b> Zoom</p>");
00490     //newImage->setWindowFlags(Qt::WindowShadeButtonHint);
00491     newImage->show();
00492     done();
00493 }
00494 
00495 void DGVMainVTK::displayImage(DGVImage *newImage)
00496 {
00497     working();
00499     addImage(newImage);
00500     console->printMessage("Displaying " + newImage->strippedNamePrefix());
00501     newImage->show();
00502     done();
00503 }
00504 
00505 void DGVMainVTK::displayTable(DGVTable *newTable)
00506 {
00507     working();
00509     //newTable->resizeColumnsToContents();
00510     //newTable->adjustSize();
00511     addTable(newTable);
00512     console->printMessage("Displaying " + newTable->strippedNamePrefix());
00513     newTable->show();
00514     done();
00515 }
00516 
00517 void DGVMainVTK::displayTable(DGVTableVTK *newTable)
00518 {
00519     working();
00521     //newTable->resizeColumnsToContents(); //!Slows program down
00522     //newTable->adjustSize();
00523     addTable(newTable);
00524     console->printMessage("Displaying " + newTable->strippedNamePrefix());
00525     newTable->setToolTip("<p style='white-space:pre'>Use the <b>context menu</b> (right click) for all operations.</p>");
00526     newTable->show();
00527     done();
00528 }
00529 
00530 void DGVMainVTK::displayPlot(DGVPlot *newPlot)
00531 {
00532     working();
00534     addPlot(newPlot);
00535     console->printMessage("Displaying " + newPlot->strippedNamePrefix());
00536     newPlot->setToolTip("<p style='white-space:pre'>Use the <b>context menu</b> (right click) for all operations.</p>");
00537     newPlot->show();
00538     done();
00539 }
00540 
00541 void DGVMainVTK::displayPlot(DGVPlotVTK *newPlot)
00542 {
00543     working();
00545     addPlot(newPlot);
00546     console->printMessage("Displaying " + newPlot->strippedNamePrefix());
00547     newPlot->show();
00548     done();
00549 }
00550 
00551 void DGVMainVTK::displayScan(DGVAnimatedScan *newScan)
00552 {
00553     working();
00555     addScan(newScan);
00556     console->printMessage("Displaying " + newScan->strippedNamePrefix());
00557     newScan->show();
00558     done();
00559 }
00560 
00561 void DGVMainVTK::displaySurfacePlot(DGVSurfacePlotVTK *newPlot)
00562 {
00563     working();
00565     addSurfacePlot(newPlot);
00566     console->printMessage("Displaying " + newPlot->strippedNamePrefix());
00567     newPlot->setToolTip("<p style='white-space:pre'>VTK Render Window Keys - <b>f:</b> Move to, <b>r:</b> Reset, <b>Shift+r:</b> Reset Camera,\n<b>Shift+Mouse1:</b> Translate, <b>Shift+Ctrl+Mouse1:</b> Zoom</p>");
00568     newPlot->show();
00569     done();
00570 }
00571 
00572 void DGVMainVTK::displayVolumePlot(DGVVolumePlotVTK *newPlot)
00573 {
00574     working();
00576     addVolumePlot(newPlot);
00577     console->printMessage("Displaying " + newPlot->strippedNamePrefix());
00578     newPlot->setToolTip("<p style='white-space:pre'>VTK Render Window Keys - <b>f:</b> Move to, <b>r:</b> Reset, <b>Shift+r:</b> Reset Camera,\n<b>Shift+Mouse1:</b> Translate, <b>Shift+Ctrl+Mouse1:</b> Zoom</p>");
00579     newPlot->show();
00580     done();
00581 }
00582 
00583 void DGVMainVTK::displayLattice(DGVLatticeVTK *newLattice)
00584 {
00585     working();
00587     addLattice(newLattice);
00588     console->printMessage("Displaying Lattice: " + newLattice->strippedName());
00589     newLattice->setToolTip("<p style='white-space:pre'>VTK Render Window Keys - <b>f:</b> Move to, <b>r:</b> Reset, <b>Shift+r:</b> Reset Camera,\n<b>Shift+Mouse1:</b> Translate, <b>Shift+Ctrl+Mouse1:</b> Zoom</p>");
00590     newLattice->show();
00591     done();
00592 }
00593 
00594 void DGVMainVTK::createImage(Array<imageType,2> newData, QString imgName)
00595 {
00596     DGVImageVTK *image = new DGVImageVTK(this);
00597 
00598     console->printInfo("Generating Image and Displaying Result: " + imgName);
00599     image->setName(imgName);
00600     image->setConsole(console);
00601     if(actionCenterDC->isChecked() && conductingFFT)
00602     {
00603         console->printInfo("Shifting DC: Check alignment for odd arrays sizes.");
00604         Transforms->shiftDC(newData);
00605         conductingFFT = false;
00606         conductingInverseFFT = false;
00607     }
00608     if(actionNormalise->isChecked() && conductingInverseFFT)
00609     {
00610         console->printInfo("Normalising FFT.");
00611         Transforms->normalise(newData);
00612         conductingInverseFFT = false;
00613     }
00614     image->setData(newData);
00615     image->generateImage();
00616     console->printMessage("Done Generating");
00617 
00618     displayImage(image);
00619 }
00620 
00621 void DGVMainVTK::createImage(Array< complex<imageType>,2 > newData, QString imgName)
00622 {
00623     DGVImageVTK *image = new DGVImageVTK(this);
00624 
00625     console->printInfo("Generating Image and Displaying Result: " + imgName);
00626     image->setName(imgName);
00627     image->setConsole(console);
00628     if(actionCenterDC->isChecked() && conductingFFT)
00629     {
00630         console->printInfo("Shifting DC: Check alignment for odd arrays sizes.");
00631         Transforms->shiftDC(newData);
00632         conductingFFT = false;
00633         conductingInverseFFT = false;
00634     }
00635     if(actionNormalise->isChecked() && conductingInverseFFT)
00636     {
00637         console->printInfo("Normalising FFT.");
00638         Transforms->normalise(newData);
00639         conductingInverseFFT = false;
00640     }
00641     image->setData(newData);
00642     image->generateImage();
00643     console->printMessage("Done Generating");
00644 
00645     displayImage(image);
00646 }
00647 
00648 void DGVMainVTK::createTable(Array<imageType,2> newData, QString tblName)
00649 {
00650     DGVTableVTK *tbl = new DGVTableVTK(this);
00651 
00652     console->printInfo("Generating Table and Displaying Result");
00653     tbl->setName(tblName);
00654     tbl->setConsole(console);
00656     if(actionNormalise->isChecked() && conductingInverseFFT_1D)
00657     {
00658         console->printInfo("Normalising 1D FFT.");
00659         //Transforms->normalise(newData); //Doesn't work well for multiple 1D FFTs
00660         if(newData.cols() > newData.rows())
00661             newData /= newData.cols();
00662         else
00663             newData /= newData.rows();
00664         conductingInverseFFT_1D = false;
00665     }
00666     tbl->setData(newData);
00667     console->printMessage("Done Generating");
00668 
00669     displayTable(tbl);
00670 }
00671 
00672 void DGVMainVTK::createTable(Array< complex<imageType>,2 > newData, QString tblName)
00673 {
00674     DGVTableVTK *tbl = new DGVTableVTK(this);
00675 
00676     console->printInfo("Generating Complex Table and Displaying Result");
00677     tbl->setName(tblName);
00678     tbl->setConsole(console);
00679     if(actionCenterDC->isChecked() && conductingFFT_1D)
00680     {
00681         console->printInfo("Shifting DC: Check alignment for odd arrays sizes.");
00682         Transforms->shiftDC(newData);
00683         conductingFFT_1D = false;
00684         conductingInverseFFT_1D = false;
00685     }
00686     if(actionNormalise->isChecked() && conductingInverseFFT_1D)
00687     {
00688         console->printInfo("Normalising 1D FFT.");
00689         //Transforms->normalise(newData); //Doesn't work well for multiple 1D FFTs
00690         if(newData.cols() > newData.rows())
00691             newData /= newData.cols();
00692         else
00693             newData /= newData.rows();
00694         conductingFFT_1D = false;
00695         conductingInverseFFT_1D = false;
00696     }
00697     tbl->setData(newData);
00698     console->printMessage("Done Generating");
00699 
00700     displayTable(tbl);
00701 }
00702 
00703 void DGVMainVTK::open()
00704 {
00705     QFileDialog *fileOpener = new QFileDialog(this);
00706     QSettings settings("Shakes", "DGV");
00707 
00708     QString path = settings.value("recentPath").toString();
00709     QStringList filenames = fileOpener->getOpenFileNames(this,
00710                            tr("Select File(s) to Open"),
00711                            path,
00712     tr("Images (*.png *.pnm *.ppm *.pgm *.pbm *.jpeg *.jpg *.bmp *.tiff *.tif *.tga);;DICOM Images (*.dcm *.dicom);;CSV Files (*.csv);;VTK Files (*.vti *.vtk);;GNUPlot 2D Files (*.dat *.gnu *.gnuplot);;Diophantine Files (*.dio);;Blitz Array Format (*.blz *.blitz)"));
00713 
00714     loadFiles(filenames);
00715 }
00716 
00717 void DGVMainVTK::openStack()
00718 {
00719     QFileDialog *fileOpener = new QFileDialog(this);
00720     QSettings settings("Shakes", "DGV");
00721 
00722     QString path = settings.value("recentPath").toString();
00723     QString filename = fileOpener->getOpenFileName(this,
00724                            tr("Select First File in Stack"),
00725                            path,
00726     tr("Images (*.png *.pnm *.ppm *.pgm *.pbm *.jpeg *.jpg *.bmp *.tiff *.tif)"));
00727 
00728     loadStack(filename);
00729 }
00730 
00731 void DGVMainVTK::openRecentFile()
00732 {
00733     QAction *action = qobject_cast<QAction *>(sender());
00734     if(action)
00735         loadFile(action->data().toString());
00736 }
00737 
00738 void DGVMainVTK::save()
00739 {
00740     QSettings settings("Shakes", "DGV");
00741     QString path = settings.value("recentPath").toString(), filename;
00742     QWidget *activeWindow = qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow();
00743 
00744     if(!activeWindow)
00745         return;
00746     else
00747     {
00748         QFileDialog *fileSaver = new QFileDialog(this);
00749 
00750         if(isActiveImage() || isActiveSPlot() || isActiveVPlot() || isActiveLattice())
00751         {
00752             vtkWindowToImageFilter *windowToImage = vtkWindowToImageFilter::New();
00753             QVTKWidget *windowVTK = qobject_cast<QVTKWidget *>(activeWindow);
00754 
00755             if(windowVTK == 0)
00756                 return;
00757 
00758             filename = fileSaver->getSaveFileName(this,
00759                                    tr("Select File Name to Save"),
00760                                    path,
00761                                    tr("Images (*.png *.pnm *.ppm *.pgm *.jpeg *.jpg *.bmp *.tiff *.tif *.vti *.ps)"));
00762 
00763             if (!filename.isEmpty())
00764             {
00765                 QFileInfo fi(filename);
00766                 QString extension = fi.suffix().toLower();
00767 
00768                 windowToImage->SetInput(windowVTK->GetRenderWindow());
00769                 windowToImage->Update();
00770 
00771                 if(extension == "png")
00772                 {
00773                     vtkPNGWriter *writer = vtkPNGWriter::New();
00774                     writer->SetInputConnection(windowToImage->GetOutputPort()); //Cant group outside if's GCC compiler error
00775                     writer->SetFileName(filename.toStdString().c_str());
00776                     windowVTK->GetRenderWindow()->Render();
00777                     writer->Write();
00778                     writer->Delete();
00779                 }
00780                 else if(extension == "jpeg" || extension == "jpg")
00781                 {
00782                     vtkJPEGWriter *writer = vtkJPEGWriter::New();
00783                     writer->SetInputConnection(windowToImage->GetOutputPort());
00784                     writer->SetFileName(filename.toStdString().c_str());
00785                     windowVTK->GetRenderWindow()->Render();
00786                     writer->Write();
00787                     writer->Delete();
00788                 }
00789                 else if(extension == "tiff" || extension == "tif")
00790                 {
00791                     vtkTIFFWriter *writer = vtkTIFFWriter::New();
00792                     writer->SetInputConnection(windowToImage->GetOutputPort());
00793                     writer->SetFileName(filename.toStdString().c_str());
00794                     windowVTK->GetRenderWindow()->Render();
00795                     writer->Write();
00796                     writer->Delete();
00797                 }
00798                 else if(extension == "pnm" || extension == "ppm" || extension == "pgm")
00799                 {
00800                     vtkPNMWriter *writer = vtkPNMWriter::New();
00801                     writer->SetInputConnection(windowToImage->GetOutputPort());
00802                     writer->SetFileName(filename.toStdString().c_str());
00803                     windowVTK->GetRenderWindow()->Render();
00804                     writer->Write();
00805                     writer->Delete();
00806                 }
00807                 else if(extension == "bmp")
00808                 {
00809                     vtkBMPWriter *writer = vtkBMPWriter::New();
00810                     writer->SetInputConnection(windowToImage->GetOutputPort());
00811                     writer->SetFileName(filename.toStdString().c_str());
00812                     windowVTK->GetRenderWindow()->Render();
00813                     writer->Write();
00814                     writer->Delete();
00815                 }
00816                 else if(extension == "ps")
00817                 {
00818                     vtkPostScriptWriter *writer = vtkPostScriptWriter::New();
00819                     writer->SetInputConnection(windowToImage->GetOutputPort());
00820                     writer->SetFileName(filename.toStdString().c_str());
00821                     windowVTK->GetRenderWindow()->Render();
00822                     writer->Write();
00823                     writer->Delete();
00824                 }
00825                 else if(extension == "vti")
00826                 {
00827                     vtkXMLImageDataWriter* writer = vtkXMLImageDataWriter::New();
00828                     writer->SetInputConnection(windowToImage->GetOutputPort());
00829                     writer->SetFileName(filename.toStdString().c_str());
00830                     writer->SetDataModeToBinary();
00831                     windowVTK->GetRenderWindow()->Render();
00832                     writer->Write();
00833                     writer->Delete();
00834                 }
00835                 else
00836                 {
00837                     console->printError("Unsupported Format");
00838                     return;
00839                 }
00840             }
00841 
00842             windowToImage->Delete();
00843         }
00844         else if(isActiveTable())
00845             activeTable()->saveAll(); 
00846 
00847         /*else if(isActivePlot())
00848         {
00849             filename = fileSaver->getSaveFileName(this,
00850                                    tr("Select File Name to Save"),
00851                                    path,
00852                                    tr("Images (*.png *.ppm *.jpeg *.jpg *.bmp *.tiff *.tif);; Vector Graphics (*.svg)"));
00853             QFileInfo fi(filename);
00854             QString extension = fi.suffix().toLower();
00855 
00856             if (!filename.isEmpty())
00857             {
00858                 if(extension == "png" || extension == "ppm" || extension == "jpeg" || extension == "jpg"
00859                     || extension == "bmp" || extension == "tiff" || extension == "tif")
00860                 {
00862                     image = QPixmap::grabWidget(activeWindow);
00863                     image.save(filename,0,100);
00864                 }
00865                 else if(extension == "svg")
00866                 {
00867                     QSvgGenerator svg;
00868                     svg.setFileName(filename);
00869                     svg.setSize(activePlot()->rect().size());
00870 
00871                     QPainter painter(&svg);
00872                     activePlot()->print(&painter, activePlot()->rect());
00873                     painter.end();
00874                 }
00875             }
00876         }*/
00877         else
00878         {
00879             console->printError("Could not save active window. Active window doesn't appear to be supported.");
00880             return;
00881         }
00882         console->printMessage("Saved Data As: " + filename);
00883         setCurrentFile(filename);
00884     }
00885 }
00886 
00887 void DGVMainVTK::saveNative()
00888 {
00889     QSettings settings("Shakes", "DGV");
00890     QString path = settings.value("recentPath").toString(), filename;
00891     QWidget *activeWindow = qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow();
00892 
00893     if(!activeWindow)
00894         return;
00895     else
00896     {
00897         QFileDialog *fileSaver = new QFileDialog(this);
00898         ofstream outFile;
00899 
00900         filename = fileSaver->getSaveFileName(this,
00901                                    tr("Select File Name to Save"),
00902                                    path,
00903                                    tr("Blitz Array Format (*.blz *.blitz)"));
00904 
00905         if (!filename.isEmpty())
00906         {
00907             outFile.open(filename.toStdString().c_str(),ios::out);
00908 
00909             outFile << "Complex: ";
00910             if(isActiveDataComplex())
00911                 outFile << "Yes" << endl << *activeDataComplex();
00912             else
00913                 outFile << "No" << endl << *activeData();
00914 
00915             outFile.close();
00916             console->printMessage("Saved Data As: " + filename);
00917             setCurrentFile(filename);
00918         }
00919     }
00920 }
00921 
00922 void DGVMainVTK::saveStack()
00923 {
00924     QSettings settings("Shakes", "DGV");
00925     QString path = settings.value("recentPath").toString(), filename;
00926     QWidget *activeWindow = qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow();
00927 
00928     if(!activeWindow || !isActiveImage())
00929         return;
00930     else
00931     {
00932         QFileDialog *fileSaver = new QFileDialog(this);
00933 
00934         filename = fileSaver->getSaveFileName(this,
00935                                    tr("Enter First File Name (with extension)"),
00936                                    path,
00937                                    tr("Images (*.png *.pnm *.ppm *.pgm *.pbm *.jpeg *.jpg *.bmp *.tiff *.tif)"));
00938 
00939         if (!filename.isEmpty())
00940         {
00941             working();
00942             DGVImageVTK *actImage = activeImage();
00943 
00944             actImage->saveStack(filename);
00945             done();
00946         }
00947     }
00948 }
00949 
00950 void DGVMainVTK::newTab()
00951 {
00952     QWorkspace *tmpPtr = new QWorkspace; 
00953     workspaces->addTab(tmpPtr, tr("Empty"));
00954     workspaces->setCurrentWidget(tmpPtr);
00955     tmpPtr->setAttribute(Qt::WA_DeleteOnClose);
00956     connect(tmpPtr, SIGNAL(windowActivated(QWidget *)), this, SLOT(setTabName(QWidget *)));
00957 }
00958 
00959 void DGVMainVTK::newTable()
00960 {
00961     bool ok;
00962     int rows = QInputDialog::getInteger(this, tr("Enter the Number of Rows of the table."),
00963                                           tr("New Rows:"), 23, 0, INT_MAX, 1, &ok);
00964     int cols = QInputDialog::getInteger(this, tr("Enter the Number of Columns of the table."),
00965                                           tr("New Columns:"), 23, 0, INT_MAX, 1, &ok);
00966     int value = QInputDialog::getInteger(this, tr("Enter value to be applied over entire table."),
00967                                           tr("Value:"), 1, 0, INT_MAX, 1, &ok);
00968 
00969     if(ok && rows > 0 && cols > 0)
00970     {
00971         DGVTableVTK *tbl = new DGVTableVTK(this);
00972 
00973         tbl->setWindowTitle("New Table");
00974         tbl->setConsole(console);
00975         tbl->setDataSize(rows,cols);
00976         tbl->data() = static_cast<imageType>(value);
00977         tbl->refresh();
00978         displayTable(tbl);
00979     }
00980 }
00981 
00982 void DGVMainVTK::newImage()
00983 {
00984     bool ok;
00985     int rows = QInputDialog::getInteger(this, tr("Enter the Number of Rows of the image."),
00986                                           tr("New Rows:"), 23, 0, INT_MAX, 1, &ok);
00987     int cols = QInputDialog::getInteger(this, tr("Enter the Number of Columns of the image."),
00988                                           tr("New Columns:"), 23, 0, INT_MAX, 1, &ok);
00989     int grey = QInputDialog::getInteger(this, tr("Enter the greyscale to be applied over entire image."),
00990                                           tr("Greyscale:"), 1, 0, INT_MAX, 1, &ok);
00991 
00992     if(ok && rows > 0 && cols > 0)
00993     {
00994         DGVImageVTK *image = new DGVImageVTK(this);
00995 
00996         image->setDataSize(rows,cols);
00997         image->setWindowTitle("New Image");
00998         image->data() = static_cast<imageType>(grey);
00999         image->setConsole(console);
01000         image->generateImage();
01001         displayImage(image);
01002     }
01003 }
01004 
01005 void DGVMainVTK::table()
01006 {
01007     if(qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow() != 0)
01008     {
01009         Array<imageType,2> *tblData = activeData();
01010         QString nameOfData = activeName();
01011 
01012         createTable(*tblData,nameOfData);
01013     }
01014 }
01015 
01016 void DGVMainVTK::embed()
01017 {
01018     console->printError("To be implemented");
01019 }
01020 
01021 void DGVMainVTK::operate()
01022 {
01023     Array<imageType,2> *dataset1 = NULL, *dataset2 = NULL, result;
01024     Array<complex<imageType>,2> *dataset1Complex = NULL, *dataset2Complex = NULL, resultComplex;
01025     Array<int,1> x_sizes(4), y_sizes(4);
01026     OperateForm *op = new OperateForm(this);
01027     QComboBox *data1 = op->getComboBoxSource1();
01028     QComboBox *data2 = op->getComboBoxSource2();
01029     QComboBox *operation = op->getComboBoxOperation();
01030     bool acceptedOp = false, complexData1 = false, complexData2 = false, pureComplexOp = false;
01031     QString operateName;
01032 
01034     QWidgetList windows = qobject_cast<QWorkspace *>(workspaces->currentWidget())->windowList();
01035 
01036     for(int j = 0; j < windows.size(); j ++)
01037     {
01038         data1->insertItem(j,windows.at(j)->windowTitle());
01039         data2->insertItem(j,windows.at(j)->windowTitle());
01040     }
01041 
01042     acceptedOp = op->exec();
01043 
01044     if(acceptedOp)
01045     {
01046         x_sizes = 0;
01047         y_sizes = 0;
01048         qobject_cast<QWorkspace *>(workspaces->currentWidget())->setActiveWindow(windows.at(data1->currentIndex()));
01049         operateName += activeName();
01050         if(isActiveDataComplex())
01051         {
01052             if(op->onlyViewedData())
01053             {
01054                 dataset1 = activeViewedData();
01055                 x_sizes(0) = dataset1->rows();
01056                 y_sizes(0) = dataset1->cols();
01057             }
01058             else
01059             {
01060                 dataset1Complex = activeDataComplex();
01061                 x_sizes(2) = dataset1Complex->rows();
01062                 y_sizes(2) = dataset1Complex->cols();
01063                 complexData1 = true;
01064             }
01065         }
01066         else
01067         {
01068             dataset1 = activeData();
01069             x_sizes(0) = dataset1->rows();
01070             y_sizes(0) = dataset1->cols();
01071         }
01072         if(!op->isAFunction()) 
01073         {
01074             qobject_cast<QWorkspace *>(workspaces->currentWidget())->setActiveWindow(windows.at(data2->currentIndex()));
01075             operateName += " & ";
01076             operateName += activeName();
01077             if(isActiveDataComplex())
01078             {
01079                 if(op->onlyViewedData())
01080                 {
01081                     dataset2 = activeViewedData();
01082                     x_sizes(1) = dataset2->rows();
01083                     y_sizes(1) = dataset2->cols();
01084                 }
01085                 else
01086                 {
01087                     dataset2Complex = activeDataComplex();
01088                     x_sizes(3) = dataset2Complex->rows();
01089                     y_sizes(3) = dataset2Complex->cols();
01090                     complexData2 = true;
01091                 }
01092             }
01093             else
01094             {
01095                 dataset2 = activeData();
01096                 x_sizes(1) = dataset2->rows();
01097                 y_sizes(1) = dataset2->cols();
01098             }
01099         }
01100 
01101         if(op->isAFunction())
01102         {
01103             if(complexData1)
01104                 resultComplex.resize(dataset1->shape());
01105             else
01106                 result.resize(dataset1->shape());
01107 
01108             if(operation->currentText() == "sin(x)")
01109             {
01110                 console->printInfo("Sine Function was selected");
01111                 if(complexData1 && !op->onlyViewedData())
01112                 {
01113                     resultComplex = sin(*(dataset1Complex));
01114                     createImage(resultComplex,"Sine-" + operateName);
01115                 }
01116                 else
01117                 {
01118                     result = sin(*(dataset1));
01119                     createImage(result,"Sine-" + operateName);
01120                 }
01121             }
01122             else if(operation->currentText() == "cos(x)")
01123             {
01124                 console->printInfo("Cosine Function was selected");
01125                 if(complexData1 && !op->onlyViewedData())
01126                 {
01127                     resultComplex = cos(*(dataset1Complex));
01128                     createImage(resultComplex,"Cosine-" + operateName);
01129                 }
01130                 else
01131                 {
01132                     result = cos(*(dataset1));
01133                     createImage(result,"Cosine-" + operateName);
01134                 }
01135             }
01136             else if(operation->currentText() == "tan(x)")
01137             {
01138                 console->printInfo("Tangent Function was selected");
01139                 if(complexData1 && !op->onlyViewedData())
01140                 {
01141                     resultComplex = tan(*(dataset1Complex));
01142                     createImage(resultComplex,"Tangent-" + operateName);
01143                 }
01144                 else
01145                 {
01146                     result = tan(*(dataset1));
01147                     createImage(result,"Tangent-" + operateName);
01148                 }
01149             }
01150             else if(operation->currentText() == "exp(x)")
01151             {
01152                 console->printInfo("Exponential Function was selected");
01153                 if(complexData1 && !op->onlyViewedData())
01154                 {
01155                     resultComplex = exp(*(dataset1Complex));
01156                     createImage(resultComplex,"Exponent-" + operateName);
01157                 }
01158                 else
01159                 {
01160                     result = exp(*(dataset1));
01161                     createImage(result,"Exponent-" + operateName);
01162                 }
01163             }
01164             else if(operation->currentText() == "ln(1+x)")
01165             {
01166                 console->printInfo("Natural Log Function was selected");
01167                 if(complexData1 && !op->onlyViewedData())
01168                 {
01169                     resultComplex = log(1.0+*(dataset1Complex));
01170                     createImage(resultComplex,"Natural Log-" + operateName);
01171                 }
01172                 else
01173                 {
01174                     result = log(1.0+*(dataset1));
01175                     createImage(result,"Natural Log-" + operateName);
01176                 }
01177             }
01178             else if(operation->currentText() == "log10(1+x)")
01179             {
01180                 console->printInfo("Log Base 10 Function was selected");
01181                 if(complexData1 && !op->onlyViewedData())
01182                 {
01183                     resultComplex = log10(1.0+*(dataset1Complex));
01184                     createImage(resultComplex,"Log Base 10-" + operateName);
01185                 }
01186                 else
01187                 {
01188                     result = log10(1.0+*(dataset1));
01189                     createImage(result,"Log Base 10-" + operateName);
01190                 }
01191             }
01192             else if(operation->currentText() == "x mod M")
01193             {
01194                 console->printInfo("Modulo M Function was selected");
01195                 bool ok;
01196                 QString tmp;
01197 
01198                 double modulus = QInputDialog::getDouble(this, tr("Apply Modulus"), tr("Modulus: "), 256, 0, 2147483647, 1, &ok);
01199                 console->printInfo("Modulus: " + tmp.setNum(modulus));
01200 
01201                 if(complexData1 && !op->onlyViewedData())
01202                     console->printError("Cannot apply modulus to Complex Array."); 
01203                 else
01204                 {
01205                     result = fmod(*(dataset1),modulus);
01206                     createImage(result,"(mod " + tmp.setNum(modulus));
01207                 }
01208             }
01209         }
01210         else
01211         {
01214             int maxRows = 0, maxCols = 0;
01215             for(int j = 0; j < 4; j ++)
01216             {
01217                 if(x_sizes(j) > maxRows)
01218                     maxRows = x_sizes(j);
01219                 if(y_sizes(j) > maxCols)
01220                     maxCols = y_sizes(j);
01221             }
01222 
01223             if(complexData1 || complexData2)
01224             {
01225                 if(complexData1 && !complexData2)
01226                 {
01227                     dataset2Complex = new Array<complex<imageType>,2>(dataset2->shape());
01228                     real(*dataset2Complex) = *dataset2;
01229                 }
01230                 else if(complexData2 && !complexData1)
01231                 {
01232                     dataset1Complex = new Array<complex<imageType>,2>(dataset1->shape());
01233                     real(*dataset1Complex) = *dataset1;
01234                 }
01235                 resultComplex.resizeAndPreserve(maxRows,maxCols);
01236                 pureComplexOp = true;
01237             }
01238             else
01239                 result.resizeAndPreserve(maxRows,maxCols);
01240 
01241             if(operation->currentText() == "Addition")
01242             {
01243                 console->printInfo("Addition was selected");
01244                 if(pureComplexOp)
01245                 {
01246                     resultComplex = *(dataset1Complex) + *(dataset2Complex);
01247                     createImage(resultComplex,"Addition-" + operateName);
01248                 }
01249                 else
01250                 {
01251                     result = *(dataset1) + *(dataset2);
01252                     createImage(result,"Addition-" + operateName);
01253                 }
01254             }
01255             else if(operation->currentText() == "Subtract")
01256             {
01257                 console->printInfo("Subtract was selected");
01258                 if(pureComplexOp)
01259                 {
01260                     resultComplex = *(dataset1Complex) - *(dataset2Complex);
01261                     createImage(resultComplex,"Subtract-" + operateName);
01262                 }
01263                 else
01264                 {
01265                     result = *(dataset1) - *(dataset2);
01266                     createImage(result,"Subtract-" + operateName);
01267                 }
01268             }
01269             else if(operation->currentText() == "Multiply")
01270             {
01271                 console->printInfo("Multiply was selected");
01272                 if(pureComplexOp)
01273                 {
01274                     resultComplex = *(dataset1Complex) * *(dataset2Complex);
01275                     createImage(resultComplex,"Multiply-" + operateName);
01276                 }
01277                 else
01278                 {
01279                     result = *(dataset1) * *(dataset2);
01280                     createImage(result,"Multiply-" + operateName);
01281                 }
01282             }
01283             else if(operation->currentText() == "Divide")
01284             {
01285                 console->printInfo("Divide was selected");
01286                 if(pureComplexOp)
01287                 {
01288                     resultComplex = *(dataset1Complex) / *(dataset2Complex);
01289                     createImage(resultComplex,"Divide-" + operateName);
01290                 }
01291                 else
01292                 {
01293                     result = *(dataset1) / *(dataset2);
01294                     createImage(result,"Divide-" + operateName);
01295                 }
01296             }
01297         }
01298     }
01299 }
01300 
01301 void DGVMainVTK::FFT()
01302 {
01303     working();
01304     conductingFFT = true;
01305     if(isActiveImage())
01306     {
01307         DGVImageVTK *childImg = activeImage();
01308 
01309         console->printInfo("FFT on " + childImg->strippedNamePrefix());
01310         Transforms->setName(childImg->strippedName());
01311         if(!childImg->isComplexValued())
01312         {
01313 //            Array<complex<double>,2> field;
01314 
01315             field.resize(childImg->data().rows(),childImg->data().cols());
01316             real(field) = childImg->data();
01317             Transforms->fft(field);
01318         }
01319         else
01320             Transforms->fft(childImg->dataComplex());
01321         console->printMessage("FFT Complete");
01322     }
01323     else if(isActiveTable())
01324     {
01325         DGVTableVTK *childTbl = activeTable();
01326 //        Array<complex<double>,2> field;
01327 
01328         field.resize(childTbl->data().rows(),childTbl->data().cols());
01329         real(field) = childTbl->data();
01330 
01331         console->printInfo("FFT on " + childTbl->strippedNamePrefix());
01332         Transforms->setName(childTbl->strippedName());
01333         Transforms->fft(field); 
01334         console->printMessage("FFT Complete");
01335     }
01336     else if(isActiveSPlot())
01337     {
01338         DGVSurfacePlotVTK *childSPlt = activeSPlot();
01339 //        Array<complex<double>,2> field;
01340 
01341         field.resize(childSPlt->data().rows(),childSPlt->data().cols());
01342         real(field) = childSPlt->data();
01343 
01344         console->printInfo("FFT on " + childSPlt->strippedNamePrefix());
01345         Transforms->setName(childSPlt->strippedName());
01346         Transforms->fft(field);
01347         console->printMessage("FFT Complete");
01348     }
01349     else if(isActiveVPlot())
01350     {
01351         console->printError("Not implemented yet");
01352     }
01353     done();
01354 }
01355 
01356 void DGVMainVTK::iFFT()
01357 {
01358     working();
01359     conductingInverseFFT = true;
01360     if(isActiveImage())
01361     {
01362         DGVImageVTK *childImg = activeImage();
01363 
01364         console->printInfo("iFFT on " + childImg->strippedNamePrefix());
01365         Transforms->setName(childImg->strippedName());
01366         if(!childImg->isComplexValued())
01367         {
01368             Array<complex<double>,2> kSpace;
01369 
01370             kSpace.resize(childImg->data().rows(),childImg->data().cols());
01371             real(kSpace) = childImg->data();
01372             Transforms->ifft(kSpace);
01373         }
01374         else
01375             Transforms->ifft(childImg->dataComplex());
01376         console->printMessage("iFFT Complete");
01377     }
01378     else if(isActiveTable())
01379     {
01380         DGVTableVTK *childTbl = activeTable();
01381         Array<complex<double>,2> kSpace;
01382 
01383         kSpace.resize(childTbl->data().rows(),childTbl->data().cols());
01384         real(kSpace) = childTbl->data();
01385 
01386         console->printInfo("iFFT on " + childTbl->strippedNamePrefix());
01387         Transforms->setName(childTbl->strippedName());
01388         Transforms->ifft(kSpace);
01389         console->printMessage("iFFT Complete");
01390     }
01391     else if(isActiveSPlot())
01392     {
01393         DGVSurfacePlotVTK *childSPlt = activeSPlot();
01394         Array<complex<double>,2> kSpace;
01395 
01396         kSpace.resize(childSPlt->data().rows(),childSPlt->data().cols());
01397         real(kSpace) = childSPlt->data();
01398 
01399         console->printInfo("iFFT on " + childSPlt->strippedNamePrefix());
01400         Transforms->setName(childSPlt->strippedName());
01401         Transforms->ifft(kSpace);
01402         console->printMessage("iFFT Complete");
01403     }
01404     else if(isActiveVPlot())
01405     {
01406         console->printError("Not implemented yet");
01407     }
01408     done();
01409 }
01410 
01411 void DGVMainVTK::FFT_Real()
01412 {
01413     working();
01414     conductingFFT = true;
01415     if(isActiveImage())
01416     {
01417         DGVImageVTK *childImg = activeImage();
01418 
01419         console->printInfo("FFT on " + childImg->strippedNamePrefix());
01420         Transforms->setName(childImg->strippedName());
01421         Transforms->fft_real(childImg->data());
01422         console->printMessage("FFT Complete");
01423     }
01424     else if(isActiveTable())
01425     {
01426         DGVTableVTK *childTbl = activeTable();
01427 
01428         console->printInfo("FFT on " + childTbl->strippedNamePrefix());
01429         Transforms->setName(childTbl->strippedName());
01430         Transforms->fft_real(childTbl->data());
01431         console->printMessage("FFT Complete");
01432     }
01433     else if(isActiveSPlot())
01434     {
01435         DGVSurfacePlotVTK *childSPlt = activeSPlot();
01436 
01437         console->printInfo("FFT on " + childSPlt->strippedNamePrefix());
01438         Transforms->setName(childSPlt->strippedName());
01439         Transforms->fft_real(childSPlt->data());
01440         console->printMessage("FFT Complete");
01441     }
01442     else if(isActiveVPlot())
01443     {
01444         console->printError("Not implemented yet");
01445     }
01446     done();
01447 }
01448 
01449 void DGVMainVTK::iFFT_Real()
01450 {
01451     working();
01452     conductingInverseFFT = true;
01453     if(isActiveImage())
01454     {
01455         DGVImageVTK *childImg = activeImage();
01456 
01457         console->printInfo("iFFT on " + childImg->strippedNamePrefix());
01458         Transforms->setName(childImg->strippedName());
01459         if(!childImg->isComplexValued())
01460         {
01461             Array<complex<double>,2> kSpace;
01462 
01463             kSpace.resize(childImg->data().rows(),childImg->data().cols());
01464             real(kSpace) = childImg->data();
01465             Transforms->ifft_real(kSpace);
01466         }
01467         else
01468             Transforms->ifft_real(childImg->dataComplex());
01469         console->printMessage("iFFT Complete");
01470     }
01471     else if(isActiveTable())
01472     {
01473         DGVTableVTK *childTbl = activeTable();
01474         Array<complex<double>,2> kSpace;
01475 
01476         kSpace.resize(childTbl->data().rows(),childTbl->data().cols());
01477         real(kSpace) = childTbl->data();
01478 
01479         console->printInfo("iFFT on " + childTbl->strippedNamePrefix());
01480         Transforms->setName(childTbl->strippedName());
01481         Transforms->ifft_real(kSpace);
01482         console->printMessage("iFFT Complete");
01483     }
01484     else if(isActiveSPlot())
01485     {
01486         DGVSurfacePlotVTK *childSPlt = activeSPlot();
01487         Array<complex<double>,2> kSpace;
01488 
01489         kSpace.resize(childSPlt->data().rows(),childSPlt->data().cols());
01490         real(kSpace) = childSPlt->data();
01491 
01492         console->printInfo("iFFT on " + childSPlt->strippedNamePrefix());
01493         Transforms->setName(childSPlt->strippedName());
01494         Transforms->ifft_real(kSpace);
01495         console->printMessage("iFFT Complete");
01496     }
01497     else if(isActiveVPlot())
01498     {
01499         console->printError("Not implemented yet");
01500     }
01501     done();
01502 }
01503 
01504 void DGVMainVTK::FFT_1D(Array<Array<complex<tableType>,1>,1> data)
01505 {
01506     working();
01507 
01508     int maxCols = 0;
01509 
01510     for(int j = 0; j < data.size(); j ++)
01511         if(data(j).size() > maxCols)
01512             maxCols = data(j).size();
01513 
01514     DGVTableVTK *childTbl = activeTable();
01515     Array<complex<tableType>,2> values(data.size(),maxCols);
01516 
01517     values = 0;
01518     for(int j = 0; j < data.size(); j ++)
01519         for(int k = 0; k < data(j).size(); k ++)
01520             values(j,k) = data(j)(k);
01521 
01522     console->printInfo("1D FFT on " + childTbl->strippedNamePrefix());
01523     Transforms->setName(childTbl->strippedName());
01524     console->printInfo("Assuming multiple selections are of same size. If not, then select individually.");
01525     conductingFFT_1D = true;
01526     conductingInverseFFT_1D = false;
01527     Transforms->fft_1D(values);
01528     console->printMessage("1D FFT Complete");
01529 
01530     done();
01531 }
01532 
01533 void DGVMainVTK::iFFT_1D(Array<Array<complex<tableType>,1>,1> data)
01534 {
01535     working();
01536 
01537     int maxCols = 0;
01538 
01539     for(int j = 0; j < data.size(); j ++)
01540         if(data(j).size() > maxCols)
01541             maxCols = data(j).size();
01542 
01543     DGVTableVTK *childTbl = activeTable();
01544     Array<complex<tableType>,2> values(data.size(),maxCols);
01545 
01546     values = 0;
01547     for(int j = 0; j < data.size(); j ++)
01548         for(int k = 0; k < data(j).size(); k ++)
01549             values(j,k) = data(j)(k);
01550 
01551     console->printInfo("1D iFFT on " + childTbl->strippedNamePrefix());
01552     Transforms->setName(childTbl->strippedName());
01553     console->printInfo("Assuming multiple selections are of same size. If not, then select individually.");
01554     conductingFFT_1D = false;
01555     conductingInverseFFT_1D = true;
01556     Transforms->ifft_1D(values);
01557     console->printMessage("1D iFFT Complete");
01558 
01559     done();
01560 }
01561 
01562 void DGVMainVTK::FFT_Real_1D(Array<Array<tableType,1>,1> data)
01563 {
01564     working();
01565 
01566     int maxCols = 0;
01567 
01568     for(int j = 0; j < data.size(); j ++)
01569         if(data(j).size() > maxCols)
01570             maxCols = data(j).size();
01571 
01572     DGVTableVTK *childTbl = activeTable();
01573     Array<tableType,2> values(data.size(),maxCols);
01574 
01575     values = 0;
01576     for(int j = 0; j < data.size(); j ++)
01577         for(int k = 0; k < data(j).size(); k ++)
01578             values(j,k) = data(j)(k);
01579 
01580     console->printInfo("1D Real FFT on " + childTbl->strippedNamePrefix());
01581     Transforms->setName(childTbl->strippedName());
01582     console->printInfo("Assuming multiple selections are of same size. If not, then select individually.");
01583     conductingInverseFFT_1D = false;
01584     Transforms->fft_real_1D(values);
01585     console->printMessage("1D Real FFT Complete");
01586 
01587     done();
01588 }
01589 
01590 void DGVMainVTK::iFFT_Real_1D(Array<Array<complex<tableType>,1>,1> data)
01591 {
01592     working();
01593 
01594     int maxCols = 0;
01595 
01596     for(int j = 0; j < data.size(); j ++)
01597         if(data(j).size() > maxCols)
01598             maxCols = data(j).size();
01599 
01600     DGVTableVTK *childTbl = activeTable();
01601     Array<complex<tableType>,2> values(data.size(),maxCols);
01602 
01603     values = 0;
01604     for(int j = 0; j < data.size(); j ++)
01605         for(int k = 0; k < data(j).size(); k ++)
01606             values(j,k) = data(j)(k);
01607 
01608     console->printInfo("1D Real iFFT on " + childTbl->strippedNamePrefix());
01609     Transforms->setName(childTbl->strippedName());
01610     console->printInfo("Assuming multiple selections are of same size. If not, then select individually.");
01611     conductingInverseFFT_1D = true;
01612     Transforms->ifft_real_1D(values);
01613     console->printMessage("1D Real iFFT Complete");
01614 
01615     done();
01616 }
01617 
01618 void DGVMainVTK::radonSlices()
01619 {
01620     working();
01621     if(isActiveImage())
01622     {
01623         DGVImageVTK *childImg = activeImage();
01624         console->printInfo("FRT on " + childImg->strippedNamePrefix());
01625         Transforms->setName(childImg->strippedName());
01626         if(childImg->isComplexValued())
01627             Transforms->radonSlices(childImg->dataComplex());
01628         else
01629             Transforms->radonSlices(childImg->data());
01630         console->printMessage("FRT Complete");
01631     }
01632     else if(isActiveTable())
01633     {
01634         DGVTableVTK *childTbl = activeTable();
01635         console->printInfo("FRT on " + childTbl->strippedNamePrefix());
01636         Transforms->setName(childTbl->strippedName());
01637         if(childTbl->isComplexValued())
01638             Transforms->radonSlices(childTbl->dataComplex());
01639         else
01640             Transforms->radonSlices(childTbl->data());
01641         console->printMessage("FRT Complete");
01642     }
01643     else if(isActiveSPlot())
01644     {
01645         console->printError("Not implemented yet");
01646     }
01647     else if(isActiveVPlot())
01648     {
01649         console->printError("Not implemented yet");
01650     }
01651     done();
01652 }
01653 
01654 void DGVMainVTK::FRT()
01655 {
01656     working();
01657     if(isActiveImage())
01658     {
01659         DGVImageVTK *childImg = activeImage();
01660         console->printInfo("FRT on " + childImg->strippedNamePrefix());
01661         Transforms->setName(childImg->strippedName());
01662         Transforms->frt(childImg->data());
01663         console->printMessage("FRT Complete");
01664     }
01665     else if(isActiveTable())
01666     {
01667         DGVTableVTK *childTbl = activeTable();
01668         console->printInfo("FRT on " + childTbl->strippedNamePrefix());
01669         Transforms->setName(childTbl->strippedName());
01670         Transforms->frt(childTbl->data());
01671         console->printMessage("FRT Complete");
01672     }
01673     else if(isActiveSPlot())
01674     {
01675         DGVSurfacePlotVTK *childSPlt = activeSPlot();
01676         console->printInfo("FRT on " + childSPlt->strippedNamePrefix());
01677         Transforms->setName(childSPlt->strippedName());
01678         Transforms->frt(childSPlt->data());
01679         console->printMessage("FRT Complete");
01680     }
01681     else if(isActiveVPlot())
01682     {
01683         console->printError("Not implemented yet");
01684     }
01685     done();
01686 }
01687 
01688 void DGVMainVTK::iFRT()
01689 {
01690     working();
01691     if(isActiveImage())
01692     {
01693         DGVImageVTK *childImg = activeImage();
01694         console->printInfo("iFRT on " + childImg->strippedNamePrefix());
01695         Transforms->setName(childImg->strippedName());
01696         Transforms->ifrt(childImg->data());
01697         console->printMessage("iFRT Complete");
01698     }
01699     else if(isActiveTable())
01700     {
01701         DGVTableVTK *childTbl = activeTable();
01702         console->printInfo("iFRT on " + childTbl->strippedNamePrefix());
01703         Transforms->setName(childTbl->strippedName());
01704         Transforms->ifrt(childTbl->data());
01705         console->printMessage("iFRT Complete");
01706     }
01707     else if(isActiveSPlot())
01708     {
01709         DGVSurfacePlotVTK *childSPlt = activeSPlot();
01710         console->printInfo("iFRT on " + childSPlt->strippedNamePrefix());
01711         Transforms->setName(childSPlt->strippedName());
01712         Transforms->ifrt(childSPlt->data());
01713         console->printMessage("iFRT Complete");
01714     }
01715     else if(isActiveVPlot())
01716     {
01717         console->printError("Not implemented yet");
01718     }
01719     done();
01720 }
01721 
01722 void DGVMainVTK::iFRT_Unscaled()
01723 {
01724     working();
01725     if(isActiveImage())
01726     {
01727         DGVImageVTK *childImg = activeImage();
01728         console->printInfo("iFRT (Unscaled) on " + childImg->strippedNamePrefix());
01729         Transforms->setName(childImg->strippedName());
01730         Transforms->ifrtUnscaled(childImg->data());
01731         console->printMessage("iFRT (Unscaled) Complete");
01732     }
01733     else if(isActiveTable())
01734     {
01735         DGVTableVTK *childTbl = activeTable();
01736         console->printInfo("iFRT (Unscaled) on " + childTbl->strippedNamePrefix());
01737         Transforms->setName(childTbl->strippedName());
01738         Transforms->ifrtUnscaled(childTbl->data());
01739         console->printMessage("iFRT (Unscaled) Complete");
01740     }
01741     else if(isActiveSPlot())
01742     {
01743         DGVSurfacePlotVTK *childSPlt = activeSPlot();
01744         console->printInfo("iFRT (Unscaled) on " + childSPlt->strippedNamePrefix());
01745         Transforms->setName(childSPlt->strippedName());
01746         Transforms->ifrtUnscaled(childSPlt->data());
01747         console->printMessage("iFRT (Unscaled) Complete");
01748     }
01749     else if(isActiveVPlot())
01750     {
01751         console->printError("Not implemented yet");
01752     }
01753     done();
01754 }
01755 
01756 void DGVMainVTK::updateWindowMenu()
01757 {
01758     QWidgetList windows = qobject_cast<QWorkspace *>(workspaces->currentWidget())->windowList();
01759     QString text;
01760     DGVImageVTK *childImg = NULL;
01761     DGVTableVTK *childTbl = NULL;
01762     DGVSurfacePlotVTK *childSPlt = NULL;
01763     DGVPlot *childPlt = NULL;
01764     DGVVolumePlotVTK *childVPlt = NULL;
01765     QActionGroup *winGp = new QActionGroup(this);
01766     const int displayLimit = 9;
01767 
01768     menuWindows->clear();
01769     menuWindows->addAction(actionCascade);
01770     menuWindows->addAction(actionTile);
01771     menuWindows->addAction(actionConsole);
01772     if(console->isVisible())
01773         actionConsole->setChecked(true);
01774     else
01775         actionConsole->setChecked(false);
01776     menuWindows->addAction(actionSeparator);
01778 
01779     for (int j = 0; j < windows.size(); j ++)
01780     {
01781         if(!windows.at(j))
01782             continue;
01783         childImg = qobject_cast<DGVImageVTK *>(windows.at(j));
01784 
01785         if(childImg == 0)
01786         {
01787             childTbl = qobject_cast<DGVTableVTK *>(windows.at(j));
01788 
01789             if(childTbl == 0)
01790             {
01791                 childSPlt = qobject_cast<DGVSurfacePlotVTK *>(windows.at(j));
01792 
01793                 if(childSPlt == 0)
01794                 {
01795                     childPlt = qobject_cast<DGVPlot *>(windows.at(j));
01796 
01797                     if(childPlt == 0)
01798                     {
01799                         childVPlt = qobject_cast<DGVVolumePlotVTK *>(windows.at(j));
01800 
01801                         if(childVPlt == 0)
01802                             return;
01803                         else
01804                         {
01805                             if(j < displayLimit)
01806                                 text = tr("&%1 %2").arg(j + 1).arg(childVPlt->strippedNamePrefix());
01807                             else
01808                                 text = tr("%1 %2").arg(j + 1).arg(childVPlt->strippedNamePrefix());
01809                         }
01810                     }
01811                     else
01812                     {
01813                         if(j < displayLimit)
01814                             text = tr("&%1 %2").arg(j + 1).arg(childPlt->strippedNamePrefix());
01815                         else
01816                             text = tr("%1 %2").arg(j + 1).arg(childPlt->strippedNamePrefix());
01817                     }
01818                 }
01819                 else
01820                 {
01821                     if(j < displayLimit)
01822                         text = tr("&%1 %2").arg(j + 1).arg(childSPlt->strippedNamePrefix());
01823                     else
01824                         text = tr("%1 %2").arg(j + 1).arg(childSPlt->strippedNamePrefix());
01825                 }
01826             }
01827             else
01828             {
01829                 if(j < displayLimit)
01830                     text = tr("&%1 %2").arg(j + 1).arg(childTbl->strippedNamePrefix());
01831                 else
01832                     text = tr("%1 %2").arg(j + 1).arg(childTbl->strippedNamePrefix());
01833             }
01834         }
01835         else
01836         {
01837             if(j < displayLimit)
01838                 text = tr("&%1 %2").arg(j + 1).arg(childImg->strippedNamePrefix());
01839             else
01840                 text = tr("%1 %2").arg(j + 1).arg(childImg->strippedNamePrefix());
01841         }
01842 
01843         QAction *action  = menuWindows->addAction(text);
01844         action->setCheckable(true);
01845         winGp->addAction(action);
01846 
01847         if(isActiveImage())
01848             action ->setChecked(childImg == activeImage());
01849         else if(isActiveTable())
01850             action ->setChecked(childTbl == activeTable());
01851         else if(isActiveSPlot())
01852             action ->setChecked(childSPlt == activeSPlot());
01853         else if(isActivePlot())
01854             action ->setChecked(childPlt == activePlot());
01855         else if(isActiveVPlot())
01856             action ->setChecked(childVPlt == activeVPlot());
01857         else
01858             action ->setChecked(false);
01859 
01860         connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
01861         windowMapper->setMapping(action, windows.at(j));
01862     }
01863 
01864     actionSeparator->setVisible(!windows.isEmpty());
01865     menuWindows->addSeparator();
01866     menuWindows->addAction(actionCloseActive);
01867     menuWindows->addAction(actionCloseAll);
01868 }
01869 
01870 void DGVMainVTK::setActiveWindow(QWidget *window)
01871 {
01872     if(!window)
01873         return;
01874     else
01875         qobject_cast<QWorkspace *>(workspaces->currentWidget())->setActiveWindow(window);
01876 }
01877 
01878 void DGVMainVTK::setTabName(QWidget *window)
01879 {
01880     QString tabTitle = activeNamePrefix();
01881     int index = workspaces->currentIndex();
01882 
01883     if(window == NULL)
01884         workspaces->setTabText(index, "Empty");
01885     else
01886         workspaces->setTabText(index, tabTitle);
01887 }
01888 
01889 void DGVMainVTK::closeTab(int index)
01890 {
01891     int newIndex = 0;
01892 
01893     if(workspaces->count() > 1 || index > 0)
01894     {
01895         QWorkspace *tmpWorkspace = qobject_cast<QWorkspace *>(workspaces->widget(index));
01896 
01897         //disconnect(tmpWorkspace, 0, this, 0);
01898         disconnect(tmpWorkspace, SIGNAL(windowActivated(QWidget *)), 0, 0);
01899         tmpWorkspace->closeAllWindows();
01900         tmpWorkspace->close();
01901         workspaces->removeTab(index);
01902 
01903         if(index > 0 && workspaces->currentIndex() == index)
01904             newIndex = workspaces->currentIndex(); //Safe to decrement
01905         else if(index > 0)
01906             newIndex = index-1; //Safe to decrement
01907         workspaces->setCurrentIndex(newIndex); //else use zero
01908     }
01909 }
01910 
01911 void DGVMainVTK::working()
01912 {
01913     if(!workingOn)
01914     {
01915         QPushButton *btnCancel = new QPushButton("Cancel",this);
01916         btnCancel->setDisabled(true);
01917 
01918         workingOn = true;
01919         workingDlg = new QProgressDialog("Busy, Please Wait...", "Cancel", 0, 0, this);
01920         workingDlg->setAutoClose(false);
01921         workingDlg->setAutoReset(false);
01922         workingDlg->setMinimumDuration(1000);
01923         workingDlg->setCancelButton(btnCancel);
01924         workingDlg->setWindowModality(Qt::WindowModal);
01925         workingDlg->show();
01926         qApp->processEvents();
01927     }
01928 }
01929 
01930 void DGVMainVTK::done()
01931 {
01932     if(workingOn)
01933     {
01934         workingOn = false;
01935         workingDlg->cancel();
01936     }
01937 }
01938 
01939 void DGVMainVTK::about()
01940 {
01941     AboutForm *aboutDlg = new AboutForm(this);
01942 
01943     aboutDlg->show();
01944 }
01945 
01946 void DGVMainVTK::cut()
01947 {
01948 }
01949 
01950 void DGVMainVTK::copy()
01951 {
01952 }
01953 
01954 void DGVMainVTK::paste()
01955 {
01956 }
01957 
01958 void DGVMainVTK::createMenu()
01959 {
01960     menuBar = new QMenuBar(this);
01961     //File
01962     menuFile = new QMenu(menuBar);
01963     submenuNew = new QMenu(menuBar);
01964     menuData = new QMenu(menuBar);
01965     menuTransform = new QMenu(menuBar);
01966     submenuFourier = new QMenu(menuBar);
01967     submenuRadon = new QMenu(menuBar);
01968     menuWindows = new QMenu(menuBar);
01969     menuHelp = new QMenu(menuBar);
01970     actionOpen = new QAction(this);
01971     actionOpenStack = new QAction(this);
01972     actionSave = new QAction(this);
01973     actionSaveRaw = new QAction(this);
01974     actionSaveStack = new QAction(this);
01975     actionCloseActive = new QAction(this);
01976     actionCloseAll = new QAction(this);
01977     for (int i = 0; i < MaxRecentFiles; ++i)
01978     {
01979         actionsRecentFile[i] = new QAction(this);
01980         actionsRecentFile[i]->setVisible(false);
01981         connect(actionsRecentFile[i], SIGNAL(triggered()), this, SLOT(openRecentFile()));
01982     }
01983     actionExit = new QAction(this);
01984     actionNewTab = new QAction(this);
01985     actionNewTable = new QAction(this);
01986     actionNewImage = new QAction(this);
01987     //Data
01988     actionTable = new QAction(this);
01989     actionEmbed = new QAction(this);
01990     actionOperate = new QAction(this);
01991     //Transforms
01992     actionFFT = new QAction(this);
01993     actioniFFT = new QAction(this);
01994     actionFFT_Real = new QAction(this);
01995     actioniFFT_Real = new QAction(this);
01996     actionSlice = new QAction(this);
01997     actionFRT = new QAction(this);
01998     actioniFRT = new QAction(this);
01999     actioniFRT_Unscaled = new QAction(this);
02000     actionNormalise = new QAction(this);
02001     actionCenterDC = new QAction(this);
02002     //Window
02003     actionCascade = new QAction(this);
02004     actionTile = new QAction(this);
02005     actionSeparator = new QAction(this);
02006     actionConsole = new QAction(this);
02007     //Help
02008     actionAbout = new QAction(this);
02009 
02012     menuBar->addAction(menuFile->menuAction());
02013     menuFile->addAction(submenuNew->menuAction());
02014     menuFile->setTitle(QApplication::translate("MainWindow", "File", 0, QApplication::UnicodeUTF8));
02015     submenuNew->setTitle(QApplication::translate("MainWindow", "New", 0, QApplication::UnicodeUTF8));
02016     actionOpen->setText(QApplication::translate("MainWindow", "Open...", 0, QApplication::UnicodeUTF8));
02017     actionOpen->setShortcut(tr("Ctrl+o"));
02018     actionOpenStack->setText(QApplication::translate("MainWindow", "Open Stack...", 0, QApplication::UnicodeUTF8));
02019     actionOpenStack->setShortcut(tr("Ctrl+Shift+o"));
02020     actionSave->setText(QApplication::translate("MainWindow", "Save Window as Image...", 0, QApplication::UnicodeUTF8));
02021     actionSave->setShortcut(tr("Ctrl+s"));
02022     actionSaveRaw->setText(QApplication::translate("MainWindow", "Save Slice as Native File...", 0, QApplication::UnicodeUTF8));
02023     actionSaveRaw->setShortcut(tr("Ctrl+Alt+s"));
02024     actionSaveStack->setText(QApplication::translate("MainWindow", "Save Stack...", 0, QApplication::UnicodeUTF8));
02025     actionSaveStack->setShortcut(tr("Ctrl+Shift+s"));
02026     actionCloseActive->setText(QApplication::translate("MainWindow", "Close", 0, QApplication::UnicodeUTF8));
02027     actionCloseActive->setShortcut(tr("Ctrl+w"));
02028     actionCloseAll->setText(QApplication::translate("MainWindow", "Close All", 0, QApplication::UnicodeUTF8));
02029     actionCloseAll->setShortcut(tr("Ctrl+Shift+w"));
02030     actionExit->setText(QApplication::translate("MainWindow", "Exit", 0, QApplication::UnicodeUTF8));
02031     actionExit->setShortcut(tr("Ctrl+x"));
02032     menuFile->addAction(actionOpen);
02033     menuFile->addAction(actionOpenStack);
02034     menuFile->addAction(actionSave);
02035     menuFile->addAction(actionSaveRaw);
02036     menuFile->addAction(actionSaveStack);
02037     menuFile->addSeparator();
02038     menuFile->addAction(actionCloseActive);
02039     menuFile->addAction(actionCloseAll);
02040     menuFile->addSeparator();
02041     for (int i = 0; i < MaxRecentFiles; ++i)
02042          menuFile->addAction(actionsRecentFile[i]);
02043     actionRecentFileSeparator = menuFile->addSeparator();
02044     menuFile->addAction(actionExit);
02045     updateRecentFileActions();
02047     actionNewTab->setText(QApplication::translate("MainWindow", "New Tab", 0, QApplication::UnicodeUTF8));
02048     actionNewTab->setShortcut(tr("Alt+t"));
02049     actionNewTable->setText(QApplication::translate("MainWindow", "New Table", 0, QApplication::UnicodeUTF8));
02050     actionNewTable->setShortcut(tr("Alt+n"));
02051     actionNewImage->setText(QApplication::translate("MainWindow", "New Image", 0, QApplication::UnicodeUTF8));
02052     actionNewImage->setShortcut(tr("Ctrl+n"));
02053     submenuNew->addAction(actionNewTab);
02054     submenuNew->addAction(actionNewTable);
02055     submenuNew->addAction(actionNewImage);
02057     menuBar->addAction(menuData->menuAction());
02058     menuData->setTitle(QApplication::translate("MainWindow", "Data", 0, QApplication::UnicodeUTF8));
02059     actionTable->setText(QApplication::translate("MainWindow", "Table of View", 0, QApplication::UnicodeUTF8));
02060     actionTable->setShortcut(tr("Ctrl+Shift+t"));
02061     menuData->addSeparator();
02062     actionEmbed->setText(QApplication::translate("MainWindow", "Embed/Crop...", 0, QApplication::UnicodeUTF8));
02063     actionEmbed->setDisabled(true);
02064     actionOperate->setText(QApplication::translate("MainWindow", "Operate...", 0, QApplication::UnicodeUTF8));
02065     actionOperate->setShortcut(tr("Ctrl+Shift+o"));
02066     menuData->addAction(actionTable);
02067     menuData->addAction(actionEmbed);
02068     menuData->addAction(actionOperate);
02070     menuBar->addAction(menuTransform->menuAction());
02071     menuTransform->setTitle(QApplication::translate("MainWindow", "Transform", 0, QApplication::UnicodeUTF8));
02072     menuTransform->addAction(submenuFourier->menuAction());
02073     menuTransform->addAction(submenuRadon->menuAction());
02074     submenuFourier->setTitle(QApplication::translate("MainWindow", "Fourier", 0, QApplication::UnicodeUTF8));
02075     submenuRadon->setTitle(QApplication::translate("MainWindow", "Radon", 0, QApplication::UnicodeUTF8));
02076     actionFFT->setText(QApplication::translate("MainWindow", "FFT", 0, QApplication::UnicodeUTF8));
02077     actionFFT->setShortcut(tr("F7"));
02078     actioniFFT->setText(QApplication::translate("MainWindow", "iFFT", 0, QApplication::UnicodeUTF8));
02079     actioniFFT->setShortcut(tr("Shift+F7"));
02080     actionFFT_Real->setText(QApplication::translate("MainWindow", "Real FFT", 0, QApplication::UnicodeUTF8));
02081     actionFFT_Real->setShortcut(tr("F8"));
02082     actioniFFT_Real->setText(QApplication::translate("MainWindow", "Real iFFT", 0, QApplication::UnicodeUTF8));
02083     actioniFFT_Real->setShortcut(tr("Shift+F8"));
02084     actionSlice->setText(QApplication::translate("MainWindow", "Radon Slices", 0, QApplication::UnicodeUTF8));
02085     actionSlice->setShortcut(tr("Ctrl+Shift+F8"));
02086     actionNormalise->setText(QApplication::translate("MainWindow", "Normalise", 0, QApplication::UnicodeUTF8));
02087     actionNormalise->setShortcut(tr("Ctrl+Shift+F7"));
02088     actionNormalise->setCheckable(true);
02089     actionNormalise->setChecked(true);
02090     actionCenterDC->setText(QApplication::translate("MainWindow", "Center DC", 0, QApplication::UnicodeUTF8));
02091     actionCenterDC->setShortcut(tr("Ctrl+F7"));
02092     actionCenterDC->setCheckable(true);
02093     actionCenterDC->setChecked(false);
02094     actionFRT->setText(QApplication::translate("MainWindow", "FRT", 0, QApplication::UnicodeUTF8));
02095     actionFRT->setShortcut(tr("F9"));
02096     actioniFRT->setText(QApplication::translate("MainWindow", "iFRT", 0, QApplication::UnicodeUTF8));
02097     actioniFRT->setShortcut(tr("Shift+F9"));
02098     actioniFRT_Unscaled->setText(QApplication::translate("MainWindow", "iFRT Unscaled", 0, QApplication::UnicodeUTF8));
02099     actioniFRT_Unscaled->setShortcut(tr("Ctrl+Shift+F9"));
02100     submenuFourier->addAction(actionFFT);
02101     submenuFourier->addAction(actioniFFT);
02102     submenuFourier->addAction(actionFFT_Real);
02103     submenuFourier->addAction(actioniFFT_Real);
02104     submenuFourier->addAction(actionSlice);
02105     submenuFourier->addAction(actionNormalise);
02106     submenuFourier->addAction(actionCenterDC);
02107     submenuRadon->addAction(actionFRT);
02108     submenuRadon->addAction(actioniFRT);
02109     submenuRadon->addAction(actioniFRT_Unscaled);
02111     menuBar->addAction(menuWindows->menuAction());
02112     menuWindows->setTitle(QApplication::translate("MainWindow", "Windows", 0, QApplication::UnicodeUTF8));
02113     actionCascade->setText(QApplication::translate("MainWindow", "Cascade", 0, QApplication::UnicodeUTF8));
02114     menuWindows->addAction(actionCascade);
02115     actionTile->setText(QApplication::translate("MainWindow", "Tile", 0, QApplication::UnicodeUTF8));
02116     menuWindows->addAction(actionTile);
02117     actionSeparator->setSeparator(true);
02118     actionConsole->setText(QApplication::translate("MainWindow", "Console", 0, QApplication::UnicodeUTF8));
02119     actionConsole->setCheckable(true);
02120     if(console->isVisible())
02121         actionConsole->setChecked(true);
02122     else
02123         actionConsole->setChecked(false);
02124     menuWindows->addAction(actionConsole);
02125     menuWindows->addAction(actionSeparator);
02126     updateWindowMenu();
02127     connect(menuWindows, SIGNAL(aboutToShow()), this, SLOT(updateWindowMenu()));
02129     menuBar->addAction(menuHelp->menuAction());
02130     menuHelp->setTitle(QApplication::translate("MainWindow", "Help", 0, QApplication::UnicodeUTF8));
02131     actionAbout->setText(QApplication::translate("MainWindow", "About", 0, QApplication::UnicodeUTF8));
02132     actionAbout->setShortcut(tr("Shift+F1"));
02133     menuHelp->addAction(actionAbout);
02134 
02136     contextMenusToPass.append(menuTransform);
02137 
02139     setupTooltips();
02140 
02141     statusBar()->showMessage(tr("Ready"));
02142     setMenuBar(menuBar);
02143 }
02144 
02145 void DGVMainVTK::createConnections()
02146 {
02147     connect(workspaces, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
02148     //connect(windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(setActiveWindow(QWidget *)));
02149 
02150     qRegisterMetaType< Array<imageType,2> >("Array<imageType,2>"); 
02151     qRegisterMetaType< Array< complex<imageType>,2 > >("Array< complex<imageType>,2 >"); 
02152     connect(Transforms, SIGNAL(resultAvailable(Array<imageType,2> , QString)), this, SLOT(createImage(Array<imageType,2> , QString)));
02153     connect(Transforms, SIGNAL(resultAvailable(Array< complex<imageType>,2 > , QString)), this, SLOT(createImage(Array< complex<imageType>,2 > , QString)));
02154     connect(Transforms, SIGNAL(resultAvailable_1D(Array<imageType,2> , QString)), this, SLOT(createTable(Array<imageType,2> , QString)));
02155     connect(Transforms, SIGNAL(resultAvailable_1D(Array< complex<imageType>,2 > , QString)), this, SLOT(createTable(Array< complex<imageType>,2 > , QString)));
02156 
02157     QObject::connect(actionOpen, SIGNAL(activated()), this, SLOT(open()));
02158     QObject::connect(actionOpenStack, SIGNAL(activated()), this, SLOT(openStack()));
02159     QObject::connect(actionSave, SIGNAL(activated()), this, SLOT(save()));
02160     QObject::connect(actionSaveRaw, SIGNAL(activated()), this, SLOT(saveNative()));
02161     QObject::connect(actionSaveStack, SIGNAL(activated()), this, SLOT(saveStack()));
02162     QObject::connect(actionCloseActive, SIGNAL(activated()), this, SLOT(closeTabActiveWindow()));
02163     QObject::connect(actionCloseAll, SIGNAL(activated()), this, SLOT(closeTabAllWindows()));
02164     QObject::connect(actionExit, SIGNAL(activated()), this, SLOT(close()));
02165     QObject::connect(actionNewTab, SIGNAL(activated()), this, SLOT(newTab()));
02166     QObject::connect(actionNewTable, SIGNAL(activated()), this, SLOT(newTable()));
02167     QObject::connect(actionNewImage, SIGNAL(activated()), this, SLOT(newImage()));
02168     //Data
02169     QObject::connect(actionTable, SIGNAL(activated()), this, SLOT(table()));
02170     QObject::connect(actionEmbed, SIGNAL(activated()), this, SLOT(embed()));
02171     QObject::connect(actionOperate, SIGNAL(activated()), this, SLOT(operate()));
02172     //Transform
02173     QObject::connect(actionFFT, SIGNAL(activated()), this, SLOT(FFT()));
02174     QObject::connect(actioniFFT, SIGNAL(activated()), this, SLOT(iFFT()));
02175     QObject::connect(actionFFT_Real, SIGNAL(activated()), this, SLOT(FFT_Real()));
02176     QObject::connect(actioniFFT_Real, SIGNAL(activated()), this, SLOT(iFFT_Real()));
02177     QObject::connect(actionSlice, SIGNAL(activated()), this, SLOT(radonSlices()));
02178     QObject::connect(actionFRT, SIGNAL(activated()), this, SLOT(FRT()));
02179     QObject::connect(actioniFRT, SIGNAL(activated()), this, SLOT(iFRT()));
02180     QObject::connect(actioniFRT_Unscaled, SIGNAL(activated()), this, SLOT(iFRT_Unscaled()));
02181     QObject::connect(actionCascade, SIGNAL(activated()), this, SLOT(cascadeTab()));
02182     QObject::connect(actionTile, SIGNAL(activated()), this, SLOT(tileTab()));
02183     QObject::connect(actionConsole, SIGNAL(triggered(bool)), console, SLOT(setVisible(bool)));
02184     QObject::connect(actionAbout, SIGNAL(activated()), this, SLOT(about()));
02185 }
02186 
02187 void DGVMainVTK::contextMenuEvent(QContextMenuEvent *event)
02188 {
02189     contextMenu = new QMenu(this); 
02190 
02191     contextMenu->addAction(submenuNew->menuAction());
02192     contextMenu->addAction(actionOpen);
02193     contextMenu->addAction(actionSave);
02194     contextMenu->addAction(actionSaveRaw);
02195     contextMenu->addSeparator();
02196     contextMenu->addAction(actionCloseActive);
02197     contextMenu->addAction(actionCloseAll);
02198     contextMenu->addSeparator();
02199     contextMenu->addAction(actionCascade);
02200     contextMenu->addAction(actionTile);
02201     contextMenu->addSeparator();
02202     contextMenu->addAction(actionExit);
02203 
02204     contextMenu->exec(event->globalPos());
02205 }
02206 
02207 void DGVMainVTK::dragEnterEvent(QDragEnterEvent *event)
02208 {
02209     if(event->mimeData()->hasFormat("text/uri-list") || event->mimeData()->hasFormat("text/plain"))
02210         event->acceptProposedAction();
02211 }
02212 
02213 void DGVMainVTK::dropEvent(QDropEvent *event)
02214 {
02215     QList<QUrl> urlsList = event->mimeData()->urls();
02216     QString tmp;
02217 
02218     for(int j = 0; j < urlsList.size(); j ++)
02219     {
02220         if(urlsList[j].isValid())
02221         {
02222             #ifdef Q_WS_WIN
02223                 tmp = urlsList[j].path().remove(0,1); 
02224                 console->printInfo("Dropped Path (Win): " + tmp);
02225                 loadFile(tmp);
02226             #else
02227                 console->printInfo("Dropped Path (Linux): " + urlsList[j].path());
02228                 loadFile(urlsList[j].path());
02229             #endif
02230         }
02231     }
02232 
02233     event->acceptProposedAction();
02234 }
02235 
02236 void DGVMainVTK::closeEvent(QCloseEvent *event)
02237 {
02238     writeSettings();
02239     event->accept();
02240 }
02241 
02242 void DGVMainVTK::setupTooltips()
02243 {
02244     actionSave->setToolTip("Save the state of the window (i.e., exactly how it looks) as an image");
02245     actionSaveRaw->setToolTip("Save the data in exact form with the DGV Native Format. Saves complex and non-complex valued data");
02246     actionTable->setToolTip("Display a table of the data being viewed");
02247     actionOperate->setToolTip("Compute aritmetic with data currently open");
02248     actionTable->setToolTip("Display Table of the data being viewed, which may be different from entire data (e.g. complex data)");
02249     actionEmbed->setToolTip("Embed/Crop the data");
02250     actionOperate->setToolTip("Apply Arithmetic Operation to data");
02251     actionFFT->setStatusTip("Complex-valued Fast Fourier Transform (FFT)");
02252     actioniFFT->setToolTip("Complex-valued Inverse Fast Fourier Transform (iFFT)");
02253     actioniFFT->setStatusTip("Complex-valued Inverse Fast Fourier Transform (iFFT)");
02254     actionFFT_Real->setToolTip("Real-valued Fast Fourier Transform (FFT)");
02255     actionFFT_Real->setStatusTip("Real-valued Fast Fourier Transform (FFT)");
02256     actioniFFT_Real->setToolTip("Real-valued Inverse Fast Fourier Transform (iFFT)");
02257     actioniFFT_Real->setStatusTip("Real-valued Inverse Fast Fourier Transform (iFFT)");
02258     actionSlice->setToolTip("Extract All Radon Slices via the Fourier Slice Theorem");
02259     actionSlice->setStatusTip("Extract All Radon Slices via the Fourier Slice Theorem");
02260     actionFRT->setToolTip("Fast Finite Radon Transform (FRT)");
02261     actionFRT->setStatusTip("Fast Finite Radon Transform (FRT)");
02262     actioniFRT->setToolTip("Inverse Fast Finite Radon Transform (iFRT)");
02263     actioniFRT->setStatusTip("Inverse Fast Finite Radon Transform (iFRT)");
02264     actioniFRT_Unscaled->setToolTip("Unscaled Inverse Fast Finite Radon Transform (iFRT Unscaled)");
02265     actioniFRT_Unscaled->setStatusTip("Unscaled Inverse Fast Finite Radon Transform (iFRT Unscaled)");
02266 }
02267 
02268 //From Qt Examples for Recent Files
02269 void DGVMainVTK::setCurrentFile(const QString &fileName)
02270 {
02271     QFileInfo fi(fileName);
02272 
02273     if(!fileName.isEmpty())
02274         setWindowTitle(tr("%1 - %2").arg(strippedName(fileName)).arg(tr("DGV")));
02275     else
02276         setWindowTitle(tr("Discrete Geometry Viewer"));
02277 
02278     QSettings settings("Shakes", "DGV");
02279     QStringList files = settings.value("recentFileList").toStringList();
02280     files.removeAll(fileName);
02281     files.prepend(fileName);
02282     while (files.size() > MaxRecentFiles)
02283         files.removeLast();
02284 
02285     settings.setValue("recentFileList", files);
02286     settings.setValue("recentPath",fi.absolutePath());
02287 
02288     foreach (QWidget *widget, QApplication::topLevelWidgets())
02289     {
02290         DGVMainVTK *mainWin = qobject_cast<DGVMainVTK *>(widget);
02291         if (mainWin)
02292             mainWin->updateRecentFileActions();
02293     }
02294 }
02295 
02296 //From Qt Examples for Recent Files
02297 void DGVMainVTK::updateRecentFileActions()
02298 {
02299     QSettings settings("Shakes", "DGV");
02300     QStringList files = settings.value("recentFileList").toStringList();
02301 
02302     int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
02303 
02304     for (int i = 0; i < numRecentFiles; ++i) {
02305         QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
02306         actionsRecentFile[i]->setText(text);
02307         actionsRecentFile[i]->setData(files[i]);
02308         actionsRecentFile[i]->setToolTip(files[i]);
02309         actionsRecentFile[i]->setStatusTip(files[i]);
02310         actionsRecentFile[i]->setShortcut("Ctrl+" + text.setNum( (i+1)%numRecentFiles ));
02311         actionsRecentFile[i]->setVisible(true);
02312     }
02313     for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
02314         actionsRecentFile[j]->setVisible(false);
02315 
02316     actionRecentFileSeparator->setVisible(numRecentFiles > 0);
02317 }
02318 
02319 void DGVMainVTK::commonChildProperties(QWidget *widget)
02320 {
02321     widget->setAttribute(Qt::WA_DeleteOnClose);
02322     widget->setFocusPolicy(Qt::StrongFocus);
02323 }
02324 
02325 bool DGVMainVTK::isActiveImage()
02326 {
02327     if(activeImage() == 0)
02328         return false;
02329     else
02330         return true;
02331 }
02332 
02333 DGVImageVTK* DGVMainVTK::activeImage()
02334 {
02335     if(QWidget *activeWin = qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow())
02336         return qobject_cast<DGVImageVTK *>(activeWin);
02337     return 0;
02338 }
02339 
02340 bool DGVMainVTK::isActiveTable()
02341 {
02342     if(activeTable() == 0)
02343         return false;
02344     else
02345         return true;
02346 }
02347 
02348 DGVTableVTK* DGVMainVTK::activeTable()
02349 {
02350     if(QWidget *activeWin = qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow())
02351         return qobject_cast<DGVTableVTK *>(activeWin);
02352     return 0;
02353 }
02354 
02355 bool DGVMainVTK::isActiveSPlot()
02356 {
02357     if(activeSPlot() == 0)
02358         return false;
02359     else
02360         return true;
02361 }
02362 
02363 DGVSurfacePlotVTK* DGVMainVTK::activeSPlot()
02364 {
02365     if(QWidget *activeWin = qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow())
02366         return qobject_cast<DGVSurfacePlotVTK *>(activeWin);
02367     return 0;
02368 }
02369 
02370 bool DGVMainVTK::isActivePlot()
02371 {
02372     if(activePlot() == 0)
02373         return false;
02374     else
02375         return true;
02376 }
02377 
02378 DGVPlot* DGVMainVTK::activePlot()
02379 {
02380     if(QWidget *activeWin = qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow())
02381         return qobject_cast<DGVPlot *>(activeWin);
02382     return 0;
02383 }
02384 
02385 bool DGVMainVTK::isActiveVPlot()
02386 {
02387     if(activeVPlot() == 0)
02388         return false;
02389     else
02390         return true;
02391 }
02392 
02393 DGVVolumePlotVTK* DGVMainVTK::activeVPlot()
02394 {
02395     if(QWidget *activeWin = qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow())
02396         return qobject_cast<DGVVolumePlotVTK *>(activeWin);
02397     return 0;
02398 }
02399 
02400 bool DGVMainVTK::isActiveLattice()
02401 {
02402     if(activeLattice() == 0)
02403         return false;
02404     else
02405         return true;
02406 }
02407 
02408 DGVLatticeVTK* DGVMainVTK::activeLattice()
02409 {
02410     if(QWidget *activeWin = qobject_cast<QWorkspace *>(workspaces->currentWidget())->activeWindow())
02411         return qobject_cast<DGVLatticeVTK *>(activeWin);
02412     return 0;
02413 }
02414 
02415 void DGVMainVTK::writeSettings()
02416  {
02417      QSettings settings("Shakes", "DGV");
02418 
02419      settings.beginGroup("DGVWindow");
02420      settings.setValue("size", size());
02421      settings.setValue("pos", pos());
02422      settings.endGroup();
02423  }
02424 
02425  void DGVMainVTK::readSettings()
02426  {
02427      QSettings settings("Shakes", "DGV");
02428 
02429      settings.beginGroup("DGVWindow");
02430      resize(settings.value("size", QSize(400, 400)).toSize());
02431      move(settings.value("pos", QPoint(200, 200)).toPoint());
02432      settings.endGroup();
02433  }

Generated on Wed Sep 8 2010 01:36:51 for DGV by  doxygen 1.7.1