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_
multires_image::TileCache::CacheThread::CacheThread
CacheThread(TileCache *parent)
Definition: tile_cache.h:98
multires_image::TileCache::m_precacheRequestsLock
QMutex m_precacheRequestsLock
Definition: tile_cache.h:122
multires_image::TileCache::m_precacheRequestSet
std::map< int64_t, Tile * > m_precacheRequestSet
Definition: tile_cache.h:89
multires_image
Definition: multires_view_node.h:51
multires_image::TileCache::m_renderRequestSet
std::map< int64_t, Tile * > m_renderRequestSet
Definition: tile_cache.h:88
multires_image::TileCache::~TileCache
~TileCache(void)
Definition: tile_cache.cpp:80
multires_image::TileCache::CacheThread::run
virtual void run()
Definition: tile_cache.cpp:241
multires_image::TileCache::FreeThread::run
virtual void run()
Definition: tile_cache.cpp:358
multires_image::TileCache::PrecacheLayer
void PrecacheLayer(int layer, const tf::Point &position, int size)
Definition: tile_cache.cpp:149
multires_image::TileCache::FreeThread::p
TileCache * p
Definition: tile_cache.h:113
multires_image::Tile
Definition: tile.h:50
multires_image::TileCache::LoadTextureSlot
void LoadTextureSlot(Tile *)
Definition: tile_cache.cpp:87
multires_image::TileCache::Exit
void Exit()
Definition: tile_cache.cpp:189
multires_image::TileCache::SignalDeleteTexture
void SignalDeleteTexture(Tile *)
multires_image::TileCache::Precache
void Precache(const tf::Point &position)
Definition: tile_cache.cpp:125
multires_image::TileCache::m_renderRequestSetLock
QMutex m_renderRequestSetLock
Definition: tile_cache.h:121
multires_image::TileCache::CacheThread::p
TileCache * p
Definition: tile_cache.h:102
multires_image::TileCache::m_widget
QGLWidget * m_widget
Definition: tile_cache.h:79
tf::Point
tf::Vector3 Point
multires_image::TileCache::m_exit
bool m_exit
Definition: tile_cache.h:82
multires_image::TileCache::SignalLoadTexture
void SignalLoadTexture(Tile *)
multires_image::TileCache::m_currentPosition
tf::Point m_currentPosition
Definition: tile_cache.h:81
multires_image::TileCache::m_precacheRequests
std::vector< std::queue< Tile * > > m_precacheRequests
Definition: tile_cache.h:85
tile_set.h
multires_image::TileCache::m_renderRequestsLock
QMutex m_renderRequestsLock
Definition: tile_cache.h:120
multires_image::TileCache::m_currentLayer
int32_t m_currentLayer
Definition: tile_cache.h:80
multires_image::TileCache::DeleteTextureSlot
void DeleteTextureSlot(Tile *)
Definition: tile_cache.cpp:92
multires_image::TileCache::m_memorySize
int64_t m_memorySize
Definition: tile_cache.h:83
multires_image::TileCache::TileCache
TileCache(TileSet *tileSet, QGLWidget *widget)
Definition: tile_cache.cpp:47
multires_image::TileCache::m_cacheThread
CacheThread m_cacheThread
Definition: tile_cache.h:117
multires_image::TileCache::FreeThread::FreeThread
FreeThread(TileCache *parent)
Definition: tile_cache.h:109
multires_image::TileCache::LoadTexture
void LoadTexture(Tile *tile)
Definition: tile_cache.cpp:194
transform_datatypes.h
multires_image::TileCache::m_precacheRequestSetLock
QMutex m_precacheRequestSetLock
Definition: tile_cache.h:123
multires_image::TileCache::SetCurrentLayer
void SetCurrentLayer(int layer)
Definition: tile_cache.h:64
multires_image::TileCache::m_tileSet
TileSet * m_tileSet
Definition: tile_cache.h:78
multires_image::TileCache::m_textureLoadedLock
QMutex m_textureLoadedLock
Definition: tile_cache.h:124
multires_image::TileCache::CacheThread
Definition: tile_cache.h:95
multires_image::TileCache::UnloadTexture
void UnloadTexture(Tile *tile)
Definition: tile_cache.cpp:220
multires_image::TileCache::FreeThread
Definition: tile_cache.h:106
multires_image::TileCache::m_freeThread
FreeThread m_freeThread
Definition: tile_cache.h:118
multires_image::TileCache::m_textureLoaded
std::map< int64_t, Tile * > m_textureLoaded
Definition: tile_cache.h:87
tile.h
multires_image::TileCache::Load
void Load(Tile *tile)
Definition: tile_cache.cpp:97
multires_image::TileSet
Definition: tile_set.h:43
multires_image::TileCache::m_renderRequests
std::stack< Tile * > m_renderRequests
Definition: tile_cache.h:86
multires_image::TileCache
Definition: tile_cache.h:52
multires_image::TileCache::SignalMemorySize
void SignalMemorySize(int64_t)


multires_image
Author(s): Marc Alban
autogenerated on Sun Sep 8 2024 02:27:21