00001 #ifndef MAIN_H
00002 #define MAIN_H
00003
00004
00005
00006 #include "Arguments.h"
00007 #include <string>
00008 #include "Volume.h"
00009 #include <il.h>
00010
00011 #include "BasicObjects.h"
00012 #include "GlewContentManagement.h"
00013
00014 class GLUI_Listbox;
00015 class GLUI_Scrollbar;
00016 class GLUI_Spinner;
00017 class GLUI_StaticText;
00018 class GLUI_RadioGroup;
00019 class GLUI_Rotation;
00020
00021 class Shader;
00022
00023 class HistogramDraw;
00024
00025
00026 using namespace std;
00027
00028
00029
00030 int initialization( int argc, char ** argv);
00031 void initGlutMainWindow( int argc, char ** argv );
00032 int initDevil();
00033 void initGLUIMaster();
00034 void initRightWindow();
00035
00036 void initGlutSubWindowRendering();
00037 void initGlutSubWindowBottom();
00038 void initGlutSubWindowRight();
00039
00040 void initInterfaceBottomValues();
00041
00042 bool initShaders();
00043
00044 void initBottomWindow();
00045 void initRenderWindow();
00046
00047 void enterMainLoop();
00048
00049 void processSliceOfData(std::string strDataFile );
00050
00051 void positionRenderWindow(int width, int height);
00052 void positionRightWindow(int width, int height);
00053 void positionBottomWindow(int width, int height);
00054
00055 void reshapeRenderWindow(int width, int height);
00056 void reshapeRightWindow(int width, int height);
00057 void reshapeBottomWindow(int width, int height);
00058
00059 void saveSliceTo2DTexture();
00060 void saveDataTo3DTexture();
00061
00062 void gluiMasterSpecial(int a, int b, int c);
00063 void glutKeyboard(unsigned char key, int x, int y);
00064 void mainWindowMouseCallback(int button, int state, int x, int y);
00065 void mouseWheelFuncRenderWindow(int, int, int, int);
00066
00067 void mouseMotionRenderWindow(int x, int y);
00068 void mouseMotionBottomWindow(int x, int y);
00069
00070 void reshapeFuncBottomWindow(int width, int height);
00071 void reshapeFuncRenderWindow(int width, int height);
00072 void reshapeFuncRightWindow(int width, int height);
00073
00074 void orthogonalStart(int width, int height);
00075 void orthogonalEnd();
00076
00077 void handleMouseActionBottomWindow(int button, int state, int x, int y);
00078 void glutBottomWindowKeyboard(unsigned char key, int x, int y);
00079
00080 void drawTransferTexture(int windowWidth, int windowHeight, float xOffset, float yOffset);
00081 void drawControlPoints(int windowWidth, int windowHeight, int xOffset, int yOffset);
00082 void drawColourPicker(int windowWidth, int windowHeight, int xOffset, int yOffset);
00083 void drawColourPickerCursor(int windowWidth, int windowHeight, int xOffset, int yOffset);
00084 void drawHistogram(int windowWidth, int windowHeight, int xOffset, int yOffset);
00085
00086 void initInterfaceBottom();
00087
00088 void initInterfaceRight();
00089
00090 void handleColourSpaceListboxChange(int id);
00091 void openFile(int);
00092
00093 void updateRenderWindow(int);
00094 void updateBottomWindow(int);
00095 void renderBottomWindow();
00096 void renderRightWindow();
00097 void renderRenderWindow();
00098
00099 void initTransferFunctionBackgroundTexture();
00100 void deinitTransferFunctionBackgroundTexture();
00101
00102 void drawTransferFuncPickerBackground(int windowWidth, int windowHeight, int xOffset, int yOffset);
00103 void drawTransferFuncPickerForeground( int xOffset, int yOffset );
00104 void drawTransferFuncPicker(int windowWidth, int windowHeight, int transferFuncXOffset, int transferFuncYOffset);
00105
00106 bool checkForColourPickerAction(int button, int state, int x, int y);
00107
00108 void handleColourPickerSliderModeChange(int id);
00109 void handleColourPickerSliderChange(int id);
00110 void handleHistoGramDrawTypeListboxChange(int id);
00111
00112 void mouseActionBottomWindow(int button, int state, int x, int y);
00113 void mouseActionRenderWindow(int button, int state, int x, int y);
00114
00115 void updateGUIColourWithColourPickerValue();
00116
00117 void refreshColourMapCornerPositions();
00118
00119 void updateColourPickerCursorMovement( int x, int y );
00120
00121 void updateColourPickerCursorPosBasedOnMouseCoordinates( int x, int y );
00122
00123 void transformCoordinatesToTransferFunctionPickerSpace(int &transferFuncSpaceX, int &transferFuncSpaceY);
00124
00125 void updateGUIColourWithSelectedControlPointColour();
00126 void updateSelectedControlPointColourWithGUIColour();
00127 void updateColourPickerCursorPosBasedOnSelectedColour();
00128
00129 void refreshBottomWindowData();
00130
00131 void handleGUIColourLabLChange(int);
00132 void handleGUIColourLabAChange(int);
00133 void handleGUIColourLabBChange(int);
00134
00135 void handleGUIColourLabChange(int);
00136 void handleGUIColourRgbChange(int);
00137 void handleGUISpecifiedColourChange(int);
00138
00139 void handleSaveTransferFunctionControlPoints(int);
00140 void handleLoadTransferFunctionControlPoints(int);
00141
00142 void postRedisplayBottomWindow();
00143
00144 void prepareRenderWindowRendering();
00145
00146 void updateColourPickerSliderWithSetGUIColourComponent();
00147
00148 void drawBoundingBox();
00149
00150 void drawBox(float cubeWidth, float cubeHeight, float cubeDepth);
00151 void drawCenterCross();
00152 void drawVolume(float cubeWidth, float cubeHeight, float cubeDepth);
00153
00154 void startShading();
00155 void stopShading();
00156
00157 void renderToFullscreenQuad();
00158
00159 void initFBOs();
00160 void refreshFBOs();
00161 void refreshFBOTextureSizes();
00162
00163 void startRenderViewPerspective();
00164 void startFBOPerspective();
00165
00166 void refreshShaderData();
00167
00168
00169 void refreshColourPickerAfterSliderChange();
00170
00171 void startRatioFixScale();
00172 void endRatioFixScale();
00173
00174 void updateViewRotationWithDragPosition(int x, int y);
00175
00176
00177 int g_iMainWindowWidth = 1280, g_iMainWindowHeight = 720;
00178 int g_iRenderWindowWidth = 0, g_iRenderWindowHeight = 0;
00179 int g_rightWindowWidth = 180, g_bottomWindowHeight = 220;
00180 Arguments g_argArguments;
00181 Volume g_Volume;
00182 unsigned int g_uExampleTexture = 0;
00183
00184 float g_fCoordXYZ = 0.5f;
00185 float g_fIncrement = 0.f;
00186 int g_iSampleRate;
00187 float rotMat[16] = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0};
00188 float *g_pRotate = rotMat;
00189 float g_fRatio_rw = 0.f;
00190 float g_fRatio_xy = 0.f;
00191 float g_fRatio_xz = 0.f;
00192 float g_fRatio_yz = 0.f;
00193
00194 int g_iSliceDir = 0;
00195 int g_iPerspectiveType = 0;
00196 int g_iCombinationType = 0;
00197
00198 HWND g_hMainWindow;
00199 int g_mainWindowID = 0;
00200 int g_renderWindowID = 0;
00201 int g_bottomWindowID = 0;
00202 int g_rightWindowID = 0;
00203
00204 GLUI_Listbox* colourSpaceListbox;
00205 GLUI_Scrollbar* g_pGLUI_SliderSlice;
00206 GLUI_Scrollbar* g_pGLUI_SliderSampleRate;
00207 GLUI_Spinner* g_pGLUI_SpinnerSampleRate;
00208 GLUI_Scrollbar* g_pColourPickerSlider;
00209 GLUI_StaticText* g_pColourPickerSliderText;
00210
00211 int g_iTransferFunctionPickerXOffset = 5;
00212 int g_iTransferFunctionPickerYOffset = 28;
00213
00214 GLuint transferFunctionBackgroundTexture;
00215 ILuint transferFunctionBackgroundImage;
00216
00217 int g_iTransferFunctionBackgroundTextureWidth;
00218 int g_iTransferFunctionBackgroundTextureHeight;
00219
00220 GLUI_RadioGroup* LabSwitcherForColourPicker;
00221
00222 int g_iColourPicker_xBegin, g_iColourPicker_xEnd, g_iColourPicker_yBegin, g_iColourPicker_yEnd;
00223
00224 float g_ColorPickerCursorXPos = 0.f;
00225 float g_ColorPickerCursorYPos = 0.f;
00226
00227 bool g_bDraggingColourPickerCursor = false;
00228
00229 GLUI_Spinner* g_ColourSpinnerRgbR, * g_ColourSpinnerRgbG, * g_ColourSpinnerRgbB;
00230 int g_iColourRgbR, g_iColourRgbG, g_iColourRgbB;
00231
00232 GLUI_Spinner* g_ColourSpinnerLabL, * g_ColourSpinnerLabA, * g_ColourSpinnerLabB;
00233 float g_fColourLabL, g_fColourLabA, g_fColourLabB;
00234
00235 GLUI_Spinner* g_ColourTransparencySpinner;
00236 int g_iColourAlpha;
00237
00238 HistogramDraw* g_HistogramDraw;
00239
00240 GLUI_Listbox* g_histogramDrawTypeListbox;
00241
00242 static const unsigned int simpleShaderID = 0;
00243
00244 GLuint g_uBackBufferTexture = 0;
00245 GLuint g_uFrontBufferTexture = 0;
00246
00247 float zoom = 0.0;
00248
00249 GLUI_Rotation *g_viewRotationGLUI = 0;
00250
00251 float g_fCubeDimensionNormedX, g_fCubeDimensionNormedY, g_fCubeDimensionNormedZ;
00252
00253 GLuint g_uBackBufferFBO;
00254 GLuint g_uFrontBufferFBO;
00255
00256 Shader* shader;
00257
00258 GLint front2DTexLoc;
00259 GLint back2DTexLoc;
00260 GLint data3DTexLoc;
00261 GLint transferTexLoc;
00262
00263 GLint slicesLoc;
00264 GLint combTypeLoc;
00265 GLint sampleRateLoc;
00266 GLint sliceDepthLoc;
00267
00268 int viewRotationDragStartX = 0;
00269 int viewRotationDragStartY = 0;
00270 bool viewRotationDragging = false;
00271
00272
00273
00274 #endif