]> Creatis software - creaMaracasVisu.git/commitdiff
DFCH: ManualPaint + imageUndoRedo -> 50% tested. (Save Images undo and redo) :) :)
authorDiego Caceres <Diego.Caceres@creatis.insa-lyon.fr>
Wed, 26 Oct 2011 16:33:03 +0000 (16:33 +0000)
committerDiego Caceres <Diego.Caceres@creatis.insa-lyon.fr>
Wed, 26 Oct 2011 16:33:03 +0000 (16:33 +0000)
18 files changed:
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp

index 2f6cdb73ddc9e8f71f0f0c551741874d6b84b42f..10de209d1616c468e91738390a0487b77ddf5683 100755 (executable)
@@ -1,7 +1,9 @@
 #include "image3DDequeUR.h"
+#include <iostream>
+#include <sstream>
 
 Image3DDequeUR::Image3DDequeUR() {
-       this->m_GlobalPath = "/tmp/";
+       this->m_GlobalPath = "/home/caceres/temporal/";
        this->m_CurrentUndoPos = -1;
        this->m_CurrentRedoPos = -1;
 }
@@ -14,20 +16,22 @@ void Image3DDequeUR::AddImageToUndoContainer(ImageType* img,
                const RegionS& region) {
        //managing memory
        if (this->m_ImgUndoDeque.size() > 0) {
-               this->m_ImgUndoDeque.back().RemoveImageFromMemory(this->m_GlobalPath);
+               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);
+       ImageInfoUR* imageInfo = new ImageInfoUR();
+       imageInfo->SetImageName(
+                       this->GetImageName(this->m_ImgUndoDeque.size(), true));
+       imageInfo->SetImage(img);
+       imageInfo->SetRegion(region);
+       imageInfo->SaveImageAsMHD(this->m_GlobalPath);
        //cleaning deque from current position
-       this->CleanUndoContainerFromIndex(this->m_CurrentUndoPos);
+       this->CleanUndoContainerFromIndex(this->m_CurrentUndoPos + 1);
        this->CleanRedoContainerFromIndex(0);
        this->m_ImgRedoDeque.clear();
        //Adding to deque
        this->m_ImgUndoDeque.push_back(imageInfo);
+       std::cout<<"Parceeeeeeeee: aaa " << this->m_ImgUndoDeque.size()<<std::endl;
        this->m_CurrentUndoPos = this->m_ImgUndoDeque.size() - 1;
 }
 //virtual
@@ -35,72 +39,71 @@ void Image3DDequeUR::AddImageToRedoContainer(ImageType* img,
                const RegionS& region) {
        //managing memory
        if (this->m_ImgRedoDeque.size() > 0) {
-               this->m_ImgRedoDeque.back().RemoveImageFromMemory(this->m_GlobalPath);
+               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);
+       ImageInfoUR* imageInfo = new ImageInfoUR();
+       imageInfo->SetImageName(
+                       this->GetImageName(this->m_ImgRedoDeque.size(), false));
+       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);
+void Image3DDequeUR::CleanUndoContainerFromIndex(const int& index) {
+       for (int i = index; i < this->m_ImgUndoDeque.size(); 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);
+void Image3DDequeUR::CleanRedoContainerFromIndex(const int& index) {
+       for (int i = index; i < this->m_ImgRedoDeque.size(); 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;
+ImageInfoUR* Image3DDequeUR::Undo() {
+       ImageInfoUR* imgRet = new ImageInfoUR();
        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_ImgUndoDeque[(m_CurrentUndoPos + 1)]->RemoveImageFromMemory(
                                        this->m_GlobalPath);
                } //fi
-               ImageInfoUR imgRet = this->m_ImgUndoDeque[m_CurrentUndoPos];
+               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_ImgUndoDeque[m_CurrentUndoPos]->GetImageName();
+                       this->m_ImgUndoDeque[m_CurrentUndoPos]->LoadImageMHDToMemory(
                                        this->m_GlobalPath);
                } //fi
        } //fi
        return (imgRet);
 }
 //virtual
-ImageInfoUR Image3DDequeUR::Redo() {
+ImageInfoUR* Image3DDequeUR::Redo() {
 
-       ImageInfoUR imgRet;
+       ImageInfoUR* imgRet = new ImageInfoUR();
        //managing undo deque
        if (this->m_ImgUndoDeque.size() > 0) {
                if ((m_CurrentUndoPos - 1) != -1) {
-                       this->m_ImgUndoDeque[m_CurrentUndoPos - 1].RemoveImageFromMemory(
+                       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_ImgUndoDeque[m_CurrentUndoPos]->LoadImageMHDToMemory(
                                        this->m_GlobalPath);
                } //fi
                  //end of undo management
@@ -108,13 +111,13 @@ ImageInfoUR Image3DDequeUR::Redo() {
          //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_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_ImgRedoDeque[m_CurrentRedoPos]->LoadImageMHDToMemory(
                                        this->m_GlobalPath);
                } //fi
                  //end of redo management
@@ -124,12 +127,12 @@ ImageInfoUR Image3DDequeUR::Redo() {
 //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);
+               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);
+               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();
@@ -143,16 +146,30 @@ std::string Image3DDequeUR::GetGlobalPath() {
        return (this->m_GlobalPath);
 }
 
-std::string Image3DDequeUR::GetImageName() {
+std::string Image3DDequeUR::GetImageName(const int & pos, const bool& undo) {
 //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;
+       if (this->m_IDImages.empty()) {
+               time_t rawtime;
+               struct tm * timeinfo;
+               char buffer[80];
+               time(&rawtime);
+               timeinfo = localtime(&rawtime);
+               strftime(buffer, 80, "%H%M%S_%a_%d_%b_%y_", timeinfo);
+               std::string date(buffer);
+               std::string aux(buffer);
+               this->m_IDImages = "img_" + aux;
+       }
+       std::stringstream ss; //create a stringstream
+       ss << pos; //add number to the stream
+       std::string imgType;
+       if (undo) {
+               imgType = "undo";
+       }
+       else
+       {
+               imgType = "redo";
+       }
+       std::string imageName = this->m_IDImages + imgType + ss.str();
+       imageName.append(".mhd");
        return (imageName);
 }
index 2909708817fb1f882a22b8443811867c6339e6ea..414f33687c605ff7b8fa4736b195983742ca9052 100755 (executable)
@@ -11,6 +11,7 @@
 #include "imageDequeUR.h"
 #include <ctime>
 
+
 class Image3DDequeUR: public ImageDequeUR {
 private:
        ImageInfoDeque m_ImgUndoDeque;
@@ -18,19 +19,20 @@ private:
        int m_CurrentUndoPos;
        int m_CurrentRedoPos;
        std::string m_GlobalPath;
+       std::string m_IDImages;
 public:
        Image3DDequeUR();
        virtual ~Image3DDequeUR();
        void SetGlobalPath(const std::string& globalPath);
        std::string GetGlobalPath();
-       std::string GetImageName();
+       std::string GetImageName(const int & pos, const bool& undo);
        virtual void AddImageToUndoContainer(ImageType* img, const RegionS& region);
        virtual void AddImageToRedoContainer(ImageType* img, const RegionS& region);
-       virtual void CleanUndoContainerFromIndex(const unsigned int& index);
-       virtual void CleanRedoContainerFromIndex(const unsigned int& index);
+       virtual void CleanUndoContainerFromIndex(const int& index);
+       virtual void CleanRedoContainerFromIndex(const int& index);
        virtual void CleanContainers();
-       virtual ImageInfoUR Undo();
-       virtual ImageInfoUR Redo();
+       virtual ImageInfoUR* Undo();
+       virtual ImageInfoUR* Redo();
 };
 
 #endif /* IMAGE3DDEQUEUR_H_ */
index 649bc3ea9a6791dc66f3fee9d678bf5668d8d3ee..66a3240cc235cc59a96d0b9d701fc860752731b5 100755 (executable)
@@ -12,17 +12,20 @@ void ImageDequeUR::AddImageToUndoContainer(ImageType* img,
 void ImageDequeUR::AddImageToRedoContainer(ImageType* img,
                const RegionS& region) {
 }
-void ImageDequeUR::CleanUndoContainerFromIndex(const unsigned int& index) {
+void ImageDequeUR::CleanUndoContainerFromIndex(const int& index) {
 
 }
-void ImageDequeUR::CleanRedoContainerFromIndex(const unsigned int& index) {
+void ImageDequeUR::CleanRedoContainerFromIndex(const int& index) {
 }
+void ImageDequeUR::CleanContainers() {
 
-ImageInfoUR ImageDequeUR::Undo() {
-       ImageInfoUR im;
+}
+
+ImageInfoUR* ImageDequeUR::Undo() {
+       ImageInfoUR* im;
        return im;
 }
-ImageInfoUR ImageDequeUR::Redo() {
-       ImageInfoUR im;
+ImageInfoUR* ImageDequeUR::Redo() {
+       ImageInfoUR* im;
        return im;
 }
index 815040f9bda332227b534723221ffeb3163f2384..5367ce6afa66690f3616088fbac52e94b28def3b 100755 (executable)
@@ -15,7 +15,7 @@
 #include "imageInfoUR.h"
 #include "regionStructUR.h"
 
-typedef std::deque<ImageInfoUR> ImageInfoDeque;
+typedef std::deque<ImageInfoUR*> ImageInfoDeque;
 typedef vtkImageData ImageType;
 typedef RegionStructUR RegionS;
 
@@ -25,11 +25,11 @@ public:
        virtual ~ImageDequeUR();
        virtual void AddImageToUndoContainer(ImageType* img, const RegionS& region);
        virtual void AddImageToRedoContainer(ImageType* img, const RegionS& region);
-       virtual void CleanUndoContainerFromIndex(const unsigned int& index);
-       virtual void CleanRedoContainerFromIndex(const unsigned int& index);
+       virtual void CleanUndoContainerFromIndex(const int& index);
+       virtual void CleanRedoContainerFromIndex(const int& index);
        virtual void CleanContainers();
-       virtual ImageInfoUR Undo();
-       virtual ImageInfoUR Redo();
+       virtual ImageInfoUR* Undo();
+       virtual ImageInfoUR* Redo();
 };
 
 #endif /* IMAGEDEQUE_H_ */
index b45e21d920915b8e27a58880380875b090ab85c2..18c255eeae6ce381f34d7cc203bf4fe96792cf06 100755 (executable)
@@ -13,7 +13,6 @@ ImageInfoUR::ImageInfoUR() {
 }
 
 ImageInfoUR::~ImageInfoUR() {
-       this->m_Image->Delete();
 }
 
 void ImageInfoUR::SetImageName(const std::string &imgName) {
@@ -42,7 +41,7 @@ void ImageInfoUR::RemoveImageFromMemory(const std::string& gPath) {
        if (!this->m_OnDisk) {
                this->SaveImageAsMHD(gPath);
        }
-       this->m_Image->Delete();
+       this->m_Image = NULL;
        this->SetStatus(false);
 }
 void ImageInfoUR::LoadImageMHDToMemory(const std::string& gPath) {
@@ -62,9 +61,7 @@ void ImageInfoUR::SaveImageAsMHD(const std::string& gPath) {
        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)
index 6a57d07819d49a2167242be2046565dc8bdd5f1b..a459e8598a21a793d1986f6758d9f91c56a9ae94 100755 (executable)
@@ -16,20 +16,21 @@ ImageUndoRedo::~ImageUndoRedo() {
 }
 //virtual
 void ImageUndoRedo::Undo() {
-       ImageInfoUR imageInfo = this->m_ImagesDeque->Undo();
-       this->SetRedoImage(imageInfo.GetRegion());
+       ImageInfoUR* imageInfo = this->m_ImagesDeque->Undo();
+       this->SetRedoImage(imageInfo->GetRegion());
+       std::cout<<"undooooooooooooooooooooooooooo"<<std::endl;
        this->DrawUR(imageInfo);
 }
 //virtual
 void ImageUndoRedo::Redo() {
-       ImageInfoUR imageInfo = this->m_ImagesDeque->Redo();
+       ImageInfoUR* imageInfo = this->m_ImagesDeque->Redo();
        this->DrawUR(imageInfo);
 }
 void ImageUndoRedo::SetImage(vtkImageData *image) {
        this->m_CurrentImage = image;
        this->m_CurrentImage->Update();
        this->m_OriginalImage = ImageType::New();
-       this->m_OriginalImage->ShallowCopy(m_CurrentImage);
+       this->m_OriginalImage->DeepCopy(m_CurrentImage);
 }
 //virtual
 void ImageUndoRedo::SetUndoImage(const RegionSType& region) {
@@ -39,8 +40,8 @@ void ImageUndoRedo::SetUndoImage(const RegionSType& region) {
                        region.minZ, region.maxZ);
        extract->SetSampleRate(1, 1, 1);
        extract->SetInput(this->m_OriginalImage);
-       this->m_ImagesDeque->AddImageToUndoContainer(extract->GetOutput(), region);
-       extract->Delete();
+       vtkImageData* imgResult = extract->GetOutput();
+       this->m_ImagesDeque->AddImageToUndoContainer(imgResult, region);
 }
 //virtual
 void ImageUndoRedo::SetRedoImage(const RegionSType& region) {
@@ -50,8 +51,8 @@ void ImageUndoRedo::SetRedoImage(const RegionSType& region) {
                        region.minZ, region.maxZ);
        extract->SetSampleRate(1, 1, 1);
        extract->SetInput(this->m_CurrentImage);
-       this->m_ImagesDeque->AddImageToUndoContainer(extract->GetOutput(), region);
-       extract->Delete();
+       vtkImageData* imgResult = extract->GetOutput();
+       this->m_ImagesDeque->AddImageToRedoContainer(imgResult, region);
 }
 void ImageUndoRedo::SetOriginalImage(ImageType* img) {
        this->m_OriginalImage = img;
@@ -60,7 +61,7 @@ void ImageUndoRedo::SetCurrentImage(ImageType* img) {
        this->m_CurrentImage = img;
 }
 //virtual
-void ImageUndoRedo::DrawUR(ImageInfoUR imageInfo) {
+void ImageUndoRedo::DrawUR(ImageInfoUR* imageInfo) {
 
 }
 
index da6cac92824bab5171d8519222f474909445c2a9..f38de3d787b84cad3a78aec9be263e07d58c3c1e 100755 (executable)
@@ -31,7 +31,7 @@ public:
        void SetOriginalImage(ImageType* img);
        void SetCurrentImage(ImageType* img);
 private:
-       virtual void DrawUR(ImageInfoUR imageInfo);
+       virtual void DrawUR(ImageInfoUR* imageInfo);
 
 };
 
index c174558261c83575409a0c55022a870c77bae77c..d58d6db7d528ca24b7ef322d3fb07e85a81bbd94 100644 (file)
@@ -119,13 +119,13 @@ void BrushFilter::Run()  // virtual
                         zz=zz*zz;
                         if (_brushform==0)
                         {
-                               //this->CalculateMinMaxRegion(i,j,k); //DFCH
+                               this->CalculateMinMaxRegion(i,j,k); //DFCH
                             _image->SetScalarComponentFromFloat (i,j,k, 0, value );
                         } else if (_brushform==1)
                         {
                             if ((xx+yy+zz)<=rr)
                             {
-                               //this->CalculateMinMaxRegion(i,j,k); //DFCH
+                               this->CalculateMinMaxRegion(i,j,k); //DFCH
                                 _image->SetScalarComponentFromFloat (i,j,k, 0, value );
                             }
                         } // _brushform
index 0e3651383f6a1bfbc36474fdb8a2692eb7abd35c..694c6abc8d92e852c5f4374795b4d78d0986ded4 100644 (file)
@@ -99,7 +99,7 @@ void FillFilter::FillToolRecursive(int px,int py, int pz)
     {
         if (_usingAuxImageFill==true)
         {
-               //this->CalculateMinMaxRegion(px,py,pz); //DFCH
+               this->CalculateMinMaxRegion(px,py,pz); //DFCH
             _auxImageFill->SetScalarComponentFromFloat (px, py, pz,0, 0);
         }
         _tmpDistfill=(px-_pxfill)*(px-_pxfill)  + (py-_pyfill)*(py-_pyfill) + (pz-_pzfill)*(pz-_pzfill);
@@ -150,7 +150,7 @@ void FillFilter::FillToolRecursive(int px,int py, int pz)
 
         if (  _auxGrayLevelValidationFill==true )
         {
-               //this->CalculateMinMaxRegion(px,py,pz); //DFCH
+               this->CalculateMinMaxRegion(px,py,pz); //DFCH
             _image->SetScalarComponentFromFloat (px,py,pz, 0, (float)_graylevel );
 
             if (_countRecursiveFill< _limitRecursionFill)
@@ -259,7 +259,7 @@ void FillFilter::SetAuxImageFill(int px,int py, int pz)
 {
     if ((px>=_minX) && (px<=_maxX) && (py>=_minY) && (py<=_maxY) && (pz>=_minZ) && (pz<=_maxZ))
     {
-       //this->CalculateMinMaxRegion(px,py,pz); //DFCH
+       this->CalculateMinMaxRegion(px,py,pz); //DFCH
         _auxImageFill->SetScalarComponentFromFloat (px, py, pz,0, 1);
     }
 }
index f51d7d29451262d336bc0dfa6f6b0fe95d79fb12..cdfc6ba889bdac6be08a30b61f340da3bce94423 100644 (file)
@@ -49,7 +49,7 @@ void ManualPaintControler::PaintImage(int px, int py, int pz) {
 }
 
 //---------------------------------------------------------------------------
-/*void ManualPaintControler::SetImageUndo()
+void ManualPaintControler::SetImageUndo()
 {
        _manualPaintModel->SetUndoImage();
-}*/
+}
index c610bd7766327b298c18967908cb48f75bcbd61b..7e7a1fa2adcaedb0f312d10c1ffc736f80f476b2 100644 (file)
@@ -4,7 +4,7 @@ ManualPaintModel::ManualPaintModel() {
        _tool = 0; // 0 pencil         ,   1 fill
        _brushfilter = new BrushFilter();
        _fillfilter = new FillFilter();
-       //_imageUndoRedo = new ImageUndoRedo();
+       _imageUndoRedo = new ImageUndoRedo();
 }
 
 //---------------------------------------------------------------------------
@@ -40,7 +40,8 @@ void ManualPaintModel::Set2D3D(int dim2D3D) {
 void ManualPaintModel::SetImage(vtkImageData *image) {
        _brushfilter->SetImage(image);
        _fillfilter->SetImage(image);
-       //_imageUndoRedo->SetImage(image);
+       std::cout<<"setIMAAAAAAGEEEEEE"<<std::endl;
+       _imageUndoRedo->SetImage(image);
 }
 
 //---------------------------------------------------------------------------
@@ -91,7 +92,7 @@ void ManualPaintModel::GetScalarRange(double * range) {
        _fillfilter->GetScalarRange(range);
 }
 //---------------------------------------------------------------------------
-/*void ManualPaintModel::SetUndoImage() {
+void ManualPaintModel::SetUndoImage() {
        RegionStructUR* region = NULL;
        if (_tool == 0) {
                region = this->_brushfilter->GetModifiedRegion();
@@ -106,5 +107,5 @@ void ManualPaintModel::GetScalarRange(double * range) {
 //---------------------------------------------------------------------------
 
 void ManualPaintModel::Undo() {
-       //this->_imageUndoRedo->Undo();
-}*/
+       this->_imageUndoRedo->Undo();
+}
index e8c8b04b830c037a40abf47c83828deb1dd010ac..93adac962337fc698c78ceeaa3c62668c158f668 100644 (file)
@@ -24,15 +24,15 @@ public:
     void SetRangeMin( int min );
     void SetRangeMax( int max );
     void GetScalarRange( double * range );
-    //void SetUndoImage();//DFCH
-    //void Undo();//DFCH
+    void SetUndoImage();//DFCH
+    void Undo();//DFCH
 
 
 private:
     int             _tool;
     BrushFilter     *_brushfilter;
     FillFilter      *_fillfilter;
-       //ImageUndoRedo *_imageUndoRedo;
+       ImageUndoRedo   *_imageUndoRedo;
 
 protected:
 
index d52f5f09ccbcd5c22138eae2a226062a6c1f0d5f..95f3fad0234f0d7339a4b4bad6a197f8852adebe 100644 (file)
@@ -20,10 +20,8 @@ public:
     void SetRangeMax( int max );
     void GetScalarRange( double * range);
 
-private:
-       ManualPaintModel        *_manualPaintModel;
-
 protected:
+       ManualPaintModel        *_manualPaintModel;
 
 };
 
index 80dbcc4a8d8f99ebeabaa54615f7608e4bef8bbb..3fda57bf49cc39b76705d4eb50672034f39a1fa6 100644 (file)
@@ -1,8 +1,8 @@
 #include "baseFilterManualPaint.h"
 
 baseFilterManualPaint::baseFilterManualPaint() {
-       //_MRegion = new RegionStructUR();
-       //CleanModifiedRegion();
+       _MRegion = new RegionStructUR();
+       CleanModifiedRegion();
        _graylevel = 0.0;
        _2D3D = 1; // 0 2D             ,   1 true 3D
        _direction = 0; // 1 XZ             ,   0 YZ            ,   2 XY
@@ -109,7 +109,7 @@ void baseFilterManualPaint::SetGeneralMinMax(int minX, int maxX, int minY,
 void baseFilterManualPaint::GetScalarRange(double * range) {
        range = this->_image->GetScalarRange();
 }
-/*
+
 RegionStructUR* baseFilterManualPaint::GetModifiedRegion() {
        return (this->_MRegion);
 } //DFCH
@@ -139,5 +139,5 @@ void baseFilterManualPaint::CalculateMinMaxRegion(const int& i, const int& j,
                this->_MRegion->maxZ = k;
        } //fi
 }
-*/
+
 
index f8e521a5429677564183b484c759cd0b21dae47a..ad3f662ea1861e0c3642bf5d7ba4d454fc13c8d1 100644 (file)
@@ -18,15 +18,15 @@ class baseFilterManualPaint  {
         void ResetGeneralMinMax();
         void SetGeneralMinMax(int minX,int maxX,int minY,int maxY,int minZ,int maxZ);
         void GetScalarRange( double * range );
-       /* RegionStructUR* GetModifiedRegion();//DFCH
+        RegionStructUR* GetModifiedRegion();//DFCH
         void CleanModifiedRegion();//DFCH
-        void CalculateMinMaxRegion( const int& i, const int& j, const int& k);//DFCH*/
+        void CalculateMinMaxRegion( const int& i, const int& j, const int& k);//DFCH
         virtual void Run();
 
     private:
 
     protected:
-        //RegionStructUR       *_MRegion; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ).
+        RegionStructUR *_MRegion; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ).
         vtkImageData    *_image;
         int             _direction;
         int            _px;    // start point of the brush
index 0b607c2311345d98c9cab59e2c980e30a2cbbf92..82a82c74c6f5ab90afd24af006fc6403f149e81a 100644 (file)
@@ -7,6 +7,7 @@ vtkInteractorManualPaint::vtkInteractorManualPaint(ManualPaintControler* mpc) {
        _manualPaintControler = mpc;
        _state = false;
        _stateKey = false;
+       _stateMouse = false;
 }
 
 //---------------------------------------------------------------------------
@@ -38,7 +39,8 @@ bool vtkInteractorManualPaint::OnLeftButtonDown() {
 
 //---------------------------------------------------------------------------
 bool vtkInteractorManualPaint::OnLeftButtonUp() {
-       //_manualPaintControler->SetImageUndo();
+    if((_state == true) || (_stateKey == true))
+       _manualPaintControler->SetImageUndo();
        _state = false;
        return true;
 }
index ad65c03fea443905fc357fc7989ec40a170c72a0..318cab3e55dff28e1420e0a8291ca7cf282fb9f2 100644 (file)
@@ -17,6 +17,7 @@ public:
 private:
        bool                    _state;
        bool                    _stateKey;
+       bool                                    _stateMouse;
     ManualPaintControler   *_manualPaintControler;
 
 protected:
index 44b7c0cd702922019cfd9ed597a4932e49ed5e75..75cb61de70a082a3046d295d87329f0c58af8af1 100644 (file)
@@ -78,7 +78,7 @@ wxManualPaintPanel::wxManualPaintPanel(wxWindow * parent) :
        wxButton *btnCopy = new wxButton(panel, -1, _T("Copy"));
        btnCopy->Disable();
        wxButton *btnUndo = new wxButton(panel, -1, _T("Undo"));
-       btnUndo->Disable();
+       //btnUndo->Disable();
 
        Connect(
                        _sldBrushSize->GetId(),
@@ -339,7 +339,7 @@ void wxManualPaintPanel::OnCopy(wxCommandEvent &event) {
 
 //---------------------------------------------------------------------------
 void wxManualPaintPanel::OnUndo(wxCommandEvent &event) {
-       //this->_manualPaintModel->Undo();
+       this->_manualPaintModel->Undo();
 }
 
 //--------------------------------------------------------------------------------------------------------------------------------