Material: Convert XML bindings to Python.

This commit is contained in:
Joao Matos
2025-03-24 19:06:26 +00:00
committed by Benjamin Nauck
parent 35420022e9
commit 4ec136b252
18 changed files with 858 additions and 9 deletions

View File

@@ -0,0 +1,53 @@
from Base.Metadata import export
from Base.BaseClass import BaseClass
from Base.Metadata import constmethod
from typing import Final, List, Any
@export(
Twin="Array2D",
TwinPointer="Array2D",
Namespace="Materials",
Include="Mod/Material/App/MaterialValue.h",
Delete=True,
Constructor=True
)
class Array2D(BaseClass):
"""
2D Array of material properties.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
Array: Final[List] = ...
"""The 2 dimensional array."""
Dimensions: Final[int] = ...
"""The number of dimensions in the array, in this case 2."""
Rows: int = ...
"""The number of rows in the array."""
Columns: int = ...
"""The number of columns in the array."""
@constmethod
def getRow(self, value: Any) -> Any:
"""
Get the row given the first column value
"""
...
@constmethod
def getValue(self, row: int, column: int) -> Any:
"""
Get the value at the given row and column
"""
...
def setValue(self, row: int, column: int, value: Any):
"""
Set the value at the given row and column
"""
...

View File

@@ -25,7 +25,7 @@
<Documentation>
<UserDocu>The number of dimensions in the array, in this case 2.</UserDocu>
</Documentation>
<Parameter Name="Dimensions" Type="Int"/>
<Parameter Name="Dimensions" Type="Long"/>
</Attribute>
<Attribute Name="Rows" ReadOnly="false">
<Documentation>
@@ -39,12 +39,12 @@
</Documentation>
<Parameter Name="Columns" Type="Long"/>
</Attribute>
<Methode Name="getRow" ReadOnly="true">
<Methode Name="getRow" Const="true">
<Documentation>
<UserDocu>Get the row given the first column value</UserDocu>
</Documentation>
</Methode>
<Methode Name="getValue" ReadOnly="true">
<Methode Name="getValue" Const="true">
<Documentation>
<UserDocu>Get the value at the given row and column</UserDocu>
</Documentation>

View File

@@ -0,0 +1,71 @@
from Base.Metadata import export, constmethod
from Base.BaseClass import BaseClass
from typing import Any, Final, List
@export(
Twin="Array3D",
TwinPointer="Array3D",
Namespace="Materials",
Include="Mod/Material/App/MaterialValue.h",
Delete=True,
Constructor=True
)
class Array3D(BaseClass):
"""
3D Array of material properties.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
Array: Final[List] = ...
"""The 3 dimensional array."""
Dimensions: Final[int] = ...
"""The number of dimensions in the array, in this case 3."""
Columns: int = ...
"""The number of columns in the array."""
Depth: int = ...
"""The depth of the array (3rd dimension)."""
@constmethod
def getRows(self) -> int:
"""
Get the number of rows in the array at the specified depth.
"""
...
@constmethod
def getValue(self) -> Any:
"""
Get the value at the given row and column
"""
...
@constmethod
def getDepthValue(self) -> Any:
"""
Get the column value at the given depth
"""
...
def setDepthValue(self, value: Any):
"""
Set the column value at the given depth
"""
...
def setValue(self, depth: int, row: int, column: int, value: Any):
"""
Set the value at the given depth, row, and column
"""
...
def setRows(self, depth: int, value: int):
"""
Set the number of rows at the given depth
"""
...

View File

@@ -25,31 +25,31 @@
<Documentation>
<UserDocu>The number of dimensions in the array, in this case 3.</UserDocu>
</Documentation>
<Parameter Name="Dimensions" Type="Int"/>
<Parameter Name="Dimensions" Type="Long"/>
</Attribute>
<Attribute Name="Columns" ReadOnly="false">
<Documentation>
<UserDocu>The number of columns in the array.</UserDocu>
</Documentation>
<Parameter Name="Columns" Type="Int"/>
<Parameter Name="Columns" Type="Long"/>
</Attribute>
<Attribute Name="Depth" ReadOnly="false">
<Documentation>
<UserDocu>The depth of the array (3rd dimension).</UserDocu>
</Documentation>
<Parameter Name="Depth" Type="Int"/>
<Parameter Name="Depth" Type="Long"/>
</Attribute>
<Methode Name="getRows" ReadOnly="true">
<Methode Name="getRows" Const="true">
<Documentation>
<UserDocu>Get the number of rows in the array at the specified depth.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getValue" ReadOnly="true">
<Methode Name="getValue" Const="true">
<Documentation>
<UserDocu>Get the value at the given row and column</UserDocu>
</Documentation>
</Methode>
<Methode Name="getDepthValue" ReadOnly="true">
<Methode Name="getDepthValue" Const="true">
<Documentation>
<UserDocu>Get the column value at the given depth</UserDocu>
</Documentation>

View File

@@ -43,17 +43,29 @@ else()
endif()
generate_from_xml(Array2DPy)
generate_from_py_(Array2D)
generate_from_xml(Array3DPy)
generate_from_py_(Array3D)
generate_from_xml(MaterialFilterPy)
generate_from_py_(MaterialFilter)
generate_from_xml(MaterialFilterOptionsPy)
generate_from_py_(MaterialFilterOptions)
generate_from_xml(MaterialLibraryPy)
generate_from_py_(MaterialLibrary)
generate_from_xml(MaterialManagerPy)
generate_from_py_(MaterialManager)
generate_from_xml(MaterialPy)
generate_from_py_(Material)
generate_from_xml(ModelManagerPy)
generate_from_py_(ModelManager)
generate_from_xml(ModelPropertyPy)
generate_from_py_(ModelProperty)
generate_from_xml(MaterialPropertyPy)
generate_from_py_(MaterialProperty)
generate_from_xml(ModelPy)
generate_from_py_(Model)
generate_from_xml(UUIDsPy)
generate_from_py_(UUIDs)
SET(Python_SRCS
Exceptions.h

View File

@@ -0,0 +1,156 @@
from Base.Metadata import export, no_args, sequence_protocol
from Base.BaseClass import BaseClass
from typing import Final, Dict
@export(
Include="Mod/Material/App/Materials.h",
Namespace="Materials",
Constructor=True,
Delete=True,
)
@sequence_protocol(sq_length=True, sq_item=True, sq_contains=True, mp_subscript=True)
class Material(BaseClass):
"""
Material descriptions.
Author: David Carter (dcarter@davidcarter.ca)
Licence: LGPL
"""
LibraryName: Final[str] = ...
"""Model library name."""
LibraryRoot: Final[str] = ...
"""Model library path."""
LibraryIcon: Final[str] = ...
"""Model icon path."""
Name: str = ...
"""Model name."""
Directory: str = ...
"""Model directory relative to the library root."""
UUID: Final[str] = ...
"""Unique model identifier. This is only valid after the material is saved."""
Description: str = ...
"""Description of the material."""
URL: str = ...
"""URL to a material reference."""
Reference: str = ...
"""Reference for material data."""
Parent: str = ...
"""Parent material UUID."""
AuthorAndLicense: Final[str] = ...
"""deprecated -- Author and license information."""
Author: str = ...
"""Author information."""
License: str = ...
"""License information."""
PhysicalModels: Final[list] = ...
"""List of implemented models."""
AppearanceModels: Final[list] = ...
"""List of implemented models."""
Tags: Final[list] = ...
"""List of searchable tags."""
Properties: Final[dict] = ...
"""deprecated -- Dictionary of all material properties."""
PhysicalProperties: Final[dict] = ...
"""deprecated -- Dictionary of material physical properties."""
AppearanceProperties: Final[dict] = ...
"""deprecated -- Dictionary of material appearance properties."""
LegacyProperties: Final[dict] = ...
"""deprecated -- Dictionary of material legacy properties."""
PropertyObjects: Final[dict] = ...
"""Dictionary of MaterialProperty objects."""
def addPhysicalModel(self) -> None:
"""Add the physical model with the given UUID"""
...
def removePhysicalModel(self) -> None:
"""Remove the physical model with the given UUID"""
...
def hasPhysicalModel(self) -> bool:
"""Check if the material implements the physical model with the given UUID"""
...
def addAppearanceModel(self) -> None:
"""Add the appearance model with the given UUID"""
...
def removeAppearanceModel(self) -> None:
"""Remove the appearance model with the given UUID"""
...
def hasAppearanceModel(self) -> bool:
"""Check if the material implements the appearance model with the given UUID"""
...
def isPhysicalModelComplete(self) -> bool:
"""Check if the material implements the physical model with the given UUID, and has values defined for each property"""
...
def isAppearanceModelComplete(self) -> bool:
"""Check if the material implements the appearance model with the given UUID, and has values defined for each property"""
...
def hasPhysicalProperty(self) -> bool:
"""Check if the material implements the physical property with the given name"""
...
def hasAppearanceProperty(self) -> bool:
"""Check if the material implements the appearance property with the given name"""
...
def hasLegacyProperties(self) -> bool:
"""Returns true of there are legacy properties"""
...
def getPhysicalValue(self) -> str:
"""Get the value associated with the property"""
...
def setPhysicalValue(self) -> None:
"""Set the value associated with the property"""
...
def getAppearanceValue(self) -> str:
"""Get the value associated with the property"""
...
def setAppearanceValue(self) -> None:
"""Set the value associated with the property"""
...
def setValue(self) -> None:
"""Set the value associated with the property"""
...
@no_args
def keys(self) -> list:
"""Property keys"""
...
@no_args
def values(self) -> list:
"""Property values"""
...

View File

@@ -0,0 +1,27 @@
from Base.Metadata import export, constmethod
from Base.BaseClass import BaseClass
from typing import List
@export(
Include="Mod/Material/App/MaterialFilter.h",
Namespace="Materials",
Constructor=True,
Delete=True,
)
class MaterialFilter(BaseClass):
"""
Material filters.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
Name: str = ...
"""Name of the filter used to select a filter in a list"""
RequiredModels: List = ...
"""Materials must include the specified models."""
RequiredCompleteModels: List = ...
"""Materials must have complete versions of the specified models."""

View File

@@ -0,0 +1,32 @@
from Base.Metadata import export
from Base.BaseClass import BaseClass
@export(
Include="Mod/Material/App/MaterialFilter.h",
Namespace="Materials",
Constructor=True,
Delete=True
)
class MaterialFilterOptions(BaseClass):
"""
Material filtering options.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
IncludeFavorites: bool = ...
"""Include materials marked as favorite."""
IncludeRecent: bool = ...
"""Include recently used materials."""
IncludeEmptyFolders: bool = ...
"""Include empty folders."""
IncludeEmptyLibraries: bool = ...
"""Include empty libraries."""
IncludeLegacy: bool = ...
"""Include materials using the older legacy format."""

View File

@@ -0,0 +1,32 @@
from Base.Metadata import export, constmethod
from Base.BaseClass import BaseClass
from typing import Final
@export(
Include="Mod/Material/App/MaterialLibrary.h",
Namespace="Materials",
Constructor=True,
Delete=True,
)
class MaterialLibrary(BaseClass):
"""
Material library.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
Name: str = ...
"""Name of the library"""
Icon: str = ...
"""String value of the icon."""
Directory: str = ...
"""Local directory where the library is located. For non-local libraries this will be empty"""
ReadOnly: bool = ...
"""True if the library is local."""
Local: bool = ...
"""True if the library is local."""

View File

@@ -0,0 +1,70 @@
from Base.Metadata import export, constmethod
from Base.BaseClass import BaseClass
from typing import Final, List, Dict, overload
@export(
Include="Mod/Material/App/MaterialManager.h",
Namespace="Materials",
Constructor=True
)
class MaterialManager(BaseClass):
"""
Material descriptions.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
MaterialLibraries: Final[List] = ...
"""List of Material libraries."""
Materials: Final[Dict] = ...
"""List of Materials."""
def getMaterial(self) -> None:
"""
Get a material object by specifying its UUID
"""
...
def getMaterialByPath(self) -> None:
"""
Get a material object by specifying its path and library name
"""
...
def inheritMaterial(self) -> None:
"""
Create a new material object by specifying the UUID of its parent
"""
...
def materialsWithModel(self) -> None:
"""
Get a list of materials implementing the specified model
"""
...
def materialsWithModelComplete(self) -> None:
"""
Get a list of materials implementing the specified model, with values for all properties
"""
...
def save(self, **kwargs) -> None:
"""
Save the material in the specified library
"""
...
def filterMaterials(self, **kwargs) -> None:
"""
Returns a filtered material list
"""
...
def refresh(self) -> None:
"""
Refreshes the material tree. Use sparingly as this is an expensive operation.
"""
...

View File

@@ -0,0 +1,25 @@
from Base.Metadata import export
from ModelProperty import ModelProperty
from typing import Final
@export(
Include="Mod/Material/App/Materials.h",
Namespace="Materials",
FatherInclude="Mod/Material/App/Model.h",
FatherNamespace="Materials",
Constructor=True,
Delete=False,
)
class MaterialProperty(ModelProperty):
"""
Material property descriptions.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
Value: Final[object] = None
"""The value of the material property."""
Empty: Final[bool] = False
"""The property value is undefined."""

View File

@@ -0,0 +1,65 @@
from Base.Metadata import export, constmethod
from Base.BaseClass import BaseClass
from typing import Final, List, Dict, overload
@export(
Include="Mod/Material/App/Model.h",
Namespace="Materials",
Constructor=True,
Delete=True,
)
class Model(BaseClass):
"""
Material model descriptions.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
LibraryName: Final[str] = ""
"""Model library name."""
LibraryRoot: Final[str] = ""
"""Model library path."""
LibraryIcon: Final[str] = ""
"""Model icon path."""
Name: str = ""
"""Model name."""
Type: str = ""
"""Model type."""
Directory: str = ""
"""Model directory."""
UUID: Final[str] = ""
"""Unique model identifier."""
Description: str = ""
"""Description of the model."""
URL: str = ""
"""URL to a detailed description of the model."""
DOI: str = ""
"""Digital Object Identifier (see https://doi.org/)"""
Inherited: Final[List[str]] = []
"""List of inherited models identified by UUID."""
Properties: Final[Dict[str, str]] = {}
"""Dictionary of model properties."""
def addInheritance(self) -> None:
"""
Add an inherited model.
"""
...
def addProperty(self) -> None:
"""
Add a model property.
"""
...

View File

@@ -0,0 +1,37 @@
from Base.Metadata import export, constmethod
from Base.BaseClass import BaseClass
from typing import Final, List, Dict
@export(
Include="Mod/Material/App/ModelManager.h",
Namespace="Materials",
Constructor=True
)
class ModelManager(BaseClass):
"""
Material model descriptions.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
ModelLibraries: Final[List] = ...
"""List of model libraries."""
LocalModelLibraries: Final[List] = ...
"""List of local model libraries."""
Models: Final[Dict] = ...
"""List of model libraries."""
def getModel(self) -> ...:
"""
Get a model object by specifying its UUID
"""
...
def getModelByPath(self) -> ...:
"""
Get a model object by specifying its path
"""
...

View File

@@ -0,0 +1,51 @@
from Base.Metadata import export, constmethod
from Base.BaseClass import BaseClass
from typing import Final
@export(
Include="Mod/Material/App/Model.h",
Namespace="Materials",
Constructor=True,
Delete=True,
)
class ModelProperty(BaseClass):
"""
Material property descriptions.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
Name: str = ...
"""Property name."""
DisplayName: str = ...
"""Property display friendly name."""
Type: str = ...
"""Property type."""
Units: str = ...
"""Property units category."""
URL: str = ...
"""URL to a detailed description of the property."""
Description: str = ...
"""Property description."""
Columns: Final[list] = ...
"""List of array columns."""
Inheritance: Final[str] = ...
"""UUID of the model in which the property is defined."""
Inherited: Final[bool] = ...
"""True if the property is inherited."""
def addColumn(self) -> None:
"""
Add a model property column.
"""
...

View File

@@ -0,0 +1,167 @@
from Base.Metadata import export, constmethod
from Base.BaseClass import BaseClass
from typing import Final
@export(
PythonName="Material.UUIDs",
Twin="ModelUUIDs",
TwinPointer="ModelUUIDs",
Include="Mod/Material/App/ModelUuids.h",
Namespace="Materials",
Constructor=True,
Delete=True,
)
class UUIDs(BaseClass):
"""
Material model UUID identifiers.
Author: DavidCarter (dcarter@davidcarter.ca)
Licence: LGPL
"""
Father: Final[str] = ...
"""UUID for model System:Legacy/Father"""
MaterialStandard: Final[str] = ...
"""UUID for model System:Legacy/MaterialStandard"""
ArrudaBoyce: Final[str] = ...
"""UUID for model System:Mechanical/ArrudaBoyce"""
Density: Final[str] = ...
"""UUID for model System:Mechanical/Density"""
Hardness: Final[str] = ...
"""UUID for model System:Mechanical/Hardness"""
IsotropicLinearElastic: Final[str] = ...
"""UUID for model System:Mechanical/IsotropicLinearElastic"""
LinearElastic: Final[str] = ...
"""UUID for model System:Mechanical/LinearElastic"""
Machinability: Final[str] = ...
"""UUID for model System:Machining/Machinability"""
MooneyRivlin: Final[str] = ...
"""UUID for model System:Mechanical/MooneyRivlin"""
NeoHooke: Final[str] = ...
"""UUID for model System:Mechanical/NeoHooke"""
OgdenN1: Final[str] = ...
"""UUID for model System:Mechanical/OgdenN1"""
OgdenN2: Final[str] = ...
"""UUID for model System:Mechanical/OgdenN2"""
OgdenN3: Final[str] = ...
"""UUID for model System:Mechanical/OgdenN3"""
OgdenYld2004p18: Final[str] = ...
"""UUID for model System:Mechanical/OgdenYld2004p18"""
OrthotropicLinearElastic: Final[str] = ...
"""UUID for model System:Mechanical/OrthotropicLinearElastic"""
PolynomialN1: Final[str] = ...
"""UUID for model System:Mechanical/PolynomialN1"""
PolynomialN2: Final[str] = ...
"""UUID for model System:Mechanical/PolynomialN2"""
PolynomialN3: Final[str] = ...
"""UUID for model System:Mechanical/PolynomialN3"""
ReducedPolynomialN1: Final[str] = ...
"""UUID for model System:Mechanical/ReducedPolynomialN1"""
ReducedPolynomialN2: Final[str] = ...
"""UUID for model System:Mechanical/ReducedPolynomialN2"""
ReducedPolynomialN3: Final[str] = ...
"""UUID for model System:Mechanical/ReducedPolynomialN3"""
Yeoh: Final[str] = ...
"""UUID for model System:Mechanical/Yeoh"""
Fluid: Final[str] = ...
"""UUID for model System:Fluid/Fluid"""
Thermal: Final[str] = ...
"""UUID for model System:Thermal/Thermal"""
Electromagnetic: Final[str] = ...
"""UUID for model System:Electromagnetic/Electromagnetic"""
Architectural: Final[str] = ...
"""UUID for model System:Architectural/Architectural"""
ArchitecturalRendering: Final[str] = ...
"""UUID for model System:Architectural/ArchitecturalRendering"""
Costs: Final[str] = ...
"""UUID for model System:Costs/Costs"""
BasicRendering: Final[str] = ...
"""UUID for model System:Rendering/BasicRendering"""
TextureRendering: Final[str] = ...
"""UUID for model System:Rendering/TextureRendering"""
AdvancedRendering: Final[str] = ...
"""UUID for model System:Rendering/AdvancedRendering"""
VectorRendering: Final[str] = ...
"""UUID for model System:Rendering/VectorRendering"""
RenderAppleseed: Final[str] = ...
"""UUID for model System:Rendering/RenderAppleseed"""
RenderCarpaint: Final[str] = ...
"""UUID for model System:Rendering/RenderCarpaint"""
RenderCycles: Final[str] = ...
"""UUID for model System:Rendering/RenderCycles"""
RenderDiffuse: Final[str] = ...
"""UUID for model System:Rendering/RenderDiffuse"""
RenderDisney: Final[str] = ...
"""UUID for model System:Rendering/RenderDisney"""
RenderEmission: Final[str] = ...
"""UUID for model System:Rendering/RenderEmission"""
RenderGlass: Final[str] = ...
"""UUID for model System:Rendering/RenderGlass"""
RenderLuxcore: Final[str] = ...
"""UUID for model System:Rendering/RenderLuxcore"""
RenderLuxrender: Final[str] = ...
"""UUID for model System:Rendering/RenderLuxrender"""
RenderMixed: Final[str] = ...
"""UUID for model System:Rendering/RenderMixed"""
RenderOspray: Final[str] = ...
"""UUID for model System:Rendering/RenderOspray"""
RenderPbrt: Final[str] = ...
"""UUID for model System:Rendering/RenderPbrt"""
RenderPovray: Final[str] = ...
"""UUID for model System:Rendering/RenderPovray"""
RenderSubstancePBR: Final[str] = ...
"""UUID for model System:Rendering/RenderSubstancePBR"""
RenderTexture: Final[str] = ...
"""UUID for model System:Rendering/RenderTexture"""
RenderWB: Final[str] = ...
"""UUID for model System:Rendering/RenderWB"""
TestModel: Final[str] = ...
"""UUID for model System:Test/Test Model"""

View File

@@ -31,6 +31,7 @@ qt_create_resource_file(${Material_TR_QRC} ${QM_SRCS})
qt_add_resources(MatGui_QRC_SRCS Resources/Material.qrc ${Material_TR_QRC})
generate_from_xml(MaterialTreeWidgetPy)
generate_from_py_(MaterialTreeWidget)
SET(Python_SRCS
MaterialTreeWidgetPy.xml

View File

@@ -0,0 +1,49 @@
from Metadata import export, constmethod, forward_declarations, class_declarations, sequence_protocol
from Base.BaseClass import BaseClass
from typing import Final, overload
@export(
Twin="MaterialTreeWidget",
TwinPointer="MaterialTreeWidget",
Include="Mod/Material/Gui/MaterialTreeWidget.h",
Namespace="MatGui",
Constructor=True,
Delete=False,
)
class MaterialTreeWidget(BaseClass):
"""
Material tree widget.
"""
UUID: str = ...
"""Material UUID."""
expanded: bool = ...
"""Expand material tree."""
IncludeFavorites: bool = ...
"""Include favorites in the material list."""
IncludeRecent: bool = ...
"""Include recently used materials in the material list."""
IncludeEmptyFolders: bool = ...
"""Include empty folders in the material list."""
IncludeEmptyLibraries: bool = ...
"""Include empty libraries in the material list."""
IncludeLegacy: bool = ...
"""Include legacy materials in the material list."""
def setFilter(self) -> None:
"""
Set the material filter or list of filters.
"""
...
def selectFilter(self) -> None:
"""
Set the current material filter.
"""
...

View File

@@ -492,6 +492,7 @@ def _parse_class(class_node, source_code: str, path: str, imports_mapping: dict)
# Parse imports to compute module metadata
module_name = _get_module_from_path(path)
imported_from_module = imports_mapping[base_class_name]
parent_module_name = _extract_module_name(imported_from_module, module_name)