]> 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 bf524449210ba8fbfb52bd3bb26f211cce39ca59..2137a713e5d4fcd57277cf17a94598dfcba30bea 100755 (executable)
@@ -17,20 +17,19 @@ ImageUndoRedo::~ImageUndoRedo() {
 //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;
@@ -38,34 +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(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();
@@ -90,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++) {