]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx
DFCH: imageUndoRedo + Manual Paint: It doesn't works :s :s
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / imageUndoRedo / imageUndoRedo.cxx
index dd9bcecf4d3e6233b5a2d79d754f38d075b9b374..2137a713e5d4fcd57277cf17a94598dfcba30bea 100755 (executable)
@@ -17,16 +17,19 @@ ImageUndoRedo::~ImageUndoRedo() {
 //virtual
 void ImageUndoRedo::Undo() {
        ImageInfoUR* imageInfo = this->m_ImagesDeque->Undo();
-       if (imageInfo != NULL)
-       {
-               //this->SetRedoImage(imageInfo->GetRegion());
-               this->DrawUR(imageInfo);
+       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);
+        }*/
 }
 void ImageUndoRedo::SetImage(VTKImageDataPointerType image) {
        this->m_CurrentImage = image;
@@ -34,26 +37,21 @@ void ImageUndoRedo::SetImage(VTKImageDataPointerType 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(const ImageMManagerType* imMManager) {
-       /*RegionSType region = imMManager.GetModifiedRegion();
-        VTKImageDataPointerType imgResult = this->ImageMManagerType(region,
-        this->m_CurrentImage);
-        this->m_ImagesDeque->AddImageToRedoContainer(imgResult, imMManager);*/
-}
 
 void ImageUndoRedo::UpdateUndoImage() {
        this->m_CurrentImage->Update();
@@ -78,8 +76,14 @@ void ImageUndoRedo::SetCurrentImage(VTKImageDataPointerType img) {
        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++) {