123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- #ifndef QHALCONWINDOW_H
- #define QHALCONWINDOW_H
- #include "showunit_global.h"
- #include <QtWidgets/qwidget.h>
- #include <qwidget.h>
- #include "HalconCpp.h"
- #include "HObjectEntry.h"
- #include "GraphicsContext.h"
- #include "ROIController.h"
- #include "ROI.h"
- #include "HWndMessage.h"
- #include <QtWidgets/QLabel>
- #include "ROI.h"
- #include "ROICircle.h"
- #include "ROIRect1.h"
- #include "ROICircularArc.h"
- #include "ROIRect2.h"
- #include "ROILine.h"
- #include "ROIPoint.h"
- #include<QAction>
- #include<QMenu>
- #include <QMutex>
- enum class ShowMode
- {
- IncludeROI = 1,
- ExcludeROI
- };
- enum class ResultShow
- {
- Image,
- AllObject
- };
- using namespace HalconCpp;
- class ROIController;
- class HWndMessage;
- class SHOWUNITSHARED_EXPORT QHalconWindow:public QWidget
- {
- Q_OBJECT
- public:
- QHalconWindow(QWidget *parent = 0);
- virtual ~QHalconWindow(void);
- HTuple getWindowID(void) { return winID; }
- void refresh();
- void addIconicVar(HImage img);
- void addIconicVar(HObject obj);
- void addMessage(HWndMessage message);
- void useROIController(ROIController *rC);
- void resetWindow();
- void clearWindow();
- void changeGraphicSettings(const QString &mode, const HTuple &val);
- void setResultShow(const ResultShow &resultShow);
- void setShowMode(const ShowMode &showMode);
- GraphicsContext mGC;
- void setBackgroundColor(QString color);
- signals:
- void mouseMoveStatus(const QString &message);
- public slots:
- void on_actDispImageOnly();
- void on_actDispFit();
- void on_actSaveImage();
- void on_actDumpWindow();
- void on_actShowCross();
- void on_actDelActiveRoi();
- void on_actDelAllRoi();
- void on_actSetRoiAdd();
- void on_actSetRoiSub();
- void on_actGetDistance();
- void on_actShowImageOnly();
- void on_actCreateCircle();
- void on_actCreateCircleArc();
- void on_actCreateLine();
- void on_actCreateRect1();
- void on_actCreateRect2();
- protected:
- void resizeEvent(QResizeEvent*);
- //鼠标操作
- void mousePressEvent(QMouseEvent *)override;
- void wheelEvent(QWheelEvent *) override;
- void mouseReleaseEvent(QMouseEvent *)override;
- void mouseMoveEvent(QMouseEvent *)override;
- void contextMenuEvent(QContextMenuEvent *) override;
- void enterEvent(QEvent *) override;
- void showEvent(QShowEvent* )override;
- private:
- HTuple winID;
- //HTuple bufferID;
- const int MAX_NUM_OBJ_LIST = 50;
- bool mousePressed = false;
- double startX, startY;
- QString backguoundColor;
- QMenu *popMenu;
- QAction *actDispImageOnly;
- QAction *actDispFit;
- QAction *actShowCross;
- QAction *actSaveImage;
- QAction *actDumpWindow;
- ShowMode showMode;
- int windowWidth;
- int windowHeight;
- int imageWidth;
- int imageHeight;
- double ImgRow1, ImgCol1, ImgRow2, ImgCol2;
- double zoomWndFactor;
- bool showCross = false;
- QList<HObjectEntry> HObjList;
- HImage originalImage;
- HObject showImage;
- ROIController * roiManager=NULL;
- ResultShow resultShow;
- QMutex m_Mutex;
- bool firstEnter;
- // 设定图像的窗口显示部分
- int zoom_beginRow, zoom_beginCol, zoom_endRow, zoom_endCol;
- // 获取图像的当前显示部分
- HTuple current_beginRow, current_beginCol, current_endRow, current_endCol;
- void OpenWindow(void);
- void DispImageZoom(HTuple mode, HTuple Mouse_row, HTuple Mouse_col);
- void InitUserUI();
- void moveImage(double motionX, double motionY);
- };
- #endif // QHALCONWINDOW_H
|