From: Diego Caceres Date: Fri, 28 Oct 2011 12:47:32 +0000 (+0000) Subject: DFCH: imageUndoRedo beta1 (Undo Working - problems saving to disk) X-Git-Tag: v1.0.4~49 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=c1e96e29d470edd3c0e9d45db561ff1a5d8bf81a;p=creaMaracasVisu.git DFCH: imageUndoRedo beta1 (Undo Working - problems saving to disk) --- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx index a497b16..22224c5 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx @@ -14,42 +14,38 @@ Image3DDequeUR::~Image3DDequeUR() { //virtual void Image3DDequeUR::AddImageToUndoContainer(VTKImageDataPointerType 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 = new ImageInfoUR(); imageInfo->SetImageName( this->GetImageName(this->m_ImgUndoDeque.size(), true)); imageInfo->SetImage(img); imageInfo->SetRegion(region); + ///--------------------------------------------------------------------------------------------------- + // Uncoment the following line imageInfo->SaveImageAsMHD(this->m_GlobalPath); - //cleaning deque from current position - this->CleanUndoContainerFromIndex(this->m_CurrentUndoPos + 1); - 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 +ImageInfoUR* Image3DDequeUR::Undo() { + ImageInfoUR* imgRet = NULL; + if ((this->m_ImgUndoDeque.size() > 0) && (this->m_CurrentUndoPos != -1)) { + imgRet = this->m_ImgUndoDeque[m_CurrentUndoPos]; + this->m_CurrentUndoPos--; + } //fi + return (imgRet); +} +//virtual void Image3DDequeUR::AddImageToRedoContainer(VTKImageDataPointerType 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 = 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 +ImageInfoUR* Image3DDequeUR::Redo() { + + ImageInfoUR* imgRet = new ImageInfoUR(); + return (imgRet); } //virtual void Image3DDequeUR::CleanUndoContainerFromIndex(const int& index) { @@ -67,64 +63,6 @@ void Image3DDequeUR::CleanRedoContainerFromIndex(const int& index) { this->m_ImgRedoDeque.pop_back(); } } - -//virtual -ImageInfoUR* Image3DDequeUR::Undo() { - ImageInfoUR* imgRet = NULL; - if ((this->m_ImgUndoDeque.size() > 0) && (this->m_CurrentUndoPos != -1)) { - std::cout<<"Controooool"<m_CurrentUndoPos + 1) < this->m_ImgUndoDeque.size()) { - this->m_ImgUndoDeque[(m_CurrentUndoPos + 1)]->RemoveImageFromMemory( - this->m_GlobalPath); - } //fi - imgRet = this->m_ImgUndoDeque[m_CurrentUndoPos]; - std::cout << "imageName: " << imgRet->GetImageName() << std::endl; - this->m_CurrentUndoPos--; - //adding to memory - if (this->m_CurrentUndoPos != -1) { - //Loading image - StringType 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 = 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_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++) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx index 8864148..55a4e1f 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx @@ -19,7 +19,7 @@ void ImageUndoRedo::Undo() { ImageInfoUR* imageInfo = this->m_ImagesDeque->Undo(); if (imageInfo != NULL) { - this->SetRedoImage(imageInfo->GetRegion()); + //this->SetRedoImage(imageInfo->GetRegion()); this->DrawUR(imageInfo); } } @@ -68,18 +68,21 @@ void ImageUndoRedo::SetCurrentImage(VTKImageDataPointerType img) { //virtual void ImageUndoRedo::DrawUR(ImageInfoUR* imageInfo) { VTKImageDataPointerType img = imageInfo->GetImage(); - for (int i = imageInfo->GetRegion().minX, x = 0; - i <= imageInfo->GetRegion().maxX; i++, x++) { - for (int j = imageInfo->GetRegion().minY, y = 0; - j <= imageInfo->GetRegion().maxY; j++, y++) { - for (int k = imageInfo->GetRegion().minZ, z = 0; - k <= imageInfo->GetRegion().maxZ; k++, z++) { - float value = img->GetScalarComponentAsFloat(i, j, k, 0); - this->m_CurrentImage->SetScalarComponentFromFloat(i, j, k, 0, - value); + if( img != NULL ) + { + for (int i = imageInfo->GetRegion().minX, x = 0; + i <= imageInfo->GetRegion().maxX; i++, x++) { + for (int j = imageInfo->GetRegion().minY, y = 0; + j <= imageInfo->GetRegion().maxY; j++, y++) { + for (int k = imageInfo->GetRegion().minZ, z = 0; + k <= imageInfo->GetRegion().maxZ; k++, z++) { + float value = img->GetScalarComponentAsFloat(i, j, k, 0); + this->m_CurrentImage->SetScalarComponentFromFloat(i, j, k, 0, + value); + } //rof } //rof } //rof - } //rof - this->m_CurrentImage->Modified(); + this->m_CurrentImage->Modified(); + } }