From 18ee90f0ed954598f598e9e059179493c42e71ad Mon Sep 17 00:00:00 2001 From: adrido Date: Thu, 2 Jul 2015 14:48:40 +0200 Subject: [PATCH] Improve Geometrymode (thanks to @Rogier-5) --- mainwindow.cpp | 47 +++++++++- mainwindow.h | 1 + mainwindow.ui | 248 +++++++++++++++++++++++++++---------------------- 3 files changed, 183 insertions(+), 113 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 910ff9f..40e989a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -16,6 +16,31 @@ static const QString qSettingsApplicationPrefix("Minetestmapper_"); static const QString qSettingsOrganisation("minetestmapper"); static const QString qSettingsApplicationPrefix(""); #endif +static QMap geometryGranularitySymbolic; +static QMap geometryGranularityNumeric; +static QMap geometrySizeModeSymbolic; +static QMap geometrySizeModeNumeric; +struct InitStatics { InitStatics(void); }; +static const InitStatics initStatics; + +InitStatics::InitStatics(void) +{ + int n = -1; + geometryGranularitySymbolic[n++] = "unspecified"; + geometryGranularitySymbolic[n++] = "pixel"; + geometryGranularitySymbolic[n++] = "block"; + for (int i = -1; i < n; i++) + geometryGranularityNumeric[geometryGranularitySymbolic[i]] = i; + + n = -1; + geometrySizeModeSymbolic[n++] = "auto"; + geometrySizeModeSymbolic[n++] = "auto"; + geometrySizeModeSymbolic[n++] = "fixed"; + geometrySizeModeSymbolic[n++] = "shrink"; + for (int i = -1; i < n; i++) + geometrySizeModeNumeric[geometrySizeModeSymbolic[i]] = i; +} + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -47,6 +72,16 @@ MainWindow::MainWindow(QWidget *parent) : ui->path_World->setCompleter(completer); } +void MainWindow::finishUiInitialisation(void) +{ + ui->geometrymode_granularity_group->setId(ui->geometrymode_pixel, geometryGranularityNumeric["pixel"]); + ui->geometrymode_granularity_group->setId(ui->geometrymode_block, geometryGranularityNumeric["block"]); + + ui->geometrymode_size_group->setId(ui->geometrymode_auto, geometrySizeModeNumeric["auto"]); + ui->geometrymode_size_group->setId(ui->geometrymode_fixed, geometrySizeModeNumeric["fixed"]); + ui->geometrymode_size_group->setId(ui->geometrymode_shrink, geometrySizeModeNumeric["shrink"]); +} + // we create the language menu entries dynamically, dependent on the existing translations. void MainWindow::createLanguageMenu(void) { @@ -644,7 +679,8 @@ void MainWindow::writeProfile(QString profile) settings.setValue("geometry",ui->geometry->text()); settings.setValue("minY",ui->minY->value()); settings.setValue("maxY",ui->maxY->value()); - //todo checkboxes + settings.setValue("geometry_granularity",geometryGranularitySymbolic[ui->geometrymode_granularity_group->checkedId()]); + settings.setValue("geometry_sizemode",geometrySizeModeSymbolic[ui->geometrymode_size_group->checkedId()]); //tab3 heightmap settings.setValue("generateHeightmap",ui->generateHeightmap->isChecked()); @@ -717,7 +753,14 @@ void MainWindow::readProfile(QString profile) ui->checkBox_minY->setChecked(settings.value("checkBox_minY",false).toBool()); ui->maxY->setValue(settings.value("maxY",0).toInt()); ui->minY->setValue(settings.value("minY",0).toInt()); - //todo geometriemode + QString granularity = settings.value("geometry_granularity").toString(); + if (geometryGranularityNumeric.find(granularity) != geometryGranularityNumeric.end()) + ui->geometrymode_granularity_group->button(geometryGranularityNumeric[granularity])->setChecked(true); + // Else post a warning message ?? + QString sizemode = settings.value("geometry_sizemode").toString(); + if (geometrySizeModeNumeric.find(sizemode) != geometrySizeModeNumeric.end()) + ui->geometrymode_size_group->button(geometrySizeModeNumeric[granularity])->setChecked(true); + // Else post a warning message ?? //tab3 Heightmap ui->generateHeightmap->setChecked(settings.value("generateHeightmap",false).toBool()); diff --git a/mainwindow.h b/mainwindow.h index fecea06..7fdbb2b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -93,6 +93,7 @@ private: QWinTaskbarButton *taskbarButton; QWinTaskbarProgress *taskbarProgress; #endif + void finishUiInitialisation(void); // loads a language by the given language shortcur (e.g. de, en) void loadLanguage(const QString& rLanguage); diff --git a/mainwindow.ui b/mainwindow.ui index b7f3c58..04f656d 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -198,50 +198,7 @@ Map-Limit - - - - The requested geometry will be extended so that the map does not contain partial map blocks (of 16x16 nodes each). At least all pixels covered by the geometry will be in the map, but there may be up to 15 more in every direction. - - - round the coodinates to a multiple of 16. - - - block - - - - - - - min-Y - - - - - - - A map of exactly the requested size is generated (after adjustments due to the 'shrink' flag, or possible adjustments required by the scale factor). - - - interpret the coordinates with pixel granularity. - - - pixel - - - - - - - Specify the upper height limit for the map - - - max-Y - - - - + Qt::Vertical @@ -254,20 +211,24 @@ - - - - Currently, shrinking is done with block granularity, and based on which blocks are in the database. As the database always contains a row or and column of empty, or partially empty blocks at the map edges, there will still be empty pixels at the edges of the map. Use --blockcolor to visualize these empty blocks. - - - Generate a map of at most the requested geometry. Shrink it to the smallest possible size that still includes the same information. - + + - shrink + min-Y - + + + + Specify the upper height limit for the map + + + max-Y + + + + false @@ -286,17 +247,14 @@ - - + + - - - - e.g. -200,-100:200,200 + geometry - + 1:1 @@ -335,34 +293,14 @@ - - - - NOTE: If this flag is used, and no actual geometry is specified, this would result in a maximum-size map (65536 x 65536), which is currently not possible, and will fail, due to a bug in the drawing library. - - - don't reduce the map size. What ever is specified using a geometry option, is what will be draw, even if partly or fully empty. - - - fixed - - - - - - - geometry - - - - + geometrymode - + false @@ -381,10 +319,110 @@ - - + + + + + + auto + + + true + + + geometrymode_size_group + + + + + + + The requested geometry will be extended so that the map does not contain partial map blocks (of 16x16 nodes each). At least all pixels covered by the geometry will be in the map, but there may be up to 15 more in every direction. + + + round the coodinates to a multiple of 16. + + + block + + + geometrymode_granularity_group + + + + + + + Currently, shrinking is done with block granularity, and based on which blocks are in the database. As the database always contains a row or and column of empty, or partially empty blocks at the map edges, there will still be empty pixels at the edges of the map. Use --blockcolor to visualize these empty blocks. + + + Generate a map of at most the requested geometry. Shrink it to the smallest possible size that still includes the same information. + + + shrink + + + geometrymode_size_group + + + + + + + NOTE: If this flag is used, and no actual geometry is specified, this would result in a maximum-size map (65536 x 65536), which is currently not possible, and will fail, due to a bug in the drawing library. + + + don't reduce the map size. What ever is specified using a geometry option, is what will be draw, even if partly or fully empty. + + + fixed + + + geometrymode_size_group + + + + + + + A map of exactly the requested size is generated (after adjustments due to the 'shrink' flag, or possible adjustments required by the scale factor). + + + interpret the coordinates with pixel granularity. + + + pixel + + + true + + + geometrymode_granularity_group + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + - <html><head/><body><p><a href="geometry-syntax"><span style=" text-decoration: underline; color:#0000ff;">help</span></a></p></body></html> + + + + e.g. -200,-100:200,200 @@ -2616,7 +2654,7 @@ p, li { white-space: pre-wrap; } -1 - 528 + 414 141 @@ -2660,12 +2698,12 @@ p, li { white-space: pre-wrap; } setEnabled(bool) - 63 - 164 + 74 + 206 - 166 - 166 + 224 + 208 @@ -2676,12 +2714,12 @@ p, li { white-space: pre-wrap; } setEnabled(bool) - 73 - 190 + 84 + 232 - 167 - 192 + 225 + 234 @@ -2781,22 +2819,6 @@ p, li { white-space: pre-wrap; } - - label_3 - linkActivated(QString) - helpBrowser - scrollToAnchor(QString) - - - 533 - 131 - - - 603 - 136 - - - pushButton_2 clicked() @@ -2926,4 +2948,8 @@ p, li { white-space: pre-wrap; } + + + +