Skip to content

Commit

Permalink
Merge branch 'dui3/alpha' into lock-files-dui3
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Jun 20, 2024
2 parents 3a53a48 + e31969f commit 4964d1e
Show file tree
Hide file tree
Showing 46 changed files with 1,095 additions and 117 deletions.
19 changes: 19 additions & 0 deletions All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B1324D25
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Revit2023.Tests", "DUI3-DX\Converters\Revit\Speckle.Converters.Revit2023.Tests\Speckle.Converters.Revit2023.Tests.csproj", "{AEC26A0B-25F3-4544-A9D6-A427BFF79250}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Converters.Common.Tests", "DUI3-DX\Sdk\Speckle.Converters.Common.Tests\Speckle.Converters.Common.Tests.csproj", "{95E23A97-E5EA-4506-A52C-D3DA9012DA02}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Mac|Any CPU = Debug Mac|Any CPU
Expand Down Expand Up @@ -2807,6 +2809,22 @@ Global
{AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|Any CPU.Build.0 = Release|Any CPU
{AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.ActiveCfg = Release|Any CPU
{AEC26A0B-25F3-4544-A9D6-A427BFF79250}.Release|x64.Build.0 = Release|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|x64.ActiveCfg = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug Mac|x64.Build.0 = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|x64.ActiveCfg = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Debug|x64.Build.0 = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|Any CPU.ActiveCfg = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|Any CPU.Build.0 = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|x64.ActiveCfg = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release Mac|x64.Build.0 = Debug|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|Any CPU.Build.0 = Release|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.ActiveCfg = Release|Any CPU
{95E23A97-E5EA-4506-A52C-D3DA9012DA02}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -3019,6 +3037,7 @@ Global
{F06E4C37-4076-4272-9CA6-FB505E02CD31} = {BE521908-7944-46F3-98BF-B47D34509934}
{E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {D92751C8-1039-4005-90B2-913E55E0B8BD}
{AEC26A0B-25F3-4544-A9D6-A427BFF79250} = {D92751C8-1039-4005-90B2-913E55E0B8BD}
{95E23A97-E5EA-4506-A52C-D3DA9012DA02} = {2E00592E-558D-492D-88F9-3ECEE4C0C7DA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1D43D91B-4F01-4A78-8250-CC6F9BD93A14}
Expand Down
1 change: 0 additions & 1 deletion Core/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<PackageReference Include="Sentry.Serilog" Version="3.33.0"/>
<PackageReference Include="Serilog" Version="2.12.0"/>
<PackageReference Include="Serilog.Enrichers.ClientInfo" Version="1.3.0"/>
<PackageReference Include="Serilog.Enrichers.GlobalLogContext" Version="3.0.0"/>
<PackageReference Include="Serilog.Exceptions" Version="8.4.0"/>
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0"/>
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2"/>
Expand Down
1 change: 1 addition & 0 deletions DUI3-DX.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"DUI3-DX\\Sdk\\Speckle.Autofac\\Speckle.Autofac.csproj",
"DUI3-DX\\Sdk\\Speckle.Connectors.Utils\\Speckle.Connectors.Utils.csproj",
"DUI3-DX\\Sdk\\Speckle.Converters.Common.DependencyInjection\\Speckle.Converters.Common.DependencyInjection.csproj",
"DUI3-DX\\Sdk\\Speckle.Converters.Common.Tests\\Speckle.Converters.Common.Tests.csproj",
"DUI3-DX\\Sdk\\Speckle.Converters.Common\\Speckle.Converters.Common.csproj",
"Objects\\Objects\\Objects.csproj",
"Objects\\Tests\\Objects.Tests.Unit\\Objects.Tests.Unit.csproj"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Speckle.Connectors.ArcGIS.Bindings;

public class ArcGISSelectionBinding : ISelectionBinding
{
public string Name { get; } = "selectionBinding";
public IBridge Parent { get; set; }
public string Name => "selectionBinding";
public IBridge Parent { get; }

public ArcGISSelectionBinding(IBridge parent)
{
Expand All @@ -22,7 +22,7 @@ public ArcGISSelectionBinding(IBridge parent)
private void OnSelectionChanged(MapViewEventArgs args)
{
SelectionInfo selInfo = GetSelection();
Parent?.Send(SelectionBindingEvents.SET_SELECTION, selInfo);
Parent.Send(SelectionBindingEvents.SET_SELECTION, selInfo);
}

public SelectionInfo GetSelection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ private void SelectMapMembersInTOC(List<MapMember> mapMembers)
{
if (member is Layer layer)
{
layers.Add(layer);
if (member is not GroupLayer) // group layer selection clears other layers selection
{
layers.Add(layer);
}
}
else if (member is StandaloneTable table)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ CancellationToken cancellationToken
{
if (IsGISType(obj))
{
string nestedLayerPath = $"{string.Join("\\", path)}\\{((Collection)obj).name}";
string nestedLayerPath = $"{string.Join("\\", path)}";
string datasetId = (string)_converter.Convert(obj);
conversionTracker[ctx] = new ObjectConversionTracker(obj, nestedLayerPath, datasetId);
}
Expand All @@ -92,10 +92,17 @@ CancellationToken cancellationToken
onOperationProgressed?.Invoke("Writing to Database", null);
_nonGisFeaturesUtils.WriteGeometriesToDatasets(conversionTracker);

// Create main group layer
Dictionary<string, GroupLayer> createdLayerGroups = new();
Map map = _contextStack.Current.Document.Map;
GroupLayer groupLayer = LayerFactory.Instance.CreateGroupLayer(map, 0, $"{projectName}: {modelName}");
createdLayerGroups["Basic Speckle Group"] = groupLayer; // key doesn't really matter here

// 3. add layer and tables to the Table Of Content
int bakeCount = 0;
Dictionary<string, MapMember> bakedMapMembers = new();
onOperationProgressed?.Invoke("Adding to Map", bakeCount);

foreach (var item in conversionTracker)
{
cancellationToken.ThrowIfCancellationRequested();
Expand All @@ -120,7 +127,7 @@ CancellationToken cancellationToken
else
{
// add layer and layer URI to tracker
MapMember mapMember = AddDatasetsToMap(trackerItem);
MapMember mapMember = AddDatasetsToMap(trackerItem, createdLayerGroups);
trackerItem.AddConvertedMapMember(mapMember);
trackerItem.AddLayerURI(mapMember.URI);
conversionTracker[item.Key] = trackerItem;
Expand All @@ -133,6 +140,7 @@ CancellationToken cancellationToken
}
onOperationProgressed?.Invoke("Adding to Map", (double)++bakeCount / conversionTracker.Count);
}
bakedObjectIds.AddRange(createdLayerGroups.Values.Select(x => x.URI));

// TODO: validated a correct set regarding bakedobject ids
return new(bakedObjectIds, results);
Expand Down Expand Up @@ -160,37 +168,77 @@ private void AddResultsFromTracker(ObjectConversionTracker trackerItem, List<Rec
}
}

private MapMember AddDatasetsToMap(ObjectConversionTracker trackerItem)
private MapMember AddDatasetsToMap(
ObjectConversionTracker trackerItem,
Dictionary<string, GroupLayer> createdLayerGroups
)
{
// get layer details
string? datasetId = trackerItem.DatasetId; // should not ne null here
Uri uri = new($"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{datasetId}");
string nestedLayerName = trackerItem.NestedLayerName;

Uri uri = new($"{_contextStack.Current.Document.SpeckleDatabasePath.AbsolutePath.Replace('/', '\\')}\\{datasetId}");
Map map = _contextStack.Current.Document.Map;
// add group for the current layer
string shortName = nestedLayerName.Split("\\")[^1];
string nestedLayerPath = string.Join("\\", nestedLayerName.Split("\\").SkipLast(1));

GroupLayer groupLayer = CreateNestedGroupLayer(nestedLayerPath, createdLayerGroups);

// Most of the Speckle-written datasets will be containing geometry and added as Layers
// although, some datasets might be just tables (e.g. native GIS Tables, in the future maybe Revit schedules etc.
// We can create a connection to the dataset in advance and determine its type, but this will be more
// expensive, than assuming by default that it's a layer with geometry (which in most cases it's expected to be)
try
{
var layer = LayerFactory.Instance.CreateLayer(uri, map, layerName: nestedLayerName);
var layer = LayerFactory.Instance.CreateLayer(uri, groupLayer, layerName: shortName);
layer.SetExpanded(true);
return layer;
}
catch (ArgumentException)
{
var table = StandaloneTableFactory.Instance.CreateStandaloneTable(uri, map, tableName: nestedLayerName);
var table = StandaloneTableFactory.Instance.CreateStandaloneTable(uri, groupLayer, tableName: shortName);
return table;
}
}

private GroupLayer CreateNestedGroupLayer(string nestedLayerPath, Dictionary<string, GroupLayer> createdLayerGroups)
{
GroupLayer lastGroup = createdLayerGroups.FirstOrDefault().Value;
if (lastGroup == null) // if layer not found
{
throw new InvalidOperationException("Speckle Layer Group not found");
}

// iterate through each nested level
string createdGroupPath = "";
var allPathElements = nestedLayerPath.Split("\\").Where(x => !string.IsNullOrEmpty(x));
foreach (string pathElement in allPathElements)
{
createdGroupPath += "\\" + pathElement;
if (createdLayerGroups.TryGetValue(createdGroupPath, out var existingGroupLayer))
{
lastGroup = existingGroupLayer;
}
else
{
// create new GroupLayer under last found Group, named with last pathElement
lastGroup = LayerFactory.Instance.CreateGroupLayer(lastGroup, 0, pathElement);
lastGroup.SetExpanded(true);
}
createdLayerGroups[createdGroupPath] = lastGroup;
}
return lastGroup;
}

[Pure]
private static string[] GetLayerPath(TraversalContext context)
{
string[] collectionBasedPath = context.GetAscendantOfType<Collection>().Select(c => c.name).ToArray();
string[] reverseOrderPath =
collectionBasedPath.Length != 0 ? collectionBasedPath : context.GetPropertyPath().ToArray();
return reverseOrderPath.Reverse().ToArray();

var originalPath = reverseOrderPath.Reverse().ToArray();
return originalPath.Where(x => !string.IsNullOrEmpty(x)).ToArray();
}

[Pure]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ public class AutocadSelectionBinding : ISelectionBinding
{
private const string SELECTION_EVENT = "setSelection";

private readonly List<Document> _visitedDocuments = new();

public string Name { get; set; } = "selectionBinding";

private readonly HashSet<Document> _visitedDocuments = new();
public string Name => "selectionBinding";
public IBridge Parent { get; }

public AutocadSelectionBinding(IBridge parent)
Expand All @@ -26,9 +24,9 @@ public AutocadSelectionBinding(IBridge parent)
Application.DocumentManager.DocumentActivated += (sender, e) => OnDocumentChanged(e.Document);
}

private void OnDocumentChanged(Document document) => TryRegisterDocumentForSelection(document);
private void OnDocumentChanged(Document? document) => TryRegisterDocumentForSelection(document);

private void TryRegisterDocumentForSelection(Document document)
private void TryRegisterDocumentForSelection(Document? document)
{
if (document == null)
{
Expand All @@ -49,13 +47,13 @@ private void TryRegisterDocumentForSelection(Document document)
private void OnSelectionChanged()
{
SelectionInfo selInfo = GetSelection();
Parent?.Send(SELECTION_EVENT, selInfo);
Parent.Send(SELECTION_EVENT, selInfo);
}

public SelectionInfo GetSelection()
{
// POC: Will be addressed to move it into AutocadContext! https://spockle.atlassian.net/browse/CNX-9319
Document doc = Application.DocumentManager.MdiActiveDocument;
Document? doc = Application.DocumentManager.MdiActiveDocument;
List<string> objs = new();
List<string> objectTypes = new();
if (doc != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Speckle.Connectors.Autocad.Bindings;

public sealed class AutocadSendBinding : ISendBinding
{
public string Name { get; } = "sendBinding";
public string Name => "sendBinding";
public SendBindingUICommands Commands { get; }
public IBridge Parent { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace Speckle.Connectors.Revit.Bindings;
internal abstract class RevitBaseBinding : IBinding
{
// POC: name and bridge might be better for them to be protected props?
public string Name { get; protected set; }
public IBridge Parent { get; protected set; }
public string Name { get; }
public IBridge Parent { get; }

protected readonly DocumentModelStore Store;
protected readonly RevitContext RevitContext;

public RevitBaseBinding(string name, DocumentModelStore store, IBridge bridge, RevitContext revitContext)
protected RevitBaseBinding(string name, DocumentModelStore store, IBridge bridge, RevitContext revitContext)
{
Name = name;
Parent = bridge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ public RootObjectBuilderResult Build(
var countProgress = 0; // because for(int i = 0; ...) loops are so last year
var cacheHitCount = 0;
List<SendConversionResult> results = new(revitElements.Count);
var path = new string[2];
foreach (Element revitElement in revitElements)
{
ct.ThrowIfCancellationRequested();

var cat = revitElement.Category.Name;
var path = new[] { doc.GetElement(revitElement.LevelId) is not Level level ? "No level" : level.Name, cat };
path[0] = doc.GetElement(revitElement.LevelId) is not Level level ? "No level" : level.Name;
path[1] = cat;
var collection = GetAndCreateObjectHostCollection(path);

var applicationId = revitElement.Id.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace Speckle.Connectors.Rhino7.Bindings;

public class RhinoBasicConnectorBinding : IBasicConnectorBinding
{
public string Name { get; set; } = "baseBinding";
public IBridge Parent { get; set; }
public string Name => "baseBinding";
public IBridge Parent { get; }
public BasicConnectorBindingCommands Commands { get; }

private readonly DocumentModelStore _store;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace Speckle.Connectors.Rhino7.Bindings;

public class RhinoReceiveBinding : IReceiveBinding
{
public string Name { get; set; } = "receiveBinding";
public IBridge Parent { get; set; }
public string Name => "receiveBinding";
public IBridge Parent { get; }

private readonly CancellationManager _cancellationManager;
private readonly DocumentModelStore _store;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace Speckle.Connectors.Rhino7.Bindings;

public sealed class RhinoSendBinding : ISendBinding
{
public string Name { get; } = "sendBinding";
public string Name => "sendBinding";
public SendBindingUICommands Commands { get; }
public IBridge Parent { get; set; }
public IBridge Parent { get; }

private readonly DocumentModelStore _store;
private readonly RhinoIdleManager _idleManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ArcGISConverterModule : ISpeckleModule
public void Load(SpeckleContainerBuilder builder)
{
//don't need a host specific RootToSpeckleConverter
builder.AddConverterCommon<RootToSpeckleConverter, ArcGISToSpeckleUnitConverter, Unit>();
builder.AddConverterCommon<LegacyRootToSpeckleConverter, ArcGISToSpeckleUnitConverter, Unit>();
// most things should be InstancePerLifetimeScope so we get one per operation
builder.AddScoped<IFeatureClassUtils, FeatureClassUtils>();
builder.AddScoped<IArcGISFieldUtils, ArcGISFieldUtils>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class RevitConverterModule : ISpeckleModule
public void Load(SpeckleContainerBuilder builder)
{
builder.AddConverterCommon<RootToSpeckleConverter, RevitToSpeckleUnitConverter, IRevitForgeTypeId>();
builder.ScanAssemblyOfType<RootConvertManager>();

// POC: do we need ToSpeckleScalingService as is, do we need to interface it out?
builder.AddScoped<IScalingServiceToSpeckle, ScalingServiceToSpeckle>();
Expand All @@ -28,5 +29,6 @@ public void Load(SpeckleContainerBuilder builder)
builder.AddScoped<IHostedElementConversionToSpeckle, HostedElementConversionToSpeckle>();
builder.AddScoped<IParameterObjectAssigner, ParameterObjectAssigner>();
builder.AddScoped<ISlopeArrowExtractor, SlopeArrowExtractor>();
builder.AddScoped<IRootElementProvider, RevitRootElementProvider>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Speckle.Revit2023.Api" Version="0.1.1-preview.0.23" />
<PackageReference Include="Speckle.Revit2023.Api" Version="0.1.1-preview.0.24" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Sdk\Speckle.Converters.Common.DependencyInjection\Speckle.Converters.Common.DependencyInjection.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0"/>
<PackageReference Include="coverlet.collector" Version="6.0.2"/>
<PackageReference Include="Speckle.Revit2023.Interfaces" Version="0.1.1-preview.0.23" />
<PackageReference Include="Speckle.Revit2023.Interfaces" Version="0.1.1-preview.0.24" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 4964d1e

Please sign in to comment.