#ifndef _wx_ImageViewerInteractor_h_ #define _wx_ImageViewerInteractor_h_ #include "wxImageViewer.h" #include "itkGDCMImporter.h" #include class wxVtkPageView; class wxImageThumbnail; class vtkImageData; class wxImageViewerInteractor : public wxImageViewer { public: wxImageViewerInteractor(wxWindow* parent, int id=-1, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString& title=wxT ("")); virtual ~wxImageViewerInteractor(){}; typedef itk::GDCMImporter::FloatImageType ImageType; typedef itk::Image Image4DType; virtual void OnToolBarOpenVol (wxCommandEvent &); virtual void OnToolBarOpenDICOM (wxCommandEvent &); virtual void OnToolBarSave (wxCommandEvent &); virtual void OnToolBarSaveAll (wxCommandEvent &); virtual void OnToolBarSnapShot (wxCommandEvent &); virtual void OnFullScreenAxial (wxCommandEvent &); virtual void OnFullScreenCoronal (wxCommandEvent &); virtual void OnFullScreenSagittal (wxCommandEvent &); virtual void OnFullScreen3D (wxCommandEvent &); virtual void OnToolBarFlip (wxCommandEvent &); virtual void OnToolBarLink (wxCommandEvent &); virtual void OnDeletePage (wxAuiNotebookEvent&); virtual void OnPageChanged (wxAuiNotebookEvent&); virtual void OnSelectInteractionEvent (wxCommandEvent &); virtual void OnWindowLevelInteractionEvent (wxCommandEvent &); virtual void OnZoomInteractionEvent (wxCommandEvent &); virtual void OnToolBarCLUT (wxCommandEvent &); void OnToolBarVRMode (wxCommandEvent &); void OnToolBarShading (wxCommandEvent &); virtual void OnFullPageInteractionEvent (wxCommandEvent &); virtual void On3DVolumeRendering (wxCommandEvent &); virtual void SaveImage (wxVtkPageView* page, const char* filename); virtual void OpenImage (const char* filename); int SetCmdLine (int argc, char** argv); /** Get open file name */ static wxString GetOpenFileName (wxWindow* parent, const wxString& tip, const wxString& filters) { wxFileDialog* myFileDialog = new wxFileDialog(parent, tip, wxT(""), wxT(""), filters, wxFD_OPEN|wxFD_CHANGE_DIR, wxDefaultPosition); wxString fileName; fileName.Empty(); int OK = myFileDialog->ShowModal(); if( OK==wxID_OK ) fileName = myFileDialog->GetPath(); myFileDialog->Destroy(); return fileName; } /** Get open file names */ static wxArrayString GetOpenFileNames (wxWindow* parent, const wxString& tip, const wxString& filters) { wxFileDialog* myFileDialog = new wxFileDialog(parent, tip, wxT(""), wxT(""), filters, wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_MULTIPLE, wxDefaultPosition); wxArrayString fileNames; fileNames.Empty(); int OK = myFileDialog->ShowModal(); if( OK==wxID_OK ) myFileDialog->GetPaths(fileNames); myFileDialog->Destroy(); return fileNames; } /** Get save file name */ static wxString GetSaveFileName (wxWindow* parent, const wxString& tip, const wxString& filters) { wxFileDialog* myFileDialog = new wxFileDialog(parent, tip, wxT(""), wxT(""), filters, wxFD_SAVE|wxFD_CHANGE_DIR|wxFD_OVERWRITE_PROMPT, wxDefaultPosition); wxString fileName; fileName.Empty(); int OK = myFileDialog->ShowModal(); if( OK==wxID_OK ) fileName = myFileDialog->GetPath(); myFileDialog->Destroy(); return fileName; } /** Display warning message */ static void DisplayWarningMessage (wxWindow* parent, const wxString& message) { wxMessageDialog* myDialog = new wxMessageDialog(parent, message, wxT ("ImageViewer warning"), wxOK|wxICON_WARNING); myDialog->ShowModal(); myDialog->Destroy(); } /** Display error message */ static void DisplayErrorMessage (wxWindow* parent, const wxString& message) { wxMessageDialog* myDialog = new wxMessageDialog(parent, message, wxT ("ImageViewer error"), wxOK|wxICON_ERROR); myDialog->ShowModal(); myDialog->Destroy(); } static std::string GetNameFromFile (std::string filename) { // look for the path to the file #ifdef __WXMSW__ std::string::size_type slashpos = filename.rfind ("\\"); // last occurence of "/" #else std::string::size_type slashpos = filename.rfind ("/"); // last occurence of "/" #endif std::string name = ""; if( slashpos != std::string::npos ) name=filename.substr(slashpos+1, (filename.length() - slashpos)); else name = filename; return name; } static wxString GetNameFromFile (wxString filename) { // look for the path to the file #ifdef __WXMSW__ std::string::size_type slashpos = filename.rfind ("\\"); // last occurence of "/" #else std::string::size_type slashpos = filename.rfind ("/"); // last occurence of "/" #endif wxString name = wxT(""); if( slashpos != std::string::npos ) name=filename.substr(slashpos+1, (filename.length() - slashpos)); else name = filename; return name; } protected: wxVtkPageView* CreateNewVtkPage(void); void AddPreviewThumbnail ( wxVtkPageView*, const char*); void AddImage (vtkImageData*, const char*); private: wxImageThumbnail* m_Thumbnail; int m_InteractionStyle; }; #endif