Allow setting geometry manually as well
parent
15ef6d529e
commit
180956b044
|
@ -6,6 +6,11 @@
|
|||
QMap<Geometry::Format, QString> Geometry::geometryIdNameMap;
|
||||
QMap<QString, Geometry::Format> Geometry::geometryNameIdMap;
|
||||
|
||||
Geometry::InitStatics::InitStatics()
|
||||
{
|
||||
### Complete
|
||||
}
|
||||
|
||||
bool Geometry::set(const char *s)
|
||||
{
|
||||
char sign[2];
|
||||
|
@ -70,7 +75,8 @@ bool Geometry::set(const char *s)
|
|||
//todo select correct dropdown entry in widget
|
||||
}
|
||||
else {
|
||||
//GeometryWidget::setFormat(FormatNone);
|
||||
ui->geometry_FormatCustom->setText(s);
|
||||
//GeometryWidget::setFormat(FormatCustom);
|
||||
//todo
|
||||
return false;
|
||||
|
||||
|
@ -145,16 +151,15 @@ QString Geometry::getString(Geometry::Format format)
|
|||
switch (format) {
|
||||
case CenterDimensions:
|
||||
n = snprintf(buffer, BUFSIZE, "%d,%d:%dx%d", center[0], center[1], dimension[0], dimension[1]);
|
||||
//search alternative for snptintf
|
||||
break;
|
||||
case CornerDimensions:
|
||||
n = snprintf(buffer, BUFSIZE, "%d,%d+%d+%d", corner[0][0], corner[0][1], dimension[0], dimension[1]);
|
||||
//search alternative for snptintf
|
||||
break;
|
||||
case FormatCustom:
|
||||
return ui->geometry_FormatCustom->text();
|
||||
case Corners:
|
||||
default:
|
||||
n = snprintf(buffer, BUFSIZE, "%d,%d:%d,%d", corner[0][0], corner[0][1], corner[1][0], corner[1][1]);
|
||||
//search alternative for snptintf
|
||||
break;
|
||||
}
|
||||
if (n > 0 && n < BUFSIZE)
|
||||
|
@ -238,17 +243,22 @@ GeometryWidget::~GeometryWidget()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void GeometryWidget::set(const QString gstr)
|
||||
// Return true when parsing succeeded
|
||||
// false when not (string was still accepted, mode was set to custom)
|
||||
bool GeometryWidget::_set(const char *gstr)
|
||||
{
|
||||
Geometry g;
|
||||
if (gstr=="") {
|
||||
bool result = true;
|
||||
if (!gstr || !*gstr) {
|
||||
g.setMax();
|
||||
}
|
||||
else if (!g.set(gstr)) {
|
||||
result = false;
|
||||
// TODO (??): verify if string contains '#' or '.' - if not, the problem is serious...
|
||||
####### Move this to mainwindow...
|
||||
QMessageBox::warning(this, tr("Failure Loading Settings"),
|
||||
tr("WARNING: Failed to parse the geometry string<br>"
|
||||
"geometry string: <i>%1</i>").arg(gstr));
|
||||
g.setMax();
|
||||
}
|
||||
for (int i=0; i<2; i++) {
|
||||
setQWidgetValue(m_ui_CD_center[i], g.center[i]);
|
||||
|
@ -258,6 +268,7 @@ void GeometryWidget::set(const QString gstr)
|
|||
setQWidgetValue(m_ui_C01_corner[0][i], g.corner[0][i]);
|
||||
setQWidgetValue(m_ui_C01_corner[1][i], g.corner[1][i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString GeometryWidget::getGeometry()
|
||||
|
@ -297,11 +308,16 @@ QString GeometryWidget::getGeometry()
|
|||
void GeometryWidget::setFormat(Geometry::Format format)
|
||||
{
|
||||
if (format < Geometry::FormatNone || format >= Geometry::FormatMax)
|
||||
{} //Exception ???
|
||||
{ return; } //Exception ???
|
||||
Geometry::Format prevFormat = static_cast<Geometry::Format>(m_ui_stack->currentIndex());
|
||||
if (format != prevFormat) {
|
||||
set(getGeometry());
|
||||
m_ui_stack->setCurrentIndex(format);
|
||||
if (!set(getGeometry())) {
|
||||
####### Print a dialog & revert to FormatCustom...
|
||||
m_ui_stack->setCurrentIndex(Geoemtry::FormatCustom);
|
||||
}
|
||||
else {
|
||||
m_ui_stack->setCurrentIndex(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,3 +413,8 @@ void GeometryWidget::on_geometry_C0D_DimensionY_editingFinished()
|
|||
else if (corner + dimension - 1 < -32768)
|
||||
ui->geometry_C0D_DimensionY->setValue(-32768 + 1 - corner);
|
||||
}
|
||||
|
||||
void GeometryWidget::on_geometry_parse_clicked()
|
||||
{
|
||||
set(ui->geometry_custom->text());
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
CenterDimensions = 1,
|
||||
CornerDimensions = 2,
|
||||
Corners = 3,
|
||||
FormatCustom,
|
||||
FormatMax
|
||||
};
|
||||
static QMap<Geometry::Format, QString> geometryIdNameMap;
|
||||
|
@ -25,6 +26,9 @@ public:
|
|||
|
||||
static const QString &formatName(Geometry::Format id);
|
||||
static Geometry::Format formatId(const QString &name);
|
||||
struct InitStatics { InitStatics(void); };
|
||||
static const InitStatics initStatics;
|
||||
friend class InitStatics;
|
||||
|
||||
int center[2];
|
||||
int dimension[2];
|
||||
|
@ -58,7 +62,9 @@ public:
|
|||
explicit GeometryWidget(QWidget *parent = 0);
|
||||
~GeometryWidget();
|
||||
|
||||
void set(const QString gstr);
|
||||
bool set(const chat *gstr) { return _set(gstr); }
|
||||
bool set(const QString gstr) { return _set(gstr.toStdString().c_str()); }
|
||||
bool setDefault(void) { return _set(""); }
|
||||
void setFormat(int i) { setFormat(static_cast<Geometry::Format>(i)); }
|
||||
void setFormat(Geometry::Format t);
|
||||
void setFormat(QString s) { setFormat(Geometry::formatId(s)); }
|
||||
|
@ -77,6 +83,8 @@ private slots:
|
|||
void on_geometry_CD_DimensionX_editingFinished();
|
||||
void on_geometry_CD_DimensionY_editingFinished();
|
||||
|
||||
void on_geometry_parse_clicked();
|
||||
|
||||
private:
|
||||
Ui::GeometryWidget *ui;
|
||||
|
||||
|
@ -86,6 +94,8 @@ private:
|
|||
QSpinBox *m_ui_C0D_corner[2];
|
||||
QSpinBox *m_ui_C0D_dimension[2];
|
||||
QSpinBox *m_ui_C01_corner[2][2];
|
||||
|
||||
bool _set(const char *gstr);
|
||||
};
|
||||
|
||||
#endif // GEOMETRYWIDGET_H
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>412</width>
|
||||
<height>58</height>
|
||||
<height>68</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
|
@ -28,6 +28,9 @@
|
|||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="geometryFormat">
|
||||
<property name="toolTip">
|
||||
<string>Try to convert to a non-custom format</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -51,10 +54,18 @@
|
|||
<string>Two Corners</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Custom</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="geometryStackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_0"/>
|
||||
<widget class="QWidget" name="page_1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,4,0,4,1,0,0,4,0,4">
|
||||
|
@ -602,6 +613,54 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,0">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="geometry_custom">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>e.g. -200,-100:200,200</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="geometry_parse">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Try to convert to another</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Parse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -251,8 +251,8 @@ void MainWindow::on_button_generate_clicked()
|
|||
if(ui->backend->currentIndex() !=0){
|
||||
arguments <<"--backend" << ui->backend->currentText();
|
||||
}
|
||||
if(ui->geometry->text() !=""){
|
||||
arguments <<"--geometry" << ui->geometry->text().trimmed();
|
||||
if(ui->geometry->getGeometry() !=""){
|
||||
arguments <<"--geometry" << ui->geometry->getGeometry().trimmed();
|
||||
}
|
||||
|
||||
if(ui->scalefactor->currentIndex() !=0){
|
||||
|
@ -677,7 +677,7 @@ void MainWindow::writeProfile(QString profile)
|
|||
|
||||
//tab2 area
|
||||
settings.setValue("scalefactor",ui->scalefactor->currentIndex());
|
||||
settings.setValue("geometry",ui->geometry->text());
|
||||
settings.setValue("geometry",ui->geometry->getGeometry());
|
||||
settings.setValue("minY",ui->minY->value());
|
||||
settings.setValue("maxY",ui->maxY->value());
|
||||
settings.setValue("geometry_granularity",geometryGranularitySymbolic[ui->geometrymode_granularity_group->checkedId()]);
|
||||
|
@ -749,8 +749,7 @@ void MainWindow::readProfile(QString profile)
|
|||
|
||||
//tab2 Area
|
||||
ui->scalefactor->setCurrentIndex(settings.value("scalefactor",0).toInt());
|
||||
ui->geometry->setText(settings.value("geometry").toString());
|
||||
ui->geometryWidget->set(settings.value("geometry","").toString());
|
||||
ui->geometry->set(settings.value("geometry").toString());
|
||||
ui->checkBox_maxY->setChecked(settings.value("checkBox_maxY",false).toBool());
|
||||
ui->checkBox_minY->setChecked(settings.value("checkBox_minY",false).toBool());
|
||||
ui->maxY->setValue(settings.value("maxY",0).toInt());
|
||||
|
|
|
@ -198,39 +198,7 @@
|
|||
<string>Map-Limit</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="13" column="4">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="7" column="4">
|
||||
<widget class="QSpinBox" name="maxY">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Nodes higher than this level will not be drawn. This can be used to avoid floating islands or floating artefacts from abscuring the world below.</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Specify the upper height limit for the map</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-30000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="4">
|
||||
<item row="5" column="4">
|
||||
<widget class="QSpinBox" name="minY">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
|
@ -249,7 +217,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="4" rowspan="2">
|
||||
<item row="7" column="4" rowspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="geometrymode_auto">
|
||||
|
@ -356,24 +324,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QLineEdit" name="geometry">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>e.g. -200,-100:200,200</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_minY">
|
||||
<property name="text">
|
||||
<string>min-Y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_maxY">
|
||||
<property name="statusTip">
|
||||
<string>Specify the upper height limit for the map</string>
|
||||
|
@ -422,7 +380,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>geometrymode</string>
|
||||
|
@ -430,7 +388,39 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4" rowspan="2">
|
||||
<widget class="GeometryWidget" name="geometryWidget" native="true"/>
|
||||
<widget class="GeometryWidget" name="geometry" native="true"/>
|
||||
</item>
|
||||
<item row="12" column="4">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="4">
|
||||
<widget class="QSpinBox" name="maxY">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Nodes higher than this level will not be drawn. This can be used to avoid floating islands or floating artefacts from abscuring the world below.</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Specify the upper height limit for the map</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-30000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in New Issue