Engauge Digitizer  2
PdfCropping.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef PDF_CROPPING_H
8 #define PDF_CROPPING_H
9 
10 #include <QRect>
11 #include <QSize>
12 
13 class PdfFrameHandle;
14 class QGraphicsRectItem;
15 class QGraphicsScene;
16 class QPointF;
17 class ViewPreview;
18 
25 {
26 public:
28  PdfCropping(QGraphicsScene &scene,
29  ViewPreview &view);
30 
32  QRectF frameRect () const;
33 
35  void moveBL (const QPointF &newPos,
36  const QPointF &oldPos);
37 
39  void moveBR (const QPointF &newPos,
40  const QPointF &oldPos);
41 
43  void moveTL (const QPointF &newPos,
44  const QPointF &oldPos);
45 
47  void moveTR (const QPointF &newPos,
48  const QPointF &oldPos);
49 
50  static const int PDF_CROPPING_BOTTOM = 1;
51  static const int PDF_CROPPING_LEFT = 2;
52  static const int PDF_CROPPING_RIGHT = 4;
53  static const int PDF_CROPPING_TOP = 8;
54 
56  QSize windowSize () const;
57 
58 private:
59  PdfCropping ();
60 
61  void createWidgets (QGraphicsScene &scene);
62  void disableEventsWhileMovingAutomatically();
63  void enableEventsWhileMovingAutomatically();
64  QRectF rectFromTLAndBR () const;
65  void updateBox();
66 
67  ViewPreview &m_view;
68 
69  // Box
70  QGraphicsRectItem *m_box;
71 
72  // Handles
73  PdfFrameHandle *m_handleTL;
74  PdfFrameHandle *m_handleTR;
75  PdfFrameHandle *m_handleBR;
76  PdfFrameHandle *m_handleBL;
77 
78 };
79 
80 #endif // PDF_CROPPING_H
void moveTL(const QPointF &newPos, const QPointF &oldPos)
Top left corner handle was moved.
void moveBR(const QPointF &newPos, const QPointF &oldPos)
Bottom right corner handle was moved.
static const int PDF_CROPPING_RIGHT
Bit flag when handle is aligned with right edge at reference point.
Definition: PdfCropping.h:52
static const int PDF_CROPPING_TOP
Bit flag when handle is aligned with top edge at reference point.
Definition: PdfCropping.h:53
QRectF frameRect() const
Frame rectangle selected by user.
Definition: PdfCropping.cpp:68
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window...
Definition: ViewPreview.h:14
This class shows a frame around the selected portion of the pdf import preview window.
Definition: PdfCropping.h:24
static const int PDF_CROPPING_BOTTOM
Bit flag when handle is aligned with bottom edge at reference point.
Definition: PdfCropping.h:50
void moveBL(const QPointF &newPos, const QPointF &oldPos)
Bottom left corner handle was moved.
Definition: PdfCropping.cpp:82
QSize windowSize() const
Size of window in scene coordinates.
This class acts as a single handle for the PdfCropping class.
static const int PDF_CROPPING_LEFT
Bit flag when handle is aligned with left edge at reference point.
Definition: PdfCropping.h:51
void moveTR(const QPointF &newPos, const QPointF &oldPos)
Top right corner handle was moved.