Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | List of all members
PdfCropping Class Reference

This class shows a frame around the selected portion of the pdf import preview window. More...

#include <PdfCropping.h>

Collaboration diagram for PdfCropping:
Collaboration graph

Public Member Functions

 PdfCropping (QGraphicsScene &scene, ViewPreview &view)
 Single constructor. More...
 
QRectF frameRect () const
 Frame rectangle selected by user. More...
 
void moveBL (const QPointF &newPos, const QPointF &oldPos)
 Bottom left corner handle was moved. More...
 
void moveBR (const QPointF &newPos, const QPointF &oldPos)
 Bottom right corner handle was moved. More...
 
void moveTL (const QPointF &newPos, const QPointF &oldPos)
 Top left corner handle was moved. More...
 
void moveTR (const QPointF &newPos, const QPointF &oldPos)
 Top right corner handle was moved. More...
 
QSize windowSize () const
 Size of window in scene coordinates. More...
 

Static Public Attributes

static const int PDF_CROPPING_BOTTOM = 1
 Bit flag when handle is aligned with bottom edge at reference point. More...
 
static const int PDF_CROPPING_LEFT = 2
 Bit flag when handle is aligned with left edge at reference point. More...
 
static const int PDF_CROPPING_RIGHT = 4
 Bit flag when handle is aligned with right edge at reference point. More...
 
static const int PDF_CROPPING_TOP = 8
 Bit flag when handle is aligned with top edge at reference point. More...
 

Detailed Description

This class shows a frame around the selected portion of the pdf import preview window.

Originally there were 4 handles at the corners and 4 handles at the middles of the sides, but dragging the corner handles did not result in 1/2 the movement at the middle handles. The middle handles were deemed not worth the effort

Definition at line 24 of file PdfCropping.h.

Constructor & Destructor Documentation

PdfCropping::PdfCropping ( QGraphicsScene &  scene,
ViewPreview view 
)

Single constructor.

Definition at line 20 of file PdfCropping.cpp.

21  :
22  m_view (view)
23 {
24  createWidgets (scene);
25 }

Member Function Documentation

QRectF PdfCropping::frameRect ( ) const

Frame rectangle selected by user.

Definition at line 69 of file PdfCropping.cpp.

70 {
71  // The x(), y(), pos(), rect() and boundingRect() will return coordinates assuming origin at the initial position of
72  // each handle. So to get the coordinates in the window reference frame it takes a two step process like
73  // QGraphicsRectItem::mapRectToScene (QGraphicsRectItem::rect())
74 
75  QRectF rectTL = m_handleTL->mapRectToScene (m_handleTL->boundingRect());
76  QRectF rectBR = m_handleBR->mapRectToScene (m_handleBR->boundingRect());
77 
78  QRectF rectUnited = rectTL.united (rectBR);
79 
80  return rectUnited;
81 }
void PdfCropping::moveBL ( const QPointF &  newPos,
const QPointF &  oldPos 
)

Bottom left corner handle was moved.

Definition at line 83 of file PdfCropping.cpp.

85 {
86  disableEventsWhileMovingAutomatically();
87 
88  double deltaX = newPos.x() - oldPos.x();
89  double deltaY = newPos.y() - oldPos.y();
90 
91  m_handleTL->moveBy (deltaX,
92  0);
93  m_handleBR->moveBy (0,
94  deltaY);
95 
96  enableEventsWhileMovingAutomatically();
97 
98  updateBox();
99 }
void PdfCropping::moveBR ( const QPointF &  newPos,
const QPointF &  oldPos 
)

Bottom right corner handle was moved.

Definition at line 101 of file PdfCropping.cpp.

103 {
104  disableEventsWhileMovingAutomatically();
105 
106  double deltaX = newPos.x() - oldPos.x();
107  double deltaY = newPos.y() - oldPos.y();
108 
109  m_handleBL->moveBy (0,
110  deltaY);
111  m_handleTR->moveBy (deltaX,
112  0);
113 
114  enableEventsWhileMovingAutomatically();
115 
116  updateBox();
117 }
void PdfCropping::moveTL ( const QPointF &  newPos,
const QPointF &  oldPos 
)

Top left corner handle was moved.

Definition at line 119 of file PdfCropping.cpp.

121 {
122  disableEventsWhileMovingAutomatically();
123 
124  double deltaX = newPos.x() - oldPos.x();
125  double deltaY = newPos.y() - oldPos.y();
126 
127  m_handleBL->moveBy (deltaX,
128  0);
129  m_handleTR->moveBy (0,
130  deltaY);
131 
132  enableEventsWhileMovingAutomatically();
133 
134  updateBox();
135 }
void PdfCropping::moveTR ( const QPointF &  newPos,
const QPointF &  oldPos 
)

Top right corner handle was moved.

Definition at line 137 of file PdfCropping.cpp.

139 {
140  disableEventsWhileMovingAutomatically();
141 
142  double deltaX = newPos.x() - oldPos.x();
143  double deltaY = newPos.y() - oldPos.y();
144 
145  m_handleTL->moveBy (0,
146  deltaY);
147  m_handleBR->moveBy (deltaX,
148  0);
149 
150  enableEventsWhileMovingAutomatically();
151 
152  updateBox();
153 }
QSize PdfCropping::windowSize ( ) const

Size of window in scene coordinates.

Definition at line 166 of file PdfCropping.cpp.

167 {
168  return QSize (qFloor (m_view.scene()->width()),
169  qFloor (m_view.scene()->height()));
170 }

Member Data Documentation

const int PdfCropping::PDF_CROPPING_BOTTOM = 1
static

Bit flag when handle is aligned with bottom edge at reference point.

Definition at line 50 of file PdfCropping.h.

const int PdfCropping::PDF_CROPPING_LEFT = 2
static

Bit flag when handle is aligned with left edge at reference point.

Definition at line 51 of file PdfCropping.h.

const int PdfCropping::PDF_CROPPING_RIGHT = 4
static

Bit flag when handle is aligned with right edge at reference point.

Definition at line 52 of file PdfCropping.h.

const int PdfCropping::PDF_CROPPING_TOP = 8
static

Bit flag when handle is aligned with top edge at reference point.

Definition at line 53 of file PdfCropping.h.


The documentation for this class was generated from the following files: