Warning, file /office/calligra/libs/flake/KoShapeManager_p.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002 
0003    Copyright (C) 2006-2008 Thorsten Zachmann <zachmann@kde.org>
0004    Copyright (C) 2006-2010 Thomas Zander <zander@kde.org>
0005    Copyright (C) 2009-2010 Jan Hambrecht <jaham@gmx.net>
0006 
0007    This library is free software; you can redistribute it and/or
0008    modify it under the terms of the GNU Library General Public
0009    License as published by the Free Software Foundation; either
0010    version 2 of the License, or (at your option) any later version.
0011 
0012    This library is distributed in the hope that it will be useful,
0013    but WITHOUT ANY WARRANTY; without even the implied warranty of
0014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015    Library General Public License for more details.
0016 
0017    You should have received a copy of the GNU Library General Public License
0018    along with this library; see the file COPYING.LIB.  If not, write to
0019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020    Boston, MA 02110-1301, USA.
0021 */
0022 #ifndef KoShapeManager_p_h
0023 #define KoShapeManager_p_h
0024 
0025 #include "KoShapeManager.h"
0026 #include "KoSelection.h"
0027 #include "KoPointerEvent.h"
0028 #include "KoShape.h"
0029 #include "KoShape_p.h"
0030 #include "KoCanvasBase.h"
0031 #include "KoShapeContainer.h"
0032 #include "KoShapeStrokeModel.h"
0033 #include "KoShapeGroup.h"
0034 #include "KoToolProxy.h"
0035 #include "KoShapeManagerPaintingStrategy.h"
0036 #include "KoShapeShadow.h"
0037 #include "KoShapeLayer.h"
0038 #include "KoFilterEffect.h"
0039 #include "KoFilterEffectStack.h"
0040 #include "KoFilterEffectRenderContext.h"
0041 #include "KoShapeBackground.h"
0042 #include <KoRTree.h>
0043 #include "KoClipPath.h"
0044 #include "KoShapePaintingContext.h"
0045 
0046 #include <QPainter>
0047 #include <QTimer>
0048 #include <FlakeDebug.h>
0049 
0050 class Q_DECL_HIDDEN KoShapeManager::Private
0051 {
0052 public:
0053     Private(KoShapeManager *shapeManager, KoCanvasBase *c)
0054         : selection(new KoSelection()),
0055           canvas(c),
0056           tree(4, 2),
0057           strategy(new KoShapeManagerPaintingStrategy(shapeManager)),
0058           q(shapeManager)
0059     {
0060     }
0061 
0062     ~Private() {
0063         delete selection;
0064         delete strategy;
0065     }
0066 
0067     /**
0068      * Update the tree when there are shapes in m_aggregate4update. This is done so not all
0069      * updates to the tree are done when they are asked for but when they are needed.
0070      */
0071     void updateTree();
0072 
0073     /**
0074      * Recursively paints the given group shape to the specified painter
0075      * This is needed for filter effects on group shapes where the filter effect
0076      * applies to all the children of the group shape at once
0077      */
0078     void paintGroup(KoShapeGroup *group, QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &paintContext);
0079 
0080     class DetectCollision
0081     {
0082     public:
0083         DetectCollision() {}
0084         void detect(KoRTree<KoShape *> &tree, KoShape *s, int prevZIndex) {
0085             foreach(KoShape *shape, tree.intersects(s->boundingRect())) {
0086                 bool isChild = false;
0087                 KoShapeContainer *parent = s->parent();
0088                 while (parent && !isChild) {
0089                     if (parent == shape)
0090                         isChild = true;
0091                     parent = parent->parent();
0092                 }
0093                 if (isChild)
0094                     continue;
0095                 if (s->zIndex() <= shape->zIndex() && prevZIndex <= shape->zIndex())
0096                     // Moving a shape will only make it collide with shapes below it.
0097                     continue;
0098                 if (shape->collisionDetection() && !shapesWithCollisionDetection.contains(shape))
0099                     shapesWithCollisionDetection.append(shape);
0100             }
0101         }
0102 
0103         void fireSignals() {
0104             foreach(KoShape *shape, shapesWithCollisionDetection)
0105                 shape->priv()->shapeChanged(KoShape::CollisionDetected);
0106         }
0107 
0108     private:
0109         QList<KoShape*> shapesWithCollisionDetection;
0110     };
0111 
0112     QList<KoShape *> shapes;
0113     QList<KoShape *> additionalShapes; // these are shapes that are only handled for updates
0114     KoSelection *selection;
0115     KoCanvasBase *canvas;
0116     KoRTree<KoShape *> tree;
0117     QSet<KoShape *> aggregate4update;
0118     QHash<KoShape*, int> shapeIndexesBeforeUpdate;
0119     KoShapeManagerPaintingStrategy *strategy;
0120     KoShapeManager *q;
0121 };
0122 
0123 #endif