Engauge Digitizer  2
NonPdfCropping.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 NON_PDF_CROPPING_H
8 #define NON_PDF_CROPPING_H
9 
10 #include <QRect>
11 #include <QSize>
12 
13 class NonPdfFrameHandle;
14 class QGraphicsRectItem;
15 class QGraphicsScene;
16 class QPointF;
17 class ViewPreview;
18 
23 {
24 public:
26  NonPdfCropping(QGraphicsScene &scene,
27  ViewPreview &view);
28 
30  QRectF frameRect () const;
31 
33  void moveBL (const QPointF &newPos,
34  const QPointF &oldPos);
35 
37  void moveBR (const QPointF &newPos,
38  const QPointF &oldPos);
39 
41  void moveTL (const QPointF &newPos,
42  const QPointF &oldPos);
43 
45  void moveTR (const QPointF &newPos,
46  const QPointF &oldPos);
47 
48  static const int NON_PDF_CROPPING_BOTTOM = 1;
49  static const int NON_PDF_CROPPING_LEFT = 2;
50  static const int NON_PDF_CROPPING_RIGHT = 4;
51  static const int NON_PDF_CROPPING_TOP = 8;
52 
54  QSize windowSize () const;
55 
56 private:
57  NonPdfCropping ();
58 
59  void createWidgets (QGraphicsScene &scene);
60  void disableEventsWhileMovingAutomatically();
61  void enableEventsWhileMovingAutomatically();
62  QRectF rectFromTLAndBR () const;
63  void updateBox();
64 
65  ViewPreview &m_view;
66 
67  // Box
68  QGraphicsRectItem *m_box;
69 
70  // Handles
71  NonPdfFrameHandle *m_handleTL;
72  NonPdfFrameHandle *m_handleTR;
73  NonPdfFrameHandle *m_handleBR;
74  NonPdfFrameHandle *m_handleBL;
75 
76 };
77 
78 #endif // NON_PDF_CROPPING_H
static const int NON_PDF_CROPPING_LEFT
Bit flag when handle is aligned with left edge at reference point.
This class shows a frame around the selected portion of the import preview window.
void moveTL(const QPointF &newPos, const QPointF &oldPos)
Top left corner handle was moved.
QSize windowSize() const
Size of window in scene coordinates.
static const int NON_PDF_CROPPING_TOP
Bit flag when handle is aligned with top edge at reference point.
static const int NON_PDF_CROPPING_BOTTOM
Bit flag when handle is aligned with bottom edge at reference point.
void moveTR(const QPointF &newPos, const QPointF &oldPos)
Top right corner handle was moved.
QRectF frameRect() const
Frame rectangle selected by user.
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window...
Definition: ViewPreview.h:14
This class acts as a single handle for the NonPdfCropping class.
void moveBR(const QPointF &newPos, const QPointF &oldPos)
Bottom right corner handle was moved.
void moveBL(const QPointF &newPos, const QPointF &oldPos)
Bottom left corner handle was moved.
static const int NON_PDF_CROPPING_RIGHT
Bit flag when handle is aligned with right edge at reference point.