Material: Continued Material enahncements
Continues the work of the material subsystem improvements. Several important items are included in this merge. In terms of new capabilities, this merge adds List and MultiLineString as valid property types, complete with editing dialogs. This will help with backwards compatibility for external workbenches, such as Render. Stability has been a big focus. New unit tests help to verify features work as expected. Bugs have been fixed and crashes avoided. Material cards have had a renaming to their tree structure. For example, 'StandardMeterials' is redundant, so this was renamed to 'Standard'. The cards themselves are more compliant fully passing the yamllint tests. More soon.
This commit is contained in:
committed by
Chris Hennes
parent
c81bd982b5
commit
332bf7ed08
@@ -49,8 +49,10 @@
|
||||
|
||||
#include "Array2D.h"
|
||||
#include "Array3D.h"
|
||||
#include "ListEdit.h"
|
||||
#include "MaterialDelegate.h"
|
||||
#include "MaterialSave.h"
|
||||
#include "TextEdit.h"
|
||||
|
||||
|
||||
using namespace MatGui;
|
||||
@@ -92,6 +94,18 @@ bool MaterialDelegate::editorEvent(QEvent* event,
|
||||
// Mark as handled
|
||||
return true;
|
||||
}
|
||||
else if (type == "MultiLineString") {
|
||||
Base::Console().Log("Edit List\n");
|
||||
showMultiLineString(propertyName, item);
|
||||
// Mark as handled
|
||||
return true;
|
||||
}
|
||||
else if (type == "List") {
|
||||
Base::Console().Log("Edit List\n");
|
||||
showListModal(propertyName, item);
|
||||
// Mark as handled
|
||||
return true;
|
||||
}
|
||||
else if (type == "2DArray") {
|
||||
Base::Console().Log("Edit 2DArray\n");
|
||||
showArray2DModal(propertyName, item);
|
||||
@@ -145,6 +159,43 @@ void MaterialDelegate::showColorModal(QStandardItem* item, QString propertyName)
|
||||
dlg->exec();
|
||||
}
|
||||
|
||||
void MaterialDelegate::showListModal(const QString& propertyName, QStandardItem* item)
|
||||
{
|
||||
auto material = item->data().value<std::shared_ptr<Materials::Material>>();
|
||||
auto dlg = new ListEdit(propertyName, material);
|
||||
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
dlg->adjustSize();
|
||||
|
||||
connect(dlg, &QDialog::finished, this, [&](int result) {
|
||||
if (result == QDialog::Accepted) {
|
||||
Base::Console().Log("Accepted\n");
|
||||
}
|
||||
});
|
||||
|
||||
dlg->exec();
|
||||
}
|
||||
|
||||
void MaterialDelegate::showMultiLineString(const QString& propertyName, QStandardItem* item)
|
||||
{
|
||||
auto material = item->data().value<std::shared_ptr<Materials::Material>>();
|
||||
TextEdit* dlg = new TextEdit(propertyName, material);
|
||||
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
dlg->adjustSize();
|
||||
|
||||
connect(dlg, &QDialog::finished, this, [&](int result) {
|
||||
if (result == QDialog::Accepted) {
|
||||
Base::Console().Log("Accepted\n");
|
||||
}
|
||||
});
|
||||
|
||||
dlg->exec();
|
||||
}
|
||||
|
||||
|
||||
void MaterialDelegate::showArray2DModal(const QString& propertyName, QStandardItem* item)
|
||||
{
|
||||
auto material = item->data().value<std::shared_ptr<Materials::Material>>();
|
||||
@@ -234,6 +285,38 @@ void MaterialDelegate::paint(QPainter* painter,
|
||||
painter->restore();
|
||||
return;
|
||||
}
|
||||
else if (type == "MultiLineString") {
|
||||
painter->save();
|
||||
|
||||
QImage table(QString::fromStdString(":/icons/multiline.svg"));
|
||||
QRect target(option.rect);
|
||||
if (target.width() > target.height()) {
|
||||
target.setWidth(target.height());
|
||||
}
|
||||
else {
|
||||
target.setHeight(target.width());
|
||||
}
|
||||
painter->drawImage(target, table, table.rect());
|
||||
|
||||
painter->restore();
|
||||
return;
|
||||
}
|
||||
else if (type == "List") {
|
||||
painter->save();
|
||||
|
||||
QImage table(QString::fromStdString(":/icons/list.svg"));
|
||||
QRect target(option.rect);
|
||||
if (target.width() > target.height()) {
|
||||
target.setWidth(target.height());
|
||||
}
|
||||
else {
|
||||
target.setHeight(target.width());
|
||||
}
|
||||
painter->drawImage(target, table, table.rect());
|
||||
|
||||
painter->restore();
|
||||
return;
|
||||
}
|
||||
else if (type == "2DArray" || type == "3DArray") {
|
||||
// painter->save();
|
||||
|
||||
@@ -280,7 +363,8 @@ QSize MaterialDelegate::sizeHint(const QStyleOptionViewItem& option, const QMode
|
||||
if (type == "Color") {
|
||||
return QSize(75, 23); // Standard QPushButton size
|
||||
}
|
||||
else if (type == "2DArray" || type == "3DArray") {
|
||||
else if (type == "2DArray" || type == "3DArray" || type == "MultiLineString"
|
||||
|| type == "List") {
|
||||
return QSize(23, 23);
|
||||
}
|
||||
|
||||
@@ -387,14 +471,14 @@ QWidget* MaterialDelegate::createWidget(QWidget* parent,
|
||||
QWidget* widget = nullptr;
|
||||
|
||||
std::string type = propertyType.toStdString();
|
||||
if (type == "String" || type == "URL" || type == "Vector") {
|
||||
if (type == "String" || type == "URL" || type == "List") {
|
||||
widget = new Gui::PrefLineEdit(parent);
|
||||
}
|
||||
else if ((type == "Integer") || (type == "Int")) {
|
||||
Gui::UIntSpinBox* spinner = new Gui::UIntSpinBox(parent);
|
||||
Gui::IntSpinBox* spinner = new Gui::IntSpinBox(parent);
|
||||
spinner->setMinimum(0);
|
||||
spinner->setMaximum(UINT_MAX);
|
||||
spinner->setValue(propertyValue.toUInt());
|
||||
spinner->setMaximum(INT_MAX);
|
||||
spinner->setValue(propertyValue.toInt());
|
||||
widget = spinner;
|
||||
}
|
||||
else if (type == "Float") {
|
||||
|
||||
Reference in New Issue
Block a user