From: Diego Caceres Date: Wed, 26 Oct 2011 16:33:03 +0000 (+0000) Subject: DFCH: ManualPaint + imageUndoRedo -> 50% tested. (Save Images undo and redo) :) :) X-Git-Tag: v1.0.4~51 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d0338585b83d4b0422ad465dedd0f885b3441600;p=creaMaracasVisu.git DFCH: ManualPaint + imageUndoRedo -> 50% tested. (Save Images undo and redo) :) :) --- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx index 2f6cdb7..10de209 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx @@ -1,7 +1,9 @@ #include "image3DDequeUR.h" +#include +#include 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()<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); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h index 2909708..414f336 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h @@ -11,6 +11,7 @@ #include "imageDequeUR.h" #include + 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_ */ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.cxx index 649bc3e..66a3240 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.cxx @@ -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; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h index 815040f..5367ce6 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h @@ -15,7 +15,7 @@ #include "imageInfoUR.h" #include "regionStructUR.h" -typedef std::deque ImageInfoDeque; +typedef std::deque 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_ */ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx index b45e21d..18c255e 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx @@ -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) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx index 6a57d07..a459e85 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx @@ -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"<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) { } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h index da6cac9..f38de3d 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h @@ -31,7 +31,7 @@ public: void SetOriginalImage(ImageType* img); void SetCurrentImage(ImageType* img); private: - virtual void DrawUR(ImageInfoUR imageInfo); + virtual void DrawUR(ImageInfoUR* imageInfo); }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp index c174558..d58d6db 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp @@ -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 diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp index 0e36513..694c6ab 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp @@ -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); } } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp index f51d7d2..cdfc6ba 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp @@ -49,7 +49,7 @@ void ManualPaintControler::PaintImage(int px, int py, int pz) { } //--------------------------------------------------------------------------- -/*void ManualPaintControler::SetImageUndo() +void ManualPaintControler::SetImageUndo() { _manualPaintModel->SetUndoImage(); -}*/ +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp index c610bd7..7e7a1fa 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp @@ -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"<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(); +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h index e8c8b04..93adac9 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h @@ -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: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h index d52f5f0..95f3fad 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h @@ -20,10 +20,8 @@ public: void SetRangeMax( int max ); void GetScalarRange( double * range); -private: - ManualPaintModel *_manualPaintModel; - protected: + ManualPaintModel *_manualPaintModel; }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp index 80dbcc4..3fda57b 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp @@ -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 } -*/ + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h index f8e521a..ad3f662 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h @@ -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 diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp index 0b607c2..82a82c7 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp @@ -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; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.h index ad65c03..318cab3 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.h @@ -17,6 +17,7 @@ public: private: bool _state; bool _stateKey; + bool _stateMouse; ManualPaintControler *_manualPaintControler; protected: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp index 44b7c0c..75cb61d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp @@ -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(); } //--------------------------------------------------------------------------------------------------------------------------------