summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsscene_bsp_p.h
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@trolltech.com>2009-04-07 18:42:53 (GMT)
committerAlexis Menard <alexis.menard@trolltech.com>2009-04-07 18:42:53 (GMT)
commit226baa99f53eeeff2489148c9187c19f5bc86f0e (patch)
tree9dae513b7d8da6667d7a2f86a5334326a6c29e34 /src/gui/graphicsview/qgraphicsscene_bsp_p.h
parenta779817905ae66de9333fbe3896b0ff1c3990581 (diff)
downloadQt-226baa99f53eeeff2489148c9187c19f5bc86f0e.zip
Qt-226baa99f53eeeff2489148c9187c19f5bc86f0e.tar.gz
Qt-226baa99f53eeeff2489148c9187c19f5bc86f0e.tar.bz2
Remove the indexing (BSP) logic from the scene
We basically add a new index that implement the old BSP logic but in a separate class instead of living into the QGraphicsScene. It will be much more easier to add a new index method or for people to use their own Conflicts: src/gui/graphicsview/qgraphicsitem.cpp src/gui/graphicsview/qgraphicssceneindex.h
Diffstat (limited to 'src/gui/graphicsview/qgraphicsscene_bsp_p.h')
-rw-r--r--src/gui/graphicsview/qgraphicsscene_bsp_p.h27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene_bsp_p.h b/src/gui/graphicsview/qgraphicsscene_bsp_p.h
index 69d9eee..e6ceb78 100644
--- a/src/gui/graphicsview/qgraphicsscene_bsp_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_bsp_p.h
@@ -60,7 +60,6 @@
#include <QtCore/qrect.h>
#include <QtCore/qset.h>
#include <QtCore/qvector.h>
-#include <QtGui/qgraphicssceneindex.h>
QT_BEGIN_NAMESPACE
@@ -70,10 +69,8 @@ class QGraphicsSceneInsertItemBspTreeVisitor;
class QGraphicsSceneRemoveItemBspTreeVisitor;
class QGraphicsSceneFindItemBspTreeVisitor;
-class Q_AUTOTEST_EXPORT QGraphicsSceneBspTree : public QGraphicsSceneIndex
+class QGraphicsSceneBspTree
{
- Q_OBJECT
-
public:
struct Node
{
@@ -85,27 +82,20 @@ public:
Type type;
};
- QGraphicsSceneBspTree(QObject *parent = 0);
+ QGraphicsSceneBspTree();
~QGraphicsSceneBspTree();
void initialize(const QRectF &rect, int depth);
void clear();
- QRectF rect() const;
- void setRect(const QRectF &rect);
- void insertItem(QGraphicsItem *item);
- void removeItem(QGraphicsItem *item);
- void removeItems(const QList<QGraphicsItem *> &items);
+ void insertItem(QGraphicsItem *item, const QRectF &rect);
+ void removeItem(QGraphicsItem *item, const QRectF &rect);
+ void removeItems(const QSet<QGraphicsItem *> &items);
- QList<QGraphicsItem *> items(const QPointF &point);
QList<QGraphicsItem *> items(const QRectF &rect);
-
+ QList<QGraphicsItem *> items(const QPointF &pos);
int leafCount() const;
- int depth;
-
-private:
-
inline int firstChildIndex(int index) const
{ return index * 2 + 1; }
@@ -114,6 +104,7 @@ private:
QString debug(int index) const;
+private:
void initialize(const QRectF &rect, int depth, int index);
void climbTree(QGraphicsSceneBspTreeVisitor *visitor, const QPointF &pos, int index = 0);
void climbTree(QGraphicsSceneBspTreeVisitor *visitor, const QRectF &rect, int index = 0);
@@ -125,7 +116,7 @@ private:
QVector<Node> nodes;
QVector<QList<QGraphicsItem *> > leaves;
int leafCnt;
- QRectF sceneRect;
+ QRectF rect;
QGraphicsSceneInsertItemBspTreeVisitor *insertVisitor;
QGraphicsSceneRemoveItemBspTreeVisitor *removeVisitor;
@@ -139,8 +130,6 @@ public:
virtual void visit(QList<QGraphicsItem *> *items) = 0;
};
-Q_DECLARE_TYPEINFO(QGraphicsSceneBspTree::Node, Q_PRIMITIVE_TYPE);
-
QT_END_NAMESPACE
#endif // QT_NO_GRAPHICSVIEW