1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* ====================================================================== |
---|
3 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
4 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
5 | * |
---|
6 | * Copyright (c) 2004-2006 Purdue Research Foundation |
---|
7 | * |
---|
8 | * See the file "license.terms" for information on usage and |
---|
9 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
10 | * ====================================================================== |
---|
11 | */ |
---|
12 | #ifndef TRANSFER_FUNCTION_GLUT_WINDOW_H |
---|
13 | #define TRANSFER_FUNCTION_GLUT_WINDOW_H |
---|
14 | |
---|
15 | #include <stdlib.h> |
---|
16 | #include <time.h> |
---|
17 | #include <float.h> |
---|
18 | |
---|
19 | #include "ControlPoint.h" |
---|
20 | |
---|
21 | ////////////////////Interpolation Result///////////////////////////////////////// |
---|
22 | #define NUM_OF_OUTPUT 256 //define |
---|
23 | extern int numOfOutput; //number of interpolations in the output array |
---|
24 | extern float* output; //result array of interpolation of control points |
---|
25 | ///////////////////////////////////////////////////////////////////////////////// |
---|
26 | |
---|
27 | extern int tf_winx, tf_winy; //window size |
---|
28 | extern int tf_unitWidth; //unit width |
---|
29 | extern bool tf_gvIsDragging; //is dragging a control point |
---|
30 | extern ControlPoint *tf_gvSelectedPoint; //selected controlpoint |
---|
31 | extern float tfMaximum; |
---|
32 | extern ControlPoint* tf_pointList; //list of controlpoint |
---|
33 | extern int tf_numOfPoints; //number of controlpoints |
---|
34 | extern int transferFuctionWindow; //global winid |
---|
35 | extern int tf_pointEditState; //pointEditState |
---|
36 | //if ==1, add point |
---|
37 | //if ==2, remove point |
---|
38 | struct Histogram |
---|
39 | { |
---|
40 | Histogram() |
---|
41 | { |
---|
42 | range =256; |
---|
43 | min = FLT_MAX; |
---|
44 | max = FLT_MIN; |
---|
45 | count = (unsigned long*) malloc(sizeof(unsigned long)*(range)); |
---|
46 | |
---|
47 | int i=0; |
---|
48 | for (i=0; i<range; i++){ |
---|
49 | count[i]=0; |
---|
50 | } |
---|
51 | }; |
---|
52 | |
---|
53 | int range; |
---|
54 | unsigned long* count; |
---|
55 | float min; |
---|
56 | float max; |
---|
57 | }; |
---|
58 | |
---|
59 | extern Histogram Hist[4]; //s, p, d, ss histograms |
---|
60 | |
---|
61 | class TransferFunctionGLUTWindow |
---|
62 | { |
---|
63 | public: |
---|
64 | TransferFunctionGLUTWindow(); |
---|
65 | virtual ~TransferFunctionGLUTWindow(); |
---|
66 | |
---|
67 | void static tfInit(int main_window_x, int main_window_y); |
---|
68 | void static WriteControlPoints(); |
---|
69 | void static ReadControlPoints(); |
---|
70 | |
---|
71 | void static tfReshape(int x, int y); |
---|
72 | void static tfKeyboard(unsigned char key, int x, int y); |
---|
73 | void static tfIdle(); |
---|
74 | void static tfMouse(int button, int state, int x, int y); |
---|
75 | void static tfMotion(int x, int y); |
---|
76 | void static tfDisplay(); |
---|
77 | |
---|
78 | bool static SelectPoint(double x, double y); |
---|
79 | |
---|
80 | void static sortPoints(); //sort all the points by there x coordinates |
---|
81 | static ControlPoint* addPoint(double x, double y); //add control point |
---|
82 | void static removePoint(void* ptr); //remove control point |
---|
83 | void static scalePointsY(int offset); //scale point X |
---|
84 | void static scalePointsX(); //scale point Y |
---|
85 | static ControlPoint* boundaryChecking(); //point boundary checking |
---|
86 | void static plotHist(); //draw Histogram in transformation window |
---|
87 | static void cleanUpPoints(); //remove all points but the two initial points |
---|
88 | |
---|
89 | void static printPoints(); //debugging: print out all points |
---|
90 | void static printInterpolation(); //debugging: print interpolation |
---|
91 | void static dumpHist(); //dump histogram |
---|
92 | void static readHist(); //read histogram |
---|
93 | void static printHist(); |
---|
94 | |
---|
95 | }; |
---|
96 | |
---|
97 | |
---|
98 | #endif |
---|