#include <sstream>
Image3DDequeUR::Image3DDequeUR() {
- this->m_GlobalPath = "/home/pechan/temporal/";
+ this->m_GlobalPath = "/home/caceres/temporal/";
this->m_CurrentURPos = -1;
}
//virtual
this->CleanURContainerFromIndex(this->m_CurrentURPos + 1);
//Adding image
ImageInfoUR* imageInfo = new ImageInfoUR();
- imageInfo->SetImageName(
- this->GetImageName(this->m_ImgURDeque.size(), true));
+ imageInfo->SetImageName(this->GetImageName(this->m_ImgURDeque.size()));
imageInfo->SetImages(imgUndo, imgRedo);
imageInfo->SetImageMManager(imMManager);
//Adding to deque
//virtual
ImageInfoUR* Image3DDequeUR::Undo() {
ImageInfoUR* imgRet = NULL;
- if ((this->m_ImgURDeque.size() > 0) && (this->m_CurrentURPos != -1)) {
+ int imgURDequeSize = this->m_ImgURDeque.size();
+ if ((this->m_ImgURDeque.size() > 0) && (this->m_CurrentURPos != -1)
+ && (this->m_CurrentURPos < imgURDequeSize)) {
imgRet = this->m_ImgURDeque[m_CurrentURPos];
this->m_CurrentURPos--;
} //fi
//virtual
ImageInfoUR* Image3DDequeUR::Redo() {
ImageInfoUR* imgRet = NULL;
+ this->m_CurrentURPos++;
+ int imgURDequeSize = this->m_ImgURDeque.size();
+ if ((this->m_ImgURDeque.size() > 0) && (this->m_CurrentURPos != -1)
+ && (this->m_CurrentURPos < imgURDequeSize)) {
+ imgRet = this->m_ImgURDeque[m_CurrentURPos];
+ } //fi
+ else {
+ this->m_CurrentURPos--;
+ }
return (imgRet);
}
//virtual
//virtual
void Image3DDequeUR::ManageMemory() {
- for (int i = 0; (unsigned int) i < this->m_ImgURDeque.size(); i++) {
+ int imgURDequeSize = this->m_ImgURDeque.size();
+ for (int i = 0; i < imgURDequeSize; i++) {
if (this->m_ImgURDeque[i]->GetStatus()) {
this->m_ImgURDeque[i]->RemoveImagesFromMemory(this->m_GlobalPath);
} //fi
this->m_ImgURDeque[this->m_CurrentURPos]->LoadImagesToMemory(
this->m_GlobalPath);
}
+ int currentRedoPos = this->m_CurrentURPos + 1;
+ if ((currentRedoPos < imgURDequeSize)
+ && !(this->m_ImgURDeque[currentRedoPos]->GetStatus())) {
+ this->m_ImgURDeque[currentRedoPos]->LoadImagesToMemory(
+ this->m_GlobalPath);
+ }
}
void Image3DDequeUR::SetGlobalPath(const StringType& globalPath) {
return (this->m_GlobalPath);
}
-Image3DDequeUR::StringType Image3DDequeUR::GetImageName(const int & pos,
- const bool& undo) {
+Image3DDequeUR::StringType Image3DDequeUR::GetImageName(const int & pos) {
//Giving a name to an image using the date and time
if (this->m_IDImages.empty()) {
time_t rawtime;
virtual ImageInfoUR* Redo();
void SetGlobalPath(const StringType& globalPath);
StringType GetGlobalPath();
- StringType GetImageName(const int & pos, const bool& undo);
+ StringType GetImageName(const int & pos);
void CleanHardDisk();
protected:
ImageInfoDeque m_ImgURDeque;
void ImageUndoRedo::Undo() {
ImageInfoUR* imageInfo = this->m_ImagesDeque->Undo();
if (imageInfo != NULL) {
- //this->SetRedoImage(imageInfo->GetImageMManager());
this->DrawUR(imageInfo, true);
this->UpdateUndoImage();
}
}
//virtual
void ImageUndoRedo::Redo() {
- /*ImageInfoUR* imageInfo = this->m_ImagesDeque->Redo();
- if (imageInfo != NULL)
- {
- this->DrawUR(imageInfo);
- }*/
+ ImageInfoUR* imageInfo = this->m_ImagesDeque->Redo();
+ if (imageInfo != NULL) {
+ this->DrawUR(imageInfo, false);
+ this->UpdateUndoImage();
+ }
}
void ImageUndoRedo::SetImage(VTKImageDataPointerType image) {
this->m_CurrentImage = image;
extract->SetVOI(region.minX, region.maxX, region.minY, region.maxY,
region.minZ, region.maxZ);
extract->SetSampleRate(1, 1, 1);
- extract->SetInput(this->m_UndoImage);
+ extract->SetInput(img);
VTKImageDataPointerType imgResult = extract->GetOutput();
imgResult->Update();
return (imgResult);
_tool = 0; // 0 pencil , 1 fill
_brushfilter = new BrushFilter();
_fillfilter = new FillFilter();
- //_imageUndoRedo = new ImageUndoRedo();
+ _imageUndoRedo = new ImageUndoRedo();
}
//---------------------------------------------------------------------------
void ManualPaintModel::SetImage(vtkImageData *image) {
_brushfilter->SetImage(image);
_fillfilter->SetImage(image);
- //_imageUndoRedo->SetImage(image);
+ _imageUndoRedo->SetImage(image);
}
//---------------------------------------------------------------------------
}
//---------------------------------------------------------------------------
void ManualPaintModel::SetUndoImage() {
- /*ImageMManager* imMManager = NULL;
+ ImageMManager* imMManager = NULL;
if (_tool == 0) {
imMManager = this->_brushfilter->GetImageMManager();
}
}
this->_imageUndoRedo->SetURImages(imMManager);
this->_brushfilter->CleanImageMManager();
- this->_fillfilter->CleanImageMManager();*/
+ this->_fillfilter->CleanImageMManager();
}
//---------------------------------------------------------------------------
void ManualPaintModel::Undo() {
- //this->_imageUndoRedo->Undo();
+ this->_imageUndoRedo->Undo();
}
void ManualPaintModel::Redo() {
- //this->_imageUndoRedo->Redo();
+ this->_imageUndoRedo->Redo();
}