Material: Material editor enhancements

Continues the work of the material subsystem improvements.

This merge covers the continued development of the material editor. The
primary improvements are in the handling of 2D and 3D array properties.
These properties are now fully editable, and can be saved and restored.

The cards now separate the author and license. These were previously
saved as a single item. Future support will be provided for standard
open source licenses.

Saving operations validate the cards to ensure UUIDs of materials are
considered. Warnings are given when a save could potentially impact the
models, such as saving over a material instead of creating a new
instance.

The editor is still not complete. There are a number of functional
elements, such as drag/drop operations, folder creation, and deletion
operations that need to be added to the main tree. State needs to be
saved and restored to improve the user experience. The appearance
preview also needs significant work. This will be handled in a future
PR.
This commit is contained in:
David Carter
2023-10-23 15:19:20 -04:00
parent aaa962944b
commit 58bacb6b40
221 changed files with 6493 additions and 1614 deletions

View File

@@ -0,0 +1,85 @@
/***************************************************************************
* 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"
#include "Array2DPy.h"
#include "Model.h"
#include "ModelLibrary.h"
#include "ModelPropertyPy.h"
#include "ModelUuids.h"
#include "Array2DPy.cpp"
using namespace Materials;
// returns a string which represents the object e.g. when printed in python
std::string Array2DPy::representation() const
{
std::stringstream str;
str << "<Array2D object at " << getMaterial2DArrayPtr() << ">";
return str.str();
}
PyObject* Array2DPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
{
// never create such objects with the constructor
return new Array2DPy(new Material2DArray());
}
// constructor method
int Array2DPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
{
return 0;
}
Py::Int Array2DPy::getRows() const
{
return Py::Int(getMaterial2DArrayPtr()->rows());
}
Py::Int Array2DPy::getColumns() const
{
return Py::Int(getMaterial2DArrayPtr()->columns());
}
PyObject* Array2DPy::getDefaultValue(PyObject* args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name)) {
return nullptr;
}
// QVariant value = getMaterial2DArrayPtr()->getPhysicalValue(QString::fromStdString(name));
// return _pyObjectFromVariant(value);
return nullptr;
}
PyObject* Array2DPy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}
int Array2DPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}