00001 #ifndef HISTOGRAMDLG_H 00002 #define HISTOGRAMDLG_H 00003 00004 // QT 00005 #include <qwidget.h> 00006 #include <qcolor.h> 00007 #include <qmenubar.h> 00008 #include <qaction.h> 00009 #include <qpainter.h> 00010 #include <qpixmap.h> 00011 #include <qpointarray.h> 00012 #include <qcursor.h> 00013 #include <qapplication.h> 00014 00015 // STDLIB 00016 #include <vector> 00017 #include <stack> 00018 #include <cstdio> 00019 00020 // LOCAL 00021 #include "histogramdatasource.h" 00022 #include "histogramuser.h" 00023 00024 00036 class HistogramDataSource; 00037 00042 typedef struct { 00043 int scaleW; 00044 int graphBorderW; 00045 int topY; 00046 int winW; 00047 int winH; 00048 int graphW; 00049 int graphH; 00050 int graphZeroX; 00051 int graphMaxX; 00052 int graphZeroY; 00053 int graphMaxY; 00054 } DspDims; 00055 00059 typedef struct { 00060 int mPointMoving; 00061 bool mLeftDown; 00062 bool mMidDown; 00063 bool mRightDown; 00064 int mMouseX; 00065 int mMouseY; 00066 } MouseState; 00067 00068 00073 typedef struct { 00074 vector<HistogramDataSource*> HDS; 00075 vector<QAction*> actSet; 00076 int curHDS; 00077 HistogramSet histSet; 00078 int curHist; 00079 QPointArray dataPnts[3]; 00080 } HDSSet; 00081 00085 typedef struct { 00086 stack<QPointArray> lineSet[3]; 00087 stack<QPointArray> redoSet; 00088 int curLine; 00089 QPointArray *curArr; 00090 bool isChanging; 00091 bool isMerged; 00092 } StretchLineSet; 00093 00102 class HistogramDlg : public QWidget { 00103 Q_OBJECT 00104 public: 00105 00106 protected: 00107 QMenuBar *mMenuBar; 00108 00109 MouseState mMouse; 00110 StretchLineSet mSLSet; 00111 HDSSet mHDS; 00112 00113 HistogramUser *mHistUser; 00114 00115 vector<QAction*> mPercentAct; 00116 QAction *mMergeAct; 00117 QActionGroup *mDSActGroup; 00118 QPopupMenu *mDSMenu; 00119 vector<QAction*> mColorAct; 00120 00121 DspDims mDspDims; 00122 DspDims mOldDspDims; 00123 00124 DspDims calcDspDims( ); 00125 00126 void init( ); 00127 void buildMenuBar( ); 00128 bool mouseInGraph( ); 00129 int mouseOnPoint( ); 00130 void createDataPnts( ); 00131 void alertUser( ); 00132 void initPntsFromUser( ); 00133 00134 public: 00135 HistogramDlg( QWidget *parent ); 00136 HistogramDlg( QWidget *parent, 00137 vector<HistogramDataSource*> hds, 00138 HistogramUser *huser=NULL ); 00139 00140 void mousePressEvent( QMouseEvent * ); 00141 void mouseReleaseEvent( QMouseEvent * ); 00142 void mouseMoveEvent( QMouseEvent * ); 00143 void mouseDoubleClickEvent( QMouseEvent * ); 00144 void paintEvent( QPaintEvent *pe ); 00145 void resizeEvent( QResizeEvent *re ); 00146 00147 void addHDS( HistogramDataSource *hds ); 00148 void setHDS( vector<HistogramDataSource*> hds ); 00149 void setUser( HistogramUser *user ); 00150 00151 public slots: 00152 void changeToRed( ); 00153 void changeToBlue( ); 00154 void changeToGreen( ); 00155 void changeToAll( ); 00156 void changeDataSource( ); 00157 void bestFit( ); 00158 void mergeAll( ); 00159 void clearPoints( ); 00160 void undoToLast( ); 00161 void redoToPrev( ); 00162 void reloadHistSet( ); 00163 void calcPercent( ); 00164 }; 00165 00166 #endif 00167 00168 00169
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |