]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx
#3335 creaMaracasVisu Feature New Normal - Manual Paint Model Undo Redo from box
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / imageUndoRedo / imageModificationManager.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 /*!
27  * @file        imageMManager.cxx
28  * @brief       This file contains the implementation of the ImageMManager class.
29  * @author      Info-Dev
30  * @author      Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
31  * @date        2011-11-15
32  */
33
34 #include "imageModificationManager.h"
35
36 // ----------------------------------------------------------------------------------
37 ImageMManager::ImageMManager() 
38 {
39         baseInitialPointX=-9999;
40         baseInitialPointY=-9999;
41         baseInitialPointZ=-9999;
42 }
43
44 // ----------------------------------------------------------------------------------
45 ImageMManager::ImageMManager(ImageMManager* manager) 
46 {
47         this->m_RegionStruct    = manager->GetModifiedRegion();
48         this->m_ValidRegion     = manager->ValidateRegion();
49         this->baseInitialPointX = manager->GetBaseInitialPointX();
50         this->baseInitialPointY = manager->GetBaseInitialPointY();
51         this->baseInitialPointZ = manager->GetBaseInitialPointZ();
52 }
53 // ----------------------------------------------------------------------------------
54 ImageMManager::~ImageMManager() 
55 {
56 }
57
58 // ----------------------------------------------------------------------------------
59 void ImageMManager::CleanModifiedRegion() 
60 {
61         int min                                         = std::numeric_limits<int>::min();
62         int max                                         = std::numeric_limits<int>::max();
63         this->m_RegionStruct.minX       = max;
64         this->m_RegionStruct.maxX       = min;
65         this->m_RegionStruct.minY       = max;
66         this->m_RegionStruct.maxY       = min;
67         this->m_RegionStruct.minZ       = max;
68         this->m_RegionStruct.maxZ       = min;
69         this->m_ValidRegion             = false;
70 }
71
72 // ----------------------------------------------------------------------------------
73 void ImageMManager::CalculateMinMaxRegion(const int& i, const int& j, const int& k) 
74 {
75         if (i >= 0 && j >= 0 && k >= 0) 
76         {
77                 if (i <= this->m_RegionStruct.minX) { this->m_RegionStruct.minX = i; } //fi
78                 if (i > this->m_RegionStruct.maxX)  { this->m_RegionStruct.maxX = i; } //esle
79                 if (j <= this->m_RegionStruct.minY) { this->m_RegionStruct.minY = j; } //fi
80                 if (j > this->m_RegionStruct.maxY)  { this->m_RegionStruct.maxY = j; } //esle
81                 if (k <= this->m_RegionStruct.minZ) { this->m_RegionStruct.minZ = k; } //fi
82                 if (k > this->m_RegionStruct.maxZ)  { this->m_RegionStruct.maxZ = k; } //esle
83                 this->m_ValidRegion = true;
84         }else {
85                 this->m_ValidRegion = false;
86         } // if i j k
87
88 //      if (m_ValidRegion )  printf("  ImageMManager::CalculateMinMaxRegion true \n");
89 //      if (!m_ValidRegion ) printf("  ImageMManager::CalculateMinMaxRegion false \n");
90 }
91
92 // ----------------------------------------------------------------------------------
93 void ImageMManager::AddModifiedPixel(const int& i, const int& j, const int& k) 
94 {
95         this->CalculateMinMaxRegion(i, j, k);
96 }
97 // ----------------------------------------------------------------------------------
98 bool ImageMManager::ValidateRegion() 
99 {
100         return (m_ValidRegion);
101 }
102 // ----------------------------------------------------------------------------------
103 RegionStructUR ImageMManager::GetModifiedRegion() 
104 {
105         return (this->m_RegionStruct);
106 }
107 // ----------------------------------------------------------------------------------
108
109 void ImageMManager::BaseInitialPoint(int x, int y, int z)
110 {
111         baseInitialPointX = x;  
112         baseInitialPointY = y;  
113         baseInitialPointZ = z;  
114 }
115
116 int ImageMManager::GetBaseInitialPointX()
117 {
118         return baseInitialPointX;
119 }
120
121 int ImageMManager::GetBaseInitialPointY()
122 {
123         return baseInitialPointY;
124 }
125
126 int ImageMManager::GetBaseInitialPointZ()
127 {
128         return baseInitialPointZ;
129 }
130