7 #ifndef QSMARTGRAPHICSVIEW_H
8 #define QSMARTGRAPHICSVIEW_H
10 #include <QApplication>
13 #include <QGraphicsItem>
14 #include <QGraphicsPixmapItem>
15 #include <QGraphicsView>
18 #include <QPushButton>
19 #include <QWheelEvent>
20 #include <QMessageBox>
26 #include "opencv2/opencv.hpp"
34 #include <QButtonGroup>
35 #include <QGraphicsOpacityEffect>
36 #include <QPropertyAnimation>
37 #include <QStyleOption>
42 class customQGraphicsItem;
52 void initialize(
const int _img_num,
const int width,
const int height,
int changeRow = 4);
55 void setImage(
const cv::Mat &img);
56 void setImage(
const std::vector<cv::Mat> &imgs);
81 void on_saveAction_triggered();
82 void on_copyToClipboardAction_triggered();
84 void on_normal_triggered();
85 void on_selectRegion_triggered();
86 void on_hideSideBar_triggered();
87 void on_copySelectedRegionAction_triggered();
88 void onAnimationFinished();
91 QAction *hideSideBar, *saveAction, *copyToClipBoardAction, *copySelectedRegion;
92 QClipboard *clipboard;
93 QGraphicsScene *scene;
94 QVector<QGraphicsPixmapItem*> pix_item_vec;
100 bool _initial =
false;
105 int mouse_status = 0;
106 QPointF select_start, select_item_bound, select_item_start;
107 bool is_item =
false;
108 QRubberBand *rubberBand = 0;
111 QGraphicsOpacityEffect* mEffect;
128 this->setStyleSheet(
"QSideButtonBar{border: 2px solid grey;}");
131 this->setStyleSheet(
"QSideButtonBar{border: 2px solid grey;}");
132 btn.resize(button_num);
133 for(
int i = 0; i <
btn.size(); i++)
135 btn[i].btn =
new QPushButton(
this);
136 btn[i].btn->setCheckable(
true);
137 btn[i].btn->setGeometry(0, i * 31 + 0, 30, 30);
150 newb.
btn =
new QPushButton(
this);
156 if(btn_num >= 0 && btn_num <
btn.size())
157 btn[btn_num].
btn->setText(text);
162 if(btn_num >= 0 && btn_num <
btn.size())
163 btn[btn_num].ID = ID;
169 for(i = 0; i <
btn.size(); i++)
171 if(!
btn[i].ID.compare(name))
181 for(i = 0; i <
btn.size(); i++)
183 if(!
btn[i].ID.compare(name))
193 for(i = 0; i <
btn.size(); i++)
195 if(!
btn[i].ID.compare(name))
197 btn[i].btn->setIcon(icon);
208 for(i = 0; i <
btn.size(); i++)
210 if(!
btn[i].ID.compare(name))
212 btn[i].btn->setCheckable(c);
222 void paintEvent(QPaintEvent *)
227 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p,
this);
233 #endif // SMARTGRAPHICSVIEW_H
void sendMousePress()
Sends signal if the mouse is pressed.
void mouseReleaseEvent(QMouseEvent *event)
void keyPressEvent(QKeyEvent *event)
void mouseDoubleClickEvent(QMouseEvent *event)
void sendSelectedRegion(const QImage &img)
Send selected region selected by the rubberBand.
void setImagefromQImage(const QImage &qimg)
Set a single image (QImage) to QSmartGraphicsView.
void sendItemMouXY(const double x, const double y)
Sends the mouse coordinate of the image when clicked the image.
void mousePressEvent(QMouseEvent *event)
void initialize(const int _img_num, const int width, const int height, int changeRow=4)
Must initial before setting any image to QSmartGraphicsView.
int getImgNum()
Returns the number of images set in QSmartGraphicsView.
void mouseMoveEvent(QMouseEvent *event)
void wheelEvent(QWheelEvent *event)
bool isInitial() const
Returns true if initialized before.
QSmartGraphicsView(QWidget *parent=0)