File indexing completed on 2024-05-12 15:56:49

0001 /* This file is part of the KDE project
0002 
0003    SPDX-FileCopyrightText: 2006-2008 Thorsten Zachmann <zachmann@kde.org>
0004    SPDX-FileCopyrightText: 2006-2010 Thomas Zander <zander@kde.org>
0005    SPDX-FileCopyrightText: 2009-2010 Jan Hambrecht <jaham@gmx.net>
0006 
0007    SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 #ifndef KoShapeManager_p_h
0010 #define KoShapeManager_p_h
0011 
0012 #include "KoSelection.h"
0013 #include "KoShape.h"
0014 #include "KoShape_p.h"
0015 #include "KoShapeContainer.h"
0016 #include "KoShapeManager.h"
0017 #include <KoRTree.h>
0018 #include <QMutex>
0019 #include "kis_thread_safe_signal_compressor.h"
0020 
0021 class KoCanvasBase;
0022 class KoShapeGroup;
0023 class QPainter;
0024 
0025 class Q_DECL_HIDDEN KoShapeManager::Private
0026 {
0027 public:
0028     Private(KoShapeManager *shapeManager, KoCanvasBase *c)
0029         : selection(new KoSelection(shapeManager)),
0030           canvas(c),
0031           tree(4, 2),
0032           q(shapeManager),
0033           shapeInterface(shapeManager),
0034           updateCompressor(100, KisSignalCompressor::FIRST_ACTIVE)
0035     {
0036     }
0037 
0038     ~Private() {
0039         delete selection;
0040     }
0041 
0042     /**
0043      * Update the tree when there are shapes in m_aggregate4update. This is done so not all
0044      * updates to the tree are done when they are asked for but when they are needed.
0045      */
0046     void updateTree();
0047 
0048     void forwardCompressedUdpate();
0049 
0050 
0051     /**
0052      * Recursively detach the shapes from this shape manager
0053      */
0054     void unlinkFromShapesRecursively(const QList<KoShape *> &shapes);
0055 
0056     QList<KoShape *> shapes;
0057     KoSelection *selection;
0058     KoCanvasBase *canvas;
0059     KoRTree<KoShape *> tree;
0060     QSet<KoShape *> aggregate4update;
0061     QHash<KoShape*, int> shapeIndexesBeforeUpdate;
0062     KoShapeManager *q;
0063     KoShapeManager::ShapeInterface shapeInterface;
0064     QMutex shapesMutex;
0065     QMutex treeMutex;
0066 
0067     KisThreadSafeSignalCompressor updateCompressor;
0068     QRectF compressedUpdate;
0069     QSet<const KoShape*> compressedUpdatedShapes;
0070 
0071     bool updatesBlocked = false;
0072 };
0073 
0074 #endif