Improve Geometrymode (thanks to @Rogier-5)

master
adrido 2015-07-02 14:48:40 +02:00
parent ead7343e8b
commit 18ee90f0ed
3 changed files with 183 additions and 113 deletions

View File

@ -16,6 +16,31 @@ static const QString qSettingsApplicationPrefix("Minetestmapper_");
static const QString qSettingsOrganisation("minetestmapper"); static const QString qSettingsOrganisation("minetestmapper");
static const QString qSettingsApplicationPrefix(""); static const QString qSettingsApplicationPrefix("");
#endif #endif
static QMap<int, QString> geometryGranularitySymbolic;
static QMap<QString, int> geometryGranularityNumeric;
static QMap<int, QString> geometrySizeModeSymbolic;
static QMap<QString, int> 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) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
@ -47,6 +72,16 @@ MainWindow::MainWindow(QWidget *parent) :
ui->path_World->setCompleter(completer); 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. // we create the language menu entries dynamically, dependent on the existing translations.
void MainWindow::createLanguageMenu(void) void MainWindow::createLanguageMenu(void)
{ {
@ -644,7 +679,8 @@ void MainWindow::writeProfile(QString profile)
settings.setValue("geometry",ui->geometry->text()); settings.setValue("geometry",ui->geometry->text());
settings.setValue("minY",ui->minY->value()); settings.setValue("minY",ui->minY->value());
settings.setValue("maxY",ui->maxY->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 //tab3 heightmap
settings.setValue("generateHeightmap",ui->generateHeightmap->isChecked()); 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->checkBox_minY->setChecked(settings.value("checkBox_minY",false).toBool());
ui->maxY->setValue(settings.value("maxY",0).toInt()); ui->maxY->setValue(settings.value("maxY",0).toInt());
ui->minY->setValue(settings.value("minY",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 //tab3 Heightmap
ui->generateHeightmap->setChecked(settings.value("generateHeightmap",false).toBool()); ui->generateHeightmap->setChecked(settings.value("generateHeightmap",false).toBool());

View File

@ -93,6 +93,7 @@ private:
QWinTaskbarButton *taskbarButton; QWinTaskbarButton *taskbarButton;
QWinTaskbarProgress *taskbarProgress; QWinTaskbarProgress *taskbarProgress;
#endif #endif
void finishUiInitialisation(void);
// loads a language by the given language shortcur (e.g. de, en) // loads a language by the given language shortcur (e.g. de, en)
void loadLanguage(const QString& rLanguage); void loadLanguage(const QString& rLanguage);

View File

@ -198,50 +198,7 @@
<string>Map-Limit</string> <string>Map-Limit</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_8"> <layout class="QGridLayout" name="gridLayout_8">
<item row="6" column="2"> <item row="11" column="4">
<widget class="QCheckBox" name="geometrymode_block">
<property name="toolTip">
<string>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.</string>
</property>
<property name="statusTip">
<string>round the coodinates to a multiple of 16.</string>
</property>
<property name="text">
<string>block</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_minY">
<property name="text">
<string>min-Y</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QCheckBox" name="geometrymode_pixel">
<property name="toolTip">
<string>A map of exactly the requested size is generated (after adjustments due to the 'shrink' flag, or possible adjustments required by the scale factor).</string>
</property>
<property name="statusTip">
<string>interpret the coordinates with pixel granularity.</string>
</property>
<property name="text">
<string>pixel</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox_maxY">
<property name="statusTip">
<string>Specify the upper height limit for the map</string>
</property>
<property name="text">
<string>max-Y</string>
</property>
</widget>
</item>
<item row="9" column="2">
<spacer name="verticalSpacer_5"> <spacer name="verticalSpacer_5">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -254,20 +211,24 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="7" column="2"> <item row="4" column="0">
<widget class="QCheckBox" name="geometrymode_shrink"> <widget class="QCheckBox" name="checkBox_minY">
<property name="toolTip">
<string>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.</string>
</property>
<property name="statusTip">
<string>Generate a map of at most the requested geometry. Shrink it to the smallest possible size that still includes the same information.</string>
</property>
<property name="text"> <property name="text">
<string>shrink</string> <string>min-Y</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="5" column="0">
<widget class="QCheckBox" name="checkBox_maxY">
<property name="statusTip">
<string>Specify the upper height limit for the map</string>
</property>
<property name="text">
<string>max-Y</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QSpinBox" name="minY"> <widget class="QSpinBox" name="minY">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -286,17 +247,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="0">
<widget class="QLineEdit" name="geometry"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string notr="true"/> <string>geometry</string>
</property>
<property name="placeholderText">
<string>e.g. -200,-100:200,200</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="4">
<widget class="QComboBox" name="scalefactor"> <widget class="QComboBox" name="scalefactor">
<property name="currentText"> <property name="currentText">
<string notr="true">1:1</string> <string notr="true">1:1</string>
@ -335,34 +293,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="2"> <item row="6" column="0">
<widget class="QCheckBox" name="geometrymode_fixed">
<property name="toolTip">
<string>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.</string>
</property>
<property name="statusTip">
<string>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.</string>
</property>
<property name="text">
<string>fixed</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>geometry</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
<string>geometrymode</string> <string>geometrymode</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="2"> <item row="5" column="4">
<widget class="QSpinBox" name="maxY"> <widget class="QSpinBox" name="maxY">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -381,10 +319,110 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="6" column="4" rowspan="2">
<widget class="QLabel" name="label_3"> <layout class="QGridLayout" name="gridLayout_10">
<item row="1" column="0">
<widget class="QRadioButton" name="geometrymode_auto">
<property name="text">
<string>auto</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">geometrymode_size_group</string>
</attribute>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="geometrymode_block">
<property name="toolTip">
<string>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.</string>
</property>
<property name="statusTip">
<string>round the coodinates to a multiple of 16.</string>
</property>
<property name="text">
<string>block</string>
</property>
<attribute name="buttonGroup">
<string notr="true">geometrymode_granularity_group</string>
</attribute>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="geometrymode_shrink">
<property name="toolTip">
<string>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.</string>
</property>
<property name="statusTip">
<string>Generate a map of at most the requested geometry. Shrink it to the smallest possible size that still includes the same information.</string>
</property>
<property name="text">
<string>shrink</string>
</property>
<attribute name="buttonGroup">
<string notr="true">geometrymode_size_group</string>
</attribute>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="geometrymode_fixed">
<property name="toolTip">
<string>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.</string>
</property>
<property name="statusTip">
<string>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.</string>
</property>
<property name="text">
<string>fixed</string>
</property>
<attribute name="buttonGroup">
<string notr="true">geometrymode_size_group</string>
</attribute>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="geometrymode_pixel">
<property name="toolTip">
<string>A map of exactly the requested size is generated (after adjustments due to the 'shrink' flag, or possible adjustments required by the scale factor).</string>
</property>
<property name="statusTip">
<string>interpret the coordinates with pixel granularity.</string>
</property>
<property name="text">
<string>pixel</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">geometrymode_granularity_group</string>
</attribute>
</widget>
</item>
<item row="1" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="4">
<widget class="QLineEdit" name="geometry">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;geometry-syntax&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;help&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string notr="true"/>
</property>
<property name="placeholderText">
<string>e.g. -200,-100:200,200</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -2616,7 +2654,7 @@ p, li { white-space: pre-wrap; }
<y>-1</y> <y>-1</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>528</x> <x>414</x>
<y>141</y> <y>141</y>
</hint> </hint>
</hints> </hints>
@ -2660,12 +2698,12 @@ p, li { white-space: pre-wrap; }
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>63</x> <x>74</x>
<y>164</y> <y>206</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>166</x> <x>224</x>
<y>166</y> <y>208</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -2676,12 +2714,12 @@ p, li { white-space: pre-wrap; }
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>73</x> <x>84</x>
<y>190</y> <y>232</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>167</x> <x>225</x>
<y>192</y> <y>234</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -2781,22 +2819,6 @@ p, li { white-space: pre-wrap; }
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>label_3</sender>
<signal>linkActivated(QString)</signal>
<receiver>helpBrowser</receiver>
<slot>scrollToAnchor(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>533</x>
<y>131</y>
</hint>
<hint type="destinationlabel">
<x>603</x>
<y>136</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>pushButton_2</sender> <sender>pushButton_2</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
@ -2926,4 +2948,8 @@ p, li { white-space: pre-wrap; }
</hints> </hints>
</connection> </connection>
</connections> </connections>
<buttongroups>
<buttongroup name="geometrymode_size_group"/>
<buttongroup name="geometrymode_granularity_group"/>
</buttongroups>
</ui> </ui>