[go: up one dir, main page]

Menu

[332e47]: / src / rectangle.h  Maximize  Restore  History

Download this file

94 lines (74 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/****************************************************************************
** This file is part of the taborca project hosted at
** sf.net/projects/taborca
** Copyright (C) 2013 Shawn Rutledge
** Contact: s@ecloud.org
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called LICENSE; if not, write to the
** Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
****************************************************************************/
#ifndef RECTANGLE_H
#define RECTANGLE_H
#include <QGraphicsRectItem>
/**
\brief A type of PDF annotation: a rectangular region selected
for further processing (for example, OCR).
It can be dragged to size, moved around, selected,
and later resized by dragging the corner handles.
*/
class Rectangle : public QGraphicsRectItem
{
public:
Rectangle(qreal x, qreal y, qreal width, qreal height,
QGraphicsItem * parent = 0);
enum { Type = UserType + 1 };
int type() const { return Type; }
enum ResizeHandleIdx {
RH_NONE,
RH_TOP_LEFT,
RH_TOP_RIGHT,
RH_BOTTOM_RIGHT,
RH_BOTTOM_LEFT };
ResizeHandleIdx handleAt(QPointF pos);
void startResize();
void resize(ResizeHandleIdx hidx, QPointF pos);
void rotate(bool clockwise);
int handleWidth();
double actualWidth();
double actualHeight();
QRectF boundingRect () const;
void resizeDone();
/**
Inform this item that the mouse was clicked at the given position.
Will remember buttonDownPos in its own coord system for later use
while dragging.
*/
void buttonDown(QPointF scenePos);
QPointF buttonDownPos() { return m_buttonDownPos; };
/**
If selected, overlay the resize handle images.
*/
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option,
QWidget * widget = 0 );
protected:
virtual QRectF innerBoundingRect () const;
protected:
/**
Last position given to buttonDown(), mapped to item coord system.
*/
QPointF m_buttonDownPos;
static QPixmap* resizeHandle;
};
#endif // RECTANGLE_H