Skip to content

Commit

Permalink
Rhino interfaces for testing (#3523)
Browse files Browse the repository at this point in the history
* add root converter with fallback and tests

* proper references

* Converters work

* fmt

* added test!

* fmt

* One converter to rhino interfaces

* more converters done

* more converters done!

* even more converters

* more conversions

* more top level converters

* all rhino types converted

* doing Rhino loading and testing

* type moving around

* update and use interfaces

* using clean up

* clean up

* Change reflection

* update host api and add tests

* add no build for tests

* revert for circular dependency

* to host fixes

* update host apis and lock files

* fmt

* fixes curves!
  • Loading branch information
adamhathcock authored Jun 25, 2024
1 parent 483fe7d commit 207753c
Show file tree
Hide file tree
Showing 106 changed files with 979 additions and 777 deletions.
6 changes: 5 additions & 1 deletion Build/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ namespace Build;
public static class Consts
{
public static readonly string[] Solutions = { "DUI3-DX.slnf" };
public static readonly string[] TestProjects = { "Speckle.Converters.Revit2023.Tests" };
public static readonly string[] TestProjects =
{
"Speckle.Converters.Revit2023.Tests",
"Speckle.Converters.Common.Tests"
};

public static readonly InstallerProject[] InstallerManifests =
{
Expand Down
2 changes: 1 addition & 1 deletion Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ IEnumerable<string> GetFiles(string d)

foreach (var file in GetFiles($"**/{t}.csproj"))
{
Run("dotnet", $"test {file} -c Release --no-restore --verbosity=normal");
Run("dotnet", $"test {file} -c Release --no-build --no-restore --verbosity=normal");
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,6 @@
"resolved": "13.0.2",
"contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA=="
},
"Speckle.Revit2023.Interfaces": {
"type": "Transitive",
"resolved": "0.1.1-preview.0.24",
"contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A=="
},
"SQLitePCLRaw.bundle_e_sqlite3": {
"type": "Transitive",
"resolved": "2.1.4",
Expand Down Expand Up @@ -431,8 +426,7 @@
"type": "Project",
"dependencies": {
"Speckle.Autofac": "[2.0.999-local, )",
"Speckle.Objects": "[2.0.999-local, )",
"Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )"
"Speckle.Objects": "[2.0.999-local, )"
}
},
"speckle.converters.common.dependencyinjection": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,6 @@
"resolved": "13.0.2",
"contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA=="
},
"Speckle.Revit2023.Interfaces": {
"type": "Transitive",
"resolved": "0.1.1-preview.0.24",
"contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A=="
},
"SQLitePCLRaw.bundle_e_sqlite3": {
"type": "Transitive",
"resolved": "2.1.4",
Expand Down Expand Up @@ -487,8 +482,7 @@
"type": "Project",
"dependencies": {
"Speckle.Autofac": "[2.0.999-local, )",
"Speckle.Objects": "[2.0.999-local, )",
"Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )"
"Speckle.Objects": "[2.0.999-local, )"
}
},
"speckle.converters.common.dependencyinjection": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,18 +315,18 @@
},
"Speckle.Revit2023.Api": {
"type": "Transitive",
"resolved": "0.1.1-preview.0.24",
"contentHash": "hPRXbyvgmealdPPWTxjHbpBRTsyt67DddoIs09M0n319eHh/eONnPC+SgBzJmmB834TtzzayMVk06S1cMT0Iow==",
"resolved": "0.1.1-preview.0.28",
"contentHash": "ejwYS/HI8yy0rJE4vgTr5aj8Fkg/E9JnMGjwyVS2fLtI4f7+FmwAY6inTUT2p/RAoRc2nQw+TerDpUtOhddzag==",
"dependencies": {
"Mapster": "7.3.0",
"Speckle.Revit.API": "2023.0.0",
"Speckle.Revit2023.Interfaces": "0.1.1-preview.0.24"
"Speckle.Revit2023.Interfaces": "0.1.1-preview.0.28"
}
},
"Speckle.Revit2023.Interfaces": {
"type": "Transitive",
"resolved": "0.1.1-preview.0.24",
"contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A=="
"resolved": "0.1.1-preview.0.28",
"contentHash": "7szXg/vRvP3Wdrn2ZGriVOfsw+bddlpVorBkCIhSHHs5qVTTG8IAIrI1l9dO0/aullaTMF+Xgxm9x3w1aXPiuA=="
},
"SQLitePCLRaw.bundle_e_sqlite3": {
"type": "Transitive",
Expand Down Expand Up @@ -514,8 +514,7 @@
"type": "Project",
"dependencies": {
"Speckle.Autofac": "[2.0.999-local, )",
"Speckle.Objects": "[2.0.999-local, )",
"Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )"
"Speckle.Objects": "[2.0.999-local, )"
}
},
"speckle.converters.common.dependencyinjection": {
Expand All @@ -529,7 +528,7 @@
"type": "Project",
"dependencies": {
"Speckle.Converters.Common": "[2.0.999-local, )",
"Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )"
"Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.28, )"
}
},
"speckle.converters.revit2023.dependencyinjection": {
Expand All @@ -538,7 +537,7 @@
"Speckle.Converters.Common": "[2.0.999-local, )",
"Speckle.Converters.Common.DependencyInjection": "[2.0.999-local, )",
"Speckle.Converters.Revit2023": "[2.0.999-local, )",
"Speckle.Revit2023.Api": "[0.1.1-preview.0.24, )"
"Speckle.Revit2023.Api": "[0.1.1-preview.0.28, )"
}
},
"Speckle.Core": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Speckle.Converters.Common;
using Speckle.ProxyGenerator;

namespace Speckle.Connectors.Revit.DependencyInjection;

public class ProxyMapper : IProxyMapper
{
public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type);

public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type);

public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type);

public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap);

public T CreateProxy<T>(object toWrap) => ProxyMap.CreateProxy<T>(toWrap);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ namespace Speckle.Connectors.Rhino7.Bindings;

public class RhinoSelectionBinding : ISelectionBinding
{
private readonly RhinoIdleManager _idleManager;
private readonly IRhinoIdleManager _idleManager;
private readonly ITopLevelExceptionHandler _topLevelExceptionHandler;
private const string SELECTION_EVENT = "setSelection";

public string Name => "selectionBinding";
public IBridge Parent { get; }

public RhinoSelectionBinding(
RhinoIdleManager idleManager,
IRhinoIdleManager idleManager,
IBridge parent,
ITopLevelExceptionHandler topLevelExceptionHandler
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ public sealed class RhinoSendBinding : ISendBinding
public IBridge Parent { get; }

private readonly DocumentModelStore _store;
private readonly RhinoIdleManager _idleManager;
private readonly IRhinoIdleManager _idleManager;
private readonly IUnitOfWorkFactory _unitOfWorkFactory;
private readonly List<ISendFilter> _sendFilters;
private readonly SendOperation<RhinoObject> _sendOperation;
private readonly CancellationManager _cancellationManager;
private readonly RhinoSettings _rhinoSettings;

Expand All @@ -40,10 +39,9 @@ public sealed class RhinoSendBinding : ISendBinding

public RhinoSendBinding(
DocumentModelStore store,
RhinoIdleManager idleManager,
IRhinoIdleManager idleManager,
IBridge parent,
IEnumerable<ISendFilter> sendFilters,
SendOperation<RhinoObject> sendOperation,
IUnitOfWorkFactory unitOfWorkFactory,
RhinoSettings rhinoSettings,
CancellationManager cancellationManager,
Expand All @@ -54,7 +52,6 @@ ITopLevelExceptionHandler topLevelExceptionHandler
_store = store;
_idleManager = idleManager;
_unitOfWorkFactory = unitOfWorkFactory;
_sendOperation = sendOperation;
_sendFilters = sendFilters.ToList();
_rhinoSettings = rhinoSettings;
_cancellationManager = cancellationManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Speckle.Converters.Common;
using Speckle.ProxyGenerator;

namespace Speckle.Connectors.Rhino7.DependencyInjection;

public class ProxyMapper : IProxyMapper
{
public Type? GetMappedTypeFromHostType(Type type) => ProxyMap.GetMappedTypeFromHostType(type);

public Type? GetMappedTypeFromProxyType(Type type) => ProxyMap.GetMappedTypeFromProxyType(type);

public Type? GetHostTypeFromMappedType(Type type) => ProxyMap.GetHostTypeFromMappedType(type);

public object CreateProxy(Type type, object toWrap) => ProxyMap.CreateProxy(type, toWrap);

public T CreateProxy<T>(object toWrap) => ProxyMap.CreateProxy<T>(toWrap);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Speckle.Connectors.Rhino7.Bindings;
using Speckle.Connectors.Rhino7.Filters;
using Speckle.Connectors.Rhino7.HostApp;
using Speckle.Connectors.Rhino7.Interfaces;
using Speckle.Connectors.Rhino7.Operations.Send;
using Speckle.Connectors.Rhino7.Plugin;
using Speckle.Connectors.Utils.Cancellation;
Expand All @@ -21,7 +20,9 @@
using Speckle.Connectors.Utils.Builders;
using Speckle.Connectors.Utils.Caching;
using Speckle.Connectors.Utils.Operations;
using Speckle.Converters.Common;
using Speckle.Core.Models.GraphTraversal;
using Speckle.Rhino7.Api;

namespace Speckle.Connectors.Rhino7.DependencyInjection;

Expand All @@ -37,14 +38,16 @@ public void Load(SpeckleContainerBuilder builder)
builder.AddConnectorUtils();
builder.AddDUI();
builder.AddDUIView();
builder.ScanAssemblyOfType<RhinoArcFactory>();

// POC: Overwriting the SyncToMainThread to SyncToCurrentThread for Rhino!
builder.AddSingletonInstance<ISyncToThread, SyncToCurrentThread>();

// Register other connector specific types
builder.AddSingleton<IRhinoPlugin, RhinoPlugin>();
builder.AddSingleton<DocumentModelStore, RhinoDocumentStore>();
builder.AddSingleton<RhinoIdleManager>();
builder.AddSingleton<IRhinoIdleManager, RhinoIdleManager>();
builder.AddSingleton<IProxyMapper, ProxyMapper>();

// Register bindings
builder.AddSingleton<IBinding, TestBinding>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
using Rhino;
using Speckle.Connectors.DUI.WebView;
using Speckle.Connectors.Rhino7.HostApp;
using Speckle.Connectors.Rhino7.Interfaces;
using Speckle.Connectors.Rhino7.Plugin;
using Speckle.InterfaceGenerator;

namespace Speckle.Connectors.Rhino7.DependencyInjection;

[GenerateAutoInterface]
public class RhinoPlugin : IRhinoPlugin
{
private readonly RhinoIdleManager _idleManager;
private readonly DUI3ControlWebView _panel;
private readonly RhinoSettings _settings;
private readonly IRhinoIdleManager _idleManager;

public RhinoPlugin(DUI3ControlWebView panel, RhinoSettings settings, RhinoIdleManager idleManager)
public RhinoPlugin(IRhinoIdleManager idleManager)
{
_panel = panel;
_settings = settings;
_idleManager = idleManager;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System.Collections.Concurrent;
using Rhino;
using Speckle.InterfaceGenerator;

namespace Speckle.Connectors.Rhino7.HostApp;

/// <summary>
/// Rhino Idle Manager is a helper util to manage deferred actions.
/// </summary>
public class RhinoIdleManager
[GenerateAutoInterface]
public class RhinoIdleManager : IRhinoIdleManager
{
// NOTE: ConcurrentDictionary possibly removing the collection has been modified errors in here
private readonly ConcurrentDictionary<string, Action> _sCalls = new();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using Rhino.DocObjects.Tables;
using Speckle.Rhino7.Interfaces;

namespace Speckle.Connectors.Rhino7.Operations.Receive;

/// <summary>
/// Helper class to disable <see cref="ViewTable.RedrawEnabled"/> within a scope
/// Helper class to disable <see cref="IRhinoViewTable.RedrawEnabled"/> within a scope
/// </summary>
public sealed class DisableRedrawScope : IDisposable
{
private readonly ViewTable _viewTable;
private readonly IRhinoViewTable _viewTable;
private readonly bool _returnToStatus;

public DisableRedrawScope(ViewTable viewTable, bool returnToStatus = true)
public DisableRedrawScope(IRhinoViewTable viewTable, bool returnToStatus = true)
{
_viewTable = viewTable;
_returnToStatus = returnToStatus;
Expand Down
Loading

0 comments on commit 207753c

Please sign in to comment.