]> Creatis software - clitk.git/blobdiff - vv/vvMainWindow.h
dicom structure in cmd line
[clitk.git] / vv / vvMainWindow.h
index dfc2fc6116f96934cb53756ebc2112b00b0a540f..23ee6f414f84a1200382bc1431715c605aadef8f 100644 (file)
@@ -1,38 +1,35 @@
 /*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
 
- Program:   vv
- Language:  C++
- Author :   Pierre Seroul (pierre.seroul@gmail.com)
+  Authors belong to: 
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
-Copyright (C) 2008
-Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
-CREATIS-LRMN http://www.creatis.insa-lyon.fr
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
 
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
+  It is distributed under dual licence
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
 
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-=========================================================================*/
-
-#ifndef vvMainWindow_h
-#define vvMainWindow_h
+#ifndef VVMAINWINDOW_H
+#define VVMAINWINDOW_H
 
 #include <iostream>
 #include <vector>
-
 #include "ui_vvMainWindow.h"
-
-#include "vvConstants.h"
-#include "vvImage.h"
+#include "vvMainWindowBase.h"
+#include "vvToolManager.h"
+#include "vvImageReader.h"
 #include "vvMesh.h"
+#include "clitkMemoryUsage.h"
+
+#include "vtkSmartPointer.h"
+
 
 class vvSlicerManager;
 class vvHelpDialog;
@@ -40,146 +37,188 @@ class vvDocumentation;
 class vtkRenderWindowInteractor;
 class vtkImageData;
 class vtkRenderer;
+class vtkMatrix4x4;
 class vvDicomSeriesSelector;
+class vvSlicer;
+class QTreeWidget;
 
-class vvMainWindow : public QMainWindow, private Ui::vvMainWindow
+//------------------------------------------------------------------------------
+class vvMainWindow: public vvMainWindowBase,
+                    private Ui::vvMainWindow
 {
-    Q_OBJECT
-
-public:
-    vvMainWindow();
-    ~vvMainWindow();
-    void LoadImages(std::vector<std::string> filenames, LoadedImageType type);
-    void AddImage(vvImage::Pointer image,std::string filename);
-    void AddImage(vvSlicerManager * m);
-    void AddField(QString file,int index);
-    void AddOverlayImage(int index, QString filename);
-    ///Adds a mesh to a SlicerManager, with optional warping by vector field
-    void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
-    ///This is used to show an image when opened or computed
-    void ShowLastImage();
+  Q_OBJECT
+
+  public:
+  vvMainWindow();
+  ~vvMainWindow();
+  void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
+  vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
+  void AddField(QString file,int index);
+  void AddOverlayImage(int index, QString filename);
+  void AddFusionImage(int index, QString filename);
+  void AddROI(int index, QString filename);
+  ///Adds a mesh to a SlicerManager, with optional warping by vector field
+  void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
+  ///This is used to show an image when opened or computed
+  void ShowLastImage();
+  void SaveCurrentStateAs(const std::string& stateFile);
+  void ReadSavedStateFile(const std::string& stateFile);
+       void LinkAllImages();
+
+  virtual void UpdateCurrentSlicer();
+  virtual QTabWidget * GetTab();
+  QTreeWidget* GetTree() { return DataTree; }
+  //vvMainWindowToolInfo * GetInfoForTool();
+//   void AddRunningTool(vvToolCreatorBase * tool);
 
 public slots:
-    ///Allows the user to open and select various surfaces contained in a dicom-struct file
-    void OpenDCStructContour();
-    ///Computes the MIP of the currently selected image and displays it
-    void ComputeMIP();
-    ///Computes the midposition image of a 4D sequence with a VF and displays it
-    void ComputeMidPosition();
-    void OpenImages();
-    ///Slot triggered by the dynamically-generated recent file menu actions
-    void OpenRecentImage();
-    void OpenImageWithTime();
-    void MergeImages();
-    void MergeImagesWithTime();
-    void OpenDicom();
-    ///Open a vtkPolyData surface mesh and display it over the current image
-    void OpenVTKContour();
-    void SaveAs();
-    void CurrentImageChanged(std::string id);
-    void ImageInfoChanged();
-    void ShowHelpDialog();
-    void ShowDocumentation();
-    void ComputeDeformableRegistration();
-    void WarpImage();
-    void ChangeViewMode();
-    void DisplayChanged(QTreeWidgetItem *item, int column);
-    void CloseImage(QTreeWidgetItem* item, int column);
-    void ReloadImage(QTreeWidgetItem* item, int column);
-    void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
-    void VectorChanged(int visibility, double x, double y, double z, double value);
-    void OverlayChanged(int visibility, double valueOver, double valueRef);
-    void FusionChanged(int visibility, double value);
-    void ResampleCurrentImage();
-    void SegmentationOnCurrentImage();
-    void SurfaceViewerLaunch();
-
-    void WindowsChanged(int window, int view, int slice);
-    void WindowLevelChanged(double window, double level,int preset, int colormap);
-    void UpdateSlice(int slicer, int slice);
-    void UpdateTSlice(int slicer, int slice);
-    void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
-    void WindowLevelEdited();
-    void UpdateColorMap();
-    void UpdateWindowLevel();
-    void SwitchWindowLevel();
-    void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
-    void AddLink(QString image1,QString image2);
-    void RemoveLink(QString image1,QString image2);
-
-    ///Generic method called when any one of the horizontal sliders is moved
-    void HorizontalSliderMoved(int value,int column, int slicer_index);
-    void NOHorizontalSliderMoved();
-    void NEHorizontalSliderMoved();
-    void SOHorizontalSliderMoved();
-    void SEHorizontalSliderMoved();
-
-    void NOVerticalSliderChanged();
-    void NEVerticalSliderChanged();
-    void SOVerticalSliderChanged();
-    void SEVerticalSliderChanged();
-
-    void SaveNEScreenshot();
-    void SaveNOScreenshot();
-    void SaveSEScreenshot();
-    void SaveSOScreenshot();
-
-    void ShowContextMenu(QPoint point);
-    void CropImage();
-    void SplitImage();
-    void CloseImage();
-    void ReloadImage();
-    void OpenField();
-    void SelectOverlayImage();
-    void AddFusionImage();
-
-    void SetVFProperty(int subsampling,int scale,int lut);
-    void SetOverlayProperty(int color);
-    void SetFusionProperty(int opacity,int colormap,double window,double level);
-
-    void GoToCursor();
-    void PlayPause();
-    void PlayNext();
-    void ChangeFrameRate(int rate) {
-        mFrameRate = rate;
-    }
-
-    void UpdateRenderWindows();
-
+  ///Allows the user to open and select various surfaces contained in a dicom-struct file
+  void AddDCStructContour(int index, QString file);
+  void OpenDCStructContour();
+  ///Computes the midposition image of a 4D sequence with a VF and displays it
+  void ComputeMidPosition();
+  void OpenImages();
+  ///Slot triggered by the dynamically-generated recent file menu actions
+  void OpenRecentImage();
+  void OpenImageWithTime();
+  void MergeImages();
+  void SliceImages();
+  void MergeImagesWithTime();
+  void OpenDicom();
+  ///Open a vtkPolyData surface mesh and display it over the current image
+  void OpenVTKContour();
+  void SaveAs();
+  void SaveCurrentState();
+  void ReadSavedState();
+  void CurrentImageChanged(std::string id);
+  void CurrentPickedImageChanged(std::string id);
+  void ImageInfoChanged();
+  void ShowHelpDialog();
+  void ShowDocumentation();
+  void PopupRegisterForm(bool checkCanPush=false);
+  void ComputeDeformableRegistration();
+  void WarpImage();
+  void ChangeViewMode();
+  void DisplayChanged(QTreeWidgetItem *item, int column);
+  void CloseImage(QTreeWidgetItem* item, int column);
+  void ReloadImage(QTreeWidgetItem* item, int column);
+  void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
+  void VectorChanged(int visibility, double x, double y, double z, double value);
+  void OverlayChanged(int visibility, double valueOver, double valueRef);
+  void FusionChanged(int visibility, double value);
+  void SegmentationOnCurrentImage();
+  void SurfaceViewerLaunch();
+
+  void WindowLevelChanged();
+  void UpdateSlice(int slicer, int slice);
+  void UpdateTSlice(int slicer, int slice);
+  void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
+  void WindowLevelEdited();
+  void SetWindowLevel(double w, double l);
+  void UpdateColorMap();
+  void UpdateWindowLevel();
+  void SwitchWindowLevel();
+  void ApplyWindowLevelToAllImages();
+  void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
+  void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
+  void AddLink(QString image1,QString image2);
+  void RemoveLink(QString image1,QString image2);
+  void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
+
+  ///Generic method called when any one of the horizontal sliders is moved
+  void HorizontalSliderMoved(int value,int column, int slicer_index);
+  void NOHorizontalSliderMoved();
+  void NEHorizontalSliderMoved();
+  void SOHorizontalSliderMoved();
+  void SEHorizontalSliderMoved();
+
+  void NOVerticalSliderChanged();
+  void NEVerticalSliderChanged();
+  void SOVerticalSliderChanged();
+  void SEVerticalSliderChanged();
+
+  void SaveNEScreenshot();
+  void SaveNOScreenshot();
+  void SaveSEScreenshot();
+  void SaveSOScreenshot();
+  void SaveScreenshotAllSlices();
+
+  void ShowContextMenu(QPoint point);
+  void CloseImage();
+  void ReloadImage();
+  void OpenField();
+  void SelectOverlayImage();
+  void SelectFusionImage();
+  void ResetTransformationToIdentity();
+
+  void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
+  void SetOverlayProperty(int color, int linked, double window, double level);
+  void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level);
+
+  void GoToCursor();
+  void PlayPause();
+  void PlayNext();
+  void ChangeFrameRate(int rate) {
+    mFrameRate = rate;
+  }
+  void UpdateRenderWindows();
+  void UpdateMemoryUsage();
+  void show();
+  
+protected:
+  
+  void createRecentlyOpenedFilesMenu();
+  void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
+  
 private:
 
-    //variables
-    std::vector<vvSlicerManager*> mSlicerManagers;
-    vvHelpDialog *help_dialog;
-    vvDocumentation *documentation;
-    vvDicomSeriesSelector *dicomSeriesSelector;
-
-    QString mInputPathName;
-    bool viewMode;
-    bool playMode;
-
-    //functions
-    void UpdateTree();
-    ///Adds a vector field to slicer manager index
-    void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
-    void AddFieldEntry(QString filename,int index,bool from_disk);
-    void AddField(vvImage::Pointer vf,QString file,int index);
-    void InitDisplay();
-    ///Sets the render window and LUT for the last SlicerManager
-    void InitSlicers();
-    void DisplaySliders(int slicer, int window);
-    QString GetSizeInBytes(unsigned long size);
-    QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
-    QString GetVectorIntAsString(std::vector<int> vectorInt);
-    int GetSlicerIndexFromItem(QTreeWidgetItem* item);
-    void SaveScreenshot(vtkImageData* image);
-
-    QMenu contextMenu;
-    //QMenu *AddSubImageMenu;
-    std::vector<QAction*> contextActions;
-    std::vector<QSlider*> horizontalSliders;
-    std::vector<QSlider*> verticalSliders;
-    int mFrameRate;
+  //variables
+  // std::vector<vvSlicerManager*> mSlicerManagers;
+  vvHelpDialog *help_dialog;
+  vvDocumentation *documentation;
+  vvDicomSeriesSelector *dicomSeriesSelector;
+
+  bool viewMode;
+  bool playMode;
+
+  //functions
+  void UpdateTree();
+  ///Adds a vector field to slicer manager index
+  void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
+  void AddFieldEntry(QString filename,int index,bool from_disk);
+  void AddField(vvImage::Pointer vf,QString file,int index);
+  void InitDisplay();
+  ///Sets the render window and LUT for the last SlicerManager
+  void InitSlicers();
+  void DisplaySliders(int slicer, int window);
+  QString GetSizeInBytes(unsigned long size);
+  QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
+  QString GetVectorIntAsString(std::vector<int> vectorInt);
+  QString Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix);
+  int GetSlicerIndexFromItem(QTreeWidgetItem* item);
+  QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
+  void SaveScreenshot(QVTKWidget *widget);
+  int GetImageDuplicateFilenameNumber(std::string filename);
+
+  QMenu contextMenu;
+  QMenu* recentlyOpenedFilesMenu;
+  //QMenu *AddSubImageMenu;
+  std::vector<QAction*> contextActions;
+  std::vector<QSlider*> horizontalSliders;
+  std::vector<QSlider*> verticalSliders;
+  int mFrameRate;
+  
+  std::string mCurrentSelectedImageId;
+  std::string mCurrentPickedImageId;
+  unsigned int mCurrentPickedImageIndex;
+
+  // vvMainWindowToolInfo * mCurrentToolInfo;
+  // std::vector<vvToolCreatorBase*> mListOfRunningTool;
+
+  static vvMainWindow * mSingleton;
+
+  int mCurrentTime;
+  
 };
 
 #endif