You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
2.9 KiB
C
108 lines
2.9 KiB
C
|
5 years ago
|
#ifndef ROISCENE
|
||
|
|
#define ROISCENE
|
||
|
|
|
||
|
|
#include <QGraphicsScene>
|
||
|
|
#include "DrawTool.h"
|
||
|
|
#include "RoiItem.h"
|
||
|
|
#include "lpbengine.h"
|
||
|
|
#include "lpdesigner.h"
|
||
|
|
#include <QtWidgets>
|
||
|
|
#include <QMap>
|
||
|
|
QT_BEGIN_NAMESPACE
|
||
|
|
class QGraphicsSceneMouseEvent;
|
||
|
|
class QMenu;
|
||
|
|
class QPointF;
|
||
|
|
class QGraphicsLineItem;
|
||
|
|
class QFont;
|
||
|
|
class QGraphicsTextItem;
|
||
|
|
class QColor;
|
||
|
|
QT_END_NAMESPACE
|
||
|
|
|
||
|
|
enum DirType
|
||
|
|
{
|
||
|
|
UP = 0,
|
||
|
|
DOWN,
|
||
|
|
LEFT,
|
||
|
|
RIGHT,
|
||
|
|
};
|
||
|
|
typedef enum {
|
||
|
|
ENUM_DELROI = 0,
|
||
|
|
ENUM_LOCKROI,
|
||
|
|
ENUM_UNLOCKROI,
|
||
|
|
ENUM_BINDROI,
|
||
|
|
ENUM_UNBINDROI,
|
||
|
|
ENUM_RELEASEBIN,
|
||
|
|
ENUM_DEFAULT
|
||
|
|
}enumMemuModel;
|
||
|
|
typedef struct tagROIParas{
|
||
|
|
QRectF rectf;
|
||
|
|
enumMemuModel _model{ENUM_UNLOCKROI};
|
||
|
|
}ROIParas;
|
||
|
|
class GraphicsItem;
|
||
|
|
class RoiScene : public QGraphicsScene
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
public:
|
||
|
|
explicit RoiScene(QObject *parent = 0);
|
||
|
|
~RoiScene();
|
||
|
|
int getGraphItems() const{ return m_graphItemMapStruct.size(); };
|
||
|
|
void mouseEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||
|
|
|
||
|
|
bool Initialize(LP_DETECTOR_ROI_DATA roiData);
|
||
|
|
bool CheckRecord(Item_List &record, int maxwidth, int maxheight);
|
||
|
|
bool InitRecord(Item_List record, int nIndex);
|
||
|
|
void InitShowImage(cv::Mat img);
|
||
|
|
void DisableMenu(bool bRet) { m_bDisableMenu = bRet; }
|
||
|
|
void MoveSelectedItem(DirType type,int step = 1);
|
||
|
|
void SetSelectedItem(QPoint pos, QRect size);
|
||
|
|
void SetGraphicsView(QGraphicsView* ipGV){ mpGraphicsView = ipGV; }
|
||
|
|
void SetInfoLable(QLabel* ipLable){ mpInfoLabel = ipLable; }
|
||
|
|
QPointF GetOffSet(){ return mImgPosOffSet; }
|
||
|
|
void zoomImage(bool bZoomIn);
|
||
|
|
void scaleImageWithFixedViewSize();
|
||
|
|
bool InImgRectangel(GraphicsItem *pItem);
|
||
|
|
QPointF getCenterPoint(){ return centerPoint; };
|
||
|
|
QPointF getStartPoint(){ return startPoint; };
|
||
|
|
void updateLineItem();
|
||
|
|
void updateTenItem(bool bFlag);
|
||
|
|
int flag{ 0 };
|
||
|
|
bool bUseTenFlag{ false };
|
||
|
|
signals:
|
||
|
|
void sgResetItem(QPoint pos, QRect size);
|
||
|
|
protected:
|
||
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||
|
|
void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent);
|
||
|
|
void keyPressEvent(QKeyEvent *event);
|
||
|
|
|
||
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
|
||
|
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
||
|
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||
|
|
void scaleImg(qreal scale);
|
||
|
|
void updateInfoLable();
|
||
|
|
QRectF maptoImgNewPos(GraphicsItem *pItem);
|
||
|
|
QPoint maptoImgPos(QPointF& iscenePos);
|
||
|
|
protected:
|
||
|
|
QPoint m_tCurrentPos;
|
||
|
|
QGraphicsPixmapItem* m_pImageItem{ nullptr };
|
||
|
|
bool m_bDisableMenu;
|
||
|
|
QGraphicsView* mpGraphicsView{ nullptr };
|
||
|
|
QLabel* mpInfoLabel{ nullptr };
|
||
|
|
QSize mImgOriSize;
|
||
|
|
QPointF mImgPosOffSet;
|
||
|
|
QImage* mpShowImage{ nullptr };
|
||
|
|
QPointF centerPoint;
|
||
|
|
QPointF startPoint;
|
||
|
|
qreal mFixedSizeScale{ 1.0 };
|
||
|
|
QMap<GraphicsItem*, tagROIParas> m_graphItemMapStruct;
|
||
|
|
QGraphicsLineItem *pLineItem{ nullptr };
|
||
|
|
|
||
|
|
QGraphicsLineItem *pTenLineITemH{ nullptr };
|
||
|
|
QGraphicsLineItem *pTenLineITemV{ nullptr };
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif // ROISCENE
|
||
|
|
|