tile_cache.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2014, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
30 #ifndef MULTIRES_IMAGE_TILE_CACHE_H_
31 #define MULTIRES_IMAGE_TILE_CACHE_H_
32 
33 // C++ standard libraries
34 #include <vector>
35 #include <stack>
36 #include <queue>
37 #include <map>
38 
39 // QT libraries
40 #include <QObject>
41 #include <QThread>
42 #include <QMutex>
43 #include <QGLWidget>
44 
45 #include <tf/transform_datatypes.h>
46 
48 #include <multires_image/tile.h>
49 
50 namespace multires_image
51 {
52  class TileCache : public QObject
53  {
54  Q_OBJECT
55 
56  public:
57  TileCache(TileSet* tileSet, QGLWidget* widget);
58  ~TileCache(void);
59 
60  void Load(Tile* tile);
61  void Precache(const tf::Point& position);
62  void Precache(double x, double y);
63 
64  void SetCurrentLayer(int layer) { m_currentLayer = layer; }
65 
66  void Exit();
67 
68  public Q_SLOTS:
69  void LoadTextureSlot(Tile*);
70  void DeleteTextureSlot(Tile*);
71 
72  Q_SIGNALS:
73  void SignalLoadTexture(Tile*);
75  void SignalMemorySize(int64_t);
76 
77  private:
79  QGLWidget* m_widget;
80  int32_t m_currentLayer;
82  bool m_exit;
83  int64_t m_memorySize;
84 
85  std::vector<std::queue<Tile*> > m_precacheRequests;
86  std::stack<Tile*> m_renderRequests;
87  std::map<int64_t, Tile*> m_textureLoaded;
88  std::map<int64_t, Tile*> m_renderRequestSet;
89  std::map<int64_t, Tile*> m_precacheRequestSet;
90 
91  void PrecacheLayer(int layer, const tf::Point& position, int size);
92  void LoadTexture(Tile* tile);
93  void UnloadTexture(Tile* tile);
94 
95  class CacheThread : public QThread
96  {
97  public:
98  explicit CacheThread(TileCache* parent) : p(parent) {}
99  virtual void run();
100 
101  private:
103  };
104  friend class CacheThread;
105 
106  class FreeThread : public QThread
107  {
108  public:
109  explicit FreeThread(TileCache* parent) : p(parent) {}
110  virtual void run();
111 
112  private:
114  };
115  friend class FreeThread;
116 
119 
125  };
126 }
127 
128 #endif // MULTIRES_IMAGE_TILE_CACHE_H_
void PrecacheLayer(int layer, const tf::Point &position, int size)
Definition: tile_cache.cpp:149
std::map< int64_t, Tile * > m_precacheRequestSet
Definition: tile_cache.h:89
void SignalMemorySize(int64_t)
TileCache(TileSet *tileSet, QGLWidget *widget)
Definition: tile_cache.cpp:47
TFSIMD_FORCE_INLINE const tfScalar & y() const
void LoadTexture(Tile *tile)
Definition: tile_cache.cpp:194
void SetCurrentLayer(int layer)
Definition: tile_cache.h:64
std::stack< Tile * > m_renderRequests
Definition: tile_cache.h:86
std::map< int64_t, Tile * > m_renderRequestSet
Definition: tile_cache.h:88
TFSIMD_FORCE_INLINE const tfScalar & x() const
std::map< int64_t, Tile * > m_textureLoaded
Definition: tile_cache.h:87
void SignalLoadTexture(Tile *)
void DeleteTextureSlot(Tile *)
Definition: tile_cache.cpp:92
void Precache(const tf::Point &position)
Definition: tile_cache.cpp:125
std::vector< std::queue< Tile * > > m_precacheRequests
Definition: tile_cache.h:85
void UnloadTexture(Tile *tile)
Definition: tile_cache.cpp:220
void SignalDeleteTexture(Tile *)
void LoadTextureSlot(Tile *)
Definition: tile_cache.cpp:87
void Load(Tile *tile)
Definition: tile_cache.cpp:97


multires_image
Author(s): Marc Alban
autogenerated on Thu Jun 6 2019 19:25:29