21#ifndef Tulip_QLQUADTREELODCALCULATOR_H
22#define Tulip_QLQUADTREELODCALCULATOR_H
24#include <unordered_map>
27#include <tulip/GlCPULODCalculator.h>
28#include <tulip/Observable.h>
29#include <tulip/GlGraphRenderingParameters.h>
37class PropertyInterface;
44class TLP_GL_SCOPE GlQuadTreeLODCalculator :
public GlCPULODCalculator,
private Observable {
47 GlQuadTreeLODCalculator();
48 ~GlQuadTreeLODCalculator()
override;
53 void setScene(GlScene &scene)
override;
58 bool needEntities()
override;
62 void setNeedEntities(
bool)
override;
67 void addSimpleEntityBoundingBox(GlSimpleEntity *entity,
const BoundingBox &bb)
override;
71 void addEdgeBoundingBox(
unsigned int id,
unsigned int pos,
const BoundingBox &bb)
override;
78 void compute(
const Vector<int, 4> &globalViewport,
79 const Vector<int, 4> ¤tViewport)
override;
84 void computeFor3DCamera(LayerLODUnit *layerLODUnit,
const Coord &eye,
85 const Matrix<float, 4> &transformMatrix,
86 const Vector<int, 4> &globalViewport,
87 const Vector<int, 4> ¤tViewport)
override;
92 void setInputData(
const GlGraphInputData *newInputData)
override;
97 GlLODCalculator *clone()
override {
98 GlQuadTreeLODCalculator *newCalculator =
new GlQuadTreeLODCalculator();
99 newCalculator->setScene(*glScene);
100 newCalculator->setInputData(inputData);
101 return newCalculator;
105 void update(PropertyInterface *property);
106 void treatEvent(
const Event &ev)
override;
108 void removeObservers();
111 void initCamerasObservers();
112 void clearCamerasObservers();
114 void setHaveToCompute();
116 std::vector<QuadTreeNode<std::pair<uint, uint>> *> nodesQuadTree;
117 std::vector<QuadTreeNode<std::pair<uint, uint>> *> edgesQuadTree;
118 std::vector<QuadTreeNode<GlSimpleEntity *> *> entitiesQuadTree;
119 std::vector<std::vector<SimpleEntityLODUnit>> simpleEntities;
122 bool haveToInitObservers;
125 const unsigned int seBBIndex;
127 const unsigned int eBBOffset;
129 std::vector<Camera *> cameras;
130 std::unordered_map<GlLayer *, Camera> layerToCamera;
131 Camera *currentCamera;
133 PropertyInterface *layoutProperty;
134 PropertyInterface *sizeProperty;
135 PropertyInterface *selectionProperty;
136 GlGraphRenderingParameters oldParameters;
138 int quadTreesVectorPosition;
139 int simpleEntitiesVectorPosition;