Go to the documentation of this file.00001
00022 #ifndef DGVIMAGEVTK_H
00023 #define DGVIMAGEVTK_H
00024
00025 #include <QtGui/QtGui>
00026
00027 #include "QVTKWidget.h"
00028 #include "vtkImageViewer2.h"
00029 #include "vtkImageData.h"
00030 #include "vtkImageMagnify.h"
00031 #include "vtkImagePermute.h"
00032
00033 #include "DGVBlitzArrayCasterVTK.h"
00034 #include "DGVConsole.h"
00035 #include "DGVTableVTK.h"
00036 #include "DGVPlot.h"
00037 #include "DGVPlotVTK.h"
00038 #include "DGVVolumePlotVTK.h"
00039
00040 typedef vtkImageViewer2 ImageViewer;
00041
00068 class DGV_VTK_EXPORT DGVImageVTK : public QVTKWidget
00069 {
00070 Q_OBJECT
00071
00072 public:
00077 DGVImageVTK(QWidget *parent = 0);
00082 DGVImageVTK(QVector<QMenu*> &menus, QWidget *parent = 0);
00087 ~DGVImageVTK();
00088
00093 void setName(QString filename);
00101 bool openImage(QString filename);
00109 bool saveImage(QString filename);
00117 bool openStack(QString filename);
00125 bool saveStack(QString filename);
00130 bool openPNG();
00135 bool savePNG(const QString filename);
00140 bool openPNGVolume();
00145 bool savePNGVolume(const QString filename);
00150 bool openJPEG();
00155 bool saveJPEG(const QString filename);
00160 bool openJPEGVolume();
00165 bool saveJPEGVolume(const QString filename);
00170 bool openTIFF();
00175 bool saveTIFF(const QString filename);
00180 bool openTIFFVolume();
00185 bool saveTIFFVolume(const QString filename);
00190 bool openPNM();
00195 bool savePNM(const QString filename);
00200 bool openPNMVolume();
00205 bool savePNMVolume(const QString filename);
00210 bool openBMP();
00215 bool saveBMP(const QString filename);
00220 bool openBMPVolume();
00225 bool saveBMPVolume(const QString filename);
00230 bool savePS(const QString filename);
00235 bool openDICOM();
00240 bool saveDICOM(const QString filename);
00245 bool openVTI();
00250 bool saveVTI(const QString filename);
00255 bool openVTK();
00260 bool saveVTK(const QString filename);
00265 bool openTGA();
00270 bool saveTGA(const QString filename);
00275 void complexValuedMode(bool complexValues);
00280 inline bool isComplexValued()
00281 { return complexData; }
00286 void setData(Array<imageType,2> &data);
00292 void setData(Array<imageType,3> &data);
00298 void setData(Array<complex<imageType>,3> &data);
00303 void setData(Array< complex<imageType>,2 > &data);
00308 void setData(vtkImageData *newData);
00314 void setDataSize(int rows, int cols);
00319 void SetInput(vtkImageData *newData);
00324 inline void viewMagnitude()
00325 { absoluteMagnitudeAct->setChecked(true); refresh(); }
00330 inline void viewImaginaryPart()
00331 { imaginaryPartAct->setChecked(true); refresh(); }
00336 inline void viewRealPart()
00337 { realPartAct->setChecked(true); refresh(); }
00342 inline void viewPhase()
00343 { phaseAct->setChecked(true); refresh(); }
00348 Array<imageType,2>& data();
00353 Array< complex<imageType>,2 >& dataComplex();
00360 Array<imageType,2>& dataViewing();
00365 inline vtkAlgorithmOutput* GetOutputPort()
00366 { return outputPort; }
00371 inline vtkImageData* GetOutput()
00372 { return imageData; }
00377 inline bool isVolume()
00378 { return volume; }
00384 inline void disableVolumeDisplay(bool disable)
00385 { enableVolumes = !disable; }
00390 DGVVolumePlotVTK* getVolume();
00391
00396 QString strippedName();
00401 QString strippedNamePrefix();
00406 void addToContextMenu(QVector<QMenu*> &menus);
00412 void setConsole(DGVConsole *newConsole);
00417 inline void setVerboseMode(bool verbose)
00418 { verboseMode = verbose; }
00423 inline void alignImages(bool align)
00424 { Blitz.alignmentForImages(align); }
00425
00426 public slots:
00431 void table();
00436 void mergedSurfacePlot();
00443 void generateVolume();
00451 void generateImage();
00456 void scan();
00461 void clip();
00466 void histogram();
00474 bool saveImage();
00482 bool saveStack();
00487 void refresh();
00492 void renameData();
00497 void updateData(int row, int col);
00502 void interpolateDisplay();
00507 void meanGreyScale();
00512 void incrementSlice();
00517 void decrementSlice();
00522 void viewToXYPlane();
00527 void viewToZXPlane();
00532 void viewToZYPlane();
00533
00534 signals:
00539 void resultAvailable(DGVImageVTK *);
00544 void tableAvailable(DGVTableVTK *tableWidget);
00549 void surfacePlotAvailable(DGVSurfacePlotVTK *plotWidget);
00554 void plotAvailable(DGVPlot *plotWidget);
00559 void plotAvailable(DGVPlotVTK *plotWidget);
00564 void volumePlotAvailable(DGVVolumePlotVTK *plotWidget);
00569 void recentFileAvailable(const QString &fileName);
00570
00571 protected:
00572 QString name;
00573 bool loaded;
00574 bool arrayLoaded;
00575 bool imageDataSource;
00576 bool imageDataLoaded;
00577 bool externalData;
00578 bool viewing;
00579 bool volume;
00580 bool complexData;
00581 bool consoleAssigned;
00582 bool verboseMode;
00583 bool enableVolumes;
00584 bool permuted;
00585 int sliceInView;
00586
00587
00588 QMenu *contextMenu;
00589 QVector<QMenu*> menusToAdd;
00590 QAction *tableAct;
00591 QAction *surfacePlotAct;
00592 QAction *scanAct;
00593 QAction *volumeAct;
00594 QAction *clipAct;
00595 QAction *histAct;
00596
00597 QAction *interpolateAct;
00598 QAction *meanGreyAct;
00599 QMenu *viewMenu;
00600 QAction *viewXY;
00601 QAction *viewZX;
00602 QAction *viewZY;
00603
00604 QActionGroup *complexGroup;
00605 QAction *absoluteMagnitudeAct;
00606 QAction *imaginaryPartAct;
00607 QAction *realPartAct;
00608 QAction *phaseAct;
00609
00610 QAction *saveAct;
00611 QAction *saveStackAct;
00612 QAction *refreshAct;
00613 QAction *renameAct;
00614 QAction *closeAct;
00615
00616 ImageViewer *viewer;
00617 vtkImageData *imageData;
00618 vtkImageMagnify *magnify;
00619 vtkImagePermute *permute;
00620 DGVTableVTK *dataTable;
00621 DGVSurfacePlotVTK *surfacePlot;
00622 DGVVolumePlotVTK *volViewer;
00623
00624 DGVConsole *console;
00625 DGVBlitzArrayCasterVTK<imageType> Blitz;
00626 Array<imageType,2> imageArray;
00627 Array< complex<imageType>,2 > imageComplexArray;
00628
00629 vtkAlgorithmOutput *outputPort;
00630
00631 double timerInterval;
00632 int timerId;
00633
00635
00639 void createActions();
00644 void createConnections();
00649 void connectTable(DGVTableVTK *child);
00654 void dataToArray();
00659 bool sliceToData();
00664 void arrayToData();
00669 void checkDataIsManual();
00674 void setupEvents();
00679 void setupViewerFromReader();
00684 void addContextMenuExtras();
00689 void contextMenuEvent(QContextMenuEvent *event);
00694 virtual void timerEvent(QTimerEvent *event);
00700
00705 void printError(QString msg);
00710 void printWarning(QString msg);
00715 void printInfo(QString msg);
00716 };
00717
00718 #endif
00719
00722 static void handleKeys(vtkObject* obj, unsigned long, void *clientData, void *callData);
00725 static void handleWheelUp(vtkObject* obj, unsigned long, void *clientData, void *callData);
00728 static void handleWheelDown(vtkObject* obj, unsigned long, void *clientData, void *callData);