From 9da1d791cc51fcf287e140b6b46427f8ac3a8022 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Fri, 2 Aug 2024 16:24:58 +0100 Subject: [PATCH] Restructures proxies, removes layer colors, and adds color proxy class (#58) --- .../Models/Collections/Collection.cs | 4 +-- .../Models/Collections/Interfaces.cs | 12 ------- src/Speckle.Core/Models/Collections/Layer.cs | 11 ++----- .../Instances/InstanceDefinitionProxy.cs | 2 ++ src/Speckle.Core/Models/Proxies/ColorProxy.cs | 31 +++++++++++++++++++ .../{Instances => Proxies}/GroupProxy.cs | 2 +- .../IProxyCollection.cs | 2 +- src/Speckle.Objects/Other/RenderMaterial.cs | 2 +- 8 files changed, 39 insertions(+), 27 deletions(-) delete mode 100644 src/Speckle.Core/Models/Collections/Interfaces.cs create mode 100644 src/Speckle.Core/Models/Proxies/ColorProxy.cs rename src/Speckle.Core/Models/{Instances => Proxies}/GroupProxy.cs (92%) rename src/Speckle.Core/Models/{Instances => Proxies}/IProxyCollection.cs (91%) diff --git a/src/Speckle.Core/Models/Collections/Collection.cs b/src/Speckle.Core/Models/Collections/Collection.cs index d702dcd8..f0cedd39 100644 --- a/src/Speckle.Core/Models/Collections/Collection.cs +++ b/src/Speckle.Core/Models/Collections/Collection.cs @@ -17,11 +17,9 @@ public Collection() { } /// Constructor for a basic collection. /// /// The human-readable name of this collection - /// - public Collection(string name, string collectionType) + public Collection(string name) { this.name = name; - this.collectionType = collectionType; } /// diff --git a/src/Speckle.Core/Models/Collections/Interfaces.cs b/src/Speckle.Core/Models/Collections/Interfaces.cs deleted file mode 100644 index 2ecab1ee..00000000 --- a/src/Speckle.Core/Models/Collections/Interfaces.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Speckle.Core.Models.Collections; - -/// -/// Represents a collection that has a -/// -public interface IHasColor -{ - /// - /// The argb int value of the collection color - /// - public int color { get; set; } -} diff --git a/src/Speckle.Core/Models/Collections/Layer.cs b/src/Speckle.Core/Models/Collections/Layer.cs index 9f1de176..027a0eca 100644 --- a/src/Speckle.Core/Models/Collections/Layer.cs +++ b/src/Speckle.Core/Models/Collections/Layer.cs @@ -3,7 +3,7 @@ namespace Speckle.Core.Models.Collections; /// /// A specialized collection that represents a CAD-app layer. We expect this to grow in the future with possibly other shared props. /// -public class Layer : Collection, IHasColor +public class Layer : Collection { public Layer() { } @@ -11,15 +11,8 @@ public Layer() { } /// Constructor for a basic Layer. /// /// The human-readable name of this collection - /// - public Layer(string name, int color) + public Layer(string name) { this.name = name; - this.color = color; } - - /// - /// The argb int value of the layer color - /// - public int color { get; set; } } diff --git a/src/Speckle.Core/Models/Instances/InstanceDefinitionProxy.cs b/src/Speckle.Core/Models/Instances/InstanceDefinitionProxy.cs index 54227648..a8d4c8ea 100644 --- a/src/Speckle.Core/Models/Instances/InstanceDefinitionProxy.cs +++ b/src/Speckle.Core/Models/Instances/InstanceDefinitionProxy.cs @@ -1,3 +1,5 @@ +using Speckle.Core.Models.Proxies; + namespace Speckle.Core.Models.Instances; /// diff --git a/src/Speckle.Core/Models/Proxies/ColorProxy.cs b/src/Speckle.Core/Models/Proxies/ColorProxy.cs new file mode 100644 index 00000000..f647d041 --- /dev/null +++ b/src/Speckle.Core/Models/Proxies/ColorProxy.cs @@ -0,0 +1,31 @@ +using System.Drawing; +using Speckle.Core.Models.Proxies; + +namespace Speckle.Core.Models.Proxies; + +/// +/// Represents a color that is found on objects and collections in a root collection +/// +public class ColorProxy : Base, IProxyCollection +{ + public ColorProxy() { } + + public ColorProxy(int color, string applicationId, string? name) + { + value = color; + this.applicationId = applicationId; + this.name = name; + } + + public List objects { get; set; } + + /// + /// The argb int of the color + /// + public int value { get; set; } + + /// + /// The name, if any, of the color + /// + public string? name { get; set; } +} diff --git a/src/Speckle.Core/Models/Instances/GroupProxy.cs b/src/Speckle.Core/Models/Proxies/GroupProxy.cs similarity index 92% rename from src/Speckle.Core/Models/Instances/GroupProxy.cs rename to src/Speckle.Core/Models/Proxies/GroupProxy.cs index 0a94436c..03139fb0 100644 --- a/src/Speckle.Core/Models/Instances/GroupProxy.cs +++ b/src/Speckle.Core/Models/Proxies/GroupProxy.cs @@ -1,4 +1,4 @@ -namespace Speckle.Core.Models.Instances; +namespace Speckle.Core.Models.Proxies; /// /// Grouped objects with a meaningful way for host application so use this proxy if you want to group object references for any purpose. diff --git a/src/Speckle.Core/Models/Instances/IProxyCollection.cs b/src/Speckle.Core/Models/Proxies/IProxyCollection.cs similarity index 91% rename from src/Speckle.Core/Models/Instances/IProxyCollection.cs rename to src/Speckle.Core/Models/Proxies/IProxyCollection.cs index c6a918d6..8f40fb5a 100644 --- a/src/Speckle.Core/Models/Instances/IProxyCollection.cs +++ b/src/Speckle.Core/Models/Proxies/IProxyCollection.cs @@ -1,4 +1,4 @@ -namespace Speckle.Core.Models.Instances; +namespace Speckle.Core.Models.Proxies; /// /// Collection to proxy objects that lies in definitions, groups or whatever logic in the host app. diff --git a/src/Speckle.Objects/Other/RenderMaterial.cs b/src/Speckle.Objects/Other/RenderMaterial.cs index 5ded81cf..8a385e5c 100644 --- a/src/Speckle.Objects/Other/RenderMaterial.cs +++ b/src/Speckle.Objects/Other/RenderMaterial.cs @@ -1,7 +1,7 @@ using System.Drawing; using Speckle.Core.Kits; using Speckle.Core.Models; -using Speckle.Core.Models.Instances; +using Speckle.Core.Models.Proxies; using Speckle.Newtonsoft.Json; namespace Objects.Other;