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
94
src/Mod/Material/Gui/TextEdit.cpp
Normal file
94
src/Mod/Material/Gui/TextEdit.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <Gui/MainWindow.h>
|
||||
|
||||
#include <Mod/Material/App/Exceptions.h>
|
||||
#include <Mod/Material/App/Materials.h>
|
||||
|
||||
#include "TextEdit.h"
|
||||
#include "ui_TextEdit.h"
|
||||
|
||||
|
||||
using namespace MatGui;
|
||||
|
||||
/* TRANSLATOR MatGui::TextEdit */
|
||||
|
||||
TextEdit::TextEdit(const QString& propertyName,
|
||||
std::shared_ptr<Materials::Material> material,
|
||||
QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui_TextEdit)
|
||||
, _material(material)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
if (material->hasPhysicalProperty(propertyName)) {
|
||||
_property = material->getPhysicalProperty(propertyName);
|
||||
}
|
||||
else if (material->hasAppearanceProperty(propertyName)) {
|
||||
_property = material->getAppearanceProperty(propertyName);
|
||||
}
|
||||
else {
|
||||
Base::Console().Log("Property '%s' not found\n", propertyName.toStdString().c_str());
|
||||
_property = nullptr;
|
||||
}
|
||||
if (_property) {
|
||||
Base::Console().Log("Value type %d\n",
|
||||
static_cast<int>(_property->getMaterialValue()->getType()));
|
||||
_value = _property->getString();
|
||||
}
|
||||
else {
|
||||
Base::Console().Log("No value loaded\n");
|
||||
_value = QString();
|
||||
}
|
||||
|
||||
ui->textEdit->setText(_value);
|
||||
ui->textEdit->setAcceptRichText(false);
|
||||
ui->textEdit->setWordWrapMode(QTextOption::NoWrap);
|
||||
|
||||
connect(ui->standardButtons, &QDialogButtonBox::accepted, this, &TextEdit::accept);
|
||||
connect(ui->standardButtons, &QDialogButtonBox::rejected, this, &TextEdit::reject);
|
||||
}
|
||||
|
||||
void TextEdit::accept()
|
||||
{
|
||||
QString newText = ui->textEdit->toPlainText();
|
||||
if (newText != _value) {
|
||||
_property->setValue(ui->textEdit->toPlainText());
|
||||
_material->setEditStateAlter();
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void TextEdit::reject()
|
||||
{
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
#include "moc_TextEdit.cpp"
|
||||
Reference in New Issue
Block a user