summaryrefslogtreecommitdiffstats
path: root/Tools/QtBiomeVisualiser
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-09-15 17:29:34 +0200
committerMattes D <github@xoft.cz>2014-09-15 17:29:34 +0200
commit21b70f17c264de4f7c216cfca580e8254df5cbee (patch)
treeab513d7146904bfdfa88943c787548311997cfdd /Tools/QtBiomeVisualiser
parentQtBiomeVisualiser: removed multithreading. (diff)
downloadcuberite-21b70f17c264de4f7c216cfca580e8254df5cbee.tar
cuberite-21b70f17c264de4f7c216cfca580e8254df5cbee.tar.gz
cuberite-21b70f17c264de4f7c216cfca580e8254df5cbee.tar.bz2
cuberite-21b70f17c264de4f7c216cfca580e8254df5cbee.tar.lz
cuberite-21b70f17c264de4f7c216cfca580e8254df5cbee.tar.xz
cuberite-21b70f17c264de4f7c216cfca580e8254df5cbee.tar.zst
cuberite-21b70f17c264de4f7c216cfca580e8254df5cbee.zip
Diffstat (limited to 'Tools/QtBiomeVisualiser')
-rw-r--r--Tools/QtBiomeVisualiser/BiomeView.cpp15
-rw-r--r--Tools/QtBiomeVisualiser/BiomeView.h3
-rw-r--r--Tools/QtBiomeVisualiser/ChunkCache.cpp16
-rw-r--r--Tools/QtBiomeVisualiser/ChunkCache.h5
-rw-r--r--Tools/QtBiomeVisualiser/MainWindow.cpp13
-rw-r--r--Tools/QtBiomeVisualiser/MainWindow.h1
6 files changed, 49 insertions, 4 deletions
diff --git a/Tools/QtBiomeVisualiser/BiomeView.cpp b/Tools/QtBiomeVisualiser/BiomeView.cpp
index 671942440..bbaccb369 100644
--- a/Tools/QtBiomeVisualiser/BiomeView.cpp
+++ b/Tools/QtBiomeVisualiser/BiomeView.cpp
@@ -131,6 +131,21 @@ void BiomeView::chunkAvailable(int a_ChunkX, int a_ChunkZ)
+void BiomeView::reload()
+{
+ if (!hasData())
+ {
+ return;
+ }
+ m_Cache.reload();
+
+ redraw();
+}
+
+
+
+
+
void BiomeView::drawChunk(int a_ChunkX, int a_ChunkZ)
{
if (!hasData())
diff --git a/Tools/QtBiomeVisualiser/BiomeView.h b/Tools/QtBiomeVisualiser/BiomeView.h
index 61bda45c2..86af8bcaf 100644
--- a/Tools/QtBiomeVisualiser/BiomeView.h
+++ b/Tools/QtBiomeVisualiser/BiomeView.h
@@ -33,6 +33,9 @@ public slots:
/** A specified chunk has become available, redraw it. */
void chunkAvailable(int a_ChunkX, int a_ChunkZ);
+ /** Reloads the current chunk source and redraws the entire workspace. */
+ void reload();
+
protected:
double m_X, m_Z;
double m_Zoom;
diff --git a/Tools/QtBiomeVisualiser/ChunkCache.cpp b/Tools/QtBiomeVisualiser/ChunkCache.cpp
index b2230def0..05c267d30 100644
--- a/Tools/QtBiomeVisualiser/ChunkCache.cpp
+++ b/Tools/QtBiomeVisualiser/ChunkCache.cpp
@@ -76,6 +76,22 @@ void ChunkCache::setChunkSource(std::shared_ptr<ChunkSource> a_ChunkSource)
+void ChunkCache::reload()
+{
+ assert(m_ChunkSource.get() != nullptr);
+
+ // Reload the chunk source:
+ m_ChunkSource->reload();
+
+ // Clear the cache:
+ QMutexLocker lock(&m_Mtx);
+ m_Cache.clear();
+}
+
+
+
+
+
void ChunkCache::gotChunk(int a_ChunkX, int a_ChunkZ)
{
emit chunkAvailable(a_ChunkX, a_ChunkZ);
diff --git a/Tools/QtBiomeVisualiser/ChunkCache.h b/Tools/QtBiomeVisualiser/ChunkCache.h
index 0efa7fc39..0134bc7af 100644
--- a/Tools/QtBiomeVisualiser/ChunkCache.h
+++ b/Tools/QtBiomeVisualiser/ChunkCache.h
@@ -36,7 +36,10 @@ public:
void setChunkSource(std::shared_ptr<ChunkSource> a_ChunkSource);
/** Returns true iff the chunk source has been initialized. */
- bool hasData(void) const { return (m_ChunkSource.get() != nullptr); }
+ bool hasData() const { return (m_ChunkSource.get() != nullptr); }
+
+ /** Reloads the current chunk source. */
+ void reload();
signals:
void chunkAvailable(int a_ChunkX, int a_ChunkZ);
diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp
index 21fb1a0c0..65d0ccf5e 100644
--- a/Tools/QtBiomeVisualiser/MainWindow.cpp
+++ b/Tools/QtBiomeVisualiser/MainWindow.cpp
@@ -16,11 +16,11 @@
MainWindow::MainWindow(QWidget * parent) :
QMainWindow(parent)
{
- createActions();
- createMenus();
-
m_BiomeView = new BiomeView(this);
setCentralWidget(m_BiomeView);
+
+ createActions();
+ createMenus();
}
@@ -68,6 +68,11 @@ void MainWindow::createActions()
m_actOpen->setStatusTip(tr("Open an existing world and display its biomes"));
connect(m_actOpen, SIGNAL(triggered()), this, SLOT(open()));
+ m_actReload = new QAction(tr("&Reload"), this);
+ m_actReload->setShortcut(tr("F5"));
+ m_actReload->setStatusTip(tr("Open an existing world and display its biomes"));
+ connect(m_actReload, SIGNAL(triggered()), m_BiomeView, SLOT(reload()));
+
m_actExit = new QAction(tr("E&xit"), this);
m_actExit->setShortcut(tr("Alt+X"));
m_actExit->setStatusTip(tr("Exit %1").arg(QApplication::instance()->applicationName()));
@@ -84,6 +89,8 @@ void MainWindow::createMenus()
mFile->addAction(m_actGen);
mFile->addAction(m_actOpen);
mFile->addSeparator();
+ mFile->addAction(m_actReload);
+ mFile->addSeparator();
mFile->addAction(m_actExit);
}
diff --git a/Tools/QtBiomeVisualiser/MainWindow.h b/Tools/QtBiomeVisualiser/MainWindow.h
index f6028aff1..b37bf4120 100644
--- a/Tools/QtBiomeVisualiser/MainWindow.h
+++ b/Tools/QtBiomeVisualiser/MainWindow.h
@@ -29,6 +29,7 @@ protected:
// Actions:
QAction * m_actGen;
QAction * m_actOpen;
+ QAction * m_actReload;
QAction * m_actExit;