//virtual
void ImageUndoRedo::Undo() {
ImageInfoUR* imageInfo = this->m_ImagesDeque->Undo();
- if (imageInfo != NULL)
- {
+ if (imageInfo != NULL) {
//this->SetRedoImage(imageInfo->GetImageMManager());
- this->DrawUR(imageInfo);
+ this->DrawUR(imageInfo, true);
this->UpdateUndoImage();
}
}
//virtual
void ImageUndoRedo::Redo() {
/*ImageInfoUR* imageInfo = this->m_ImagesDeque->Redo();
- if (imageInfo != NULL)
- {
- this->DrawUR(imageInfo);
- }*/
+ if (imageInfo != NULL)
+ {
+ this->DrawUR(imageInfo);
+ }*/
}
void ImageUndoRedo::SetImage(VTKImageDataPointerType image) {
this->m_CurrentImage = image;
this->UpdateUndoImage();
}
//virtual
-void ImageUndoRedo::SetUndoImage(ImageMManagerType* imMManager) {
+void ImageUndoRedo::SetURImages(ImageMManagerType* imMManager) {
ImageMManagerType* newImageManager = new ImageMManagerType(imMManager);
if (newImageManager->ValidateRegion()) {
RegionSType region = newImageManager->GetModifiedRegion();
- VTKImageDataPointerType imgResult = this->GetImageRegion(region,
+ VTKImageDataPointerType imgUndo = this->GetImageRegion(region,
this->m_UndoImage);
- this->m_ImagesDeque->AddImageToUndoContainer(imgResult,
+ VTKImageDataPointerType imgRedo = this->GetImageRegion(region,
+ this->m_CurrentImage);
+ this->m_ImagesDeque->AddImagesToURContainer(imgUndo, imgRedo,
newImageManager);
this->UpdateUndoImage();
} else {
std::cerr << "INVALID REGION" << std::endl;
}
}
-//virtual
-void ImageUndoRedo::SetRedoImage(ImageMManagerType* imMManager) {
- /*this->m_CurrentImage->Update();
- ImageMManagerType* newImageManager = new ImageMManagerType(imMManager);
- if (newImageManager->ValidateRegion()) {
- RegionSType region = newImageManager->GetModifiedRegion();
- VTKImageDataPointerType imgResult = this->GetImageRegion(region,
- this->m_CurrentImage);
- this->m_ImagesDeque->AddImageToRedoContainer(imgResult,
- newImageManager);
- imgResult->Update();
- } else {
- std::cerr << "INVALID REGION" << std::endl;
- }*/
-}
void ImageUndoRedo::UpdateUndoImage() {
this->m_CurrentImage->Update();
this->m_CurrentImage = img;
}
//virtual
-void ImageUndoRedo::DrawUR(ImageInfoUR* imageInfo) {
- VTKImageDataPointerType img = imageInfo->GetImage();
+void ImageUndoRedo::DrawUR(ImageInfoUR* imageInfo, const bool& undo) {
+ VTKImageDataPointerType img;
+ if (undo) {
+ img = imageInfo->GetUndoImage();
+ } //fi
+ else {
+ img = imageInfo->GetRedoImage();
+ } //else
RegionSType region = imageInfo->GetImageMManager()->GetModifiedRegion();
if (img != NULL) {
for (int i = region.minX, x = 0; i <= region.maxX; i++, x++) {