Skip to content

Commit

Permalink
feat: adds an alpha mapping functionality in DUI and Rhino (#1840)
Browse files Browse the repository at this point in the history
* wip: rhino mappings in dui

* feat(dui): load mapping panel in rhino

* feat(mapping): pulls available types from schema builder

* wip: almost working

* feat(mapping): UI work

* feat(core): fallback to default Objects folder if no converter is found

* feat(mappings): addes reference to Objects and sets it not to be copied

* feat(mappings): adds direct shapes and freeformelements

* feat(mapping): better stream selection

* feat(mappings): existing mappings & display conduit

* feat(mapping): selection and other minor touches

* feat(mappings): clear schema

* fix(rhino): do not build DUI launcher proj on release

* fix(rhino): attempts fixing resx issue on mac

* Revert "fix(rhino): attempts fixing resx issue on mac"

This reverts commit 4a656c9.

* fix(mapping): rhino mac now build but not loads

* fix(rhino): prevents rhino nugets going in the bin folder

* feat(mapping): show mapping tool in rhino mac
  • Loading branch information
teocomi authored Nov 14, 2022
1 parent 931560d commit 663142e
Show file tree
Hide file tree
Showing 45 changed files with 2,344 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{109B3382-634B-408A-8A5C-4CD09CB92641}</ProjectGuid>
<ProjectGuid>{86920221-416E-4A66-A601-3418207E2401}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConnectorGrasshopper</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="GrasshopperAsyncComponent" Version="1.2.3" />
<PackageReference Include="RhinoCommon" Version="7.4.21078.1001" IncludeAssets="compile;build" />
<PackageReference Include="Grasshopper" Version="7.4.21078.1001" IncludeAssets="compile;build" />
<PackageReference Include="RhinoCommon" Version="7.4.21078.1001" IncludeAssets="compile;build" >
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Grasshopper" Version="7.4.21078.1001" IncludeAssets="compile;build" >
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
51 changes: 31 additions & 20 deletions ConnectorRhino/ConnectorRhino.sln
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaHwndHost", "..\Desk
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterGrasshopper6", "..\Objects\Converters\ConverterRhinoGh\ConverterGrasshopper6\ConverterGrasshopper6.csproj", "{9454D346-A629-40E0-9EE2-7C6933ED1530}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConverterGrasshopper7", "..\Objects\Converters\ConverterRhinoGh\ConverterGrasshopper7\ConverterGrasshopper7.csproj", "{CAE61AC4-E81A-4E69-8DD0-07B7CDF77E2E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConverterGrasshopper7", "..\Objects\Converters\ConverterRhinoGh\ConverterGrasshopper7\ConverterGrasshopper7.csproj", "{CAE61AC4-E81A-4E69-8DD0-07B7CDF77E2E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorGrasshopper7", "..\ConnectorGrasshopper\ConnectorGrasshopper7\ConnectorGrasshopper7.csproj", "{109B3382-634B-408A-8A5C-4CD09CB92641}"
ProjectSection(ProjectDependencies) = postProject
Expand All @@ -58,7 +58,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiskTransport", "..\Core\Tr
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ConnectorGrasshopperShared", "..\ConnectorGrasshopper\ConnectorGrasshopperShared\ConnectorGrasshopperShared.shproj", "{0F1FD0C3-875F-4689-9C4A-C56E9AB31102}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorGrasshopper6", "..\ConnectorGrasshopper\ConnectorGrasshopper6\ConnectorGrasshopper6.csproj", "{86920221-416E-4A66-A601-3418207E2401}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectorGrasshopper6", "..\ConnectorGrasshopper\ConnectorGrasshopper6\ConnectorGrasshopper6.csproj", "{86920221-416E-4A66-A601-3418207E2401}"
ProjectSection(ProjectDependencies) = postProject
{9454D346-A629-40E0-9EE2-7C6933ED1530} = {9454D346-A629-40E0-9EE2-7C6933ED1530}
{EAA8D25F-A118-4B16-BC6C-A71463B3C53D} = {EAA8D25F-A118-4B16-BC6C-A71463B3C53D}
Expand All @@ -68,6 +68,19 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorGrasshopperUtils", "..\ConnectorGrasshopper\ConnectorGrasshopperUtils\ConnectorGrasshopperUtils.csproj", "{E2A8E961-6DB6-4474-9E31-0C00FEB4A067}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\ConnectorGrasshopper\ConnectorGrasshopperShared\ConnectorGrasshopperShared.projitems*{0f1fd0c3-875f-4689-9c4a-c56e9ab31102}*SharedItemsImports = 13
..\ConnectorGrasshopper\ConnectorGrasshopperShared\ConnectorGrasshopperShared.projitems*{109b3382-634b-408a-8a5c-4cd09cb92641}*SharedItemsImports = 5
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{6c851417-514b-4e45-9553-408377535b68}*SharedItemsImports = 5
..\ConnectorGrasshopper\ConnectorGrasshopperShared\ConnectorGrasshopperShared.projitems*{86920221-416e-4a66-a601-3418207e2401}*SharedItemsImports = 5
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{9454d346-a629-40e0-9ee2-7c6933ed1530}*SharedItemsImports = 5
ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{a64acbf9-db82-4839-af99-57ed2e7989f4}*SharedItemsImports = 5
ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{b7376ec8-5d3e-47d2-96a7-748552f14c39}*SharedItemsImports = 13
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{b74cb8c1-187b-46a6-b20b-92b8c129f3ee}*SharedItemsImports = 13
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{cae61ac4-e81a-4e69-8dd0-07b7cdf77e2e}*SharedItemsImports = 5
ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{d648bb69-b992-4d34-906e-7a547374b86c}*SharedItemsImports = 5
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{f1703d03-3edb-4389-add9-39c52c6aea19}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Mac|Any CPU = Debug Mac|Any CPU
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -150,14 +163,14 @@ Global
{CAE61AC4-E81A-4E69-8DD0-07B7CDF77E2E}.Release Mac|Any CPU.Build.0 = Release|Any CPU
{CAE61AC4-E81A-4E69-8DD0-07B7CDF77E2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CAE61AC4-E81A-4E69-8DD0-07B7CDF77E2E}.Release|Any CPU.Build.0 = Release|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Debug|Any CPU.Build.0 = Debug|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Release|Any CPU.ActiveCfg = Release|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Release|Any CPU.Build.0 = Release|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Debug Mac|Any CPU.ActiveCfg = Debug Mac|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Debug Mac|Any CPU.Build.0 = Debug Mac|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Debug|Any CPU.Build.0 = Debug|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Release Mac|Any CPU.ActiveCfg = Release Mac|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Release Mac|Any CPU.Build.0 = Release Mac|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Release|Any CPU.ActiveCfg = Release|Any CPU
{109B3382-634B-408A-8A5C-4CD09CB92641}.Release|Any CPU.Build.0 = Release|Any CPU
{E20D7D1E-0FF7-49A5-9AA9-9430901F92BB}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{E20D7D1E-0FF7-49A5-9AA9-9430901F92BB}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{E20D7D1E-0FF7-49A5-9AA9-9430901F92BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand All @@ -166,14 +179,22 @@ Global
{E20D7D1E-0FF7-49A5-9AA9-9430901F92BB}.Release Mac|Any CPU.Build.0 = Release|Any CPU
{E20D7D1E-0FF7-49A5-9AA9-9430901F92BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E20D7D1E-0FF7-49A5-9AA9-9430901F92BB}.Release|Any CPU.Build.0 = Release|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Release|Any CPU.Build.0 = Release|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Debug Mac|Any CPU.ActiveCfg = Debug Mac|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Debug Mac|Any CPU.Build.0 = Debug Mac|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Release Mac|Any CPU.ActiveCfg = Release Mac|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Release Mac|Any CPU.Build.0 = Release Mac|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86920221-416E-4A66-A601-3418207E2401}.Release|Any CPU.Build.0 = Release|Any CPU
{E2A8E961-6DB6-4474-9E31-0C00FEB4A067}.Debug Mac|Any CPU.ActiveCfg = Debug|Any CPU
{E2A8E961-6DB6-4474-9E31-0C00FEB4A067}.Debug Mac|Any CPU.Build.0 = Debug|Any CPU
{E2A8E961-6DB6-4474-9E31-0C00FEB4A067}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2A8E961-6DB6-4474-9E31-0C00FEB4A067}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2A8E961-6DB6-4474-9E31-0C00FEB4A067}.Release Mac|Any CPU.ActiveCfg = Release|Any CPU
{E2A8E961-6DB6-4474-9E31-0C00FEB4A067}.Release Mac|Any CPU.Build.0 = Release|Any CPU
{E2A8E961-6DB6-4474-9E31-0C00FEB4A067}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2A8E961-6DB6-4474-9E31-0C00FEB4A067}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -198,14 +219,4 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1BFED19F-741B-4E11-95C0-753E2058B3D2}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{6c851417-514b-4e45-9553-408377535b68}*SharedItemsImports = 5
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{9454d346-a629-40e0-9ee2-7c6933ed1530}*SharedItemsImports = 5
ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{a64acbf9-db82-4839-af99-57ed2e7989f4}*SharedItemsImports = 5
ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{b7376ec8-5d3e-47d2-96a7-748552f14c39}*SharedItemsImports = 13
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{b74cb8c1-187b-46a6-b20b-92b8c129f3ee}*SharedItemsImports = 13
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{cae61ac4-e81a-4e69-8dd0-07b7cdf77e2e}*SharedItemsImports = 5
ConnectorRhino\ConnectorRhinoShared\ConnectorRhinoShared.projitems*{d648bb69-b992-4d34-906e-7a547374b86c}*SharedItemsImports = 5
..\Objects\Converters\ConverterRhinoGh\ConverterRhinoGhShared\ConverterRhinoGhShared.projitems*{f1703d03-3edb-4389-add9-39c52c6aea19}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,47 @@
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)BIMElements\BIMElementCommands.cs" />
<Compile Include="$(MSBuildThisFileDirectory)BIMElements\BIMElementFilter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entry\ConnectorRhinoCommandWin.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entry\SpeckleMappingsCommandWin.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entry\SpeckleCommandWin.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entry\Plugin.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Resources.Designer.cs">
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UI\MappingBindingsRhino.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\ConnectorBindingsRhino.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MacOSHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entry\ConnectorRhinoCommandMac.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entry\SpeckleCommandMac.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entry\SpeckleMappingsCommandMac.cs" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='Release'">
<Page Include="$(MSBuildThisFileDirectory)UI\Panel.xaml">

<Page Include="$(MSBuildThisFileDirectory)UI\DuiPanel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="$(MSBuildThisFileDirectory)UI\DuiPanel.xaml.cs">
<DependentUpon>DuiPanel.xaml</DependentUpon>
</Compile>
<Page Include="$(MSBuildThisFileDirectory)UI\MappingsPanel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="$(MSBuildThisFileDirectory)UI\Panel.xaml.cs">
<DependentUpon>Panel.xaml</DependentUpon>
<Compile Include="$(MSBuildThisFileDirectory)UI\MappingsPanel.xaml.cs">
<DependentUpon>MappingsPanel.xaml</DependentUpon>
</Compile>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Resources.resx">
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<Generator>ResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)Resources\icon.ico" />
</ItemGroup>

</Project>
71 changes: 60 additions & 11 deletions ConnectorRhino/ConnectorRhino/ConnectorRhinoShared/Entry/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class SpeckleRhinoConnectorPlugin : PlugIn
private static string SpeckleKey = "speckle2";

public ConnectorBindingsRhino Bindings { get; private set; }
public MappingBindingsRhino MappingBindings { get; private set; }

private bool SelectionExpired = false;
internal bool ExistingSchemaLogExpired = false;


public static AppBuilder appBuilder;
Expand All @@ -49,9 +53,18 @@ public void Init()


Bindings = new ConnectorBindingsRhino();
MappingBindings = new MappingBindingsRhino();

RhinoDoc.BeginOpenDocument += RhinoDoc_BeginOpenDocument;
RhinoDoc.EndOpenDocument += RhinoDoc_EndOpenDocument;

//Mapping tool selection
RhinoDoc.ActiveDocumentChanged += RhinoDoc_ActiveDocumentChanged;
RhinoDoc.SelectObjects += (sender, e) => SelectionExpired = true;
RhinoDoc.DeselectObjects += (sender, e) => SelectionExpired = true;
RhinoDoc.DeselectAllObjects += (sender, e) => SelectionExpired = true;
RhinoDoc.DeleteRhinoObject += (sender, e) => ExistingSchemaLogExpired = true;
RhinoApp.Idle += RhinoApp_Idle;
}
catch (Exception ex)
{
Expand All @@ -63,17 +76,17 @@ public void Init()

public static void InitAvaloniaMac()
{
var rhinoMenuPtr = MacOSHelpers.MainMenu;
var rhinoDelegate = MacOSHelpers.AppDelegate;
var titlePtr = MacOSHelpers.MenuItemGetTitle(MacOSHelpers.MenuItemGetSubmenu(MacOSHelpers.MenuItemAt(rhinoMenuPtr, 0)));
var rhinoMenuPtr = MacOSHelpers.MainMenu;
var rhinoDelegate = MacOSHelpers.AppDelegate;
var titlePtr = MacOSHelpers.MenuItemGetTitle(MacOSHelpers.MenuItemGetSubmenu(MacOSHelpers.MenuItemAt(rhinoMenuPtr, 0)));

appBuilder = BuildAvaloniaApp().SetupWithoutStarting();
appBuilder = BuildAvaloniaApp().SetupWithoutStarting();

// don't use Avalonia's AppDelegate.. not sure what consequences this might have to Avalonia functionality
MacOSHelpers.AppDelegate = rhinoDelegate;
MacOSHelpers.MainMenu = rhinoMenuPtr;
MacOSHelpers.MenuItemSetTitle(MacOSHelpers.MenuItemGetSubmenu(MacOSHelpers.MenuItemAt(rhinoMenuPtr, 0)), MacOSHelpers.NewObject("NSString"));
MacOSHelpers.MenuItemSetTitle(MacOSHelpers.MenuItemGetSubmenu(MacOSHelpers.MenuItemAt(rhinoMenuPtr, 0)), titlePtr);
// don't use Avalonia's AppDelegate.. not sure what consequences this might have to Avalonia functionality
MacOSHelpers.AppDelegate = rhinoDelegate;
MacOSHelpers.MainMenu = rhinoMenuPtr;
MacOSHelpers.MenuItemSetTitle(MacOSHelpers.MenuItemGetSubmenu(MacOSHelpers.MenuItemAt(rhinoMenuPtr, 0)), MacOSHelpers.NewObject("NSString"));
MacOSHelpers.MenuItemSetTitle(MacOSHelpers.MenuItemGetSubmenu(MacOSHelpers.MenuItemAt(rhinoMenuPtr, 0)), titlePtr);

}

Expand Down Expand Up @@ -117,7 +130,8 @@ private void RhinoDoc_EndOpenDocument(object sender, DocumentOpenEventArgs e)
RhinoApp.CommandLineOut.WriteLine($"Speckle error - {ex.ToFormattedString()}");
}
#else
Rhino.UI.Panels.OpenPanel(typeof(Panel).GUID);
Rhino.UI.Panels.OpenPanel(typeof(DuiPanel).GUID);
Rhino.UI.Panels.OpenPanel(typeof(MappingsPanel).GUID);
#endif

}
Expand Down Expand Up @@ -155,8 +169,11 @@ protected override LoadReturnCode OnLoad(ref string errorMessage)
Init();

#if !MAC
System.Type panelType = typeof(Panel);
System.Type panelType = typeof(DuiPanel);
Rhino.UI.Panels.RegisterPanel(this, panelType, "Speckle", Resources.icon);

System.Type mappingsPanelType = typeof(MappingsPanel);
Rhino.UI.Panels.RegisterPanel(this, mappingsPanelType, "Speckle Mapping Tool", Resources.icon);
#endif
// Get the version number of our plugin, that was last used, from our settings file.
var plugin_version = Settings.GetString("PlugInVersion", null);
Expand Down Expand Up @@ -197,5 +214,37 @@ protected override LoadReturnCode OnLoad(ref string errorMessage)
return LoadReturnCode.Success;
}
public override PlugInLoadTime LoadTime => PlugInLoadTime.AtStartup;


private void RhinoApp_Idle(object sender, EventArgs e)
{
if (SelectionExpired)
{
SelectionExpired = false;
MappingBindings.UpdateSelection(MappingBindings.GetSelectionInfo());
}

if (ExistingSchemaLogExpired)
{
ExistingSchemaLogExpired = false;
MappingBindings.UpdateExistingSchemaElements(MappingBindings.GetExistingSchemaElements());
}

}
private void RhinoDoc_DeselectObjects(object sender, Rhino.DocObjects.RhinoObjectSelectionEventArgs e)
{
SelectionExpired = true;
}

private void RhinoDoc_SelectObjects(object sender, Rhino.DocObjects.RhinoObjectSelectionEventArgs e)
{
SelectionExpired = true;
}

private void RhinoDoc_ActiveDocumentChanged(object sender, DocumentEventArgs e)
{
SelectionExpired = true;
// TODO: Parse new doc for existing stuff
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Avalonia;
Expand All @@ -12,7 +12,7 @@

namespace SpeckleRhino
{
#if !MAC
#if !MAC
public class SpeckleCommandWin : Command
{

Expand All @@ -31,7 +31,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode)
try
{

Rhino.UI.Panels.OpenPanel(typeof(Panel).GUID);
Rhino.UI.Panels.OpenPanel(typeof(DuiPanel).GUID);
return Result.Success;
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Avalonia;
using Avalonia.Controls;
using Avalonia.ReactiveUI;
using DesktopUI2.ViewModels;
using DesktopUI2.ViewModels.MappingTool;
using DesktopUI2.Views;
using Rhino;
using Rhino.Commands;
using Speckle.Core.Models.Extensions;

namespace SpeckleRhino
{
#if MAC
public class SpeckleMappingsCommandMac : Command
{

public static SpeckleMappingsCommandMac Instance { get; private set; }

public override string EnglishName => "SpeckleMappings";
public static Window MainWindow { get; private set; }

public SpeckleMappingsCommandMac()
{
Instance = this;
}

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{

try
{
if (MainWindow == null)
{
var viewModel = new MappingsViewModel(SpeckleRhinoConnectorPlugin.Instance.MappingBindings);
MainWindow = new MappingsWindow
{
DataContext = viewModel
};
}

MainWindow.Show();
MainWindow.Activate();
return Result.Success;
}
catch (Exception e)
{
RhinoApp.CommandLineOut.WriteLine($"Speckle Error - {e.ToFormattedString()}");
return Result.Failure;
}
}



}
#endif
}
Loading

0 comments on commit 663142e

Please sign in to comment.