1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
/*=========================================================================
Program: ITK-SNAP
Module: $RCSfile: SNAPCommon.h,v $
Language: C++
Date: $Date: 2010/07/01 21:40:24 $
Version: $Revision: 1.13 $
Copyright (c) 2007 Paul A. Yushkevich
This file is part of ITK-SNAP
ITK-SNAP is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----
Copyright (c) 2003 Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __SNAPCommon_h_
#define __SNAPCommon_h_
/** This is an include file that should be inserted into all SNAP files */
// Some standard library things are used so commonly that there is no need
// to have them included every time
#include <assert.h>
#include <iostream>
#include <ctime>
// Specify a standard stream for verbose messages
extern std::ostream &verbose;
// Specify a standard stream for error messages
extern std::ostream &snaperr;
// From ITK we use SmartPointer so many times that it is necessary
#include <itkSmartPointer.h>
// Include the VectorNx defintions
#include "IRISVectorTypes.h"
// RGB Pixel support
#include <itkRGBPixel.h>
/** Definitions for the string streams, for compatibility */
typedef std::ostringstream IRISOStringStream;
typedef std::istringstream IRISIStringStream;
// Non-cvs version
extern const char SNAPSoftVersion[];
// Just the number part of the SNAP version
extern unsigned int SNAPVersionMajor;
extern unsigned int SNAPVersionMinor;
extern unsigned int SNAPVersionPatch;
extern const char SNAPVersionQualifier[];
// Hardware architecture for this build
extern const char SNAPArch[];
// A string that appears in the user interface
extern const char SNAPUISoftVersion[];
// Release date of the current version
extern const char SNAPCurrentVersionReleaseDate[];
// Release date of the latest version whose user preference files are
// incompatible with the current version and will be erased
extern const char SNAPLastIncompatibleReleaseDate[];
// Build date - shown to help debugging nightly builds
extern const char SNAPBuildInfo[];
// Voxel types
// CAREFUL: do not redefine this to INT without disabling the usage of
// UnaryFunctorCache in the GreyImageWrapper type. Greyscale instensities
// 0 to MAXGREYVAL are used in a cache table, which would be too big with int
typedef unsigned short LabelType;
typedef short GreyType;
extern const GreyType MAXGREYVAL;
extern const GreyType MINGREYVAL;
typedef itk::RGBPixel<unsigned char> RGBType;
/************************************************************************/
/* Enums that are common enough to declare them outside of a class */
/************************************************************************/
// Coverage mode for draw-over operations
enum CoverageModeType
{
PAINT_OVER_ALL = 0,
PAINT_OVER_VISIBLE,
PAINT_OVER_ONE
};
// Role played by an image layer.
enum LayerRole
{
MAIN_ROLE = 0x0001,
OVERLAY_ROLE = 0x0002,
SNAP_ROLE = 0x0004,
LABEL_ROLE = 0x0008,
NO_ROLE = 0x0010,
ALL_ROLES = 0xffffffff
};
// Cardinal directions in the anatomical space
enum AnatomicalDirection
{
ANATOMY_AXIAL = 0,
ANATOMY_SAGITTAL,
ANATOMY_CORONAL,
ANATOMY_NONSENSE
};
// An atomic data type to represent draw-over state
struct DrawOverFilter
{
CoverageModeType CoverageMode;
LabelType DrawOverLabel;
bool operator == (const DrawOverFilter &cmp) const
{
return CoverageMode == cmp.CoverageMode
&& DrawOverLabel == cmp.DrawOverLabel;
}
bool operator != (const DrawOverFilter &cmp) const
{
return CoverageMode != cmp.CoverageMode
|| DrawOverLabel != cmp.DrawOverLabel;
}
DrawOverFilter()
: CoverageMode(PAINT_OVER_ALL), DrawOverLabel(0) {}
DrawOverFilter(CoverageModeType cm, LabelType label)
: CoverageMode(cm), DrawOverLabel(label) {}
DrawOverFilter(const DrawOverFilter &ref)
: CoverageMode(ref.CoverageMode), DrawOverLabel(ref.DrawOverLabel) {}
};
#define MAX_COLOR_LABELS 0xffff
#define NUM_INITIAL_COLOR_LABELS 6
#define DEFAULT_HISTOGRAM_BINS 40
/**
A debugging function to get the system time in ms. Actual definition is
in SystemInterface.cxx
*/
long get_system_time_ms();
/**
A child class around itk::SmartPointer. It's main purpose is to allow Qt
Creator's intellisense to work with smart pointers. The current version
(Qt 4.7.x) does not complete smart pointers because of typedefs used by
the -> operator. In the future when this goes away (or does not matter)
we can simply replace this class by "typedef itk::SmartPointer SmartPtr"
*/
template <class TObject> class SmartPtr : public itk::SmartPointer<TObject>
{
public:
typedef SmartPtr<TObject> Self;
typedef itk::SmartPointer<TObject> Superclass;
TObject* operator -> () const
{ return Superclass::GetPointer(); }
SmartPtr(const Superclass &p) : Superclass(p) {}
SmartPtr(TObject *p) : Superclass(p) {}
SmartPtr() : Superclass() {}
Self &operator =(const Self &p)
{
Superclass::operator =(p);
return *this;
}
};
/************************************************************************/
/* PY: Some macros because I am tired of typing get/set */
/************************************************************************/
/**
* Set macro borrowed from VTK and modified. Assumes m_ for private vars
*/
#define irisSetMacro(name,type) \
virtual void Set##name (type _arg) \
{ \
this->m_##name = _arg; \
}
/**
* Get macro borrowed from VTK and modified. Assumes m_ for private vars
*/
#define irisGetMacro(name,type) \
virtual type Get##name () const { \
return this->m_##name; \
}
/**
* Get macro borrowed from VTK and modified. Assumes m_ for private vars
*/
#define irisStaticGetMacro(name,type) \
static type Get##name () const { \
return this->m_##name; \
}
/**
* Set macro borrowed from VTK and modified. Assumes m_ for private vars
*/
#define irisVirtualSetMacro(name,type) \
virtual void Set##name (type _arg) = 0;
/**
* Get macro borrowed from VTK and modified. Assumes m_ for private vars
*/
#define irisVirtualGetMacro(name,type) \
virtual type Get##name () const = 0;
/**
* Combo get/set macro
*/
#define irisGetSetMacro(name,type) \
virtual void Set##name (type _arg) \
{ this->m_##name = _arg; } \
virtual type Get##name () const \
{ return this->m_##name; }
/**
* Set macro for strings
*/
#define irisSetStringMacro(name) \
virtual void Set##name (const std::string &_arg) \
{ \
this->m_##name = _arg; \
}
/**
* Get macro borrowed from VTK and modified. Assumes m_ for private vars
*/
#define irisGetStringMacro(name) \
virtual const char *Get##name () const { \
return this->m_##name.c_str(); \
}
/**
* Set macro for strings
*/
#define irisVirtualSetStringMacro(name) \
virtual void Set##name (const std::string &_arg) = 0;
/**
* Get macro borrowed from VTK and modified. Assumes m_ for private vars
*/
#define irisVirtualGetStringMacro(name) \
virtual const char *Get##name () const = 0;
/**
* A get macro for boolean variables, IsXXX instead of GetXXX
*/
#define irisIsMacro(name) \
virtual bool Is##name () const { \
return this->m_##name; \
}
/**
* A get macro for boolean variables, IsXXX instead of GetXXX
*/
#define irisVirtualIsMacro(name) \
virtual bool Is##name () const = 0;
/**
A macro combining the standard macros at the head of itk::Object classes
*/
#define irisITKObjectMacro(self,super) \
typedef self Self; \
typedef super Superclass; \
typedef SmartPtr<Self> Pointer; \
typedef SmartPtr<const Self> ConstPointer; \
itkTypeMacro(self, super) \
itkNewMacro(Self)
/**
A macro combining the standard macros at the head of itk::Object classes,
excluding the New construct
*/
#define irisITKAbstractObjectMacro(self,super) \
typedef self Self; \
typedef super Superclass; \
typedef SmartPtr<Self> Pointer; \
typedef SmartPtr<const Self> ConstPointer; \
itkTypeMacro(self, super)
/**
* A rip off from the ITK not used macro to eliminate 'parameter not used'
* warnings
*/
#define irisNotUsed(x)
#endif // __SNAPCommonIO_h_
|