From ce3e591a4762204c8dd23ffeb46224d9809b5d87 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Wed, 24 Jul 2024 12:43:39 +0100 Subject: [PATCH] feat: CNX-19 adds render material proxy class (#50) * adds render material proxy class * Update RenderMaterial.cs * Update RenderMaterial.cs * refactors IProxyCollection interface * Update RenderMaterial.cs --- .../Models/Instances/GroupProxy.cs | 5 +++- .../Models/Instances/IProxyCollection.cs | 7 +----- .../Instances/InstanceDefinitionProxy.cs | 3 +++ src/Speckle.Objects/Other/RenderMaterial.cs | 25 +++++++++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/Speckle.Core/Models/Instances/GroupProxy.cs b/src/Speckle.Core/Models/Instances/GroupProxy.cs index c0221be6..0a94436c 100644 --- a/src/Speckle.Core/Models/Instances/GroupProxy.cs +++ b/src/Speckle.Core/Models/Instances/GroupProxy.cs @@ -1,4 +1,4 @@ -namespace Speckle.Core.Models.Instances; +namespace Speckle.Core.Models.Instances; /// /// Grouped objects with a meaningful way for host application so use this proxy if you want to group object references for any purpose. @@ -8,5 +8,8 @@ public class GroupProxy : Base, IProxyCollection { public List objects { get; set; } + /// + /// Name of the group proxy collection which is unique for rhino, autocad and sketchup + /// public string name { get; set; } } diff --git a/src/Speckle.Core/Models/Instances/IProxyCollection.cs b/src/Speckle.Core/Models/Instances/IProxyCollection.cs index 571e2d33..c6a918d6 100644 --- a/src/Speckle.Core/Models/Instances/IProxyCollection.cs +++ b/src/Speckle.Core/Models/Instances/IProxyCollection.cs @@ -1,4 +1,4 @@ -namespace Speckle.Core.Models.Instances; +namespace Speckle.Core.Models.Instances; /// /// Collection to proxy objects that lies in definitions, groups or whatever logic in the host app. @@ -10,9 +10,4 @@ public interface IProxyCollection /// On receive, they will be mapped to corresponding newly created definition ids. /// public List objects { get; set; } - - /// - /// Name of the proxy collection which is unique for rhino, autocad and sketchup - /// - public string name { get; set; } } diff --git a/src/Speckle.Core/Models/Instances/InstanceDefinitionProxy.cs b/src/Speckle.Core/Models/Instances/InstanceDefinitionProxy.cs index 47c9430a..54227648 100644 --- a/src/Speckle.Core/Models/Instances/InstanceDefinitionProxy.cs +++ b/src/Speckle.Core/Models/Instances/InstanceDefinitionProxy.cs @@ -12,5 +12,8 @@ public class InstanceDefinitionProxy : Base, IInstanceComponent, IProxyCollectio public int maxDepth { get; set; } + /// + /// Name of the instance definition proxy collection which is unique for rhino, autocad and sketchup + /// public string name { get; set; } } diff --git a/src/Speckle.Objects/Other/RenderMaterial.cs b/src/Speckle.Objects/Other/RenderMaterial.cs index dfe7daa8..5ded81cf 100644 --- a/src/Speckle.Objects/Other/RenderMaterial.cs +++ b/src/Speckle.Objects/Other/RenderMaterial.cs @@ -1,6 +1,7 @@ using System.Drawing; using Speckle.Core.Kits; using Speckle.Core.Models; +using Speckle.Core.Models.Instances; using Speckle.Newtonsoft.Json; namespace Objects.Other; @@ -58,3 +59,27 @@ public Color emissiveColor set => diffuse = value.ToArgb(); } } + +/// +/// Used to store render material to object relationships in root collections +/// +public class RenderMaterialProxy : Base, IProxyCollection +{ + public RenderMaterialProxy() { } + + public RenderMaterialProxy(RenderMaterial renderMaterial, List objects) + { + value = renderMaterial; + this.objects = objects; + } + + /// + /// The list of application ids of objects that use this render material + /// + public List objects { get; set; } + + /// + /// The render material used by + /// + public RenderMaterial value { get; set; } +}