]> Creatis software - creaMaracasVisu.git/commitdiff
DFCH: ManualPaint, ImageUndoRedo (module) 70%.
authorDiego Caceres <Diego.Caceres@creatis.insa-lyon.fr>
Fri, 14 Oct 2011 22:53:12 +0000 (22:53 +0000)
committerDiego Caceres <Diego.Caceres@creatis.insa-lyon.fr>
Fri, 14 Oct 2011 22:53:12 +0000 (22:53 +0000)
15 files changed:
CMakeLists.txt
lib/maracasVisuLib/CMakeLists.txt
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx [new file with mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h [moved from lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/image3DDequeUR.h with 61% similarity, mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.cxx [moved from lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/imageDequeUR.cxx with 51% similarity, mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h [moved from lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/imageDequeUR.h with 66% similarity, mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx [new file with mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.h [moved from lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/imageInfoUR.h with 67% similarity, mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx [moved from lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/imageUndoRedo.cxx with 88% similarity, mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h [moved from lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/imageUndoRedo.h with 96% similarity, mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/managerUR.cxx [moved from lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/managerUR.cxx with 100% similarity, mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/managerUR.h [moved from lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/managerUR.h with 100% similarity, mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/regionStructUR.h [moved from lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/regionStructUR.h with 100% similarity, mode: 0755]
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/image3DDequeUR.cxx [deleted file]
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/imageInfoUR.cxx [deleted file]

index 41e961e9a0a7440345f6f6205d7553e4c81df0ea..3f2f6cfa66b7a6d6c6b7acebca83197afe3f1e7a 100644 (file)
@@ -71,12 +71,13 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/interface/wxWi
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour )
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint )
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView )
-#DCH
+#DFCH
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model )
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view )
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller )
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer )
-#DCH
+INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo )
+#DFCH
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/CutModule/interface )
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/src/CutModule/kernel )
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib/maracasVisuLib/../../../ )
index 060e92d9d94862c5cba95b384bc38e66ad55ee8c..5fa08eaaa34ab3adfb2454b3f91217062ab0ad43 100644 (file)
@@ -53,14 +53,16 @@ IF ( BUILD_${LIBRARY_NAME} )
   FILE(GLOB ${LIBRARY_NAME}_HEADERS_PPLOTTER "src/interface/wxWindows/widgets/pPlotter/*.h")
   FILE(GLOB ${LIBRARY_NAME}_SOURCES_PPLOTTER src/interface/wxWindows/widgets/pPlotter/*.cxx src/interface/wxWindows/widgets/pPlotter/*.cpp src/interface/wxWindows/widgets/pPlotter/*.cc)
 
-#DCH
+#DFCH
   FILE(GLOB ${LIBRARY_NAME}_HEADERS_CBUTTONCONTAINER "src/interface/wxWindows/widgets/creaButtonContainer/model/*.h" "src/interface/wxWindows/widgets/creaButtonContainer/model/*.txx" "src/interface/wxWindows/widgets/creaButtonContainer/view/*.h" "src/interface/wxWindows/widgets/creaButtonContainer/controller/*.h" )
   FILE(GLOB ${LIBRARY_NAME}_SOURCES_CBUTTONCONTAINER src/interface/wxWindows/widgets/creaButtonContainer/model/*.cxx src/interface/wxWindows/widgets/creaButtonContainer/view/*.cxx src/interface/wxWindows/widgets/creaButtonContainer/controller/*.cxx )
 
   FILE(GLOB ${LIBRARY_NAME}_HEADERS_CPBUTTONCONTAINER "src/interface/wxWindows/widgets/creaPanelButtonContainer/*.h" )
   FILE(GLOB ${LIBRARY_NAME}_SOURCES_CPBUTTONCONTAINER src/interface/wxWindows/widgets/creaPanelButtonContainer/*.cxx )  
-#DCH
 
+  FILE(GLOB ${LIBRARY_NAME}_HEADERS_UNDO_REDO "src/interface/wxWindows/widgets/imageUndoRedo/*.h")
+  FILE(GLOB ${LIBRARY_NAME}_SOURCES_UNDO_REDO  src/interface/wxWindows/widgets/imageUndoRedo/*.cxx )
+#DFCH
   FILE(GLOB ${LIBRARY_NAME}_HEADERS_MANUAL_CONTOUR "src/interface/wxWindows/widgets/manualContour/*.h")
   FILE(GLOB ${LIBRARY_NAME}_SOURCES_MANUAL_CONTOUR src/interface/wxWindows/widgets/manualContour/*.cpp )
 
@@ -88,6 +90,7 @@ FILE(GLOB ${LIBRARY_NAME}_HEADERS_CUTMODULE src/CutModule/interface/*.h src/CutM
        ${${LIBRARY_NAME}_HEADERS_CUTMODULE}
        ${${LIBRARY_NAME}_HEADERS_CBUTTONCONTAINER}
        ${${LIBRARY_NAME}_HEADERS_CPBUTTONCONTAINER}
+       ${${LIBRARY_NAME}_HEADERS_UNDO_REDO}
        
   )
   #----------------------------------------------------------------------------
@@ -110,6 +113,7 @@ FILE(GLOB ${LIBRARY_NAME}_HEADERS_CUTMODULE src/CutModule/interface/*.h src/CutM
        ${${LIBRARY_NAME}_SOURCES_CUTMODULE}
        ${${LIBRARY_NAME}_SOURCES_CBUTTONCONTAINER}
        ${${LIBRARY_NAME}_SOURCES_CPBUTTONCONTAINER}
+       ${${LIBRARY_NAME}_SOURCES_UNDO_REDO}
   )
   #----------------------------------------------------------------------------
 #jhcl-Start===========================================================================
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx
new file mode 100755 (executable)
index 0000000..2f6cdb7
--- /dev/null
@@ -0,0 +1,158 @@
+#include "image3DDequeUR.h"
+
+Image3DDequeUR::Image3DDequeUR() {
+       this->m_GlobalPath = "/tmp/";
+       this->m_CurrentUndoPos = -1;
+       this->m_CurrentRedoPos = -1;
+}
+//virtual
+Image3DDequeUR::~Image3DDequeUR() {
+
+}
+//virtual
+void Image3DDequeUR::AddImageToUndoContainer(ImageType* img,
+               const RegionS& region) {
+       //managing memory
+       if (this->m_ImgUndoDeque.size() > 0) {
+               this->m_ImgUndoDeque.back().RemoveImageFromMemory(this->m_GlobalPath);
+       } //fi
+         //Adding image
+       ImageInfoUR imageInfo;
+       imageInfo.SetImageName(this->GetImageName());
+       imageInfo.SetImage(img);
+       imageInfo.SetRegion(region);
+       imageInfo.SaveImageAsMHD(this->m_GlobalPath);
+       //cleaning deque from current position
+       this->CleanUndoContainerFromIndex(this->m_CurrentUndoPos);
+       this->CleanRedoContainerFromIndex(0);
+       this->m_ImgRedoDeque.clear();
+       //Adding to deque
+       this->m_ImgUndoDeque.push_back(imageInfo);
+       this->m_CurrentUndoPos = this->m_ImgUndoDeque.size() - 1;
+}
+//virtual
+void Image3DDequeUR::AddImageToRedoContainer(ImageType* img,
+               const RegionS& region) {
+       //managing memory
+       if (this->m_ImgRedoDeque.size() > 0) {
+               this->m_ImgRedoDeque.back().RemoveImageFromMemory(this->m_GlobalPath);
+       } //fi
+         //adding image
+       ImageInfoUR imageInfo;
+       imageInfo.SetImageName(this->GetImageName());
+       imageInfo.SetImage(img);
+       imageInfo.SetRegion(region);
+       imageInfo.SaveImageAsMHD(this->m_GlobalPath);
+       //Adding to deque
+       this->m_ImgRedoDeque.push_back(imageInfo);
+       this->m_CurrentUndoPos = this->m_ImgRedoDeque.size() - 1;
+}
+//virtual
+void Image3DDequeUR::CleanUndoContainerFromIndex(const unsigned int& index) {
+       for (int i = this->m_ImgUndoDeque.size() - 1; i > this->m_CurrentUndoPos;
+                       i--) {
+               this->m_ImgUndoDeque[i].RemoveImageFromMemory(this->m_GlobalPath);
+               this->m_ImgUndoDeque[i].RemoveImageFromDisk(this->m_GlobalPath);
+               this->m_ImgUndoDeque.pop_back();
+       }
+}
+//virtual
+void Image3DDequeUR::CleanRedoContainerFromIndex(const unsigned int& index) {
+       for (int i = this->m_ImgRedoDeque.size() - 1; i > this->m_CurrentRedoPos;
+                       i--) {
+               this->m_ImgRedoDeque[i].RemoveImageFromMemory(this->m_GlobalPath);
+               this->m_ImgRedoDeque[i].RemoveImageFromDisk(this->m_GlobalPath);
+               this->m_ImgRedoDeque.pop_back();
+       }
+}
+
+//virtual
+ImageInfoUR Image3DDequeUR::Undo() {
+       ImageInfoUR imgRet;
+       if ((this->m_ImgUndoDeque.size() > 0) && (this->m_CurrentUndoPos != -1)) {
+               //removing from memory
+               if ((this->m_CurrentUndoPos + 1) < this->m_ImgUndoDeque.size()) {
+                       this->m_ImgUndoDeque[(m_CurrentUndoPos + 1)].RemoveImageFromMemory(
+                                       this->m_GlobalPath);
+               } //fi
+               ImageInfoUR imgRet = this->m_ImgUndoDeque[m_CurrentUndoPos];
+               this->m_CurrentUndoPos--;
+               //adding to memory
+               if (this->m_CurrentUndoPos != -1) {
+                       //Loading image
+                       std::string fullPath = this->m_GlobalPath
+                                       + this->m_ImgUndoDeque[m_CurrentUndoPos].GetImageName();
+                       this->m_ImgUndoDeque[m_CurrentUndoPos].LoadImageMHDToMemory(
+                                       this->m_GlobalPath);
+               } //fi
+       } //fi
+       return (imgRet);
+}
+//virtual
+ImageInfoUR Image3DDequeUR::Redo() {
+
+       ImageInfoUR imgRet;
+       //managing undo deque
+       if (this->m_ImgUndoDeque.size() > 0) {
+               if ((m_CurrentUndoPos - 1) != -1) {
+                       this->m_ImgUndoDeque[m_CurrentUndoPos - 1].RemoveImageFromMemory(
+                                       this->m_GlobalPath);
+               } //fi
+               this->m_CurrentUndoPos++; //ready to do undo
+               if (this->m_CurrentUndoPos < ((int) this->m_ImgUndoDeque.size())) {
+                       this->m_ImgUndoDeque[m_CurrentUndoPos].LoadImageMHDToMemory(
+                                       this->m_GlobalPath);
+               } //fi
+                 //end of undo management
+       } //fi
+         //managing redo
+       if ((this->m_ImgRedoDeque.size() > 0) && (this->m_CurrentRedoPos != -1)) {
+               if ((this->m_CurrentRedoPos + 1) < this->m_ImgRedoDeque.size()) {
+                       this->m_ImgRedoDeque[(m_CurrentRedoPos + 1)].RemoveImageFromMemory(
+                                       this->m_GlobalPath);
+               } //fi
+               imgRet = this->m_ImgRedoDeque[this->m_CurrentRedoPos];
+               this->m_CurrentRedoPos--;
+               if (this->m_CurrentRedoPos != -1) {
+                       this->m_ImgRedoDeque[m_CurrentRedoPos].LoadImageMHDToMemory(
+                                       this->m_GlobalPath);
+               } //fi
+                 //end of redo management
+       }
+       return (imgRet);
+}
+//virtual
+void Image3DDequeUR::CleanContainers() {
+       for (unsigned int i = 0; i < this->m_ImgUndoDeque.size(); i++) {
+               this->m_ImgUndoDeque[i].RemoveImageFromMemory(this->m_GlobalPath);
+               this->m_ImgUndoDeque[i].RemoveImageFromDisk(this->m_GlobalPath);
+       } //rof
+       for (unsigned int i = 0; i < this->m_ImgRedoDeque.size(); i++) {
+               this->m_ImgRedoDeque[i].RemoveImageFromMemory(this->m_GlobalPath);
+               this->m_ImgRedoDeque[i].RemoveImageFromDisk(this->m_GlobalPath);
+       } //rof
+       this->m_ImgRedoDeque.clear();
+       this->m_ImgUndoDeque.clear();
+}
+
+void Image3DDequeUR::SetGlobalPath(const std::string& globalPath) {
+       this->m_GlobalPath = globalPath;
+}
+
+std::string Image3DDequeUR::GetGlobalPath() {
+       return (this->m_GlobalPath);
+}
+
+std::string Image3DDequeUR::GetImageName() {
+//Giving a name to an image using the date and time
+       time_t rawtime;
+       struct tm * timeinfo;
+       char buffer[80];
+       time(&rawtime);
+       timeinfo = localtime(&rawtime);
+       strftime(buffer, 80, "%a_%d_%b_%y_%H_%M_S", timeinfo);
+       std::string date(buffer);
+       std::string aux(buffer);
+       std::string imageName = "img_" + aux;
+       return (imageName);
+}
 
 #include "imageDequeUR.h"
 #include <ctime>
-#include "vtkMetaImageWriter.h"
 
 class Image3DDequeUR: public ImageDequeUR {
 private:
        ImageInfoDeque m_ImgUndoDeque;
        ImageInfoDeque m_ImgRedoDeque;
-       int m_currentUndoPos;
-       std::string m_globalPath;
+       int m_CurrentUndoPos;
+       int m_CurrentRedoPos;
+       std::string m_GlobalPath;
 public:
        Image3DDequeUR();
        virtual ~Image3DDequeUR();
+       void SetGlobalPath(const std::string& globalPath);
+       std::string GetGlobalPath();
+       std::string GetImageName();
        virtual void AddImageToUndoContainer(ImageType* img, const RegionS& region);
        virtual void AddImageToRedoContainer(ImageType* img, const RegionS& region);
-       virtual void LoadUndoImageToPMemory(const unsigned int& index);
-       virtual void RemoveUndoImageFromPMemory(const unsigned int& index);
-       virtual void LoadRedoImageToPMemory(const unsigned int& index);
-       virtual void RemoveRedoImageFromPMemory(const unsigned int& index);
-       virtual void SaveImageAsMHD(ImageType* img, const std::string& filename);
+       virtual void CleanUndoContainerFromIndex(const unsigned int& index);
+       virtual void CleanRedoContainerFromIndex(const unsigned int& index);
+       virtual void CleanContainers();
        virtual ImageInfoUR Undo();
        virtual ImageInfoUR Redo();
-       void CleanContainers();
-       void SetGlobalPath(const std::string& globalPath);
-       std::string GetGlobalPath();
-       std::string GetImageName();
 };
 
 #endif /* IMAGE3DDEQUEUR_H_ */
@@ -8,27 +8,16 @@ ImageDequeUR::~ImageDequeUR() {
 }
 void ImageDequeUR::AddImageToUndoContainer(ImageType* img,
                const RegionS& region) {
-
 }
 void ImageDequeUR::AddImageToRedoContainer(ImageType* img,
                const RegionS& region) {
-
-}
-void ImageDequeUR::LoadUndoImageToPMemory(const unsigned int& index) {
-
 }
-void ImageDequeUR::RemoveUndoImageFromPMemory(const unsigned int& index) {
+void ImageDequeUR::CleanUndoContainerFromIndex(const unsigned int& index) {
 
 }
-void ImageDequeUR::LoadRedoImageToPMemory(const unsigned int& index) {
-
-}
-void ImageDequeUR::RemoveRedoImageFromPMemory(const unsigned int& index) {
-
+void ImageDequeUR::CleanRedoContainerFromIndex(const unsigned int& index) {
 }
-void ImageDequeUR::SaveImageAsMHD(ImageType* img, const std::string& filename) {
 
-}
 ImageInfoUR ImageDequeUR::Undo() {
        ImageInfoUR im;
        return im;
@@ -25,11 +25,9 @@ public:
        virtual ~ImageDequeUR();
        virtual void AddImageToUndoContainer(ImageType* img, const RegionS& region);
        virtual void AddImageToRedoContainer(ImageType* img, const RegionS& region);
-       virtual void LoadUndoImageToPMemory(const unsigned int& index);
-       virtual void RemoveUndoImageFromPMemory(const unsigned int& index);
-       virtual void LoadRedoImageToPMemory(const unsigned int& index);
-       virtual void RemoveRedoImageFromPMemory(const unsigned int& index);
-       virtual void SaveImageAsMHD(ImageType* img, const std::string& filename);
+       virtual void CleanUndoContainerFromIndex(const unsigned int& index);
+       virtual void CleanRedoContainerFromIndex(const unsigned int& index);
+       virtual void CleanContainers();
        virtual ImageInfoUR Undo();
        virtual ImageInfoUR Redo();
 };
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx
new file mode 100755 (executable)
index 0000000..b45e21d
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * ImageInfo.cxx
+ *
+ *  Created on: Sep 22, 2011
+ *      Author: caceres
+ */
+#include "imageInfoUR.h"
+
+ImageInfoUR::ImageInfoUR() {
+       this->m_Image = NULL;
+       this->m_OnMemory = false;
+       this->m_OnDisk = false;
+}
+
+ImageInfoUR::~ImageInfoUR() {
+       this->m_Image->Delete();
+}
+
+void ImageInfoUR::SetImageName(const std::string &imgName) {
+       this->m_ImageName = imgName;
+}
+void ImageInfoUR::SetRegion(const RegionStructUR &region) {
+       this->m_Region = region;
+}
+void ImageInfoUR::SetStatus(const bool& onMemory) {
+       this->m_OnMemory = onMemory;
+}
+void ImageInfoUR::SetImage(vtkImageData* img) {
+       this->m_Image = img;
+       this->SetStatus(true);
+}
+std::string ImageInfoUR::GetImageName() {
+       return (this->m_ImageName);
+}
+RegionStructUR ImageInfoUR::GetRegion() {
+       return (this->m_Region);
+}
+bool ImageInfoUR::GetStatus() {
+       return (this->m_OnMemory);
+}
+void ImageInfoUR::RemoveImageFromMemory(const std::string& gPath) {
+       if (!this->m_OnDisk) {
+               this->SaveImageAsMHD(gPath);
+       }
+       this->m_Image->Delete();
+       this->SetStatus(false);
+}
+void ImageInfoUR::LoadImageMHDToMemory(const std::string& gPath) {
+       std::string filename = gPath + this->m_ImageName;
+       vtkSmartPointer<vtkMetaImageReader> reader = vtkSmartPointer<
+                       vtkMetaImageReader>::New();
+       reader->SetFileName(filename.c_str());
+       this->m_Image = reader->GetOutput();
+       this->m_OnMemory = true;
+}
+void ImageInfoUR::SaveImageAsMHD(const std::string& gPath) {
+       this->m_OnDisk = true;
+       std::string filename = gPath + this->m_ImageName;
+       vtkSmartPointer<vtkMetaImageWriter> w =
+                       vtkSmartPointer<vtkMetaImageWriter>::New();
+       w->SetInput(this->m_Image);
+       w->SetCompression(false);
+       w->SetFileDimensionality(this->m_Image->GetDataDimension());
+       w->SetFileName(filename.c_str());
+       w->Update();
+       w->Write();
+       w->Delete();
+}
+
+void ImageInfoUR::RemoveImageFromDisk(const std::string& gPath)
+{
+
+}
@@ -11,6 +11,9 @@
 #include <iostream>
 #include <string>
 #include <vtkImageData.h>
+#include <vtkMetaImageWriter.h>
+#include <vtkMetaImageReader.h>
+#include <vtkSmartPointer.h>
 #include "regionStructUR.h"
 
 class ImageInfoUR {
@@ -19,6 +22,7 @@ private:
        std::string m_ImageName;
        RegionStructUR m_Region;
        bool m_OnMemory;
+       bool m_OnDisk;
 public:
        ImageInfoUR();
        virtual ~ImageInfoUR();
@@ -26,10 +30,13 @@ public:
        void SetRegion(const RegionStructUR &region);
        void SetStatus(const bool& onMemory);
        void SetImage(vtkImageData* img);
+       void RemoveImageFromMemory(const std::string& gPath);
+       void LoadImageMHDToMemory(const std::string& gPath);
+       void SaveImageAsMHD(const std::string& gPath);
+       void RemoveImageFromDisk(const std::string& gPath);
        std::string GetImageName();
        RegionStructUR GetRegion();
        bool GetStatus();
-       void RemoveImageFromMemory();
 };
 
 #endif /* IMAGEINFO_H_ */
@@ -24,10 +24,8 @@ void ImageUndoRedo::Undo() {
 void ImageUndoRedo::Redo() {
        ImageInfoUR imageInfo = this->m_ImagesDeque->Redo();
        this->DrawUR(imageInfo);
-       imageInfo.RemoveImageFromMemory();
 }
-void ImageUndoRedo::SetImage(vtkImageData *image)
-{
+void ImageUndoRedo::SetImage(vtkImageData *image) {
        this->m_CurrentImage = image;
        this->m_CurrentImage->Update();
        this->m_OriginalImage = ImageType::New();
@@ -35,8 +33,8 @@ void ImageUndoRedo::SetImage(vtkImageData *image)
 }
 //virtual
 void ImageUndoRedo::SetUndoImage(const RegionSType& region) {
-       vtkExtractVOI* extract;
-       extract->New();
+       vtkSmartPointer<vtkExtractVOI> extract =
+                       vtkSmartPointer<vtkExtractVOI>::New();
        extract->SetVOI(region.minX, region.maxX, region.minY, region.maxY,
                        region.minZ, region.maxZ);
        extract->SetSampleRate(1, 1, 1);
@@ -46,8 +44,8 @@ void ImageUndoRedo::SetUndoImage(const RegionSType& region) {
 }
 //virtual
 void ImageUndoRedo::SetRedoImage(const RegionSType& region) {
-       vtkExtractVOI* extract;
-       extract->New();
+       vtkSmartPointer<vtkExtractVOI> extract =
+                       vtkSmartPointer<vtkExtractVOI>::New();
        extract->SetVOI(region.minX, region.maxX, region.minY, region.maxY,
                        region.minZ, region.maxZ);
        extract->SetSampleRate(1, 1, 1);
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/image3DDequeUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/image3DDequeUR.cxx
deleted file mode 100644 (file)
index 0021d54..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-#include "image3DDequeUR.h"
-
-Image3DDequeUR::Image3DDequeUR() {
-       this->m_globalPath = "/tmp/";
-       this->m_currentUndoPos = -1;
-}
-//virtual
-Image3DDequeUR::~Image3DDequeUR() {
-
-}
-//virtual
-void Image3DDequeUR::AddImageToUndoContainer(ImageType* img,
-               const RegionS& region) {
-       //managing memory
-       if (this->m_ImgUndoDeque.size() > 0) {
-               this->m_ImgUndoDeque.back().RemoveImageFromMemory();
-       } //fi
-       ImageInfoUR imageInfo;
-       imageInfo.SetImageName(this->GetImageName());
-       imageInfo.SetImage(img);
-       imageInfo.SetRegion(region);
-       //saving to disk
-       std::string fullpath = this->m_globalPath + imageInfo.GetImageName()
-                       + "_UNDO.MHD";
-       this->SaveImageAsMHD(img, fullpath);
-       //Adding to deque
-       this->m_ImgUndoDeque.push_back(imageInfo);
-       this->m_currentUndoPos = this->m_ImgUndoDeque.size() - 1;
-}
-//virtual
-void Image3DDequeUR::AddImageToRedoContainer(ImageType* img,
-               const RegionS& region) {
-       //managing memory
-       if (this->m_ImgRedoDeque.size() > 0) {
-               this->m_ImgRedoDeque.back().RemoveImageFromMemory();
-       } //fi
-       ImageInfoUR imageInfo;
-       imageInfo.SetImageName(this->GetImageName());
-       imageInfo.SetImage(img);
-       imageInfo.SetRegion(region);
-       //saving to disk
-       std::string fullpath = this->m_globalPath + imageInfo.GetImageName()
-                       + "_REDO.MHD";
-       this->SaveImageAsMHD(img, fullpath);
-       //Adding to deque
-       this->m_ImgRedoDeque.push_back(imageInfo);
-}
-//virtual
-void Image3DDequeUR::LoadUndoImageToPMemory(const unsigned int& index) {
-
-}
-//virtual
-void Image3DDequeUR::RemoveUndoImageFromPMemory(const unsigned int& index) {
-       this->m_ImgUndoDeque[index].RemoveImageFromMemory();
-}
-//virtual
-void Image3DDequeUR::LoadRedoImageToPMemory(const unsigned int& index) {
-
-}
-//virtual
-void Image3DDequeUR::RemoveRedoImageFromPMemory(const unsigned int& index) {
-       this->m_ImgRedoDeque[index].RemoveImageFromMemory();
-}
-//virtual
-void Image3DDequeUR::SaveImageAsMHD(ImageType* img,
-               const std::string& filename) {
-       vtkMetaImageWriter* w = vtkMetaImageWriter::New();
-       w->SetInput(img);
-       w->SetCompression(false);
-       w->SetFileDimensionality(img->GetDataDimension());
-       w->SetFileName(filename.c_str());
-       w->Update();
-       w->Write();
-       w->Delete();
-}
-
-//virtual
-ImageInfoUR Image3DDequeUR::Undo() {
-       ImageInfoUR imgRet;
-       if (this->m_currentUndoPos < (this->m_ImgUndoDeque.size() + 1)) {
-               this->m_ImgUndoDeque[(unsigned int) (m_currentUndoPos + 1)].RemoveImageFromMemory();
-       } //fi
-       if (this->m_currentUndoPos != -1) {
-               //removing from memory
-               if ((this->m_currentUndoPos + 1) < this->m_ImgUndoDeque.size()) {
-                       this->m_ImgUndoDeque[(unsigned int) (m_currentUndoPos + 1)].RemoveImageFromMemory();
-               } //fi
-               ImageInfoUR imgRet =
-                               this->m_ImgUndoDeque[(unsigned int) m_currentUndoPos];
-               this->m_currentUndoPos--;
-               //adding to memory
-               if (this->m_currentUndoPos != -1) {
-                       this->LoadUndoImageToPMemory((unsigned int) m_currentUndoPos);
-               } //fi
-       } //fi
-       return (imgRet);
-}
-//virtual
-ImageInfoUR Image3DDequeUR::Redo() {
-       ImageInfoUR imgRet;
-       if (this->m_currentUndoPos >= (this->m_ImgRedoDeque.size() - 1)
-                       && (this->m_ImgRedoDeque.size() > 0)) {
-               this->m_ImgUndoDeque[(unsigned int) (m_currentUndoPos)].RemoveImageFromMemory();
-               this->m_currentUndoPos++;
-               this->LoadUndoImageToPMemory((unsigned int) m_currentUndoPos);
-               imgRet = this->m_ImgRedoDeque.back();
-               this->m_ImgRedoDeque.pop_back();
-               if (this->m_ImgRedoDeque.size() > 0) {
-                       LoadRedoImageToPMemory(
-                                       (unsigned int) (this->m_ImgRedoDeque.size() - 1));
-               } //fi
-       } //fi
-       return (imgRet);
-}
-
-void Image3DDequeUR::CleanContainers() {
-       for (unsigned int i = 0; i < this->m_ImgUndoDeque.size(); i++) {
-               this->m_ImgUndoDeque[i].RemoveImageFromMemory();
-       } //rof
-       for (unsigned int i = 0; i < this->m_ImgRedoDeque.size(); i++) {
-               this->m_ImgRedoDeque[i].RemoveImageFromMemory();
-       } //rof
-       this->m_ImgRedoDeque.clear();
-       this->m_ImgUndoDeque.clear();
-}
-
-void Image3DDequeUR::SetGlobalPath(const std::string& globalPath) {
-       this->m_globalPath = globalPath;
-}
-
-std::string Image3DDequeUR::GetGlobalPath() {
-       return (this->m_globalPath);
-}
-
-std::string Image3DDequeUR::GetImageName() {
-       //Giving a name to an image using the date and time
-       time_t rawtime;
-       struct tm * timeinfo;
-       char buffer[80];
-       time(&rawtime);
-       timeinfo = localtime(&rawtime);
-       strftime(buffer, 80, "%a_%d_%b_%y_%H_%M_S", timeinfo);
-       std::string date(buffer);
-       std::string aux(buffer);
-       std::string imageName = "img_" + aux;
-       return (imageName);
-}
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/imageInfoUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/imageInfoUR.cxx
deleted file mode 100644 (file)
index d637125..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ImageInfo.cxx
- *
- *  Created on: Sep 22, 2011
- *      Author: caceres
- */
-#include "imageInfoUR.h"
-
-ImageInfoUR::ImageInfoUR() {
-       this->m_Image = NULL;
-}
-
-ImageInfoUR::~ImageInfoUR() {
-       this->RemoveImageFromMemory();
-}
-
-void ImageInfoUR::SetImageName(const std::string &imgName) {
-       this->m_ImageName = imgName;
-}
-void ImageInfoUR::SetRegion(const RegionStructUR &region) {
-       this->m_Region = region;
-}
-void ImageInfoUR::SetStatus(const bool& onMemory) {
-       this->m_OnMemory = onMemory;
-}
-void ImageInfoUR::SetImage(vtkImageData* img) {
-       this->m_Image = img;
-       this->SetStatus(true);
-}
-std::string ImageInfoUR::GetImageName() {
-       return (this->m_ImageName);
-}
-RegionStructUR ImageInfoUR::GetRegion() {
-       return (this->m_Region);
-}
-bool ImageInfoUR::GetStatus() {
-       return (this->m_OnMemory);
-}
-void ImageInfoUR::RemoveImageFromMemory() {
-       this->m_Image->Delete();
-       this->SetStatus(false);
-}