]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx
#3331 creaMaracasVisu Bug New Normal - Select contour with 2 points, HelpViewerNV
[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 }
40 // ----------------------------------------------------------------------------------
41 ImageMManager::ImageMManager(ImageMManager* manager) 
42 {
43         this->m_RegionStruct = manager->GetModifiedRegion();
44 }
45 // ----------------------------------------------------------------------------------
46 ImageMManager::~ImageMManager() 
47 {
48 }
49 // ----------------------------------------------------------------------------------
50 void ImageMManager::CleanModifiedRegion() 
51 {
52         int min = std::numeric_limits<int>::min();
53         int max = std::numeric_limits<int>::max();
54         this->m_RegionStruct.minX = max;
55         this->m_RegionStruct.maxX = min;
56         this->m_RegionStruct.minY = max;
57         this->m_RegionStruct.maxY = min;
58         this->m_RegionStruct.minZ = max;
59         this->m_RegionStruct.maxZ = min;
60         this->m_ValidRegion = false;
61 }
62 // ----------------------------------------------------------------------------------
63 void ImageMManager::CalculateMinMaxRegion(const int& i, const int& j, const int& k) 
64 {
65         if (i >= 0 && j >= 0 && k >= 0) 
66         {
67                 if (i <= this->m_RegionStruct.minX) 
68                 {
69                         this->m_RegionStruct.minX = i;
70                 } //fi
71                 if (i > this->m_RegionStruct.maxX) 
72                 {
73                         this->m_RegionStruct.maxX = i;
74                 } //esle
75                 if (j <= this->m_RegionStruct.minY) 
76                 {
77                         this->m_RegionStruct.minY = j;
78                 } //fi
79                 if (j > this->m_RegionStruct.maxY) 
80                 {
81                         this->m_RegionStruct.maxY = j;
82                 } //esle
83                 if (k <= this->m_RegionStruct.minZ) 
84                 {
85                         this->m_RegionStruct.minZ = k;
86                 } //fi
87                 if (k > this->m_RegionStruct.maxZ) 
88                 {
89                         this->m_RegionStruct.maxZ = k;
90                 } //esle
91                 this->m_ValidRegion = true;
92         }else {
93                 this->m_ValidRegion = false;
94         } // if i j k
95
96         if (m_ValidRegion )  printf("  ImageMManager::CalculateMinMaxRegion true \n");
97         if (!m_ValidRegion ) printf("  ImageMManager::CalculateMinMaxRegion false \n");
98 }
99
100 // ----------------------------------------------------------------------------------
101 void ImageMManager::AddModifiedPixel(const int& i, const int& j, const int& k) 
102 {
103 printf("EED ImageMManager::AddModifiedPixel \n");
104         this->CalculateMinMaxRegion(i, j, k);
105 }
106 // ----------------------------------------------------------------------------------
107 bool ImageMManager::ValidateRegion() 
108 {
109         return (m_ValidRegion);
110 }
111 // ----------------------------------------------------------------------------------
112 RegionStructUR ImageMManager::GetModifiedRegion() 
113 {
114         return (this->m_RegionStruct);
115 }
116 // ----------------------------------------------------------------------------------