pdfpagecontainer.cpp 18,6 КБ
Newer Older
OMP Education's avatar
OMP Education включено в состав коммита
1
// SPDX-FileCopyrightText: 2022-2024 Open Mobile Platform LLC <community@omp.ru>
OMP Education's avatar
OMP Education включено в состав коммита
2
// SPDX-License-Identifier: BSD-3-Clause
OMP Education's avatar
OMP Education включено в состав коммита
3
4
5
6
7
8
9

#include "QQuickWindow"
#include <QSGSimpleTextureNode>
#include <QtMath>
#include <QFutureWatcher>

#include "pdfpagetile.h"
OMP Education's avatar
OMP Education включено в состав коммита
10
11
12
#include "pdfsimpleannotation.h"
#include "pdfsimplenote.h"
#include "baseannotation.h"
OMP Education's avatar
OMP Education включено в состав коммита
13
#include "basepage.h"
OMP Education's avatar
OMP Education включено в состав коммита
14
#include "pdfbackgroundpage.h"
OMP Education's avatar
OMP Education включено в состав коммита
15
16
17

#include "pdfpagecontainer.h"

OMP Education's avatar
OMP Education включено в состав коммита
18
19
#include <amberpdf/pdfpage.h>

OMP Education's avatar
OMP Education включено в состав коммита
20
21
22
23
24
25
26
27
28
29
30
31
32
33
PdfPageContainer::PdfPageContainer(QQuickItem *parent)
    : QQuickItem(parent)
    , m_scale(1.0)
    , m_mapper(nullptr)
    , m_backgroundPage(nullptr)
    , m_maxTileZ(0)
    , m_tileSize(256)
    , m_annotationsPaint(false)
    , m_notesPaint(false)
    , m_allTilesReady(false)
    , m_grayScaleRendering(false)
    , m_checked(false)
    , m_pageIndex(-1)
    , m_centering(false)
OMP Education's avatar
OMP Education включено в состав коммита
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
    setFlag(QQuickItem::ItemHasContents, true);

    auto itemWindow = window();
    if (itemWindow != nullptr)
        connect(itemWindow, &QQuickWindow::beforeSynchronizing, this, &PdfPageContainer::_updateVisible, Qt::DirectConnection);
}

PdfPageContainer::~PdfPageContainer() = default;

QSGNode *PdfPageContainer::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *)
{
    return oldNode;
}

void PdfPageContainer::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
    QQuickItem::geometryChanged(newGeometry, oldGeometry);

    if (qFuzzyCompare(newGeometry.width(), oldGeometry.width()) && qFuzzyCompare(newGeometry.height(), oldGeometry.height()))
        return;
OMP Education's avatar
OMP Education включено в состав коммита
55
56

    auto pageRate = width() / m_pageGeometry.width();
OMP Education's avatar
OMP Education включено в состав коммита
57
58
59
60
61
62
63
64

    if (m_backgroundPage) {
        m_backgroundPage->setWidth(width());
        m_backgroundPage->setHeight(height());
        m_backgroundPage->setImageScale(pageRate);
        m_backgroundPage->setPageScale(m_scale);
    }

OMP Education's avatar
OMP Education включено в состав коммита
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    QMutableListIterator<PdfSimpleAnnotation *> annotIter(m_annotationsItems);
    while (annotIter.hasNext()) {
        annotIter.next();
        if (annotIter.value() == nullptr) {
            annotIter.remove();
            continue;
        }
        auto pdfAnnotation = annotIter.value()->source();
        annotIter.value()->setX(pdfAnnotation->rect.x() * pageRate);
        annotIter.value()->setY((m_pageGeometry.height() - pdfAnnotation->rect.y()) * pageRate - pdfAnnotation->rect.height() * pageRate);
        annotIter.value()->setWidth(pdfAnnotation->rect.width() * pageRate);
        annotIter.value()->setHeight(pdfAnnotation->rect.height() * pageRate);

    }

    QMutableListIterator<PdfSimpleNote *> noteIter(m_notesItems);
    while (noteIter.hasNext()) {
        noteIter.next();
        if (noteIter.value() == nullptr) {
            noteIter.remove();
            continue;
        }

        auto pdfAnnotation = noteIter.value()->source();
        noteIter.value()->setX(pdfAnnotation->rect.x() * pageRate);
        noteIter.value()->setY((m_pageGeometry.height() - pdfAnnotation->rect.y()) * pageRate - pdfAnnotation->rect.height() * pageRate);
        noteIter.value()->setWidth(pdfAnnotation->rect.width() * pageRate);
        noteIter.value()->setHeight(pdfAnnotation->rect.height() * pageRate);
    }
OMP Education's avatar
OMP Education включено в состав коммита
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
}

QSizeF PdfPageContainer::requestedSize() const
{
    return m_requestedSize;
}

Qt::Orientation PdfPageContainer::orientation() const
{
    return m_orientation;
}

qreal PdfPageContainer::scale() const
{
    return m_scale;
}

OMP Education's avatar
OMP Education включено в состав коммита
111
112
113
114
115
bool PdfPageContainer::checked() const
{
    return m_checked;
}

OMP Education's avatar
OMP Education включено в состав коммита
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
void PdfPageContainer::setPageSource(QSharedPointer<BasePage> pageSource)
{
    if (!pageSource)
        return;

    if (m_pageSource == pageSource) {
        _correctSize();
        return;
    }

    m_pageSource = pageSource;

    m_pageSource->originalSize();
    auto sizeWatcher = new QFutureWatcher<QSizeF>(this);
    connect(sizeWatcher, &QFutureWatcher<QSizeF>::finished, this, [this, sizeWatcher]() {
        if (m_pageSource) {
            for(auto &tile : m_tilesMap.values())
                tile->setPageSource(m_pageSource);

            update();
        }

        sizeWatcher->deleteLater();
    });
    sizeWatcher->setFuture(m_pageSource->originalSize());

OMP Education's avatar
OMP Education включено в состав коммита
142
143
    _prepareBackgroundPage();

OMP Education's avatar
OMP Education включено в состав коммита
144
    _correctSize();
OMP Education's avatar
OMP Education включено в состав коммита
145
146
147
148
149
150
151
152
153
154
155

    if (!m_pageSource->isAnnotationsSupport())
        return;

    connect(m_pageSource.data(), &BasePage::annotationsLoaded, this, &PdfPageContainer::_loadAnnotations);
    connect(m_pageSource.data(), &BasePage::annotationAdded, this, [this](bool added) {
        if (m_pageSource && added) {
            m_pageSource->loadAnnotations();
            emit pageChanged();
        }
    });
OMP Education's avatar
OMP Education включено в состав коммита
156
157
158
159
160
161
162
163
    connect(m_pageSource.data(), &BasePage::annotationDelete, this, [this](int noteId, bool removeResult) {
        if (removeResult) {
            m_pageSource->loadAnnotations();
            emit pageChanged();
        }

        emit noteRemoved(noteId, removeResult);
    });
OMP Education's avatar
OMP Education включено в состав коммита
164
165
166
167
168
169
170
171
172
173
    connect(m_pageSource.data(), &BasePage::annotationEdited, this, [this](int noteId, bool edited) {
        Q_UNUSED(noteId)

        if (m_pageSource && edited) {
            m_pageSource->loadAnnotations();
            emit pageChanged();
        }

        emit noteEdited(noteId, edited);
    });
OMP Education's avatar
OMP Education включено в состав коммита
174
175
176
177
178

    if (m_pageSource->annotations().isEmpty())
        m_pageSource->loadAnnotations();
    else
        _loadAnnotations();
OMP Education's avatar
OMP Education включено в состав коммита
179
180
181
182
183
184
185
186
187
188
}

void PdfPageContainer::setPageGeometry(const PageGeometry &pg)
{
    m_pageGeometry = pg;
    _correctSize();
}

int PdfPageContainer::index() const
{
OMP Education's avatar
OMP Education включено в состав коммита
189
    return m_pageSource ? m_pageSource->pageNumber() : m_pageIndex;
OMP Education's avatar
OMP Education включено в состав коммита
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
}

void PdfPageContainer::setMapper(DocumentMapper *mapper)
{
    if (mapper == m_mapper || mapper == nullptr)
        return;

    m_mapper = mapper;
}

QSizeF PdfPageContainer::pageCurrentSize(const PageGeometry &pageGeometry,
                                         const QSizeF &requestedSize,
                                         Qt::Orientation orientation,
                                         qreal scale)
{
    auto heightToWidthRatio = pageGeometry.height() / pageGeometry.width();
    auto fitHeight = qMin(static_cast<qreal>(requestedSize.height()), requestedSize.width() * heightToWidthRatio);
    return {
        static_cast<qreal>((orientation == Qt::Vertical ? requestedSize.width() : fitHeight / heightToWidthRatio) * scale),
        static_cast<qreal>((orientation == Qt::Vertical ? requestedSize.width() * heightToWidthRatio : fitHeight) * scale)
    };
}

void PdfPageContainer::setVisibleArea(const QRectF &visibleArea)
{
    if (visibleArea == m_visibleArea)
        return;

    m_visibleArea = visibleArea;
}

OMP Education's avatar
OMP Education включено в состав коммита
221
222
223
224
225
226
227
228
229
230
bool PdfPageContainer::annotationsPaint() const
{
    return m_annotationsPaint;
}

bool PdfPageContainer::notesPaint() const
{
    return m_notesPaint;
}

OMP Education's avatar
OMP Education включено в состав коммита
231
232
233
234
235
bool PdfPageContainer::grayScaleRendering() const
{
    return m_grayScaleRendering;
}

OMP Education's avatar
OMP Education включено в состав коммита
236
237
238
239
QSharedPointer<BasePage> PdfPageContainer::source() const {
    return m_pageSource;
}

OMP Education's avatar
OMP Education включено в состав коммита
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
void PdfPageContainer::addAnnotation(const QRectF &rect, const QColor &color, const QString &author, const QString &content)
{
    if (!m_pageSource)
        return;

    auto pageRate = width() / m_pageGeometry.width();
    auto correctRect = QRectF();
    correctRect.setX(qMax(0.0f, float(rect.x() / pageRate)));
    correctRect.setY(qMax(0.0f, float((height() - rect.y() - rect.height()) / pageRate)));

    correctRect.setWidth(rect.width() / pageRate);
    if (correctRect.x() + correctRect.width() > m_pageGeometry.width())
        correctRect.setWidth(m_pageGeometry.width() - correctRect.x() - 1);

    correctRect.setHeight(rect.height() / pageRate);
    if (correctRect.y() + correctRect.height() > m_pageGeometry.height())
        correctRect.setHeight(m_pageGeometry.height() - correctRect.y() - 1);

    m_pageSource->addAnnotation(correctRect, color, author, content);
}

OMP Education's avatar
OMP Education включено в состав коммита
261
262
263
264
265
266
267
268
void PdfPageContainer::removeNote(int noteId)
{
    if (!m_pageSource)
        return;

    m_pageSource->removeAnnotation(noteId);
}

OMP Education's avatar
OMP Education включено в состав коммита
269
270
271
272
273
274
275
276
void PdfPageContainer::editNote(int noteId, const QString &newContent, const QColor &newColor)
{
    if (!m_pageSource)
        return;

    m_pageSource->editNote(noteId, newContent, newColor);
}

OMP Education's avatar
OMP Education включено в состав коммита
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
void PdfPageContainer::setRequestedSize(QSizeF requestedSize)
{
    if (m_requestedSize == requestedSize)
        return;

    m_requestedSize = requestedSize;
    emit requestedSizeChanged(m_requestedSize);
    _correctSize();
}

void PdfPageContainer::setOrientation(Qt::Orientation orientation)
{
    if (m_orientation == orientation)
        return;

    m_orientation = orientation;
    emit orientationChanged(m_orientation);

    _correctSize();
}

void PdfPageContainer::setScale(qreal scale)
{
    if (qFuzzyCompare(m_scale, scale))
        return;

    m_scale = scale;
    emit scaleChanged(m_scale);

    _correctSize();
}

OMP Education's avatar
OMP Education включено в состав коммита
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
void PdfPageContainer::setAnnotationsPaint(bool annotationsPaint)
{
    if (m_annotationsPaint == annotationsPaint)
        return;

    m_annotationsPaint = annotationsPaint;
    emit annotationsPaintChanged(m_annotationsPaint);

    if (m_annotationsItems.isEmpty())
        _loadAnnotations();
    else
        for (auto annotation : m_annotationsItems)
            annotation->setOpacity(m_annotationsPaint ? 1.0 : 0.0);
}

void PdfPageContainer::setNotesPaint(bool notesPaint)
{
    if (m_notesPaint == notesPaint)
        return;

    m_notesPaint = notesPaint;
    emit notesPaintChanged(m_notesPaint);

    if (m_notesItems.isEmpty())
        _loadAnnotations();
    else
        for (auto note : m_notesItems)
            note->setOpacity(m_notesPaint ? 1.0 : 0.0);
}

OMP Education's avatar
OMP Education включено в состав коммита
339
340
341
342
343
344
345
346
347
348
349
void PdfPageContainer::setGrayScaleRendering(bool grayScaleRendering)
{
    if (m_grayScaleRendering == grayScaleRendering) {
        return;
    }

    m_grayScaleRendering = grayScaleRendering;

    _tailorise();
}

OMP Education's avatar
OMP Education включено в состав коммита
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
void PdfPageContainer::setChecked(bool checked)
{
    if (m_checked == checked)
        return;

    m_checked = checked;
    emit checkedChanged(m_checked);
    emit sendCheckChangedInfo(m_pageIndex, m_checked);
}

void PdfPageContainer::setIndex(int pageIndex)
{
    if (m_pageIndex == pageIndex)
        return;

    m_pageIndex = pageIndex;
}

OMP Education's avatar
OMP Education включено в состав коммита
368
369
370
371
372
373
374
375
void PdfPageContainer::setCentering(bool centering)
{
    if (m_centering == centering)
        return;

    m_centering = centering;
}

OMP Education's avatar
OMP Education включено в состав коммита
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
void PdfPageContainer::_correctSize()
{
    auto heightToWidthRatio = m_pageGeometry.height() / m_pageGeometry.width();
    auto fitHeight = qMin(static_cast<qreal>(m_requestedSize.height()), m_requestedSize.width() * heightToWidthRatio);
    m_pageImageSize.setWidth((m_orientation == Qt::Vertical ? m_requestedSize.width() : fitHeight / heightToWidthRatio) * m_scale);
    m_pageImageSize.setHeight((m_orientation == Qt::Vertical ? m_requestedSize.width() * heightToWidthRatio : fitHeight) * m_scale);

    setWidth(m_pageImageSize.width());
    setHeight(m_pageImageSize.height());

    auto pageScale = qMin(m_pageImageSize.width() / m_pageGeometry.width(), m_pageImageSize.height() / m_pageGeometry.height());

    if (qFuzzyCompare(m_imageScale, pageScale) && !m_tilesMap.isEmpty())
        return;

    m_imageScale = pageScale;

    _tailorise();
}

void PdfPageContainer::_tailorise()
{
    auto heightToWidthRatio = m_pageImageSize.height() / m_pageImageSize.width();
    auto actualTileWidth = m_tileSize * m_scale;
    auto actualTileHeight = actualTileWidth * heightToWidthRatio;
    auto tileCountX = qCeil(m_pageImageSize.width() / actualTileWidth);
    auto tileCountY = qCeil(m_pageImageSize.height() / actualTileHeight);
    auto maxTileCount = qMax(tileCountX, tileCountY);

    if (m_tilesMap.size() != tileCountX * tileCountY) {
        for (auto &tile : m_tilesMap.values()) {
            tile->setEnabled(false);
            tile->setVisible(false);
            tile->deleteLater();
        }

        m_tilesMap.clear();
    }

    actualTileWidth = m_pageImageSize.width() / maxTileCount;
    actualTileHeight = m_pageImageSize.height() / maxTileCount;
    auto tileIndex = -1;
OMP Education's avatar
OMP Education включено в состав коммита
418
    auto oldMaxZ = m_maxTileZ;
OMP Education's avatar
OMP Education включено в состав коммита
419
420
421
422
423
424
425
426
427
428
429
    for (int tileX = 0; tileX < maxTileCount; ++tileX) {
        for (int tileY = 0; tileY < maxTileCount; ++tileY) {
            ++tileIndex;

            if (!m_tilesMap.contains(tileIndex)) {
                auto tile = new PdfPageTile(this);
                tile->setRenderable(false);
                m_tilesMap.insert(tileIndex, tile);
            }

            auto tile = m_tilesMap.value(tileIndex);
OMP Education's avatar
OMP Education включено в состав коммита
430
            tile->setRenderFlags(m_grayScaleRendering ? PdfPage::RenderFlags::GrayScale : PdfPage::RenderFlags::NoFlags);
OMP Education's avatar
OMP Education включено в состав коммита
431
            tile->setCentering(m_centering);
OMP Education's avatar
OMP Education включено в состав коммита
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
            tile->setImageScale(m_imageScale);

            if (m_pageSource)
                tile->setPageSource(m_pageSource);

            QPointF tilePosition(tileX * actualTileWidth, tileY * actualTileHeight);
            tile->setX(tilePosition.x());
            tile->setY(tilePosition.y());

            auto currentWidth = tilePosition.x() + actualTileWidth;
            if (currentWidth <= m_pageImageSize.width())
                tile->setWidth(actualTileWidth);
            else
                tile->setWidth(actualTileWidth - qAbs(std::remainder(m_pageImageSize.width(), actualTileWidth)));

            auto currentHeight = tilePosition.y() + actualTileHeight;
            if (currentHeight <= m_pageImageSize.height())
                tile->setHeight(actualTileHeight);
            else
                tile->setHeight(actualTileHeight - qAbs(std::remainder(m_pageImageSize.height(), actualTileHeight)));

            m_maxTileZ = qMax(m_maxTileZ, tile->z());
        }
    }

OMP Education's avatar
OMP Education включено в состав коммита
457
458
459
460
461
462
463
464
    if (qFuzzyCompare(m_maxTileZ, oldMaxZ)) {
        for (auto annotationItem : m_annotationsItems)
            annotationItem->setZ(m_maxTileZ + 1);

        for (auto noteItem : m_notesItems)
            noteItem->setZ(m_maxTileZ + 1);
    }

OMP Education's avatar
OMP Education включено в состав коммита
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
    emit pageReady();

    m_allTilesReady = false;
}

void PdfPageContainer::_updateVisible()
{
    if (!isEnabled())
        return;

    if (!m_pageSource)
        return;

    if (m_mapper == nullptr)
        return;

    if (m_orientation == Qt::Vertical) {
        if (y() > m_visibleArea.height() || height() < -y()) {
            for (auto &tile : m_tilesMap.values())
                tile->setRenderable(false);

            return;
        }
    } else {
        if (x() > m_visibleArea.width() || width() < -x()) {
            for (auto &tile : m_tilesMap.values())
                tile->setRenderable(false);
            return;
        }
    }

    auto hVisible = 0.0f;
    auto wVisible = 0.0f;
    auto yVisible = 0.0f;
    auto xVisible = 0.0f;

    if (m_orientation == Qt::Vertical) {
        hVisible = y() > 0 ? (m_visibleArea.height() - y()) : (height() + y());
        wVisible = m_visibleArea.width();
        yVisible = y() > 0 ? 0.0f : -y();
        xVisible = x() > 0 ? 0.0f : -x();
    } else {
        hVisible = m_visibleArea.height();
        wVisible = x() > 0 ? (m_visibleArea.width() - x()) : (width() + x());
        yVisible = y() > 0 ? 0.0f : -y();
        xVisible = x() > 0 ? 0.0f : -x();
    }

    QRectF localVisibleArea(xVisible, yVisible, wVisible, hVisible);

    bool allTilesAreBitmap = true;
    for (auto &tile : m_tilesMap.values()) {
        QRectF tileRect(tile->x(), tile->y(), tile->width(), tile->height());
        auto tileVisible = localVisibleArea.intersects(tileRect);
        tile->setRenderable(tileVisible);

        if (!tile->isBitmap() && tileVisible)
            allTilesAreBitmap = false;
    }

    if (m_allTilesReady)
        return;

    if (allTilesAreBitmap) {
OMP Education's avatar
OMP Education включено в состав коммита
529
530
531
532
533
534
        for (auto &annotation : m_annotationsItems)
            annotation->setVisible(true);

        for (auto &note : m_notesItems)
            note->setVisible(true);

OMP Education's avatar
OMP Education включено в состав коммита
535
536
537
        m_allTilesReady = true;
    }
}
OMP Education's avatar
OMP Education включено в состав коммита
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576

void PdfPageContainer::_loadAnnotations()
{
    if (!m_pageSource)
        return;

    for (auto &annotation : m_annotationsItems)
        annotation->deleteLater();
    m_annotationsItems.clear();

    for (auto &note : m_notesItems)
        note->deleteLater();
    m_notesItems.clear();

    auto pageRate = width() / m_pageGeometry.width();
    auto annotations = m_pageSource->annotations();
    for (const auto &annotation : annotations) {
        if (annotation == nullptr)
            continue;

        if (annotation->type == BaseAnnotation::AnnotationType::Link || annotation->type == BaseAnnotation::AnnotationType::Url) {
            auto annotationItem = new PdfSimpleAnnotation(this, annotation);
            connect(annotationItem, &PdfSimpleAnnotation::triggered, this, &PdfPageContainer::annotationActivate);
            connect(this, &PdfPageContainer::yChanged, annotationItem, &PdfSimpleAnnotation::clearHighlight);
            annotationItem->setOpacity(m_annotationsPaint ? 1.0 : 0.0);
            annotationItem->setX(annotation->rect.x() * pageRate);
            annotationItem->setY((m_pageGeometry.height() - annotation->rect.y()) * pageRate - annotation->rect.height() * pageRate);
            annotationItem->setWidth(annotation->rect.width() * pageRate);
            annotationItem->setHeight(annotation->rect.height() * pageRate);
            annotationItem->setZ(m_maxTileZ);
            annotationItem->setVisible(false);
            m_annotationsItems.append(annotationItem);

            continue;
        }

        if (annotation->type == BaseAnnotation::AnnotationType::HighLight
                || annotation->type == BaseAnnotation::AnnotationType::Text) {
            auto noteItem = new PdfSimpleNote(this, annotation);
OMP Education's avatar
OMP Education включено в состав коммита
577
            connect(noteItem, &PdfSimpleNote::triggered, this, &PdfPageContainer::_noteActivate);
OMP Education's avatar
OMP Education включено в состав коммита
578
579
580
581
582
583
584
585
586
587
588
589
590
591
            connect(this, &PdfPageContainer::yChanged, noteItem, &PdfSimpleNote::clearHighlight);
            noteItem->setOpacity(m_notesPaint ? 1.0 : 0.0);
            noteItem->setX(annotation->rect.x() * pageRate);
            noteItem->setY((m_pageGeometry.height() - annotation->rect.y()) * pageRate - annotation->rect.height() * pageRate);
            noteItem->setWidth(annotation->rect.width() * pageRate);
            noteItem->setHeight(annotation->rect.height() * pageRate);
            noteItem->setZ(m_maxTileZ);
            noteItem->setVisible(false);
            m_notesItems.append(noteItem);

            continue;
        }
    }
}
OMP Education's avatar
OMP Education включено в состав коммита
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606

void PdfPageContainer::_prepareBackgroundPage()
{
    if (!m_pageSource)
        return;

    if (m_backgroundPage) {
        m_backgroundPage->setRenderable(false);
        m_backgroundPage->deleteLater();
    }

    m_backgroundPage = new PdfBackgroundPage(this);

    m_backgroundPage->setPageSource(m_pageSource);

OMP Education's avatar
OMP Education включено в состав коммита
607
    m_backgroundPage->setCentering(m_centering);
OMP Education's avatar
OMP Education включено в состав коммита
608
609
610
611
612
613
614
    m_backgroundPage->setImageScale(m_imageScale);
    m_backgroundPage->setPageScale(m_scale);
    m_backgroundPage->setWidth(width());
    m_backgroundPage->setHeight(height());
    m_backgroundPage->setRenderable(true);
    m_backgroundPage->setZ(-1);
}
OMP Education's avatar
OMP Education включено в состав коммита
615
616
617
618
619

void PdfPageContainer::_noteActivate(QString noteText, QString author)
{
    emit noteActivate(noteText, author, m_pageSource->pageNumber());
}