Engauge Digitizer 2
Loading...
Searching...
No Matches
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.
QRectF frameRect () const
 Frame rectangle selected by user.
void moveBL (const QPointF &newPos, const QPointF &oldPos)
 Bottom left corner handle was moved.
void moveBR (const QPointF &newPos, const QPointF &oldPos)
 Bottom right corner handle was moved.
void moveTL (const QPointF &newPos, const QPointF &oldPos)
 Top left corner handle was moved.
void moveTR (const QPointF &newPos, const QPointF &oldPos)
 Top right corner handle was moved.
QSize windowSize () const
 Size of window in scene coordinates.

Static Public Attributes

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

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::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

◆ frameRect()

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}

◆ moveBL()

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}

◆ moveBR()

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}

◆ moveTL()

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}

◆ moveTR()

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}

◆ windowSize()

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

◆ PDF_CROPPING_BOTTOM

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.

◆ PDF_CROPPING_LEFT

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.

◆ PDF_CROPPING_RIGHT

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.

◆ PDF_CROPPING_TOP

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: