Esempio n. 1
0
VectorProperty::VectorProperty(QWidget *parent, PropertyForm &sheet, std::string name, Vec3f value,
                               bool isAbsorption, std::function<bool(Vec3f)> setter)
    : _value(value),
      _setter(std::move(setter)),
      _isAbsorption(isAbsorption)
{
    _nameLabel = new QLabel(QString::fromStdString(name + ":"), parent);

    QBoxLayout *horz = new QBoxLayout(QBoxLayout::LeftToRight);
    horz->setMargin(0);

    for (int i = 0; i < 3; ++i) {
        _lineEdits[i] = new QLineEdit(QString::number(value[i]), parent);
        _lineEdits[i]->setCursorPosition(0);
        connect(_lineEdits[i], SIGNAL(editingFinished()), this, SLOT(changeRgb()));
        horz->addWidget(_lineEdits[i], 1);
    }

    _colorPicker = new ColorPickButton(_isAbsorption ? std::exp(-value) : value, parent);
    connect(_colorPicker, SIGNAL(colorChanged(Vec3f)), this, SLOT(changeRgb(Vec3f)));
    horz->addWidget(_colorPicker);

    sheet.addWidget(_nameLabel, sheet.rowCount(), 0);
    sheet.addLayout(horz, sheet.rowCount() - 1, 1);
}
Esempio n. 2
0
FloatProperty::FloatProperty(QWidget *parent, PropertyForm &sheet, std::string name, float value,
        std::function<bool(float)> setter)
: _value(value),
  _setter(std::move(setter))
{
    _nameLabel = new QLabel(QString::fromStdString(name + ":"), parent);
    _lineEdit = new QLineEdit(QString::number(value), parent);
    connect(_lineEdit, SIGNAL(editingFinished()), this, SLOT(textEdited()));

    sheet.addWidget(_nameLabel, sheet.rowCount(), 0);
    sheet.addWidget(_lineEdit, sheet.rowCount() - 1, 1);
}
Esempio n. 3
0
MediumProperty::MediumProperty(QWidget *parent, PropertyForm &sheet, std::string name, std::shared_ptr<Medium> value,
        std::function<bool(std::shared_ptr<Medium> &)> setter, Scene *scene)
: _value(std::move(value)),
  _setter(std::move(setter)),
  _scene(scene)
{
    _nameLabel = new QLabel(QString::fromStdString(name + ":"), parent);

    _mediumSelector = new QComboBox(parent);

    buildMediumList();

    sheet.addWidget(_nameLabel, sheet.rowCount(), 0);
    sheet.addWidget(_mediumSelector, sheet.rowCount() - 1, 1);
}
Esempio n. 4
0
ListProperty::ListProperty(QWidget *parent, PropertyForm &sheet, std::string name, std::vector<std::string> list,
        std::string value, std::function<bool(const std::string &, int)> setter)
: _list(std::move(list)),
  _index(0),
  _value(std::move(value)),
  _setter(std::move(setter))
{
    for (size_t i = 0; i < _list.size(); ++i)
        if (strcasecmp(_value.c_str(), _list[i].c_str()) == 0)
            _index = i;

    _nameLabel = new QLabel(QString::fromStdString(name + ":"), parent);
    _comboBox = new QComboBox(parent);
    for (const std::string &s : _list)
        _comboBox->addItem(s.c_str());
    _comboBox->setCurrentIndex(_index);

    connect(_comboBox, SIGNAL(activated(int)), this, SLOT(changeActive(int)));

    sheet.addWidget(_nameLabel, sheet.rowCount(), 0);
    sheet.addWidget(_comboBox, sheet.rowCount() - 1, 1);
}