Uses new material system for appearance Each feature object now has a property called ShapeMaterial that describes its physical properties. If it has a shape, it has a material. The ShapeColor attribute is replaced by a ShapeAppearance attribute. This is a material list that describes all appearance properties, not just diffuse color. As a list in can be used for all elements of a shape, such as edges and faces. A new widget is provided to allow the user to select materials in a consistent fashion. It can also launch the material editor with its more advanced capabilities.
102 lines
3.2 KiB
C++
102 lines
3.2 KiB
C++
/***************************************************************************
|
|
* Copyright (c) 2023-2024 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/>. *
|
|
* *
|
|
**************************************************************************/
|
|
|
|
#ifndef MATERIAL_PROPERTYMATERIAL_H
|
|
#define MATERIAL_PROPERTYMATERIAL_H
|
|
|
|
#include <App/Property.h>
|
|
#include <Base/Reader.h>
|
|
|
|
#include "Materials.h"
|
|
|
|
namespace App
|
|
{
|
|
class Material;
|
|
}
|
|
|
|
namespace Materials
|
|
{
|
|
|
|
/** Material properties
|
|
* This is the father of all properties handling colors.
|
|
*/
|
|
class MaterialsExport PropertyMaterial: public App::Property
|
|
{
|
|
TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
|
|
|
public:
|
|
/**
|
|
* A constructor.
|
|
* A more elaborate description of the constructor.
|
|
*/
|
|
PropertyMaterial();
|
|
|
|
/**
|
|
* A destructor.
|
|
* A more elaborate description of the destructor.
|
|
*/
|
|
~PropertyMaterial() override;
|
|
|
|
/** Sets the property
|
|
*/
|
|
void setValue(const Material& mat);
|
|
|
|
/** Sets the appearance properties
|
|
*/
|
|
void setValue(const App::Material& mat);
|
|
|
|
/** This method returns a string representation of the property
|
|
*/
|
|
const Material& getValue() const;
|
|
|
|
PyObject* getPyObject() override;
|
|
void setPyObject(PyObject*) override;
|
|
|
|
void Save(Base::Writer& writer) const override;
|
|
void Restore(Base::XMLReader& reader) override;
|
|
|
|
const char* getEditorName() const override;
|
|
|
|
Property* Copy() const override;
|
|
void Paste(const Property& from) override;
|
|
|
|
unsigned int getMemSize() const override
|
|
{
|
|
return sizeof(_material);
|
|
}
|
|
|
|
bool isSame(const Property& other) const override
|
|
{
|
|
if (&other == this) {
|
|
return true;
|
|
}
|
|
return getTypeId() == other.getTypeId()
|
|
&& getValue() == static_cast<decltype(this)>(&other)->getValue();
|
|
}
|
|
|
|
private:
|
|
Material _material;
|
|
};
|
|
|
|
} // namespace Materials
|
|
|
|
#endif // MATERIAL_PROPERTYMATERIAL_H
|