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

Method resetBoxes

modules/QtPDF/src/PDFDocumentTools.cpp:984–1029  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

982}
983
984void Select::resetBoxes(const size_type pageNum /* = -1 */)
985{
986 _pageNum = pageNum;
987 _boxes.clear();
988#ifdef DEBUG
989 // In debug builds, remove any previously shown (selectable) boxes
990 foreach(QGraphicsRectItem * box, _displayBoxes) {
991 delete box;
992 }
993 _displayBoxes.clear();
994#endif
995
996 Q_ASSERT(_parent != nullptr);
997 PDFDocumentScene * scene = dynamic_cast<PDFDocumentScene*>(_parent->scene());
998 Q_ASSERT(scene != nullptr);
999 QSharedPointer<Backend::Document> doc(scene->document().toStrongRef());
1000 if (!doc)
1001 return;
1002
1003 QSharedPointer<Backend::Page> page(doc->page(pageNum).toStrongRef());
1004 if (page.isNull())
1005 return;
1006
1007 _boxes = page->boxes();
1008#ifdef DEBUG
1009 // In debug builds, show all selectable boxes
1010 PDFPageGraphicsItem * pageGraphicsItem = dynamic_cast<PDFPageGraphicsItem*>(scene->pageAt(pageNum));
1011 Q_ASSERT(pageGraphicsItem != nullptr);
1012
1013 QTransform toView = pageGraphicsItem->pointScale();
1014 for(const Backend::Page::Box & b : _boxes) {
1015 if (b.subBoxes.isEmpty()) {
1016 QGraphicsRectItem * rectItem = scene->addRect(toView.mapRect(b.boundingBox), QPen(_highlightColor));
1017 rectItem->setParentItem(pageGraphicsItem);
1018 _displayBoxes << rectItem;
1019 }
1020 else {
1021 for (const Backend::Page::Box & sb : b.subBoxes) {
1022 QGraphicsRectItem * rectItem = scene->addRect(toView.mapRect(sb.boundingBox), QPen(_highlightColor));
1023 rectItem->setParentItem(pageGraphicsItem);
1024 _displayBoxes << rectItem;
1025 }
1026 }
1027 }
1028#endif // DEBUG
1029}
1030
1031void Select::pageDestroyed()
1032{

Callers

nothing calls this directly

Calls 7

isNullMethod · 0.80
pageAtMethod · 0.80
pointScaleMethod · 0.80
clearMethod · 0.45
documentMethod · 0.45
pageMethod · 0.45
boxesMethod · 0.45

Tested by

no test coverage detected