]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx
DFCH: Manualpaint + imageUndoRedo Big changes, new class for the management of the...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / imageUndoRedo / imageUndoRedo.cxx
index 55a4e1f24b9fc907f100e6396a65247d05ab75f2..2f80bd6594ff3352d3a53f0e57b1eb5c917d7c88 100755 (executable)
@@ -35,27 +35,30 @@ void ImageUndoRedo::SetImage(VTKImageDataPointerType image) {
        this->m_OriginalImage->DeepCopy(m_CurrentImage);
 }
 //virtual
-void ImageUndoRedo::SetUndoImage(const RegionSType& region) {
+void ImageUndoRedo::SetUndoImage(ImageMManagerType* imMManager) {
+       ImageMManagerType* newImageManager = new ImageMManagerType(imMManager);
+       RegionSType region = newImageManager->GetModifiedRegion();
        VTKImageDataPointerType imgResult = this->GetImageRegion(region,
                        this->m_OriginalImage);
-       this->m_ImagesDeque->AddImageToUndoContainer(imgResult, region);
+       this->m_ImagesDeque->AddImageToUndoContainer(imgResult, newImageManager);
 }
 //virtual
-void ImageUndoRedo::SetRedoImage(const RegionSType& region) {
-       VTKImageDataPointerType imgResult = this->GetImageRegion(region,
-                       this->m_CurrentImage);
-       this->m_ImagesDeque->AddImageToRedoContainer(imgResult, region);
+void ImageUndoRedo::SetRedoImage(const ImageMManagerType* imMManager) {
+       /*RegionSType region = imMManager.GetModifiedRegion();
+        VTKImageDataPointerType imgResult = this->ImageMManagerType(region,
+        this->m_CurrentImage);
+        this->m_ImagesDeque->AddImageToRedoContainer(imgResult, imMManager);*/
 }
 
 ImageUndoRedo::VTKImageDataPointerType ImageUndoRedo::GetImageRegion(
                const RegionSType& region, VTKImageDataPointerType img) {
        VTKExtractVOIPointerType extract = VTKExtractVOIPointerType::New();
-       VTKImageDataPointerType imgResult = VTKImageDataPointerType::New();
        extract->SetVOI(region.minX, region.maxX, region.minY, region.maxY,
                        region.minZ, region.maxZ);
        extract->SetSampleRate(1, 1, 1);
        extract->SetInput(this->m_OriginalImage);
-       imgResult = extract->GetOutput();
+       VTKImageDataPointerType imgResult = extract->GetOutput();
+       imgResult->Update();
        return (imgResult);
 }
 
@@ -68,17 +71,21 @@ void ImageUndoRedo::SetCurrentImage(VTKImageDataPointerType img) {
 //virtual
 void ImageUndoRedo::DrawUR(ImageInfoUR* imageInfo) {
        VTKImageDataPointerType img = imageInfo->GetImage();
-       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);
+       RegionSType region = imageInfo->GetImageMManager()->GetModifiedRegion();
+       ImageMManager::PixelModMap map =
+                       imageInfo->GetImageMManager()->GetModificationMap();
+       std::cout << "Region " << "(" << region.maxX << "," << region.maxY << ","
+                       << region.maxZ << ")" << std::endl;
+       if (img != NULL) {
+               for (int i = region.minX, x = 0; i <= region.maxX; i++, x++) {
+                       for (int j = region.minY, y = 0; j <= region.maxY; j++, y++) {
+                               for (int k = region.minZ, z = 0; k <= region.maxZ; k++, z++) {
+                                       if (map[i][j][k]) {
+                                               float value = img->GetScalarComponentAsFloat(i, j, k,
+                                                               0);
+                                               this->m_CurrentImage->SetScalarComponentFromFloat(i, j,
+                                                               k, 0, value);
+                                       }
                                } //rof
                        } //rof
                } //rof