#ifndef WIDGET_H #define WIDGET_H #include #include //#include "colorlinesetdef.h" namespace Ui { class Widget; } // //enum COLOR_TPYE //{ // RGB, // GRAY, // RED, // BLUE, // GREEN //}; class Widget : public QWidget { Q_OBJECT public: explicit Widget(QWidget *parent = nullptr); ~Widget(); void initAllLstPnt(); //初始化所有颜色曲线 void setLstPnt_RGB(const QList& plst); //设置生成RGB曲线的关键点(<=4) QList getLstPnt_RGB()const; //获取生成RGB曲线的关键点 void setLstPnt_RED(const QList& plst); QList getLstPnt_RED()const; void setLstPnt_BLUE(const QList& plst); QList getLstPnt_BLUE()const; void setLstPnt_GREEN(const QList& plst); QList getLstPnt_GREEN()const; void setLstPnt_GRAY(const QList& plst); QList getLstPnt_GRAY()const; QVector getRgbALLPoint(); QList getRgbKeyPoint()const; void setRgbKeyPoint(const QList& pVec); QVector getRedALLPoint(); QList getRedKeyPoint()const; void setRedKeyPoint(const QList& pVec); QVector getBlueALLPoint(); QList getBlueKeyPoint()const; void setBlueKeyPoint(const QList& pVec); QVector getGreenALLPoint(); QList getGreenKeyPoint()const; void setGreenKeyPoint(const QList& pVec); QVector getGrayALLPoint(); QList getGrayKeyPoint()const; void setGrayKeyPoint(const QList& pVec); void setHist_RGB(const QVector& hist);//设置RGB的背景直方图 QVector getHist_RGB()const;//获取RGB的背景直方图 void setHist_RED(const QVector& hist); QVector getHist_RED()const; void setHist_BLUE(const QVector& hist); QVector getHist_BLUE()const; void setHist_GREEN(const QVector& hist); QVector getHist_GREEN()const; void setHist_GRAY(const QVector& hist); QVector getHist_GRAY()const; void getCurLineLUT(uchar* table, size_t length = 256);//获取当前曲线上的所有点并存入table QVector getCurLinePntVec();//获取当前曲线上的所有点 void setXCoorVal(const int &xVal);//设置被选中的点的X坐标 void setYCoorVal(const int &yVal);//设置被选中的点的Y坐标 void updateCurLinePnt(const int& colType);//根据当前所选颜色(colType)重绘界面 void initSelectColLine(const int& colType);//初始化当前所选颜色(colType)界面的曲线 void SetAllLinePnt(QVector& all);//设置自定义曲线的所有点 signals: void dragPointChecked(bool);//曲线上的点被选中的信号 void mouseLeaveSig();//鼠标离开控件的信号 void mouseCoordSig(QPoint pos);//鼠标的坐标信号 void lineChangeSig(); private: void initInterface();//初始化界面 void paintEvent(QPaintEvent *); void mousePressEvent(QMouseEvent*); void mouseMoveEvent(QMouseEvent*); void mouseReleaseEvent(QMouseEvent*); void enterEvent(QEvent*); void leaveEvent(QEvent*); void drawCoordinate(QPainter&);//画直角坐标 void drawBackgroudColor(QPainter&,QVector&);//画背景直方图 void drawBackColorBySlc(QPainter&);//画不同的背景直方图 void drawCoorScale(QPainter&);//画虚线刻度 void drawLineFromPoint(QList &plst, const int &col);//根据多点求出曲线方程,并画出曲线 void drawAllPoint(QPainter&);//画出生成曲线的关键点 void drawCurveByColor(QPainter&);//画不同的颜色曲线 void drawLineByVector(QPainter&,QVector&);//将数组的所有点连接绘制曲线 int caculateAllMi(int num,int n);//计算num的n次方的值 private: Ui::Widget *ui; QVector rgbBackColor; QVector redBackColor; QVector blueBackColor; QVector greenBackColor; QVector grayBackColor; QVector rgbALLPoint; QVector redALLPoint; QVector blueALLPoint; QVector greenALLPoint; QVector grayALLPoint; QVector allLinePntSet; QVector linePoints; //QList points; QList pointLst; QList linePoint; QList greenLine; QList redLine; QList blueLine; QList rgbLine; QList grayLine; QColor color; unsigned char allLinePoints[256]; bool leftMouseMv; bool newPoint; bool clickLine; int dragPoint; int selectCol; }; #endif // WIDGET_H