From f625b33d56f6a0ce98f03a24bf6cad8b5624ce07 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 3 Oct 2014 12:33:03 +0200 Subject: QtBiomeVisualiser: Zoom is now limited and aligned to steps. --- Tools/QtBiomeVisualiser/MainWindow.cpp | 107 +++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) (limited to 'Tools/QtBiomeVisualiser/MainWindow.cpp') diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp index eb45690c1..25a88d442 100644 --- a/Tools/QtBiomeVisualiser/MainWindow.cpp +++ b/Tools/QtBiomeVisualiser/MainWindow.cpp @@ -18,6 +18,15 @@ +const double MainWindow::m_ViewZooms[] = +{ + 0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16, 24, +}; + + + + + MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent), m_GeneratorSetup(nullptr), @@ -26,6 +35,11 @@ MainWindow::MainWindow(QWidget * parent) : initMinecraftPath(); m_BiomeView = new BiomeView(); + connect(m_BiomeView, SIGNAL(increaseZoom()), this, SLOT(increaseZoom())); + connect(m_BiomeView, SIGNAL(decreaseZoom()), this, SLOT(decreaseZoom())); + connect(m_BiomeView, SIGNAL(wheelUp()), this, SLOT(increaseZoom())); + connect(m_BiomeView, SIGNAL(wheelDown()), this, SLOT(decreaseZoom())); + m_MainLayout = new QHBoxLayout(); m_MainLayout->addWidget(m_BiomeView, 1); m_MainLayout->setMenuBar(menuBar()); @@ -129,6 +143,68 @@ void MainWindow::openVanillaWorld() +void MainWindow::centerView() +{ + m_BiomeView->setPosition(0, 0); +} + + + + + +void MainWindow::setViewZoom() +{ + // The zoom level is stored in the sender action's data, retrieve it: + QAction * action = qobject_cast(sender()); + if (action == nullptr) + { + return; + } + double newZoom = m_ViewZooms[action->data().toInt()]; + m_BiomeView->setZoomLevel(newZoom); + action->setChecked(true); +} + + + + + +void MainWindow::increaseZoom() +{ + // If already at max zoom, bail out: + if (m_CurrentZoomLevel >= ARRAYCOUNT(m_ViewZooms) - 1) + { + return; + } + + // Increase the zoom level: + m_CurrentZoomLevel += 1; + m_actViewZoom[m_CurrentZoomLevel]->setChecked(true); + m_BiomeView->setZoomLevel(m_ViewZooms[m_CurrentZoomLevel]); +} + + + + + +void MainWindow::decreaseZoom() +{ + // If already at min zoom, bail out: + if (m_CurrentZoomLevel == 0) + { + return; + } + + // Decrease the zoom level: + m_CurrentZoomLevel -= 1; + m_actViewZoom[m_CurrentZoomLevel]->setChecked(true); + m_BiomeView->setZoomLevel(m_ViewZooms[m_CurrentZoomLevel]); +} + + + + + void MainWindow::initMinecraftPath() { #ifdef Q_OS_MAC @@ -147,6 +223,7 @@ void MainWindow::initMinecraftPath() void MainWindow::createActions() { + // Map menu: createWorldActions(); m_actNewGen = new QAction(tr("&New generator"), this); @@ -173,6 +250,26 @@ void MainWindow::createActions() m_actExit->setShortcut(tr("Alt+X")); m_actExit->setStatusTip(tr("Exit %1").arg(QApplication::instance()->applicationName())); connect(m_actExit, SIGNAL(triggered()), this, SLOT(close())); + + // View menu: + m_actViewCenter = new QAction(tr("&Reset to center"), this); + m_actViewCenter->setStatusTip(tr("Scrolls the view back to the map center")); + connect(m_actViewCenter, SIGNAL(triggered()), this, SLOT(centerView())); + + QActionGroup * zoomGroup = new QActionGroup(this); + for (int i = 0; i < ARRAYCOUNT(m_ViewZooms); i++) + { + m_actViewZoom[i] = new QAction(tr("&Zoom %1%").arg(std::floor(m_ViewZooms[i] * 100)), this); + m_actViewZoom[i]->setCheckable(true); + if ((int)(m_ViewZooms[i] * 16) == 16) + { + m_actViewZoom[i]->setChecked(true); + m_CurrentZoomLevel = i; + } + m_actViewZoom[i]->setData(QVariant(i)); + zoomGroup->addAction(m_actViewZoom[i]); + connect(m_actViewZoom[i], SIGNAL(triggered()), this, SLOT(setViewZoom())); + } } @@ -220,6 +317,7 @@ void MainWindow::createWorldActions() void MainWindow::createMenus() { + // Map menu: QMenu * file = menuBar()->addMenu(tr("&Map")); file->addAction(m_actNewGen); file->addAction(m_actOpenGen); @@ -235,6 +333,15 @@ void MainWindow::createMenus() file->addAction(m_actReload); file->addSeparator(); file->addAction(m_actExit); + + // View menu: + QMenu * view = menuBar()->addMenu(tr("&View")); + view->addAction(m_actViewCenter); + view->addSeparator(); + for (size_t i = 0; i < ARRAYCOUNT(m_actViewZoom); i++) + { + view->addAction(m_actViewZoom[i]); + } } -- cgit v1.2.3 From 0aa1b5667e0ba97101f60343323c595cc7866c6d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 3 Oct 2014 19:41:42 +0200 Subject: QtBiomeVisualiser: Added mouse hover info. --- Tools/QtBiomeVisualiser/MainWindow.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'Tools/QtBiomeVisualiser/MainWindow.cpp') diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp index 25a88d442..63d72f992 100644 --- a/Tools/QtBiomeVisualiser/MainWindow.cpp +++ b/Tools/QtBiomeVisualiser/MainWindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "inifile/iniFile.h" #include "ChunkSource.h" #include "src/Generating/BioGen.h" @@ -40,6 +41,15 @@ MainWindow::MainWindow(QWidget * parent) : connect(m_BiomeView, SIGNAL(wheelUp()), this, SLOT(increaseZoom())); connect(m_BiomeView, SIGNAL(wheelDown()), this, SLOT(decreaseZoom())); + m_StatusBar = new QStatusBar(); + this->setStatusBar(m_StatusBar); + m_StatusBlockX = new QLabel(tr("X")); + m_StatusBlockZ = new QLabel(tr("Z")); + m_StatusBiome = new QLabel(tr("B")); + m_StatusBar->addPermanentWidget(m_StatusBlockX); + m_StatusBar->addPermanentWidget(m_StatusBlockZ); + m_StatusBar->addPermanentWidget(m_StatusBiome); + m_MainLayout = new QHBoxLayout(); m_MainLayout->addWidget(m_BiomeView, 1); m_MainLayout->setMenuBar(menuBar()); @@ -50,6 +60,8 @@ MainWindow::MainWindow(QWidget * parent) : createActions(); createMenus(); + + connect(m_BiomeView, SIGNAL(hoverChanged(int, int, int)), this, SLOT(hoverChanged(int, int, int))); } @@ -205,6 +217,17 @@ void MainWindow::decreaseZoom() +void MainWindow::hoverChanged(int a_BlockX, int a_BlockZ, int a_Biome) +{ + m_StatusBlockX->setText(tr("X: %1").arg(a_BlockX)); + m_StatusBlockZ->setText(tr("Z: %1").arg(a_BlockZ)); + m_StatusBiome->setText (tr("B: %1 (%2)").arg(BiomeToString(a_Biome).c_str()).arg(a_Biome)); +} + + + + + void MainWindow::initMinecraftPath() { #ifdef Q_OS_MAC @@ -322,7 +345,7 @@ void MainWindow::createMenus() file->addAction(m_actNewGen); file->addAction(m_actOpenGen); file->addSeparator(); - QMenu * worlds = file->addMenu(tr("Open existing")); + QMenu * worlds = file->addMenu(tr("Open &existing")); worlds->addActions(m_WorldActions); if (m_WorldActions.empty()) { -- cgit v1.2.3 From 298be25413b9d2f48b1071385a52a55d37d86857 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 23 Oct 2014 15:29:02 +0200 Subject: QtBiomeVisualiser: Moved the IniFile lib. --- Tools/QtBiomeVisualiser/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Tools/QtBiomeVisualiser/MainWindow.cpp') diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp index 63d72f992..7853d768e 100644 --- a/Tools/QtBiomeVisualiser/MainWindow.cpp +++ b/Tools/QtBiomeVisualiser/MainWindow.cpp @@ -8,7 +8,7 @@ #include #include #include -#include "inifile/iniFile.h" +#include "src/IniFile.h" #include "ChunkSource.h" #include "src/Generating/BioGen.h" #include "src/StringCompression.h" -- cgit v1.2.3 From c53b7e5d38c24bce7ba55abf3060ffd012783086 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 27 Oct 2014 23:58:09 +0100 Subject: QtBiomeVisualiser: Switched caching to entire regions. This speeds up the rendering preparation for small zooms. --- Tools/QtBiomeVisualiser/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Tools/QtBiomeVisualiser/MainWindow.cpp') diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp index 7853d768e..dc26a32c7 100644 --- a/Tools/QtBiomeVisualiser/MainWindow.cpp +++ b/Tools/QtBiomeVisualiser/MainWindow.cpp @@ -8,8 +8,8 @@ #include #include #include -#include "src/IniFile.h" #include "ChunkSource.h" +#include "src/IniFile.h" #include "src/Generating/BioGen.h" #include "src/StringCompression.h" #include "src/WorldStorage/FastNBT.h" -- cgit v1.2.3 From 3168a95404c6232dd937aeeb2fdeade21239521b Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 28 Oct 2014 22:15:42 +0100 Subject: QtBiomeVisualiser: Fixed mouse zoom vs menu zoom. --- Tools/QtBiomeVisualiser/MainWindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Tools/QtBiomeVisualiser/MainWindow.cpp') diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp index dc26a32c7..4437d9ceb 100644 --- a/Tools/QtBiomeVisualiser/MainWindow.cpp +++ b/Tools/QtBiomeVisualiser/MainWindow.cpp @@ -172,7 +172,8 @@ void MainWindow::setViewZoom() { return; } - double newZoom = m_ViewZooms[action->data().toInt()]; + m_CurrentZoomLevel = action->data().toInt(); + double newZoom = m_ViewZooms[m_CurrentZoomLevel]; m_BiomeView->setZoomLevel(newZoom); action->setChecked(true); } -- cgit v1.2.3 From 48ac3acc84274fe8d0bf3af30fb47c6729b07147 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 28 Oct 2014 22:19:24 +0100 Subject: QtBiomeVisualiser: Added quick shutdown to region loaders. Now the app shuts down immediately even if regions are queued for loading. --- Tools/QtBiomeVisualiser/MainWindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Tools/QtBiomeVisualiser/MainWindow.cpp') diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp index 4437d9ceb..e6e951b60 100644 --- a/Tools/QtBiomeVisualiser/MainWindow.cpp +++ b/Tools/QtBiomeVisualiser/MainWindow.cpp @@ -14,6 +14,7 @@ #include "src/StringCompression.h" #include "src/WorldStorage/FastNBT.h" #include "GeneratorSetup.h" +#include "RegionLoader.h" @@ -70,7 +71,7 @@ MainWindow::MainWindow(QWidget * parent) : MainWindow::~MainWindow() { - + RegionLoader::shutdown(); } -- cgit v1.2.3 From f25e268ca0641362dac80c0095730b2f17839607 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 30 Oct 2014 16:54:23 +0100 Subject: QtBiomeVisualiser: Set start zoom to 25%, just like AMIDST. --- Tools/QtBiomeVisualiser/MainWindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Tools/QtBiomeVisualiser/MainWindow.cpp') diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp index e6e951b60..481e49cea 100644 --- a/Tools/QtBiomeVisualiser/MainWindow.cpp +++ b/Tools/QtBiomeVisualiser/MainWindow.cpp @@ -32,7 +32,8 @@ const double MainWindow::m_ViewZooms[] = MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent), m_GeneratorSetup(nullptr), - m_LineSeparator(nullptr) + m_LineSeparator(nullptr), + m_CurrentZoomLevel(2) { initMinecraftPath(); @@ -41,6 +42,7 @@ MainWindow::MainWindow(QWidget * parent) : connect(m_BiomeView, SIGNAL(decreaseZoom()), this, SLOT(decreaseZoom())); connect(m_BiomeView, SIGNAL(wheelUp()), this, SLOT(increaseZoom())); connect(m_BiomeView, SIGNAL(wheelDown()), this, SLOT(decreaseZoom())); + m_BiomeView->setZoomLevel(m_ViewZooms[m_CurrentZoomLevel]); m_StatusBar = new QStatusBar(); this->setStatusBar(m_StatusBar); -- cgit v1.2.3 From c6e8da893e5ccb87555563941d5b4100e370e385 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 31 Oct 2014 12:26:12 +0100 Subject: QtBiomeVisualiser: Fixed default zoom selection. --- Tools/QtBiomeVisualiser/MainWindow.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'Tools/QtBiomeVisualiser/MainWindow.cpp') diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp index 481e49cea..c6ea8656e 100644 --- a/Tools/QtBiomeVisualiser/MainWindow.cpp +++ b/Tools/QtBiomeVisualiser/MainWindow.cpp @@ -288,15 +288,11 @@ void MainWindow::createActions() { m_actViewZoom[i] = new QAction(tr("&Zoom %1%").arg(std::floor(m_ViewZooms[i] * 100)), this); m_actViewZoom[i]->setCheckable(true); - if ((int)(m_ViewZooms[i] * 16) == 16) - { - m_actViewZoom[i]->setChecked(true); - m_CurrentZoomLevel = i; - } m_actViewZoom[i]->setData(QVariant(i)); zoomGroup->addAction(m_actViewZoom[i]); connect(m_actViewZoom[i], SIGNAL(triggered()), this, SLOT(setViewZoom())); } + m_actViewZoom[m_CurrentZoomLevel]->setChecked(true); } -- cgit v1.2.3