00001 #pragma once 00002 00003 #ifndef HIST_TRANSFER 00004 #define HIST_TRANSFER 00005 00006 #include <QtCore/QMap> 00007 #include <QtGui/QPixmap> 00008 #include <QtCore/QVector> 00009 #include <QtGui/QWidget> 00010 #include <QtGui/QPainter> 00011 #include <QtGui/QStylePainter> 00012 #include <QtGui/QMouseEvent> 00013 #include <QtGui/QKeyEvent> 00014 #include <QtCore/QDataStream> 00015 #include <vector> 00016 00017 using namespace std; 00018 00022 struct MappingData { 00023 float color[3]; 00024 float alpha; 00025 unsigned int position[2]; 00026 bool activated; 00027 int label; 00028 }; 00029 00033 class Hist_Transfer : public QWidget 00034 { 00035 00036 Q_OBJECT 00037 00038 public: 00039 00043 Hist_Transfer(QWidget* parent = 0); 00044 ~Hist_Transfer(void); 00045 00049 void setKnotColor (int label, QColor color); 00050 00054 void setHistogram (); 00055 00059 void setScanData (unsigned short* scanData, unsigned int size); 00060 00064 void updateHist (unsigned int x, unsigned int y); 00065 00069 float* getTexture (); 00070 00074 unsigned int getClassCt (); 00075 00079 void printFunction (QDataStream& fileHandle); 00080 00084 void loadFunction (QDataStream& fileHandle); 00085 00086 protected: 00087 void paintEvent(QPaintEvent * evt); 00088 void resizeEvent(QResizeEvent *evt); 00089 void mousePressEvent(QMouseEvent *evt); 00090 void mouseMoveEvent(QMouseEvent *evt); 00091 void mouseReleaseEvent(QMouseEvent *evt); 00092 void keyPressEvent(QKeyEvent *evt); 00093 00094 void paint(); 00095 00096 private: 00097 00098 void drawCoordinates(QPainter* p); 00099 void drawHist(QPainter* p); 00100 void drawTFunc(QPainter* p); 00101 00102 void remove (unsigned int x, unsigned int y); 00103 00104 static const unsigned short borderSize = 10; 00105 00106 unsigned int touchRadiusClassSpace; 00107 unsigned int actLabel; 00108 unsigned short classCount; 00109 bool mousePress; 00110 QPixmap pixmap; 00111 vector<MappingData> mapArray; 00112 unsigned int* histogram; 00113 unsigned short* scanData; 00114 unsigned int dimensionSizes; 00115 unsigned short scanMaxVal; 00116 unsigned int histMaxVal; 00117 unsigned int actKnotChosen; 00118 bool existsChosen; 00119 bool loaded; 00120 float* colorTexture; 00121 QColor lastColor; 00122 00123 signals: 00124 00125 void choose (int label, QColor color); 00126 void valueChange (); 00127 }; 00128 00129 #endif