Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geometry visualization #245

Merged
merged 21 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions RevitLookup.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ Global
Benchmark|Any CPU = Benchmark|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.UI.Demo Debug|Any CPU.ActiveCfg = Debug R22|Any CPU
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.UI.Demo Debug|Any CPU.Build.0 = Debug R22|Any CPU
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.UI.Demo Release|Any CPU.ActiveCfg = Release R22|Any CPU
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.UI.Demo Release|Any CPU.Build.0 = Release R22|Any CPU
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.Benchmark|Any CPU.ActiveCfg = Release R24|Any CPU
Expand All @@ -64,6 +62,8 @@ Global
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.Release R24|Any CPU.Build.0 = Release R24|Any CPU
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.Release R25|Any CPU.ActiveCfg = Release R25|Any CPU
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.Release R25|Any CPU.Build.0 = Release R25|Any CPU
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.UI.Demo Debug|Any CPU.ActiveCfg = Debug R25|Any CPU
{05C77115-2277-4DFC-8F95-BE37E5F1130F}.UI.Demo Debug|Any CPU.Build.0 = Debug R25|Any CPU
{64D9C223-D070-46CD-A635-04FD4E1BEC3C}.UI.Demo Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64D9C223-D070-46CD-A635-04FD4E1BEC3C}.UI.Demo Release|Any CPU.ActiveCfg = Release|Any CPU
{64D9C223-D070-46CD-A635-04FD4E1BEC3C}.Installer|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -141,8 +141,8 @@ Global
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Benchmark|Any CPU.Build.0 = Release|Any CPU
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Installer|Any CPU.ActiveCfg = Release|Any CPU
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Debug R21|Any CPU.ActiveCfg = Debug|Any CPU
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Debug R22|Any CPU.ActiveCfg = Debug|Any CPU
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Debug R23|Any CPU.ActiveCfg = Debug|Any CPU
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Debug R22|Any CPU.ActiveCfg = Debug|Any CPU
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Debug R23|Any CPU.ActiveCfg = Debug|Any CPU
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Debug R24|Any CPU.ActiveCfg = Debug|Any CPU
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Debug R25|Any CPU.ActiveCfg = Debug|Any CPU
{827646DF-D373-4D40-8F0B-1E9842E3CE9A}.Release R21|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
6 changes: 3 additions & 3 deletions source/RevitLookup.UI.Demo/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ private void OnStartup(object sender, StartupEventArgs e)
private void OnExit(object sender, ExitEventArgs e)
{
var settingsService = Host.GetService<ISettingsService>();
settingsService.Save();
settingsService.SaveSettings();

Host.Stop();
}

private Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args)
{
var assemblyName = new AssemblyName(args.Name);
var path = _revitPath ?? $@"C:\Program Files\Autodesk\Revit 20{assemblyName.Version.Major}";
var path = _revitPath ?? $@"C:\Program Files\Autodesk\Revit 20{assemblyName.Version!.Major}";
if (!Directory.Exists(path)) return null;
_revitPath = path;

return Directory.EnumerateFiles(_revitPath, $"{assemblyName.Name}.dll")
.Select(Assembly.LoadFile)
.Select(Assembly.LoadFrom)
.First();
}
}
2 changes: 1 addition & 1 deletion source/RevitLookup.UI.Demo/HostProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static IHost CreateHost()

//Logging
builder.Logging.ClearProviders();
builder.Logging.AddLoggerConfiguration();
builder.Logging.AddSerilogConfiguration();

//Configuration
builder.Services.AddOptions(builder.Configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public ILookupServiceDependsStage Snoop(SnoopableObject snoopableObject)
return this;
}

public ILookupServiceDependsStage Snoop(IReadOnlyCollection<SnoopableObject> snoopableObjects)
public ILookupServiceDependsStage Snoop(IList<SnoopableObject> snoopableObjects)
{
_scope.ServiceProvider.GetService<ISnoopVisualService>()!.Snoop(snoopableObjects);
return this;
}

public ILookupServiceShowStage DependsOn(IServiceProvider provider)
{
_owner = (Window) provider.GetService<IWindow>();
_owner = (Window)provider.GetService<IWindow>();
return this;
}

Expand Down Expand Up @@ -86,7 +86,7 @@ public void Execute<T>(Action<T> handler) where T : class

private void ShowPage<T>() where T : Page
{
var window = (Window) _scope.ServiceProvider.GetService<IWindow>();
var window = (Window)_scope.ServiceProvider.GetService<IWindow>();
window.Closed += OnWindowClosed;

if (_owner is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ public sealed partial class MockEventsViewModel(
{
private readonly CancellationTokenSource _cancellationTokenSource = new();
private readonly Stack<SnoopableObject> _events = new();

[ObservableProperty] private string _searchText = string.Empty;
[ObservableProperty] private IReadOnlyCollection<SnoopableObject> _snoopableObjects = Array.Empty<SnoopableObject>();
[ObservableProperty] private IReadOnlyCollection<SnoopableObject> _filteredSnoopableObjects = Array.Empty<SnoopableObject>();
[ObservableProperty] private IReadOnlyCollection<Descriptor> _snoopableData;
[ObservableProperty] private IReadOnlyCollection<Descriptor> _filteredSnoopableData;
[ObservableProperty] private IList<SnoopableObject> _snoopableObjects = [];
[ObservableProperty] private IList<SnoopableObject> _filteredSnoopableObjects = [];
[ObservableProperty] private IList<Descriptor> _filteredSnoopableData;
[ObservableProperty] private IList<Descriptor> _snoopableData;

public SnoopableObject SelectedObject { get; set; }
public IServiceProvider ServiceProvider { get; } = provider;
Expand All @@ -36,26 +37,39 @@ public void Navigate(SnoopableObject selectedItem)
.Show<SnoopView>();
}

public void Navigate(IReadOnlyCollection<SnoopableObject> selectedItems)
public void Navigate(IList<SnoopableObject> selectedItems)
{
Host.GetService<ILookupService>()
.Snoop(selectedItems)
.DependsOn(ServiceProvider)
.Show<SnoopView>();
}

public void RemoveObject(object obj)
{
var snoopableObject = obj switch
{
SnoopableObject snoopable => snoopable,
Descriptor descriptor => descriptor.Value.Descriptor.Value,
_ => throw new NotSupportedException($"Type {obj.GetType().Name} removing not supported")
};

SnoopableObjects.Remove(snoopableObject);
FilteredSnoopableObjects.Remove(snoopableObject);
}

partial void OnSearchTextChanged(string value)
{
UpdateSearchResults(SearchOption.Objects);
}

partial void OnSnoopableObjectsChanged(IReadOnlyCollection<SnoopableObject> value)
partial void OnSnoopableObjectsChanged(IList<SnoopableObject> value)
{
SelectedObject = null;
UpdateSearchResults(SearchOption.Objects);
}

partial void OnSnoopableDataChanged(IReadOnlyCollection<Descriptor> value)
partial void OnSnoopableDataChanged(IList<Descriptor> value)
{
UpdateSearchResults(SearchOption.Selection);
}
Expand Down
2 changes: 1 addition & 1 deletion source/RevitLookup.UI.Demo/RevitLookup.UI.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>latest</LangVersion>
<PlatformTarget>x64</PlatformTarget>
<ImplicitUsings>true</ImplicitUsings>
<TargetFramework>net48</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>2023.0.0</Version>
</PropertyGroup>
Expand Down
6 changes: 4 additions & 2 deletions source/RevitLookup.UI/SimpleContentDialogCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ public class SimpleContentDialogCreateOptions
/// <summary>
/// Gets or sets a dialog Horizontal Alignment.
/// </summary>
/// <returns>HorizontalAlignment.Stretch by default</returns>
public HorizontalAlignment DialogHorizontalAlignment { get; set; } = HorizontalAlignment.Stretch;

/// <summary>
/// Gets or sets a dialog Vertical Alignment.
/// </summary>
/// <returns>VerticalAlignment.Stretch by default</returns>
public VerticalAlignment DialogVerticalAlignment { get; set; } = VerticalAlignment.Stretch;
}
}
15 changes: 8 additions & 7 deletions source/RevitLookup/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Nice3point.Revit.Toolkit.External;
using Nice3point.Revit.Toolkit.External.Handlers;
using RevitLookup.Core.Objects;
using RevitLookup.Models.Settings;
using RevitLookup.Services.Contracts;
using RevitLookup.Utils;

Expand All @@ -45,8 +46,8 @@ public override void OnStartup()
var settingsService = Host.GetService<ISettingsService>();
var updateService = Host.GetService<ISoftwareUpdateService>();

EnableHardwareRendering(settingsService);
RibbonController.CreatePanel(Application, settingsService);
EnableHardwareRendering(settingsService.GeneralSettings);
RibbonController.CreatePanel(Application, settingsService.GeneralSettings);

updateService.CheckUpdates();
}
Expand All @@ -67,21 +68,21 @@ private static void UpdateSoftware()
private static void SaveSettings()
{
var settingsService = Host.GetService<ISettingsService>();
settingsService.Save();
settingsService.SaveSettings();
}

public static void EnableHardwareRendering(ISettingsService settingsService)
public static void EnableHardwareRendering(GeneralSettings settings)
{
if (!settingsService.UseHardwareRendering) return;
if (!settings.UseHardwareRendering) return;

//Revit overrides render mode during initialization
//EventHandler is called after initialization
ActionEventHandler.Raise(_ => RenderOptions.ProcessRenderMode = RenderMode.Default);
}

public static void DisableHardwareRendering(ISettingsService settingsService)
public static void DisableHardwareRendering(GeneralSettings settings)
{
if (settingsService.UseHardwareRendering) return;
if (settings.UseHardwareRendering) return;
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
}

Expand Down
55 changes: 55 additions & 0 deletions source/RevitLookup/Config/GeneralConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2003-2024 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.

using System.Text.Json.Serialization;
using Wpf.Ui.Appearance;
using Wpf.Ui.Controls;

namespace RevitLookup.Config;

/// <summary>
/// Settings options saved on disk
/// </summary>
[Serializable]
public sealed class GeneralConfiguration
{
public int DefaultTransitionDuration => 200;

[JsonPropertyName("Theme")] public ApplicationTheme Theme { get; set; } = ApplicationTheme.Light;
[JsonPropertyName("Background")] public WindowBackdropType Background { get; set; } = WindowBackdropType.None;
[JsonPropertyName("TransitionDuration")] public int TransitionDuration { get; set; } //= SettingsService.DefaultTransitionDuration;

[JsonPropertyName("WindowWidth")] public double WindowWidth { get; set; }
[JsonPropertyName("WindowHeight")] public double WindowHeight { get; set; }

[JsonPropertyName("IsUnsupportedAllowed")] public bool IncludeUnsupported { get; set; }
[JsonPropertyName("IsPrivateAllowed")] public bool IncludePrivate { get; set; }
[JsonPropertyName("IsStaticAllowed")] public bool IncludeStatic { get; set; }
[JsonPropertyName("IsFieldsAllowed")] public bool IncludeFields { get; set; }
[JsonPropertyName("IsEventsAllowed")] public bool IncludeEvents { get; set; }
[JsonPropertyName("IsExtensionsAllowed")] public bool IncludeExtensions { get; set; }
[JsonPropertyName("IsRootHierarchyAllowed")] public bool IncludeRootHierarchy { get; set; }

[JsonPropertyName("IsHardwareRenderingAllowed")] public bool UseHardwareRendering { get; set; } = true;
[JsonPropertyName("IsTimeColumnAllowed")] public bool ShowTimeColumn { get; set; }
[JsonPropertyName("ShowMemoryColumn")] public bool ShowMemoryColumn { get; set; }
[JsonPropertyName("UseSizeRestoring")] public bool UseSizeRestoring { get; set; }
[JsonPropertyName("IsModifyTabAllowed")] public bool UseModifyTab { get; set; }
}
3 changes: 2 additions & 1 deletion source/RevitLookup/Config/OptionsConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public static void AddOptions(this IServiceCollection services, ConfigurationMan
options.RootFolder = rootPath;
options.ConfigFolder = Path.Combine(rootPath, "Config");
options.DownloadFolder = Path.Combine(rootPath, "Downloads");
options.SettingsPath = Path.Combine(rootPath, "Config", "Settings.cfg");
options.GeneralSettingsPath = Path.Combine(rootPath, "Config", "Settings.cfg");
options.RenderSettingsPath = Path.Combine(rootPath, "Config", "RenderSettings.cfg");
});

services.Configure<JsonSerializerOptions>(options =>
Expand Down
Loading