MCPcopy Create free account
hub / github.com/TeXworks/texworks / PDFPageGraphicsItem

Method PDFPageGraphicsItem

modules/QtPDF/src/PDFDocumentView.cpp:1873–1908  ·  view source on GitHub ↗

This class descends from `QGraphicsObject` and implements the on-screen representation of `Page` objects.

Source from the content-addressed store, hash-verified

1871// This class descends from `QGraphicsObject` and implements the on-screen
1872// representation of `Page` objects.
1873PDFPageGraphicsItem::PDFPageGraphicsItem(QWeakPointer<Backend::Page> a_page, const double dpiX, const double dpiY, QGraphicsItem *parent /* = nullptr */):
1874 Super(parent),
1875 _page(a_page),
1876 // FIXME: The QGraphicsObject should be independent of the hardware it is
1877 // shown on
1878 _dpiX(dpiX),
1879 _dpiY(dpiY),
1880 _pageNum(-1),
1881 _linksLoaded(false),
1882 _annotationsLoaded(false),
1883 _zoomLevel(0.0)
1884{
1885 // So we get information during paint events about what portion of the page
1886 // is visible.
1887 //
1888 // NOTE: This flag needs Qt 4.6 or newer.
1889 setFlags(QGraphicsItem::ItemUsesExtendedStyleOption);
1890
1891 QSharedPointer<Backend::Page> page(_page.toStrongRef());
1892 if (page) {
1893 _pageNum = page->pageNum();
1894 // Create an empty pixmap that is the same size as the PDF page. This
1895 // allows us to delay the rendering of pages until they actually come into
1896 // view yet still know what the page size is.
1897 _pageSize = page->pageSizeF();
1898 _pageSize.setWidth(_pageSize.width() * _dpiX / 72.0);
1899 _pageSize.setHeight(_pageSize.height() * _dpiY / 72.0);
1900
1901 // `_pageScale` holds a transformation matrix that can map between normalized
1902 // page coordinates (in the range 0...1) and the coordinate system for this
1903 // graphics item. `_pointScale` is similar, except it maps from coordinates
1904 // expressed in pixels at a resolution of 72 dpi.
1905 _pageScale = QTransform::fromScale(_pageSize.width(), _pageSize.height());
1906 _pointScale = QTransform::fromScale(_dpiX / 72.0, _dpiY / 72.0);
1907 }
1908}
1909
1910QRectF PDFPageGraphicsItem::boundingRect() const { return QRectF(QPointF(0.0, 0.0), _pageSize); }
1911int PDFPageGraphicsItem::type() const { return Type; }

Callers

nothing calls this directly

Calls 2

pageNumMethod · 0.45
pageSizeFMethod · 0.45

Tested by

no test coverage detected