Commit ee96a02c6686349cd3beb677d4b7563ea73bd02e

Authored by David Mayerich
0 parents

first commit from GitHub

CMakeLists.txt 0 → 100644
  1 +++ a/CMakeLists.txt
  1 +#Specify the version being used aswell as the language
  2 +cmake_minimum_required(VERSION 2.8)
  3 +#Name your project here
  4 +project(TrueEyes)
  5 +
  6 +#set the module directory
  7 +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
  8 +
  9 +#find the Qt4
  10 +find_package(Qt4 REQUIRED)
  11 +include_directories(${QT_INCLUDE_DIRECTORY})
  12 +include(${QT_USE_FILE})
  13 +
  14 +#find OpenGL
  15 +find_package(OpenGL REQUIRED)
  16 +
  17 +#find GLUT
  18 +set(GLUT_ROOT_PATH $ENV{GLUT_ROOT_PATH})
  19 +find_package(GLUT REQUIRED)
  20 +
  21 +#find GLEW
  22 +find_package(GLEW REQUIRED)
  23 +
  24 +#add Qt OpenGL stuff
  25 +set(QT_USE_QTOPENGL TRUE)
  26 +
  27 +#ask the user for the RTS location
  28 +set(RTS_ROOT_PATH $ENV{RTS_ROOT_PATH})
  29 +find_package(RTS REQUIRED)
  30 +
  31 +#set the include directories
  32 +include_directories(
  33 + ${CMAKE_CURRENT_BINARY_DIR}
  34 + ${QT_INCLUDES}
  35 + ${QT_QTOPENGL_INCLUDE_DIR}
  36 + ${OPENGL_INCLUDE_DIR}
  37 + ${GLEW_INCLUDE_PATH}
  38 + ${GLUT_INCLUDE_DIR}
  39 + ${RTS_INCLUDE_DIR}
  40 +)
  41 +
  42 +#set up copying data files
  43 +configure_file(fragPrefix.glsl ${CMAKE_CURRENT_BINARY_DIR}/fragPrefix.glsl @ONLY)
  44 +configure_file(fragPostfix.glsl ${CMAKE_CURRENT_BINARY_DIR}/fragPostfix.glsl @ONLY)
  45 +configure_file(fragRayCast.glsl ${CMAKE_CURRENT_BINARY_DIR}/fragRayCast.glsl @ONLY)
  46 +#configure_file(example/genus.tep ${CMAKE_CURRENT_BINARY_DIR}/example/genus.tep @ONLY)
  47 +#configure_file(example/gradient.glsl ${CMAKE_CURRENT_BINARY_DIR}/example/gradient.glsl @ONLY)
  48 +#configure_file(example/intensity.glsl ${CMAKE_CURRENT_BINARY_DIR}/example/intensity.glsl @ONLY)
  49 +#configure_file(example/high_genus_512_512_512.raw ${CMAKE_CURRENT_BINARY_DIR}/example/high_genus_512_512_512.raw @ONLY)
  50 +
  51 +#Assign source files to the appropriate variables
  52 +file(GLOB SRC_CPP "*.cpp")
  53 +file(GLOB SRC_H "*.h")
  54 +file(GLOB SRC_UI "*.ui")
  55 +file(GLOB SRC_QRC "*.qrc")
  56 +
  57 +#determine which source files have to be moc'd
  58 +Qt4_wrap_cpp(UI_MOC ${SRC_H})
  59 +Qt4_wrap_ui(UI_H ${SRC_UI})
  60 +Qt4_add_resources(ALL_RCC ${ALL_QRC})
  61 +
  62 +#moc the necessary files
  63 +Qt4_automoc(${ALL_CPP})
  64 +
  65 +source_group(QtMoc FILES ${UI_MOC})
  66 +source_group(QtUI FILES ${SRC_UI})
  67 +
  68 +#create an executable
  69 +add_executable(TrueEyes ${SRC_CPP} ${SRC_H} ${UI_H} ${UI_MOC} ${ALL_RCC})
  70 +
  71 +#set the link libraries
  72 +target_link_libraries(TrueEyes ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${GLEW_LIBRARY} ${GLUT_glut_LIBRARY})
  73 +
  74 +
  75 +
... ...
CreateHistogram.cpp 0 → 100644
  1 +++ a/CreateHistogram.cpp
  1 +#include "GlobalValues.h"
  2 +#include <QImage>
  3 +
  4 +struct HistogramStruct{
  5 + unsigned int* hist2D;
  6 + int nBins;
  7 +
  8 + float bounds[4];
  9 +
  10 + HistogramStruct(float minX, float minY, float maxX, float maxY, int bins){
  11 +
  12 + //allocate memory for the histogram
  13 + hist2D = (unsigned int*)malloc(sizeof(unsigned int)*bins*bins);
  14 + memset(hist2D, 0, sizeof(unsigned int)*bins*bins);
  15 +
  16 + bounds[0] = minX;
  17 + bounds[1] = maxX;
  18 + bounds[2] = minY;
  19 + bounds[3] = maxY;
  20 +
  21 + nBins = bins;
  22 + }
  23 +
  24 + bool checkBounds(float x, float y){
  25 + if(x < bounds[0] || x > bounds[1] || y < bounds[2] || y > bounds[3])
  26 + return false;
  27 + else return true;
  28 + }
  29 +
  30 + void increment(float x, float y){
  31 + //increment the counter at the appropriate histogram location
  32 +
  33 + //is the location within the bounds of the histogram
  34 + if(checkBounds(x, y)){
  35 +
  36 + int binX = (x - bounds[0])/(bounds[1] - bounds[0]) * nBins;
  37 + int binY = (y - bounds[2])/(bounds[3] - bounds[2]) * nBins;
  38 +
  39 + hist2D[binY * nBins + binX]++;
  40 + }
  41 +
  42 + }
  43 +
  44 + void saveImage(string fileName){
  45 +
  46 + //create an output image
  47 + QImage outImage(nBins, nBins, QImage::Format_RGB888);
  48 +
  49 + //find the maximum value in the histogram
  50 + unsigned int histMax = 0;
  51 + for(int i=0; i<nBins*nBins; i++)
  52 + if(hist2D[i] > histMax)
  53 + histMax = hist2D[i];
  54 + cout<<"HistMax: "<<histMax;
  55 + //convert all histogram values into colors and save
  56 + int x, y;
  57 + unsigned char intensity;
  58 + QRgb color;
  59 + for(x=0; x<nBins; x++)
  60 + for(y=0; y<nBins; y++){
  61 + intensity = log((double)hist2D[y*nBins + x]) / log((double)histMax) * 255;
  62 + //cout<<(int)intensity<<endl;
  63 + color = qRgb(intensity, intensity, intensity);
  64 + outImage.setPixel(x, y, color);
  65 + }
  66 +
  67 + //save the image file
  68 + outImage.save(fileName.c_str());
  69 + }
  70 +
  71 +
  72 +
  73 +
  74 +
  75 +};
  76 +
  77 +void CreateHistogram(int bins, float& minU, float& maxU, float& minV, float& maxV)
  78 +{
  79 + VolumeData vol = VolumeList[0];
  80 + int Sx = vol.Dim.x;
  81 + int Sy = vol.Dim.y;
  82 + int Sz = vol.Dim.z;
  83 + int C = 3;
  84 +
  85 + //create the histogram
  86 + HistogramStruct histogram(minU, minV, maxU, maxV, bins);
  87 +
  88 +
  89 + //get the texture data from the GPU
  90 + //allocate memory for the volume
  91 + unsigned char* cpuVolume;
  92 + int size = sizeof(unsigned char) * C * Sx * Sy * Sz;
  93 + cpuVolume = (unsigned char*)malloc(size);
  94 + memset(cpuVolume, 0, size);
  95 +
  96 + //copy the texture from the GPU
  97 + vol.Texture.BeginTexture();
  98 + glGetTexImage(GL_TEXTURE_3D, 0, GL_RGB, GL_UNSIGNED_BYTE, cpuVolume);
  99 +
  100 + int x, y, z, c;
  101 + float maxVal = 0;
  102 + float u, v;
  103 + float xn, xp, yn, yp, zn, zp;
  104 + float dx, dy, dz;
  105 + minU = 99999;
  106 + maxU = -99999;
  107 + minV = 99999;
  108 + maxV = -99999;
  109 + for(x=1; x<Sx-1; x++)
  110 + for(y=1; y<Sy-1; y++)
  111 + for(z=1; z<Sz-1; z++)
  112 + for(c=0; c<1; c++)
  113 + {
  114 + //compute the gradient magnitude
  115 + u = cpuVolume[z*Sx*Sy*C + y*Sx*C + x*C + c];
  116 +
  117 + xn = cpuVolume[z*Sx*Sy*C + y*Sx*C + (x-1)*C + c];
  118 + xp = cpuVolume[z*Sx*Sy*C + y*Sx*C + (x+1)*C + c];
  119 + yn = cpuVolume[z*Sx*Sy*C + (y-1)*Sx*C + x*C + c];
  120 + yp = cpuVolume[z*Sx*Sy*C + (y+1)*Sx*C + x*C + c];
  121 + zn = cpuVolume[(z-1)*Sx*Sy*C + y*Sx*C + x*C + c];
  122 + zp = cpuVolume[(z+1)*Sx*Sy*C + y*Sx*C + x*C + c];
  123 +
  124 + dx = (xp - xn)/2.0;
  125 + dy = (yp - yn)/2.0;
  126 + dz = (zp - zn)/2.0;
  127 +
  128 + v = sqrt(dx*dx + dy*dy + dz*dz);
  129 + histogram.increment(u, v);
  130 +
  131 + if(v < minV)
  132 + minV = v;
  133 + if(v > maxV)
  134 + maxV = v;
  135 + if(u < minU)
  136 + minU = u;
  137 + if(u > maxU)
  138 + maxU = u;
  139 +
  140 +
  141 + }
  142 +
  143 + free(cpuVolume);
  144 + cout<<"Data Value: "<<maxVal<<endl;
  145 +
  146 + //save the histogram image
  147 + histogram.saveImage("testHistogram.bmp");
  148 +
  149 +
  150 +}
0 151 \ No newline at end of file
... ...
FindCUDASDK.cmake 0 → 100644
  1 +++ a/FindCUDASDK.cmake
  1 +#
  2 +# The script defines the following variables:
  3 +#
  4 +##############################################################################
  5 +# Note: Removed everything related to CUDA_SDK_ROOT_DIR and only left this as
  6 +# a possible environment variable to set the SDK directory.
  7 +# Include file will be: CUDA_CUT_INCLUDE_DIR
  8 +# Cutil library: CUDA_CUT_LIBRARY
  9 +##############################################################################
  10 +#
  11 +#
  12 +# CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the
  13 +# SDK. This script will not directly support finding
  14 +# specific libraries or headers, as that isn't
  15 +# supported by NVIDIA. If you want to change
  16 +# libraries when the path changes see the
  17 +# FindCUDA.cmake script for an example of how to clear
  18 +# these variables. There are also examples of how to
  19 +# use the CUDA_SDK_ROOT_DIR to locate headers or
  20 +# libraries, if you so choose (at your own risk).
  21 +#
  22 +# This code is licensed under the MIT License. See the FindCUDASDK.cmake script
  23 +# for the text of the license.
  24 +
  25 +# The MIT License
  26 +#
  27 +# License for the specific language governing rights and limitations under
  28 +# Permission is hereby granted, free of charge, to any person obtaining a
  29 +# copy of this software and associated documentation files (the "Software"),
  30 +# to deal in the Software without restriction, including without limitation
  31 +# the rights to use, copy, modify, merge, publish, distribute, sublicense,
  32 +# and/or sell copies of the Software, and to permit persons to whom the
  33 +# Software is furnished to do so, subject to the following conditions:
  34 +#
  35 +# The above copyright notice and this permission notice shall be included
  36 +# in all copies or substantial portions of the Software.
  37 +#
  38 +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  39 +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40 +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  41 +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42 +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  43 +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  44 +# DEALINGS IN THE SOFTWARE.
  45 +#
  46 +###############################################################################
  47 +
  48 +# FindCUDASDK.cmake
  49 +
  50 +# # Check to see if the CUDA_SDK_ROOT_DIR has changed,
  51 +# # if it has then clear the cache variable, so that it will be detected again.
  52 +# if(NOT "${CUDA_SDK_ROOT_DIR}" STREQUAL "${CUDA_SDK_ROOT_DIR_INTERNAL}")
  53 +# # No specific variables to catch. Use this kind of code before calling
  54 +# # find_package(CUDA) to clean up any variables that may depend on this path.
  55 +#
  56 +# # unset(MY_SPECIAL_CUDA_SDK_INCLUDE_DIR CACHE)
  57 +# # unset(MY_SPECIAL_CUDA_SDK_LIBRARY CACHE)
  58 +# endif()
  59 +#
  60 +# ########################
  61 +# # Look for the SDK stuff
  62 +# find_path(CUDA_SDK_ROOT_DIR cutil.h
  63 +# PATH_SUFFIXES "common/inc" "C/common/inc"
  64 +# "$ENV{NVSDKCUDA_ROOT}"
  65 +# "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]"
  66 +# "/Developer/GPU\ Computing/C"
  67 +# )
  68 +#
  69 +# # fallback method for determining CUDA_SDK_ROOT_DIR in case the previous one failed!
  70 +# if (NOT CUDA_SDK_ROOT_DIR)
  71 +# find_path(CUDA_SDK_ROOT_DIR C/common/inc/cutil.h
  72 +# "$ENV{NVSDKCUDA_ROOT}"
  73 +# "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]"
  74 +# "/Developer/GPU\ Computing/C"
  75 +# )
  76 +# endif()
  77 +
  78 +# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the
  79 +# environment variables.
  80 +set(CUDA_SDK_SEARCH_PATH
  81 + "${CUDA_SDK_ROOT_DIR}"
  82 + "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2"
  83 + "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2"
  84 + "${CUDA_TOOLKIT_ROOT_DIR}/NV_SDK"
  85 + "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK"
  86 + "$ENV{HOME}/NVIDIA_CUDA_SDK"
  87 + "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX"
  88 + "$ENV{HOME}/NVIDIA_GPU_Computing_SDK"
  89 + "/Developer/CUDA"
  90 + )
  91 +
  92 +# Find include file from the CUDA_SDK_SEARCH_PATH
  93 +
  94 +find_path(CUDA_CUT_INCLUDE_DIR
  95 + cutil.h
  96 + PATHS ${CUDA_SDK_SEARCH_PATH}
  97 + PATH_SUFFIXES "common/inc" "C/common/inc"
  98 + DOC "Location of cutil.h"
  99 + NO_DEFAULT_PATH
  100 + )
  101 +# Now search system paths
  102 +find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h")
  103 +
  104 +# mark_as_advanced(CUDA_CUT_INCLUDE_DIR)
  105 +
  106 +
  107 +# Example of how to find a library in the CUDA_SDK_ROOT_DIR
  108 +
  109 +# cutil library is called cutil64 for 64 bit builds on windows. We don't want
  110 +# to get these confused, so we are setting the name based on the word size of
  111 +# the build.
  112 +
  113 +# New library might be called cutil_x86_64 !
  114 +
  115 +if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  116 + set(cuda_cutil_name cutil64)
  117 +else(CMAKE_SIZEOF_VOID_P EQUAL 8)
  118 + set(cuda_cutil_name cutil32)
  119 +endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
  120 +
  121 +find_library(CUDA_CUT_LIBRARY
  122 + NAMES ${cuda_cutil_name} cutil cutil_x86_64 cutil_i386
  123 + PATHS ${CUDA_SDK_SEARCH_PATH}
  124 + # The new version of the sdk shows up in common/lib, but the old one is in lib
  125 + # The very newest installation Path of the SDK is in subdirectory 'C'. Please add this Path to the possible suffixes.
  126 + PATH_SUFFIXES "C/lib" "common/lib" "lib" "C/common/lib" "common/lib"
  127 + DOC "Location of cutil library"
  128 + NO_DEFAULT_PATH
  129 + )
  130 +# # Now search system paths
  131 +# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library")
  132 +mark_as_advanced(CUDA_CUT_LIBRARY)
  133 +set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY})
  134 +
  135 +#############################
  136 +# Check for required components
  137 +if(CUDA_CUT_INCLUDE_DIR)
  138 + set(CUDASDK_FOUND TRUE)
  139 +endif(CUDA_CUT_INCLUDE_DIR)
  140 +
  141 +# set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL
  142 +# "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE)
... ...
FindGLEW.cmake 0 → 100644
  1 +++ a/FindGLEW.cmake
  1 +#
  2 +# Try to find GLEW library and include path.
  3 +# Once done this will define
  4 +#
  5 +# GLEW_FOUND
  6 +# GLEW_INCLUDE_PATH
  7 +# GLEW_LIBRARY
  8 +#
  9 +
  10 +IF (WIN32)
  11 + FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
  12 + $ENV{PROGRAMFILES}/GLEW/include
  13 + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include
  14 + DOC "The directory where GL/glew.h resides")
  15 + FIND_LIBRARY( GLEW_LIBRARY
  16 + NAMES glew GLEW glew32 glew32s
  17 + PATHS
  18 + $ENV{PROGRAMFILES}/GLEW/lib
  19 + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
  20 + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
  21 + DOC "The GLEW library")
  22 +ELSE (WIN32)
  23 + FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
  24 + /usr/include
  25 + /usr/local/include
  26 + /sw/include
  27 + /opt/local/include
  28 + DOC "The directory where GL/glew.h resides")
  29 + FIND_LIBRARY( GLEW_LIBRARY
  30 + NAMES GLEW glew
  31 + PATHS
  32 + /usr/lib64
  33 + /usr/lib
  34 + /usr/local/lib64
  35 + /usr/local/lib
  36 + /sw/lib
  37 + /opt/local/lib
  38 + DOC "The GLEW library")
  39 +ENDIF (WIN32)
  40 +
  41 +IF (GLEW_INCLUDE_PATH)
  42 + SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
  43 +ELSE (GLEW_INCLUDE_PATH)
  44 + SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
  45 +ENDIF (GLEW_INCLUDE_PATH)
  46 +
  47 +MARK_AS_ADVANCED(
  48 + GLEW_FOUND
  49 + GLEW_INCLUDE_PATH
  50 + GLEW_LIBRARY
  51 +)
0 52 \ No newline at end of file
... ...
FindRTS.cmake 0 → 100644
  1 +++ a/FindRTS.cmake
  1 +# Tries to find the RTS include directory
  2 +
  3 + FIND_PATH( RTS_INCLUDE_DIR NAMES rts_glShaderProgram.h
  4 + PATHS
  5 + ${CMAKE_CURRENT_SOURCE_DIR}/rts
  6 + ${RTS_ROOT_PATH}
  7 +)
  8 +
  9 +IF (RTS_FOUND)
  10 + #The following deprecated settings are for backwards compatibility with CMake1.4
  11 + SET (RTS_INCLUDE_PATH ${RTS_INCLUDE_DIR})
  12 +ENDIF(RTS_FOUND)
  13 +
  14 +FIND_PACKAGE_HANDLE_STANDARD_ARGS(RTS REQUIRED_VARS TRUE RTS_INCLUDE_DIR)
... ...
GLWidget.cpp 0 → 100644
  1 +++ a/GLWidget.cpp
  1 +#include "GLWidget.h"
  2 +
  3 +//constructor
  4 +GLWidget::GLWidget(QWidget *parent)
  5 + : QGLWidget(parent)
  6 +{
  7 + //initialize the camera
  8 + SourceList[SelectedSource].S.setPosition(0, 0, 1.6);
  9 + SourceList[SelectedSource].S.LookAt(0, 0, 0);
  10 +
  11 +}
  12 +
  13 +//destructor
  14 +GLWidget::~GLWidget()
  15 +{
  16 + makeCurrent();
  17 +
  18 +
  19 +
  20 +
  21 +}
  22 +
  23 +QSize GLWidget::minimumSizeHint() const
  24 +{
  25 + return QSize(50, 50);
  26 +}
  27 +
  28 +QSize GLWidget::sizeHint() const
  29 +{
  30 + return QSize(400, 400);
  31 +}
  32 +
  33 +void GLWidget::initializeGL()
  34 +{
  35 + GLenum err = glewInit();
  36 + if(GLEW_OK != err)
  37 + {
  38 + printf("Error starting GLEW.");
  39 + }
  40 + fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
  41 +
  42 + glClearColor(1.0, 1.0, 1.0, 0.0);
  43 + //glShadeModel(GL_FLAT);
  44 + glEnable(GL_DEPTH_TEST);
  45 + glEnable(GL_BLEND);
  46 + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
  47 + glEnable(GL_CULL_FACE);
  48 +}
  49 +
  50 +void GLWidget::paintGL()
  51 +{
  52 + glMatrixMode(GL_MODELVIEW);
  53 + glLoadIdentity();
  54 +
  55 + //set up the camera
  56 + point3D<float> eye = SourceList[RenderSource].S.getPosition();
  57 + vector3D<float> up = SourceList[RenderSource].S.getUp();
  58 + point3D<float> lookat = SourceList[RenderSource].S.getLookAt();
  59 + gluLookAt(eye.x, eye.y, eye.z, lookat.x, lookat.y, lookat.z, up.x, up.y, up.z);
  60 +
  61 + //clear the screen
  62 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  63 +
  64 +
  65 + glColor3f(0.0, 1.0, 0.0);
  66 +
  67 + //if a volume is loaded, render it
  68 + if(VolumeList.size() > 0)
  69 + DrawCube();
  70 + if(RenderSources)
  71 + DrawLights();
  72 +
  73 + glFlush();
  74 +}
  75 +
  76 +void GLWidget::resizeGL(int width, int height)
  77 +{
  78 + glViewport(0, 0, width, height);
  79 +
  80 + glMatrixMode(GL_PROJECTION);
  81 + glLoadIdentity();
  82 +
  83 + float aspect;
  84 + /*if(width > height)
  85 + {
  86 + aspect = (float)height/(float)width;
  87 + gluPerspective(60, aspect, 0.001, 100);
  88 + //glOrtho(-1, 1, -aspect, aspect, -100, 100);
  89 + }
  90 + else
  91 + {*/
  92 + aspect = (float)width/(float)height;
  93 + //glOrtho(-aspect, aspect, -1, 1, -100, 100);
  94 + gluPerspective(60, aspect, 0.01, 100);
  95 + //}
  96 + glMatrixMode(GL_MODELVIEW);
  97 +}
  98 +
  99 +void GLWidget::mousePressEvent(QMouseEvent *event)
  100 +{
  101 + prevMouse = event->pos();
  102 +}
  103 +
  104 +void GLWidget::mouseMoveEvent(QMouseEvent *event)
  105 +{
  106 + //find the change in mouse position
  107 + int dx = prevMouse.x() - event->pos().x();
  108 + int dy = prevMouse.y() - event->pos().y();
  109 + prevMouse = event->pos();
  110 +
  111 + if(event->buttons() == Qt::LeftButton)
  112 + {
  113 + float theta_factor = 0.01;
  114 + SourceList[RenderSource].S.OrbitFocus(dx*theta_factor, -dy*theta_factor);
  115 + }
  116 + else if(event->buttons() == Qt::RightButton)
  117 + {
  118 + float zoom_factor = 0.01;
  119 + SourceList[RenderSource].S.Push(dy*zoom_factor);
  120 + }
  121 +
  122 + updateGL();
  123 +}
0 124 \ No newline at end of file
... ...
GLWidget.h 0 → 100644
  1 +++ a/GLWidget.h
  1 + #ifndef GLWIDGET_H
  2 + #define GLWIDGET_H
  3 +
  4 +//#include "trueeyes.h"
  5 +#include "GlobalValues.h"
  6 +#include <QtOpenGL/QGLWidget>
  7 +#include <QMouseEvent>
  8 +
  9 +#include "rtsCamera.h"
  10 +#include "GL/glut.h"
  11 +
  12 + class GLWidget : public QGLWidget
  13 + {
  14 + Q_OBJECT
  15 +
  16 + private:
  17 + QPoint prevMouse;
  18 +
  19 + public:
  20 + GLWidget(QWidget *parent = 0);
  21 + ~GLWidget();
  22 +
  23 + QSize minimumSizeHint() const;
  24 + QSize sizeHint() const;
  25 +
  26 + public slots:
  27 +
  28 +
  29 + signals:
  30 +
  31 +
  32 + protected:
  33 + void initializeGL();
  34 + void paintGL();
  35 + void resizeGL(int width, int height);
  36 + void mousePressEvent(QMouseEvent *event);
  37 + //void mouseReleaseEvent(QMouseEvent *event);
  38 + void mouseMoveEvent(QMouseEvent *event);
  39 + //void keyPressEvent(QKeyEvent* event);
  40 +
  41 + private:
  42 +
  43 + };
  44 +
  45 + #endif
0 46 \ No newline at end of file
... ...
GlobalValues.h 0 → 100644
  1 +++ a/GlobalValues.h
  1 +#ifndef GLOBAL_VALUES_H
  2 +#define GLOBAL_VALUES_H
  3 +
  4 +//shader variables
  5 +#include "rts_glShaderProgram.h"
  6 +#include "rts_glShaderObject.h"
  7 +#include "VolumeShaderStruct.h"
  8 +void AttachShaderVariables();
  9 +void SetRenderSource();
  10 +void ReloadShaders();
  11 +void CreateShader(string filename);
  12 +extern vector<VolumeShader> ShaderList;
  13 +extern int SelectedShader;
  14 +
  15 +
  16 +//texture variables
  17 +#include "rts_glTextureMap.h"
  18 +#include "VolumeDataStruct.h"
  19 +#include "TextureDataStruct.h"
  20 +extern rts_glTextureMap VolumeTexture;
  21 +void CreateAutoVolume();
  22 +int LoadRawVolume(VolumeData &newVolume);
  23 +int LoadImages(VolumeData &newVolume);
  24 +int LoadTexture(TextureData &newTexture);
  25 +extern vector<VolumeData> VolumeList;
  26 +extern vector<TextureData> TextureList;
  27 +
  28 +
  29 +//scene variables
  30 +#include "rtsCamera.h"
  31 +#include "VolumeSourceStruct.h"
  32 +extern vector<VolumeSource> SourceList;
  33 +extern float gpVolSize[3];
  34 +extern float gpCropMin[3];
  35 +extern float gpCropMax[3];
  36 +extern int SelectedSource;
  37 +extern int RenderSource;
  38 +extern bool RenderSources;
  39 +extern float StepSize;
  40 +void DrawCube();
  41 +void DrawLights();
  42 +
  43 +//project variables
  44 +void SaveProject(string filename);
  45 +void LoadProject(string filename);
  46 +
  47 +//transfer function variables
  48 +void CreateHistogram(int bins, float& minX, float& maxX, float& minY, float& maxY);
  49 +
  50 +#endif
0 51 \ No newline at end of file
... ...
HistogramToolDialog.h 0 → 100644
  1 +++ a/HistogramToolDialog.h
  1 +#ifndef HISTOGRAMTOOLDIALOG_H
  2 +#define HISTOGRAMTOOLDIALOG_H
  3 +
  4 +#include "ui_HistogramToolDialog.h"
  5 +#include "VolumeDataStruct.h"
  6 +#include "GlobalValues.h"
  7 +#include <QFileDialog>
  8 +#include <iostream>
  9 +using namespace std;
  10 +
  11 +
  12 +
  13 +class HistogramToolDialog : public QDialog
  14 +{
  15 + Q_OBJECT
  16 +
  17 +public:
  18 + HistogramToolDialog(QWidget *parent = 0, Qt::WFlags flags = 0)
  19 + {
  20 + ui.setupUi(this);
  21 +
  22 + }
  23 + ~HistogramToolDialog(){}
  24 +
  25 +private:
  26 + Ui::HistogramToolDialogClass ui;
  27 +
  28 +
  29 +
  30 +
  31 +public slots:
  32 + void on_okButton_clicked()
  33 + {
  34 +
  35 + }
  36 +
  37 + void on_btnCreateHistogram_clicked()
  38 + {
  39 + //get the user-specified histogram margins
  40 + float minX = ui.spinMinX->value();
  41 + float maxX = ui.spinMaxX->value();
  42 + float minY = ui.spinMinY->value();
  43 + float maxY = ui.spinMaxY->value();
  44 +
  45 + int bins = ui.spinBins->value();
  46 +
  47 + //create the histogram and compute the exact margins
  48 + CreateHistogram(bins, minX, maxX, minY, maxY);
  49 +
  50 + //display the exact margins in the labels
  51 + ui.lblDataMinX->setText(QString::number(minX));
  52 + ui.lblDataMaxX->setText(QString::number(maxX));
  53 + ui.lblDataMinY->setText(QString::number(minY));
  54 + ui.lblDataMaxY->setText(QString::number(maxY));
  55 +
  56 + }
  57 +
  58 +
  59 +};
  60 +
  61 +#endif
0 62 \ No newline at end of file
... ...
HistogramToolDialog.ui 0 → 100644
  1 +++ a/HistogramToolDialog.ui
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<ui version="4.0">
  3 + <class>HistogramToolDialogClass</class>
  4 + <widget class="QDialog" name="HistogramToolDialogClass">
  5 + <property name="geometry">
  6 + <rect>
  7 + <x>0</x>
  8 + <y>0</y>
  9 + <width>400</width>
  10 + <height>300</height>
  11 + </rect>
  12 + </property>
  13 + <property name="windowTitle">
  14 + <string>Dialog</string>
  15 + </property>
  16 + <widget class="QWidget" name="layoutWidget">
  17 + <property name="geometry">
  18 + <rect>
  19 + <x>20</x>
  20 + <y>250</y>
  21 + <width>351</width>
  22 + <height>33</height>
  23 + </rect>
  24 + </property>
  25 + <layout class="QHBoxLayout">
  26 + <property name="spacing">
  27 + <number>6</number>
  28 + </property>
  29 + <property name="margin">
  30 + <number>0</number>
  31 + </property>
  32 + <item>
  33 + <spacer>
  34 + <property name="orientation">
  35 + <enum>Qt::Horizontal</enum>
  36 + </property>
  37 + <property name="sizeHint" stdset="0">
  38 + <size>
  39 + <width>131</width>
  40 + <height>31</height>
  41 + </size>
  42 + </property>
  43 + </spacer>
  44 + </item>
  45 + <item>
  46 + <widget class="QPushButton" name="okButton">
  47 + <property name="text">
  48 + <string>OK</string>
  49 + </property>
  50 + </widget>
  51 + </item>
  52 + <item>
  53 + <widget class="QPushButton" name="cancelButton">
  54 + <property name="text">
  55 + <string>Cancel</string>
  56 + </property>
  57 + </widget>
  58 + </item>
  59 + </layout>
  60 + </widget>
  61 + <widget class="QPushButton" name="btnCreateHistogram">
  62 + <property name="geometry">
  63 + <rect>
  64 + <x>20</x>
  65 + <y>210</y>
  66 + <width>75</width>
  67 + <height>23</height>
  68 + </rect>
  69 + </property>
  70 + <property name="text">
  71 + <string>Create</string>
  72 + </property>
  73 + </widget>
  74 + <widget class="QGroupBox" name="groupBox">
  75 + <property name="geometry">
  76 + <rect>
  77 + <x>220</x>
  78 + <y>20</y>
  79 + <width>171</width>
  80 + <height>71</height>
  81 + </rect>
  82 + </property>
  83 + <property name="title">
  84 + <string>Histogram Type</string>
  85 + </property>
  86 + <widget class="QRadioButton" name="radGradientMag">
  87 + <property name="geometry">
  88 + <rect>
  89 + <x>10</x>
  90 + <y>20</y>
  91 + <width>151</width>
  92 + <height>17</height>
  93 + </rect>
  94 + </property>
  95 + <property name="text">
  96 + <string>Grad. Mag. vs Intensity</string>
  97 + </property>
  98 + </widget>
  99 + <widget class="QRadioButton" name="radOrientation">
  100 + <property name="geometry">
  101 + <rect>
  102 + <x>10</x>
  103 + <y>40</y>
  104 + <width>131</width>
  105 + <height>17</height>
  106 + </rect>
  107 + </property>
  108 + <property name="text">
  109 + <string>Orientation (theta, phi)</string>
  110 + </property>
  111 + </widget>
  112 + </widget>
  113 + <widget class="QDoubleSpinBox" name="spinMinX">
  114 + <property name="geometry">
  115 + <rect>
  116 + <x>50</x>
  117 + <y>50</y>
  118 + <width>62</width>
  119 + <height>22</height>
  120 + </rect>
  121 + </property>
  122 + <property name="maximum">
  123 + <double>9999.000000000000000</double>
  124 + </property>
  125 + </widget>
  126 + <widget class="QDoubleSpinBox" name="spinMaxX">
  127 + <property name="geometry">
  128 + <rect>
  129 + <x>120</x>
  130 + <y>50</y>
  131 + <width>62</width>
  132 + <height>22</height>
  133 + </rect>
  134 + </property>
  135 + <property name="maximum">
  136 + <double>9999.000000000000000</double>
  137 + </property>
  138 + <property name="value">
  139 + <double>255.000000000000000</double>
  140 + </property>
  141 + </widget>
  142 + <widget class="QDoubleSpinBox" name="spinMaxY">
  143 + <property name="geometry">
  144 + <rect>
  145 + <x>120</x>
  146 + <y>110</y>
  147 + <width>62</width>
  148 + <height>22</height>
  149 + </rect>
  150 + </property>
  151 + <property name="maximum">
  152 + <double>9999.000000000000000</double>
  153 + </property>
  154 + <property name="value">
  155 + <double>255.000000000000000</double>
  156 + </property>
  157 + </widget>
  158 + <widget class="QDoubleSpinBox" name="spinMinY">
  159 + <property name="geometry">
  160 + <rect>
  161 + <x>50</x>
  162 + <y>110</y>
  163 + <width>62</width>
  164 + <height>22</height>
  165 + </rect>
  166 + </property>
  167 + <property name="maximum">
  168 + <double>9999.000000000000000</double>
  169 + </property>
  170 + </widget>
  171 + <widget class="QLabel" name="label">
  172 + <property name="geometry">
  173 + <rect>
  174 + <x>70</x>
  175 + <y>30</y>
  176 + <width>46</width>
  177 + <height>13</height>
  178 + </rect>
  179 + </property>
  180 + <property name="text">
  181 + <string>Min</string>
  182 + </property>
  183 + </widget>
  184 + <widget class="QLabel" name="label_2">
  185 + <property name="geometry">
  186 + <rect>
  187 + <x>140</x>
  188 + <y>30</y>
  189 + <width>46</width>
  190 + <height>13</height>
  191 + </rect>
  192 + </property>
  193 + <property name="text">
  194 + <string>Max</string>
  195 + </property>
  196 + </widget>
  197 + <widget class="QLabel" name="label_3">
  198 + <property name="geometry">
  199 + <rect>
  200 + <x>30</x>
  201 + <y>50</y>
  202 + <width>16</width>
  203 + <height>16</height>
  204 + </rect>
  205 + </property>
  206 + <property name="text">
  207 + <string>X</string>
  208 + </property>
  209 + </widget>
  210 + <widget class="QLabel" name="label_4">
  211 + <property name="geometry">
  212 + <rect>
  213 + <x>30</x>
  214 + <y>110</y>
  215 + <width>16</width>
  216 + <height>16</height>
  217 + </rect>
  218 + </property>
  219 + <property name="text">
  220 + <string>Y</string>
  221 + </property>
  222 + </widget>
  223 + <widget class="QLabel" name="lblDataMaxX">
  224 + <property name="geometry">
  225 + <rect>
  226 + <x>115</x>
  227 + <y>70</y>
  228 + <width>71</width>
  229 + <height>21</height>
  230 + </rect>
  231 + </property>
  232 + <property name="font">
  233 + <font>
  234 + <pointsize>14</pointsize>
  235 + </font>
  236 + </property>
  237 + <property name="text">
  238 + <string>Max</string>
  239 + </property>
  240 + <property name="alignment">
  241 + <set>Qt::AlignCenter</set>
  242 + </property>
  243 + </widget>
  244 + <widget class="QLabel" name="lblDataMinX">
  245 + <property name="geometry">
  246 + <rect>
  247 + <x>45</x>
  248 + <y>70</y>
  249 + <width>71</width>
  250 + <height>21</height>
  251 + </rect>
  252 + </property>
  253 + <property name="font">
  254 + <font>
  255 + <pointsize>14</pointsize>
  256 + </font>
  257 + </property>
  258 + <property name="text">
  259 + <string>Min</string>
  260 + </property>
  261 + <property name="alignment">
  262 + <set>Qt::AlignCenter</set>
  263 + </property>
  264 + </widget>
  265 + <widget class="QLabel" name="lblDataMinY">
  266 + <property name="geometry">
  267 + <rect>
  268 + <x>45</x>
  269 + <y>130</y>
  270 + <width>71</width>
  271 + <height>21</height>
  272 + </rect>
  273 + </property>
  274 + <property name="font">
  275 + <font>
  276 + <pointsize>14</pointsize>
  277 + </font>
  278 + </property>
  279 + <property name="text">
  280 + <string>Min</string>
  281 + </property>
  282 + <property name="alignment">
  283 + <set>Qt::AlignCenter</set>
  284 + </property>
  285 + </widget>
  286 + <widget class="QLabel" name="lblDataMaxY">
  287 + <property name="geometry">
  288 + <rect>
  289 + <x>115</x>
  290 + <y>130</y>
  291 + <width>71</width>
  292 + <height>21</height>
  293 + </rect>
  294 + </property>
  295 + <property name="font">
  296 + <font>
  297 + <pointsize>14</pointsize>
  298 + </font>
  299 + </property>
  300 + <property name="layoutDirection">
  301 + <enum>Qt::LeftToRight</enum>
  302 + </property>
  303 + <property name="text">
  304 + <string>Max</string>
  305 + </property>
  306 + <property name="alignment">
  307 + <set>Qt::AlignCenter</set>
  308 + </property>
  309 + </widget>
  310 + <widget class="QPushButton" name="btnPreprocess">
  311 + <property name="geometry">
  312 + <rect>
  313 + <x>220</x>
  314 + <y>100</y>
  315 + <width>75</width>
  316 + <height>23</height>
  317 + </rect>
  318 + </property>
  319 + <property name="text">
  320 + <string>Preprocess</string>
  321 + </property>
  322 + </widget>
  323 + <widget class="QSpinBox" name="spinBins">
  324 + <property name="geometry">
  325 + <rect>
  326 + <x>50</x>
  327 + <y>160</y>
  328 + <width>61</width>
  329 + <height>22</height>
  330 + </rect>
  331 + </property>
  332 + <property name="maximum">
  333 + <number>2048</number>
  334 + </property>
  335 + <property name="value">
  336 + <number>128</number>
  337 + </property>
  338 + </widget>
  339 + <widget class="QLabel" name="label_5">
  340 + <property name="geometry">
  341 + <rect>
  342 + <x>25</x>
  343 + <y>160</y>
  344 + <width>21</width>
  345 + <height>20</height>
  346 + </rect>
  347 + </property>
  348 + <property name="text">
  349 + <string>Bins</string>
  350 + </property>
  351 + </widget>
  352 + </widget>
  353 + <resources/>
  354 + <connections>
  355 + <connection>
  356 + <sender>okButton</sender>
  357 + <signal>clicked()</signal>
  358 + <receiver>HistogramToolDialogClass</receiver>
  359 + <slot>accept()</slot>
  360 + <hints>
  361 + <hint type="sourcelabel">
  362 + <x>278</x>
  363 + <y>253</y>
  364 + </hint>
  365 + <hint type="destinationlabel">
  366 + <x>96</x>
  367 + <y>254</y>
  368 + </hint>
  369 + </hints>
  370 + </connection>
  371 + <connection>
  372 + <sender>cancelButton</sender>
  373 + <signal>clicked()</signal>
  374 + <receiver>HistogramToolDialogClass</receiver>
  375 + <slot>reject()</slot>
  376 + <hints>
  377 + <hint type="sourcelabel">
  378 + <x>369</x>
  379 + <y>253</y>
  380 + </hint>
  381 + <hint type="destinationlabel">
  382 + <x>179</x>
  383 + <y>282</y>
  384 + </hint>
  385 + </hints>
  386 + </connection>
  387 + </connections>
  388 +</ui>
... ...
LoadRawDialog.h 0 → 100644
  1 +++ a/LoadRawDialog.h
  1 +#ifndef LOADRAWDIALOG_H
  2 +#define LOADRAWDIALOG_H
  3 +
  4 +#include "ui_LoadRawDialog.h"
  5 +#include "VolumeDataStruct.h"
  6 +#include "GlobalValues.h"
  7 +#include <QFileDialog>
  8 +#include <iostream>
  9 +using namespace std;
  10 +
  11 +
  12 +
  13 +class LoadRawDialog : public QDialog
  14 +{
  15 + Q_OBJECT
  16 +
  17 +public:
  18 + LoadRawDialog(QWidget *parent = 0, Qt::WFlags flags = 0)
  19 + {
  20 + ui.setupUi(this);
  21 + file_size = 0;
  22 + ui.cmbDataType->insertItem(0, tr("uchar"), GL_UNSIGNED_BYTE);
  23 + ui.cmbDataType->insertItem(1, tr("float"), GL_FLOAT);
  24 + ui.cmbDataType->insertItem(2, tr("int16"), GL_SHORT);
  25 +
  26 + ui.cmbInternalPrecision->insertItem(0, tr("8-bit"), GL_UNSIGNED_BYTE);
  27 + ui.cmbInternalPrecision->insertItem(1, tr("32-float"), GL_FLOAT);
  28 + ui.cmbInternalPrecision->insertItem(2, tr("16-bit"), GL_SHORT);
  29 + newVolume.FileType = VOLUME_FILE_RAW;
  30 +
  31 + ui.cmbEndian->insertItem(0, tr("little"), LOAD_LITTLE_ENDIAN);
  32 + ui.cmbEndian->insertItem(1, tr("big"), LOAD_BIG_ENDIAN);
  33 + }
  34 + ~LoadRawDialog(){}
  35 +
  36 +private:
  37 + Ui::LoadRawDialogClass ui;
  38 +
  39 + //volume structure
  40 + VolumeData newVolume;
  41 +
  42 + //loaded file size
  43 + int file_size;
  44 +
  45 + //enables or disables all widgets
  46 + void widgetsEnabled(bool b)
  47 + {
  48 + ui.spinHeaderSize->setEnabled(b);
  49 + ui.cmbDataType->setEnabled(b);
  50 + ui.spinNumComponents->setEnabled(b);
  51 + ui.spinDataSizeX->setEnabled(b);
  52 + ui.spinDataSizeY->setEnabled(b);
  53 + ui.spinDataSizeZ->setEnabled(b);
  54 + ui.cmbEndian->setEnabled(b);
  55 + }
  56 + void updateVolumeStructure()
  57 + {
  58 + newVolume.HeaderSize = ui.spinHeaderSize->text().toInt();
  59 + newVolume.BitType = ui.cmbEndian->itemData(ui.cmbEndian->currentIndex()).toInt();
  60 + newVolume.ExternalComponents = ui.spinNumComponents->text().toInt();
  61 + newVolume.ExternalDatatype = ui.cmbDataType->itemData(ui.cmbDataType->currentIndex()).toInt();
  62 + newVolume.InternalComponents = ui.spinNumComponents->text().toInt();
  63 + newVolume.InternalDatatype = ui.cmbInternalPrecision->itemData(ui.cmbInternalPrecision->currentIndex()).toInt();
  64 + newVolume.GetByteSize(newVolume.ExternalDatatype);
  65 + newVolume.Dim.x = ui.spinDataSizeX->text().toInt();
  66 + newVolume.Dim.y = ui.spinDataSizeY->text().toInt();
  67 + newVolume.Dim.z = ui.spinDataSizeZ->text().toInt();
  68 + newVolume.Normalized = (int)ui.chkNormalized->isChecked();
  69 + //newVolume.Name = ui.txtName->text().toAscii();
  70 + }
  71 + void calculateSize()
  72 + {
  73 + int header = ui.spinHeaderSize->text().toInt();
  74 + int components = ui.spinNumComponents->text().toInt();
  75 + newVolume.ExternalDatatype = ui.cmbDataType->itemData(ui.cmbDataType->currentIndex()).toInt();
  76 + int precision = newVolume.GetByteSize(newVolume.ExternalDatatype);
  77 + int sx = ui.spinDataSizeX->text().toInt();
  78 + int sy = ui.spinDataSizeY->text().toInt();
  79 + int sz = ui.spinDataSizeZ->text().toInt();
  80 +
  81 + int calc_size = header + sx*sy*sz*components*precision;
  82 +
  83 + //update the calculated size on lblCalcSize
  84 + ui.lblCalcSize->setText(QString::number(calc_size));
  85 +
  86 + //if the calculated size is > the size of the file on disk, don't allow OK
  87 + if(calc_size > file_size)
  88 + {
  89 + QPalette plt;
  90 + plt.setColor(QPalette::WindowText, Qt::red);
  91 + ui.lblCalcSize->setPalette(plt);
  92 + ui.okButton->setEnabled(false);
  93 + }
  94 + else if(calc_size < file_size)
  95 + {
  96 + QPalette plt;
  97 + plt.setColor(QPalette::WindowText, Qt::black);
  98 + ui.lblCalcSize->setPalette(plt);
  99 + ui.okButton->setEnabled(true);
  100 + }
  101 + else
  102 + {
  103 + QPalette plt;
  104 + plt.setColor(QPalette::WindowText, Qt::green);
  105 + ui.lblCalcSize->setPalette(plt);
  106 + ui.okButton->setEnabled(true);
  107 + }
  108 + }
  109 +
  110 +public slots:
  111 + void on_okButton_clicked()
  112 + {
  113 + updateVolumeStructure();
  114 + newVolume.Name = newVolume.Filenames[0].getPrefix();
  115 + LoadRawVolume(newVolume);
  116 + }
  117 + void on_spinHeaderSize_valueChanged(int x){calculateSize();}
  118 + void on_spinDataSizeX_valueChanged(int x){calculateSize();}
  119 + void on_spinDataSizeY_valueChanged(int x){calculateSize();}
  120 + void on_spinDataSizeZ_valueChanged(int x){calculateSize();}
  121 + void on_spinNumComponents_valueChanged(int x){calculateSize();}
  122 + void on_cmbDataType_currentIndexChanged(int x){calculateSize();}
  123 + void on_btnLoadFile_clicked()
  124 + {
  125 + //load a file dialog and grab the selected file name
  126 + QStringList filenames =QFileDialog::getOpenFileNames(this,tr("Load RAW Volume"), QString(), tr("(*.*)"));
  127 +
  128 + if(!filenames.isEmpty())
  129 + {
  130 + //fill the newVolume structure with the filenames
  131 + newVolume.Filenames.clear();
  132 + for(int f=0; f<filenames.count(); f++)
  133 + newVolume.Filenames.push_back(string(filenames[f].toAscii()));
  134 +
  135 + //update the textbox showing the first filename
  136 + ui.txtFilename->setText(filenames[0]);
  137 +
  138 + //enable all of the widgets
  139 + widgetsEnabled(true);
  140 +
  141 + //disable the z-widget if multiple files are selected
  142 + if(filenames.count() > 1)
  143 + {
  144 + ui.spinDataSizeZ->setValue(1);
  145 + ui.spinDataSizeZ->setEnabled(false);
  146 + }
  147 +
  148 + //get the file size
  149 + string file_string = (const char *)filenames[0].toAscii();
  150 + cout<<file_string<<endl;
  151 + FILE* f = fopen(file_string.c_str(), "rb");
  152 + fseek(f, 0, SEEK_END);
  153 + file_size = ftell(f);
  154 + fclose(f);
  155 +
  156 + //update lblFileSize
  157 + ui.lblFileSize->setText(QString::number(file_size));
  158 + calculateSize();
  159 + }
  160 + else
  161 + {
  162 + //disable all of the widgets
  163 + ui.txtFilename->setText(QString());
  164 + widgetsEnabled(false);
  165 + }
  166 +
  167 + }
  168 +
  169 +};
  170 +
  171 +#endif
0 172 \ No newline at end of file
... ...
LoadRawDialog.ui 0 → 100644
  1 +++ a/LoadRawDialog.ui
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<ui version="4.0">
  3 + <class>LoadRawDialogClass</class>
  4 + <widget class="QDialog" name="LoadRawDialogClass">
  5 + <property name="geometry">
  6 + <rect>
  7 + <x>0</x>
  8 + <y>0</y>
  9 + <width>400</width>
  10 + <height>340</height>
  11 + </rect>
  12 + </property>
  13 + <property name="windowTitle">
  14 + <string>Dialog</string>
  15 + </property>
  16 + <widget class="QWidget" name="layoutWidget">
  17 + <property name="geometry">
  18 + <rect>
  19 + <x>20</x>
  20 + <y>300</y>
  21 + <width>351</width>
  22 + <height>33</height>
  23 + </rect>
  24 + </property>
  25 + <layout class="QHBoxLayout">
  26 + <property name="spacing">
  27 + <number>6</number>
  28 + </property>
  29 + <property name="margin">
  30 + <number>0</number>
  31 + </property>
  32 + <item>
  33 + <spacer>
  34 + <property name="orientation">
  35 + <enum>Qt::Horizontal</enum>
  36 + </property>
  37 + <property name="sizeHint" stdset="0">
  38 + <size>
  39 + <width>131</width>
  40 + <height>31</height>
  41 + </size>
  42 + </property>
  43 + </spacer>
  44 + </item>
  45 + <item>
  46 + <widget class="QPushButton" name="okButton">
  47 + <property name="enabled">
  48 + <bool>true</bool>
  49 + </property>
  50 + <property name="text">
  51 + <string>OK</string>
  52 + </property>
  53 + </widget>
  54 + </item>
  55 + <item>
  56 + <widget class="QPushButton" name="cancelButton">
  57 + <property name="text">
  58 + <string>Cancel</string>
  59 + </property>
  60 + </widget>
  61 + </item>
  62 + </layout>
  63 + </widget>
  64 + <widget class="QPushButton" name="btnLoadFile">
  65 + <property name="geometry">
  66 + <rect>
  67 + <x>10</x>
  68 + <y>10</y>
  69 + <width>75</width>
  70 + <height>23</height>
  71 + </rect>
  72 + </property>
  73 + <property name="text">
  74 + <string>Load File</string>
  75 + </property>
  76 + </widget>
  77 + <widget class="QSpinBox" name="spinDataSizeX">
  78 + <property name="enabled">
  79 + <bool>false</bool>
  80 + </property>
  81 + <property name="geometry">
  82 + <rect>
  83 + <x>30</x>
  84 + <y>180</y>
  85 + <width>81</width>
  86 + <height>22</height>
  87 + </rect>
  88 + </property>
  89 + <property name="maximum">
  90 + <number>100000000</number>
  91 + </property>
  92 + <property name="value">
  93 + <number>1</number>
  94 + </property>
  95 + </widget>
  96 + <widget class="QSpinBox" name="spinDataSizeY">
  97 + <property name="enabled">
  98 + <bool>false</bool>
  99 + </property>
  100 + <property name="geometry">
  101 + <rect>
  102 + <x>160</x>
  103 + <y>180</y>
  104 + <width>81</width>
  105 + <height>22</height>
  106 + </rect>
  107 + </property>
  108 + <property name="maximum">
  109 + <number>100000000</number>
  110 + </property>
  111 + <property name="value">
  112 + <number>1</number>
  113 + </property>
  114 + </widget>
  115 + <widget class="QSpinBox" name="spinDataSizeZ">
  116 + <property name="enabled">
  117 + <bool>false</bool>
  118 + </property>
  119 + <property name="geometry">
  120 + <rect>
  121 + <x>280</x>
  122 + <y>180</y>
  123 + <width>81</width>
  124 + <height>22</height>
  125 + </rect>
  126 + </property>
  127 + <property name="maximum">
  128 + <number>100000000</number>
  129 + </property>
  130 + <property name="value">
  131 + <number>1</number>
  132 + </property>
  133 + </widget>
  134 + <widget class="QLabel" name="label">
  135 + <property name="geometry">
  136 + <rect>
  137 + <x>10</x>
  138 + <y>180</y>
  139 + <width>16</width>
  140 + <height>16</height>
  141 + </rect>
  142 + </property>
  143 + <property name="font">
  144 + <font>
  145 + <pointsize>12</pointsize>
  146 + </font>
  147 + </property>
  148 + <property name="text">
  149 + <string>X</string>
  150 + </property>
  151 + </widget>
  152 + <widget class="QLabel" name="label_2">
  153 + <property name="geometry">
  154 + <rect>
  155 + <x>140</x>
  156 + <y>180</y>
  157 + <width>16</width>
  158 + <height>16</height>
  159 + </rect>
  160 + </property>
  161 + <property name="font">
  162 + <font>
  163 + <pointsize>12</pointsize>
  164 + </font>
  165 + </property>
  166 + <property name="text">
  167 + <string>Y</string>
  168 + </property>
  169 + </widget>
  170 + <widget class="QLabel" name="label_3">
  171 + <property name="geometry">
  172 + <rect>
  173 + <x>260</x>
  174 + <y>180</y>
  175 + <width>16</width>
  176 + <height>16</height>
  177 + </rect>
  178 + </property>
  179 + <property name="font">
  180 + <font>
  181 + <pointsize>12</pointsize>
  182 + </font>
  183 + </property>
  184 + <property name="text">
  185 + <string>Z</string>
  186 + </property>
  187 + </widget>
  188 + <widget class="QLabel" name="label_4">
  189 + <property name="geometry">
  190 + <rect>
  191 + <x>40</x>
  192 + <y>160</y>
  193 + <width>51</width>
  194 + <height>16</height>
  195 + </rect>
  196 + </property>
  197 + <property name="text">
  198 + <string>Data Size</string>
  199 + </property>
  200 + </widget>
  201 + <widget class="QLabel" name="label_5">
  202 + <property name="geometry">
  203 + <rect>
  204 + <x>20</x>
  205 + <y>110</y>
  206 + <width>101</width>
  207 + <height>16</height>
  208 + </rect>
  209 + </property>
  210 + <property name="text">
  211 + <string>Header Size (bytes)</string>
  212 + </property>
  213 + </widget>
  214 + <widget class="QSpinBox" name="spinHeaderSize">
  215 + <property name="enabled">
  216 + <bool>false</bool>
  217 + </property>
  218 + <property name="geometry">
  219 + <rect>
  220 + <x>30</x>
  221 + <y>130</y>
  222 + <width>81</width>
  223 + <height>22</height>
  224 + </rect>
  225 + </property>
  226 + <property name="correctionMode">
  227 + <enum>QAbstractSpinBox::CorrectToNearestValue</enum>
  228 + </property>
  229 + <property name="minimum">
  230 + <number>0</number>
  231 + </property>
  232 + <property name="maximum">
  233 + <number>100000000</number>
  234 + </property>
  235 + <property name="singleStep">
  236 + <number>1</number>
  237 + </property>
  238 + </widget>
  239 + <widget class="QComboBox" name="cmbDataType">
  240 + <property name="enabled">
  241 + <bool>false</bool>
  242 + </property>
  243 + <property name="geometry">
  244 + <rect>
  245 + <x>160</x>
  246 + <y>130</y>
  247 + <width>81</width>
  248 + <height>22</height>
  249 + </rect>
  250 + </property>
  251 + </widget>
  252 + <widget class="QLabel" name="label_6">
  253 + <property name="geometry">
  254 + <rect>
  255 + <x>180</x>
  256 + <y>110</y>
  257 + <width>61</width>
  258 + <height>16</height>
  259 + </rect>
  260 + </property>
  261 + <property name="text">
  262 + <string>Data Type</string>
  263 + </property>
  264 + </widget>
  265 + <widget class="QLabel" name="label_7">
  266 + <property name="geometry">
  267 + <rect>
  268 + <x>290</x>
  269 + <y>110</y>
  270 + <width>71</width>
  271 + <height>16</height>
  272 + </rect>
  273 + </property>
  274 + <property name="text">
  275 + <string>Components</string>
  276 + </property>
  277 + </widget>
  278 + <widget class="QSpinBox" name="spinNumComponents">
  279 + <property name="enabled">
  280 + <bool>false</bool>
  281 + </property>
  282 + <property name="geometry">
  283 + <rect>
  284 + <x>280</x>
  285 + <y>130</y>
  286 + <width>81</width>
  287 + <height>22</height>
  288 + </rect>
  289 + </property>
  290 + <property name="value">
  291 + <number>1</number>
  292 + </property>
  293 + </widget>
  294 + <widget class="QTextBrowser" name="txtFilename">
  295 + <property name="geometry">
  296 + <rect>
  297 + <x>110</x>
  298 + <y>10</y>
  299 + <width>271</width>
  300 + <height>71</height>
  301 + </rect>
  302 + </property>
  303 + </widget>
  304 + <widget class="QLabel" name="lblCalcSize">
  305 + <property name="geometry">
  306 + <rect>
  307 + <x>20</x>
  308 + <y>220</y>
  309 + <width>91</width>
  310 + <height>31</height>
  311 + </rect>
  312 + </property>
  313 + <property name="font">
  314 + <font>
  315 + <pointsize>12</pointsize>
  316 + </font>
  317 + </property>
  318 + <property name="layoutDirection">
  319 + <enum>Qt::LeftToRight</enum>
  320 + </property>
  321 + <property name="text">
  322 + <string/>
  323 + </property>
  324 + <property name="alignment">
  325 + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
  326 + </property>
  327 + </widget>
  328 + <widget class="QLabel" name="lblLoadSize_2">
  329 + <property name="geometry">
  330 + <rect>
  331 + <x>120</x>
  332 + <y>220</y>
  333 + <width>21</width>
  334 + <height>31</height>
  335 + </rect>
  336 + </property>
  337 + <property name="font">
  338 + <font>
  339 + <pointsize>12</pointsize>
  340 + </font>
  341 + </property>
  342 + <property name="text">
  343 + <string>/</string>
  344 + </property>
  345 + </widget>
  346 + <widget class="QLabel" name="lblFileSize">
  347 + <property name="geometry">
  348 + <rect>
  349 + <x>130</x>
  350 + <y>220</y>
  351 + <width>91</width>
  352 + <height>31</height>
  353 + </rect>
  354 + </property>
  355 + <property name="font">
  356 + <font>
  357 + <pointsize>12</pointsize>
  358 + </font>
  359 + </property>
  360 + <property name="text">
  361 + <string/>
  362 + </property>
  363 + </widget>
  364 + <widget class="QLabel" name="label_8">
  365 + <property name="geometry">
  366 + <rect>
  367 + <x>40</x>
  368 + <y>210</y>
  369 + <width>191</width>
  370 + <height>16</height>
  371 + </rect>
  372 + </property>
  373 + <property name="text">
  374 + <string>Calculated Size Size on Disk</string>
  375 + </property>
  376 + </widget>
  377 + <widget class="QComboBox" name="cmbInternalPrecision">
  378 + <property name="enabled">
  379 + <bool>true</bool>
  380 + </property>
  381 + <property name="geometry">
  382 + <rect>
  383 + <x>250</x>
  384 + <y>230</y>
  385 + <width>81</width>
  386 + <height>22</height>
  387 + </rect>
  388 + </property>
  389 + </widget>
  390 + <widget class="QLabel" name="label_10">
  391 + <property name="geometry">
  392 + <rect>
  393 + <x>230</x>
  394 + <y>210</y>
  395 + <width>131</width>
  396 + <height>16</height>
  397 + </rect>
  398 + </property>
  399 + <property name="text">
  400 + <string>Internal Precision (GPU)</string>
  401 + </property>
  402 + </widget>
  403 + <widget class="QLabel" name="label_9">
  404 + <property name="geometry">
  405 + <rect>
  406 + <x>20</x>
  407 + <y>40</y>
  408 + <width>71</width>
  409 + <height>16</height>
  410 + </rect>
  411 + </property>
  412 + <property name="text">
  413 + <string>Input Endian</string>
  414 + </property>
  415 + </widget>
  416 + <widget class="QComboBox" name="cmbEndian">
  417 + <property name="enabled">
  418 + <bool>false</bool>
  419 + </property>
  420 + <property name="geometry">
  421 + <rect>
  422 + <x>10</x>
  423 + <y>60</y>
  424 + <width>81</width>
  425 + <height>22</height>
  426 + </rect>
  427 + </property>
  428 + </widget>
  429 + <widget class="QCheckBox" name="chkNormalized">
  430 + <property name="geometry">
  431 + <rect>
  432 + <x>260</x>
  433 + <y>260</y>
  434 + <width>81</width>
  435 + <height>17</height>
  436 + </rect>
  437 + </property>
  438 + <property name="text">
  439 + <string>Normalized</string>
  440 + </property>
  441 + </widget>
  442 + </widget>
  443 + <tabstops>
  444 + <tabstop>btnLoadFile</tabstop>
  445 + <tabstop>spinHeaderSize</tabstop>
  446 + <tabstop>cmbDataType</tabstop>
  447 + <tabstop>spinNumComponents</tabstop>
  448 + <tabstop>spinDataSizeX</tabstop>
  449 + <tabstop>spinDataSizeY</tabstop>
  450 + <tabstop>spinDataSizeZ</tabstop>
  451 + <tabstop>okButton</tabstop>
  452 + <tabstop>cancelButton</tabstop>
  453 + <tabstop>txtFilename</tabstop>
  454 + </tabstops>
  455 + <resources/>
  456 + <connections>
  457 + <connection>
  458 + <sender>okButton</sender>
  459 + <signal>clicked()</signal>
  460 + <receiver>LoadRawDialogClass</receiver>
  461 + <slot>accept()</slot>
  462 + <hints>
  463 + <hint type="sourcelabel">
  464 + <x>288</x>
  465</