From: reyes Date: Wed, 29 Jun 2011 09:37:43 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=67837fa48c205487fbb9e5d6134d028c142867bc;p=bbtk.git *** empty log message *** --- diff --git a/kernel/src/bbtkSimpleUtilities.cxx b/kernel/src/bbtkSimpleUtilities.cxx deleted file mode 100644 index 549a56a..0000000 --- a/kernel/src/bbtkSimpleUtilities.cxx +++ /dev/null @@ -1,369 +0,0 @@ - -#include "bbtkSimpleUtilities.h" -#define LOG_FILE_NAME "log.txt" - -namespace bbtk -{ - - -//template - - - - - -/* -namespace what -{ - std::string kind(int*); - std::string is(int*, bool withkind=false); - std::string kind(double* a); - std::string is(double* a, bool withkind=false); - std::string kind(float* a); - std::string is(float* a, bool withkind=false); - std::string kind(char* a); - std::string is(char* a, bool withkind=false); - std::string kind(long* a); - std::string is(long* a, bool withkind=false); - std::string kind(short* a); - std::string is(short* a, bool withkind=false); - std::string kind(bool* a); - std::string is(bool* a, bool withkind=false); - std::string kind(void* a); - std::string is(void* a, bool withkind=false); - - std::string kind(unsigned int* a); - std::string is(unsigned int* a, bool withkind=false); - std::string kind(unsigned char* a); - std::string is(unsigned char* a, bool withkind=false); - std::string kind(unsigned long* a); - std::string is(unsigned long* a, bool withkind=false); - std::string kind(unsigned short* a); - std::string is(unsigned short* a, bool withkind=false); - std::string kind(__int64* a); - std::string is(__int64* a, bool withkind=false); - std::string kind(unsigned __int64* a); - std::string is(unsigned __int64* a, bool withkind=false); - std::string kind(long double* a); - std::string is(long double* a, bool withkind=false); - - std::string kind(int a); - std::string is(int a, bool withkind=false); - std::string kind(double a); - std::string is(double a, bool withkind=false); - std::string kind(float a); - std::string is(float a, bool withkind=false); - std::string kind(short a); - std::string is(short a, bool withkind=false); - std::string kind(char a); - std::string is(char a, bool withkind=false); - std::string kind(long a); - std::string is(long a, bool withkind=false); - std::string kind(bool a); - std::string is(bool a, bool withkind=false); - std::string kind(unsigned int a); - std::string is(unsigned int a, bool withkind=false); - std::string kind(unsigned char a); - std::string is(unsigned char a, bool withkind=false); - std::string kind(unsigned long a); - std::string is(unsigned long a, bool withkind=false); - std::string kind(unsigned short a); - std::string is(unsigned short a, bool withkind=false); - std::string kind(__int64 a); - std::string is(__int64 a, bool withkind=false); - std::string kind(unsigned __int64 a); - std::string is(unsigned __int64 a, bool withkind=false); - std::string kind(long double a); - std::string is(long double a, bool withkind=false); - - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector<__int64> a); - std::string is(std::vector<__int64> a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - - std::string is(double* a,int len=1, bool withkind=false); - std::string is(int* a,int len=1, bool withkind=false); - std::string is(float* a,int len=1, bool withkind=false); - std::string is(char* a,int len=1, bool withkind=false); - -} -*/ - - - - bool persistence::writeFile(std::string stm, std::string content) - { - std::ofstream myfile (stm.c_str()); - if (myfile.is_open()) - { - myfile << content; - myfile.close(); - return true; - } - else - { - return false; - } - } - - std::string persistence::readFile(std::string path) - { - std::string line; - std::stringstream stm; - std::ifstream myfile (path.c_str()); - if (myfile.is_open()) - { - while (! myfile.eof() ) - { - getline (myfile,line); - stm << line << std::endl; - } - myfile.close(); - } - else - { - - } - return stm.str(); - } - - - - - std::string logging::fecha() - { - time_t seconds; - seconds = time (NULL); - - //char timeStr [9]; - std::stringstream out; - out << seconds; - std::string la_fecha = out.str(); - //_strtime( timeStr ); - //std::string la_fecha(timeStr); - return "["+la_fecha+"] "; - } - - void logging::out(std::string texto) - { - std::ofstream outFile; - outFile.open(LOG_FILE_NAME, std::ios::app); - if (outFile) - { - outFile << fecha() << texto << std::endl; - } - } - - void logging::erase() - { - std::ofstream outFile; - outFile.open(LOG_FILE_NAME, std::ios::out); - if (outFile) - { - outFile << fecha() << "INICIO" << std::endl; - } - } - - - std::vector translate::StringSplit(std::string str, std::string delim) - { - std::vector results; - int cutAt; - while( (cutAt = (int)str.find_first_of(delim)) != str.npos ) - { - if(cutAt > 0) - { - results.push_back(str.substr(0,cutAt)); - } - str = str.substr(cutAt+1); - } - if(str.length() > 0) - { - results.push_back(str); - } - return results; - } - - std::vector translate::stringTovector(std::string texto, std::string start, std::string end) - { - std::vector el_vector; - std::vector partes; - - - int inicial = (int)texto.find( start, 0 ); - int final = (int)texto.find( end, 0 ); - - if (inicial == std::string::npos || final == std::string::npos) - return el_vector; - if (final<=inicial) - return el_vector; - - std::string contenido = texto.substr(inicial+1, final-inicial-1); - - partes = StringSplit(contenido, ","); - if (partes.size() != -1){ - for (int i=0; i<(int)partes.size(); i++) - { - if (partes.at(i).size() > 0) - { - double uno = atof(partes.at(i).data()); - el_vector.push_back(uno); - } - } - } - return el_vector; - } - - std::vector translate::stringTovectorDelimited(std::string texto, std::string delimitador) - { - std::vector el_vector; - std::vector partes; - - std::string contenido = texto; - - partes = StringSplit(contenido, delimitador); - if (partes.size() != -1){ - for (int i=0; i<(int)partes.size(); i++) - { - double uno = atof(partes.at(i).data()); - el_vector.push_back(uno); - } - } - return el_vector; - } - - double* translate::stringToArray(std::string texto) - { - std::vector el_vector = stringTovector(texto); - double* array = new double[el_vector.size()]; - for (int i=0; i<(int)el_vector.size(); i++) - { - array[i]=el_vector[i]; - } - return array; - } - - std::string translate::getInnerInfo(std::string texto) - { - int first_par = (int)texto.find("[", 0); - int last_par = (int)texto.rfind("]", texto.size()); - - return texto.substr(first_par+1,last_par-first_par-1); - } - - std::vector translate::stringToVectorArray(std::string texto) - { - std::vector el_vector; - std::string innerInfo = getInnerInfo(texto); - - int first_par = 0; - int last_par = 0; - int lastComma = 0; - - while (lastComma != std::string::npos) - { - first_par = (int)innerInfo.find("[", lastComma); - last_par = (int)innerInfo.find("]", lastComma); - lastComma = (int)innerInfo.find(",", last_par); - if (first_par == std::string::npos || last_par == std::string::npos) - break; - std::string subArreglo = innerInfo.substr(first_par,last_par-first_par+1); - double* subArray = stringToArray(subArreglo); - el_vector.push_back(subArray); - } - return el_vector; - } - - std::string translate::vectorToStringDelimited(std::vector a, std::string delim) - { - std::stringstream out; - - unsigned int i; - for (i = 0; i < a.size(); i++) - { - out << a.at(i); - if (i != a.size()-1) - out << delim; - } - return out.str(); - } - - - -//Recorre el vector de manera ciclica -double vectores::vectorInfinite(std::vector in, int index) -{ - //std::cout << "index = " << index; - int value; - int tamanio = in.size(); - bool inverso = false; - if (tamanio == 0) - return -1; - - if (index < 0) - { - inverso = true; - index = abs(index); - value = tamanio - index%tamanio; - if (value == tamanio) - value = 0; - }else{ - value = index%tamanio; - } - //std::cout << ", value=" << value << std::endl; - //return 0; - return in.at(value); -} - - - - /** - Ordenamiento busbuja, array[0] es el maximo - http://mathbits.com/mathbits/compsci/Arrays/Bubble.htm - **/ - void sorts::bubble(std::vector &array) - { - double i, j, flag = 1; // set flag to 1 to begin initial pass - double temp; // holding variable - double arrayLength = array.size(); - for(i = 1; (i <= arrayLength) && flag; i++) - { - flag = 0; - for (j=0; j < (arrayLength -1); j++) - { - if (array[(int)(j+1)] > array[(int)j]) // ascending order simply changes to < - { - temp = array[(int)j]; // swap elements - array[(int)j] = array[(int)(j+1)]; - array[(int)(j+1)] = temp; - flag = 1; // indicates that a swap occurred. - } - } - } - } - -}; - - diff --git a/kernel/src/bbtkSimpleUtilities.h b/kernel/src/bbtkSimpleUtilities.h deleted file mode 100755 index 91d2d97..0000000 --- a/kernel/src/bbtkSimpleUtilities.h +++ /dev/null @@ -1,342 +0,0 @@ -#ifndef _BBTKSIMPLEUTILITIES_H_ -#define _BBTKSIMPLEUTILITIES_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -namespace bbtk -{ - - - -template -class Memcache -{ -public: - vtkImageData* db; - - Memcache() - { - db = NULL; - } - - ~Memcache() - { - if (db!=NULL) - db->Delete(); - } - - void init(int x, int y, int z) - { - //Se pregunta al OS el tamanio de la palabra de un apuntador - int palabra = sizeof(T); - db = vtkImageData::New(); - db->SetScalarType(Memcache::darTipo(palabra)); - db->SetDimensions(x,y,z); - db->SetOrigin(0, 0, 0); - db->AllocateScalars(); - db->Update(); - } - void* get(int x, int y, int z) - { - T* apap = (T*)db->GetScalarPointer(x,y,z); - void* ap = (void*)*apap; - return ap; - } - - void* pop(int x, int y, int z) - { - T* apap = (T*)db->GetScalarPointer(x,y,z); - void* ap = (void*)*apap; - *apap = NULL; - return ap; - } - - void put(int x, int y, int z, void* apt) - { - T* punto = (T*)db->GetScalarPointer(x,y,z); - *punto = (T)apt; - } - void clear() - { - int ext[6]; - db->GetExtent(ext); - T* ap1; - for (int i=ext[0]; i<=ext[1]; i++) - { - for (int j=ext[2]; j<=ext[3]; j++) - { - for (int k=ext[4]; k<=ext[5]; k++) - { - ap1 = (T*)db->GetScalarPointer(i,j,k); - *ap1 = NULL; - } - } - } - } - static int darTipo(int tamanio) - { - if (tamanio == sizeof(char)) - return VTK_CHAR; - if (tamanio == sizeof(unsigned char)) - return VTK_UNSIGNED_CHAR; - if (tamanio == sizeof(short)) - return VTK_SHORT; - if (tamanio == sizeof(unsigned short)) - return VTK_UNSIGNED_SHORT; - if (tamanio == sizeof(int)) - return VTK_INT; - if (tamanio == sizeof(unsigned int)) - return VTK_UNSIGNED_INT; - if (tamanio == sizeof(long)) - return VTK_LONG; - if (tamanio == sizeof(unsigned long)) - return VTK_UNSIGNED_LONG; - if (tamanio == sizeof(float)) - return VTK_FLOAT; - if (tamanio == sizeof(double)) - return VTK_DOUBLE; - return 0; - } - -}; - - -class tiempo -{ - public: - static time_t first, second; - static double bytes; -static void tic(vtkImageData* img) - { - tiempo::bytes = VTK_SIZE(img); - tiempo::first = time (NULL); - } - static void tic(int bytes_=0) - { - tiempo::bytes = bytes_; - tiempo::first = time (NULL); - } - - static void toc() - { - tiempo::second = time (NULL); - double diferencia = difftime (tiempo::second,tiempo::first); - printf ("Total time for %f Bytes is %f (%f Bytes/s)\n", tiempo::bytes, diferencia, tiempo::bytes/diferencia); - } - - static int VTK_SIZE(vtkImageData* img) - { - int dims[3]; - img->GetDimensions(dims); - int tamanio = VTK_SIZE_T(img->GetScalarType()); - std::cout << "[" << dims[0] << "x" << dims[1] << "x" << dims[2] << "x" << tamanio << "]" << std::endl; - return dims[0]*dims[1]*dims[2]*tamanio; - } - static int VTK_SIZE_T(int tipo) - { - switch(tipo) - { - case VTK_CHAR: - return sizeof(char); - break; - case VTK_UNSIGNED_CHAR: - return sizeof(unsigned char); - break; - case VTK_SHORT: - return sizeof(short); - break; - case VTK_UNSIGNED_SHORT: - return sizeof(unsigned short); - break; - case VTK_INT: - return sizeof(int); - break; - case VTK_UNSIGNED_INT: - return sizeof(unsigned int); - break; - case VTK_LONG: - return sizeof(long); - break; - case VTK_UNSIGNED_LONG: - return sizeof(unsigned long); - break; - case VTK_FLOAT: - return sizeof(float); - break; - case VTK_DOUBLE: - return sizeof(double); - break; - default: - return 0; - break; - } - } -}; - -/* -namespace what -{ - std::string kind(int*); - std::string is(int*, bool withkind=false); - std::string kind(double* a); - std::string is(double* a, bool withkind=false); - std::string kind(float* a); - std::string is(float* a, bool withkind=false); - std::string kind(char* a); - std::string is(char* a, bool withkind=false); - std::string kind(long* a); - std::string is(long* a, bool withkind=false); - std::string kind(short* a); - std::string is(short* a, bool withkind=false); - std::string kind(bool* a); - std::string is(bool* a, bool withkind=false); - std::string kind(void* a); - std::string is(void* a, bool withkind=false); - - std::string kind(unsigned int* a); - std::string is(unsigned int* a, bool withkind=false); - std::string kind(unsigned char* a); - std::string is(unsigned char* a, bool withkind=false); - std::string kind(unsigned long* a); - std::string is(unsigned long* a, bool withkind=false); - std::string kind(unsigned short* a); - std::string is(unsigned short* a, bool withkind=false); - std::string kind(__int64* a); - std::string is(__int64* a, bool withkind=false); - std::string kind(unsigned __int64* a); - std::string is(unsigned __int64* a, bool withkind=false); - std::string kind(long double* a); - std::string is(long double* a, bool withkind=false); - - std::string kind(int a); - std::string is(int a, bool withkind=false); - std::string kind(double a); - std::string is(double a, bool withkind=false); - std::string kind(float a); - std::string is(float a, bool withkind=false); - std::string kind(short a); - std::string is(short a, bool withkind=false); - std::string kind(char a); - std::string is(char a, bool withkind=false); - std::string kind(long a); - std::string is(long a, bool withkind=false); - std::string kind(bool a); - std::string is(bool a, bool withkind=false); - std::string kind(unsigned int a); - std::string is(unsigned int a, bool withkind=false); - std::string kind(unsigned char a); - std::string is(unsigned char a, bool withkind=false); - std::string kind(unsigned long a); - std::string is(unsigned long a, bool withkind=false); - std::string kind(unsigned short a); - std::string is(unsigned short a, bool withkind=false); - std::string kind(__int64 a); - std::string is(__int64 a, bool withkind=false); - std::string kind(unsigned __int64 a); - std::string is(unsigned __int64 a, bool withkind=false); - std::string kind(long double a); - std::string is(long double a, bool withkind=false); - - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector<__int64> a); - std::string is(std::vector<__int64> a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - std::string kind(std::vector a); - std::string is(std::vector a, bool withkind=false); - - std::string is(double* a,int len=1, bool withkind=false); - std::string is(int* a,int len=1, bool withkind=false); - std::string is(float* a,int len=1, bool withkind=false); - std::string is(char* a,int len=1, bool withkind=false); -} - -*/ - -class persistence -{ - public: - bool writeFile(std::string stm, std::string content); - std::string readFile(std::string stm); -}; - -class logging -{ - public: - std::string fecha(); - void out(std::string texto); - void erase(); -}; - -class translate -{ - public: - /** - el texto debe ser de la forma [12,45.6] y retorna un vector con la informacion esperada - **/ - std::vector stringTovector(std::string, std::string start="[", std::string end="]"); - /** - Ayuda a parsear una linea de texto que contiene numeros - */ - std::vector stringTovectorDelimited(std::string, std::string); - - std::string vectorToStringDelimited(std::vector a, std::string delim); - std::vector stringToVectorArray(std::string); - /** - StringSplit toma str y lo parte por el delimitador delim y retorna el vector de partes - **/ - std::vector StringSplit(std::string, std::string); - /** - Lo mismo que stringTovector, pero retornando un arreglo en vez de un vector - **/ - double* stringToArray(std::string); - std::string getInnerInfo(std::string); -// std::vector stringToVectorArray(std::string); -}; - -class vectores -{ - public: - //Recorre el vector de manera ciclica - double vectorInfinite(std::vector in, int index); -}; - -class sorts -{ - public: - void bubble(std::vector &array); -}; - -} - -#endif /* _DLL_H_ */ diff --git a/packages/wxvtk/src/wxvtkImageViewer2.cxx b/packages/wxvtk/src/wxvtkImageViewer2.cxx index e0fca3a..533677c 100644 --- a/packages/wxvtk/src/wxvtkImageViewer2.cxx +++ b/packages/wxvtk/src/wxvtkImageViewer2.cxx @@ -21,12 +21,12 @@ #include "vtkImageData.h" #include "vtkImageMapToWindowLevelColors.h" #include "vtkInteractorStyleImage.h" -#include "vtkObjectFactory.h" +#include "vtk.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkRenderer.h" -vtkCxxRevisionMacro(wxvtkImageViewer2, "$Revision: 1.3 $"); +vtkCxxRevisionMacro(wxvtkImageViewer2, "$Revision: 1.4 $"); vtkStandardNewMacro(wxvtkImageViewer2); //---------------------------------------------------------------------------- @@ -110,9 +110,9 @@ void wxvtkImageViewer2::SetupInteractor(vtkRenderWindowInteractor *arg) { this->Interactor->UnRegister(this); } - + this->Interactor = arg; - + if (this->Interactor) { this->Interactor->Register(this); @@ -140,9 +140,9 @@ void wxvtkImageViewer2::SetRenderWindow(vtkRenderWindow *arg) { this->RenderWindow->UnRegister(this); } - + this->RenderWindow = arg; - + if (this->RenderWindow) { this->RenderWindow->Register(this); @@ -165,9 +165,9 @@ void wxvtkImageViewer2::SetRenderer(vtkRenderer *arg) { this->Renderer->UnRegister(this); } - + this->Renderer = arg; - + if (this->Renderer) { this->Renderer->Register(this); @@ -178,13 +178,13 @@ void wxvtkImageViewer2::SetRenderer(vtkRenderer *arg) } //---------------------------------------------------------------------------- -void wxvtkImageViewer2::SetSize(int a,int b) +void wxvtkImageViewer2::SetSize(int a,int b) { this->RenderWindow->SetSize(a, b); } //---------------------------------------------------------------------------- -int* wxvtkImageViewer2::GetSize() +int* wxvtkImageViewer2::GetSize() { return this->RenderWindow->GetSize(); } @@ -215,7 +215,7 @@ int* wxvtkImageViewer2::GetSliceRange() } //---------------------------------------------------------------------------- -int wxvtkImageViewer2::GetSliceMin() +int wxvtkImageViewer2::GetSliceMin() { int *range = this->GetSliceRange(); if (range) @@ -226,7 +226,7 @@ int wxvtkImageViewer2::GetSliceMin() } //---------------------------------------------------------------------------- -int wxvtkImageViewer2::GetSliceMax() +int wxvtkImageViewer2::GetSliceMax() { int *range = this->GetSliceRange(); if (range) @@ -273,7 +273,7 @@ void wxvtkImageViewer2::SetSliceOrientation(int orientation) vtkErrorMacro("Error - invalid slice orientation " << orientation); return; } - + if (this->SliceOrientation == orientation) { return; @@ -281,7 +281,7 @@ void wxvtkImageViewer2::SetSliceOrientation(int orientation) this->SliceOrientation = orientation; - // Update the viewer + // Update the viewer int *range = this->GetSliceRange(); if (range) @@ -317,13 +317,13 @@ void wxvtkImageViewer2::UpdateOrientation() cam->SetPosition(0,0,1); // -1 if medical ? cam->SetViewUp(0,1,0); break; - + case wxvtkImageViewer2::SLICE_ORIENTATION_XZ: cam->SetFocalPoint(0,0,0); cam->SetPosition(0,-1,0); // 1 if medical ? cam->SetViewUp(0,0,1); break; - + case wxvtkImageViewer2::SLICE_ORIENTATION_YZ: cam->SetFocalPoint(0,0,0); cam->SetPosition(1,0,0); // -1 if medical ? @@ -384,7 +384,7 @@ void wxvtkImageViewer2::UpdateDisplayExtent() if (this->Renderer) { - if (this->InteractorStyle && + if (this->InteractorStyle && this->InteractorStyle->GetAutoAdjustCameraClippingRange()) { this->Renderer->ResetCameraClippingRange(); @@ -400,7 +400,7 @@ void wxvtkImageViewer2::UpdateDisplayExtent() double cpos = cam->GetPosition()[this->SliceOrientation]; double range = fabs(spos - cpos); double *spacing = input->GetSpacing(); - double avg_spacing = + double avg_spacing = //(spacing[0] + spacing[1] + spacing[2]) / 3.0; spacing[2]; // JPR?? cam->SetClippingRange( @@ -411,55 +411,55 @@ void wxvtkImageViewer2::UpdateDisplayExtent() } //---------------------------------------------------------------------------- -void wxvtkImageViewer2::SetPosition(int a,int b) +void wxvtkImageViewer2::SetPosition(int a,int b) { this->RenderWindow->SetPosition(a, b); } //---------------------------------------------------------------------------- -int* wxvtkImageViewer2::GetPosition() +int* wxvtkImageViewer2::GetPosition() { return this->RenderWindow->GetPosition(); } //---------------------------------------------------------------------------- -void wxvtkImageViewer2::SetDisplayId(void *a) +void wxvtkImageViewer2::SetDisplayId(void *a) { this->RenderWindow->SetDisplayId(a); } //---------------------------------------------------------------------------- -void wxvtkImageViewer2::SetWindowId(void *a) +void wxvtkImageViewer2::SetWindowId(void *a) { this->RenderWindow->SetWindowId(a); } //---------------------------------------------------------------------------- -void wxvtkImageViewer2::SetParentId(void *a) +void wxvtkImageViewer2::SetParentId(void *a) { this->RenderWindow->SetParentId(a); } //---------------------------------------------------------------------------- -double wxvtkImageViewer2::GetColorWindow() +double wxvtkImageViewer2::GetColorWindow() { return this->WindowLevel->GetWindow(); } //---------------------------------------------------------------------------- -double wxvtkImageViewer2::GetColorLevel() +double wxvtkImageViewer2::GetColorLevel() { return this->WindowLevel->GetLevel(); } //---------------------------------------------------------------------------- -void wxvtkImageViewer2::SetColorWindow(double s) +void wxvtkImageViewer2::SetColorWindow(double s) { this->WindowLevel->SetWindow(s); } //---------------------------------------------------------------------------- -void wxvtkImageViewer2::SetColorLevel(double s) +void wxvtkImageViewer2::SetColorLevel(double s) { this->WindowLevel->SetLevel(s); } @@ -469,9 +469,9 @@ class wxvtkImageViewer2Callback : public vtkCommand { public: static wxvtkImageViewer2Callback *New() { return new wxvtkImageViewer2Callback; } - - void Execute(vtkObject *caller, - unsigned long event, + + void Execute(vtkObject *caller, + unsigned long event, void *vtkNotUsed(callData)) { if (this->IV->GetInput() == NULL) @@ -502,25 +502,25 @@ public: this->InitialLevel = this->IV->GetColorLevel(); return; } - + // Adjust the window level here - vtkInteractorStyleImage *isi = + vtkInteractorStyleImage *isi = static_cast(caller); int *size = this->IV->GetRenderWindow()->GetSize(); double window = this->InitialWindow; double level = this->InitialLevel; - + // Compute normalized delta - double dx = 4.0 * - (isi->GetWindowLevelCurrentPosition()[0] - + double dx = 4.0 * + (isi->GetWindowLevelCurrentPosition()[0] - isi->GetWindowLevelStartPosition()[0]) / size[0]; - double dy = 4.0 * - (isi->GetWindowLevelStartPosition()[1] - + double dy = 4.0 * + (isi->GetWindowLevelStartPosition()[1] - isi->GetWindowLevelCurrentPosition()[1]) / size[1]; - + // Scale by current values if (fabs(window) > 0.01) @@ -539,24 +539,24 @@ public: { dy = dy * (level < 0 ? -0.01 : 0.01); } - + // Abs so that direction does not flip - if (window < 0.0) + if (window < 0.0) { dx = -1*dx; } - if (level < 0.0) + if (level < 0.0) { dy = -1*dy; } - + // Compute new window level double newWindow = dx + window; double newLevel; newLevel = level - dy; - + // Stay away from zero and really if (fabs(newWindow) < 0.01) @@ -567,12 +567,12 @@ public: { newLevel = 0.01*(newLevel < 0 ? -1 : 1); } - + this->IV->SetColorWindow(newWindow); this->IV->SetColorLevel(newLevel); this->IV->Render(); } - + wxvtkImageViewer2 *IV; double InitialWindow; double InitialLevel; @@ -601,7 +601,7 @@ void wxvtkImageViewer2::InstallPipeline() vtkCommand::ResetWindowLevelEvent, cbk); cbk->Delete(); } - + this->Interactor->SetInteractorStyle(this->InteractorStyle); this->Interactor->SetRenderWindow(this->RenderWindow); } @@ -650,20 +650,20 @@ void wxvtkImageViewer2::Render() // Initialize the size if not set yet vtkImageData *input = this->GetInput(); - if (this->RenderWindow->GetSize()[0] == 0 && + if (this->RenderWindow->GetSize()[0] == 0 && input) { - + input->UpdateInformation(); int *w_ext = input->GetWholeExtent(); int xs = 0, ys = 0; - + // std::cout << "wxvtkImageViewer2::Render ext = " // <SliceOrientation) { case wxvtkImageViewer2::SLICE_ORIENTATION_XY: @@ -697,7 +697,7 @@ void wxvtkImageViewer2::Render() this->Renderer->GetActiveCamera()->SetParallelScale( xs < 150 ? 75 : (xs - 1 ) / 2.0); } - this->FirstRender = 0; + this->FirstRender = 0; } } @@ -708,7 +708,7 @@ void wxvtkImageViewer2::Render() } //---------------------------------------------------------------------------- -const char* wxvtkImageViewer2::GetWindowName() +const char* wxvtkImageViewer2::GetWindowName() { return this->RenderWindow->GetWindowName(); } @@ -726,7 +726,7 @@ int wxvtkImageViewer2::GetOffScreenRendering() } //---------------------------------------------------------------------------- -void wxvtkImageViewer2::SetInput(vtkImageData *in) +void wxvtkImageViewer2::SetInput(vtkImageData *in) { // std::cout << "### wxvtkImageViewer2::SetInput"<WindowLevel->SetInput(in); @@ -736,12 +736,12 @@ void wxvtkImageViewer2::SetInput(vtkImageData *in) } //---------------------------------------------------------------------------- vtkImageData* wxvtkImageViewer2::GetInput() -{ +{ return vtkImageData::SafeDownCast(this->WindowLevel->GetInput()); } //---------------------------------------------------------------------------- -void wxvtkImageViewer2::SetInputConnection(vtkAlgorithmOutput* input) +void wxvtkImageViewer2::SetInputConnection(vtkAlgorithmOutput* input) { this->WindowLevel->SetInputConnection(input); this->UpdateDisplayExtent();