a lot of work on th map-creator
This commit is contained in:
@@ -38,7 +38,6 @@ QComboBox* getObstacleTypes() {
|
||||
QComboBox* cmb = new QComboBox();
|
||||
for (int i = 0; i < (int)ObstacleType::_END; ++i) {
|
||||
switch ((ObstacleType)i) {
|
||||
case ObstacleType::DOOR: cmb->addItem("Door", i); break;
|
||||
case ObstacleType::UNKNOWN: cmb->addItem("Unknown ", i); break;
|
||||
case ObstacleType::WALL: cmb->addItem("Wall", i); break;
|
||||
case ObstacleType::WINDOW: cmb->addItem("Window", i); break;
|
||||
@@ -64,6 +63,7 @@ QComboBox* getOutlineMethods() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
ElementParamWidget::ElementParamWidget(QWidget *parent) : QGroupBox(parent) {
|
||||
|
||||
this->lay = new QGridLayout(this);
|
||||
@@ -81,6 +81,13 @@ ElementParamWidget::ElementParamWidget(QWidget *parent) : QGroupBox(parent) {
|
||||
|
||||
void ElementParamWidget::setElement(MapModelElement* el) {
|
||||
|
||||
this->curElement = el;
|
||||
refresh();
|
||||
|
||||
}
|
||||
|
||||
void ElementParamWidget::refresh() {
|
||||
|
||||
while ( QWidget* w = this->findChild<QWidget*>() ) {delete w;}
|
||||
delete this->layout();
|
||||
|
||||
@@ -88,20 +95,7 @@ void ElementParamWidget::setElement(MapModelElement* el) {
|
||||
this->setLayout(lay);
|
||||
int r = 0;
|
||||
|
||||
this->curElement = el;
|
||||
|
||||
// if (el == nullptr) {
|
||||
// lblDetails->setText("-");
|
||||
// } else if (dynamic_cast<MMFloorObstacleLine*>(el)) {
|
||||
// MMFloorObstacleLine* obs = dynamic_cast<MMFloorObstacleLine*>(el);
|
||||
// lblDetails->setText("Obstacle");
|
||||
// } else if (dynamic_cast<MMFloorOutlinePolygon*>(el)) {
|
||||
// MMFloorOutlinePolygon* poly = dynamic_cast<MMFloorOutlinePolygon*>(el);
|
||||
// std::string txt = "Polygon (" + std::to_string(poly->getPolygon()->poly.points.size()) + " Points)";
|
||||
// lblDetails->setText(txt.c_str());
|
||||
// } else {
|
||||
// lblDetails->setText("?");
|
||||
// }
|
||||
MapModelElement* el = this->curElement;
|
||||
|
||||
// material? -> select in combo-box
|
||||
{
|
||||
@@ -157,18 +151,39 @@ void ElementParamWidget::setElement(MapModelElement* el) {
|
||||
const Param param = elem->getParamDesc(i);
|
||||
const ParamValue value = elem->getParamValue(i);
|
||||
|
||||
// skip Not-Available entries
|
||||
if (param.type == ParamType::NOT_AVAILABLE) {continue;}
|
||||
|
||||
lay->addWidget(new QLabel(param.name.c_str()),r,0);
|
||||
|
||||
switch(param.type) {
|
||||
|
||||
case ParamType::BOOL: {
|
||||
QCheckBox* chk = new QCheckBox( );
|
||||
chk->setChecked(value.toBool());
|
||||
if (param.readOnly) {
|
||||
chk->setEnabled(false);
|
||||
} else {
|
||||
connect(chk, &QCheckBox::clicked, [i,elem] (const bool checked) {
|
||||
elem->setParamValue(i, ParamValue(checked));
|
||||
});
|
||||
}
|
||||
lay->addWidget(chk,r,1);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::FLOAT: {
|
||||
const std::string str = std::to_string(value.toFloat());
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
const float val = std::stof(str.toStdString());
|
||||
elem->setParamValue(i, ParamValue(val));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
if (param.readOnly) {
|
||||
lay->addWidget(new QLabel(str.c_str()),r,1);
|
||||
} else {
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
const float val = str.toFloat();
|
||||
elem->setParamValue(i, ParamValue(val));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -176,7 +191,7 @@ void ElementParamWidget::setElement(MapModelElement* el) {
|
||||
const std::string str = std::to_string(value.toInt());
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
const int val = std::stoi(str.toStdString());
|
||||
const int val = str.toInt();
|
||||
elem->setParamValue(i, ParamValue(val));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
@@ -237,6 +252,7 @@ void ElementParamWidget::setElement(MapModelElement* el) {
|
||||
laySub->addWidget(txtZ,0,2);
|
||||
lay->addWidget(subWidget,r,1);
|
||||
auto onChange = [i,elem,txtX,txtY,txtZ] (const QString& str) {
|
||||
(void) str;
|
||||
elem->setParamValue(i, ParamValue( Point3(txtX->text().toFloat(), txtY->text().toFloat(), txtZ->text().toFloat()) ));
|
||||
};
|
||||
connect(txtX, &QLineEdit::textChanged, onChange);
|
||||
|
||||
Reference in New Issue
Block a user