123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- /*
- * ImageHolder.h
- *
- * Created on: Oct 5, 2011
- * Author: Gapchich Vladislav
- */
- #ifndef __IMAGEHOLDER_H__
- #define __IMAGEHOLDER_H__
- #include <QLabel>
- struct BoundingBox {
- QRect rect;
- int label_ID_;
- };
- struct Polygon {
- QPolygon poly;
- int label_ID_;
- };
- enum ZoomDirection {
- NoZoom,
- ZoomIn,
- ZoomOut
- };
- class QListWidgetItem;
- class QPixmap;
- class ImageHolder : public QLabel
- {
- Q_OBJECT
- protected:
- void keyPressEvent(QKeyEvent *anEvent);
- void mouseMoveEvent(QMouseEvent *anEvent);
- void mousePressEvent(QMouseEvent *anEvent);
- void mouseReleaseEvent(QMouseEvent *anEvent);
- void paintEvent (QPaintEvent *anEvent);
- void triggerBoundBox(
- const QPoint &aNewPos,
- const QPoint &anOldPos,
- QRect *aNewBox
- );
- void triggerPolygon(
- const QPoint &aPoint,
- QPolygon *aNewPoly
- );
- void drawBoundingBoxes(
- QPainter *aPainter,
- QPen *aPen
- );
- void drawPolygons(
- QPainter *aPainter,
- QPen *aPen
- );
- public:
- enum Tool {
- NoTool,
- BoundingBoxTool,
- PolygonTool,
- TaggingTool
- };
- enum State {
- StandBy,
- NewSelection
- };
- ImageHolder(QWidget *aParent = 0);
- virtual ~ImageHolder();
- void setTool(Tool aTool);
- void setBoundingBoxList(QList< BoundingBox > *aBBoxList);
- void setPolygonList(QList< Polygon > *aPolyList);
- void setLabelColorList(QList< uint > *aLabelColorList);
- void setMainLabelNum(int *aNum);
- void setImage(QPixmap *anImage);
- void scaleImage(ZoomDirection aDirection, double scaleFactor);
- State state();
- Tool tool();
- public slots:
- void clearAll();
- void clearLast();
- void confirmSelection();
- void focusOnArea(QListWidgetItem *anItem);
- void clearFocusOnArea();
- void undo();
- void redo();
- signals:
- void selectionStarted();
- void imageScaled();
- private:
- bool repaint_needed_;
- QList< BoundingBox > *list_bounding_box_;
- QList< Polygon > *list_polygon_;
- QList< uint > *list_label_color_;
- QList< QPoint > list_poly_history_;
- QPixmap *image_;
- int *main_label_;
- BoundingBox bounding_box_;
- Polygon polygon_;
- int keyboard_modifier_;
- QPoint prev_cursor_pos_;
- Tool tool_;
- State state_;
- int focused_selection_;
- Tool focused_selection_type_;
- double scale_;
- };
- #endif /* IMAGEHOLDER_H_ */
- /*
- *
- */
|