00001 #ifndef _HISTOGRAM_
00002 #define _HISTOGRAM_
00003
00004 #include <glui.h>
00005 #include <vector>
00006
00007 #include "LifeVariables.h"
00008
00009 #include "GuiComponent.h"
00010 #include "TxFunction.h"
00011
00012
00014 #define HISTOGRAM_VALUE_RANGE 4096
00015 #define HISTOGRAM_VALUE_RANGE_FLOAT HISTOGRAM_VALUE_RANGE.0f
00016
00018 #define HISTOGRAM_VGRID_SIZE 256
00019
00020
00021
00022 using namespace std;
00023
00026 static unsigned int occurrenceArray[HISTOGRAM_VALUE_RANGE];
00027
00028
00033 class Histogram: public GuiComponent {
00034 private:
00036 bool initialised;
00037
00041 void addTxPoint();
00042
00045 void deleteTxPoint();
00046
00048 TxFunction *txFunction;
00049
00050 float oneAlphaPercent;
00051
00052 public:
00053
00054
00055
00057 OrthographicCamera *camera;
00058
00060 TxPoint *grabbedPoint;
00061
00063
00064
00067 Histogram();
00068
00071 ~Histogram() {
00072 delete txFunction;
00073 delete grabbedPoint;
00074 };
00075
00083 void update(unsigned short *data, unsigned int &size);
00084
00085
00095 void render(int x, int y, int width, int height);
00096
00097
00109 void onLeftMouseClick(int x, int y);
00110
00111
00112 bool onRightMouseClick(int x, int y);
00113
00119 void onMouseDrag(int x, int y);
00120
00129 void getColorByDensity(unsigned short &density,
00130 float &red, float &green, float &blue, float &alpha);
00131
00133 bool isInitialised() {
00134 return initialised;
00135 };
00136
00139 bool removeControlPoint();
00140
00141
00142 void getVoxelColorByDensity(float density,
00143 float &red, float &green, float &blue);
00144
00145 void getLevoyVoxelColor(float density,
00146 float &red, float &green, float &blue, float gradient);
00147
00148 void getSolidVoxelColorByDensity(float density,
00149 float &red, float &green, float &blue);
00150
00151 };
00152
00153 #endif