]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h
21d38c5f503bcf70d035fc7aa0e407c2052da28c
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualPaint / baseFilterManualPaint.h
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 #ifndef _BASE_FILTER_MANUAL_PAINT_H_
27 #define _BASE_FILTER_MANUAL_PAINT_H_
28
29 #include <vtkImageData.h>
30
31 //#include "regionStructUR.h"
32
33 #include "imageModificationManager.h"
34
35
36 #define GETVALUE_MANUALPAINT(VALUE,POINTER,SCALARTYPE)                                                                          \
37         if              (SCALARTYPE==VTK_DOUBLE)                { VALUE=(double)*((double*)POINTER);            }       \
38         else if (SCALARTYPE==VTK_FLOAT)                 { VALUE=(double)*((float*)POINTER);                     }       \
39         else if (SCALARTYPE==VTK_CHAR)                  { VALUE=(double)*((char*)POINTER);                      }       \
40         else if (SCALARTYPE==VTK_UNSIGNED_CHAR) { VALUE=(double)*((unsigned char*)POINTER);     }       \
41         else if (SCALARTYPE==VTK_INT)                   { VALUE=(double)*((int*)POINTER);                       }       \
42         else if (SCALARTYPE==VTK_UNSIGNED_INT)  { VALUE=(double)*((unsigned int*)POINTER);      }       \
43         else if (SCALARTYPE==VTK_LONG)                  { VALUE=(double)*((long*)POINTER);                      }       \
44         else if (SCALARTYPE==VTK_UNSIGNED_LONG) { VALUE=(double)*((unsigned long*)POINTER);     }       \
45         else if (SCALARTYPE==VTK_SHORT)                 { VALUE=(double)*((short*)POINTER);                     }       \
46         else if (SCALARTYPE==VTK_UNSIGNED_SHORT){ VALUE=(double)*((unsigned short*)POINTER);}   \
47         else { printf("EED GETVALUE_MANUALPAINT   error\n"); }
48
49 #define GETVALUE2_MANUALPAINT(VALUE,POINTER,SCALARTYPE,INDEX)                                                                           \
50         if              (SCALARTYPE==VTK_DOUBLE)                { VALUE=(double)((double*)POINTER)[INDEX];                      }       \
51         else if (SCALARTYPE==VTK_FLOAT)                 { VALUE=(double)((float*)POINTER)[INDEX];                       }       \
52         else if (SCALARTYPE==VTK_CHAR)                  { VALUE=(double)((char*)POINTER)[INDEX];                        }       \
53         else if (SCALARTYPE==VTK_UNSIGNED_CHAR) { VALUE=(double)((unsigned char*)POINTER)[INDEX];       }       \
54         else if (SCALARTYPE==VTK_INT)                   { VALUE=(double)((int*)POINTER)[INDEX];                         }       \
55         else if (SCALARTYPE==VTK_UNSIGNED_INT)  { VALUE=(double)((unsigned int*)POINTER)[INDEX];        }       \
56         else if (SCALARTYPE==VTK_LONG)                  { VALUE=(double)((long*)POINTER)[INDEX];                        }       \
57         else if (SCALARTYPE==VTK_UNSIGNED_LONG) { VALUE=(double)((unsigned long*)POINTER)[INDEX];       }       \
58         else if (SCALARTYPE==VTK_SHORT)                 { VALUE=(double)((short*)POINTER)[INDEX];                       }       \
59         else if (SCALARTYPE==VTK_UNSIGNED_SHORT){ VALUE=(double)((unsigned short*)POINTER)[INDEX];      }       \
60         else { printf("EED GETVALUE2_MANUALPAINT   error\n"); }
61
62 #define SETVALUE2_MANUALPAINT(VALUE,POINTER,SCALARTYPE,INDEX)                                                                                           \
63         if              (SCALARTYPE==VTK_DOUBLE)                { ((double*)POINTER)[INDEX]                     = (double)VALUE;                }       \
64         else if (SCALARTYPE==VTK_FLOAT)                 { ((float*)POINTER)[INDEX]                      = (float)VALUE;                 }       \
65         else if (SCALARTYPE==VTK_CHAR)                  { ((char*)POINTER)[INDEX]                       = (char)VALUE;                  }       \
66         else if (SCALARTYPE==VTK_UNSIGNED_CHAR) { ((unsigned char*)POINTER)[INDEX]      = (unsigned char)VALUE; }       \
67         else if (SCALARTYPE==VTK_INT)                   { ((int*)POINTER)[INDEX]                        = (int)VALUE;                   }       \
68         else if (SCALARTYPE==VTK_UNSIGNED_INT)  { ((unsigned int*)POINTER)[INDEX]       = (unsigned int)VALUE;  }       \
69         else if (SCALARTYPE==VTK_LONG)                  { ((long*)POINTER)[INDEX]                       = (long)VALUE;                  }       \
70         else if (SCALARTYPE==VTK_UNSIGNED_LONG) { ((unsigned long*)POINTER)[INDEX]      = (unsigned long)VALUE; }       \
71         else if (SCALARTYPE==VTK_SHORT)                 { ((short*)POINTER)[INDEX]                      = (short)VALUE;                 }       \
72         else if (SCALARTYPE==VTK_UNSIGNED_SHORT){ ((unsigned short*)POINTER)[INDEX] = (unsigned short)VALUE;}   \
73         else { printf("EED SETVALUE2_MANUALPAINT   error\n"); }
74
75
76 #define DEFINEPOINTERIMAGE_MANUALPAINT(VALUE,SCALARSIZE,POINTERIMAGE,SCALARTYPE,IMAGE)          \
77         double  VALUE                   = 0;                                                                                                                    \
78         int     SCALARSIZE              = IMAGE->GetScalarSize();                                                                               \
79         char    *POINTERIMAGE   = (char*)(IMAGE->GetScalarPointer());                                                   \
80         int             SCALARTYPE              = IMAGE->GetScalarType();                               
81
82
83
84
85 class baseFilterManualPaint {
86
87 public:
88         baseFilterManualPaint();
89         virtual ~baseFilterManualPaint();
90
91         virtual void SetImages(vtkImageData *image,vtkImageData *image2);
92         void SetPoint(int px, int py, int pz);
93         void Set2D3D(int dim2D3D);
94         void SetGrayLevel(double graylevel);
95         void SetDirection(int direction);
96         void ResetGeneralMinMax();
97         void SetGeneralMinMax(int minX, int maxX, int minY, int maxY, int minZ, int maxZ);
98         void GetScalarRange(double * range);
99
100     void SetRangeMin( int min );//DFCH
101     void SetRangeMax( int max );//DFCH
102     int GetRangeMin( ); //DFCH
103     int GetRangeMax( ); //DFCH
104
105         ImageMManager* GetImageMManager(); //DFCH
106         void CleanImageMManager(); //DFCH
107         virtual void Run();
108
109 private:
110
111 protected:
112         ImageMManager   *_IMManager; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ).
113         vtkImageData    *_image;
114         vtkImageData    *_image2;
115         int                     _direction;
116         int                     _px; // start point of the brush
117         int                     _py;
118         int                     _pz;
119         int                     _pMinX; // General min max of many brush actions
120         int                     _pMinY;
121         int                     _pMinZ;
122         int                     _pMaxX;
123         int                     _pMaxY;
124         int                     _pMaxZ;
125         int                     _minX; // min max of the image
126         int                     _maxX;
127         int                     _minY;
128         int                     _maxY;
129         int                     _minZ;
130         int                     _maxZ;
131         long int                _OneColumn;
132         long int                _OneLine;
133         long int                _OnePlane;
134         bool                    _2D3D;
135         double                  _graylevel;
136     int                         _RangeMin;
137     int                         _RangeMax;
138
139
140 };
141
142 #endif // _BASE_FILTER_MANUAL_PAINT_H_